chintan85
2010-Dec-06 10:02 UTC
[R] Urgent Help with R calculation correlation coefficient
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 -- View this message in context: http://r.789695.n4.nabble.com/Urgent-Help-with-R-calculation-correlation-coefficient-tp3074206p3074206.html Sent from the R help mailing list archive at Nabble.com.
Liviu Andronic
2010-Dec-06 10:25 UTC
[R] Urgent Help with R calculation correlation coefficient
On Mon, Dec 6, 2010 at 11:02 AM, chintan85 <chintanpathak15 at yahoo.com> wrote:> > 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 you post the following? str(gse20437) Liviu> can anybody help me. > > thanks in advance > > > > > -- > View this message in context: http://r.789695.n4.nabble.com/Urgent-Help-with-R-calculation-correlation-coefficient-tp3074206p3074206.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >-- Do you know how to read? http://www.alienetworks.com/srtest.cfm http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader Do you know how to write? http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail
Petr PIKAL
2010-Dec-06 10:28 UTC
[R] Odp: Urgent Help with R calculation correlation coefficient
Hi r-help-bounces at r-project.org napsal dne 06.12.2010 11:02:03:> > Hi, > > I am trying to calculate correlation coefficient for gene expressiondata.> > 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.At least your Id column is not numeric. Do not use it for cor. gsecor <- cor(gse20437[,-1]) Regards Petr> > thanks in advance > > > > > -- > View this message in context:http://r.789695.n4.nabble.com/Urgent-Help-with-> R-calculation-correlation-coefficient-tp3074206p3074206.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
Peter Ehlers
2010-Dec-06 10:30 UTC
[R] Urgent Help with R calculation correlation coefficient
On 2010-12-06 02:02, chintan85 wrote:> > 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..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> > can anybody help me. > > thanks in advance > > > >
Mark Seeto
2010-Dec-06 10:32 UTC
[R] Urgent Help with R calculation correlation coefficient
Try excluding the first column. cor(gse20437[, 2:4]) chintan85 wrote:> > > 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.. > >-- View this message in context: http://r.789695.n4.nabble.com/Urgent-Help-with-R-calculation-correlation-coefficient-tp3074206p3074251.html Sent from the R help mailing list archive at Nabble.com.
peter dalgaard
2010-Dec-06 10:39 UTC
[R] Odp: Urgent Help with R calculation correlation coefficient
On Dec 6, 2010, at 11:28 , Petr PIKAL wrote:> Hi > > r-help-bounces at r-project.org napsal dne 06.12.2010 11:02:03: > >> >> 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. > > At least your Id column is not numeric. Do not use it for cor. > > gsecor <- cor(gse20437[,-1])Also, using sep="," for a TAB delimited file is suspect (to say the least). (Note, by the way read.delim()) -- Peter Dalgaard Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com