diff --git a/NEWS.md b/NEWS.md index c17cd858d..559b90104 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,7 +5,9 @@ - Part 6 and new visual report: Fix bug related to determining the combination of thresholds to use for the visual report and for part 6 analyses when there are several options and part6_threshold_combi is NULL. #1260 - + +- Part 6: Revise fix to #1181 and #1245 in 3.1-11 as it slowed down part 6 substantially. #1263 + # CHANGES IN GGIR VERSION 3.1-11 - Part 2: @@ -40,7 +42,7 @@ with only 1 valid day, these were previously skipped. #1246 - Change extraction of imputation code from sleep diary, which is now assumed to correspond to preceding night. #1251 -- Part 1, 5 and 6: Update code to be backward compatible with R 4.2.0 +- Part 1, 5 and 6: Update code to be backward compatible with R 4.2.0 #1181 and #1245 - Part 5: Default values for parameters `do.sibreport` and `save_ms5rawlevels` changed to TRUE, for `save_ms5raw_format` changed to "RData" in order to ease generating visual diff --git a/R/g.part6.R b/R/g.part6.R index 76b22ed51..cbfcf7c88 100644 --- a/R/g.part6.R +++ b/R/g.part6.R @@ -169,9 +169,8 @@ g.part6 = function(datadir = c(), metadatadir = c(), f0 = c(), f1 = c(), mdat$window[invalid] = 9999 mdat$invalid_sleepperiod[invalid] = 100 mdat$invalid_wakinghours[invalid] = 100 - mdat$time = mdat$timestamp = as.POSIXct(mdat$timenum, - tz = params_general[["desiredtz"]], - origin = "1970-01-01") + mdat$time = mdat$timestamp = .POSIXct(mdat$timenum, + tz = params_general[["desiredtz"]]) return(mdat) } mdat = imputeTimeGaps(mdat, epochSize) @@ -240,8 +239,7 @@ g.part6 = function(datadir = c(), metadatadir = c(), f0 = c(), f1 = c(), summary[fi] = unlist(strsplit(fnames.ms5raw[i], "_"))[1] s_names[fi] = "ID" fi = fi + 1 - starttime = as.POSIXlt(ts$time[1], tz = params_general[["desiredtz"]], - origin = "1970-01-01") + starttime = .POSIXct(ts$time[1], tz = params_general[["desiredtz"]]) summary[fi] = format(starttime) s_names[fi] = "starttime" fi = fi + 1 @@ -294,10 +292,10 @@ g.part6 = function(datadir = c(), metadatadir = c(), f0 = c(), f1 = c(), threshold = as.numeric(unlist(strsplit( params_phyact[["part6_threshold_combi"]], "_"))[1]) # extract nightsi again - tempp = unclass(as.POSIXlt(acc4cos$time, tz = params_general[["desiredtz"]], origin = "1970-01-01")) - sec = tempp$sec - min = tempp$min - hour = tempp$hour + tempp = .POSIXct(acc4cos$time, tz = params_general[["desiredtz"]]) + sec = data.table::second(tempp) + min = data.table::minute(tempp) + hour = data.table::hour(tempp) if (params_general[["dayborder"]] == 0) { nightsi = which(sec == 0 & min == 0 & hour == 0) } else { diff --git a/tests/testthat/test_part6.R b/tests/testthat/test_part6.R index 02ea7a91f..d763c8f5e 100644 --- a/tests/testthat/test_part6.R +++ b/tests/testthat/test_part6.R @@ -1,7 +1,7 @@ library(GGIR) context("g.part6") -test_that("Part 6 with household co-analysis", { +test_that("Part 6 can run household co-analysis and Circadian Rhythm analysis", { # Create test files for household co-analysis metadatadir = "./output_testpart6"