[R] Use of the command 'replicate'
Manny Gomez
manuel.gomes at lshtm.ac.uk
Thu Oct 22 00:38:35 CEST 2009
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.
More information about the R-help
mailing list