library(psych) corr.test(d6) ????? --- On Sun, 9/20/09, Adrian Johnson <oriolebaltim...@gmail.com> wrote:
> From: Adrian Johnson <oriolebaltim...@gmail.com> > Subject: Re: [R] correlation help > To: r-help@r-project.org > Received: Sunday, September 20, 2009, 6:19 PM > thank you john. > however, I am finding it difficult to automate on a > matrix. > > Pardon my ignorance in R computing: > > I do not know how to automate on a matrix. > > If I do the following it works: > > x = cor.test(d6[1,],d6[2,]) > > x > > Pearson's product-moment > correlation > > data: d6[1, ] and d6[2, ] > t = 10.5196, df = 10, p-value = 9.973e-07 > alternative hypothesis: true correlation is not equal to 0 > 95 percent confidence interval: > 0.8520623 0.9883592 > sample estimates: > cor > 0.9576655 > > > If I want to run it on all rows, I do not know how to do > it. > > I tried following, > > > lapply(d6,cor.test) > Error in cor.test.default(X[[1L]], ...) : > element 1 is empty; > the part of the args list of 'length' being > evaluated was: > (y) > > > > sapply(d6,cor.test) > Error in cor.test.default(X[[1L]], ...) : > element 1 is empty; > the part of the args list of 'length' being > evaluated was: > (y) > > > for(i in 1:14659){ > + k = i+1 > + cor.test(d6[i,],d6[k,]) > + x = cor.test(d6[i,],d6[k,]) > + return(x)} > Error: no function to return from, jumping to top level > > > I appreciate your help. > > thank you. > Adrian > > On Sun, Sep 20, 2009 at 6:17 PM, Adrian Johnson > <oriolebaltim...@gmail.com> > wrote: > > thank you john. > > however, I am finding it difficult to automate on a > matrix. > > > > Pardon my ignorance in R computing: > > > > I do not know how to automate on a matrix. > > > > If I do the following it works: > >> x = cor.test(d6[1,],d6[2,]) > >> x > > > > Pearson's product-moment correlation > > > > data: d6[1, ] and d6[2, ] > > t = 10.5196, df = 10, p-value = 9.973e-07 > > alternative hypothesis: true correlation is not equal > to 0 > > 95 percent confidence interval: > > 0.8520623 0.9883592 > > sample estimates: > > cor > > 0.9576655 > > > > > > If I want to run it on all rows, I do not know how to > do it. > > > > I tried following, > > > >> lapply(d6,cor.test) > > Error in cor.test.default(X[[1L]], ...) : > > element 1 is empty; > > the part of the args list of 'length' being > evaluated was: > > (y) > > > > > >> sapply(d6,cor.test) > > Error in cor.test.default(X[[1L]], ...) : > > element 1 is empty; > > the part of the args list of 'length' being > evaluated was: > > (y) > > > >> for(i in 1:14659){ > > + k = i+1 > > + cor.test(d6[i,],d6[k,]) > > + x = cor.test(d6[i,],d6[k,]) > > + return(x)} > > Error: no function to return from, jumping to top > level > > > > > > I appreciate your help. > > > > thank you. > > Adrian > > > > > > > > > > > > > > On Sun, Sep 20, 2009 at 5:13 PM, John Kane <jrkrid...@yahoo.ca> > wrote: > >> ?cor > >> ?cor.test > >> > >> --- On Sun, 9/20/09, Adrian Johnson <oriolebaltim...@gmail.com> > wrote: > >> > >>> From: Adrian Johnson <oriolebaltim...@gmail.com> > >>> Subject: [R] correlation help > >>> To: r-help@r-project.org > >>> Received: Sunday, September 20, 2009, 5:00 PM > >>> Dear group, > >>> > >>> I have a matrix like the following: > >>> > >>> Name Sample1 > >>> sample2 sample3 sample4 ..... > >>> sample(n) > >>> nm1 10.5 > >>> 13.5 > >>> 30 31 > >>> nm2 8 > >>> 11 > >>> 34 > >>> 29 > >>> nm3 9 > >>> 10.3 > >>> 27.8 35 > >>> nm(j) > >>> > >>> > >>> I want to be able to calculate correlation > between > >>> all pairs of names. > >>> For example (nm1,nm2), (nm1,nm3), (nm1,nmj), > (nm2,nm3), > >>> (nm2,nmj).... > >>> > >>> Then I want to calculate the significance of > correlation > >>> using t-score > >>> or p-value. > >>> > >>> I can calculate correlation coeffecient in > excel but not > >>> significance > >>> in both excel and R. > >>> > >>> I want to be able to do it in R, I appreciate > your help. > >>> thank you. > >>> Ad. > >>> > >>> > ______________________________________________ > >>> 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. > >>> > >> > >> > >> > __________________________________________________________________ > >> Be smarter than spam. See how smart SpamGu Click on Options in Mail and switch to New Mail today or > register fo ________________________ > 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. > __________________________________________________________________ Make your browsing faster, safer, and easier with the new Internet Explorer® 8. Optimize explorer/ ______________________________________________ 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.