"Error in the library (rjson): no package called rjson"

My rjson package randomly doesn't work. As in the case, it works fine sometimes, sometimes it does not load. I do not know why.

I get this error.

Error in library("rjson") : there is no package called 'rjson' 

To try to mitigate this, despite the fact that he knows it, I added the installation line to my script.

  install.packages("rjson", repos="http://cran.rstudio.com/") library(rjson) 

Now I get ....

Install package (s) in 'C: /Users/Tom/Documents/R/win-library/2.15 (since' lib is not specified ') try url' http://cran.rstudio.com/bin/windows/contrib/ 2.15 / rjson_0.2.13.zip 'Content type "application / zip" length 491848 bytes (480 Kb) open URL downloaded 480 Kb

'rjson package successfully unpacked and MD5 sums checked Warning: cannot uninstall previous installation of' rjson package

Downloaded binary packages are located in C: \ Users \ Tom \ AppData \ Local \ Temp \ RtmpiOfTqK \ downloaded_packages

In R, when I go to "Packages β†’ Download", for some reason rjson is NOT there. It never was, even when it worked.

I drew...

C: \ Users \ Tom \ Documents \ R \ win-win library \ 2.15

I can confirm the folder for rjson.

I do not know what to do.

+5
source share
1 answer

This has happened to me quite a few times. This usually happens when you try to install a newer version of an already installed package (although this can also happen in other rarer cases).

The solution that I have found so far is to return to the path to your library, that is, to the location on your computer where the package is installed ( C:\Users\user_name\Documents\R\win-library\R_version - the default path on Windows) remove the appropriate package folder, and then reinstall the package, as usual, using:

 install.packages('rjson') 

And so it should work.

Or you could do it programmatically according to @Thomas 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 to use:

 if ("rjson" %in% inst_packages[, 1]) update.packages("rjson") 
+5
source

Source: https://habr.com/ru/post/1232037/


All Articles