Report this

What is the reason for this report?

How to Install R Package from Github

Posted on March 20, 2023

I am using the plumberDeploy package in R to set up an API endpoints on DO to a droplet I have running now. I have a package that is on a public github that I need to install.

I’m trying to figure out how to use this function:

analogsea::install_github_r_package(mydrop, "PACERStuff",  repo = "https://github.com/myname/Blog/tree/master/packagename")

Which does not work. If I were doing this in the R console it would be

devtools::install_github("myname/Blog", subdir='packagename')

Which does indeed install the package locally. Does anyone else have experience or knowledge on how to install an R package to a droplet from github, specifically using these same functions from plumberDeploy?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there,

Indeed, the documentation is not very clear, maybe it’s worth raising an issue to report this!

But as far as I can see in their tests, they don’t specify the full GitHub URL:

https://github.com/pachadotdev/analogsea/blob/main/tests/testthat/test-droplet_actions_1.R#LL33C51-L33C51

Example test:

  z <- install_github_r_package(x, "pachamaltese/eflm")
  expect_false(z$locked)
  expect_equal(z$status, "active")

So this indicates that the problem you are facing might be related to the specification of the GitHub repository in your call to analogsea::install_github_r_package(). The repo argument should be in the form “username/repo”, not a full URL (at least judging by their tests). Also, the subdir argument should be used to specify the subdirectory if the package is not in the root of the repository.

Here is how you might use the function:

analogsea::install_github_r_package(mydrop, "myname/Blog", subdir = "packagename")

This function should install the package located in the “packagename” subdirectory of the “myname/Blog” repository on your droplet named mydrop.

Best,

Bobby

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.