[R] Using read.csv() to import data

charles rockson chlsrocks at yahoo.com
Mon Apr 25 18:05:38 CEST 2016


First save your file as csv and then type the following in the console....assignname
assignname=read.csv(file.choose())

This would open up your dcouments file and then you can select the file you saved as csv.
Cheers

      From: Jason Hernandez via R-help <r-help at r-project.org>
 To: "r-help at r-project.org" <r-help at r-project.org> 
 Sent: Sunday, April 24, 2016 1:30 PM
 Subject: [R] Using read.csv() to import data
   
I am just beginning to learn R, using _R for Dummies_ by Andrie de Vries and Joris Meys. I am using Windows 7, and RGui (64-bit) version 3.0.2. I have reached the chapter on "Getting Data Into and Out of R." But the code they use for importing data doesn't seem to be working for me.

Their example is:> elements <- read.csv(file.path("f:", "elements.csv"))
Since I don't have any such file, I am trying to use a file I have. I went to Excel, brought up my file titled JPH_data, and saved it as .csv (comma delineated) on my main hard drive C:

Then I entered:>  mammals <- read.csv(file.path("C:", "JPH_data.csv"))
I got the following:Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
  cannot open file 'C:/JPH_data.csv': No such file or directory
Aside from the obvious (how can it say "no such file or directory" when I just saved one such?), the "cannot open the connection" is also unexpected. What am I doing wrong here?
Jason Hernandezno current affiliation

    [[alternative HTML version deleted]]

______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

  
	[[alternative HTML version deleted]]



More information about the R-help mailing list