Skip to content

Commit

Permalink
add origin to make GGIR compatible with R 4.2.0, see also #1181 and #…
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentvanhees committed Jan 22, 2025
1 parent cf9b048 commit 2d22dd9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# CHANGES IN GGIR VERSION 3.1-??
# CHANGES IN GGIR VERSION 3.1-11

- Part 2:

Expand All @@ -21,6 +21,10 @@
- Added warning when there are two accelerometer recordings with the same ID.

- Change extraction of imputation code from sleep diary, which is now assumed to correspond to preceding night. This is now also documented. #1251

- Part 1, 5 and 6:

- Update code to be backward compatible with R 4.2.0

# CHANGES IN GGIR VERSION 3.1-10

Expand Down
9 changes: 6 additions & 3 deletions R/g.part6.R
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ 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"]])
mdat$time = mdat$timestamp = as.POSIXct(mdat$timenum,
tz = params_general[["desiredtz"]],
origin = "1970-01-01")
return(mdat)
}
mdat = imputeTimeGaps(mdat, epochSize)
Expand Down Expand Up @@ -238,7 +240,8 @@ 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"]])
starttime = as.POSIXlt(ts$time[1], tz = params_general[["desiredtz"]],
origin = "1970-01-01")
summary[fi] = format(starttime)
s_names[fi] = "starttime"
fi = fi + 1
Expand Down Expand Up @@ -291,7 +294,7 @@ 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"]]))
tempp = unclass(as.POSIXlt(acc4cos$time, tz = params_general[["desiredtz"]], origin = "1970-01-01"))
sec = tempp$sec
min = tempp$min
hour = tempp$hour
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test_part6.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ test_that("Part 6 with household co-analysis", {
"day_IN_bts_10_30", "day_LIG_bts_10")

mdat$timenum = mdat$timenum - (5 * 60)
mdat$timestamp = as.POSIXct(mdat$timenum, tz = params_general[["desiredtz"]])
mdat$timestamp = as.POSIXct(mdat$timenum, tz = params_general[["desiredtz"]], origin = "1970-01-01")
filename = "800-900-001_left wrist.bin"
save(mdat, filename, Lnames, file = paste0(dn, "/800-900-001_left wrist.RData"))
mdat$timenum = mdat$timenum + (7 * 60)
mdat$timestamp = as.POSIXct(mdat$timenum, tz = params_general[["desiredtz"]])
mdat$timestamp = as.POSIXct(mdat$timenum, tz = params_general[["desiredtz"]], origin = "1970-01-01")
filename = "800-900-002_left wrist.bin"
save(mdat, filename, Lnames, file = paste0(dn, "/800-900-002_left wrist.RData"))
mdat$timenum = mdat$timenum + (14 * 60)
mdat$timestamp = as.POSIXct(mdat$timenum, tz = params_general[["desiredtz"]])
mdat$timestamp = as.POSIXct(mdat$timenum, tz = params_general[["desiredtz"]], origin = "1970-01-01")
filename = "800-900-003_left wrist.bin"
save(mdat, filename, Lnames, file = paste0(dn, "/800-900-003_left wrist.RData"))
mdat_file3 = mdat
Expand Down

0 comments on commit 2d22dd9

Please sign in to comment.