unable to load library packages from linux command

unable to load library packages from linux command

by Jinyuru Yang -
Number of replies: 12

Hi,


For my data I need the packages rpart, rpart.plot and psych to run analysis. I installed the packages in R and used them to create functions without an issue. However, whenever I try to run my driver.R file from git bash I run into this problem: 

Error in library(rpart.plot) : there is no package called 'rpart.plot'

Calls: source -> withVisible -> eval -> eval -> library

Execution halted

The script seems to halt every time it comes across the library(rpart.plot) or library(psych) commands in my Utilities file, but I can't seem to figure out why because I can load these packages without an issue in R? Do these packages have to be installed in the same directory as my assignment to make it work?

In reply to Jinyuru Yang

Re: unable to load library packages from linux command

by Erik Spence -
See the Software Requirements page for instructions on how to fix this error.
In reply to Erik Spence

Re: unable to load library packages from linux command

by Dorottya Harangi -
I am having a similar issue (I am on a mac) with the command line saying "Error in rpart(f, data = train.d) : could not find function "rpart" "

When I tried the .libPaths() command I got something that looks like this: /Library/Frameworks/R.framework/Versions/4.1/Resources/library

Which doesn't look like what is posted on the software requirements page so I am confused as to how I get the rpart package to run.

Thanks!
In reply to Dorottya Harangi

Re: unable to load library packages from linux command

by Erik Spence -
If you're on a Mac this should not be an issue. Did you remember to do "library(rpart)" before you tried to use the 'rpart' function?
In reply to Erik Spence

Re: unable to load library packages from linux command

by Ujas Patel -
I am also having a similar issue. I would like to load two packages: car and survival. I have followed the instructions on the Software Requirements page and I am getting the following message:

During startup - Warning message:
Setting LC_CTYPE=en_US.UTF-8 failed
Error in library(car) : there is no package called 'car'
Execution halted

Thank you for your help!
In reply to Ujas Patel

Re: unable to load library packages from linux command

by Erik Spence -
Did you remember to install the package first, and confirm that it works, from the R prompt? If you did, please revisit the Software Requirements page, as I've added a small instruction that may be helpful.
In reply to Erik Spence

Re: unable to load library packages from linux command

by Liane Phung -
I had a similar library issue, and after following the Software Requirements to try and address the library issue, interestingly it brought back the warning message:
During startup - Warning message:
Setting LC_CTYPE=en_US.UTF-8 failed
I had this before on Windows but followed the Software Requirements page since Lec 1 or 2 which resolved it... until now. Is there another way to get rid of this?
In reply to Liane Phung

Re: unable to load library packages from linux command

by Erik Spence -
Following the instructions on the Software Requirements page should not have affected that warning message. Did you change the previous entries in your .bashrc or .Renviron?
In reply to Erik Spence

Re: unable to load library packages from linux command

by Liane Phung -
Hi Eric,

No I didn't change any previous entries on .bashrc or .Renviron.
All I did was add the two lines to .bashrc for the library issue as instructed on the Software Requirements page. My .bashrc looks like this:
export PATH=${PATH}:"C:\Program Files\R\R-4.1.1\bin\x64"
export R_LIBS="C:/Users/Liane Phung/Documents/R/win-library/4.1" 
export R_ENVIRON_USER=$R_LIBS
(It also appears that if the 'export R_LIBS' line isn't in quotation marks, bash will give this error: bash: export: `Phung/Documents/R/win-library/4.1': not a valid identifier)

If I remove the library lines from .bashrc the start up warning message is gone and the Terminal is back to behaving correctly as it was before.
 
In reply to Liane Phung

Re: unable to load library packages from linux command

by Erik Spence -
Your R_LIBS slashes are in the wrong direction.
In reply to Erik Spence

Re: unable to load library packages from linux command

by Madison Argo -
Hi Dr. Spence and Group!

I have been encountering a similar problem and discovered I have two library paths (to be honest, not sure how I created two library paths, definitely didn't mean to). Here is my R output when ".libPaths()" is typed:
[1] "C:/Users/Madison Argo/Documents/R/win-library/4.1"
[2] "C:/Program Files/R/R-4.1.2/library"

I have been searching online for various ways to merge/move one library to the other and/or adjust my settings (I am on a PC laptop) by making a default directory for library downloads but the options I have been trying haven't helped much.

Do you happen to have a website link or resource that would help describe the process to either merge my library directories or set a default directory on a PC (then I would just install my packages here).

I apologize in advance for creating this mess and thank you for any help!
In reply to Madison Argo

Re: unable to load library packages from linux command

by Erik Spence -
Is this a problem? You should be able to use both.

This is caused by running R as Administrator and then installing packages. And then running R as yourself, and then installing packages.

The solution is to follow the instructions on the Software Requirements page, but to list both directories in your environment variable.

export R_LIBS="/c/Users/Madison Argo/Documents/R/win-library/4.1:/c/Program Files/R/R-4.1.2/library"

Let me know if this works.