Built with Microsoft R Open version 3.2.3. More info at https://mran.revolutionanalytics.com/open/

The current CRAN repository for packages is https://mran.revolutionanalytics.com/snapshot/2016-01-01

Setup options: echo means R code will be displayed | cache means results will be stored for future knits

knitr::opts_chunk$set(echo = TRUE, cache = TRUE)

Admin notes

This is an R markdown document and requires the ‘rmarkdown’ package

install.packages('rmarkdown', repos='http://cran.us.r-project.org')
## Warning: package 'rmarkdown' is in use and will not be installed
library(rmarkdown)

Package management utilities

The list of CRAN mirrors can be found at https://cran.r-project.org/mirrors.html

Repo used by current R session

getOption("repos")
##                                                       CRAN 
## "https://mran.revolutionanalytics.com/snapshot/2016-01-01"

Current local library

normalizePath(.libPaths(), winslash = "/")
## [1] "C:/Program Files/Microsoft/MRO/R-3.2.3/library"

Local library of packages

installed.packages()[, "Package"]
##      assertthat            base       base64enc              BB 
##    "assertthat"          "base"     "base64enc"            "BB" 
##              BH          bitops            boot            brew 
##            "BH"        "bitops"          "boot"          "brew" 
##         caTools      checkpoint           class         cluster 
##       "caTools"    "checkpoint"         "class"       "cluster" 
##       codetools      colorspace        compiler          crayon 
##     "codetools"    "colorspace"      "compiler"        "crayon" 
##            curl        datasets             DBI        devtools 
##          "curl"      "datasets"           "DBI"      "devtools" 
##         dfoptim       dichromat          digest      doParallel 
##       "dfoptim"     "dichromat"        "digest"    "doParallel" 
##           dplyr           e1071        evaluate         foreach 
##         "dplyr"         "e1071"      "evaluate"       "foreach" 
##        forecast         foreign         formatR         Formula 
##      "forecast"       "foreign"       "formatR"       "Formula" 
##        fracdiff             gam             gbm       ggfortify 
##      "fracdiff"           "gam"           "gbm"     "ggfortify" 
##         ggplot2           git2r          glmnet        graphics 
##       "ggplot2"         "git2r"        "glmnet"      "graphics" 
##       grDevices            grid        gridBase       gridExtra 
##     "grDevices"          "grid"      "gridBase"     "gridExtra" 
##          gtable           highr          HSAUR2       htmltools 
##        "gtable"         "highr"        "HSAUR2"     "htmltools" 
##            httr      igraphdata           irlba            ISLR 
##          "httr"    "igraphdata"         "irlba"          "ISLR" 
##       iterators        jsonlite      KernSmooth           knitr 
##     "iterators"      "jsonlite"    "KernSmooth"         "knitr" 
##        labeling         lattice    latticeExtra        lazyeval 
##      "labeling"       "lattice"  "latticeExtra"      "lazyeval" 
##           leaps        magrittr        markdown            MASS 
##         "leaps"      "magrittr"      "markdown"          "MASS" 
##          Matrix    MatrixModels         memoise         methods 
##        "Matrix"  "MatrixModels"       "memoise"       "methods" 
##            mgcv            mime         munsell            nlme 
##          "mgcv"          "mime"       "munsell"          "nlme" 
##             NLP            nnet        numDeriv         openssl 
##           "NLP"          "nnet"      "numDeriv"       "openssl" 
##       optextras         packrat          pacman        parallel 
##     "optextras"       "packrat"        "pacman"      "parallel" 
##        pkgmaker             PKI      PKPDmodels            plyr 
##      "pkgmaker"           "PKI"    "PKPDmodels"          "plyr" 
##          praise        quadprog              R6    randomForest 
##        "praise"      "quadprog"            "R6"  "randomForest" 
##          Rcgmin    RColorBrewer            Rcpp   RcppArmadillo 
##        "Rcgmin"  "RColorBrewer"          "Rcpp" "RcppArmadillo" 
##           RCurl        registry         reshape        reshape2 
##         "RCurl"      "registry"       "reshape"      "reshape2" 
##   RevoUtilsMath         rgenoud         RJSONIO       rmarkdown 
## "RevoUtilsMath"       "rgenoud"       "RJSONIO"     "rmarkdown" 
##        rngtools        roxygen2           rpart       rsconnect 
##      "rngtools"      "roxygen2"         "rpart"     "rsconnect" 
##      rstudioapi       rversions          Rvmmin        sandwich 
##    "rstudioapi"     "rversions"        "Rvmmin"      "sandwich" 
##          scales          setRNG         spatial         splines 
##        "scales"        "setRNG"       "spatial"       "splines" 
##           stats          stats4         stringi         stringr 
##         "stats"        "stats4"       "stringi"       "stringr" 
##        survival          svUnit           tcltk         TH.data 
##      "survival"        "svUnit"         "tcltk"       "TH.data" 
##           tidyr        timeDate           tools    translations 
##         "tidyr"      "timeDate"         "tools"  "translations" 
##            tree         tseries             TTR           utils 
##          "tree"       "tseries"           "TTR"         "utils" 
##         whisker           withr            xml2          xtable 
##       "whisker"         "withr"          "xml2"        "xtable" 
##             xts            yaml             zoo 
##           "xts"          "yaml"           "zoo"

Choose CRAN mirror site from list

(remove # to run code)

# chooseCRANmirror()

Choose a CRAN repo via URL

options(repos=structure(c(CRAN="http://cran.us.r-project.org")))

Install from a particular mirror

install.packages('rmarkdown', repos='http://cran.us.r-project.org')
## Warning: package 'rmarkdown' is in use and will not be installed

Permanently set CRAN repo

(does not work with Microsoft R distro)

local({
  r <- getOption("repos")
  r["CRAN"] <- "http://cran.us.r-project.org"
  options(repos = r)
})

Add CRAN repos

(remove # to run code)

# setRepositories(addURLs =
#                   c(CRANxtras = "http://cran.us.r-project.org"))
# setRepositories(addURLs =
#                   c(CRAN = "http://cran.us.r-project.org"))

Packages w/ newer versions available

old.packages()
## NULL

About using Microsoft R distribution

Microsoft uses the MRAN repo for packages, usually a snapshot of the Austria CRAN repo from the first of the month

(more info at https://mran.revolutionanalytics.com/timemachine/ )

The ‘checkpoint’ package from MSFT is helpful for using a specific repo snapshot more info at http://bit.ly/1Rzrqdy

  • When you create a checkpoint, the checkpoint() function performs the following:
    • Creates a snapshot folder to install packages. This library folder is located at ~/.checkpoint
    • Scans your project folder for all packages used. Specifically, it searches for all instances of library() and requires() in your code.
    • Installs these packages from the MRAN snapshot into your snapshot folder using install.packages()
    • Sets options for your CRAN mirror to point to a MRAN snapshot, i.e. modify options(repos)

This means the remainder of your script will run with the packages from a specific date.

Caption