Skip to content

Instantly share code, notes, and snippets.

View mbjoseph's full-sized avatar

Max Joseph mbjoseph

View GitHub Profile
@mbjoseph
mbjoseph / neon-veg-freq.Rmd
Created February 6, 2019 15:27
Get frequency distribution of mapped NEON stem locations
---
title: "Untitled"
author: "Max Joseph"
date: "2/6/2019"
output: html_document
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
@mbjoseph
mbjoseph / reticulate-demo.Rmd
Created December 19, 2018 02:38
Using earthpy in R Markdown
---
title: "Using earthpy via R Markdown"
author: "Max Joseph"
date: "December 18, 2018"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(reticulate)
@mbjoseph
mbjoseph / earthpy-data-gen.R
Last active December 16, 2018 16:31
Example data generation for earthpy
library(tidyverse)
library(raster)
library(sf)
library(rmapshaper)
library(elevatr)
library(USAboundaries)
dir.create('out')
# RGB satellite imagery over Rocky Mountain National Park -------------
@mbjoseph
mbjoseph / blogpost.Rmd
Created September 14, 2018 19:25
smapr Ropensci blog post
---
title: 'Mapping the 2018 East Africa floods from space with smapr'
author: "Max Joseph"
date: "2018-09-14"
output:
html_document:
keep_md: yes
---
```{r setup, include=FALSE}

Keybase proof

I hereby claim:

  • I am mbjoseph on github.
  • I am mbjoseph (https://keybase.io/mbjoseph) on keybase.
  • I have a public key ASABiVndWu_-6CJIwyKMRAlsmF3sEsWB33XMDPoZ2GAbvAo

To claim this, I am signing this object:

@mbjoseph
mbjoseph / bernoulli-occupancy.R
Created August 23, 2018 20:08
Bernoulli observation occupancy model in Stan
library(tidyverse)
library(rstan)
options(mc.cores = parallel::detectCores())
rstan_options(auto_write = TRUE)
# Simulate true occupancy states ------------------------------------------
# define a design matrix for site-level occupancy
n_site <- 200
m_psi <- 3 # m_psi is the number of columns in the site level design matrix
X_psi <- matrix(c(rep(1, n_site), rnorm((m_psi - 1) * n_site)),
@mbjoseph
mbjoseph / zoib-recovery.R
Created November 27, 2017 07:33
Simulation for zero-one inflated beta regression in Stan
## DATA GENERATION
# reproducibility
library(bayesplot)
set.seed(1839)
# matches the stan function
inv_logit <- function(x){
exp(x) / (1 + exp(x))
}
@mbjoseph
mbjoseph / hello-world.R
Created June 5, 2017 20:24
Hello world in R
print("Hello, world!")
@mbjoseph
mbjoseph / boulder-weather-basis.R
Created May 19, 2017 19:39
Using basis functions to predict weather in Boulder, CO
library(raster)
library(tidyverse)
library(lubridate)
library(mgcv)
# Boulder temperature prediction ------------------------------------------
# Goal: use historical temperature data to predict the weather a week from today
# Fetch raw data from NOAA
data_url <- "https://www.esrl.noaa.gov/psd/boulder/data/boulderdaily.complete"
@mbjoseph
mbjoseph / read_ams_data.R
Created March 29, 2017 20:24
Parse and read ams data
# Importing data from USDA into large data file ---------------------------
library(stringr)
library(tidyverse)
convert_to_df <- function(file) {
# takes a text file as input and parses the file to generate a data.frame
lines <- readLines(file)
# identify blank lines which denote separate files