April 13, 2018
There are three main ways to install a package in R:
Tools > Install Packages...install.packages("package name")install.packages("path_to_file", repos = NULL, type = "source")devtools package (must have it installed first!)
devtools::install_github("repo name")devtools::install_url("url")There are two ways to access code and data from an installed package:
library() function
library(package) loads all contents of package and makes them accessible until R restarts:: operator
package::name accesses name from package for a one-time useLet’s install devtools, here, and car from CRAN using the console:
install.packages("devtools", dependencies = TRUE)
install.packages("here", dependencies = TRUE)
install.packages("car", dependencies = TRUE)Now, let’s use devtools to install BRRR from Github (more info here).
Method 1:
library(devtools) # load the devtools package
install_github("brooke-watson/BRRR") # use the function install_github() to install BRRRMethod 2:
devtools::install_github("brooke-watson/BRRR") # use the function install_github() from devtools to install BRRRPlay around with BRRR!
ggplot2: to create beautiful graphicsgoogleVis: to use Google Chart toolsshiny: to create interactive web-based appsknitr: to combine R codes and Latex/Markdown codesslidify: to build HTML 5 slide showsrcpp: to write R functions that call C++ codedata.table: to organize datasets for fast operationsparallel: to use parallel processing in R