简体   繁体   English

带有R解释器和子模块的nix-shell

[英]nix-shell with R interpretter and submodules

Can I use R, with required submodules (eg, ggplot2) with nix-shell? 我可以使用带有nix-shell的必需子模块(例如ggplot2)的R吗?

For example, using Python with submodules: 例如,将Python与子模块一起使用:

nix-shell -p python34 python34Packages.pandas

However, I can't seem to see how to do the equivalent with R. 但是,我似乎无法看到如何与R等效。

nix-shell -p R

Gives me a vanilla R, but what about submodules? 给我一个香草R,但子模块怎么样? I'm not sure I know enough about using nix-shell to evaluate nix expressions, but could this be used from nix-shell as a command? 我不确定我是否足够了解使用nix-shell来评估nix表达式,但是可以从nix-shell中用作命令吗?

Note: It is my preference not to pop the expression from the above link in a shell.nix or default.nix . 注意:我希望在shell.nixdefault.nix弹出上面链接中的shell.nix Rather as a single command. 而不是单个命令。

You can pass a nix expression to nix-shell using the -E flag. 您可以使用-E标志将nix表达式传递给nix-shell So the following is valid: 所以以下是有效的:

nix-shell -E 'with import <nixpkgs> {}; rWrapper.override {packages = with rPackages; [ggplot2 reshape2];}'

您可以使用与Python示例中相同的方法:

nix-shell -p R rPackages.dplyr rPackages.ggplot2

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

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