I am having real trouble understanding what my problem is installing ggplot package in Rstudio. I have tried a number of the post here and here but I still can't fix the problem.
I understand that I have a library directory on my Windows machine which can be found using:
.libPaths() which returns
[1] "C:/Users/Bo Bo/Documents/R/win-library/3.2" "C:/Program Files/R/R-3.2.3/library"
I'm not sure what is stored in this directory using .Library but it looks to be pointing to the wrong directory, 3.2.3 and 32~1.3???:
[1] "C:/PROGRA~1/R/R-32~1.3/library"
Upon installing ggplot2
install.packages("ggplot2") returns:
Installing package into ‘C:/Users/Bo Bo/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.2/ggplot2_2.1.0.zip'
Content type 'application/zip' length 2001769 bytes (1.9 MB)
downloaded 1.9 MB
package ‘ggplot2’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\Bo Bo\AppData\Local\Temp\Rtmp4QKdwV\downloaded_packages
So is it dumping the package in a temp directory because the 'lib' is unspecified? If so how do I specify the 'lib' and which library needs to change.
By the way I followed #Paweł Rumian post in link 2 above meaning I have a new User variable called R_LIBS_USER pointing to C:/Program Files/R/R-3.2.3/library
Can anyone make a suggestion as to how I can resolve this conflict and move on with my life :)
So I ended up re-installing windows after hours of trying to modify/fix the permissions issue I was having with all folders on the local disk.
Since re-installing I have installed Rstudio as per before and I am back in business, no messing around with library locations, just plain vanilla for me please...
Related
I'm trying to install Tidytext package. It seems to me that R is installing the package into my OneDrive. I've been using R and I've not run into this problem before. I've unsynchronized One Drive and done a variety of things to change my working drive, but I still get the following message when installing Tidytext package -
Installing package into "C:/Users/Anjan/OneDrive/Documents/R/win-library/3.5"
(as "lib" is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/tidytext_0.2.0.zip'
Content type 'application/zip' length 2836849 bytes (2.7 MB)
downloaded 2.7 MB
I've unsynchronized One Drive from my Documents folder on This PC.
I've checked getwd()
I've set setwd()
I've used Tools and Global Options and changed my working directory.
But R still uses One Drive. How do I get R to not use One Drive?
install.packages("tidytext")
Installing package into "C:/Users/Anjan/OneDrive/Documents/R/win-library/3.5"
(as "lib" is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/tidytext_0.2.0.zip'
Content type 'application/zip' length 2836849 bytes (2.7 MB)
downloaded 2.7 MB
package ‘tidytext’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\Anjan\AppData\Local\Temp\RtmpYDylTE\downloaded_packagesinstall.packages("magritte")
Installing package into "C:/Users/Anjan/OneDrive/Documents/R/win-library/3.5"
(as "lib"is unspecified)
Warning in install.packages :
package ‘magritte’ is not available (for R version 3.5.3)
getwd()
[1] "C:/Users/Anjan/OneDrive/Documents"
Use this to see actual library paths:
.libPaths()
And the same to set another destination folder to install:
.libPaths(PATH_THAT_YOU_WANT)
You can also specify a location like we see here:
Install R package to a specific directory
Take a look into the docs:
https://rdocumentation.org/packages/base/versions/3.6.1/topics/libPaths
It's a bug, reported at https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17842.
R should never put libraries in a user's documents folder. That is an inappropriate use of that folder, and there are better places for this kind of data.
This will probably be answered by someone directing me to a help file but I'm clearly missing it thus far. My quandry is that when I install a package (sometimes), it does not appear to default to the contents of my .libPaths - instead it appears to want to install to a network path to which it does not have permission.
Here is my library path
>.libPaths()
[1] "C:/Program Files/R/R-3.3.0/library"
If I try to install this package without specifying the lib argument it seems like it is trying to save to a network folder (I have changed the name of the network drive in the error message but you get the idea):
> install.packages("rmarkdown")
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/rmarkdown_0.9.6.zip'
Content type 'application/zip' length 2182803 bytes (2.1 MB)
downloaded 2.1 MB
package ‘rmarkdown’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\my.name\AppData\Local\Temp\RtmpkFVHnn\downloaded_packages
Warning message:
In dir.create(configDir, recursive = TRUE) :
cannot create dir '\\server.name\server_directory', reason 'Permission denied'
However, if I specify .libpaths() in the "lib" argument, then it works. But isn't this the default to the lib argument?
> install.packages("rmarkdown",lib=.libPaths())
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/rmarkdown_0.9.6.zip'
Content type 'application/zip' length 2182803 bytes (2.1 MB)
downloaded 2.1 MB
package ‘rmarkdown’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\jordan.watson\AppData\Local\Temp\RtmpkFVHnn\downloaded_packages
This does not happen every time however. For example, I just loaded the "forecast" library no problem by simply writing install.packages("forecast").
I'd just like to understand this behavior better. Can someone explain why this is happening? I am on Windows 7 without full admin privileges - but I do have admin privileges to my R folder on the C drive.
Apologies in advance that I can not make a reproducible example - it's not really that type of question.
Jordan,
My feeling is your setup is incorrect.
Proposed Solution
Try running the following command and see if this fixes the situation.
Note: I have replaced my userid with <user> in the examples below.
.libPaths( c( "C:/Users/<user>/Documents/R/win-library/3.3", .libPaths()) )
Explanation
I would expect .libPaths() to return two directories not one by default.
> .libPaths()
[1] "C:/Users/<user>/Documents/R/win-library/3.3" "C:/Program Files/R/R-3.3.0/library"
When you install R it installs the base libraries under
C:/Program Files/R/R-3.3.0/library
any new libraries are normally added to:
"C:/Users/<user>/Documents/R/win-library/3.3"
if you type View(installed.packages()) you will be able to see where the packages are installed.
The packages that come with the R install (base, stats, and nearly 30 others) are stored in the library subdirectory of wherever you installed R. You can retrieve the location of this with:
> R.home("library")
[1] "C:/PROGRA~1/R/R-33~1.1/library"
> .Library
[1] "C:/PROGRA~1/R/R-33~1.1/library
You also get a user library for installing packages that will only be accessible by you. The location under Windows, for R version x.y.z, it is in the R/win-library/x.y subfolder of the home directory, where the home directory can be found via:
> path.expand("~")
[1] "C:/Users/<user>/Documents"
> Sys.getenv("HOME")
[1] "C:/Users/<user>/Documents"
Issue
Thus, I would expect .libPaths() to return two paths not one which implies that you have somehow misconfigured the R installation libpath.
I hope the above helps.
Refs:
https://stat.ethz.ch/R-manual/R-devel/library/base/html/libPaths.html
Learning R By: Richard Cotton
I am trying to download GIStools in R. I did this through the Packages menu > Install Packages. I then selected GIStools and it appears to have installed it as I get the following message:
> utils:::menuInstallPkgs()
trying URL 'https://mirrors.ebi.ac.uk/CRAN/bin/windows/contrib/3.2/GISTools_0.7-4.zip'
Content type 'application/zip' length 3460038 bytes (3.3 MB)
downloaded 3.3 MB
package ‘GISTools’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\MachineX\AppData\Local\Temp\RtmpCCEk3L\downloaded_packages
I didn't select a mirror site from which to d/l the package (was it supposed to prompt me?) When I call the library using library(GIStools) I get the following error:
Error in library(GIStools) : there is no package called ‘GIStools’
I'm not sure what I have done wrong - can anyone help? I am using R version 3.2.3. I am totally new to R, so apologies if this seems like a silly question.
Thanks!
in the console type install.packages('GIStools') make sure you are running rstudio as admin when doing this. This should install just fine make sure you don't have the rstudio screen maximized as the mirror prompt could be hidden.
My rjson package randomly doesn't work. As in, it works fine sometimes, sometimes it fails to load. Not sure why.
I get this error.
Error in library("rjson") : there is no package called ‘rjson’
To try and alleviate this, despite knowing its installed, I added an install line in my script.
install.packages("rjson", repos="http://cran.rstudio.com/")
library(rjson)
Now I get....
Installing package(s) into ‘C:/Users/Tom/Documents/R/win-library/2.15’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/bin/windows/contrib/2.15/rjson_0.2.13.zip'
Content type 'application/zip' length 491848 bytes (480 Kb)
opened URL
downloaded 480 Kb
package ‘rjson’ successfully unpacked and MD5 sums checked
Warning: cannot remove prior installation of package ‘rjson’
The downloaded binary packages are in
C:\Users\Tom\AppData\Local\Temp\RtmpiOfTqK\downloaded_packages
In R, when I go to "Packages --> Load" for some reason rjson is NOT there. It never has been, even when it worked.
I've naviaged to...
C:\Users\Tom\Documents\R\win-library\2.15
I can confirm the folder for rjson is there.
No idea what to do.
This has happened to me quite a few times. It usually happens when you try to install a newer version of an already installed package (although it can happen in other more rare occasions).
The solution I have found so far is to go back to your library path i.e. the location on your machine where the package is installed (C:\Users\user_name\Documents\R\win-library\R_version is the default path on Windows) delete the corresponding package folder and then re-install the package as usual using:
install.packages('rjson')
And this way it should work.
Or you could even do it programmatically as per #Thomas 's comment:
#get list of installed packages
inst_packages <- installed.packages()
if ("rjson" %in% inst_packages[, 1]) {
#uninstalls package
remove.packages("rjson")
#re-installs package
install.packages("rjson")
}
or even better just use:
if ("rjson" %in% inst_packages[, 1]) update.packages("rjson")
I have always worked with the zoo package, that I have installed a long time ago. Today, I created a new R script, and ran library(zoo) and got the following error:
> library(zoo)
Error in library(zoo) : there is no package called ‘zoo’
Odd.. Still, I tried reinstalling the package using install.packages("zoo"), and get the following:
> install.packages("zoo")
Installing package(s) into ‘C:/Users/U122337.BOSTONADVISORS/Documents/R/win-library/2.15’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
trying URL 'http://cran.cnr.Berkeley.edu/bin/windows/contrib/2.15/zoo_1.7-10.zip'
Content type 'application/zip' length 874474 bytes (853 Kb)
opened URL
downloaded 853 Kb
package ‘zoo’ successfully unpacked and MD5 sums checked
Warning: cannot remove prior installation of package ‘zoo’
The downloaded binary packages are in
C:\Users\U122337.BOSTONADVISORS\AppData\Local\Temp\Rtmp404t8Y\downloaded_packages
When I try uploading the package, I get the error again that the zoo package doesn't exist.
I have no idea what's happening. I exited the GUI and restarted it, same problem. I have always worked with this package, and I have no idea why this is happening now.
Do .libPaths(), close every R runing, check in the first directory, remove the zoo package restart R and install zoo again. Of course you need to have sufficient rights.
When you run
install.packages("whatever")
you got message that your binaries are downloaded into temporary location (e.g. The downloaded binary packages are in
C:\Users\User_name\AppData\Local\Temp\RtmpC6Y8Yv\downloaded_packages ). Go there. Take binaries (zip file). Copy paste into location which you get from running the code:
.libPaths()
If libPaths shows 2 locations, then paste into second one. Load library:
library(whatever)
Fixed.
I had this problem and the issue was that I had the package loaded in another R instance. Simply closing all R instances and installing on a fresh instance allowed for the package to be installed.
Generally, you can also install if every remaining instance has never loaded the package as well (even if it installed an old version).
So the package will be downloaded in a temp folder C:\Users\U122337.BOSTONADVISORS\AppData\Local\Temp\Rtmp404t8Y\downloaded_packages from where it will be installed into your library folder, e.g. C:\R\library\zoo
What you have to do once install command is done: Open Packages menu -> Load package...
You will see your package on the list. You can automate this:
How to load packages in R automatically?
go to this folder C:\Users\hp\Documents\R\win-library\4.0 in your PC.
And delete '00LOCK' named folder.
then It will work properly, THis folder is being locked all incoming file.IF your delete this , then it will work.