Skip to content

Urgent Help with R calculation correlation coefficient

7 messages · chintan85, Liviu Andronic, PIKAL Petr +3 more

#
Hi,

I am trying to calculate correlation coefficient for gene expression data.

Tab delimited file looks like this

Id v1   v2    v3
df 56   90    45
gh 87   98    78
ty 89    78    67

I used this code


[code]

gse20437 <- read.csv("C:/Users//Desktop/data/GSE20437_matrix.txt",header =
TRUE, sep = ",", strip.white = TRUE)

gsecor <- cor(gse20437, method ="pearson") or

gsecor <- cor(gse20437)

[/code]

i get error x must be numeric..

can anybody help me.

thanks in advance
#
On Mon, Dec 6, 2010 at 11:02 AM, chintan85 <chintanpathak15 at yahoo.com> wrote:
Can you post the following?
str(gse20437)

Liviu

  
    
  
#
Hi

r-help-bounces at r-project.org napsal dne 06.12.2010 11:02:03:
data.
=
At least your Id column is not numeric. Do not use it for cor.

gsecor <- cor(gse20437[,-1])

Regards
Petr
http://r.789695.n4.nabble.com/Urgent-Help-with-
http://www.R-project.org/posting-guide.html
#
On 2010-12-06 02:02, chintan85 wrote:
If this is so urgent, then wouldn't it seem like a good idea to
actually peruse the help page for read.csv?

If you have a *tab*-delimited file, then why are your using
read.csv??

Try this:
1. read your data with read.table() or read.delim()
2. issue str(gse20437) to see what you've acutally read
3. Note that one of your columns is *not* numeric (as the
    very helpful error message is trying to tell you)

Peter Ehlers
#
Try excluding the first column.

cor(gse20437[, 2:4])
chintan85 wrote:

  
    
#
On Dec 6, 2010, at 11:28 , Petr PIKAL wrote:

            
Also, using sep="," for a TAB delimited file is suspect (to say the least). (Note, by the way read.delim())
#
On Mon, Dec 6, 2010 at 11:30 AM, Peter Ehlers <ehlers at ucalgary.ca> wrote:
If you're very new to R, try Rcmdr. Data > Import > Text file.

Liviu