# Re: [R] Help to find correlation.

From: Martin Henry H. Stevens <HStevens_at_muohio.edu>
Date: Fri 17 Feb 2006 - 06:51:14 EST

Hi,
See help files for read.csv for input.
See help files for cor.test

# Generate an upper triangular matrix of Pearson product moment correlation coefficients
r.s <- matrix(NA, nr=dim(dat)[2], nc=dim(dat)[2])

```rownames(r.s) <- names(dat)
colnames(r.s) <- names(dat)
for(i in 1:(dim(dat)[2]-1)) {
```

for(j in i:dim(dat)[2]) r.s[i,j] <- {cor.test(dat[,i], dat[,j]) \$p.value}}
r.s

# Generate an upper triangular matrix of P values of the r's p.s <- matrix(NA, nr=dim(dat)[2], nc=dim(dat)[2])

```rownames(p.s) <- names(dat)
colnames(p.s) <- names(dat)
for(i in 1:(dim(dat)[2]-1)) {
```

for(j in i:dim(dat)[2]) p.s[i,j] <- {cor.test(dat[,i], dat[,j]) \$p.value}}
p.s

Hank

On Feb 16, 2006, at 1:17 PM, Anusha Aiyaloo kannan ((RIT Student)) wrote:

>
> Respected Sir,
>
> I am trying to import excel file into R, but I need to truncate
> some columns from the original file.
>
> How to delete unwanted columns when I import data from excel file.
>
> How to use cor.test for the data when I want the output rowwise.
>
> How to do grouping and use cor.test on that data
>
> I need some help regarding how to calculate the correlation.
> I don't know whether you understood my question, but I need help.
>
> Any help is appreciated.
>
> Thanks,
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> guide.html

Dr. Martin Henry H. Stevens, Assistant Professor 338 Pearson Hall
Botany Department
Miami University
Oxford, OH 45056

Office: (513) 529-4206
Lab: (513) 529-4262
FAX: (513) 529-4243

```http://www.cas.muohio.edu/~stevenmh/
http://www.muohio.edu/ecology/
http://www.muohio.edu/botany/
```

"E Pluribus Unum"

R-help@stat.math.ethz.ch mailing list