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
# Adapted from https://stackoverflow.com/a/7267364/1036500 by Andrie de Vries | |
# This is it: theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5)) | |
library(ggplot2) | |
td <- expand.grid( | |
hjust=c(0, 0.5, 1), | |
vjust=c(0, 0.5, 1), | |
angle=c(0, 45, 90), |
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(usdanutrients) | |
library(tidyverse) | |
foods_simple <- | |
food %>% | |
separate(food, into = str_glue('V{1:11}'), sep = ",") %>% | |
distinct(V1) %>% | |
mutate(V1 = tolower(V1)) %>% | |
mutate(V1 = str_replace_all(V1, "[[:punct:]]", "")) %>% | |
rename(food = V1) |
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
csv <-c('"Sample","Lab_Code","Age","One_sd" | |
"GM-C14-14","OxA-34804",12665,55 | |
"GM-C14-16","OxA-34805",9240,40 | |
"GM-C14-26","OxA-34806",2829,28') | |
c14_data <- read.csv(text = csv, header = TRUE) | |
names(c14_data) | |
# read in the filie |
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(googlesheets) | |
library(readxl) | |
library(httr) | |
#------------------------------------------------------------- | |
# mapping police violence, https://mappingpoliceviolence.org/ | |
# get google sheet info | |
mapping_police_violence <- gs_url("https://docs.google.com/spreadsheets/d/1dKmaV_JiWcG8XBoRgP8b4e9Eopkpgt7FL7nyspvzAsE/edit#gid=0") |
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(chunked) | |
library(tidyverse) | |
# I want to look at the daily page views of Wikipedia articles | |
# before 2015... I can get zipped log files | |
# from here: https://dumps.wikimedia.org/other/pagecounts-ez/merged/2012/2012-12/ | |
# I get bz file, unzip to get this: | |
my_file <- 'pagecounts-2012-12-14/pagecounts-2012-12-14' |
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
# function to do a dodged half-boxplot and jittered points next to each other | |
# | |
# data_in should be a data frame | |
# factor_col should be a bare column name (not a string) | |
# although it will work if that column is factor or a character type | |
# numeric_col is the y axis continuous variable | |
# offset is the width of the boxplots and jittered point cloud | |
# | |
# the basic approach is to draw a boxplot without the tails | |
# (e.g. only the interquartile range) and then use segments to add the |
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
## GOAL: | |
## re-create a figure similar to Fig. 2 in Wilson et al. (2018), | |
## Nature 554: 183-188. Available from: | |
## https://www.nature.com/articles/nature25479#s1 | |
## | |
## combines a boxplot (or violin) with the raw data, by splitting each | |
## category location in two (box on left, raw data on right) | |
## call required 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
# we have downloaded the files from NASA Land Processes Distributed Active | |
# Archive Center (LP DAAC) at https://earthexplorer.usgs.gov/ | |
# and unzipped the downloaded file | |
# which contains many zip files... | |
# read in the Zipped files | |
setwd("C:/Users/bmarwick/Downloads/030432578418876/DEM-ASTER-Korea") | |
library(fs) | |
zip_files <- dir_ls(regexp = "[.]zip$") |
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
# data from http://reportcard.ospi.k12.wa.us/DataDownload.aspx | |
school_data <- readxl::read_excel("2_03_AIM-EOC-MSP-SBA Assessments School (with suppression - new format).xlsx") | |
# Level 4 is Advanced (exceeding state standard): http://www.k12.wa.us/assessment/StateTesting/FAQ.aspx | |
library(tidyverse) | |
# what does the data look like? | |
glimpse(school_data) |
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
#------ | |
# for tutorials see: | |
# - https://bigdataenthusiast.wordpress.com/tag/microsoft-cognitive-services-using-r/ | |
# - https://westus.dev.cognitive.microsoft.com/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236 | |
# try facial analysis for sex and gender | |
# scrape each page for each year | |
img_srcs <- | |
map(odmp_urls, |