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
/* I have only tested this on Chrome but it | |
prints nicely to A4 size */ | |
@media print { | |
body { | |
width: 210mm; | |
height: 297mm; | |
} | |
} |
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
# libraries you will need | |
library(httr) | |
library(jsonlite) | |
# You will need a token from sciwheel API | |
token = '<<your API token goes here>>' | |
# Get Project Ids for use in sciwheel_bib | |
sciwheel_projects <- function(token){ | |
project = 'https://sciwheel.com/extapi/work/projects' | |
get_meta <- GET(project, add_headers("Authorization"= paste0("Bearer ", token))) | |
status <- httr::status_code(get_meta) |
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
#################################### Set up database ########################### | |
# - Make sure database is setup to be read,write and executable outside of sudo | |
# - Make sure to start mongo deamon before setting up database usr$ mongod | |
################################################################################ | |
##Produces mongodb documents with the following fields: | |
# _id: Transcript id - used to index the files | |
# title: Title of the speech or interview | |
# primMinister: Who gave the speech in format 'Last name, First name' | |
# releaseDate: Given in days since 1970-01-01 as per R's default data storage |
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(extrafont) | |
font_import() | |
theme_MandB <- function (base_size = 11, base_family = "Times New Roman", horizontal = TRUE, dkpanel = FALSE) | |
{ | |
bgcolors <- c("#24292D", "#323E4E", "#BED5E0") | |
ret <- theme_foundation(base_size = base_size, base_family = base_family) + |
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(magick) | |
width = 800 | |
height = 500 | |
img <- image_read("https://i.dlpng.com/static/png/6920336_preview.png") | |
pomo_bg <- magick::image_resize(img, paste0(width, "x", height, "!")) | |
pomo_bg <- magick::image_crop(pomo_bg, paste0(width, "x", height)) |
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(ggmap) | |
library(maps) | |
library(mapdata) | |
library(glue) | |
library(here) | |
library(progress) | |
library(extrafont) | |
font_import() | |
tuesdata <- tidytuesdayR::tt_load(2020, week = 25) |
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
#devtools::install_github("thebioengineer/tidytuesdayR") | |
library(tidyverse) | |
library(ggpomological) | |
tuesdata <- tidytuesdayR::tt_load(2020, week = 25) | |
extrafont::ttf_import(paths = "~/Downloads/bayard-desktop") | |
extrafont::fonts() | |
#tuesdata$census%>%View | |
#tuesdata$slave_routes %>% View |
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
# Provides APA 7th Styling to a table #### | |
# Only works using the global-font-options branch of the gt package | |
#Requires | |
library(gt) | |
library(tidyverse) | |
# APA style #### | |
apa_style <- function(data) { | |
data %>% | |
opt_table_lines(extent = "none") %>% |
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) | |
# Replication of Simmons #### | |
set.seed(42) | |
reps <- 1500 | |
n <- 40 | |
sim <- matrix(NA, nrow = reps, ncol = 4) | |
colnames(sim) <- c("vanilla_est", "vanilla_p", "covariate_est", "covariate_p") | |
for (i in 1:reps){ | |
d = data_frame( |
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
/** | |
* Updates images by there URL. Run when image changes | |
* This only works for images that have a link to themselves in a google doc | |
* To link an image right mouse click and select link. Put a link to the image URL there | |
* URLs for images in Drive take the form http://drive.google.com/uc?export=view&id=##IMAGE ID HERE## | |
* Will replace image with same dimensions. Will not match rotation angle. | |
* I think the URLs need to be http rather than https to work consistently. | |
*/ | |
function replace_images_url() { | |
// Open the document by id |
NewerOlder