-1
I would like to generate subsets of a dataframe via loop. However, when executing this code I do not get the 5 objects.
list <- list("CO", "N", "NE", "S", "SE")
for (i in list) {
df_name <- paste("Regiao_",i)
df <- df_AI[df_AI$Regiao == i,]
df[[df_name]]<- df
}
Perfect Carlos, that was it! Thank you very much. Just an additional question. What’s the difference between paste0 and Paste (using Sep ="") ?
– Joyce Maia
None,
paste0
it’s just a shortcut.– Carlos Eduardo Lagosta
Consider the response of Rui Barradas, she is more practical (among other things, by discarding the use of loop).
– Carlos Eduardo Lagosta