Last updated: 2026-04-04 18:00:21 using pinned data version from: 2026-03-27 12:57:56
Users can load data by running (requires one-time google drive authentication):
Code
library(tidyverse)
library(pins)
library(nanoparquet)
library(googledrive)
ds <- board_gdrive(path = as_id("1OZlphhu6vYm1A2Bm2-zD7a4luS5nGWgS")) %>%
  pin_read("imu_raw_samples")

Usable data

Code
usable_data <- ds %>% count(id, session) %>% mutate(usable_hours = n/3600)
recording_duration <- ds %>% group_by(id, session) %>% 
  mutate(recording_hours = as.numeric(time_leg_off - time_leg_on)) %>% 
  slice_head(n = 1) %>% ungroup
  
usable_data %>% left_join(recording_duration) %>% 
  get_summary_stats(usable_hours, recording_hours, show = c("mean", "sd","min","max")) %>% 
  flextable() %>% autofit()

Usable data and total recording length in hours

variable

n

mean

sd

min

max

usable_hours

17

6.687

1.60

4.432

9.466

recording_hours

17

10.408

1.43

7.533

12.317

Code
usable_data  %>% 
  ggplot(aes(x = usable_hours)) + 
  geom_histogram() + 
  scale_x_binned(name = "Hours", limits = c(2,14))
recording_duration  %>% 
  ggplot(aes(x = recording_hours)) + 
  geom_histogram() + 
  scale_x_binned(name = "Hours", limits = c(2,14))

Usable hours after exclusions

Usable hours after exclusions

Recording length in hours

Recording length in hours

Infant Position Frequency by Age (Overall)

Code
ds_sum <- ds %>% group_by(id, session) %>% 
  mutate(total_samples = n()) %>% group_by(id, session, pos) %>% 
  summarize(pos_n  = n(), total_samples = mean(total_samples)) %>% ungroup
ds_sum <- ds_sum %>% complete(nesting(id, session), pos, fill = list(pos_n = 0, total_samples = 1))
ds_sum$pos_prop = ds_sum$pos_n/ds_sum$total_samples*100
ds_sum$session = as.numeric(ds_sum$session)

ds_sum %>% group_by(pos, session) %>% 
  get_summary_stats(pos_prop, show = c("mean", "sd","min","max")) %>% 
  select(-variable) %>% flextable() %>% autofit()

Position summary statistics

session

pos

n

mean

sd

min

max

1

Supine

10

20.955

14.312

8.322

56.079

2

Supine

6

11.692

8.366

3.956

26.262

3

Supine

1

1.922

1.922

1.922

1

Prone

10

21.892

15.089

2.168

53.195

2

Prone

6

10.231

4.244

3.257

15.002

3

Prone

1

10.127

10.127

10.127

1

Sitting

10

34.727

13.985

12.819

53.703

2

Sitting

6

43.629

10.534

32.400

60.394

3

Sitting

1

44.118

44.118

44.118

1

Standing

10

11.754

8.956

3.644

33.114

2

Standing

6

22.278

6.338

14.710

31.995

3

Standing

1

27.855

27.855

27.855

1

Held

10

10.672

4.112

3.704

18.293

2

Held

6

12.170

5.641

3.105

19.508

3

Held

1

15.978

15.978

15.978

Code
ggplot(ds_sum, aes(x = session, y = pos_prop, color = pos)) + 
  stat_summary(position = position_dodge(.1)) + 
  stat_summary(geom = "line", position = position_dodge(.1)) + 
  ylim(0,101) + ylab("% of time") + xlab("Session") +
  scale_x_continuous(breaks = 1:3, labels = c("7 mo","9 mo","11 mo"), limits = c(0.5,3.5)) + 
  scale_color_manual(values = pal, name ="") + 
  theme(legend.position = "bottom")
ggplot(ds_sum, aes(x = session, y = pos_prop, fill = pos)) + 
  stat_summary(geom = "bar", position = "stack") + 
  ylim(0,101) + ylab("% of time") + xlab("Session") +
  scale_x_continuous(breaks = 1:3, labels = c("7 mo","9 mo","11 mo"), limits = c(0.5,3.5)) + 
  scale_fill_manual(values = pal, name ="") + 
  theme(legend.position = "bottom")

Position means and SE

Position means and SE

Position distribution

Position distribution

Infant Position Frequency by Age (Individual)

Code
ggplot(ds_sum, aes(x = session, y = pos_prop, color = pos, group = id)) + 
  facet_wrap(~ pos) + 
  geom_point() + geom_line() +  
  ylim(0,100) + ylab("% of time") + xlab("Session") +
  scale_x_continuous(breaks = 1:3, labels = c("7 mo","9 mo","11 mo"), limits = c(0.5,3.5)) + 
  scale_color_manual(values = pal, name ="") + 
  theme(legend.position = "none")