"Nathan Cooper" <[EMAIL PROTECTED]> writes: > I have an indexing question. I have a data set that looks like this: > > >b > [[1]] > [1] 22 23 24 25 26 > > [[2]] > [1] 6 7 8 9 NA > > etc. from [[1]] to [[1000]] > > Then I need to use the sample function to take two samples from b[[1]] > to b[[1000]] each separately. I thought something like > "sample(na.omit(b[[1:1000]]),2,replace=TRUE)" would work but it > doesn't. Is there a way to index this properly?? Thanks,
Not really. I'd try lapply(lapply(b,na.omit),sample,2,replace=TRUE) or lapply(b,function(x)sample(na.omit(x),2,replace=TRUE)) -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help