I'm new to R, have some experience with python. I needed to split a dataframe into 42 pieces, which i did, but the result gives me a list, so now i need to extract and export each dataframe from that list. I thought of using a loop (something you would do in python, but I can't get it to work. I hope that you can help me.
num_groups = 42
lista <- RSI_SGR1702_MAYO %>%
group_by((row_number()-1) %/% (n()/num_groups)) %>%
nest %>% pull(data)
# Loop
for(i in (1:42)){
RSI_SGR[[i]] <- as.data.frame(lista[[i]])
names(RSI_SGR[[i]]) <- paste(names(RSI_SGR1702_MAYO)) # Replace colnames
i = i + 1
}
I know this probably isn't the correct syntax for R, but i can't find an answer. The result shoud be 42 independent dataframes stored and ready to be exported. Thanks in advance.