[R] HELP me please with import of csv to R

Sarah Goslee sarah.goslee at gmail.com
Tue Jul 10 21:44:08 CEST 2012


On Tue, Jul 10, 2012 at 12:48 PM, F86 <faradj.g at gmail.com> wrote:
> Hey,
> I am having problems with importing a csv file to R.
> I could read the file by typing:
> read.csv(file="/Users/kama/Desktop/skatter.csv", header=TRUE, sep=";")

So that command does work?

> However, i can not analyze the "skatter" - for ex, when i type:     skatter
> = read.csv("skatter.csv")

Then you need the above command, not what you type here:

skatter <- read.csv(file="/Users/kama/Desktop/skatter.csv",
header=TRUE, sep=";")

But note that if sep=";" then you don't have a csv file and should
properly use read.table() instead.

> i get this message:
> Error in file(file, "rt") : cannot open the connection
> In addition: Warning message:
> In file(file, "rt") :
> 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.

That error means that R can't find the file where you told it to look.
Specifying the full and complete path as in your first example should

If you're having problems with paths (which are a Mac issue and not at
all an R issue), you could also try

read.table(file.choose(), header=TRUE, sep=";")

I think that file.choose() should work on Mac.

The Intro to R document that came with R might also be of use.


Sarah Goslee

More information about the R-help mailing list