A package of functions that I have accumulated through the years and have kept as CommonlyUsedFunctions.R
on my hard drive and would use source()
to utilize these functions. Finally upgraded to building my CommonlyUsedFunctions.R
into a functional package.
Using library(roxygen2)
and R-studio “R-package Project” I constructed this package to be shareable amongst collaborators and generally be helpful in day-to-day analyses. Most of these functions are highly specific and constructed in my mind knowing what I knew at the time. Most functions presumably could be optimized, make no sense to others or are redundant with other packages.
Please excuse any grammatical/text errors
install.packages("devtools");# if you do not have it installed on your PC
devtools::install_github("SwampThingPaul/AnalystHelper")
This package has several objective includes accessing environmental data, manipulating data and visualizing the data.
Objectives (not all functions are identified here):
South Florida Water Management District Online Environmental Database (DBHYDRO).
Several functions were developed to directly download data into R
from DBHYDRO using URL-based data access (see DBHYDRO User Manual)
DBHYDRO_WQ()
. This function requires a date range, Station ID and parameter(s) to be specified. See DBHYDRO User Manual for more information.DBHYDRO_daily()
. This function requires a date range and site/data-type identifier called a DBKEY (for more information see DBHYDRO User Manual).DBHYDRO_breakpoint()
. This function requires a date range and site/data-type identifier called a DBKEY (for more information see DBHYDRO User Manual).Data manipulation/handling
Several functions revolve around data screening, calculating or converting data for further evalution.
DO.Screening()
, DO_PerSat()
,DO.TOD.WQS.stream()
. DO.Screening()
was developed to handle dissolved oxygen and associated data to identify possible erronous data (i.e. date recorded outside the normal range of Dissolved Oxygen, Temperature or time-frame). DO_PerSat()
is to convert dissolved oxygen concentration to percent saturation to be used to evalute complaince with established water quality standards. DO.TOD.WQS.stream()
was developed to calculate water quality standards specific to dissolved oxygen for class-III streams in Florida (See ?DO.TOD.WQS.stream
for more information).cond.to.spc()
and SalinityCalc()
were developed to calculate specific conductance and salinity from conductance and temperature.TN_Combine()
will calculate total nitrogen and if total nitrogen (direct measure) data is present it will combine calculated and direct measure into one field.Additional basic statistical analyses
Other basic statsitical functions including standard error (SE()
), sample size/count (N()
) and coefficient of variation (cv.per()
) were developed to help provide statistical summaries of large datasets.
Plotting
I am partial to plotting using base
functions. To reduce the amount of code and optimize data visulaizations several functions were developed.
pt_line()
, pt_line_error()
, pt_error()
, errorbars()
were developed to quickly draw lines, points and error bar in base plotting.shaded.range()
was developed to quickly visulize model prediction and/or confidence intervals by plotting the upper and lower bounds of the predict(... interval=c("prediction" "confidence"))
output(s).log.scale.fun()
and axis_fun()
allow for manipulation of axis tick marks and labels.Date and time functions
Working with date fields correctly in R can be onerous, therefore a few functions were developed to handle these type of issues. date.fun()
and dst.to.est()
are the two major date handling functions. Other functions revolving around date fields include WY()
, hydro.day()
, decimal.WY()
and FL.Hydroseason()
to calcualte water year, day of water year and wet/dry season respectively.
read.access()
read.access()
streamlines the process of reading MS Access tables into R
by using the RODBC
package. For some systems, Microsoft Access Database Engine 2010 may need to be install. Here is the link for Redistributable installer.