从 WSL 命令行执行 R 脚本——加载库时出错
Executing R Script from WSL Command Line-- Error loading Libraries
我正在尝试从 WSL 环境中自动执行 运行 R 脚本。我收到同样的错误:
Error in library(ggplot2) :
there is no package called ‘ggplot2’
Execution halted
我已经尝试了 Rscript: There is no package called ...? 的解决方案,但没有任何结果。
我已经尝试了以下测试脚本的迭代。
Rscript test.r
signal <- .libPaths(c("C://Program Files//R//R-3.5.3//library",
"C://Users//USER//Documents//R//win-library//3.5"))
library("ggplot2", lib.loc = signal)
print("Hello World")
____________________________________________
Rscript test.r
signal <- .libPaths()
library("ggplot2", lib.loc = signal)
print("Hello World")
______________________________________________
Rscript test.r -e ".libPaths(c("C://Program Files//R//R-3.5.3//library",
"C://Users//USER//Documents//R//win-library//3.5"))"
library(ggplot2)
print("Hello World")
我认为错误是由为我的库设置的路径引起的。我想知道 WSL 环境是否导致带有“/mnt/”前缀的路径出现问题。我已经尝试更改路径以适应这种情况,但没有任何解决方案。
您应该在 WSL 中安装 Linux 版本的 R:
https://www.digitalocean.com/community/tutorials/how-to-install-r-on-ubuntu-18-04-quickstart
如果你想从 WSL 运行 它。
此致
我正在尝试从 WSL 环境中自动执行 运行 R 脚本。我收到同样的错误:
Error in library(ggplot2) :
there is no package called ‘ggplot2’
Execution halted
我已经尝试了 Rscript: There is no package called ...? 的解决方案,但没有任何结果。
我已经尝试了以下测试脚本的迭代。
Rscript test.r
signal <- .libPaths(c("C://Program Files//R//R-3.5.3//library",
"C://Users//USER//Documents//R//win-library//3.5"))
library("ggplot2", lib.loc = signal)
print("Hello World")
____________________________________________
Rscript test.r
signal <- .libPaths()
library("ggplot2", lib.loc = signal)
print("Hello World")
______________________________________________
Rscript test.r -e ".libPaths(c("C://Program Files//R//R-3.5.3//library",
"C://Users//USER//Documents//R//win-library//3.5"))"
library(ggplot2)
print("Hello World")
我认为错误是由为我的库设置的路径引起的。我想知道 WSL 环境是否导致带有“/mnt/”前缀的路径出现问题。我已经尝试更改路径以适应这种情况,但没有任何解决方案。
您应该在 WSL 中安装 Linux 版本的 R:
https://www.digitalocean.com/community/tutorials/how-to-install-r-on-ubuntu-18-04-quickstart
如果你想从 WSL 运行 它。
此致