Skip to content

Instantly share code, notes, and snippets.

@dalejung
Created August 9, 2012 01:02
Show Gist options
  • Save dalejung/3300119 to your computer and use it in GitHub Desktop.
Save dalejung/3300119 to your computer and use it in GitHub Desktop.
# If your data.frame index is unordered and you only have one column. This portion of xts will error.
if(!is.null(x) && !isOrdered(order.by, strictly=!unique) ) {
indx <- order(order.by)
if(NCOL(x) > 1 || is.matrix(x)) {
x <- x[indx,]
} else x <- x[indx]
order.by <- order.by[indx]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment