Skip to content

Commit

Permalink
correct startindex for Actical which starts at epoch zero instead of 1
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentvanhees committed Sep 27, 2024
1 parent 38669db commit 43428d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions R/readActicalCount.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ readActicalCount = function(filename = file, desiredEpochSize = NULL,
startindex = 300
quote = detectQuote(fn = filename, index = startindex)
startindex = findStartData(filename, quote, startindex)
# -1 because Actical starts at epoch 0 while function looks for epoch 1
startindex = startindex - 1
D = data.table::fread(input = filename, sep = ",", skip = startindex,
quote = quote, data.table = FALSE)
# ! Assumption that column names are present 2 lines prior to timeseries
Expand Down
10 changes: 5 additions & 5 deletions tests/testthat/test_readActicalCount.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ test_that("Actical csv is correctly read", {
file = system.file("testfiles/Actical.csv", package = "GGIRread")
D = readActicalCount(filename = file, desiredEpochSize = 60, timeformat = "%d-%b-%y %H:%M", tz = "")
expect_equal(D$epochSize, 60)
expect_equal(format(D$startTime), "2021-05-13 00:01:00")
expect_equal(nrow(D$data), 500)
expect_equal(format(D$startTime), "2021-05-13")
expect_equal(nrow(D$data), 501)
expect_equal(ncol(D$data), 2)
expect_equal(sum(D$data, na.rm = TRUE), 8174)
expect_equal(sum(D$data, na.rm = TRUE), 8436)

D = readActicalCount(filename = file, desiredEpochSize = 120, timeformat = "%d-%b-%y %H:%M", tz = "")
expect_equal(D$epochSize, 120)
expect_equal(format(D$startTime), "2021-05-13 00:01:00")
expect_equal(format(D$startTime), "2021-05-13")
expect_equal(nrow(D$data), 250)
expect_equal(ncol(D$data), 2)
expect_equal(sum(D$data, na.rm = TRUE), 8174)
expect_equal(sum(D$data, na.rm = TRUE), 8436)
})

test_that("Actical csv error correctly", {
Expand Down

0 comments on commit 43428d4

Please sign in to comment.