510,720 questions
Advice
0
votes
1
replies
36
views
2 dimensional version of "pretty" in R
In R it is generally convenient to use a function like "pretty" when deciding intervals to plot in a graph that are useful and readable to the general audience. In R if you are producing a ...
2
votes
0
answers
43
views
How to redirect output from rlang:inform messages?
Pretty much what the title says. A little more background: guidance I have received from CRAN suggests having packages use rlang::inform(), rlang::abort(), and rlang::warn() to produce output for ...
0
votes
0
answers
20
views
Post-stratification weights and weighted standard deviation [migrated]
I have a survey for which I calculated post-stratification weights of the form proportion in the population/proportion in the sample for cross-categories age, sex and education. I am analysing a ...
Advice
0
votes
3
replies
69
views
How to compare corresponding columns between data frames and keep the highest value?
I have two data frames with one ID column (all IDs are in both data frames) and 20 other columns with a value of 0 or 1. I would like to update one data frame by row (or rather ID, since the data ...
3
votes
1
answer
110
views
Using purrr::pmap within a function
I am interested in using purrr::pmap() within a function. I am having trouble passing the data-variable names from my function to the anonymous function used witin pmap()
library("purrr")
...
-3
votes
0
answers
50
views
I want to create character with name , but failed .Anyone can help on it? [duplicate]
I want to create chr with name , but failed .Anyone can help on it ?
the wished result as wished_char_with_name
library(tidyverse)
# failed code
char_with_name <- diamonds %>% select(cut,...
6
votes
1
answer
83
views
pivot_longer() with several sets of columns
I've done some looking, but can't figure out the syntax for my specific situation.
I need to group data like the following:
library(tibble)
data_example <- tribble(
~drug_name, ~ecoli_median_molar,...
1
vote
0
answers
19
views
"All columns in a tibble must be vectors" when attempting to connect to Databricks via `sparklyr::spark_connect`
I'm having issues connecting my local RStudio setup to my company's Databricks databases via sparklyr.
When I use
sc <- sparklyr::spark_connect(cluster_id = Sys.getenv("DATABRICKS_CLUSTER_ID&...
Advice
0
votes
2
replies
43
views
Smooth and smooths by nominal factor of same predictor in same GAM
Is it a good idea to use both a smooth and smooths by a nominal factor of the same predictor in the same GAM? Let's assume we want to model encounters as a function of species and space (long, lat).
...
6
votes
4
answers
242
views
Counting instances of genotype strings where order is irrelevant within locus
I'm looking at genetics punnet squares for two homologous chromosome pairs, which I've modeled in R like this:
# Punnet square for two homologous chromosome pairs
col_names<-c("AB", "...
2
votes
0
answers
51
views
R officer package - run_reference function not working as expected [duplicate]
I'm struggling with a problem of references not colored as desired for docx output. In the officer package there's a function run_reference. It takes a prop argument that allows setting custom props ...
0
votes
0
answers
98
views
R user library on macOS
I recently installed R 4.5.2 on a fresh install of macOS Tahoe 26.3.
When I run .libPaths() only the following library is returned:
[1] "/Library/Frameworks/R.framework/Versions/4.5-arm64/...
2
votes
1
answer
61
views
Calculating accompanying cohen's d for estimated marginal means in R
I am completing some data analysis at the request of a supervisor on a R script that was completed by someone else. The script used MICE to create an imputed data set and then computed a LMM with a ...
-1
votes
1
answer
133
views
Prevent lines and arrows from intersecting with each other
I have this diagram in R:
library(DiagrammeR)
grn <- '#66BB6A'
red <- '#EF5350'
nvy <- '#1B3A5C'
gry <- '#BBBBBB'
lag_diagram <- grViz(paste0("
digraph lag_grid {
graph [
...
4
votes
1
answer
81
views
epiR::epi.conf() (ctype = "inc.risk") returns different value than manual cumulative incidence
I’m trying to compute cumulative incidence with epiR::epi.conf() and the estimate doesn't match the simple manual calculation.
I have 13 events out of 107 individuals (13 events, 94 non-events).
...