我正在尝试进行常规反向排序,但我不明白如何使用
xts
对象进行排序。我希望最后一个日期位于第一行而不是最后一行。
我尝试了多种方法,但都不起作用。
library(xts)
x <- rnorm(500) |> cumsum() |> round(1) |>
xts(Sys.time()+1:500) |> to.minutes(name = NULL)
# dont work :(
# x[nrow(x):1,]
# x[order(index(x),decreasing = T),]
# rev(x)
library(xts)
x <- rnorm(500) |> cumsum() |> round(1) |>
sort(decreasing = TRUE) |>
xts(Sys.time()+1:500) |> to.minutes(name = NULL)