Skip to content

Commit

Permalink
added error checks in wtregdo for duplicated and non-ascending time s…
Browse files Browse the repository at this point in the history
…tamps
  • Loading branch information
fawda123 committed Sep 12, 2023
1 parent d7267f8 commit abff30d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: WtRegDO
Type: Package
Title: Implement Weighted Regression on Dissolved Oxygen Time Series
Version: 1.0.0
Date: 2022-08-03
Version: 1.0.1
Date: 2023-09-12
Author: Marcus W. Beck [aut, cre]
Maintainer: Marcus W. Beck <[email protected]>
Description: A sample dataset and functions to implement weighted regression
Expand Down
10 changes: 10 additions & 0 deletions R/wtreg.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ wtreg <- function(dat_in, DO_obs = 'DO_obs', depth_val = 'Tide', wins = list(4,
if(any(chk))
stop('Duplicated observations found, check rows: ', paste(which(chk), collapse = ', '))

# check for duplicated timestamps
chk <- duplicated(dat_in$DateTimeStamp)
if(any(chk))
stop('Duplicated time entries for DateTimeStamp found, check rows: ', paste(which(chk), collapse = ', '))

# check time stamps in ascending order
chk <- sign(diff(dat_in$DateTimeStamp)) == -1
if(any(chk))
stop('Time entries in DateTimeStamp not in ascending order')

# rename DO_obs if other value provided
names(dat_in)[names(dat_in) %in% DO_obs] <- 'DO_obs'

Expand Down

0 comments on commit abff30d

Please sign in to comment.