collapse.accfile: Collapse raw accelerometer files into a summary dataset

Description Usage Arguments Value Author(s) References See Also Examples

Description

This function collapses accelerometer data into a dataframe with summary statistics.

Usage

1
2
3
4
5
6
7
collapse(...)
## S3 method for class 'accfile'
collapse(object, which = "counts", palist = list(value = c(0, 100, 1000, 5000, 13000),
rescale.epoch = 60, labels = NULL, extreme = NULL), mwlist = list(value = 20,
nz = 0, rescale.epoch = 60), collapse.by = "%Y-%m-%d", collapse.epoch = 60, aggregate.by =
NULL, FUN.list = list(mean = function(x) mean(x, na.rm = TRUE)),
keep.extreme = FALSE, keep.error = FALSE, ...)

Arguments

object

an object of class gt1m.

which

either 'counts' or 'steps' for gt1m files or one of c('x','y','z','steps') for gt3x files.

palist

list of arguments for markpa.accfile.

mwlist

list of arguments for markwear.accfile.

collapse.by

dataset aggregation level. See argument format from strptime for options and details below.

collapse.epoch

epoch by which time spent in different physical activity modes is summarized. See details.

aggregate.by

pre-collapsing aggregation level for accelerometer values. See argument format from strptime for options.

FUN.list

a named list of functions. See fun.collapse.

keep.extreme

logical flag. If FALSE (default) extreme values will be replaced by NAs. See markpa.accfile.

keep.error

logical flag. If FALSE (default) data errors as identified by errorChk will be replaced by NAs.

...

arguments for dateSummary.

Value

A data frame containing the following variables

collapse.by

aggregation factor

fileid

file identifier

...

named columns according to arguments FUN and labels of palist

Author(s)

Marco Geraci

References

Geraci M, Rich C, Sera F, Cortina-Borja M, Griffiths LJ, and Dezateux C (2012). Technical report on accelerometry data processing in the Millennium Cohort Study. London, UK: University College London. Available at http://discovery.ucl.ac.uk/1361699

See Also

markpa.accfile, markwear.accfile, fun.collapse

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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
## Not run: 

data(gt1m_sample)

collapse(gt1m_sample, palist = list(value = c(0, 100, 2000, 4000, 11000),
rescale.epoch = 60, labels = c("sedentary","light","moderate","vigorous","extreme_values"),
extreme = "last"), mwlist = list(value = 20,
nz = 0), collapse.by = "%Y-%m-%d", collapse.epoch = 60,
FUN.list = list(mean = function(x) round(mean(x, na.rm = TRUE),2)),
keep.extreme = FALSE, keep.error = FALSE)
$outcome
  collapse.by fileid outcome.mean sedentary  light moderate vigorous
1  2011-12-08   test       117.63    293.75 243.75    29.75     4.00
2  2011-12-09   test       157.83    349.75 143.25    33.50    24.50
3  2011-12-10   test        79.75    468.25 177.25    24.25     6.25
4  2011-12-11   test        57.96    355.50 126.00     8.50     3.25
5  2011-12-12   test        70.05    455.50 157.25    19.50     6.00
6  2011-12-13   test        72.99    475.50 181.50    15.25     8.00
7  2011-12-14   test        79.94    476.25 210.50    20.25     8.50
8  2011-12-15   test       232.50      0.00   0.50     0.00     0.00
9  2011-12-16   test          NaN      0.00   0.00     0.00     0.00
  extreme_values non-wear
1           0.00   388.75
2           6.00   883.00
3           0.50   763.50
4           0.25   946.50
5           0.00   801.75
6           0.25   759.50
7           1.50   723.00
8           0.00  1439.50
9           0.00   187.50

$call
collapse.accfile(object = gt1m_sample, palist = list(value = c(0, 
    100, 2000, 4000, 11000), rescale.epoch = 60, labels = c("sedentary", 
    "light", "moderate", "vigorous", "extreme_values"), extreme = "last"), 
    mwlist = list(value = 20, nz = 0), collapse.by = "
    collapse.epoch = 60, FUN.list = list(mean = function(x) round(mean(x, 
        na.rm = TRUE), 2)), keep.extreme = FALSE, keep.error = FALSE)

attr(,"class")
[1] "accfile.collapse"
Warning message:
In collapse.accfile(gt1m_sample, palist = list(value = c(0, 100,  :
  NAs imputed where extreme counts found

## End(Not run)

## Not run: 

collapse(gt1m_sample, palist = list(value = c(0, 100, 2000, 4000, 11000),
rescale.epoch = 60, labels = c("sedentary","light","moderate","vigorous","extreme_values"),
extreme = "last"), mwlist = list(value = 20,
nz = 0), collapse.by = "%Y-%m-%d", collapse.epoch = 60,
FUN.list = list(mean = function(x) round(mean(x, na.rm = TRUE),2),
sd = function(x) round(sd(x, na.rm = TRUE),2),
"95th" = function(x) round(quantile(x, probs = .95, na.rm = TRUE),2)),
keep.extreme = TRUE, keep.error = FALSE)
$outcome
  collapse.by fileid outcome.mean outcome.sd outcome.95th sedentary  light
1  2011-12-08   test       117.63     216.12       529.40    293.75 243.75
2  2011-12-09   test       201.10     567.65      1085.60    349.75 143.25
3  2011-12-10   test        81.97     221.33       465.50    468.25 177.25
4  2011-12-11   test        59.80     172.08       320.35    355.50 126.00
5  2011-12-12   test        70.05     188.49       401.00    455.50 157.25
6  2011-12-13   test        74.08     207.55       386.85    475.50 181.50
7  2011-12-14   test        87.42     275.27       415.30    476.25 210.50
8  2011-12-15   test       232.50     222.74       374.25      0.00   0.50
9  2011-12-16   test          NaN         NA           NA      0.00   0.00
  moderate vigorous extreme_values non-wear
1    29.75     4.00           0.00   388.75
2    33.50    24.50           6.00   883.00
3    24.25     6.25           0.50   763.50
4     8.50     3.25           0.25   946.50
5    19.50     6.00           0.00   801.75
6    15.25     8.00           0.25   759.50
7    20.25     8.50           1.50   723.00
8     0.00     0.00           0.00  1439.50
9     0.00     0.00           0.00   187.50

$call
collapse.accfile(object = gt1m_sample, palist = list(value = c(0, 
    100, 2000, 4000, 11000), rescale.epoch = 60, labels = c("sedentary", 
    "light", "moderate", "vigorous", "extreme_values"), extreme = "last"), 
    mwlist = list(value = 20, nz = 0), collapse.by = "
    collapse.epoch = 60, FUN.list = list(mean = function(x) round(mean(x, 
        na.rm = TRUE), 2), sd = function(x) round(sd(x, na.rm = TRUE), 
        2), `95th` = function(x) round(quantile(x, probs = 0.95, 
        na.rm = TRUE), 2)), keep.extreme = TRUE, keep.error = FALSE)

attr(,"class")
[1] "accfile.collapse"

## End(Not run)

pawacc documentation built on May 2, 2019, 5:20 p.m.