Hi all, After a short hiatus away from R I have found that it's changed a bit. I used to keep a definition of .First in .Rprofile that did a couple of things on startup (load a couple of libraries). Now, I've discovered that when I change the definition of .First in .Rprofile it doesn't change anything when I start up, because .First is held over in .Rdata from the last session. The manual states that now .Rdata is loaded last, as intended. My question is, how do I change what's in .First (or any other variable, for that matter), if .Rdata will always override my changes? (I'd prefer not to have to do it manually, and I'd prefer to have all the other data preserved, rather than just leaving out .Rdata) Dave R.
.Rprofile, .Rfirst, and .Rdata
5 messages · Henrik Bengtsson, David Richmond, Martin Maechler +1 more
What do you have in .First() that you can not have directly in the
.Rprofile script? For example:
# ~/.Rprofile
cat("Running my .Rprofile...");
library(modreg)
cat("Running my .Rprofile...done");
Henrik Bengtsson
-----Original Message----- From: r-help-admin at stat.math.ethz.ch [mailto:r-help-admin at stat.math.ethz.ch] On Behalf Of David Richmond Sent: den 6 februari 2003 13:57 To: r-help at stat.math.ethz.ch Subject: [R] .Rprofile, .Rfirst, and .Rdata Hi all, After a short hiatus away from R I have found that it's changed a bit. I used to keep a definition of .First in .Rprofile that did a couple of things on startup (load a couple of libraries). Now, I've discovered that when I change the definition of .First in .Rprofile it doesn't change anything when I start up, because .First is held over in .Rdata from the last session. The manual states that now .Rdata is loaded last, as intended. My question is, how do I change what's in .First (or any other variable, for that matter), if .Rdata will always override my changes? (I'd prefer not to have to do it manually, and I'd prefer to have all the other data preserved, rather than just leaving out .Rdata) Dave R.
______________________________________________ R-help at stat.math.ethz.ch mailing list http://www.stat.math.ethz.ch/mailman/listinfo/> r-help
On Wednesday, February 5, 2003, at 09:30 PM, Henrik Bengtsson wrote:
What do you have in .First() that you can not have directly in the .Rprofile script? For example:
Nothing that I can think of, but it's the principle of the thing. If i did have a reason to change .First, how would I do it ? More generally, suppose I want to ensure a variable is set to a certain value in .Rprofile, how can I be sure that R.data won't overwrite it? It just seems like loading .Rdata after .Rprofile makes it difficult to change things easily.
# ~/.Rprofile
cat("Running my .Rprofile...");
library(modreg)
cat("Running my .Rprofile...done");
Henrik Bengtsson
-----Original Message----- From: r-help-admin at stat.math.ethz.ch [mailto:r-help-admin at stat.math.ethz.ch] On Behalf Of David Richmond Sent: den 6 februari 2003 13:57 To: r-help at stat.math.ethz.ch Subject: [R] .Rprofile, .Rfirst, and .Rdata Hi all, After a short hiatus away from R I have found that it's changed a bit. I used to keep a definition of .First in .Rprofile that did a couple of things on startup (load a couple of libraries). Now, I've discovered that when I change the definition of .First in .Rprofile it doesn't change anything when I start up, because .First is held over in .Rdata from the last session. The manual states that now .Rdata is loaded last, as intended. My question is, how do I change what's in .First (or any other variable, for that matter), if .Rdata will always override my changes? (I'd prefer not to have to do it manually, and I'd prefer to have all the other data preserved, rather than just leaving out .Rdata) Dave R.
______________________________________________ R-help at stat.math.ethz.ch mailing list http://www.stat.math.ethz.ch/mailman/listinfo/> r-help
"David" == David Richmond <daver969 at yahoo.com>
on Wed, 5 Feb 2003 22:45:04 -0800 writes:
David> On Wednesday, February 5, 2003, at 09:30 PM, Henrik Bengtsson wrote:
>> What do you have in .First() that you can not have directly in the
>> .Rprofile script? For example:
>>
David> Nothing that I can think of, but it's the principle
David> of the thing. If i did have a reason to change
David> .First, how would I do it ? More generally, suppose I
David> want to ensure a variable is set to a certain value
David> in .Rprofile, how can I be sure that .RData won't
David> overwrite it? It just seems like loading .RData after
David> .Rprofile makes it difficult to change things easily.
Setting global variables and relying on their values is always `un-clean'.
In your case, I would set options(): They can't ever be overridden by
any .RData -- e.g.,
options(myABC = 1:3, myFile = "/abc/def")
and then use getOption("myABC")
instead of a global variable named `ABC'.
BTW: I advocate not working with .RData at all.
I work with *.R scripts (using ESS) and when needed, explicit
save(.) and load(.) for a given list of objects and with
filenames such as "foobar.rda" instead of ".RData".
Martin Maechler <maechler at stat.math.ethz.ch> http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum LEO C16 Leonhardstr. 27
ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND
phone: x-41-1-632-3408 fax: ...-1228 <><
For me, it's useful to have local versions of .First in the working directories of each project. I put global startup stuff in .Rprofile and startup stuff particular to each project in the .First-s. I've always thought that .First was designed for that purpose. Pierre Kleiber Email: pkleiber at honlab.nmfs.hawaii.edu Fishery Biologist Tel: 808 983-5399/737-7544 NOAA FISHERIES - Honolulu Laboratory Fax: 808 983-2902
David Richmond wrote:
On Wednesday, February 5, 2003, at 09:30 PM, Henrik Bengtsson wrote:
What do you have in .First() that you can not have directly in the .Rprofile script? For example:
Nothing that I can think of, but it's the principle of the thing. If i did have a reason to change .First, how would I do it ? More generally, suppose I want to ensure a variable is set to a certain value in .Rprofile, how can I be sure that R.data won't overwrite it? It just seems like loading .Rdata after .Rprofile makes it difficult to change things easily.
# ~/.Rprofile
cat("Running my .Rprofile...");
library(modreg)
cat("Running my .Rprofile...done");
Henrik Bengtsson
-----Original Message-----
From: r-help-admin at stat.math.ethz.ch
[mailto:r-help-admin at stat.math.ethz.ch] On Behalf Of David Richmond
Sent: den 6 februari 2003 13:57
To: r-help at stat.math.ethz.ch
Subject: [R] .Rprofile, .Rfirst, and .Rdata
Hi all,
After a short hiatus away from R I have found that it's
changed a bit.
I used to keep a definition of .First in .Rprofile that did a
couple of
things on startup (load a couple of libraries). Now, I've discovered
that when I change the definition of .First in .Rprofile it doesn't
change anything when I start up, because .First is held over
in .Rdata
from the last session. The manual states that now .Rdata is loaded
last, as intended. My question is, how do I change what's in
.First (or
any other variable, for that matter), if .Rdata will always
override my
changes? (I'd prefer not to have to do it manually, and I'd prefer to
have all the other data preserved, rather than just leaving
out .Rdata)
Dave R.
______________________________________________ R-help at stat.math.ethz.ch mailing list http://www.stat.math.ethz.ch/mailman/listinfo/> r-help
______________________________________________ R-help at stat.math.ethz.ch mailing list http://www.stat.math.ethz.ch/mailman/listinfo/r-help