0

I think I accidentally altered my PATH when loading my libraries. I know that my packages are installed but when I perform the library() function, I get the following error message.

> library(dplyr) 

**Error: package or namespace load failed for ‘dplyr’ in inDL(x, as.logical(local), as.logical(now), ...)
unable to load shared object 'C:/Program Files/R/R-3.6.2/library/stats/libs/x64/stats.dll':
  LoadLibrary failure:  The specified module could not be found.
In addition: Warning message:
package ‘dplyr’ was built under R version 3.6.3**


And when I first open R, this is what it looks like

**R version 3.6.2 (2019-12-12) -- "Dark and Stormy Night"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
  Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
    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.2/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.2/library/stats/libs/x64/stats.dll':
  LoadLibrary failure:  The specified module could not be found.**

I cannot perform any of the previous analyses I know should work. Any help on this matter would greatly be appreciated.

1 Answers1

1

One probable explanation is that the path to the library is miss-recorded in R. The command .libPaths() will list the current paths that R searches when looking for libraries. Check that the output from this matches the folders you believe packages to be installed in.

At the very least you should probably see the installation directory for R on this list. On Windows something like "C:/Program Files/R/R-3.6.2/library".

If you are not seeing any paths/the paths you expect to see, then you can add additional paths using:

.libPaths( c( .libPaths(), "path/to/installed/packages") )

Should you identify this as the cause, all take a look at this question and this one. Both of these links deal with making permanent changes to the library paths.

Simon.S.A.
  • 6,240
  • 7
  • 22
  • 41
  • Thank you for your help Simon. This is what I get. > .libPaths() [1] "C:/Users/Sterling L. Wright/Documents/R/win-library/3.6" [2] "C:/Program Files/R/R-3.6.2/library" Now I tried your code suggestion. But when I did this, here are the outputs. > .libPaths( c( .libPaths(), "C:~/Documents/R/win-library/3.6")) > library(dplyr) Error: package or namespace load failed for ‘dplyr’ in inDL(x, as.logical(local), as.logical(now), ...): unable to load shared object 'C:/Program Files/R/R-3.6.2/library/stats/libs/x64/stats.dll': LoadLibrary failure: The specified module could not be found. – Sterling Wright Jul 22 '20 at 21:24
  • I am not sure if this helps but when I enter sessionInfo() `> 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-40~1.2/modules/x64/lapack.dll': LoadLibrary failure: The specified module could not be found.` – Sterling Wright Jul 22 '20 at 22:21
  • This might not be a package error. Reinstalling is probably the simplest solution. – Simon.S.A. Jul 23 '20 at 04:50