0

I am trying to load packages in Rstdio. When I use the command line to load packages "R -e "library('XXXXX')", or Run the command library(XXXXX) in Rstdio console, I am able to load the package.

But when I try to run a .R file that laods the same package from a .sh file, I get the following error

Error in library("XXXXX") : there is no package called ‘XXXXXX’

I am running the code in an EC2 instance

Can anyone please help with the error

neilfws
  • 32,751
  • 5
  • 50
  • 63
  • Rstdio - is this a typo? – zx8754 Mar 27 '23 at 21:13
  • 2
    If you run `which R` is that path different if you run `R.home("bin")` in the same R file where you try to run the `library()` call? How are you executing the .R file? What exactly do the commands look like? Are you using package managers like `renv`? – MrFlick Mar 27 '23 at 21:20
  • 4
    Check what paths R knows by running `print(.libPaths())` in both Rstudio and outside. They will differ--which is your problem. Check with your local admin (you?) of why that may be, there are many possibly config files that can affect this. – Dirk Eddelbuettel Mar 27 '23 at 21:53
  • I tried print(.libpaths()) and the libpaths are different. To correct it I used libpaths(c('xxxx','yyyy',...)) which adds all the libpaths excluding a specific one. What is the posssible reason for this ? – Siddharth Somani Mar 28 '23 at 20:16

0 Answers0