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

Installing from GitHub and specifying "type" #118

Open
alapo opened this issue Apr 18, 2019 · 3 comments
Open

Installing from GitHub and specifying "type" #118

alapo opened this issue Apr 18, 2019 · 3 comments

Comments

@alapo
Copy link

alapo commented Apr 18, 2019

Big fan of the package. I was curious if anyone knew how I should install the following package using pacman. The devtools syntax would be:

devtools::install_github("benmarwick/wordcountaddin", type = "source", dependencies = TRUE)

I read through the documentation but was unable to find a way to specify the type when using p_install_gh

@LoHertel
Copy link

LoHertel commented May 5, 2019

Hi @alapo

The argument section of the help page (?p_install_gh) mentions:

...       Additional parameters to pass to install_github.

You can pass on the type = "source" parameter from pacman::p_install_gh() to remotes::install_github().

Therefore, your function call is possible with p_install_gh as well:

pacman::p_install_gh("benmarwick/wordcountaddin", type = "source", dependencies = TRUE)

@alapo
Copy link
Author

alapo commented May 13, 2019

Thank you for your response @LoHertel I am attempting to make a reproducible document for other members of my lab.

The issue is that one package (wordcountaddin) relies on source where the second (apastats) relies on a subdirectory such that if I was to write each line individually it would be

pacman::p_install_gh("benmarwick/wordcountaddin", type = "source", dependencies = TRUE)

Curiously this following line using pacman doesnt work due to "incorrect capitalization specification"

pacman::p_install_gh( "achetverikov/apastats", subdir="apastats" )

But using devtools it does work using the same syntax

devtools::install_github('achetverikov/apastats',subdir='apastats')

I originally had all the GitHub packages set up as follows (which works until this example)

pacman::p_install_gh( c("benmarwick/wordcountaddin", "achetverikov/apastats") )

Do you have any recommendation on how you would pass this in one line?

Perhaps this is redundant but I've found this package to be particularly great for beginners to the RMarkdown environment who might be averse to calling install.packages("PackageName") and library(PackageName)

Sorry for the extended question but I (and my lab mates) appreciate your input

@LoHertel
Copy link

LoHertel commented May 20, 2019

Please use p_load_gh() instead

You wrote that you want to circumvent calling install.packages("PackageName") and library(PackageName) by using pacman. In that case, please use pacman::p_load_gh() instead.
Because pacman::p_install_gh() just installs packages and is not loading them.

pacman::p_load_gh('benmarwick/wordcountaddin', 'achetverikov/apastats/apastats', type = 'source', dependencies = NA)

The difference between devtools::install_github(), pacman::p_install_gh(), and pacman::p_load_gh() is:

  • devtools::install_github()

    • Installs packages only.
    • Installs only necessary dependencies of packages by default (dependencies = NA). This means dependencies of three categories ("Depends", "Imports" and "LinkingTo").
  • pacman::p_install_gh()

    • Installs packages only.
    • Installs all dependencies of packages by default (dependencies = TRUE). This means dependencies of all four categories ( "Depends", "Imports", "LinkingTo" and "Suggests").
    • If multiple packages should be installed, create a vector with all names c(..., ...) and pass it to the function.
  • pacman::p_load_gh()

    • Installs and loads packages. If they are installed already, the function just loads them.
    • Installs all dependencies of packages by default (dependencies = TRUE). This means dependencies of all four categories ( "Depends", "Imports", "LinkingTo" and "Suggests").
    • If multiple packages should be loaded, give the names as separate arguments to the function.

Call all in one statement without subdir

suppressWarnings(pacman::p_install_gh(c('benmarwick/wordcountaddin', 'achetverikov/apastats/apastats'), type = 'source', dependencies = NA))

If you want to install multiple packages at the same time, you can not combine it with the subdir argument. Instead, you could add the subdirectory name after the repository name.

At the moment, p_install_gh() throws a warning when multiple packages are installed at the same time. Therefore, you could wrap it with suppressWarnings(). When using p_load_gh(), the warning does not show up.

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

2 participants