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
Here is a simple way:
First we create a suitable (minimal).Rprofile
:
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:~$
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)
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.