Skip to content

Instantly share code, notes, and snippets.

@ThomRoman
Forked from stevenworthington/ipak.R
Created July 13, 2020 06:31
Show Gist options
  • Select an option

  • Save ThomRoman/1e25fe89a92fe1afdbb3237b076cbc0c to your computer and use it in GitHub Desktop.

Select an option

Save ThomRoman/1e25fe89a92fe1afdbb3237b076cbc0c to your computer and use it in GitHub Desktop.

Revisions

  1. @stevenworthington stevenworthington revised this gist Jul 25, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ipak.R
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # ipak function: install R packages.
    # ipak function: install and load multiple R packages.
    # check to see if packages are installed. Install them if they are not, then load them into the R session.

    ipak <- function(pkg){
  2. @stevenworthington stevenworthington created this gist Jul 25, 2012.
    13 changes: 13 additions & 0 deletions ipak.R
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    # ipak function: install R packages.
    # check to see if packages are installed. Install them if they are not, then load them into the R session.

    ipak <- function(pkg){
    new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
    if (length(new.pkg))
    install.packages(new.pkg, dependencies = TRUE)
    sapply(pkg, require, character.only = TRUE)
    }

    # usage
    packages <- c("ggplot2", "plyr", "reshape2", "RColorBrewer", "scales", "grid")
    ipak(packages)