510,920 questions
1
vote
0
answers
30
views
Why does the "$" operator not run when using the unique() function while trying to extract a specific variable from a dataset
I am trying to run a for loop that will extract variables from two different datasets into one data frame. One dataset contains information on estuaries of the West Coast of North America, the other ...
0
votes
0
answers
34
views
How to align the data upload button with other types of button?
I am writing an R Shiny app and use CSS to format the buttons on the header and footer of the page. I am running into a sticky situation with the Upload button, where no matter how I configure, it ...
Advice
0
votes
1
replies
55
views
Regression analysis
How should I handle a mass-point in the dependent variable when running OLS regression in R?
I’m working with a a household expenditure dataset (Living Costs 2019) where the dependent variable is the ...
4
votes
1
answer
125
views
data.table programming with variable columns
I have a data.table with a set of columns and I'm trying to create a new column as a pasted string of several of them. The number of the columns can change from time to time, but is based on a column ...
-1
votes
0
answers
50
views
Accounting for temporal autocorrelation with irregular time lags with GAM model in R [closed]
I am running a GAM model with bam in the mgcv package in R.
The dataset in the model is calculated from mean hourly speeds for individual fish from position data (x,y, datetime).
AR_hourly <- ...
0
votes
0
answers
37
views
Interactive Brokers TWS API: Checking order status with R/IBrokers [closed]
How can I use the IBrokers package to check the status of my order e.g. get fill price, size and execution time when it takes place?
Unlike with reqMktData placeOrder takes no argument as CALLBACK ...
0
votes
1
answer
99
views
How to create 2 new columns in R (date difference + convert Seasons to minutes)? [duplicate]
I am new to R and trying to create two new variables from my dataset.
My data frame is called netflix and it contains these relevant columns:
date_added and duration
Example values:
date_added: "...
0
votes
0
answers
65
views
Why Does Trying to Load rJava Keep Resulting in an Error?
I am trying to run r5r for a transit network based analysis.
I am using R 4.4.3 in Positron on Fedora 41.
Some context for me is that I have a couple years of R underneath my belt, but I am absolutely ...
-1
votes
0
answers
61
views
comparison (<) is possible only for atomic and list types [closed]
I have the error "comparison (<) is possible only for atomic and list types" in this loop in R. I am trying to do wilcoxon test, t-student test and sign test but gives me the error. In ...
1
vote
1
answer
172
views
Is there an error in the data.table vignette about `x[i, on=, nomatch]` left join behavior?
I am trying to confirm how joins work in data.table, and I think I found an inconsistency in the official vignette:
https://cran.r-project.org/web/packages/data.table/vignettes/datatable-joins.html
My ...
Advice
0
votes
5
replies
84
views
R Shiny - Is there a way to obtain all inputs whose name ends with a suffix as reactives?
I know I can retrieve all inputs as a list of reactives with reactiveValuesToList but how would I go about getting only those with a given suffix (e.g. *-filter)?
I would need it to feed observeEvent, ...
Tooling
0
votes
2
replies
63
views
Small resolution changes in SpatRaster
I have two very large Spatrasters (exp1012 and exp1721) which I would like to stack over each other. However, their resolution changes slightly* so I cannot stack them into a single SpatRaster as they ...
1
vote
0
answers
59
views
Recommended RStan compiler flags for gcc
I need to install RStan and I want to make sure that it's as efficient as possible. I'm using gcc. I'm reading this guide from 2022.
Luckily, the Stan developers built an option called STAN_CPP_OPTIMS
...
2
votes
1
answer
75
views
Having trouble with R's torch and tensor dimensions
I am trying to follow along with this webpage: https://jtr13.github.io/cc21fall2/tutorial-on-r-torch-package.html
I am trying to understand R's implementation of PyTorch.
I am having some trouble with ...
3
votes
1
answer
98
views
How to show parent-level categories in tbl_hierarchical() when child-level values are NA?
I want to generate the Study Completion Status in the ds table like this:
Study Completion Status in the ds table
However, when EOSSTT == "COMPLETED" or "ONGOING", the value of ...
0
votes
0
answers
61
views
R GEE Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels
I got this error when running GEE with unstructured correlation.
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
contrasts can be applied only to factors with 2 or more ...
2
votes
2
answers
151
views
Two-digit year error when converting string variable into date variable (dates span from 1962 to 1981) [duplicate]
I have a dataset that spans 1962 to 1981. The dates are formatted as a string in a single field like this: 15-Mar-62.
When I use the as.Date function to convert the field into a date format (so I can ...
4
votes
2
answers
130
views
Parallel computing in R using Julia
This is kinda of a niche question because it requires having working with Julia and R at the same time, but I've hit a wall with an issue when using {furrr} to process code in parallel and I decided ...
-2
votes
0
answers
56
views
Syntax issue? Adding life stage to reproductive rate [closed]
My current model estimates the young of the year [t,1] for each year as a product of how many adult females [t,3] are surviving multiplied by litter size (LS), pregnancy rate (PR), and newborn ...
Advice
1
vote
2
replies
81
views
Show the timezone when printing a data frame with a `POSIXct` column
Is there a simple way (i.e., not involoving writing a print() method) to show the timezone when printing a data frame with a POSIXct column ?
as.data.frame(Sys.time())
# Sys.time()
# 1 2025-...
2
votes
0
answers
67
views
Costing according to a schedule using the hesim package. All strategies at all times?
I am trying to produce a partitioned survival model (PSM) using the hesim package.
When supplying a dataframe of costs to stateval_tbl(), which is then passed to create_StateVals(), it seems every ...
0
votes
1
answer
113
views
Creating a bar graph with categories derived from multiple columns
I have generated the following summary of means and SDs for two parameters, SAR and ER, for several multi-column categories:
structure(list(category = c("DIT GROUP\nCR 16.0005\nADB", "...
0
votes
0
answers
83
views
How can I adjust branches that are outside my phylogeny?
I am working on phylogenetic tree manipulation in R, and I'm encountering a visualization issue with one of my trees. A few branches are being drawn with lengths that go past the terminal nodes (tips)
...
0
votes
1
answer
153
views
Construct a simple loop to create new data frames in R [closed]
I have a number of data.frames, with names apple, banana, and coffee. I want to create, and then export, new dataframes in a for-loop corresponding to each one, call them apple_new, banana_new, and ...
1
vote
1
answer
69
views
R/exams docx output does not include images
I'm creating a written exam and am having trouble getting exams2pandoc() to include PNG question images in the word docx output. When I test with exams2html() instead, it successfully includes the ...
0
votes
0
answers
58
views
Shiny nested module using DTedit
Assuming following app:
library(shiny)
library(DTedit) # install via devtools::install_github('jbryer/DTedit')
# outer module ui
outer_ui <- function(id) {
ns <- NS(id)
# inner module ui
...
-2
votes
0
answers
35
views
How to visualize interactions from a scaled, log-transformed GLMM with Gamma response in R? [closed]
I’m working with a fictional dataset to practice plotting a generalized linear mixed model (GLMM) and would like advice on good visualization strategies.
Here’s the model I fit using glmer from the ...
Advice
0
votes
1
replies
30
views
Check assumptions of mixed effects cox model
I am running a mixed effects cox model using coxme in R, and I cannot find any information on how to check model assumptions for this type of model. I have seen the older chats, which have recommended ...
0
votes
0
answers
39
views
RStudio Server scans all folders if _quarto.yml is existed [closed]
I want to use Quarto in RStudio Server. My folder has lots of smaller files. The Rstudio is stopped to work when I open a project which contain a _quarto.yml file.
It seems RStudio scan all folders ...
1
vote
2
answers
117
views
How do I erase these labels in ggbarstats plot?
This is my code:
daten_short<-structure(list(Asthma = c(0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
0, 0, 0, 1, 0, 0, 1, 1), Genetische_PräAs = c("Nein", &...
0
votes
1
answer
79
views
Build forest plot for estimate comparison of multiple models using ggplot2. How to add text of CI?
I am trying to create a forest plot to compare estimates of different models.
Tho goal is to plot all the estimates of the same predictor for the different models so they are comparable.
For this I ...
2
votes
1
answer
115
views
Why are my confidence and prediction intervals not plotting?
I'm trying to create a model for a data set from a paper about tooth wear, and I was able to create linear models with prediction and confidence intervals for three of the four teeth we're looking at, ...
-1
votes
0
answers
39
views
Why 'Error in vec_assign(): Can't convert to match type' calling toRelational()? How do I fix it? [closed]
An XML file of the ORPHA codes, the coding system of rare diseases, is publicly available at the ORPHANET website as Orphanet_Nomencature_Pack_EN.
I downloaded the English version and imported into R ...
Best practices
0
votes
6
replies
73
views
Loading additional functions into a Shiny app
I am developing a Shiny app that allows to download logdata from a database. Users might not necessarily need the "raw" logdata but some kind of different "shape of data", e.g. ...
3
votes
1
answer
73
views
custom size for addEasyprint with leaflet.extras2
I'm creating some html files for colleagues where they can explore a leaflet map interactively, then save a copy for presentations.
Unfortunately the downloads from addEasyprint in leaflet.extras2 are ...
0
votes
1
answer
105
views
Why is my exported Google sheets adding trailing zero to character when read by read_excel in R?
I have a data sheet that I am entering in Google Sheets and importing into R as an .xslx file. One of the columns in the datasheet is a character variable representing the specimen numbers of each ...
1
vote
1
answer
100
views
How can I prevent R "no visible binding / global function"?
I'm building a web app and I have two linter issues:
no visible binding for global variable 'xxx'
no visible global function definition for 'xxx'
I have multiple files to keep my utils-like and ...
0
votes
0
answers
45
views
Loading Newick file into R producing error [closed]
I am trying to load a phylogenetic tree from TimeTree as a Newick file into R. I downloaded the file from TimeTree onto my laptop and attempted to "load workspace" into R, but it came up ...
2
votes
1
answer
80
views
Creating a unique animal identifier using multiple id columns some with missing data [duplicate]
I have a data set of mark-recapture data with the fields species, ear_tag, pit_tag, and sample_id. I need to create a animal_id column so I can identify each unique animal which unfortunately has ...
0
votes
2
answers
78
views
Positioning of geom_text with negative stacked geom_bar
I have a ggplot2 plot with both positive and negative geom_bar values. For the geom_bar that shows the negative values, I’m having an issue where the position of geom_text is not displayed correctly. ...
2
votes
1
answer
94
views
Area with color gradient
I created this simple ggplot2 plot and would like to generate a vertical color gradient for the area between y = 0 and the respective values, possibly using geom_ribbon (?). However, I haven’t found ...
0
votes
0
answers
69
views
R and visnetwork: avoid node overlap
Please have a look at the reprex at the end of the post.
I use visNetwork to generate an interactive taxonomy (think of it as a graph).
Everything is fine, apart from the node overlap, in particular ...
0
votes
0
answers
53
views
How do you connect to RSelenium local server with rsDriver()?
I was meddling with the RSelenium package when I type in the following code:
library(tidyverse)
library(rvest)
library(RSelenium)
rs_driver_lone<-rsDriver(browser="chrome",phantomver=NULL)...
1
vote
2
answers
100
views
Using leaflet in R shiny to zoom to a postcode entered by user
I've collected longitude/latitude coordinates of roads in Hertfordshire. I want the user to enter a postcode in the app, and for the app to center the map on that postcode. The map has dots for each ...
1
vote
1
answer
107
views
Combining Two Dataframes Based on Multiple Conditions & Removing Rows that Don't Match
I need to combine two dataframes: one with detection data and another with the metadata for those detections.
The column names of the first dataframe, which is called rt_det are:
tag_id, power, ...
-5
votes
0
answers
58
views
How do I uninstall R completely to fix install.packages() function problem? [closed]
I am running R on linux mint 22.2 Cinnamon and my install.packages() command is not functionning. So I tried to uninstall R a first time, but apparently all of my R data was not uninstalled. So I ...
-2
votes
0
answers
109
views
R dplyr: How to filter murders dataset by region and homicide rate and select only specific columns without triggering validation errors [closed]
I need some help in my coding related to Basic Data Wrangling. The instructions for coding in R are as follows:
Let's say you want to live in the Northeast or West in US and you want the homicide rate ...
1
vote
0
answers
92
views
Is it possible to manually crop images loaded into RMarkdown documents via knitr::include_graphics?
I'm fairly new to rmarkdown but had a question about images. I'm trying to generate a document that displays images from the Web (i.e., accessible with a URL, not a file path on my computer). The ...
0
votes
0
answers
149
views
Error: Package or Namespace Load Failed for janitor in Quarto Only
When I ran the following Quarto file
---
title: "Step 2: Data Import and Schema Sanity Check"
author: "Dr. James Daniel"
date: today
format:
html:
toc: true
code-fold: ...
0
votes
0
answers
38
views
svyCreateTableOne cannot process factors
I tried to produce a table 1 from a code which worked perfectly well a year ago, but doesn't work now.
Here a simple example :
library(tableone)
library(survey)
age<- c(55,66,77,33,44)
gender<...