Skip to content

Instantly share code, notes, and snippets.

View elipousson's full-sized avatar

Eli Pousson elipousson

View GitHub Profile
library(tidyverse)
library(sf)
c("A", "B", "C")
"ABC"
str_flatten(c("A", "B", "C"))
us_states |>
openapi: 3.0.0
info:
title: SFTool API
version: 1.0.0
description: |
SFTool API provides machine readable data to develop a service or services to search,
display, analyze, retrieve, and view SFTool data about healthy buildings and environmentally responsible purchasing.
You can find out more about SFTool at [https://sftool.gov](https://sftool.gov).
Use the api key 'DEMO_KEY' to test the SFTool API.
library(sf)
# You can read data from these URLs
# GeoJSON (geojson)
read_sf("https://github.com/ropensci/geojsonio/raw/main/inst/examples/california.geojson")
# Keyhole Markup Language (kml)
read_sf("https://github.com/ropensci/geojsonio/raw/main/inst/examples/poa_annua.kml")
@elipousson
elipousson / 2023-09-13_bldgspatialdata_in-class_code-sample.R
Created October 4, 2023 19:43
A code sample from the in-class live coding practice session for week 3 of the GES 668 Building Spatial Datasets (Fall 2023) course: https://bldgspatialdata.github.io/website/weeks/week_03.html
library(tidyverse)
select(storms, name)
select(storms, !name)
select(storms, -name)
select(storms, name:long)
@elipousson
elipousson / bcpss_parent_survey_SY1819_analysis.R
Last active September 30, 2023 21:30
A R script to reproduce a graphic map created to visualize the distribution of elementary and elementary/middle school households surveyed in 2019 who responded to the question, "How does your child usually walk to school?" with "Walking".
# pak::pkg_install(c("elipousson/bcpss", "elipousson/mapbaltimore", "elipousson/maplayer", "hrbrthemes"))
library(bcpss)
library(tidyverse)
library(sf)
transportation_survey_resp <- parent_survey_SY1819 |>
select(
starts_with("school_n"),
c("grade_band", "management_type", "parent_response_count"),
library(sf)
library(dplyr)
# Can you convert `storms_sf` to make the feature geometry represent
# storm tracks instead of storm observations?
storms_sf <- storms |>
st_as_sf(
coords = c("long", "lat"),
crs = 4326
library(Microsoft365R)
# site_url <- "fill in url"
site_files <- get_site_files(
site_url = site_url,
recurse = TRUE
)
files <- get_site_files(site_url)
@elipousson
elipousson / baltimore-bike-facilities_schema-update.R
Last active September 9, 2023 19:36
A R script for updating the Baltimore bike facilities data to use the new schema from the Baltimore Metropolitan Council and add other related attributes as variables.
# title: R script for validating Baltimore city bike facility data, updating the
# schema to match new BMC standard, and adding new attributes for responsible
# agency and other characteristics
#
# author: Eli Pousson
# date: 2023-09-07
# last-modified: 2023-09-09
# Set up ----
@elipousson
elipousson / read_excalidraw.R
Created September 5, 2023 02:00
A R function to read an Excalidraw Markdown file created with Obsidian to a list
#' Read an Excalidraw Markdown file created using the Obsidian Excalidraw
#' plugin.
#'
#' Plugin: https://github.com/zsviczian/obsidian-excalidraw-plugin
#'
#' This function uses the experimental yyjsonr package
#' <https://github.com/coolbutuseless/yyjsonr>. jsonlite would also work here.
#'
#' @param file A Markdown file created with the Obsidian Excalidraw plugin.
#' @param ... Additional parameters passed to [readr::read_lines()]
table <- tidycensus::get_decennial(
geography = "block",
state = "MD",
county = "Baltimore city",
year = 2020,
table = "H1"
)
label_census <- function(data,
year = 2020,