Skip to content

Instantly share code, notes, and snippets.

Avatar

John Davis johnjdavisiv

View GitHub Profile
@johnjdavisiv
johnjdavisiv / covid19_by_us_state.R
Last active Mar 25, 2020
Plot the total number of COVID-19 cases for each US state
View covid19_by_us_state.R
library(tidyverse)
library(ggplot2)
library(shadowtext)
#John J Davis IV
#Biomechanics PhD Student
#Indiana University School of Public Health
#Twitter: @JDRuns
#Email: jjd1@iu.edu
#25 March 2020
@johnjdavisiv
johnjdavisiv / add_us_state_covid19_cases_for_kaggle.R
Last active Mar 24, 2020
This script pulls JHU data on COVID19 in the US and matches it with the Kaggle competition data prior to March 9th.
View add_us_state_covid19_cases_for_kaggle.R
#Kaggle COVID19 prediction model
#JJD
#24 march 2020
#johnjdiv@gmail.com
library(tidyverse)
library(nlme)
library(HRW)
@johnjdavisiv
johnjdavisiv / join_world_dev_covid19_week3.R
Last active Apr 7, 2020
Joins simple world development data with Covid-19 data for week 3 on Kaggle
View join_world_dev_covid19_week3.R
#----------------------------------------------------------------
# Add economic development data to train and test
#-------------------------------------------------------------------
covid_train <- read.csv("train.csv", stringsAsFactors = FALSE) %>%
mutate(Province_State = ifelse(Province_State == "", "none", Province_State)) %>%
unite(country_and_province,
Country_Region, Province_State,
remove=FALSE)
@johnjdavisiv
johnjdavisiv / plotFFT.m
Created Jun 30, 2020
Plot FFT of a signal
View plotFFT.m
function plotFFT(v,fs)
%plotFFT Quick function to plot the frequency content of a signal
% Input:
%
% v - (vector) signal
% fs - sample frequency in Hz
%
% Output:
% none, just plots the FFT spectrum and highlights dominant frequency
@johnjdavisiv
johnjdavisiv / thin_plate_demo.R
Created Dec 2, 2020
A quick demo of thin plate regression splines in mgcv
View thin_plate_demo.R
library(mgcv)
library(plot3D)
#Set up sample data
set.seed(42)
x <- runif(200, -1,1)
y <- runif(200, -1,1)
z <- exp(-(x^2 + y^2)) + rnorm(200, 0, 0.15)
#Fit 2D thin-plate regression spline