read_actigraphy: Read Actigraphy File

View source: R/read_actigraphy.R

read_actigraphyR Documentation

Read Actigraphy File

Description

Read Actigraphy File

Usage

read_actigraphy(file, ..., read_function = NULL)

Arguments

file

file to read

...

additional arguments to pass to function

read_function

A custom function to read the data in.

Value

An accelerometer object from the function used to read the file.

Examples



file = system.file("extdata",
"TAS1H30182785_2019-09-17.gt3x",
package = "SummarizedActigraphy")
res = read_actigraphy(file)
testthat::expect_equal(mean(res$data$X), -0.0742151351351352)

file = "blah.exe"
testthat::expect_error(read_actigraphy(file))

url = paste0("https://github.com/THLfi/read.gt3x/files/",
"3522749/GT3X%2B.01.day.gt3x.zip")
destfile = tempfile(fileext = ".zip")
dl = utils::download.file(url, destfile = destfile, mode = "wb")
gt3x_file = utils::unzip(destfile, exdir = tempdir())
gt3x_file = gt3x_file[!grepl("__MACOSX", gt3x_file)]
path = gt3x_file
res = read_actigraphy(path)
testthat::expect_equal(mean(res$data$X), -0.228406351135833)

dob = res$header$Value[res$header$Field == "DateOfBirth"]
if (length(dob) > 0) {
 SummarizedActigraphy:::ticks2datetime(dob)
}



muschellij2/SummarizedActigraphy documentation built on Aug. 12, 2024, 5:35 p.m.