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(tidyverse) | |
library(e1071) | |
library(gganimate) | |
# parameters for the simulation | |
ntimes <- 100 | |
nseries <- 20 | |
# construct tibble storing simulation | |
tbl <- tibble( |
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
# SCROLL TO THE GITHUB COMMENT BELOW FOR THE FULL OUTPUT WITH IMAGES | |
# COPY AND PASTE THIS FOR EASY ACCESS TO REPRODUCIBLE CODE | |
# ------------------------------------------------------------------------------ | |
library(tidygraph) | |
library(ggraph) | |
library(dplyr) | |
library(igraph) | |
library(tibble) |
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(ggplot2) | |
library(dplyr) | |
ft <- read.csv("ftpop.csv", stringsAsFactors=FALSE) | |
arrange(ft, start_year) %>% | |
mutate(country=factor(country, levels=c(" ", rev(country), " "))) -> ft | |
ft_labs <- data_frame( | |
x=c(1900, 1950, 2000, 2050, 1900, 1950, 2000, 2050), |
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(purrr) | |
library(dplyr) | |
library(rvest) | |
library(stringr) | |
library(geoparser) | |
w_msg <- function(f) { | |
force(f) | |
function(...) { | |
args <- list(...) |
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
read_sheet <- function(file, sheet) { | |
readxl::read_excel(file, sheet, skip = 6) %>% clean_data() | |
} | |
fix_names <- function(df) { | |
names(df)[1] <- "location" | |
names(df)[-1] <- paste(rep(c(2000, 2014), each = length(names(df)[-1]) / 2), | |
names(df)[-1], sep = "_") | |
df | |
} |
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(jsonlite) | |
library(tigris) | |
library(ggplot2) | |
library(purrr) | |
library(tidyr) | |
library(dplyr) | |
library(sp) | |
library(rgeos) | |
library(rgdal) | |
library(maptools) |
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
belief | y2015 | y2014 | |
---|---|---|---|
Improves the security posture of my organization | 0.75 | 0.71 | |
Improves the security posture of the nations critical infrastructure | 0.63 | 0.64 | |
Reduces the cost of detecting and preventing cyber attacks | 0.22 | 0.21 | |
Improves situational awareness | 0.60 | 0.54 | |
Fosters collaboration among peers and industry groups | 0.48 | 0.51 | |
Enhances the timeliness of threat data | 0.11 | 0.16 | |
Makes threat data more actionable | 0.21 | 0.24 |
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
# A Bayesian model that calculates a probability that a couple is fertile | |
# and pregnant. Please use this for fun only, not for any serious purpose | |
# like *actually* trying to figure out whether you are pregnant. | |
# Enter your own period onsets here: | |
period_onset <- as.Date(c("2014-07-02", "2014-08-02", "2014-08-29", "2014-09-25", | |
"2014-10-24", "2014-11-20", "2014-12-22", "2015-01-19")) | |
# If you have no dates you can just set days_between_periods to c() instead like: | |
# days_between_periods <- c() | |
days_between_periods <- as.numeric(diff(period_onset)) |
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(SmarterPoland) | |
library(riverplot) | |
library(RColorBrewer) | |
library(graphics) | |
library(reshape2) | |
library(plyr) | |
library(stringr) | |
library(countrycode) | |
# DOWNLOAD THE DATA |
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
# Installation | |
#install.packages("devtools") | |
devtools::install_github("rich-iannone/DiagrammeR") | |
library(DiagrammeR) | |
# Create and render an empty graph | |
empty_graph <- create_graph() | |
render_graph(empty_graph, output = "visNetwork") |
NewerOlder