On 10/10/2018 5:45 PM, Olivier GIVAUDAN wrote:
I'm not sure I'm "inventing my own way" of distributing R code... And I
distribute it to a very limited audience.
Nothing says a package has to go on CRAN. You can distribute them
privately to a small audience.
Anyway, why not "inventing a new way" if it's more efficient than the
standard one (I'm talking now in theory)?
If you know as much about R as the people who wrote it, then you can
almost certainly invent better ways to do many of the things it does. R
Core was constrained by trying to maintain back compatibility, and that
means some of their solutions aren't perfect.
But if you don't know it that well, chances are you'll make mistakes
when you invent your own way of doing it. For example, you might think
that all front ends set the working directory to the directory of the
program they are running, because the ones you've tried do it that way.
But they don't.
Duncan Murdoch
------------------------------------------------------------------------
*De :* Duncan Murdoch <murdoch.dun...@gmail.com>
*Envoyé :* mercredi 10 octobre 2018 21:39
*À :* Olivier GIVAUDAN; Jeff Newmiller
*Cc :* r-help@r-project.org
*Objet :* Re: [R] Genuine relative paths with R
On 10/10/2018 5:31 PM, Olivier GIVAUDAN wrote:
I do not want to use the terminal, just double clicks (i.e. the
simplest, automatic, non-manual way, without having to write a line /
command).
Therefore everything should happen outside any terminal. The user won't
use a terminal.
I don't have a Mac and I'm not familiar with this OS, sorry.
But I'm really surprised the click method gives different results than
on Linux and Windows.
I know the click method worked both on Linux (Ubuntu latest version) and
Windows (10).
Yes, I executed my file from a terminal and got obviously the same
result as you (that's reassuring).
Come on guys, creating a package... It's like using a hammer to kill a
fly...
It's a simple operation to create a package in RStudio. Not quite a
single click, but just a few.
In plain R, it's just a little more work using package.skeleton().
Really, if you are distributing R code, you should do it in the standard
way, not invent your own.
Duncan Murdoch
------------------------------------------------------------------------
*De :* Duncan Murdoch <murdoch.dun...@gmail.com>
*Envoyé :* mercredi 10 octobre 2018 20:54
*À :* Olivier GIVAUDAN; Jeff Newmiller
*Cc :* r-help@r-project.org
*Objet :* Re: [R] Genuine relative paths with R
On 10/10/2018 4:42 PM, Olivier GIVAUDAN wrote:
Why are you not simply double-clicking on 'TestPWD' and choosing to
execute the file (don't add anything)?
Are you executing the file from a terminal?
Yes, I was executing the file from my terminal. Otherwise I really have
no idea what the "current directory" is in the Finder. (I'm on a Mac.
I just tried the click method; it printed my home directory, not the
directory of the script.)
I don't know the name of your visual front end, but you are displaying
the working directory that it sets when you click on TestPWD. That will
be different from the working directory that your user sees in the Terminal.
You can see what I saw if you run TestPWD from the Terminal. It will
print the current working directory, not the one where TestPWD happens
to live.
If you want to do the same sort of thing in R, you could set up a script
that calls R, and execute that in the way you executed TestPWD. But in
another message you said you aren't allowed to do that, so I think your
best solution is the one offered by Bill Dunlap: organize your files as
an R package. If you name your package "Olivier", then you can find all
the files in it under the directory returned by
system.file(".", package = "Olivier")
The package system is designed for R code, but you can put arbitrary
files into a package: just store them under the "inst" directory in
your source. When the package is installed, those files will be moved
up one level, i.e.
Olivier/inst/foo
will become
system.file("foo", package = "Olivier")
Duncan Murdoch
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.