knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(tidyverse)
library(devtools)
library(roxygen2)
library(testthat)
library(PrecipPackage)

The PrecipPackage contains: Three functions summarizing data - Mean Precipitation by Season - Mean Precipitation by Month (using a multidimensional array) - Total Precipitation by Year

Three functions measuring impacts - Predict Flooding Risk - Number of months where monthly precipitation is above the annual mean - Number of months where monthly precipitation is below the annual mean

One functions calculating costs of impacts - Calculate Water Tax

Three tests - Months equal 12 and seasons equal 4 when using mean_pecip_by_season - Precipitation is always numeric and positive - Years equal 18 and Locations equal 3 when using total_precip_by_year

Sample data in and .Rda file - monthly_precip.rda

# Get precipitation data to un all the functions
data("monthly_precip")
### Mean Precipitation by Season
# To see how this function works you can change the year and use the same precipitation data

mean_precip_by_season(monthly_precip, 2014)
### Mean Precipitation by Month (using a multidimensional array)
# This function calculates mean monthly annual precipitation for all water years using a multidimensional array, displayed as either a graph (TRUE) or a table (FALSE).

mean_precip_by_month(monthly_precip, TRUE)
### Total Precipitation by Year
# This function calculates annual precipitation totals for each water year by location. displayed as either a graph (TRUE) or a table (FALSE).

total_precip_by_year(monthly_precip, TRUE)
### Predict Flooding Risk
# To see how this function works you can change the year and use the same precipitation data

predict_flooding(monthly_precip, 2007)
### Number of months where monthly precipitation is above the annual mean
# This graph is an index of how many wet months are in each year from 2002-2019. A longer dataset would show if there is a trend in rainy or dry years.

calc_months_above_mean(monthly_precip)
### Number of months where monthly precipitation is below the annual mean
# This graph is an index of how many dry months are in each year from 2002-2019. A longer dataset would show if there is a trend in rainy or dry years.

calc_months_below_mean(monthly_precip)
### Calculate Water Tax
# Calculates water tax based on housegold consumption, location, the tax month, and year.
# For the function calc_water_tax(precip_data, household_consumption, location, month_tax, year) enter:
   # precip_data = the precipitation dataset
   # household_consumption = a number of how much water is consumed
   # location = "Paso Robles", "San Luis Obispo", or "Santa Barbara"
   # month_tax = three-letter month code
   # year = Year 2002 through 2019

 calc_water_tax(monthly_precip, 100, "SANTA BARBARA", "OCT", 2012)


jkmiller-wildlife/PrecipPackage documentation built on June 18, 2019, 1:34 p.m.