stats package not found in R - r

I'm really having problems with RStudio.
It had been working fine a few days ago. Then it said I needed the newest version of RTools. I tried to install it but don't think it was successful. However now I can't load anything in R.
I am greeted with the following message when launching RStudio:
Error: package or namespace load failed for ‘stats’ in inDL(x, as.logical(local), as.logical(now), ...):
unable to load shared object 'C:/Program Files/R/R-3.6.3/library/stats/libs/x64/stats.dll':
LoadLibrary failure: The specified module could not be found.
During startup - Warning message:
package ‘stats’ in options("defaultPackages") was not found
Error in inDL(x, as.logical(local), as.logical(now), ...) :
unable to load shared object 'C:/Program Files/R/R-3.6.3/library/stats/libs/x64/stats.dll':
LoadLibrary failure: The specified module could not be found.
I have looked up solutions to this problem and people say to delete /Renviron but I don't know will that mess things up even more.
Here are a few results of things I type into R:
> Sys.getenv("PATH")
[1] "C:\rtools40"
> Sys.which("stats.dll")
stats.dll
""
> Sys.which("make")
make
""
I really don't understand what has gone wrong. Can anyone help?

You accidentally overwrote the PATH envvar. Your line in .Renviron must be: PATH="C:/rtools40/usr/bin;${PATH}" (mind the " and the {}), otherwise you'll lose the R installation path and R will not be able to load the shared library.

Related

After installing Rstudio and launching it, I get an rsession.exe system error saying "Rlapack.dll is missing from your computer"

I've just installed R x64 4.0.0 to my computer and have been trying to install RStudio.
When launching R by itself, I'm able to install packages and execute code no problem. However, when I open RStudio I get a system error saying that Rlapack.dll is missing from my computer and am prompted to reinstall the program which I have done several times to no avail. I have also tried reinstalling RStudio several times.
The following errors appear on the RStudio console after "oking" the system error popup:
Error: package or namespace load failed for ‘stats’ in inDL(x, as.logical(local), as.logical(now), ...):
unable to load shared object 'C:/Program Files/R/R-4.0.0/library/stats/libs/x64/stats.dll':
LoadLibrary failure: The specified module could not be found.
During startup - Warning message:
package ‘stats’ in options("defaultPackages") was not found
Error in inDL(x, as.logical(local), as.logical(now), ...) :
unable to load shared object 'C:/Program Files/R/R-4.0.0/library/stats/libs/x64/stats.dll':
LoadLibrary failure: The specified module could not be found.
I have also searched for the supposed missing dll in the R installation and found it in this location "C:\Program Files\R\R-4.0.0\bin\x64"
I am unable to run scripts through the RStudio IDE - does anyone know how to fix this dll issue and get RStudio working?
After scouring the internet and spending the best part of a day trying to get to the bottom of this, I have found something that seems to work..
Copy Rlapack.dll from
C:\Program Files\R\R-4.0.0\bin\x64
and paste it into the following locations:
C:\Program Files\R\R-4.0.0\library\stats\libs\x64
C:\Program Files\R\R-4.0.0\library\Matrix\libs\x64

Base packages unavailable after updating R

I've first updated R (from 3.6.3 to 4.0) and afterwards RStudio (from 1.2.5033 to the most recent 1.2.5042) on Windows 10. Because I kept receiving the error messages below, I downgraded to R 3.6.3 and Rstudio 1.1.463. However, the errors persist. When opening RStudio I receive the following:
Error: package or namespace load failed for ‘stats’ in inDL(x, as.logical(local), as.logical(now), ...):
unable to load shared object 'C:/Program Files/R/R-3.6.3/library/stats/libs/x64/stats.dll':
LoadLibrary failure:....
During startup - Warning message:
package ‘stats’ in options("defaultPackages") was not found
Error in inDL(x, as.logical(local), as.logical(now), ...) :
unable to load shared object 'C:/Program Files/R/R-3.6.3/library/stats/libs/x64/stats.dll':
LoadLibrary failure:...
stats.dll is in the above mentioned location.
Interestingly, I can use functions from the stats package in R.exe suggesting that RStudio causes the errors.
Similarly, I can't print a sessionInfo():
Error in La_library() : LAPACK routines cannot be loaded
In addition: Warning message:
In La_library() :
unable to load shared object 'C:/PROGRA~1/R/R-36~1.3/modules/x64/lapack.dll':
LoadLibrary failure:...
...even though lapack.dll is in the correct place.
It looks as there is confusion between folders of the old (3.6.3) and the new (4.0) version of R, see also this answer.
Suggestion: uninstall both versions of R and install R 4.0 from scratch into a new folder.

Unable to load shared object on startup in RStudio only

I'm not sure what I did, and my IS team is stumped. I updated R from 3.5.2 to 3.6.0 and R throws this error when opened in RStudio There is no problem when running R in the gui.
Error: package or namespace load failed for ‘stats’ in inDL(x, as.logical(local), as.logical(now), ...):
unable to load shared object 'C:/Program Files/R/R-3.6.0/library/stats/libs/x64/stats.dll':
LoadLibrary failure: The specified module could not be found.
I can navigate to the stats.dll file and the location matches my .libPaths():
"C:/Program Files/R/R-3.6.0/library"
I have uninstalled and reinstalled both R and RStudio (1.2.1335). I have also restarted my computer. Any help or even temporary solutions would be appreciated.
I found the answer on RStudio Community: I had a typo in one of the variables used in Sys.getenv("PATH")
https://community.rstudio.com/t/unable-to-load-shared-object-on-startup-in-rstudio-only/33107

Error in opening R packages

I have installed some packages on R Studio on my laptop, and I am having some issues opening them. When I try
require(ggplot)
I get this error:
Error: package or namespace load failed for ‘ggplot2’ in inDL(x, as.logical(local), as.logical(now), ...):
unable to load shared object 'C:/Users/marky/OneDrive/Documents/R/win-library/3.4/Rcpp/libs/x64/Rcpp.dll':
LoadLibrary failure: %1 is not a valid Win32 application.
Any clue to what is going on? It appears that Rcpp has something to do with converting C++ to R. When I go to the directory, I see it (although the size is 0KB). I also get this error on the UI

How to Resolve "Procedure could not be found" when loading RCurl in R?

Using R 3.1.1 64-bit in Windows 7, I am unable to load RCurl or any package which depends on RCurl. I have verified the existence of the .dll and other files in the expected location (i.e. the one printed in the error messages).
I opened an issue on Hadley's Github several months ago, but by the time someone responded I had started using another copy of R and the only suggestion was re-installation, which I've done several times.
The errors that I receive are like this:
require(devtools)
Loading required package: devtools
Error in inDL(x, as.logical(local), as.logical(now), ...) :
unable to load shared object 'C:/Users/jmiller/Documents/R/win-library/3.1/RCurl/libs/i386/RCurl.dll':
LoadLibrary failure: The specified procedure could not be found.
and
require(devtools)
Loading required package: devtools
Error in inDL(x, as.logical(local), as.logical(now), ...) :
unable to load shared object 'C:/Users/jmiller/Documents/R/win-library/3.1/RCurl/libs/i386/RCurl.dll':
LoadLibrary failure: The specified procedure could not be found.
Sometimes the errors appear even when only using primitive functions that are completely unrelated to RCurl, such as:
> require(devtools)
Loading required package: devtools
Error in inDL(x, as.logical(local), as.logical(now), ...) :
unable to load shared object 'C:/Users/jmiller/Documents/R/win-library/3.1/RCurl/libs/i386/RCurl.dll':
LoadLibrary failure: The specified procedure could not be found.
I almost wonder if the problem is somehow with inDL instead of RCurl but inDL?...

Resources