[R] .Rprofile: "contains invalid line(s)"

Stephen Davies stephen at umw.edu
Thu Jun 5 16:18:49 CEST 2014


    At some point in the recent past, my local .Rprofile has ceased to be
executed on startup. I've upgraded R several times in the last few months, and
am unsure which version caused this problem. Currently I'm running version
3.1.0 (2014-04-10) "Spring Dance" on 64-bit Ubuntu.

    My symptoms and fix attempts:

    1) Changes I make to .Rprofile are no longer automatically recognized by R
on startup.

    2) After some Googling, I was led to believe that I need to set the
environment variable R_ENVIRON to "/home/stephen/.Rprofile." But after doing
so, when I start R, I get an error message: "File /home/stephen/.Rprofile
contains invalid line(s)". Then it lists the contents of .Rprofile, which are
now simply:

.First <- function() { 
    joe <<- function(x) x*2
}

    This file is perfectly valid, however, which I know because when I
explicitly source() it, it loads .First just fine, and if I run ".First()", I
can then successfully run "joe(3)".

    Why does R say this .Rprofile is invalid on startup? Is setting R_ENVIRON,
as described, the correct procedure? And why did this suddenly become
necessary?

- Stephen Davies, Ph.D.
  (stephen at umw.edu)



More information about the R-help mailing list