Dear R users, I'd like to ask u whether you know how to sort out the following:
I'm trying to reproduce a dataset of clusters, and for that I need to build up a cluster index (inside a function) using the command "replicate" as follows: dataset<- function( clusters=100, cluster.size=50, outcome.mean=list(mean=3, sd=1), outcome.var=list(mean=0, sd=1), treat=1, unbal = FALSE){ if(clusters%%2!=0) stop("number of clusters, clusters, must be an even number \n") clust.size<-cluster.size clusters<-clusters clust.index <- rep(1:clusters, times=clust.size) # cluster index treat.ind <- c( # treatment index indicator rep(0, sum(clust.size[1:(clusters/2)])), rep(1, sum(clust.size[(clusters/2+1):clusters])) ) (...) } Doing this it gives me an error saying that the 'times' argument is invalid and that the cluster and treatment indicator indices are both invalid, and therefore, I'm probably defining "clust.size" wrongly?! Could you elucidate me about this?? Thanks a lot. Manny Gomez -- View this message in context: http://www.nabble.com/Use-of-the-command-%27replicate%27-tp26001367p26001367.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.