Skip to content

Instantly share code, notes, and snippets.

@colaresi
Last active June 7, 2016 21:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colaresi/4db7310c686dcd1496d49ea708ff6221 to your computer and use it in GitHub Desktop.
Save colaresi/4db7310c686dcd1496d49ea708ff6221 to your computer and use it in GitHub Desktop.

#Bayes and Bagels Code

A place to stash potentially helpful code for Bayes and Bagels workshop

Installing rethinking package

MPC

  • Dependencies
  • Thinking cap
  • Headache?

The book is pretty self-explanatory about this, but just in case. We can walk through the steps.

Dependencies

First we need some dependencies. Packages the rethinking depends on. We use install.packages to get these.

install.packages(c("coda","mvtnorm","devtools"),repos="http://cran.mtu.edu/")
## Installing packages into '/Users/michaelcolaresi/Library/R/3.2/library'
## (as 'lib' is unspecified)

## 
## The downloaded binary packages are in
##  /var/folders/f9/2cy3ssy1309cgxyk57db2wnr0000gn/T//RtmpmjpQm7/downloaded_packages
library(devtools)
## Warning: package 'devtools' was built under R version 3.2.5
devtools::install_github("rmcelreath/rethinking")
## Skipping install for github remote, the SHA1 (e71dbc12) has not changed since last install.
##   Use `force = TRUE` to force installation

Thinking cap

If that worked, then you will be able to type:

library(rethinking)
## Loading required package: rstan

## Warning: package 'rstan' was built under R version 3.2.3

## Loading required package: ggplot2

## Warning: package 'ggplot2' was built under R version 3.2.4

## rstan (Version 2.9.0-3, packaged: 2016-02-11 15:54:41 UTC, GitRev: 05c3d0058b6a)

## For execution on a local, multicore CPU with excess RAM we recommend calling
## rstan_options(auto_write = TRUE)
## options(mc.cores = parallel::detectCores())

## Loading required package: parallel

## Loading required package: methods

## rethinking (Version 1.58)

and not get an error.

Headache?

If this does not work (you get a package not found error) then you may need to revert to an older version of the knitr package. Like so:

packageurl <- "http://cran.r-project.org/src/contrib/Archive/knitr/knitr_1.12.tar.gz"
install.packages(packageurl, repos=NULL, type="source") 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment