[R] Cannot read in a csv file.
Duncan Murdoch
murdoch.duncan at gmail.com
Sat May 7 22:20:53 CEST 2011
On 11-05-07 1:26 PM, John Kane wrote:
> Can anyone suggest why this file http://www.mediafire.com/?afeyhhpacaq
> is refusing to open for me.?
>
> I must admit I don't know all its history but the original data was taken from an OOo spreadsheet that I edited (good bit of copying and pasting and the month variable added by hand in OOo Calc) and, then,saved as a csv file. It was not originally an English language file as far as I can determine. It may have been created in Excel for all I know.
>
> If I load the file into my text editor (Tinn-r) I can read the material in using the textConnection command and have no problem working with it. However this meant that I spend an hour and a half trying to read the file and 5 minutes doing the graph I wanted. I'd like to avoid my mistake in the future if possible.
>
> I'm showing my last try below but the directory is almost certainly correct. I've tried it using a full path name and, as below, after changing the active directory.
>
> When I try to load the file I get this:
>
>> read.csv("asp.csv", header=TRUE, sep=",")
>
> Error in file(file, "rt") : cannot open the connection
> In addition: Warning message:
> In file(file, "rt") : cannot open file 'asp.csv': No such file or directory
>
If the filename is really correct, then it would appear to be a
permissions problem. Do you have read permission on that file? Try
opening it in Notepad or some other program.
If that works, then I'd suggest that you actually don't have the
filename correct. (Windows does dumb things like displaying the file
"asp.csv.txt" as "asp.csv" by default.) If you use the file.choose()
function to select the file, you'll get the right filename.
Duncan Murdoch
> sessionInfo()
>
> R version 2.12.2 (2011-02-25)
> Platform: i386-pc-mingw32/i386 (32-bit)
>
> locale:
> [1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252
> [3] LC_MONETARY=English_Canada.1252 LC_NUMERIC=C
> [5] LC_TIME=English_Canada.1252
>
> attached base packages:
> [1] grid stats graphics grDevices utils datasets methods base
>
> other attached packages:
> [1] ggplot2_0.8.9 proto_0.3-9.1 reshape_0.8.4 plyr_1.4.1
>
> loaded via a namespace (and not attached):
> [1] digest_0.4.2 tools_2.12.2
>>
>
> Thanks.
>
> ______________________________________________
> R-help at r-project.org 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.
More information about the R-help
mailing list