510,949 questions
Advice
0
votes
5
replies
60
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
1
replies
29
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
37
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
65
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
86
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
50
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 ...
0
votes
2
answers
99
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 ...
2
votes
1
answer
76
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
48
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
73
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
63
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
94
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
74
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
147
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
60
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
55
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
34
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
29
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
36
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
116
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
70
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
114
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
72
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
69
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
98
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
99
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
42
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
79
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
76
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
92
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
67
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
52
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
98
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
104
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
57
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
108
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
90
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
148
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<...
-2
votes
0
answers
108
views
read_html(url) issues cannot open the connection [closed]
I do
read_html("https://finngen.gitbook.io/documentation")
which issues
Error in open.connection(x, "rb") : cannot open the connection
However, I can open https://finngen....
0
votes
1
answer
77
views
tbl_regression not showing p-values when compiler is running on R Markdown
I am trying to run tbl_regression() on lme4 models. In R Markdown, the p-values can be seen in the output there. However, when I try to compile to a pdf or html, the p-values disappear, while the ...
Advice
0
votes
5
replies
128
views
Find and process @concept tags in .Rd files
In several packages, I've added @concept tags to Roxygen documentation for datasets. I'd like to process these to create a datasets.csv file for the package, that would include these as tags for each ...
0
votes
1
answer
57
views
sample() returning vector of size-1 [duplicate]
In R version 5.4.1, when I set the size parameter of sample() in the form 1000*(1-i), I sometimes get a output that is 1 value too short; this only seems to happen at values of i above 0.7, but the ...
0
votes
2
answers
82
views
Control levels the marginaleffects library uses when stratifying a numeric variable
I'm trying to use the marginaleffects library in R to get the estimates of a bunch of interaction effects from a bunch of different models. When I pass it an interaction that has a continuous ...
1
vote
1
answer
92
views
Memory issue for large raster in R
I am trying to use slope_rast from rtrend R package for a large raster like
library(rtrend)
library(terra)
f = system.file("rast/MOD15A2_LAI_China_G050_2001-2020.tif", package = "...
0
votes
0
answers
104
views
Reuse function in a package
I'm trying to reuse a function from one of my packages that installs the latest version of my package in another package. The original package is {pkgA} and the function is update(). The function uses ...
3
votes
1
answer
86
views
Using sjPlot::plot_model to generate plot of lmer model with log-transformed dependent variable
I've got a lmer model that looks similar to the following example:
library(lme4)
df<-data.frame(var_1=c(1.1,2.2,2.1,4.4,4.4,5.6,4.4,2.6,3.3,3.3,3.9,3.8,1.1,1.3,1.4,1.1,1.8,2.1),
...
0
votes
0
answers
134
views
Problems with data visualization in R [closed]
I am working with the following code:
library(sjPlot)
daten_short1<-structure(list(AR = c(0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1,
0, 0),
...
-3
votes
2
answers
144
views
Blackhole assignment in R [duplicate]
Suppose I have the following:
df1 <- data.frame(id=c(1,2,3))
df2 <- data.frame(id=c(2,3,4))
I want to print: (1) The number of IDs in df1 but not in df2, (2) the number of IDs in df2 but not in ...