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.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to