[R] Help with "replicate"

Alex99 loyola9988 at yahoo.com
Thu Nov 27 18:22:07 CET 2008



Hello everyone,
I have a file called "trans" which has 100 records (rows) and 60 columns.
I need to make 2 samples (with 5 records in each) out of this file with no
replacement, so I used "replicate".
The sampling part works fine and I called the outcome "result".

my problem is then I need to calculate the correlation matrix for each
sample. I used "do.call" and called the outcome "CORE". but the problem is
when I get my out put it's not separated for each sample. they are all
together and I need them to be separated. just to give U an idea I copy and
paste the out put:

              616            783            805            134           
217
616  1.00000000 -0.08522865 -0.15018785 -0.12462239 -0.04279605
783 -0.08522865  1.00000000 -0.02986738 -0.04731350  0.33191790
805 -0.15018785 -0.02986738  1.00000000  0.15483873 -0.08998425
134 -0.12462239 -0.04731350  0.15483873  1.00000000  0.16290948
217 -0.04279605  0.33191790 -0.08998425  0.16290948  1.00000000
607  1.00000000 -0.12662932  0.16116459 -0.03479445 -0.03479445   *(from
here is for the 2nd sample)
604 -0.12662932  1.00000000  0.01298701 -0.06168397 -0.06168397
698  0.16116459  0.01298701  1.00000000 -0.03925343 -0.03925343
639 -0.03479445 -0.06168397 -0.03925343  1.00000000 -0.01694915
989 -0.03479445 -0.06168397 -0.03925343 -0.01694915  1.00000000
  
does any one has any idea how can I separate the result for 2 samples?     

This is my code:
result=replicate(2,trans[,sample(colnames(trans),5,replace =
FALSE)],simplify=FALSE)
CORE=do.call(rbind,lapply(result,function(x) cor(x)))

-- 
View this message in context: http://www.nabble.com/Help-with-%22replicate%22-tp20722891p20722891.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list