[Solved] Automatically subset data frame by factor


maybe not the best way to do it, but will get the job done.

vars_df = unique(df$x)

for (i in 1:length(vars_df)) {
assign(paste0(vars_df[i]), df %>% filter(x == vars_df[i]), envir = .GlobalEnv)
}

solved Automatically subset data frame by factor