[R] index and by groups statement
Robert Waters
rwatersg at yahoo.com
Sun Aug 15 05:32:14 CEST 2004
Dear R-users
Im working with a dataset that contains information
for 8 groups of data and I need to select a sample of
certain size (100 cubic feet by group) from this
database for each of these 8 groups. To clarify, here
is the starting code Im working with:
k<-nrow(dataset)
ix<-sort(runif(k),index.return=TRUE)$ix
M<-max(which(cumsum(dataset$volume[ix])<100))+1
test<-dataset[ix[1:M],]
However, I don't know how to specify in this code the
instruction: "by groups"
Does anyone have an idea how to do this?
Thanks in advance
RW
More information about the R-help
mailing list