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(tidycensus) | |
#install your acs api key | |
#census_api_key(YOUR_KEY, install=T) | |
pops <- get_acs(geography = "county", | |
variables = c("B19013_001", | |
"B01002_001", | |
"B01003_001","B01001_002", #sex, male | |
"B01001A_001", #swhite | |
"B15003_001","B15003_017",#education, HS |
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
CREATE TEMP FUNCTION | |
loess(x ARRAY<FLOAT64>, | |
y ARRAY<FLOAT64>) | |
RETURNS STRUCT<x ARRAY<FLOAT64>, | |
y ARRAY<FLOAT64>, | |
pred ARRAY<FLOAT64>> | |
LANGUAGE js AS """ | |
//adapted from https://gist.github.com/avibryant/1151823 | |
//adapted from the LoessInterpolator in org.apache.commons.math | |
//turtles on turles. Matches R pretty damn close: |
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
#if needed, uncomment out the follow lines and install R packages: | |
# install.packages("dplyr") | |
# install.packages("poliscidata") | |
# install.packages("covidregionaldata") | |
library(dplyr) | |
library(poliscidata) | |
library(covidregionaldata) | |
library(plotly) | |
#get regional covid stats |
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(dplyr) | |
library(ggplot) | |
library(plotly) | |
#fake data | |
dat = data.frame(x = c(1,2,3), rev = c(10,20,30), upper = c(15,25,35), lower = c(5,15,25)) | |
#create a plot | |
p1 = dat %>% | |
ggplot(aes(x = x, | |
y=rev,ymin=lower,ymax=upper)) + |
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
<div id="app"> | |
<pre> | |
Smoothing <input type="range" min="0" max="0.25" step="0.01" v-model="options.line.smoothing"> <span v-html="options.line.smoothing"></span><br> | |
Flattening <input type="range" min="0" max="1" step="0.01" v-model="options.line.flattening"> <span v-html="options.line.flattening"></span></pre> | |
<div class="container" ref="container"> | |
<svg-chart :datasets="datasets" :options="options" :svg="svg"></svg-chart> | |
</div> | |
</div> | |
<div> |