I have a list of dataframes (about 30). I want to change the order of the rows within these dataframes to a specific order. I have made a small example to illustrate my problem
df1 <-
data.frame(
stof = c("CO2", "nh3", "so2", "ch4", "pm10", "pm5"),
auto = c(1, 2, 3, 6, 2, 3),
boat = c(4, 5, 6, 7, 5, 5)
)
df2 <-
data.frame(
stof = c("CO2", "nh3", "so2", "ch4", "pm10", "pm5"),
auto = c(3, 2, 1, 8, 8, 6),
boat = c(6, 5, 4, 3 , 1 , 2)
)
l <- list(df1, df2)
I want to reorder based on a specific order for the values in column "stof". I want to do this after I have made the list, not before. The order should be: "pm5", "ch4", "CO2", "so2", "pm10", "nh3"