knitr::opts_chunk$set(echo = TRUE)

NOTE: If you are viewing this page via CRAN note that the main GGIR documentation has been migrated to the GGIR GitHub pages.

Introduction

GGIR can automatically read data from the most-frequently used accelerometer brands in the field:

However, the accelerometer manufacturers are proliferating with an increasing number of brands in the market. For such reason, GGIR includes the read.myacc.csv function, which is able to read accelerometer raw triaxial data stored in csv files, independently of the brand. This vignette provides a general introduction on how to use GGIR to read accelerometer raw data stored in csv files.

How it works:

Internally GGIR loads csv files with accelerometer data and standardises the output format to make the data compatible with other GGIR functions. Data format standardisation includes unit of measurement, timestamp, file header format, and column locations.

The read.myacc.csv function

As for the rest of GGIR functions, read.myacc.csv is intended to be used within function GGIR. All the arguments of the read.myacc.csv can be easily recognized as they all start by "rmc". GGIR checks whether argument rmc.firstrow.acc is provided by the user; in such case, GGIR will attempt to read the data with function read.myacc.csv. In other words you always need to specify rmc.firstrow.acc to use read.myacc.csv. Further, we recommend that you always first test the function argument settings by first trying to use function read.myacc.csv on its own. When that works copy the arguments to you GGIR call.

Input arguments

As the read.myacc.csv function tries to read csv files with a wide variety of formats, the key arguments to specify depend on the characteristics of the csv file to process. Overall, if an argument is not relevant, it should be left in default setting (e.g., if the csv file does not contain temperature data, the arguments related to temperature settings should be left in default values).

Below we present a summary of the available input arguments. Please see the parameters vignette for a more elaborate description of these input arguments. Further, the arguments are also covered by the function documentation for the read.myacc.csv function.

General arguments

Arguments for files containing a header {#header}

Arguments for files including timestamps

Arguments for files with acceleration stored in bits

Arguments for files including temperature

Arguments for files including wear time information

Arguments to find time gaps and resampling

Usage of the read.myacc.csv function

This section shows an example real case in which the read.myacc.csv function can be used. The csv file to be read has the following structure:

dateTime | acc_x | acc_y | acc_z | ambient_temp ---|---|---|---|--- 1/1/2022 16:48:26.000|-0.42041016|0.41114536|-0.76733398|24 1/1/2022 16:48:26.009|-0.41674805|0.40919218|-0.76611328|24 1/1/2022 16:48:26.019|-0.42407227|0.40845973|-0.77539062|24 1/1/2022 16:48:26.029|-0.41894531|0.41163366|-0.77246094|24 1/1/2022 16:48:26.039|-0.4206543|0.41749321|-0.76806641|24 1/1/2022 16:48:26.049|-0.42163086|0.42091128|-0.76757812|24 1/1/2022 16:48:26.059|-0.42236328|0.41627247|-0.76391602|24 1/1/2022 16:48:26.069|-0.42431641|0.4189581|-0.76171875|24 1/1/2022 16:48:26.079|-0.42138672|0.41993469|-0.76513672|24

This file contains timestamps in the column 1 (formatted as "%d/%m/%Y %H:%M:%OS"), the acceleration signals (in g's) for the x, y, and z axis in the columns 2, 3, and 4, respectively, and temperature information in Celsius in the column 5. Also, this file has no file header.

Before we can use this with GGIR, we first test read this file using the read.myacc.csv function directly.

```{R,eval=FALSE} library(GGIR) data = read.myacc.csv(rmc.file = "C:/mystudy/mydata/datafile.csv", rmc.nrow = Inf, rmc.skip = 0, rmc.dec = ".", rmc.firstrow.acc = 2, rmc.col.acc = 2:4, rmc.col.temp = 5, rmc.col.time=1, rmc.unit.acc = "g", rmc.unit.temp = "C", rmc.unit.time = "POSIX", rmc.format.time = "%d/%m/%Y %H:%M:%OS", desiredtz = "Europe/London", rmc.sf = 100)

The object data is a list with a data.frame name data and a header.
The time column in the data.frame represents timestamps expressed in seconds since 1-1-1970.

## Example using the shell function

If the `rmc.firstrow.acc` argument is defined within the `GGIR` function, then the data will be read through `read.myacc.csv`. GGIR needs the user to specify in which row starts the accelerometer data within the csv, so this argument must be always explicitly specified by the user. Thus, a call to the `GGIR` including the rmc arguments would look as follows (note that the `rmc.file`, `rmc.nrow`, and `rmc.skip` arguments will not be used by `GGIR` as these arguments are already defined by `datadir`, `strategy`, and [header](#header) arguments, respectively).

```{R,eval=FALSE}
library(GGIR)
GGIR(
             mode=c(1,2,3,4,5),
             datadir="C:/mystudy/mydata/datafile.csv",
             outputdir="D:/myresults",
             do.report=c(2,4,5),
             #=====================
             # read.myacc.csv arguments
             #=====================
             rmc.nrow = Inf, 
             rmc.dec = ".",
             rmc.firstrow.acc = 2, 
             rmc.col.acc = 2:4, 
             rmc.col.temp = 5, 
             rmc.col.time=1,
             rmc.unit.acc = "g", 
             rmc.unit.temp = "C", 
             rmc.unit.time = "POSIX",
             rmc.format.time = "%d/%m/%Y %H:%M:%OS",
             desiredtz = "Europe/London",
             rmc.sf = 100,
             rmc.noise = 0.013
)
knitr::include_graphics("GGIR-MASTERLOGO-RGB.png")


wadpac/GGIR documentation built on March 5, 2025, 11 p.m.