Skip to content

reading data into R

4 messages · jacaranda tree, R. Michael Weylandt, John Kane +1 more

#
You need to assign your data set to something -- right now you're just
reading it in and then throwing it away:

dats <- read.csv("mydata1.csv")

mean(dats$X) # Dollar sign, not ampersand

Best,
Michael
On Tue, May 15, 2012 at 8:57 AM, jacaranda tree <myjacaranda at yahoo.com> wrote:
#
What was the exact syntax?
 read.table> ("mydata1.csv", sep=",", header=T)
will read the data but not save anything.

mydat <-read.table ("mydata1.csv", sep=",", header=T)
give you a data.frame called mydat.

mean(mydat$X)  should give you the mean of X  




John Kane
Kingston ON Canada
____________________________________________________________
FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your desktop!
#
Hi !

You need to assign the output of read.table() into an object; this is 
how R works:
mydata <- read.table ("mydata1.csv", sep=",", header=T)
mymean <- mean(mydata$var)

You should read some introductory material.
I found this useful: 
http://www.burns-stat.com/pages/Tutor/hints_R_begin.html
And then, there are tons of good books and documentation (go check the 
CRAN as well)

HTH,
Ivan

PS: post in plain text

--
Ivan CALANDRA
Universit? de Bourgogne
UMR CNRS/uB 6282 Biog?osciences
6 Boulevard Gabriel
21000 Dijon, FRANCE
+33(0)3.80.39.63.06
ivan.calandra at u-bourgogne.fr
http://biogeosciences.u-bourgogne.fr/calandra


Le 15/05/12 14:57, jacaranda tree a ?crit :