I have a dataframe and I want to order it by a character column and by a date or numeric column.
It works when I order both in ascending order:
dataframe <- dataframe[order(dataframe$stringvariable, dataframe$numericvariable),]
However, I cannot figure out how to order it by the numeric variable in descending order.
When I try the code below, I get error message "Error in -dataframe$numericvariable : invalid argument to unary operator:"
dataframe <- dataframe[order(dataframe$stringvariable, -dataframe$numericvariable),]
When I try the code below instead, I get error message "argument 2 is not a vector" and "Unknown or uninitialised column: numericvariable
."
dataframe <- dataframe[order(dataframe$stringvariable, rev(dataframe$numericvariable)),]
It works when I only order by numericvariable, but I cannot figure out how to do this when I want to order by more than one column.