Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"package ‘mgcv’ could not be loaded" only in RStudio

Tags:

r

rstudio

I'm getting this error when trying to load the package "TSA" in RStudio:

Loading required package: leaps
Loading required package: locfit
locfit 1.5-9.1   2013-03-22
Loading required package: mgcv
Loading required package: nlme
Error : .onAttach failed in attachNamespace() for 'mgcv', details:
  call: formatDL(nm, txt, indent = max(nchar(nm, "w")) + 3)
  error: incorrect values of 'indent' and 'width'
Error: package ‘mgcv’ could not be loaded

I tried reinstalling mgcv and TSA, but it didn't help. However, when I load TSA from the R command line, it works without problem.

How can I fix this issue?

R version 3.0.2 (2013-09-25)

RStudio 0.97.551, 64 bits.

UPDATE:

I tested this issue in a 32 bit installation of RStudio and it worked flawlessly. I'm not sure what is the real culprit here.

like image 604
Robert Smith Avatar asked Sep 30 '13 03:09

Robert Smith


2 Answers

In RStudio, just resize the right side to increase the width of the windows. Now try library(mgcv) again, and it works!

like image 119
Cheng Avatar answered Nov 07 '22 06:11

Cheng


For the reference of anyone encountering a similar problem under Windows 7, I had the same problem with the forecast package - one day, it just wouldn't load in RStudio (worked fine in R). Had to completely uninstall both R and RStudio, making sure to delete C:\Program Files\R and C:\Users\[username]\AppData\Local\RStudio-Desktop and reinstall before it would work again. Wouldn't work if I just deleted the RStudio stuff and tried to keep the R files.

like image 26
Escher Avatar answered Nov 07 '22 06:11

Escher