Skip to content

Instantly share code, notes, and snippets.

Jeffrey W Hollister jhollist

Block or report user

Report or block jhollist

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View national_dem_example.R
library(USAboundaries)
library(sf)
library(dplyr)
library(elevatr)
library(raster)
# Get map of lower 48 states
usa_l48 <- us_boundaries() %>%
filter(state_abbr != "HI" &
state_abbr != "AK" &
@jhollist
jhollist / merge_linestrings.R
Created Jul 20, 2018
Combine multiple, sequential linestrings into one
View merge_linestrings.R
library(sf)
#What I have
l1 <- st_linestring(matrix(c(1,1,2,2,3,1),ncol = 2, byrow = T))
l2 <- st_linestridng(matrix(c(3,1,3,2,4,2),ncol = 2, byrow = T))
l3 <- st_linestring(matrix(c(4,2,5,1,6,1),ncol = 2, byrow = T))
all_lines <- st_sfc(l1,l2,l3)
all_lines
#What I want
@jhollist
jhollist / bibify_pkgs.R
Last active Mar 14, 2018
An R function to turn a vector of package names into a bibliorgraphy
View bibify_pkgs.R
#' Generate a bibliography of packages
#'
#' This function creates an output bibliography from an input character vector
#' of package names. The primary use case for this function is when working
#' with other authors and you need to provide a reference list of packages used.
#'
#' @param pkgs A character vector of packages
#' @param csl A csl file used to format the output bibliography. Good place to
#' look for these is \url{https://github.com/citation-style-language/styles}
#' @param append_bib Existing \code{.bib} file to append package citations to.
View keybase.md

Keybase proof

I hereby claim:

  • I am jhollist on github.
  • I am jhollist (https://keybase.io/jhollist) on keybase.
  • I have a public key whose fingerprint is D3F0 73AF 7C80 CAAA B965 4E0B 98E3 5E1B 139B 2FEF

To claim this, I am signing this object:

View case_when_examp.R
library(dplyr)
iris2 <- iris %>%
mutate(sp_abbr = case_when(Species == "virginica" ~ "vir",
Species == "setosa" ~ "set",
Species == "versicolor" ~ "vers"))
iris2
View get_org_member_stats.R
library(gh)
library(dplyr)
library(lubridate)
library(purrr)
usepa_members <- unlist(lapply(gh("/orgs/usepa/members", .limit = Inf),
function(x) x$login))
# Get all usepa repos, grab commits for each repo, filter for user and count
usepa_repos <- unlist(lapply(gh("/orgs/usepa/repos", type = "all", .limit = Inf),
function(x) x$name))
View get_private_repo_stats.R
# Got too many private repos in a GitHub Organization?
# This will list all of the private repos you have access to and rank them by
# days since last push and total number of commits.
# Add PAT to .Renviron - mine is obscured
# cat("GITHUB_PAT=yourowngithubpatgoeshere\n",
# file=file.path(normalizePath("~/"), ".Renviron"),
# append=TRUE)
View censusapi_block_1000.R
# http://api.census.gov/data/2010/sf1?get=P0010001,P0030001&for=block:1000&in=state:44+county:003+tract:020101
getCensus(name = "sf1",vintage = 2010, key = Sys.getenv("CENSUS_API_KEY"),
vars = "P0010001", region = "block:1000", regionin = "state:44+county:003+tract:020101")
# Throws error
# Error in data[, c(which(sapply(data, class) != "numeric"), which(sapply(data, :
# incorrect number of dimensions
View tidycensus_ri.R
library(tidycensus)
ri <- get_decennial(geography = "state", state = "RI",variables = "P001001",
key = api_key,
year = 2000)
#Returning this error...
#Using FIPS code '44' for state 'RI'
#Using FIPS code '44' for state 'RI'
#Error : lexical error: invalid char in json text.
# error: unknown/unsupported geog
@jhollist
jhollist / get_nars.R
Last active Jan 26, 2017
R script to scrape US EPA NARS data and metadata
View get_nars.R
#Script to scrape NARS website
library(rvest)
library(dplyr)
nars <- read_html("https://www.epa.gov/national-aquatic-resource-surveys/data-national-aquatic-resource-surveys")
links <- nars %>%
html_nodes(".file-link, a") %>%
html_attr("href") %>%
tbl_df() %>%
filter(grepl("files",value)) %>%
You can’t perform that action at this time.