[Experimental]

read_acttrust() allows you to read, tidy, and validate an ActTrust file in a consistent and easy manner. You can see the output data structure in ?acttrust.

ActTrust is a trademark of Condor Instruments Ltda.

read_acttrust(file = file.choose(), tz = "UTC", regularize = TRUE)

Arguments

file

A string with the file path for the ActTrust data. If not assigned, a dialog window will open allowing the user to browse and select a file.

tz

A string that specifies which time zone to parse the dates/time with. The string must be a time zone that is recognized by the user's OS. For more information see ?timezone (default: "UTC").

regularize

(optional) a logical value indicating if the function must correct irregular intervals (highly recommended). See more about it in the Details section (default: TRUE).

Value

A tsibble object. The data structure can be found in ?acttrust.

Details

Requirements

read_acttrust() requires the readr package. If you don't already have it installed, you can install it with:

install.packages("readr")

Regularize parameter

It's common to find some uneven epochs/intervals in ActTrust data files. This occurs because the actigraph internal clock can go off by some seconds while recording and can become an issue while doing some computations. By using regularize == TRUE, read_acttrust() find and correct those irregularities.

It's important to note that this process will only work if a clear epoch/periodicity can be found in the data. Regularization is made by aggregating the values between epochs, averaging values for numeric variables and assigning the most frequent value (mode) for single integer or other type of variables.

Any gap found in the time series will be assign as NA, with a state value of 9.

Offwrist data

read_acttrust() will transform any offwrist data (data with state == 4) into missing data (NA). They will still going to be classified as offwrist in the state variable.

Data wrangling

The process of tiding a dataset is understood as transforming it in input data, like described in Loo and Jonge (2018). It's a very similar process of tiding data described in the workflow proposed by Wickham and Grolemund (n.d.).

The process of validating a dataset is understood as detecting invalid data, by checking whether data satisfies certain assumptions from domain knowledge, to then, removing or, if possible, fixing them. This process can be considered as part of the process of transforming data, described in the workflow proposed by Wickham and Grolemund (n.d.).

To learn more about the concept of tidy data, see Wickham (2014) and Wickham and Grolemund (n.d.). You can find more about data validation and error location in Loo and Jonge (2018).

References

van der Loo, M., & de Jonge, E. (2018). Statistical data cleaning with applications in R. John Wiley & Sons. doi:10.1002/9781118897126 .

Wickham, H. (2014). Tidy Data. Journal of Statistical Software, 59(10), 1-23. doi:10.18637/jss.v059.i10 .

Wickham, H., & Grolemund, G. (n.d.). R for data science. (n.p.). https://r4ds.had.co.nz

See also

Other utility functions: aggregate_index(), find_epoch(), raw_data(), write_acttrust()

Examples

read_acttrust(raw_data("acttrust.txt"))
#>  Reading data
#>  Reading data [153ms]
#> 
#>  Tidying data
#>  Tidying data [94ms]
#> 
#>  Validating data
#>  Validating data [1.1s]
#> 
#> # A tsibble: 1,441 x 17 [1m] <UTC>
#>    timestamp             pim   tat   zcm orientation wrist_temperature
#>    <dttm>              <dbl> <dbl> <dbl>       <dbl>             <dbl>
#>  1 2021-04-24 04:14:00  7815   608   228           0              26.9
#>  2 2021-04-24 04:15:00  2661   160    64           0              27.2
#>  3 2021-04-24 04:16:00  3402   243    80           0              27.7
#>  4 2021-04-24 04:17:00  4580   317   125           0              27.9
#>  5 2021-04-24 04:18:00  2624   255    33           0              28.0
#>  6 2021-04-24 04:19:00  3929   246   105           0              28.1
#>  7 2021-04-24 04:20:00  5812   369   171           0              28.2
#>  8 2021-04-24 04:21:00  3182   270    54           0              28.4
#>  9 2021-04-24 04:22:00  6362   373   189           0              28.6
#> 10 2021-04-24 04:23:00  2621   159    64           0              28.7
#> # ℹ 1,431 more rows
#> # ℹ 11 more variables: external_temperature <dbl>, light <dbl>,
#> #   ambient_light <dbl>, red_light <dbl>, green_light <dbl>, blue_light <dbl>,
#> #   ir_light <dbl>, uva_light <dbl>, uvb_light <dbl>, event <dbl>, state <dbl>