This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# library() or require() only load one package at a time | |
# but... | |
Packages <- c("dplyr", "ggplot2", "rstan", "readr") | |
lapply(Packages, library, character.only = TRUE) | |
# this loads as many as you put in 'Packages'. They need to be installed first, of course. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# packages | |
library("ggplot2") | |
# devtools::install_github("dgrtwo/gganimate") | |
library("gganimate") | |
library("dplyr") | |
# set distribution parameters for simulation | |
p = 0.5 | |
N = 100 | |
y_lim = 20 | |
a_a = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# functions for plotting garden of forking data plots | |
library(rethinking) | |
polar2screen <- function( dist, origin, theta ) { | |
## takes dist, angle and origin and returns x and y of destination point | |
vx <- cos(theta) * dist; | |
vy <- sin(theta) * dist; | |
c( origin[1]+vx , origin[2]+vy ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# extracted from http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_countries.zip | |
# under public domain terms | |
country_bounding_boxes = { | |
'AF': ('Afghanistan', (60.5284298033, 29.318572496, 75.1580277851, 38.4862816432)), | |
'AO': ('Angola', (11.6400960629, -17.9306364885, 24.0799052263, -4.43802336998)), | |
'AL': ('Albania', (19.3044861183, 39.624997667, 21.0200403175, 42.6882473822)), | |
'AE': ('United Arab Emirates', (51.5795186705, 22.4969475367, 56.3968473651, 26.055464179)), | |
'AR': ('Argentina', (-73.4154357571, -55.25, -53.628348965, -21.8323104794)), | |
'AM': ('Armenia', (43.5827458026, 38.7412014837, 46.5057198423, 41.2481285671)), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(congressbr) | |
Seq <- seq(as.Date("1991-02-01"), to = as.Date("2018-12-31"), | |
by = 60) | |
Seq2 <- seq(as.Date("1991-03-01"), to = as.Date("2019-01-31"), | |
by = 60) | |
seq_m <- data.frame(date = Seq, end_date = Seq2) | |
seq_m$date <- gsub("-", "", seq_m$date) | |
seq_m$end_date <- gsub("-", "", seq_m$end_date) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plot.BEST_2 <- | |
function(x, which=c("mean", "sd", "effect", "nu"), credMass=0.95, | |
ROPE=NULL, compVal=0, showCurve=FALSE, ...) { | |
# This function plots the posterior distribution for one selected item. | |
# Description of arguments: | |
# x is mcmc.list object of the type returned by function BESTmcmc. | |
# which indicates which item should be displayed; possible values are "mean", "sd", | |
# "effect" or "nu". | |
# ROPE is a two element vector, such as c(-1,1), specifying the limit | |
# of the ROPE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# modified by R. McDonnell. Original at: https://github.com/cran/BEST/blob/master/R/plotPost.R | |
# Original code by John Kruschke, modified by Mike. | |
plotPost_2 <- | |
function( paramSampleVec, credMass=0.95, compVal=NULL, ROPE=NULL, | |
HDItextPlace=0.7, showMode=FALSE, showCurve=FALSE, ... ) { | |
# Does a plot for a single parameter. Called by plot.BEST but also exported. | |
# Returns a histogram object invisibly. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rgdal) | |
library(maptools) | |
library(dplyr) | |
library(ggplot2) | |
library(readr) | |
library(httr) | |
library(XML) | |
library(ggmap) | |
library(scales) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rvest) | |
library(stringr) | |
library(emojifont) | |
library(tidyverse) | |
url <- "http://www.webpagefx.com/tools/emoji-cheat-sheet/" | |
page <- read_html(url) | |
nodes <- html_nodes(page, css = "#content") | |
text <- html_text(nodes) | |
txt <- data_frame(label = unlist(str_extract_all(text, ":[a-z_]*:"))) %>% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Old_packList <- as.list(installed.packages("/Library/Frameworks/R.framework/Versions/3.2/Resources/library")) | |
# here, my R version was 3.2. Change it for the R version you want the packages from! | |
Old <- as.character(Old_packList) | |
install.packages(Old) |
NewerOlder