Skip to content

Instantly share code, notes, and snippets.

@isomorphisms
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isomorphisms/f0a19217557f68440c9d to your computer and use it in GitHub Desktop.
Save isomorphisms/f0a19217557f68440c9d to your computer and use it in GitHub Desktop.
rolling random sample merging `car::some` with `xts`
function(data, n=10, ...) {
NROW(data) -> nr
sample.int(nr-n,1) -> start
start + n -> end
pull <- start:end
data[pull, ,drop=FALSE]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment