2

I am trying to use the mgcv-package, but the mgcv::gam-function only returns an error message

Tmean = c(1,3,10,5,7)
prec = c(300,500,700,600,500)

fit = mgcv::gam(Tmean ~ s(prec))

Error message:

Error in reformulate(pav, env = p.env) : unused argument (env = p.env)

I am using R Version R version 3.5.2 (2018-12-20) and installed mgcv package version 1.8-33. During the installation I also recognized this code lines

  • byte-compile and prepare package for lazy loading Note: possible error in 'reformulate(av, response = ret[[1]]$response, ': unbenutztes Argument (env = p.env) Note: possible error in 'reformulate(pav, env = p.env)': unbenutztes Argument (env = p.env) ** help

I had the package "gam" previously installed and also had both loaded via library, which I found out was a bad idea.

R Package conflict between gam and mgcv?

I tried to detach and delete both packages and reinstalled only mgcv, but I get the same error. I am stuck here and also could not find a solution on the internet. Any suggestions how I could solve the problem?

The gam-function from the gam-package works as long as I do not load the mgcv-package via library.

This is also my first question on stackoverflow, so sorry if made any formatting errors or if I forgot some details in the question. Best, Josef

Josef
  • 21
  • 2

1 Answers1

2

I had same message when installing latest mgcv package with R 3.5.0. I could remove the warning by installing older version of 'mgcv' package, the one which was released after my R release.

If you are using 3.5.2 (2018-12-20), maybe you shoud try to install the version released on 2019-02-06 (1.8-29) manually.

Archive list here : https://cran.r-project.org/src/contrib/Archive/mgcv/

R CMD INSTALL mgcv_1.8-29.tar.gz
JulienV
  • 358
  • 2
  • 9
  • Thanks a lot for the fast answer. This solution worked for me. I installed mgcv_1.8-29.tar.gz manually and can now run the functions of mgcv. – Josef Sep 24 '20 at 07:19
  • Just to add to this. In windows it is: packageurl <- "https://cran.r-project.org/src/contrib/Archive/mgcv/mgcv_1.8-29.tar.gz" install.packages(packageurl, repos=NULL, type="source") – cs0815 Oct 02 '20 at 09:44