繁体   English   中英

为 Mac 创建 R 的便携式版本(并为此版本从源安装 package)

[英]Creating a portable version of R for Mac (and installing package from source for this version)

我正在尝试为 Mac 创建一个完全可移植的 R 版本,我可以将其发送给系统上没有 R 的用户,他们基本上可以双击命令文件并启动 Z3E751ABE1B5D0232F0232F08CF279ADZ7A 应用程序。 我需要能够安装包,包括一些从源代码构建的包(还有一些来自 GitHub)。

我使用来自这个 GitHub 存储库( https://github.com/dirkschumacher/r-shiny-electron/blob/master/get-r-mac.sh )的脚本作为起点(它也粘贴在下面),创建R 的一个版本,但是(A)我发现当我尝试启动 R 时,它给了我一个错误,找不到 etc/ldpaths 和(B)当我尝试启动 Rscript 它运行我的系统版本 - 我运行`Rscript - e 'print(R.version)' 并打印出 4.0,这是我的 R 的系统版本,而不是 shell 脚本已下载和处理的版本 3.5.1。

我已经尝试编辑“R”可执行文件并更改 R_HOME 和 R_HOME_DIR,但是当我尝试将软件包安装到 3.5.1 目录时它仍然遇到问题。

任何人都可以提供一些指导吗?

(顺便说一句,docker 不是一个选项,这需要尽可能简单的技术技能的最终用户。所以让他们安装 docker 等将不是一个选项)

#!/usr/bin/env bash
set -e

# Download and extract the main Mac Resources directory
# Requires xar and cpio, both installed in the Dockerfile
mkdir -p r-mac
curl -o r-mac/latest_r.pkg \
     https://cloud.r-project.org/bin/macosx/R-3.5.1.pkg

cd r-mac
xar -xf latest_r.pkg
rm -r r-1.pkg Resources tcltk8.pkg texinfo5.pkg Distribution latest_r.pkg
cat r.pkg/Payload | gunzip -dc | cpio -i
mv R.framework/Versions/Current/Resources/* .
rm -r r.pkg R.framework

# Patch the main R script
sed -i.bak '/^R_HOME_DIR=/d' bin/R
sed -i.bak 's;/Library/Frameworks/R.framework/Resources;${R_HOME};g' \
    bin/R
chmod +x bin/R
rm -f bin/R.bak

# Remove unneccessary files TODO: What else
rm -r doc tests
rm -r lib/*.dSYM

很高兴帮助您为您的 shiny 应用程序工作。 You can use this github repo for Electron wrapping R/Shiny... just clone, and replace the app.R (for your other packages you need to install them in the local R folder after cloning and then running R from the command line out R-Portable-Mac/bin 文件夹的...

尝试使用首先包含的 Hello World app.R

https://github.com/ColumbusCollaboratory/electron-quick-start

然后在本地 R-Portable-Mac 文件夹运行时安装你的包。 默认情况下包含的包... https://github.com/ColumbusCollaboratory/electron-quick-start/tree/master/R-Portable-Mac/library您的包将在命令行 install.packages() 之后显示在这里使用本地 R-Mac-Portable 运行时。

我们一直在为此开发一个 R 插件...... https://github.com/ColumbusCollaboratory/photon

但是,请注意该插件仍在开发中,不适用于已编译的 R 包; 仍然必须将 go 放入本地 R 文件夹和运行时在命令行中,并将软件包直接安装到本地 R 文件夹 libpath 中,如上所述。

试一试,如果您有任何疑问和问题,请通过 Github 问题告诉我们。 而且,如果您已经在那里发帖,很抱歉我们还没有回复。 很想通过光子插件进行交流,以使其与编译包(进入 libPath)一起工作——如果你有时间帮忙的话。 谢谢!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM