[R] please help me on this problem
Duncan Murdoch
dmurdoch at pair.com
Sun Oct 5 13:58:10 CEST 2003
On Sun, 5 Oct 2003 06:26:57 -0400, you wrote:
>I'm surprised that it didn't work with the full path. I assume
>the error message indicated that it could not find the file, as
>opposed to some other sort of error. Relative paths work too.
If Yong was using Windows, it's likely he specified the path as
something like "c:\data\mydata.txt". Because S was invented on Unix,
it uses the backslash as an escape character, and this doesn't work.
As various docs say, he needs to write it as "c:\\data\\mydata.txt" or
"c:/data/mydata.txt". Even better, use something like
filename <- file.choose()
read.table(filename)
or
read.table(file.choose())
It would make sense to have file.choose() as the default value for
file arguments just about everywhere, but almost none of the
file-using functions do that now.
>You don't say what operating system you are using, and it
>probably matters. But on Linux/Unix I usually start R from the
>directory where the data files are, and I have several of these
>for different projects.
One of the design flaws in Windows is that it's very hard for the user
to know the current directory. Most program shortcuts (including the
default one created by the R installer) change the directory on
startup, and R doesn't tell you the current directory unless you ask
(using getwd()).
>In sum, at least in Unix/Linux, you can put your data anywhere,
>and either you start R from where the data are or you use a
>relative or full path name.
The same is true in Windows.
Duncan Murdoch
More information about the R-help
mailing list