3

I have created a model in R and I need to use copula which involves using the copula package. I am using the latest version of R on a MacBook Pro that is fully updated.

I can install the copula package but when I trying to open the library(copula) I get the following error:

Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : there is no package called ‘gsl’ Error: package or namespace load failed for ‘copula’

I use R for statistical analysis and I am not a programmer and honestly I have no idea what loadNamespace even means. I have spent an hour looking through Google and I have tried to follow what the few that are out there say (update packages for example) to do but it doesn't solve anything.

Hack-R
  • 22,422
  • 14
  • 75
  • 131
Sam
  • 91
  • 1
  • 10
  • Hi Sam, could you please show your code and also the output of `R.Version()` just to be safe? – Hack-R Jun 30 '16 at 18:50

3 Answers3

4

Try this. If it doesn't work please update your question with all messages from RStudio/R when you run this.

if(!require(pacman)) install.packages("pacman")
pacman::p_load(copula)

also installing the dependencies ‘gsl’, ‘ADGofTest’, ‘stabledist’, ‘pspline’

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/gsl_1.9-10.1.zip' Content type 'application/zip' length 1154961 bytes (1.1 MB) downloaded 1.1 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/ADGofTest_0.3.zip' Content type 'application/zip' length 13377 bytes (13 KB) downloaded 13 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/stabledist_0.7-0.zip' Content type 'application/zip' length 41314 bytes (40 KB) downloaded 40 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/pspline_1.0-17.zip' Content type 'application/zip' length 60943 bytes (59 KB) downloaded 59 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/copula_0.999-14.zip' Content type 'application/zip' length 16620593 bytes (15.9 MB) downloaded 15.9 MB

package ‘gsl’ successfully unpacked and MD5 sums checked package ‘ADGofTest’ successfully unpacked and MD5 sums checked package ‘stabledist’ successfully unpacked and MD5 sums checked package ‘pspline’ successfully unpacked and MD5 sums checked package ‘copula’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in C:\Users\BigDaddy\AppData\Local\Temp\RtmpA7nv6c\downloaded_packages

copula installed

Hack-R
  • 22,422
  • 14
  • 75
  • 131
  • That worked perfectly thank you. I have absolutely no idea what it did but I am very thankful for your help. – Sam Jun 30 '16 at 19:06
  • Oh, I see. It had a dependency with a package called pacman. For future reference where can I find out which dependency a package I am trying to load has? – Sam Jun 30 '16 at 19:15
2

Thanks for Hack-R provided solution. It works fine for me.

Here i just want to add more although I am not sure the following info is useful, but I have met this problem on several different Ubuntu machine, it is that on Ubuntu you may also need to run sudo apt-get install libgsl0-dev to solve a gsl error.

ytutow
  • 285
  • 1
  • 4
  • 13
  • +1 This solve the missing dependency! But on Debian-Linux libgsl-dev and libgsl2 where automatically installed instead. Also see the GNU gsl page: [http://www.gnu.org/software/gsl/] – sdittmar Mar 13 '19 at 21:16
0

It looks like copula depends on gsl, and gsl hasn't been installed. Try manually installing gsl, along with any other dependencies.

Hack-R
  • 22,422
  • 14
  • 75
  • 131
  • 1
    isn't it a better practice to use `pacman` so that you're not manually installing dependencies for the rest of your life? It could be that after manually installing `gsl` he then has to install one of the several other dependencies of this package, and then the next, and so on, and so on and he'll have the same problem with the next package, etc, etc. The dependencies might themselves have unmet dependencies. Just use `pacman`. – Hack-R Jun 30 '16 at 19:02