Base packages unavailable after updating R - 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.

Related

During startup - Warning message: package ‘stats’ in options("defaultPackages") was not found in windows Rstudio eventhough stats package works in R

I have tried multiple reinstallation of R and Rstudios but following problem is presistent. Any help with this will be highly appreciated.
R version is 4.2.2
and Rstudio is 2022.12.0.-353
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/library/stats/libs/x64/stats.dll':
LoadLibrary failure: The network path was not found.
[Workspace loaded from ~/.RData]
Making 'packages.html' ... done
There should not be this error, I was following the tutorial exactly.
Go to the package window and see if the stats is checked or not. If it's not checked, check it and install/or update it using the GUI. This worked for me.

stats package not found in 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.

package or namespace load failed when trying to load 'stats' package in R

I have been trying to work with a git repository and my R 3.6.3 keeps giving me error messages. I have tried reinstalling both R and the stats package, installing Rtools, copying the stats directory from the R folder in other clients but none of seem to be working. The stats package is still found among my packages but R keeps failing to load the .dll file.
The exact error I get is:
Error message: 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':

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

Resources