[R] Correlation with p value

David L Carlson dcarlson at tamu.edu
Wed Feb 13 16:39:45 CET 2013


You can use package Hmisc. Assuming your data.frame is called "dta":

> library(Hmisc)
> dta2 <- do.call(cbind, split(dta[,2], dta$Name))
> dta2
          CTJ      PKR      TTK
[1,] 83.99429 88.54571 86.43714
[2,] 86.43714 85.71714 89.70286
[3,] 84.59600 84.90200 87.72800
[4,] 84.74000 89.88286 89.99000
[5,] 87.87714 91.55429 89.42000
[6,] 83.12000 89.42000 85.69143
[7,] 81.82400 86.81000 82.25600
> rcorr(dta2)
     CTJ  PKR  TTK
CTJ 1.00 0.29 0.85
PKR 0.29 1.00 0.22
TTK 0.85 0.22 1.00

n= 7 


P
    CTJ    PKR    TTK   
CTJ        0.5214 0.0152
PKR 0.5214        0.6277
TTK 0.0152 0.6277       

----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352


>  -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Jorge I Velez
> Sent: Wednesday, February 13, 2013 5:22 AM
> To: Nico Met
> Cc: R help
> Subject: Re: [R] Correlation with p value
> 
> Nico,
> 
> Check https://stat.ethz.ch/pipermail/r-help/2008-May/161725.html for
> some
> alternatives.  You might have to change the structure of your data,
> though.
> 
> HTH,
> Jorge.-
> 
> 
> On Wed, Feb 13, 2013 at 10:13 PM, Nico Met <> wrote:
> 
> > Dear all,
> >
> > I have a data (bellow) and I want to make a correlation test with p-
> value
> >
> > structure(list(Name = structure(c(3L, 3L, 3L, 3L, 3L, 3L, 3L,
> > 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label =
> c("CTJ",
> > "PKR", "TTK"), class = "factor"), score = c(86.4371428571428,
> > 89.7028571428572, 87.728, 89.99, 89.42, 85.6914285714286, 82.256,
> > 83.9942857142857, 86.4371428571429, 84.596, 84.74, 87.8771428571428,
> > 83.12, 81.824, 88.5457142857143, 85.7171428571429, 84.902,
> > 89.8828571428571,
> > 91.5542857142857, 89.42, 86.81)), .Names = c("Name", "score"), class
> =
> > "data.frame", row.names = c(NA,
> > 21L))
> >
> > And finally , I would like to display as matrix where I can fill up
> with
> > p-values
> >
> >
> >  *TTK*
> >  *CTJ*
> >  *PKR*
> >  *TTK*
> >  **
> >  **
> >  **
> >  *CTJ*
> >  **
> >  **
> >  **
> >  *PKR*
> >
> >
> >
> >
> >
> > Many thanks for your help in advance
> >
> > Nico
> >
> >         [[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.
> >
> 
> 	[[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