Take the 2-minute tour ×

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.


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.

share|improve this question
This appears to be a problem with the mgcv package. Did you try just installing the latest version of mgcv and then typing library(mgcv)? –  whistler Sep 30 '13 at 4:32
I used RStudio utilities to install mgcv and it picked up an updated version. However, it showed exactly the same error. The same happens if I use the command line to install mgcv. –  Robert Smith Sep 30 '13 at 4:39
Since it is complaining of 'indent' and 'width' values, I'm wondering if you altered plot window settings at all? If so, you may also want to try resetting plot window settings back to default values and then retrying the install. –  whistler Sep 30 '13 at 4:41
I haven't changed plot window settings at all. Actually, I reinstalled R since I had an older version. However, if you think this could be the issue, how can I do that in linux? –  Robert Smith Sep 30 '13 at 5:03

3 Answers 3

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

share|improve this answer
I cannot believe this works, but it does. –  alexplanation Dec 11 at 23:36
up vote 0 down vote accepted

Finally got it working.

I had to remove rstudio via sudo apt-get --purge remove rstudio and remove ~/.config/RStudio. Oddly enough, this didn't remove everything because some opened documents remained when I reinstalled RStudio. However, it did the trick.

> library(TSA)
Loading required package: leaps
Loading required package: locfit
locfit 1.5-9.1   2013-03-22
Loading required package: mgcv
Loading required package: nlme
This is mgcv 1.7-26. For overview type 'help("mgcv-package")'.
Loading required package: tseries

    ‘tseries’ version: 0.10-32

    ‘tseries’ is a package for time series analysis and
    computational finance.


Attaching package: ‘TSA’

The following objects are masked from ‘package:stats’:

    acf, arima

The following object is masked from ‘package:utils’:



Unfortunately, every time I restart RStudio, I get the same error as before. So this is only a temporary solution. Suggestions?


Ultimately, this issue seems to have been resolved. I removed ~/.rstudio-desktop/monitored/user-settings/ and the problem immediately was solved without requiring reinstalling RStudio.

share|improve this answer

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.

share|improve this answer

Your Answer


