Skip to content

Commit abff30d

Browse files
committed
added error checks in wtregdo for duplicated and non-ascending time stamps
1 parent d7267f8 commit abff30d

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

DESCRIPTION

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: WtRegDO
22
Type: Package
33
Title: Implement Weighted Regression on Dissolved Oxygen Time Series
4-
Version: 1.0.0
5-
Date: 2022-08-03
4+
Version: 1.0.1
5+
Date: 2023-09-12
66
Author: Marcus W. Beck [aut, cre]
77
Maintainer: Marcus W. Beck <mbafs2012@gmail.com>
88
Description: A sample dataset and functions to implement weighted regression

R/wtreg.R

+10
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ wtreg <- function(dat_in, DO_obs = 'DO_obs', depth_val = 'Tide', wins = list(4,
5353
if(any(chk))
5454
stop('Duplicated observations found, check rows: ', paste(which(chk), collapse = ', '))
5555

56+
# check for duplicated timestamps
57+
chk <- duplicated(dat_in$DateTimeStamp)
58+
if(any(chk))
59+
stop('Duplicated time entries for DateTimeStamp found, check rows: ', paste(which(chk), collapse = ', '))
60+
61+
# check time stamps in ascending order
62+
chk <- sign(diff(dat_in$DateTimeStamp)) == -1
63+
if(any(chk))
64+
stop('Time entries in DateTimeStamp not in ascending order')
65+
5666
# rename DO_obs if other value provided
5767
names(dat_in)[names(dat_in) %in% DO_obs] <- 'DO_obs'
5868

0 commit comments

Comments
 (0)