I think what you want is

lapply(b, function(x) sample(na.omit(x), 2, replace = TRUE))

-roger

Nathan Cooper wrote:

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,

Nathan

_________________________________________________________________
Add MSN 8 Internet Software to your existing Internet access and enjoy patented spam protection and more. Sign up now!


______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to