[R] permutation and reshuffling

Greg Snow Greg.Snow at imail.org
Tue Sep 1 16:59:37 CEST 2009


Look at ?sample for how to shuffle/permute a single vector (or rows of a data frame/matrix) and ?replicate for a way to do it a bunch of times and return the results in a nice form.

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Yonatan Nissenbaum
> Sent: Tuesday, September 01, 2009 1:35 AM
> To: r-help at r-project.org
> Subject: [R] permutation and reshuffling
> 
> Hi,
> 
> 
> 
> I'm looking for an efficient code that will enable me to reshuffle data
> (phenotype) for certain number of individuals and creating a loop that
> will
> randomly simulate it for 10000 times *(permutation)*. I also need to
> find
> how I keep the information (p value for each SNP) gathered for all the
> 10000
> iterations.
> 
> My data set looks like this (n=500):
> 
> Individual #
> 
> Phenotype
> 
> SNP1
> 
> SNP2
> 
> SNP3
> 
> SNP4
> 
> SNP5
> 
> SNP6
> 
> SNP7
> 
> SNP8
> 
> SNP9
> 
> SNP10
> 
> SNP11
> 
> SNP12
> 
> 1
> 
> 0
> 
> T
> 
> T
> 
> G
> 
> G
> 
> A
> 
> C
> 
> G
> 
> T
> 
> A
> 
> A
> 
> T
> 
> C
> 
> 2
> 
> 1
> 
> A
> 
> T
> 
> C
> 
> G
> 
> A
> 
> C
> 
> G
> 
> T
> 
> A
> 
> G
> 
> T
> 
> C
> 
> 
> 
> Many thanks,
> 
> 
> 
> Jonathan
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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.




More information about the R-help mailing list