Skip to content

Instantly share code, notes, and snippets.

View pdparker's full-sized avatar

Philip Parker pdparker

  • Australian Catholic University
  • Australia
View GitHub Profile
@pdparker
pdparker / sciwheel.R
Created June 15, 2021 05:12
Access to sciwheel api in R
# 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)
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) +
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))
library(ggmap)
library(maps)
library(mapdata)
library(glue)
library(here)
library(progress)
library(extrafont)
font_import()
tuesdata <- tidytuesdayR::tt_load(2020, week = 25)
#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
@pdparker
pdparker / apa_style_gt.R
Last active June 13, 2020 06:21
APA Style Table for GT Package
# 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") %>%
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(
@pdparker
pdparker / image_input.gs
Last active May 26, 2020 22:11
Inserts an image from url and attaches the url to the image
// Set Globals
var ui = DocumentApp.getUi();
/** Demonstrates a simple way to prompt the user for a date. */
function img_workflow() {
// Set UI prompt + reminder to use unsecured image
var url = ui.prompt('Enter URL of image', 'use http not https', ui.ButtonSet.OK_CANCEL);
var line = url.getResponseText();
// If user clicks OK
if (url.getSelectedButton() == ui.Button.OK) {
// fetch image url
@pdparker
pdparker / UpdateImage.gs
Last active May 26, 2020 23:48
Update Images by URL
/**
* 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
@pdparker
pdparker / Rmd
Created November 15, 2018 22:03
---
title: "R Notebook"
output: html_notebook
---
# Overview
##
![Overview](fig/PISA-Workshop.png)