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) ## devtools::install_github("hadley/ggplot2) | |
library(grid) ## rasterGrob | |
library(EBImage) ## readImage | |
library(ggthemes) ## theme_minimal | |
## ########## | |
## INDEPENDENT CODE TO BE SOURCED: | |
## ########## | |
# user-level interface to the element grob |
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) ## devtools::install_github("hadley/ggplot2) | |
library(grid) ## rasterGrob | |
library(EBImage) ## readImage | |
library(ggthemes) ## theme_minimal | |
## ########## | |
## INDEPENDENT CODE TO BE SOURCED: | |
## ########## | |
# user-level interface to the element grob |
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(magick) | |
library(magrittr) | |
# Convert to 'ico' format | |
image_read("https://www.r-project.org/logo/Rlogo.png") %>% | |
image_scale("32x32!") %>% # remove the "!" after 32x32 to scale proportionally | |
image_write("favicon.ico", format = "ico") | |
# Favicon can also be png/gif |
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(idbr) | |
library(ggplot2) | |
library(gganimate) | |
library(tweenr) | |
library(countrycode) | |
library(dplyr) | |
idb_api_key("Your API key goes here") | |
africa_fips <- countrycode(c('Nigeria', 'Uganda', 'Tanzania', 'Ghana'), |
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
#' Convert the output of a topicmodels Latent Dirichlet Allocation to JSON | |
#' for use with LDAvis | |
#' | |
#' @param fitted Output from a topicmodels \code{LDA} model. | |
#' @param corpus Corpus object used to create the document term | |
#' matrix for the \code{LDA} model. This should have been create with | |
#' the tm package's \code{Corpus} function. | |
#' @param doc_term The document term matrix used in the \code{LDA} | |
#' model. This should have been created with the tm package's | |
#' \code{DocumentTermMatrix} function. |
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
# Makefile to use knitr for presentations | |
SLIDES := Day1Part1-Introduction.html Day1Part1-session2.html Day1Part1-session3.html Day1Part2-session1.Rmd | |
all: $(SLIDES) | |
clean: | |
rm -rf *.md mplus.* | |
%.html: %.Rmd |
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
# R Function to Draw Edward Tufte-style Slopeplots | |
# TODO: | |
## deal with overlapping numeric values: if more than one label falls at a position, offset based on rank() of the subsequent column values for those rows | |
## overlapping rownames (same algorithm as above, but hard code for 1st and 2nd value) | |
slopegraph <- | |
function( | |
df, |