
YES IT WORKED!!!

Many thanks JiHO

 

--------------------------------------------

Vincent Deluard

 <mailto:Vincent.Deluard@TrimTabs.com> Vincent.Deluard@TrimTabs.com

Global Equity Strategist, CFA Charter Award Pending

TrimTabs Investment Research

40 Wall Street, 28th Floor

New York, NY 10005

Phone: (+1) 646-512-5616

 

From: JiHO-2 [via R] [mailto:ml-node+2131575-1078352091-90534@n4.nabble.com] 
Sent: Wednesday, May 05, 2010 3:51 PM
To: vincent.deluard
Subject: Re: read.table or read.csv without row index?

 

> I tried as.matrix but it did not help. 

as.matrix() won't work because a matrix requires everything in it to 
be of the same type (number, character, logical etc.). You do not have 
only numbers in your data.frame, so it will convert everything to 
character strings. If you try as.matrix(temp[,-1]) it should work 
(assuming you only have characters in the first column, otherwise 
remove all non-numeric columns). 

But what you really want is to circumvent the fact that, on a 
data.frame, mean works column-wise. In fact, when you call mean() on a 
data.frame() it calls mean.data.frame(), which code you can see by 
typing its name at the prompt: 

    > mean.data.frame 
    function (x, ...) 
    sapply(x, mean, ...) 
    <environment: namespace:base> 

And indeed, it uses sapply() to apply the function mean to each 
column. You could have tried: 

    mean.default(temp[2,2:3]) 

but this returns and error because it needs a numeric vector and does 
not automatically convert your data.frame into it. So you need: 

    mean.default(as.numeric(temp[2,2:3])) 

or more simply 

    mean(as.numeric(temp[2,2:3])) 

I hope that helped. Sincerely, 

JiHO 
--- 
http://maururu.net

______________________________________________ 
[hidden email] 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. 



  _____  

View message @ http://r.789695.n4.nabble.com/read-table-or-read-csv-without-row-index-tp883594p2131575.html 
To unsubscribe from Re: read.table or read.csv without row index?, click
< (link removed) 
AwNTU4Mzk3>  here. 

 


-- 
View this message in context: http://r.789695.n4.nabble.com/read-table-or-read-csv-without-row-index-tp883594p2131597.html
Sent from the R help mailing list archive at Nabble.com.

	[[alternative HTML version deleted]]

