Thanks to everyone for the help and advice! It turns out that my problem was
using $HOME in the .First function in Rprofile.site. Since $HOME is a user
specific variable, it seems to have crashed when running from the
$R_HOME/etc/ directory. I added the other .Rprofile files without deletng
the Rprofile.site file, so it never got to them. When I went back and
deleted Rprofile.site, the .Rprofile files in my home directory and working
directory work fine.

Thanks!
  S

On Mon, Jul 14, 2008 at 1:19 PM, Bryan Hanson <[EMAIL PROTECTED]> wrote:

> I accomplish this a little differently.
>
> On the mac, in your home directory (e.g. /Users/susanamrose) there is/could
> be a hidden file called .Rprofile  You can edit it with vi for instance by
> getting a terminal window and >vi .Rprofile  It will be created it if it
> doesn't exist.
>
> I keep all my local functions in a particular directory, then load them via
> the .Rprofile by putting the following lines in .Rprofile
>
> funcdir <- "/Users/susanamrose..../Functions"
> z <- paste(funcdir, "/LoadFunctions.R", sep = "")
> source(z, chdir = TRUE)
>
> This will source/execute whatever you put in the file LoadFunctions.R in
> the
> specified directory when R starts up.  So, for instance, LoadFunctions.R
> could be a bunch of source("func.R") statements.
>
> This also gives you a short cut to get to your functions directory by
> setwd(fundir).  I actually have a number of commonly used directories
> defined this way for convenience.
>
> HTH Bryan
>
> On 7/14/08 2:34 PM, "Susan Amrose" <[EMAIL PROTECTED]> wrote:
>
> > I'm trying to source a file automatically every time I start R. I tried
> > adding the following .First function in a file Rprofile.site in my
> > $R_HOME/etc/ directory (verified $R_HOME by Sys.getenv()) as well as in a
> > file .Rprofile in my $HOME directory and .Rprofile in the working
> directory:
> > .First <- function(){
> > source(file.path(Sys.getenv("HOME"), "R", "functions","standard.r"))
> >        cat("Actually read your file!!!!")
> > }
> >
> > - but no luck. I'm using a Mac (OS 10.4). It never runs (the file is not
> > sourced and the text does not appear). Does anyone have any suggestions?
> >
> > Ideally, I would like to have a directory and source all the files in the
> > directory in startup, but this is just a first step (is that possible?).
> >
> > Thanks in advance!!
> >  -Susan
> >
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help@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.
>
>
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to