Skip to content

Commit

Permalink
v2.0.5.9083
Browse files Browse the repository at this point in the history
* refactor: Fix date in example reformatHobo for DO file, Issue #117
* refactor: Update reformatHobo date time conversion to account for no seconds
and 2 vs 4 digit years, Issue #117
  • Loading branch information
leppott committed Feb 23, 2021
1 parent 4beddc8 commit cc989e5
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 45 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ContDataQC
Title: Quality Control (QC) of Continous Monitoring Data
Version: 2.0.5.9082
Version: 2.0.5.9083
Authors@R: c(
person("Erik W", "Leppo", email="[email protected]",role=c("aut","cre")),
person("Ann","Roseberry Lincoln", role="ctb"),
Expand Down
16 changes: 12 additions & 4 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,25 @@ NEWS-ContDataQC

<!-- NEWS.md is generated from NEWS.Rmd. Please edit that file -->

#> Last Update: 2021-02-23 11:14:21
#> Last Update: 2021-02-23 15:39:16

# Version History

## v2.0.5.9083

2021-02-23

- refactor: Fix date in example reformatHobo for DO file, Issue \#117
- refactor: Update reformatHobo date time conversion to account for no
seconds and 2 vs 4 digit years, Issue \#117

## v2.0.5.9082

2021-02-23

- refactor: Shiny server, zip files add -j to strip folder names,
Issue \#109
- refactor: Add additional DO parameters to config, Issue \#117
- feature: Add additional DO parameters to config, Issue \#117
- refactor: Update other versions of config, Issue \#117
- docs: Update README install directions
- docs: README, trim lines to 80 characters
Expand All @@ -23,8 +31,8 @@ NEWS-ContDataQC
- refactor: Update Report\_Config.rmd so sensor depth and water level
are next to each other
- refactor: Copy updated Report\_Config.rmd to Shiny app, Issue \#117
- refactor: Add additional DO parameters (n=3) to reformatHobo
function , Issue \#117
- feature: Add additional DO parameters (n=3) to reformatHobo function
, Issue \#117

## v2.0.5.9081

Expand Down
16 changes: 12 additions & 4 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,25 @@ NEWS-ContDataQC

<!-- NEWS.md is generated from NEWS.Rmd. Please edit that file -->

#> Last Update: 2021-02-23 11:14:21
#> Last Update: 2021-02-23 15:39:16

# Version History

## v2.0.5.9083

2021-02-23

- refactor: Fix date in example reformatHobo for DO file, Issue \#117
- refactor: Update reformatHobo date time conversion to account for no
seconds and 2 vs 4 digit years, Issue \#117

## v2.0.5.9082

2021-02-23

- refactor: Shiny server, zip files add -j to strip folder names,
Issue \#109
- refactor: Add additional DO parameters to config, Issue \#117
- feature: Add additional DO parameters to config, Issue \#117
- refactor: Update other versions of config, Issue \#117
- docs: Update README install directions
- docs: README, trim lines to 80 characters
Expand All @@ -23,8 +31,8 @@ NEWS-ContDataQC
- refactor: Update Report\_Config.rmd so sensor depth and water level
are next to each other
- refactor: Copy updated Report\_Config.rmd to Shiny app, Issue \#117
- refactor: Add additional DO parameters (n=3) to reformatHobo
function , Issue \#117
- feature: Add additional DO parameters (n=3) to reformatHobo function
, Issue \#117

## v2.0.5.9081

Expand Down
11 changes: 9 additions & 2 deletions NEWS.rmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,18 @@ cat(paste0("Last Update: ",Sys.time()))

# Version History

## v2.0.5.9083
2021-02-23

* refactor: Fix date in example reformatHobo for DO file, Issue #117
* refactor: Update reformatHobo date time conversion to account for no seconds
and 2 vs 4 digit years, Issue #117

## v2.0.5.9082
2021-02-23

* refactor: Shiny server, zip files add -j to strip folder names, Issue #109
* refactor: Add additional DO parameters to config, Issue #117
* feature: Add additional DO parameters to config, Issue #117
* refactor: Update other versions of config, Issue #117
* docs: Update README install directions
* docs: README, trim lines to 80 characters
Expand All @@ -34,7 +41,7 @@ cat(paste0("Last Update: ",Sys.time()))
* refactor: Update Report_Config.rmd so sensor depth and water level are next
to each other
* refactor: Copy updated Report_Config.rmd to Shiny app, Issue #117
* refactor: Add additional DO parameters (n=3) to reformatHobo function
* feature: Add additional DO parameters (n=3) to reformatHobo function
, Issue #117

## v2.0.5.9081
Expand Down
87 changes: 55 additions & 32 deletions R/formatHobo.R
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,10 @@
#' myFiles <- "EXAMPLE_DO_RUSSWOOD--02M_DO_20180918_20190610.csv"
#' myDir.import <- file.path(myDir.BASE, "Data0_Original")
#' myDir.export <- file.path(myDir.BASE, "Data1_RAW")
#' HoboDateFormat <- "MDY"
#'
#' # Run Function (with default config)
#' formatHobo(myFiles, myDir.import, myDir.export)
#' formatHobo(myFiles, myDir.import, myDir.export, HoboDateFormat)
#'
#' }
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -193,7 +194,7 @@ formatHobo <- function(fun.myFile = ""
fun.myFile <- "EXAMPLE_DO_RUSSWOOD--02M_DO_20180918_20190610.csv"
fun.myDir.import <- file.path(getwd(), "Data0_Original")
fun.myDir.export <- file.path(getwd(), "Data1_RAW")
fun.HoboDateFormat <- "YMD"
fun.HoboDateFormat <- "MDY"
fun.myConfig <- ""
# Load environment
#ContData.env <- new.env(parent = emptyenv()) # in config.R
Expand Down Expand Up @@ -339,39 +340,61 @@ formatHobo <- function(fun.myFile = ""
, tolower(names(df_hobo)))]


# Modify Date ####
if(is.null(fun.HoboDateFormat)==FALSE){##IF.isnull.hobodate.START
# new date
date_new <- df_hobo[,col_Date]
# Determine delimiter
if(grepl("-", date_new[1])==TRUE){
HW_delim <- "-"
} else if (grepl("/", date_new[1])==TRUE){
HW_delim <- "/"
} else {
msg <- "Data format not discernable."
stop(msg)
}
# Determine format
if(toupper(fun.HoboDateFormat)=="MDY"){
HW_format <- paste0("%m",HW_delim,"%d",HW_delim,"%y %H:%M:%S")
} else if (toupper(fun.HoboDateFormat)=="DMY") {
HW_format <- paste0("%d",HW_delim,"%m",HW_delim,"%y %H:%M:%S")
} else if (toupper(fun.HoboDateFormat)=="YMD") {
HW_format <- paste0("%y",HW_delim,"%m",HW_delim,"%d %H:%M:%S")
} else {
msg <- paste0("Incorrect Hoboware format (MDY, DMY, YMD) specified, "
, fun.HoboDateFormat)
stop(msg)
}
# Modify Date ----

# Modify dates
date_new_mod <- format(strptime(date_new, format=HW_format)
, ContData.env$myFormat.DateTime)
# modify hobo data frame to updated date format
df_hobo[,col_Date] <- date_new_mod
if(is.null(fun.HoboDateFormat) == TRUE){
msg <- "No Hoboware date format (MDY, DMY, YMD) specified."
stop(msg)
}##IF.isnull.hobodate.END

# new date
date_new <- df_hobo[, col_Date]

# Determine delimiter
if(grepl("-", date_new[1]) == TRUE){
HW_delim <- "-"
} else if (grepl("/", date_new[1]) == TRUE){
HW_delim <- "/"
} else {
msg <- "Data format not discernable."
stop(msg)
}## grepl("-", date_new[1]) ~ END

# Determine format, time
n_colon <- nchar(date_new[1]) - nchar(gsub(":", "", date_new[1]))
if(n_colon == 2) {
time_fmt <- " %H:%M:%S"
} else if(n_colon == 1) {
time_fmt <- " %H:%M"
} else {
time_fmt <- ""
}## if(n_colon) ~ END

# Determine format, year
dateonly <- strsplit(date_new, " ")[[1]][1]
dateonly_split <- unlist(strsplit(dateonly, HW_delim)[[1]])
year_fmt <- ifelse(max(nchar(dateonly_split)) == 4
, "%Y", "%y")

# Determine format, date
if(toupper(fun.HoboDateFormat) == "MDY"){
HW_format <- paste0("%m", HW_delim, "%d", HW_delim, year_fmt, time_fmt)
} else if (toupper(fun.HoboDateFormat) == "DMY") {
HW_format <- paste0("%d", HW_delim, "%m", HW_delim, year_fmt, time_fmt)
} else if (toupper(fun.HoboDateFormat) == "YMD") {
HW_format <- paste0(year_fmt, HW_delim, "%m", HW_delim, "%d", time_fmt)
} else {
msg <- paste0("Incorrect Hoboware date format (MDY, DMY, YMD) specified, "
, fun.HoboDateFormat)
stop(msg)
}## if(toupper(fun.HoboDateFormat) ~ END

# Modify dates
date_new_mod <- format(strptime(date_new, format = HW_format)
, ContData.env$myFormat.DateTime)
# modify hobo data frame to updated date format
df_hobo[,col_Date] <- date_new_mod


# Columns, Output
## same values as ContData.env$myName.*
Expand Down
2 changes: 1 addition & 1 deletion inst/extdata/ContDataQC_LibraryCreation.nb.html
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
<h1 class="title toc-ignore">ContDataQC</h1>
<h3 class="subtitle">Library Creation</h3>
<h4 class="author"><a href="mailto:[email protected]" class="email">[email protected]</a></h4>
<h4 class="date">2021-02-23 09:02:10</h4>
<h4 class="date">2021-02-23 15:39:20</h4>

</div>

Expand Down
3 changes: 2 additions & 1 deletion man/formatHobo.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cc989e5

Please sign in to comment.