Silvano, I am a little confused as to what you are looking for. Do you want each group to have approximately the same mean and variance? Randomly assigning groups should be sufficient for the means and variances to be somewhat similar. I'm not sure what your goal would be to randomly split your data into four groups with the same mean and variance though.
Regards, Charles On Mon, Aug 26, 2013 at 8:04 AM, Silvano <silv...@uel.br> wrote: > ** > Charles, > > I think if the data present a high variability, there is likely to have > heterogeneous groups. > > There would be the possibility to select the groups fixing the mean and > variance? > > Thanks a lot, > > -------------------------------------- > Silvano Cesar da Costa > Departamento de EstatÃstica > Universidade Estadual de Londrina > Fone: 3371-4346 > -------------------------------------- > > ----- Original Message ----- > *From:* Charles Determan Jr <deter...@umn.edu> > *To:* Silvano <silv...@uel.br> > *Cc:* r-help@r-project.org > *Sent:* Friday, August 23, 2013 11:25 AM > *Subject:* Re: [R] Randomization > > Hi Silvano, > > How about this? > > id <- seq(80) > weight <- runif(80) > > # randomize 4 groups with 'sample' function > group <- sample(rep(seq(4),20)) > dat <- cbind(id, weight, group) > > # ordered dataset by group > res <- data.frame(dat[order(group),]) > > # get mean and variance for each group > aggregate(res$weight, list(group=res$group), mean) > aggregate(res$weight, list(group=res$group), var) > > Cheers, > Charles > > > > On Fri, Aug 23, 2013 at 9:03 AM, Silvano <silv...@uel.br> wrote: > >> Hi, >> >> I have a set of 80 animals and their respective weights. I would like >> create 4 groups of 20 animals so that the groups have means and variances >> with values ??very close. >> How can I make this randomization in R? >> >> Thanks, >> >> ------------------------------**-------- >> Silvano Cesar da Costa >> Departamento de EstatÃstica >> Universidade Estadual de Londrina >> Fone: 3371-4346 >> >> ______________________________**________________ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help> >> PLEASE do read the posting guide http://www.R-project.org/** >> posting-guide.html <http://www.R-project.org/posting-guide.html> >> and provide commented, minimal, self-contained, reproducible code. >> > > > > -- > Charles Determan > Integrated Biosciences PhD Candidate > University of Minnesota > > -- Charles Determan Integrated Biosciences PhD Candidate University of Minnesota [[alternative HTML version deleted]]
______________________________________________ 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.