Skip to content

Commit 441a93e

Browse files
committed
added example
1 parent 7e096ac commit 441a93e

2 files changed

Lines changed: 36 additions & 16 deletions

File tree

R/create_day_inclusion.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ add_day_inclusion = function(
9494
data,
9595
...
9696
) {
97+
time = date = NULL
98+
rm(list = c("time", "date"))
99+
97100
day_data = create_day_inclusion(data, ...)
98101
data = acti_standardize_data(data, subset_xyz = FALSE, check_xyz = FALSE)
99102
data = data %>%

example.R

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@ sc = import("stepcount")
55
sc$stepcount
66
stepcount::stepcount_check()
77

8-
library(tidyverse)
9-
library(activerse)
10-
path = "~/Dropbox/Data/wearable_pilot/data/raw/ag_axivity_test/John/114890_0000000000.cwa"
11-
12-
# path = "inst/extdata/TAS1H30182785_2019-09-17.gt3x.gz"
13-
data = acti_read_cwa(path)
14-
function(data, calibrate = FALSE) {
8+
acti_run = function(data, calibrate = FALSE) {
159
if (calibrate) {
1610
data = acti_calibrate(data)
1711
}
@@ -25,19 +19,42 @@ function(data, calibrate = FALSE) {
2519
processed = processed %>%
2620
dplyr::full_join(steps)
2721

28-
res = create_day_inclusion(processed, min_required = 1368L)
22+
inclusion = create_day_inclusion(processed, min_required = 1368L)
2923
processed = processed %>%
3024
mutate(date = as.Date(time)) %>%
31-
left_join(res)
32-
processed %>%
33-
mutate(log10AC = log(counts)) %>%
25+
left_join(inclusion)
26+
na_sum = function(x) sum(x, na.rm = TRUE)
3427

35-
summarise
28+
processed = processed %>%
29+
mutate(log10AC = log(counts + 1))
30+
31+
daily = processed %>%
32+
acti_create_date() %>%
33+
group_by(date) %>%
34+
summarise(
35+
dplyr::across(any_of(
36+
c("counts", "log10AC", "steps", "MIMS", "mims")),
37+
na_sum
38+
)
39+
)
40+
daily = daily %>%
41+
full_join(inclusion)
42+
43+
list(
44+
minute_level = processed,
45+
inclusion = inclusion,
46+
daily = daily
47+
)
3648
}
3749

50+
library(tidyverse)
51+
library(activerse)
52+
path = "~/Dropbox/Data/wearable_pilot/data/raw/ag_axivity_test/John/114890_0000000000.cwa"
3853

54+
# path = "inst/extdata/TAS1H30182785_2019-09-17.gt3x.gz"
55+
data = acti_read_cwa(path)
3956

40-
41-
42-
43-
57+
out = acti_run(data)
58+
out$minute_level
59+
out$inclusion
60+
out$daily

0 commit comments

Comments
 (0)