Created
November 29, 2014 11:01
-
-
Save mbannert/95367d5d5b7cc1e5d75a to your computer and use it in GitHub Desktop.
reproducible example to split dataset into intervals when sorted
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# generate data, variables will be name X1 .... X8 | |
# dimension: 1200 rows, 7 cols | |
daten <- data.frame(matrix(rnorm(8400),ncol = 7)) | |
# 8th col is just sequential id 1-1200 | |
daten$id <- as.numeric(row.names(daten)) | |
# assume data are sorted, | |
# add another column that indicates | |
# the subset | |
x <- integer() | |
for(i in 1:10) x <- c(x,rep(i,120)) | |
daten$subset <- x | |
# do the split trick | |
lapply(split(daten,factor(daten$subset)), | |
summary) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment