在 macOS 10.14.1 上安装 Rattle for R 时出现错误消息
Error message installing Rattle for R on macOS 10.14.1
我的 R 控制台是 3.5.1。我想在我的 Mac Mojave 10.14.1 上安装 rattle 包。我知道你必须先安装 RGtk2 但即使在加载时仍然收到错误消息 "from source"
> install.packages("RGtk2")
--- Please select a CRAN mirror for use in this session ---
Package which is only available in source form, and may need
compilation of C/C++/Fortran: ‘RGtk2’
Do you want to attempt to install these from sources? (Yes/no/cancel) Yes
installing the source package ‘RGtk2’
trying URL 'https://mirrors.nics.utk.edu/cran/src/contrib/RGtk2_2.20.35.tar.gz'
Content type 'application/x-gzip' length 2793137 bytes (2.7 MB)
==================================================
downloaded 2.7 MB
* installing *source* package ‘RGtk2’ ...
** package ‘RGtk2’ successfully unpacked and MD5 sums checked
checking for pkg-config... no
checking for INTROSPECTION... no
checking for GTK... no
configure: error: GTK version 2.8.0 required
ERROR: configuration failed for package ‘RGtk2’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RGtk2’
The downloaded source packages are in
‘/private/var/folders/67/r1c_pfwn5ws6y7rsl2bp_qqh0000gn/T/Rtmpi55PMx/downloaded_packages’
Warning message:
In install.packages("RGtk2") :
installation of package ‘RGtk2’ had non-zero exit status
> install.packages("GTK")
Warning message:
package ‘GTK’ is not available (for R version 3.5.1)
> install.packages("RGtk2", dependencies=TRUE)
Package which is only available in source form, and may need
compilation of C/C++/Fortran: ‘RGtk2’
Do you want to attempt to install these from sources? (Yes/no/cancel) no
此答案是对我最初于 2017 年 8 月在 Johns Hopkins Data Science Specialization Community Mentor Github 网站上发布的内容的提炼,以回答学生关于如何在 OS X 上安装 Rattle 的问题为了用 rattle::fancyRpartPlot()
生成花哨的 rpart
图。
安装需要 gtk 工具包,Mac 实现此目的的一种方法是,根据 R 3.0 and GTK+ / RGTK2 Error:
- Install macports — 安装 mac 包的工具
- 运行 SUDO 在 mac
sudo port install gtk2 ## (X11 -- not aqua)
上安装 gtk2
- 导出新路径
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
- 从命令行 R,输入 install rgtk2 with
install.packages("RGtk2",type="source")
以从源代码编译
- 安装 rattle 包
install.packages("rattle",type="source")
注意: 为了使 RGtk2
安装从 RStudio 正常工作,必须首先确认上面列出的 PATH
更改应用于 shell 用于启动 RStudio。
最完整的指令集位于Sebastian Kopf's Gist page,并由我自己于2017年6月17日安装验证。安装后,加载rattle库将在R控制台中生成以下输出。
为了使用 fancyRpartPlot()
,还需要安装 rpart.plot
包。
install.packages("rpart.plot")
示例:Iris 数据的花式 Rpart 图
这里我们复制了在约翰霍普金斯大学数据科学专业化 实用 [=79] 中讨论的 caret
和 rattle
生成花式树图所需的代码=]hine Learning 关于 用树进行预测的讲座 。
library(caret)
library(rattle)
inTrain <- createDataPartition(y = iris$Species,
p = 0.7,
list = FALSE)
training <- iris[inTrain,]
testing <- iris[-inTrain,]
modFit <- train(Species ~ .,method = "rpart",data = training)
fancyRpartPlot(modFit$finalModel)
我的 R 控制台是 3.5.1。我想在我的 Mac Mojave 10.14.1 上安装 rattle 包。我知道你必须先安装 RGtk2 但即使在加载时仍然收到错误消息 "from source"
> install.packages("RGtk2")
--- Please select a CRAN mirror for use in this session ---
Package which is only available in source form, and may need
compilation of C/C++/Fortran: ‘RGtk2’
Do you want to attempt to install these from sources? (Yes/no/cancel) Yes
installing the source package ‘RGtk2’
trying URL 'https://mirrors.nics.utk.edu/cran/src/contrib/RGtk2_2.20.35.tar.gz'
Content type 'application/x-gzip' length 2793137 bytes (2.7 MB)
==================================================
downloaded 2.7 MB
* installing *source* package ‘RGtk2’ ...
** package ‘RGtk2’ successfully unpacked and MD5 sums checked
checking for pkg-config... no
checking for INTROSPECTION... no
checking for GTK... no
configure: error: GTK version 2.8.0 required
ERROR: configuration failed for package ‘RGtk2’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RGtk2’
The downloaded source packages are in
‘/private/var/folders/67/r1c_pfwn5ws6y7rsl2bp_qqh0000gn/T/Rtmpi55PMx/downloaded_packages’
Warning message:
In install.packages("RGtk2") :
installation of package ‘RGtk2’ had non-zero exit status
> install.packages("GTK")
Warning message:
package ‘GTK’ is not available (for R version 3.5.1)
> install.packages("RGtk2", dependencies=TRUE)
Package which is only available in source form, and may need
compilation of C/C++/Fortran: ‘RGtk2’
Do you want to attempt to install these from sources? (Yes/no/cancel) no
此答案是对我最初于 2017 年 8 月在 Johns Hopkins Data Science Specialization Community Mentor Github 网站上发布的内容的提炼,以回答学生关于如何在 OS X 上安装 Rattle 的问题为了用 rattle::fancyRpartPlot()
生成花哨的 rpart
图。
安装需要 gtk 工具包,Mac 实现此目的的一种方法是,根据 R 3.0 and GTK+ / RGTK2 Error:
- Install macports — 安装 mac 包的工具
- 运行 SUDO 在 mac
sudo port install gtk2 ## (X11 -- not aqua)
上安装 gtk2
- 导出新路径
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
- 从命令行 R,输入 install rgtk2 with
install.packages("RGtk2",type="source")
以从源代码编译 - 安装 rattle 包
install.packages("rattle",type="source")
注意: 为了使 RGtk2
安装从 RStudio 正常工作,必须首先确认上面列出的 PATH
更改应用于 shell 用于启动 RStudio。
最完整的指令集位于Sebastian Kopf's Gist page,并由我自己于2017年6月17日安装验证。安装后,加载rattle库将在R控制台中生成以下输出。
为了使用 fancyRpartPlot()
,还需要安装 rpart.plot
包。
install.packages("rpart.plot")
示例:Iris 数据的花式 Rpart 图
这里我们复制了在约翰霍普金斯大学数据科学专业化 实用 [=79] 中讨论的 caret
和 rattle
生成花式树图所需的代码=]hine Learning 关于 用树进行预测的讲座 。
library(caret)
library(rattle)
inTrain <- createDataPartition(y = iris$Species,
p = 0.7,
list = FALSE)
training <- iris[inTrain,]
testing <- iris[-inTrain,]
modFit <- train(Species ~ .,method = "rpart",data = training)
fancyRpartPlot(modFit$finalModel)