I have data that looks like this in df_Filtered
(where filtered stands for a df for a specific country):
Year Region Percentage_of_national_sell
2012 Berlin 84%
2010 Hamburg 101%
2011 Stettin 98%
2012 Stettin 100%
2012 Hamburg 122%
2011 Berlin 111%
2010 Berlin 101%
2010 Stettin 87%
2011 Hamburg 58%
What I want to do is to sort df_Filtered
so that I first get it sorted by Region
and then by Year
(starting with Berlin
and then get 2010
, 2011
, 2012
in that specific order). Both Region
and Year
should be increasing.
I tried: df_Filtered[ order(df_Filtered$Region, (df_Filtered$Year)) , ]
which works when I get the output in text in Rstudio, but it does not seem to change the order of the data frame when I try to remap it:
df_Filtered <- df_Filtered[ order(df_Filtered$Region, (df_Filtered$Year)) , ]
Is there any way to change the order of the rows in the data frame itself? I want to later export it to LaTex to make nice tables, that is why the order is important.