Skip to content

Commit

Permalink
handle dates in part 2 without assumptions in number of characters
Browse files Browse the repository at this point in the history
  • Loading branch information
jhmigueles committed Sep 23, 2024
1 parent 735b528 commit 9a9331a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion R/GGIR.R
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ GGIR = function(mode = 1:5, datadir = c(), outputdir = c(),
g.report.part2(metadatadir = metadatadir, f0 = f0, f1 = f1,
maxdur = params_cleaning[["maxdur"]],
store.long = store.long, params_output,
verbose = verbose)
verbose = verbose, desiredtz = params_general[["desiredtz"]])
}
}
if (length(which(do.report == 4)) > 0) {
Expand Down
8 changes: 5 additions & 3 deletions R/g.report.part2.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
g.report.part2 = function(metadatadir = c(), f0 = c(), f1 = c(), maxdur = 0,
store.long = FALSE, params_output, verbose = TRUE) {
store.long = FALSE, params_output, verbose = TRUE,
desiredtz = "") {
ms2.out = "/meta/ms2.out"
if (file.exists(paste0(metadatadir,ms2.out))) {
if (length(dir(paste0(metadatadir,ms2.out))) == 0) {
Expand Down Expand Up @@ -239,8 +240,9 @@ g.report.part2 = function(metadatadir = c(), f0 = c(), f1 = c(), maxdur = 0,
# tidy up data.frames
SUMMARY_clean = tidyup_df(SUMMARY)
daySUMMARY_clean = tidyup_df(daySUMMARY)
# format calendar dates (dates are stored as iso8601, so date is in the first 10 characters )
daySUMMARY_clean$calendar_date = substr(daySUMMARY_clean$calendar_date, 1, 10)
# format calendar dates
dd = iso8601chartime2POSIX(daySUMMARY_clean$calendar_date, tz = desiredtz)
daySUMMARY_clean$calendar_date = format(dd, format = "%Y-%m-%d")
#===============================================================================
# store final matrices again
data.table::fwrite(x = SUMMARY_clean, file = paste0(metadatadir, "/results/part2_summary.csv"),
Expand Down
5 changes: 4 additions & 1 deletion man/g.report.part2.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}
\usage{
g.report.part2(metadatadir = c(), f0 = c(), f1 = c(), maxdur = 0,
store.long = FALSE, params_output, verbose = TRUE)
store.long = FALSE, params_output, verbose = TRUE, desiredtz = "")
}
\arguments{
\item{metadatadir}{
Expand Down Expand Up @@ -39,6 +39,9 @@
\item{verbose}{
See details in \link{GGIR}.
}
\item{desiredtz}{
See details in \link{GGIR}.
}
}
\value{
Function does not produce data, but only writes reports
Expand Down

0 comments on commit 9a9331a

Please sign in to comment.