Hey, I am having some problems with importing a csv file into R and then saving it for analyzing. I got a csv file ( skater.csv) which i could read by typing: read.csv(file="/Users/kama/Desktop/skatter.csv", header=TRUE, sep=";") However, when i enter: skatter.csv<-read.csv("skatter.csv", header=TRUE) i get this message: Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : I have tried with: skatter.csv<-file.choose() and other codes to find the file but it does not work. Please help me fix this problem, i have been sitting with this one in 4 hours.. What i need is to import this file and analyze it using for example histogram. I have Mac(update) and the file is saved in csv file... and I'm quite new user of R. Thank you very much! [[alternative HTML version deleted]]
You don't actually have to post more than once. Really. skatter <- read.table(file.choose(), header=TRUE, sep=";") or skatter <- read.table(""/Users/kama/Desktop/skatter.csv", header=TRUE, sep=";") or whatever the actual path to the file is. As a new user of R, you should read the Introduction to R that came with R, and also the R-help posting guide. Both are full of useful information. Sarah On Tue, Jul 10, 2012 at 2:11 PM, Faradj Koliev <faradj.g at gmail.com> wrote:> Hey, > > I am having some problems with importing a csv file into R and then saving it for analyzing. > > I got a csv file ( skater.csv) which i could read by typing: read.csv(file="/Users/kama/Desktop/skatter.csv", header=TRUE, sep=";") > > However, when i enter: skatter.csv<-read.csv("skatter.csv", header=TRUE) i get this message: > Error in file(file, "rt") : cannot open the connection > In addition: Warning message: > In file(file, "rt") : > I have tried with: skatter.csv<-file.choose() and other codes to find the file but it does not work. > Please help me fix this problem, i have been sitting with this one in 4 hours.. > > > > What i need is to import this file and analyze it using for example histogram. > > I have Mac(update) and the file is saved in csv file... and I'm quite new user of R. >-- Sarah Goslee http://www.functionaldiversity.org
On Tue, 10 Jul 2012, Faradj Koliev wrote:> I got a csv file ( skater.csv) which i could read by typing: > read.csv(file="/Users/kama/Desktop/skatter.csv", header=TRUE, sep=";")Try: skatter <- read.csv('/Users/kama/Desktop/skatter.csv', header = T, sep ';') Rich
On 10.07.2012 20:11, Faradj Koliev wrote:> However, when i enter: skatter.csv<-read.csv("skatter.csv", header=TRUE) i get this message: > Error in file(file, "rt") : cannot open the connection > In addition: Warning message: > In file(file, "rt") : > I have tried with: skatter.csv<-file.choose() and other codes to find the file but it does not work.Could it be a problem with your Working directory? use getwd() to find out whether your working directory is set to your Desktop where your file seems to be and use setwd("/Path/to/Desktop") to go there if you aren't. Then you can use read.csv() without an absolute path for your file as you did above Regards, Moritz -- GnuPG Key: 0x7340821E