read.gt3x: Read GT3X

Description Usage Arguments Value Note See Also Examples

View source: R/readGT3X.R

Description

Read activity samples from a GT3X file as a matrix. Please note that all timestams are in local time (of the device) even though they are represented as POSIXct with GMT timezone.

Usage

1
2
read.gt3x(path, verbose = FALSE, asDataFrame = FALSE,
  imputeZeroes = FALSE, ...)

Arguments

path

Path to gt3x folder

verbose

print diagnostic messages

asDataFrame

convert to an activity_df, see as.data.frame.activity

imputeZeroes

Impute zeros in case there are missingness? Default is FALSE, in which case the time series will be incomplete in case there is missingness.

...

additional arguments to pass to parseGT3X C++ code

Value

A numeric matrix with 3 columns (X, Y, Z) and the following attributes:

Note

The timestamps in the .gt3x data format are saved in .NET format, which is nanoseconds in local time since 0001-01-01. This is a bit tricky to parse into an R datetime format. DateTimes are therefore represented as POSIXct format with the 'GMT' timezone attribute, which is false; the datetime actually represents local time.

See Also

Other gt3x-parsers: as.data.frame.activity, parse_gt3x_info, print.gt3x_info

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# first unzip, then read
datadir <- gt3x_datapath()
gt3xfolders <- unzip.gt3x(datadir)
gt3xfile <- gt3xfolders[2]
x <- read.gt3x(gt3xfile, imputeZeroes = TRUE, asDataFrame = FALSE,
verbose = TRUE)
df2 <- as.data.frame(x)
head(df2)
rm(x); gc(); gc()
rm(df2); gc()

# temporary unzip, read, convert to a data frame
gt3xfile <- gt3x_datapath(1)
memory.limit()
df <- read.gt3x(gt3xfile, asDataFrame = FALSE, verbose = 2)
head(df)

rm(df); gc(); gc()

df <- read.gt3x(gt3xfile, asDataFrame = TRUE, verbose = 2)
head(df)

## Not run: 
url = "https://github.com/THLfi/read.gt3x/files/3522749/GT3X%2B.01.day.gt3x.zip"
destfile = tempfile(fileext = ".zip")
dl = download.file(url, destfile = destfile)
gt3x_file = unzip(destfile, exdir = tempdir())
gt3x_file = gt3x_file[!grepl("__MACOSX", gt3x_file)]
path = gt3x_file

res = read.gt3x(path)

## End(Not run)

THLfi/read.gt3x documentation built on Dec. 8, 2019, 9:46 a.m.