I have looked extensively to find the answer to this before asking and could not find the answer, but if its out there please point me to it. Every time I start R studio I have packages that load automatically like:
Loading required package: RMySQL
Loading required package: DBI
Loading required package: cocor
Loading required package: RMySQL
I would like these packages to stop loading automatically every time I start R studio, and have tried uninstalling and reinstalling R and R studio in addition to the following:
detach("package:RMySQL",unload=TRUE)
For all three of these packages and it doesn't work. Please help! Thank you.
sapply(ls(), function(x) class(get(x)))
named list()
Look at this post and you probably want to find your .RProfile
file. Look at ?Startup
(note capital S) for more help. The .RProfile
is should be under the /etc/
folder underneath wherever R is installed on your machine. Per the post above, a fast way to find its location would be to run the following:
candidates <- c( Sys.getenv("R_PROFILE"),
file.path(Sys.getenv("R_HOME"), "etc", "Rprofile.site"),
Sys.getenv("R_PROFILE_USER"),
file.path(getwd(), ".Rprofile") )
Filter(file.exists, candidates)
From the comments you've posted, it looks like you're running Windows. The location for a user .RProfile
can be shown using:
(my_rprofile <- file.path(Sys.getenv("R_USER"), ".RProfile"))
You can then check whether that file exists using:
file.exists(my_rprofile)
and if this returns TRUE
, open it for editing using:
file.edit(my_rprofile)
If the file isn't there, try:
file.exists(".RProfile")
and if TRUE
:
file.edit(".RProfile")
If you execute this command within RStudio, you should get a window open with the current contents of your .RProfile
. I suspect it includes something along the lines of:
library("RMySQL")
which you then need to remove as appropriate before saving.
Other things to check:
Sys.getenv("R_DEFAULT_PACKAGES")
# should be blank
.First
# should give an error that .First not found
If .First
is set and you don't have a .RProfile
file, you might have it defined in file.path(Sys.getenv("R_USER"), ".RData")
and it would be worth renaming that file (or disabling restoring .RData
in the RStudio options.
Even if .First
is undefined, I'd still try loading R/RStudio without restoring from .RData
since it may be that you're restoring some S4 objects which depend on those packages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With