【问题标题】:"package ‘mgcv’ could not be loaded" only in RStudio仅在 RStudio 中“无法加载包‘mgcv’”
【发布时间】:2013-09-30 03:36:50
【问题描述】:

尝试在 RStudio 中加载包“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
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

我尝试重新安装 mgcv 和 TSA,但没有帮助。但是,当我从 R 命令行加载 TSA 时,它可以正常工作。

我该如何解决这个问题?

R 版本 3.0.2 (2013-09-25)

RStudio 0.97.551,64 位。

更新

我在 32 位安装的 RStudio 中测试了这个问题,它运行良好。我不确定这里的真正罪魁祸首是什么。

【问题讨论】:

  • 这似乎是 mgcv 包的问题。您是否尝试仅安装最新版本的 mgcv,然后输入 library(mgcv)?
  • 我使用 RStudio 实用程序安装 mgcv 并获得了更新版本。但是,它显示了完全相同的错误。如果我使用命令行安装 mgcv,也会发生同样的情况。
  • 因为它抱怨“缩进”和“宽度”值,我想知道你是否改变了绘图窗口设置?如果是这样,您可能还想尝试将绘图窗口设置重置为默认值,然后重试安装。
  • 我根本没有更改绘图窗口设置。实际上,我重新安装了 R,因为我有一个旧版本。但是,如果您认为这可能是问题所在,我该如何在 linux 中做到这一点?

标签: r rstudio


【解决方案1】:

在 RStudio 中,只需调整右侧的大小即可增加窗口的宽度。现在再次尝试library(mgcv),它可以工作了!

【讨论】:

    【解决方案2】:

    对于在 Windows 7 下遇到类似问题的任何人的参考,我在 forecast 包中遇到了同样的问题 - 有一天,它无法在 RStudio 中加载(在 R 中运行良好)。必须完全卸载 R 和 RStudio,确保删除 C:\Program Files\RC:\Users\[username]\AppData\Local\RStudio-Desktop 并重新安装,然后才能再次工作。如果我只是删除 RStudio 的东西并尝试保留 R 文件,那将无法正常工作。

    【讨论】:

      【解决方案3】:

      终于搞定了。

      我必须通过 sudo apt-get --purge remove rstudio 删除 rstudio 并删除 ~/.config/RStudio。奇怪的是,这并没有删除所有内容,因为当我重新安装 RStudio 时,一些打开的文档仍然存在。然而,它成功了。

      > 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.
      
          See ‘library(help="tseries")’ for details.
      
      
      Attaching package: ‘TSA’
      
      The following objects are masked from ‘package:stats’:
      
          acf, arima
      
      The following object is masked from ‘package:utils’:
      
          tar
      

      更新

      不幸的是,每次我重新启动 RStudio 时,都会遇到与以前相同的错误。所以这只是一个临时解决方案。有什么建议吗?

      更新 2

      最终,这个问题似乎已经解决了。我删除了~/.rstudio-desktop/monitored/user-settings/,问题立即得到解决,无需重新安装 RStudio。

      【讨论】:

      • 我删除了 ~/.rstudio-desktop/monitored/user-settings/ ==> 这似乎适用于 Mac。你知道 Windows 对应的是什么吗?
      • 对不起。我不知道 Windows 的等价物是什么。
      猜你喜欢
      • 2018-06-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-25
      • 1970-01-01
      • 2021-10-14
      • 1970-01-01
      相关资源
      最近更新 更多