Calculates daily means from depth profile data

daily_depth_means(data, col_siteid, col_datetime, col_depth, col_measure)

Arguments

data

data frame of site id, data/time, depth, and measurement (e.g., temperature).

col_siteid

Column name, SiteID

col_datetime

Column name, Date and Time

col_depth

Column name, Depth

col_measure

Column name, measurement for calculation

Value

data frame of daily means by depth

Details

Interpolates at integer depths. Daily means with interpolation.

Utilizes the `xts` package.

Examples

# Packages
library(xts)
#> Loading required package: zoo
#> 
#> Attaching package: ‘zoo’
#> The following objects are masked from ‘package:base’:
#> 
#>     as.Date, as.Date.numeric

# Lake Data
data <- laketemp

# Filter by any QC fields
data <- data[data$FlagV == "P", ]

# name columns
col_siteid   <- "SiteID"
col_datetime <- "Date_Time"
col_depth    <- "Depth_m"
col_measure  <- "Water_Temp_C"

# run function
data_ddm <- daily_depth_means(data
                             , col_siteid
                             , col_datetime
                             , col_depth
                             , col_measure)

# summary
summary(data_ddm)
#>       Date                Depth     Measurement     
#>  Min.   :2017-01-19   Min.   : 2   Min.   : 0.3707  
#>  1st Qu.:2017-04-18   1st Qu.: 8   1st Qu.: 2.0038  
#>  Median :2017-07-16   Median :15   Median : 4.8166  
#>  Mean   :2017-07-16   Mean   :15   Mean   : 6.1513  
#>  3rd Qu.:2017-10-13   3rd Qu.:22   3rd Qu.: 8.5071  
#>  Max.   :2018-01-10   Max.   :28   Max.   :22.0829