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

Henrik Bengtsson hb at biostat.ucsf.edu
Thu Jun 5 23:51:11 CEST 2014


Make sure that the last line has a newline at the end, otherwise that
expression will be silently ignored, cf. R-devel thread '[Rd] Last
line in .Rprofile must have newline (PR#4056)' on 2003-09-03
[https://stat.ethz.ch/pipermail/r-devel/2003-September/027455.html].
I'm pretty sure many many people have been bitten by this "feature".

Other than that, add a message(".Rprofile...") and the very top and a
message(".Rprofile...done") at the very bottom to confirm that
~/.Rprofile is loaded/evaluated.

/Henrik

On Thu, Jun 5, 2014 at 10:58 AM, Ista Zahn <istazahn at gmail.com> wrote:
> Hi Stephan,
>
> R_ENVIRON should not point to your .Rpofile, use R_PROFILE_USER for
> that. See ?Startup for details.
>
> Best,
> Ista
>
> On Thu, Jun 5, 2014 at 10:18 AM, Stephen Davies <stephen at umw.edu> wrote:
>>
>>     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)
>>
>> ______________________________________________
>> R-help at 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.
>
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list