Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to install R packages though RCall.jl #420

Closed
logankilpatrick opened this issue Jun 19, 2021 · 4 comments
Closed

How to install R packages though RCall.jl #420

logankilpatrick opened this issue Jun 19, 2021 · 4 comments

Comments

@logankilpatrick
Copy link

Hey folks, I don't know if I missed it in the docs but I did not see how to install a R package through Rcall. I posted a SO question here: https://stackoverflow.com/questions/68048899/how-to-install-an-r-package-using-rcall-jl

@TheCedarPrince
Copy link

Also, @logankilpatrick if you run into problems, you could exit the RCall environment and open your R version and install packages directly inside of the native R REPL and then jump back into RCall mode. I've also found using renv helps preserve the package versions and needed packages properly.

@pat-alt
Copy link

pat-alt commented Jun 22, 2022

I'm having a related issue and thought I'd revive this existing thread instead of opening a new one.

I can see how this all works out really nicely when working locally (fantastic package by the way). But what if I want to use RCall as a dependency of my own Julia package? Is there an elegant/preferred way of making sure that R package deps are installed (ideally upon load)?

Have posted a more detail question on discourse, but thought it's worth going straight to the source 😄.

Thanks!

@palday
Copy link
Collaborator

palday commented Jul 16, 2024

for posterity:

using RCall
reval("""install.packages(c("pkg1", "pkg2"))"""

@palday palday closed this as completed Jul 16, 2024
@palday
Copy link
Collaborator

palday commented Jul 16, 2024

oh and @pat-alt

reval("""if(!require("mypkg")){
install.packages("mypkg")
library("mypkg")
}
"""

require returns a boolean about whether a package was successfully loaded, while library errors if the package can't be loaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants