0

I recently changed a statement in .Rprofile. It was to load a source file:

source("/home/theuser/olddir/myfile")

This statement is in .First <- function() of .Rprofile file.

I changed it to:

source("/home/theuser/newdir/myfile")

However, on starting R, I am getting following error message:

cannot open file '/home/theuser/olddir/myfile': No such file or directory

R still looks for old file. How can I correct this. Thanks for your help.

The .Rprofile is:

$ cat .Rprofile

options(tab.width = 2)
options(width = 130)
options(graphics.record=TRUE)
options(show.signif.stars=FALSE)

.First <- function(){
 library(Hmisc)
 #library(R2HTML)
 source("/home/theuser/newdir/myfile")
 cat("\nSuccessfully loaded .Rprofile at", date(), "\n")
}

.Last <- function(){
 cat("\nGoodbye at ", date(), "\n")
}
rnso
  • 23,686
  • 25
  • 112
  • 234
  • Where is `.Rprofile` located? Does R displays this error if run in the root of your home directory? –  Sep 19 '14 at 03:36
  • Any `.Renviron` or `Rprofile.site`? –  Sep 19 '14 at 03:53
  • You can search in your home directory: `ls .R*` and `ls *.site`. –  Sep 19 '14 at 03:58
  • There are: .RData .Rhistory .RLPlot .Rprofile . No *.site file. – rnso Sep 19 '14 at 04:00
  • Can you `source("/home/theuser/newdir/myfile")` in R? –  Sep 19 '14 at 04:54
  • Yes, I can and that is what I now do to load it. – rnso Sep 19 '14 at 04:55
  • Possibly, it is running another Rprofile file, try http://stackoverflow.com/q/13735745/1201032 – flodel Sep 19 '14 at 06:00
  • The ouput is: "/usr/lib/R/etc/Rprofile.site" "/home/theuser/.Rprofile" (All lines in Rprofile.site file are commented) – rnso Sep 19 '14 at 06:08
  • ok... Is your Rprofile sourcing a file that itself sources `/home/theuser/olddir/myfile`? Can you add `print` statements to your files to guide you to the problem? – flodel Sep 19 '14 at 06:23
  • I have added .Rprofile file in question above. – rnso Sep 19 '14 at 07:18
  • If you don't need the .RData, remove it and try again. –  Sep 19 '14 at 07:59
  • Yes, it worked: "Successfully loaded .Rprofile at Fri Sep 19 ..." Please enter this as an answer so that I can accept it and thanks for your efforts. – rnso Sep 19 '14 at 13:43

0 Answers0