macos 你能在 Mac 电脑上使用 R 终端命令吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1133172/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can you use R terminal commands on a Mac computer?
提问by user130633
I wrote some code in school to basically bring up different graphs from R
and I had wanted to use it on a Mac
computer.
我在学校写了一些代码来基本上调出不同的图表R
,我想在Mac
计算机上使用它。
Is there are way to use R
terminal commands on a Mac
computer and is there a place where I could get more information about these Mac
R
Terminal commands?
有没有办法R
在Mac
计算机上使用终端命令,有什么地方可以让我获得有关这些Mac
R
终端命令的更多信息?
回答by Brendan OConnor
I use the "R" command with the standard R.app GUI download, and would recommend using that instead of macports. After running the installer, I see:
我在标准 R.app GUI 下载中使用“R”命令,并建议使用它而不是 macports。运行安装程序后,我看到:
$ which R
/usr/local/bin/R
$ ls -l /usr/local/bin/R
lrwxr-xr-x 1 root wheel 47 Nov 12 2008 /usr/local/bin/R -> /Library/Frameworks/R.framework/Resources/bin/R
$ R
R version 2.8.0 (2008-10-20)
...
>
I actually prefer to use this rather than the GUI, because it uses the current working directory for the workspace and history files (.Rhistory and .RData). It makes it easier to organize projects in this way by filesystem directory, and is very natural if you're using the commandline for other tasks as well (like running data preprocessing scripts).
我实际上更喜欢使用它而不是 GUI,因为它使用工作区和历史文件(.Rhistory 和 .RData)的当前工作目录。它可以更轻松地按文件系统目录以这种方式组织项目,如果您也将命令行用于其他任务(例如运行数据预处理脚本),这将非常自然。
Also, the terminal version lets you more easily cancel an expensive computation by pressing Ctrl-C. The GUI sometimes locks up during these.
此外,终端版本让您可以通过按 Ctrl-C 更轻松地取消昂贵的计算。在这些过程中,GUI 有时会锁定。
By default, I think Mac terminal R uses the X11 display system, which isn't as good as the Quartz one used by the GUI. You can change this though: get the CarbonELpackage, then put the following into your ~/.Rprofile
:
默认情况下,我认为 Mac 终端 R 使用 X11 显示系统,它不如 GUI 使用的 Quartz 显示系统。您可以更改此设置:获取CarbonEL包,然后将以下内容放入您的~/.Rprofile
:
goquartz = function() {
library("CarbonEL")
options(device='quartz')
Sys.unsetenv("DISPLAY")
}
if (.Platform$GUI == "X11") {
# this means we're running in the terminal (not GUI) version.
# if you actually want the X11 display, comment out the following line
goquartz()
}
回答by Todd Gamblin
You can use the R command-line tools if you install R for Mac OS X. The R website has disk imageswith installers, or you can install via MacPorts, like this:
如果您为 Mac OS X 安装 R,则可以使用 R 命令行工具。R 网站提供带有安装程序的磁盘映像,或者您可以通过 MacPorts进行安装,如下所示:
$ sudo port install R
The R website has a slightly later version (2.9.1) than MacPorts (which is at 2.8.1).
R 网站的版本 (2.9.1) 比 MacPorts(2.8.1)稍晚。