On Feb 6, 2010, at 3:29 PM, Ravi Ramaswamy wrote:
> Hi - I am not familiar with R. Could I ask you a quick question?
>
> When I read a file like this, I get an error. Not sure what I am
> doing
> wrong. I use a MAC. How do I specify a full path name for a file
> in R? Or
> do files have to reside locally?
>
>> KoreaAuto <- read.table(""/Users/
I think the opening and clsing quotes meant that you supplied an empty
string to the file argument.
> raviramaswamy/Documents/Rutgers/STT 586/HW1 Data.txt"")
> Error: unexpected numeric constant in "KoreaAuto <-
> read.table(""/Users/raviramaswamy/Documents/Rutgers/STT 586"
>>
>
Using single instances of either sort of quote ( " or ' ) on the ends
of strings should work. If you drag a file from a Finder window to the
R-console you should get a fully specified file path and name.
> Seems like the working directory is
>> getwd()
> [1] "/Users/raviramaswamy"
> rd <- read.table(file="/Users/davidwinsemius/Downloads/
meminfo.csv", sep=",", header=TRUE)
> rd
time RSS VSZ MEM
1 1 3027932 3141808 4.5
2 2 3028572 3141808 4.5
3 3 3030208 3141808 4.5
4 4 3033332 3150004 4.5
5 5 3035036 3150004 4.5
You can also shorten the Users/<username> part to "~"
> rd <- read.table(file="~/Downloads/meminfo.csv",
sep=",",
header=TRUE)
>>
>
> so I said this and still got an error
>
>> KoreaAuto <- read.table(/Documents/Rutgers/HW1Data)
> Error: unexpected '/' in "KoreaAuto <- read.table(/"
But using no quotes will definitely not work. (And that was not a full
path name anyway.)
>
>
> Could someone please help me with the correct syntax?
>
> Thanks
>
> Ravi
>
> Year AO GNP CP OP
> 01 1974 .0022 183 2322 189
> 02 1975 .0024 238 2729 206
> 03 1976 .0027 319 3069 206
> 04 1977 .0035 408 2763 190
> 05 1978 .0050 540 2414 199
> 06 1979 .0064 676 2440 233
> 07 1980 .0065 785 2430 630
> 08 1981 .0069 944 2631 740
> 09 1982 .0078 1036 3155 740
> 10 1983 .0095 1171 3200 660
>
David Winsemius, MD
Heritage Laboratories
West Hartford, CT