I have a data frame with id column
Whats the best way to split it into list of data frames based on id column and remove the id column in each one of them
I have a data frame with id column
Whats the best way to split it into list of data frames based on id column and remove the id column in each one of them
Using base R:
data <- split(data, data$id)
data <- lapply(data, function(df) df[, -which(names(df) == "id")])
Using the tidyverse:
data <- data %>%
split(data$id) %>%
map(~ select(.x, -id))