Why does R ignore ~/.Rprofile

Why isn't R reading my ~/.Rprofile file?

I'm pretty sure this issue arose when I upgraded from R 3.4 to 3.5. I never had this problem with 3.4.

Here is my ~/.Rprofile:

options(
  repos = c(CRAN = "https://cran.rstudio.com/")
)

I would expect options()$repos to give:

> options()$repos
                       CRAN
"https://cran.rstudio.com/"

But instead I get:

> options()$repos
    CRAN
"@CRAN@"

This is my session info:

> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.6

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

loaded via a namespace (and not attached):
[1] compiler_3.5.1

This ~/.Rprofile won't be read if there is a .Rprofile in you project directory / working directory when launching R or if R executable is launched using --vanilla option or similar. Have you checked those ?

Otherwise, it should be read. For reference, a great post on R startup.

2 Likes

More info in this chapter, as well:

3 Likes

Thank you for the excellent links!

I think I must have had an .Rprofile file in my working directory that was masking the one in my home folder.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.