I'm trying to sort a simple dataset by a character column (descending) and a date variable (ascending).
fx_code date fx_spot
1 AUD 2000-01-31 0.6370
2 AUD 2000-02-29 0.6178
3 AUD 2000-03-31 0.6071
4 AUD 2000-04-28 0.5839
5 AUD 2000-05-31 0.5725
When I run the following code
DF$date <- as.Date(DF$date, format = "%Y-%m-%d")
DF <- DF[order(DF$fx_code,-DF$date),]
I am getting the following error:
Error in
-.Date
(DF$date) : unary - is not defined for "Date" objects