Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Changes in version 1.0.9 (release date:15-07-2026)

- Fix bug in readActiwatchCount. #92

# Changes in version 1.0.8 (release date:11-03-2026)

- Update readActiwatchCount to handle behaviour upcoming data.table package release. #89
Expand Down
6 changes: 3 additions & 3 deletions R/readActiwatchCount.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ readActiwatchCount = function(filename = NULL,
#=========================================================
# ! Assumption that first data row equals the first row with 3 columns
index = 0

quote = detectQuote(filename = filename, skip = 50)
NC = 1
while (NC >= 3) {
NC = 0
while (NC < 3) {
testraw = data.table::fread(input = filename,
header = FALSE, sep = ",", skip = index,
nrows = 1, data.table = TRUE, quote = quote)
Expand All @@ -67,6 +66,7 @@ readActiwatchCount = function(filename = NULL,
} else {
index = index + 1
}
if (nrow(testraw) == 0) stop("No data in file")
}
D = data.table::fread(input = filename, sep = ",",
skip = index, quote = quote, data.table = FALSE)
Expand Down
8 changes: 3 additions & 5 deletions tests/testthat/test_readActiwatchCount.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ test_that("Actiwatch csv is correctly read", {
})
test_that("Actiwatch awd is correctly read", {
file = system.file("testfiles/Actiwatch.AWD", package = "GGIRread")
expect_warning(D <- readActiwatchCount(filename = file, timeformat = "%d-%b-%Y %H:%M:%S",
desiredtz = "Europe/Amsterdam"),
regexp = "Detected 1 column names but the data has 3 columns*")
D <- readActiwatchCount(filename = file, timeformat = "%d-%b-%Y %H:%M:%S",
desiredtz = "Europe/Amsterdam")
expect_equal(D$epochSize, 60)
expect_equal(format(D$startTime), "2009-10-01 17:00:00")
expect_equal(nrow(D$data), 329)
Expand All @@ -28,9 +27,8 @@ test_that("Actiwatch awd is correctly read", {

test_that("Actiwatch awd error correctly", {
file = system.file("testfiles/Actiwatch.AWD", package = "GGIRread")
expect_error(expect_warning(readActiwatchCount(filename = file,
expect_error(readActiwatchCount(filename = file,
timeformat = "%d-%m-%Y %H:%M:%S"),
regexp = "Detected 1 column names but the data has 3 columns*"),
regexp = "Time format*")

expect_error(readActiwatchCount(filename = "",
Expand Down
Loading