On 04-Dec-03 [EMAIL PROTECTED] wrote: > Hi all, > I?m working with a dataset with 9 columns and 2000 rows. Each row > represents an individual and one of the columns represents the volume > of that individual (measured in cubic meters). I?d like to select a > sample from this dataset (without considering any probability of the > rows) in which the sum of the volume of the individuals in that sample > >= 100 cubic m.
let X be the dataset. For N=2000: ix<-sort(rnorm(N),index.return=TRUE)$ix M<-max(which(cumsum(volume[ix])<100))+1 ## Assumes volume > 0 X[ix[1:M],] If you can't assume volume > 0, then somthing like M<-min( which(sum(volume)-cumsum(volume[ix]) <= sum(volume) - 100) ) Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <[EMAIL PROTECTED]> Fax-to-email: +44 (0)870 167 1972 Date: 04-Dec-03 Time: 14:08:48 ------------------------------ XFMail ------------------------------ ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help