2

I am trying to automate running a R script from a WSL environment. I receive the same error:

Error in library(ggplot2) :
there is no package called ‘ggplot2’
Execution halted

I have tried solutions from Rscript: There is no package called ...? without any result.

I have tried iterations of the test script below.

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")

I believe the error is caused by path set for my libraries. I am wondering if WSL environment is causing an issue with paths featuring the "/mnt/" prefix. I have tried changing the paths to accommodate this without any solution.

lager
  • 59
  • 6

1 Answers1

1

You should install the Linux version of R inside WSL:

https://www.digitalocean.com/community/tutorials/how-to-install-r-on-ubuntu-18-04-quickstart

If you want to run it from WSL.

Regards

Carlos Rafael Ramirez
  • 5,984
  • 1
  • 29
  • 36
  • I do have R 3.5.1 'R version 3.5.1 (2018-07-02) -- "Feather Spray" Copyright (C) 2018 The R Foundation for Statistical Computing Platform: x86_64-conda_cos6-linux-gnu (64-bit)' – lager Aug 21 '19 at 20:06
  • 1
    But in your code, you refer to the Windows version of R – Carlos Rafael Ramirez Aug 21 '19 at 21:33
  • 2
    ah, I see. I was running R Studio on Windows but WSL R version is a separate entity so I needed to install libs in that environment. Thank you! – lager Aug 22 '19 at 12:53