[R] using sample
bevare
emma.raven at jbaconsulting.co.uk
Wed Dec 7 18:16:33 CET 2011
Hi,
Can anyone help sort out the problem with the following script - I am a R
newbie and I am self taught.
obs.all = c()
for(i in 1:386){
if (n.sim[i]>0){
obs = (1:133429)[event.details[,2] == i]
obs.all = c(obs.all, sample(obs[obs < n.sim[i]], size = n.sim[i],
replace=T))
}
Basically, in the sample bit, I only want to get obs.all if the value of obs
is less than the value of n.sim[i]. I get the error message
Error in sample(obs[obs < n.sim[i]], size = n.sim[i], replace = T) :
invalid first argument
length(n.sim) is 386
Thanks in advance for your suggestions
Emma
--
View this message in context: http://r.789695.n4.nabble.com/using-sample-tp4169747p4169747.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list