How to reset a sequence in a R dataframe's column, based on the levels of a different column

How to reset a sequence in a R dataframe's column, based on the levels of a different column Problem Description: I have data that logs subject and session information in columns like so: > Subject <- c(rep("A", 6), rep("B", 7)) > Session <- c(rep(1, 3), rep(2, 3), rep(8, 4), rep(9, 3)) > df <- data.frame(Subject, … Read more

Programatically generate tabset panels of datatables in Quarto

Programatically generate tabset panels of datatables in Quarto Problem Description: This question is similar, but not identical to this one. Basically, I have a number of tables that I would like to show in tabsets using DT::datatable(). Unfortunately, I can’t figure out how. The following code works, but I need to manually type all the … Read more

Do results of survival analysis only pertain to the observations analyzed?

Do results of survival analysis only pertain to the observations analyzed? Problem Description: Hey guys, so I taught myself time-to-event analysis recently and I need some help understanding it. I made some Kaplan-Meier survival curves. Sure, the number of observations within each node is small but let’s pretend that I have plenty. K <- HF … Read more

How do I sort dates by month in R?

How do I sort dates by month in R? Problem Description: new R student here. I am trying to sort data by month. Here is a sample of the data I need to use, followed by the code, then my results. Any tips for how to accomplish this?! I’m super stuck… This is the latest … Read more

Using substring of file name to create new variable in a list of dataframes

Using substring of file name to create new variable in a list of dataframes Problem Description: I have a directory with a set of .rds files containing dataframes: files <- c("file_2022-11-30.rds", "file_2022-12-01.rds") I want to read each file into a list and then assign a new column to each dataframe in the list that contains … Read more

Categories r Tags

2 separate legends for the same aesthetic ggplot2

2 separate legends for the same aesthetic ggplot2 Problem Description: I am trying to get 2 separate legends for different groups of variables when using "facet_wrap" in ggplot 2. Basically I want to break up the legend into 2, one with "Yes/No" and one with "Sometimes/Never" and have each one close to those variables that … Read more

Check if the corresponding elements in two different list of dataframes are equal

Check if the corresponding elements in two different list of dataframes are equal Problem Description: I have a two separate list of dataframes. The first list of dataframe is lst1 $`1` [1] 8.523769e-05 6.615035e-05 1.177740e-04 1.173578e-04 8.798214e-05 6.328218e-05 4.768889e-05 3.658710e-05 [9] 1.294623e-05 1.179838e-06 1.010590e-06 5.204994e-07 2.128048e-06 6.876634e-06 6.011750e-06 5.160903e-05 [17] 5.318722e-05 1.029438e-04 1.173397e-04 $`2` [1] … Read more

Sorting with order in R with the whole data frame

Sorting with order in R with the whole data frame Problem Description: I have a data frame that I’d like to order based on a vector of IDs and on the all the columns of another data frame. id.namestest = data.frame(test = NA, id= c("id1", "id2", "id3","id3", "id2", "id1")) head(admix) # V1 V2 V3 # … Read more

We use cookies in order to give you the best possible experience on our website. By continuing to use this site, you agree to our use of cookies.
Accept
Reject