This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Split multi-year dataframe into smaller dataframes by year. | |
# This will label the new dataframes as "year1997", "year1998", etc. | |
# Replace DATAFRAME below with the name of your dataframe object | |
invisible(lapply(split(DATAFRAME, DATAFRAME$year), function(x) { | |
assign(paste0("year", x$year[1]), x, pos=.GlobalEnv) })) | |
# You can change the sort value to country or whatever other variable | |
# you like by changing all instances of "year" to whatever the other |
NewerOlder