Reputation: 3568
I want to change my .Rprofile
file so that the magrittr
package loads automatically.
Following the threads on Stack Overflow on how to do this I created a text file with no '.txt' suffix and saved that in my home directory.
The contents of this file are simply
library("magrittr")
However when I exited R and started up again the error message
Error: 1:8: unexpected input
1: library(�
^
Was displayed on the first line of the window. I get similar messages when I have test code in the .Rprofile file such as
print("hello")
where the error message reads
Error: 1:6: unexpected input
1: print(�
^
Any suggestions would be much appreciated
Upvotes: 3
Views: 321
Reputation: 368261
Here is a simple way:
First we create a suitable (minimal).Rprofile
:
edd@max:~$ echo 'library(magrittr); cat("Hello from .Rprofile\n")' > .Rprofile
edd@max:~$
Then we test it:
edd@max:~$ R -q
Hello from .Rprofile
> search()
[1] ".GlobalEnv" "package:stats" "package:graphics"
[4] "package:grDevices" "package:utils" "package:datasets"
[7] "package:magrittr" "package:methods" "Autoloads"
[10] "package:base"
> q()
Save workspace image? [y/n/c]: n
edd@max:~$
Note how the search path includes package magrittr.
Many more options are detailed in help(Startup)
.
Upvotes: 2