Skip to content

Instantly share code, notes, and snippets.

@bensoltoff
bensoltoff / map.R
Created December 4, 2019 20:13
Massachusetts map example
library(tidyverse)
library(sf)
# import shapefile and extract Massachusetts
usa <- st_read("cb_2013_us_state_20m/cb_2013_us_state_20m.shp")
mass <- usa %>%
filter(NAME == "Massachusetts")
# identify city locations
cities <- tribble(
library(tidyverse)
library(tidytext)
library(tm)
set.seed(123) # random number generator seed
# get USCongress data
data(USCongress, package = "RTextTools")
congress <- as_tibble(USCongress) %>%
mutate(text = as.character(text))
@bensoltoff
bensoltoff / install.packages.R
Last active February 25, 2022 12:48
Install packages for RStudio Server
###### code to run on RStudio cloud project
pkg_cran <- c("reprex", "tidyverse", "sf", "tidycensus", "viridis", "knitr",
"gapminder", "forcats", "broom", "wordcloud", "tidytext", "rebird",
"geonames", "modelr", "rsample", "magrittr", "ISLR", "titanic",
"microbenchmark", "partykit", "caret", "nycflights13", "ggplot2",
"tibble", "harrypotter", "ggwordcloud", "here", "arrow", "readxl",
"haven", "ggmap", "rnaturalearth", "rtweet", "leaflet", "stringr",
"widgetframe", "RColorBrewer", "patchwork", "ymlthis", "RSocrata",
"dplyr", "shiny", "httr", "repurrrsive", "purrr", "acs", "downloader",
"statebins", "rsparkling", "sparklyr", "h2o", "dbplyr", "bigrquery",
@bensoltoff
bensoltoff / cm004_tidy_tutorial.R
Created October 5, 2016 18:10
cm004 - practice tidying data
## cm004_tidy_tutorial.R
## Benjamin Soltoff
## Practice tidying data
# load libraries
library(dplyr)
library(tidyr)
# racial data
race <- read.table(header = TRUE, check.names = FALSE, text = "
@bensoltoff
bensoltoff / cm003_scorecard_practice.R
Created October 3, 2016 15:59
Practice transforming and exploring data using dplyr and ggplot2
# cm003_scorecard_practice.R
# Benjamin Soltoff
# Practice transforming and exploring data using the Department
# of Education's College Scorecard data set for 2013
# load necessary libraries
library(dplyr)
library(ggplot2)
# get dataset from rcfss library
@bensoltoff
bensoltoff / river_cross.csv
Created January 22, 2016 18:33
River crossing solution to part one
node start island1 island2 island3 island4 island5 island6 end
start 0 1 1 1
island1 1 0 1 1
island2 1 1 0 1 1
island3 1 1 0 1
island4 1 0 1 1
island5 1 1 0 1 1
island6 1 1 0 1
end 1 1 1 0
@bensoltoff
bensoltoff / tm_replicate.md
Last active January 14, 2016 15:15
Replication of Brian Burke's Value of a Timeout analysis

Value of a Timeout

Benjamin Soltoff
January 14, 2016

# load packages
require(dplyr)