Hello everybody,
I have a data set like that. I would like to sort by two conditions with two variables, namely "date" and "stock". ("stock" sorted from A to Z , "date" sorted from oldest to newest). I tried to sort but I could not combine the two conditions and got the wrong output. The data was sorted with only the day, not by month and year.
I would appreciate any helps.
Thank you in advance.
data<-data.frame(
X = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L),
closed_price = c(33100L, 33300L, 34100L, 34400L, 33600L, 33200L,
32200L, 33400L, 34100L, 34600L),
opened_price = c(33600L, 33900L, 34400L, 33900L, 34000L, 32200L,
32800L, 34500L, 34600L, 35500L),
adjust_closed_price = c(8591L, 8643L, 8850L, 8928L, 8721L, 8617L, 8357L,
8669L, 8850L, 8980L),
date = as.factor(c("31-12-10", "30-12-10", "29-12-11",
"31-12-11", "29-12-10", "24-12-10",
"23-12-11", "22-12-11", "21-12-12", "20-12-12")),
stock = as.factor(c("AAA", "AAA", "AAA", "AAA", "AAC", "AAC",
"AAC", "AAC", "AAC", "AAC"))
)