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 each point in x, identify which geometry in y the point falls within and extract value of variable `var` | |
| #' | |
| #' @param x `sf` object consisting of points | |
| #' @param y `sf` object consisting of geometries | |
| #' @param var character of variable name you wish to extract from `y` | |
| #' | |
| extract_within <- function(x, y, var) { | |
| if(!inherits(x, "sf") | !inherits(y, "sf")) { | |
| stop("Both x and y must be sf objects") | |
| } |
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(haven) | |
| #' From an indicator for treatment, retrieve start year. | |
| get_min_year = function(y, t) { | |
| return(y[order(y)][min(which(t[order(y)] == 1))]) | |
| } | |
| data <- haven::read_dta("nlswork.dta") |
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
| # Load libraries | |
| library(tidyverse) | |
| library(haven) | |
| library(fixest) | |
| library(did2s) | |
| library(did) | |
| # Install package | |
| # install.packages("tidyverse") | |
| # install.packages("haven") |
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
| #' Creates sparse 0/1 matrix for factor variables | |
| #' | |
| #' @param df dataframe containing factor columns that will be turned into sparse matrix. | |
| #' Note that the variables aren't required to be factor variables themselves. | |
| #' Make sure not to include other variables in df | |
| fact_to_sparse <- function(df) { | |
| # Convert to factor variables | |
| df[,names(df)] <- lapply(df[,names(df)] , factor) |
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(here) | |
| library(blastula) | |
| # Setup ---- | |
| # create_smtp_creds_key( | |
| # id = "kybu6659", | |
| # user = "kybu6659@colorado.edu", | |
| # provider = "gmail" | |
| # ) |
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
| const palette_index = [{"package":"awtools","palette":"a_palette","length":8,"type":"sequential","novelty":true,"key":"awtools::a_palette"},{"package":"awtools","palette":"ppalette","length":8,"type":"qualitative","novelty":true,"key":"awtools::ppalette"},{"package":"awtools","palette":"bpalette","length":16,"type":"qualitative","novelty":true,"key":"awtools::bpalette"},{"package":"awtools","palette":"gpalette","length":4,"type":"sequential","novelty":true,"key":"awtools::gpalette"},{"package":"awtools","palette":"mpalette","length":9,"type":"qualitative","novelty":true,"key":"awtools::mpalette"},{"package":"awtools","palette":"spalette","length":6,"type":"qualitative","novelty":true,"key":"awtools::spalette"},{"package":"basetheme","palette":"brutal","length":10,"type":"qualitative","novelty":true,"key":"basetheme::brutal"},{"package":"basetheme","palette":"clean","length":10,"type":"qualitative","novelty":true,"key":"basetheme::clean"},{"package":"basetheme","palette":"dark","length":10,"type":"qualitative |
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
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Mason Butts | Design</title> | |
| <script src="https://cdn-tailwindcss.vercel.app/?plugins=forms,typography,aspect-ratio,line-clamp"></script> |
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
| #' Convert raw html to htmltools/shiny tags | |
| #' | |
| #' @description Note that this copies text to your clipboard | |
| #' | |
| #' @param raw_html Character vector of html text | |
| #' | |
| #' @return Character string of htmltools:: version of html | |
| #' | |
| #' @examples | |
| #' raw1 <- div( |
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
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Fixest Stata to R</title> | |
| <!-- prism.js --> |
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
| # Extract images from PDFs | |
| import pdfplumber | |
| # Layout Parser | |
| import layoutparser as lp | |
| import cv2 | |
| # regex | |
| import re |