[R] data frame sample
arun
smartpink111 at yahoo.com
Fri May 23 18:09:24 CEST 2014
Hi,
May be this helps:
dat1 <- as.data.frame(matrix(1:(640*5), ncol=5,byrow=TRUE))
set.seed(41)
indx <-sample(nrow(dat1),nrow(dat1),replace=FALSE)
lst1 <- lapply(split(indx,as.numeric(gl(640,64,640))),function(x) dat1[x,])
A.K.
Dear all,
I have a data frame (d) composed of 640 observations for 55 variables.
I would like to randomly sample this data frame in 10 sub data frame of 64
observations for 55 variables. I dont want any of the observation to be in
more than one sub data-frame.
This code work for one sample
d1 <- d[sample(nrow(d),64,replace=F)
,]
This one give me a dataframe of 10 variable (each one is one sample...)
d1 <- replicate(10,sample(nrow(d),64,replace = F))
}
Can anyone help me ?
More information about the R-help
mailing list