Skip to content

Instantly share code, notes, and snippets.

View micahwoods's full-sized avatar

Micah Woods micahwoods

View GitHub Profile
@micahwoods
micahwoods / om_mass_volume.R
Last active December 9, 2021 01:18
shows calculations for organic matter as mass/mass or volume/volume using a 1 square meter section to a 2 cm depth as an example
## OM246 on a volume basis
## starting thought: what is 5% OM by mass on a volume basis?
library(ggplot2)
library(cowplot)
## assign bulk densities; these don't vary, nor does compressibility
bd_sand <- 1.56
bd_om <- 0.22
@micahwoods
micahwoods / p_high_ph.R
Created May 14, 2021 10:04
Reads MLSN data from GitHub and makes charts of Mehlich 3 P distribution
# load packages, then read in data from Github
library(VGAM)
library(ggplot2)
library(cowplot)
library(dplyr)
library(RColorBrewer)
# generates an mlsn value for a vector using log logistic distribution
mlsn <- function(x) {
@micahwoods
micahwoods / nasa_power_wisley.R
Created June 5, 2019 04:17
Gets global solar irradiance data from the NASA POWER agroclimatology data set, then plots it. This gist compares daily light integral near London, England, in the first 149 days of 2018 to the first 149 days of 2019.
# to look at The Wisley location data 2018 and 2019 based on
# this Q from Tom Coulson https://twitter.com/TomCoulson85/status/1135905779242995712
library(nasapower)
library(ggplot2)
library(cowplot)
library(RColorBrewer)
library(zoo)
# get the 2018 data
@micahwoods
micahwoods / tokyo_time_series_animated_gp.R
Created March 10, 2019 09:43
makes animated line plots of Tokyo monthly temperatures
# do a chart animated for 100+ years of Tokyo temperatures
# and check the GP C3 and GP C4
# tokyo monthly mean temperatures
tokyo <- 'http://www.data.jma.go.jp/obd/stats/etrn/view/monthly_s3.php?prec_no=44&block_no=47662&year=&month=&day=&view='
library(zoo)
library(cowplot)
library(ggplot2)
library(gganimate)
@micahwoods
micahwoods / ten_thousand_analysis.R
Created March 7, 2018 10:08
makes some counts of tweets and words from an archive downloaded from Twitter
# analyse my first 10000 tweets
# based on https://juliasilge.com/blog/ten-thousand-tweets/
library(ggplot2)
library(lubridate)
library(dplyr)
library(cowplot)
# read my tweet archive that I downloaded from Twitter
d <- read.csv("data/tweets.csv",
# make a chart of tweets by followers and with log2 axes
# as shown in https://blog.codecentric.de/en/2017/07/combining-social-network-analysis-topic-modeling-characterize-codecentrics-twitter-friends-followers/
# and adapted from code at https://github.com/ShirinG/blog_posts_prep/blob/master/twitter/twitter_codecentric.Rmd
library(twitteR)
library(dplyr)
library(ggrepel)
library(cowplot)
api_key <- "your API_KEY here"
@micahwoods
micahwoods / 20160625_holly_springs_hourly.R
Created June 25, 2016 12:01
downloads Holly Springs data and plots it, specifically looking at air temperature, soil 10 cm temp, and soil 10 cm H2O
# get hourly Holly Springs and plot it
library("ggplot2")
library("lubridate")
library("dplyr")
library("cowplot")
library("reshape2")
hollyHourly2015 <- read.table("http://www1.ncdc.noaa.gov/pub/data/uscrn/products/hourly02/2015/CRNH0203-2015-MS_Holly_Springs_4_N.txt",
header = FALSE)
@micahwoods
micahwoods / gp_vs_gdd.R
Last active January 19, 2016 06:22
downloads temperature data for 4 cities in 2015 then calculates and makes plots of GP and GDD and permutations
# compare C3 growth potential (GP) and growing degree days (GDD)
# at a few locations, start with Sydney, Minneapolis, Tokyo, London
# these data and charts are shown at http://www.blog.asianturfgrass.com/2016/01/g.html
# load libraries
library("dplyr")
library("lubridate")
library("ggplot2")
library("cowplot")
library("RColorBrewer")
@micahwoods
micahwoods / turf_twitter.R
Last active December 5, 2015 02:16
Counts the number of unique followers of selected turfgrass accounts on Twitter
# this code will download twitter follower information
# load packages
library("twitteR")
library("dplyr")
api_key <- "your api key"
api_secret <- "your api secret"
@micahwoods
micahwoods / before_and_after_interactions.R
Last active August 29, 2015 14:19
downloads user timeline and plots before and after interactions from a cutoff date and time
# load packages
library("twitteR")
library("dplyr")
library("lubridate")
api_key <- "your key"
api_secret <- "your secret"