All Questions
8,306
questions
1
vote
2
answers
26
views
How to get the probability data from survfit function?
I plot cumulative incidence curves based on data from the survival::survfit() function. Following this vignette I do something like the following:
library(survival)
mgus2$etime <- with(mgus2, ...
4
votes
5
answers
49
views
How to transfer dataframe `raw_df` to `list` row by row?
How to transfer data frame raw_df to list row by row? Desired output: wished_list
raw_df <- data.frame(cat=c('a','b','c'),value=c('high','mid','low'))
wished_list <- list(a='high',b='mid',c='...
0
votes
2
answers
36
views
How to update list value according given value
In below mlist object, how does one update the value to 'character' for all elements which currently are c("ordered", "factor")?
library(tidyverse)
mlist <- sapply(diamonds,...
-1
votes
0
answers
25
views
How can I extract longitudes and latitudes from a big List file [closed]
I am trying to extract the longitude and latitude columns from a vessel data list in RStudio. The data already contains longitude and latitude columns with numbers, as I can clearly see in the Excel ...
0
votes
2
answers
65
views
Transfer dataframe to list and not include NA value
How to transfer dataframe to list and not include NA value ? Thanks!
There is dataframe ori_df
library(tidyverse)
ori_df <- data.frame(category=c('a','b',NA),subcategory=c('w',NA,'Z'))
Below code ...
0
votes
1
answer
52
views
Is there a way to loop through a custom function to generate multiple ggplot2 graphs in R?
I created a custom function in R to standardize multiple graphs. The function is essentially as follows:
CustomFunction <- function(SpecificEvent) {
ggplot()+
geom_point(data = df[df$...
1
vote
1
answer
24
views
Long to wide format based on variable suffixes in tidyverse in R
I wonder if there is a way for my DATA to be reformatted to my Desired_output below?
Specifically, for each unique study, we stick together a pair of pre and postNUMBER together, separately for T and ...
0
votes
1
answer
65
views
How to check if elements of one list are also elements of another list in R
Let's assume I have two lists in R, a long one and a shorter one, for example:
list1 = list(571,572,573,574,561,562,563,564,595,570,571,573)
list2 = list(c(571,564,565,600))
Please note that numbers ...
6
votes
2
answers
92
views
Filter list of lists with purrr::keep
I have a reprex as follows:
library(dplyr)
library(purrr)
df1 <- data.frame(
col1 = 1:5,
col2 = 6:10
)
df2 <- df1 %>%
mutate(col3 = 1:5)
ls <- list(
a = list(df1 = df1),
b = ...
0
votes
1
answer
31
views
How to convert results of simulated t-tests into a dataframe?
I am trying to get better intuition about statistical testing by using simulations in R. I would like to simulate t-test results and explore the variation in estimates, p-values etc. I manage to run ...
0
votes
1
answer
37
views
Is there a way to use data.frame to iterate through a list of texts in R?
I used readLines from gutenbergr to read my list of legal cases into R. The code looks like this:
my_list <- list.files(path = "C:\\Users\\Ben Tice\\Documents\\R Stuff\\UW Job\\Cases\\data\\...
0
votes
0
answers
69
views
Find relative paths of all fields, at all depths of a nested list or data.frame in R
Objective
This question is related to, but is not covered or answered by 73083349, 63074814, 76103332, 70272176, 59820309, 74276459.
I'm trying to find/create an efficient (read: fast) function in R ...
3
votes
3
answers
102
views
Creating a frequency table for each column in a data frame using a loop and storing the results in a list
I have a data frame, with each column containing data on group membership. For each column, I would like to calculate the frequency of each group in that column as well as the percentage of each group ...
0
votes
1
answer
49
views
R adding list to a list and different data type to that list in a list
I want to make a list that represents rows to print; a row contains text and numeric data; I make a toplist that contains for each row a list to print.
The list for rows are constructed from stat.desc ...
0
votes
3
answers
57
views
Bind each dataframe in a list to each dataframe of another list
I have two lists composed of dataframes (in the example 3 dataframes per list). I would like to bind the rows of dataframes of the two lists.
I was thinking to couple rbind() with Map(), map() or ...