This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Functions from a seperate python script | |
| # Calendar to Julian Days | |
| cal2jd=function(date){ | |
| year=as.numeric(format(date,"%Y")) | |
| month=as.numeric(format(date,"%m")) | |
| day=as.numeric(format(date,"%d")) | |
| a = (14 - month)/12 | |
| y = year + 4800 - a | |
| m = month + 12*a - 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## Code was compiled by Paul Julian | |
| ## contact info: pauljulianphd@gmail.com | |
| # GIS libraries | |
| library(sp) | |
| library(rgdal) | |
| library(rgeos) | |
| library(raster) | |
| # projection |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## A series of functions to extract and display model summary tables | |
| ## Generalized Additive Models | |
| ## Code was compiled by Paul Julian | |
| ## contact info: pauljulianphd@gmail.com | |
| ## libraries | |
| library(mgcv) | |
| library(flextable) | |
| library(magrittr) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(jpeg) | |
| # Custom function similar to print.palette(...) | |
| RenderPal <- function(x,name){ | |
| if ((missing(x)) || (missing(name))){ | |
| stop("Internal error, please troubleshoot") | |
| } | |
| n <- length(x) | |
| old <- graphics::par(mar = c(0.5, 0.5, 0.5, 0.5)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## A working example with data of ggridges | |
| # Libraries --------------------------------------------------------------- | |
| if(!require(ggplot2)) { install.packages('ggplot2') } ; library(ggplot2) | |
| if(!require(ggridges)) { install.packages('ggridges') } ; library(ggridges) | |
| # Data -------------------------------------------------------------------- | |
| dat=data.frame(FedWY=c(1979, 1979, 1979, 1979, 1979, 1979, 1979, 1979, 1979, | |
| 1979, 1979, 1979, 1979, 1979, 1979, 1979, 1979, 1979, 1979, 1979, | |
| 1979, 1979, 1979, 1979, 1979, 1979, 1980, 1980, 1980, 1980, 1980, | |
| 1980, 1980, 1980, 1980, 1980, 1980, 1980, 1980, 1980, 1980, 1980, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # From | |
| ## Strobl, R.O., Robillard, P.D., 2008. Network design for water | |
| ## quality monitoring of surface freshwaters: A review. Journal | |
| ## of Environmental Management, Microbial and Nutrient Contaminants | |
| ## of Fresh and Coastal Waters 87, 639–648. | |
| ## https://doi.org/10.1016/j.jenvman.2007.03.001 | |
| #devtools::install_github("SwampThingPaul/AnalystHelper") | |
| library(AnalystHelper) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## quick bar and line plot in base | |
| data=data.frame(value=c(3,4,6,2),value2=c(10,12,20,9)) | |
| par(oma=c(3,2,0.5,3),mar=c(2,3,0.25,2)) | |
| barplot(data$value,ylim=c(0,12),las=2,space=c(0.5)) | |
| mtext(side=2,line=2,"Value") | |
| par(new=T);x=barplot(data$value2,ylim=c(0,25),axes=F,col=NA,border=NA,space=c(0.5)) | |
| lines(x,data$value2,lwd=3) | |
| axis(4,las=2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## Function to check and install packages | |
| ## If package is installed, then the function moves to the next. | |
| check.packages <- function(pkg){ | |
| new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])] | |
| if (length(new.pkg)) | |
| install.packages(new.pkg, dependencies = TRUE) | |
| sapply(pkg, require, character.only = TRUE) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## Data from Reckhow, K.H., K Kepford and W.W. Hicks. 1993 | |
| ### Methods for the Analysis of Lake Water Quality | |
| ### EPA 841-R-93-003 | |
| ## Code was compiled by Paul Julian | |
| ## contact info: paul.julian@floridadep.gov | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Base curly brackets adapted from https://stackoverflow.com/a/9310002/5213091 | |
| CurlyBraces <- function(x, y, min.val,max.val, pos = 1, direction = 1 ,b=c(0,.2,.28,.7,.8),a=c(1,2,3,48,50)) { | |
| # a set flexion point for spline | |
| # b set depth for spline flexion point | |
| curve <- spline(a, b, n = 50, method = "natural")$y / 2 | |
| curve <- c(curve,rev(curve)) | |
| a_sequence <- rep(x,100) |