library(tidyverse)
library(broom)
library(huxtable)
library(estimatr)
library(fabricatr)
set.seed(1234)
dat <- fabricate(
N = 40,
This file contains hidden or 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(stevemisc) | |
GSS <- readRDS("~/Dropbox/data/gss/GSS_spss-2018/gss7218.rds") | |
GSS %>% | |
mutate(regioncondensed = NA, | |
regioncondensed = ifelse(region == 8 | region == 9, "West", regioncondensed), | |
regioncondensed = ifelse(region == 3 | region == 4, "Midwest", regioncondensed), | |
regioncondensed = ifelse(region == 5 | region == 6 | region == 7, "South", regioncondensed), |
This file contains hidden or 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
# install.packages("countreg", repos="http://R-Forge.R-project.org") | |
# https://www.fromthebottomoftheheap.net/2016/06/07/rootograms/ | |
# https://channel9.msdn.com/Events/useR-international-R-User-conferences/useR-International-R-User-2017-Conference/countreg-Tools-for-count-data-regression | |
library(countreg) | |
rzinbinom(3e3, size = 4, mu = 20, pi = 0.05) -> x | |
table(x) | |
hist(x, col = "orange") | |
rootogram(glm(x ~ 1, family = "poisson")) # zeros under fit |
This file contains hidden or 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(scales) | |
data(diamonds) | |
diamonds %>% | |
filter(str_detect(cut, "Fair|Ideal")) %>% | |
ggplot(aes(price, carat)) + | |
geom_point(color = "skyblue", alpha = 0.5) + | |
facet_wrap(~cut, strip.position = "bottom") + | |
scale_x_continuous(labels = comma) + |
This file contains hidden or 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
# script that outputs a graph | |
library(tidyverse) | |
library(firatheme) | |
wine <- read_delim("https://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data", | |
delim = ",", | |
col_names = c( | |
"Cultivar", "Alcohol", "Malic acid", "Ash", "Alcalinity of ash", "Magnesium", | |
"Total phenols", "Flavanoids", "Nonflavanoid phenols", "Proanthocyanins", | |
"Color intensity", "Hue", "OD280/OD315", "Proline" | |
) |
❯ usethis::use_pkgdown_travis()
✔ Setting active project to '/Users/gaborcsardi/works/ps'
✔ Adding 'docs/' to '.gitignore'
● Set up deploy keys by running `travis::use_travis_deploy()`
● Insert the following code in '.travis.yml'
before_cache: Rscript -e 'remotes::install_cran("pkgdown")'
This file contains hidden or 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
rm(list = ls()) | |
library(tidyverse) | |
library(ggrepel) | |
covid <- | |
read_csv(file = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv") | |
covid <- | |
covid %>% filter(`Country/Region` != "Cruise Ship") | |
covid_long <- |
This file contains hidden or 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
--- | |
title: "COVID-19 Case Fatality Rate (CFR) by age" | |
output: html_document | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(echo = TRUE) | |
library(tidyverse) | |
``` |
This file contains hidden or 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
# ---------------------------------------------------- | |
# Installing packages for new R version. | |
# Michael DeCrescenzo | |
# | |
# Hi, I'm a political science PhD student looking for | |
# a data science/quantitative research/statistics job. | |
# Learn more at <mikedecr.github.io> and <github.com/mikedecr> | |
# | |
# This script deals with the following problem: | |
# I upgraded to new major version of R, & I want to reinstall packages. |
This file contains hidden or 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(RSelenium) | |
library(rvest) | |
library(tidyverse) | |
theme_set(theme_minimal(15) + | |
theme(plot.title.position = "plot", | |
plot.caption = element_text(color = "gray40", size = 8))) | |
url <- "https://www.nytimes.com/interactive/2020/us/coronavirus-us-cases.html" | |
rd <- rsDriver(browser = "chrome", chromever = "81.0.4044.69") |