-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path03_share.Rmd
More file actions
397 lines (339 loc) · 13.2 KB
/
Copy path03_share.Rmd
File metadata and controls
397 lines (339 loc) · 13.2 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
---
title: "Bellabeat Case Study — Visualizations"
author: "AHMAD DANIEL"
date: "2026-05-14"
output: html_document
---
---
title: "Bellabeat Case Study — Visualizations"
author: "Ahmad Daniel"
date: "`r Sys.Date()`"
output:
html_document:
theme: flatly
toc: true
toc_float: true
---
# Phase 5: Share
**Phase:** Share (Phase 5 of 6)
## Purpose
This notebook turns the findings from Phase 4 into seven polished
visualizations. Each chart's title states an insight, not just a
description, so the story is immediately legible to non-technical
stakeholders.
## Setup
```{r setup, message=FALSE, warning=FALSE}
library(tidyverse)
library(lubridate)
library(scales)
# Load clean datasets
daily_activity <- read_csv("../data/clean/daily_activity_clean.csv")
sleep_day <- read_csv("../data/clean/sleep_day_clean.csv")
hourly_steps <- read_csv("../data/clean/hourly_steps_clean.csv")
user_activity_summary <- read_csv("../data/clean/user_activity_summary.csv")
usage_frequency <- read_csv("../data/clean/usage_frequency.csv")
# Re-apply factor levels
daily_activity$day_of_week <- factor(
daily_activity$day_of_week,
levels = c("Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday", "Sunday")
)
user_activity_summary$user_type <- factor(
user_activity_summary$user_type,
levels = c("Sedentary", "Lightly Active", "Fairly Active", "Very Active")
)
```
## Bellabeat-inspired color palette
```{r palette}
# Soft, feminine wellness-brand colors
bellabeat_palette <- c(
primary = "#A8576E", # dusty rose (primary brand color)
secondary = "#D9A6A0", # blush
accent = "#6E8898", # muted teal
highlight = "#E8B4B8", # soft pink (for emphasis)
neutral = "#F4E8E1", # warm cream
dark = "#3D3838" # charcoal (text)
)
# Custom theme for visual consistency
theme_bellabeat <- function() {
theme_minimal(base_size = 12) +
theme(
plot.title = element_text(face = "bold", size = 14, color = "#3D3838",
margin = margin(b = 8)),
plot.subtitle = element_text(size = 11, color = "#6E6E6E",
margin = margin(b = 12)),
plot.caption = element_text(size = 9, color = "#9E9E9E", hjust = 0,
margin = margin(t = 12)),
axis.title = element_text(size = 11, color = "#3D3838"),
axis.text = element_text(color = "#3D3838"),
panel.grid.minor = element_blank(),
panel.grid.major = element_line(color = "#EFEFEF"),
legend.position = "top",
legend.title = element_text(size = 10),
plot.margin = margin(20, 20, 20, 20)
)
}
```
---
## Chart 1: User segments — the majority is building habits, not chasing PRs
```{r chart-1-segments, fig.width=8, fig.height=5}
p1 <- user_activity_summary %>%
count(user_type) %>%
mutate(pct = round(n / sum(n) * 100, 1)) %>%
ggplot(aes(x = user_type, y = n, fill = user_type)) +
geom_col(width = 0.7) +
geom_text(aes(label = paste0(n, " users\n(", pct, "%)")),
vjust = -0.3, size = 4, color = "#3D3838") +
scale_fill_manual(values = c(
"Sedentary" = "#A8576E",
"Lightly Active" = "#D9A6A0",
"Fairly Active" = "#6E8898",
"Very Active" = "#E8B4B8"
)) +
scale_y_continuous(limits = c(0, 12), expand = c(0, 0)) +
labs(
title = "51% of users are Sedentary or Lightly Active",
subtitle = "User type by average daily steps (n = 33)",
caption = "Source: FitBit Fitness Tracker Data (Mobius, 2016)",
x = NULL,
y = "Number of Users"
) +
theme_bellabeat() +
theme(legend.position = "none")
p1
ggsave("../visualizations/01_user_segments.png", p1,
width = 8, height = 5, dpi = 300)
```
**The story:** The Bellabeat customer is most likely a habit-builder,
not a fitness elite. Marketing should reflect that reality.
---
## Chart 2: Sunday is the laziest day — 15% fewer steps than Saturday
```{r chart-2-day-of-week, fig.width=8, fig.height=5}
day_summary <- daily_activity %>%
group_by(day_of_week) %>%
summarise(avg_steps = round(mean(total_steps), 0))
p2 <- day_summary %>%
ggplot(aes(x = day_of_week, y = avg_steps,
fill = day_of_week == "Sunday")) +
geom_col(width = 0.7) +
geom_text(aes(label = comma(avg_steps)),
vjust = -0.5, size = 3.8, color = "#3D3838") +
geom_hline(yintercept = 10000, linetype = "dashed",
color = "#9E9E9E", size = 0.5) +
annotate("text", x = 1, y = 10300, label = "10K step target",
color = "#9E9E9E", size = 3.2, hjust = 0) +
scale_fill_manual(values = c("FALSE" = "#D9A6A0", "TRUE" = "#A8576E")) +
scale_y_continuous(labels = comma, limits = c(0, 11000),
expand = c(0, 0)) +
labs(
title = "Sunday is the laziest day — 15% fewer steps than Saturday",
subtitle = "Average daily steps by day of week",
caption = "Source: FitBit Fitness Tracker Data (Mobius, 2016)",
x = NULL,
y = "Average Daily Steps"
) +
theme_bellabeat() +
theme(legend.position = "none")
p2
ggsave("../visualizations/02_day_of_week.png", p2,
width = 8, height = 5, dpi = 300)
```
**The story:** Sunday's drop is a marketing opportunity. A Sunday
motivation campaign would address the largest weekly behavior gap.
---
## Chart 3: Steps drive calories — but intensity matters too (r = 0.59)
```{r chart-3-scatter, fig.width=8, fig.height=5}
p3 <- daily_activity %>%
filter(total_steps > 0) %>% # remove non-wear days
ggplot(aes(x = total_steps, y = calories)) +
geom_point(alpha = 0.4, color = "#A8576E", size = 2) +
geom_smooth(method = "lm", color = "#3D3838",
fill = "#E8B4B8", se = TRUE) +
scale_x_continuous(labels = comma) +
scale_y_continuous(labels = comma) +
annotate("text", x = 22000, y = 1500,
label = "r = 0.59\n(moderate-to-strong)",
color = "#3D3838", size = 4, hjust = 1, fontface = "italic") +
labs(
title = "More steps mean more calories — but only partially",
subtitle = "Steps explain ~35% of calorie burn variance; intensity drives the rest",
caption = "Source: FitBit Fitness Tracker Data (Mobius, 2016) | n = 863 days",
x = "Total Daily Steps",
y = "Calories Burned"
) +
theme_bellabeat()
p3
ggsave("../visualizations/03_steps_vs_calories.png", p3,
width = 8, height = 5, dpi = 300)
```
**The story:** Step count alone doesn't tell the whole calorie story.
Bellabeat should promote intensity-based metrics — active minutes,
heart rate zones — not just step counts.
---
## Chart 4: Activity peaks at 6 PM — the post-work commute window
```{r chart-4-hourly, fig.width=9, fig.height=5}
hourly_summary <- hourly_steps %>%
group_by(hour) %>%
summarise(avg_steps = round(mean(step_total), 0))
p4 <- hourly_summary %>%
ggplot(aes(x = hour, y = avg_steps,
fill = avg_steps >= 500)) +
geom_col(width = 0.8) +
geom_text(aes(label = avg_steps),
vjust = -0.5, size = 3, color = "#3D3838") +
scale_fill_manual(values = c("FALSE" = "#D9A6A0", "TRUE" = "#A8576E")) +
scale_x_continuous(breaks = 0:23,
labels = c("12a", paste0(1:11, "a"), "12p",
paste0(1:11, "p"))) +
scale_y_continuous(limits = c(0, 700), expand = c(0, 0)) +
labs(
title = "Activity peaks at 6 PM — the post-work window is gold",
subtitle = "Average steps by hour of day; secondary peak at lunch (12-2 PM)",
caption = "Source: FitBit Fitness Tracker Data (Mobius, 2016)",
x = "Hour of Day",
y = "Average Steps"
) +
theme_bellabeat() +
theme(legend.position = "none",
axis.text.x = element_text(size = 9))
p4
ggsave("../visualizations/04_hourly_pattern.png", p4,
width = 9, height = 5, dpi = 300)
```
**The story:** Notification timing should target 11 AM and 4-5 PM —
right before users' natural activity peaks. Reminders after 8 PM are
wasted on a low-activity audience.
---
## Chart 5: Users spend 39 minutes a night in bed but not asleep
```{r chart-5-sleep, fig.width=8, fig.height=5}
sleep_long <- tibble(
metric = c("Time Asleep", "Restless (in bed, not asleep)"),
minutes = c(419, 39)
) %>%
mutate(metric = factor(metric,
levels = c("Restless (in bed, not asleep)",
"Time Asleep")))
p5 <- sleep_long %>%
ggplot(aes(x = "", y = minutes, fill = metric)) +
geom_col(width = 0.4) +
geom_text(aes(label = paste0(minutes, " min")),
position = position_stack(vjust = 0.5),
color = "white", size = 5, fontface = "bold") +
coord_flip() +
scale_fill_manual(values = c(
"Time Asleep" = "#6E8898",
"Restless (in bed, not asleep)" = "#A8576E"
)) +
labs(
title = "Users spend 39 minutes a night in bed but not asleep",
subtitle = "Average time asleep (419 min) vs. total time in bed (458 min)",
caption = "Source: FitBit Fitness Tracker Data (Mobius, 2016) | n = 24 users",
x = NULL,
y = "Minutes per Night",
fill = NULL
) +
theme_bellabeat() +
theme(legend.position = "top",
axis.text.y = element_blank())
p5
ggsave("../visualizations/05_sleep_gap.png", p5,
width = 8, height = 5, dpi = 300)
```
**The story:** 39 minutes nightly = 4.7 hours weekly of restless time
in bed. Mindfulness features have a quantifiable problem to solve.
---
## Chart 6: The average day is 16.5 hours sedentary — even subtracting sleep, that's 9.5 hours awake and still
```{r chart-6-time-breakdown, fig.width=9, fig.height=5}
time_breakdown <- tibble(
category = c("Sedentary", "Lightly Active",
"Fairly Active", "Very Active"),
hours = c(16.5, 3.2, 0.23, 0.36)
) %>%
mutate(category = factor(category,
levels = c("Very Active", "Fairly Active",
"Lightly Active", "Sedentary")),
pct = round(hours / sum(hours) * 100, 1))
p6 <- time_breakdown %>%
ggplot(aes(x = "", y = hours, fill = category)) +
geom_col(width = 0.5) +
geom_text(aes(label = ifelse(hours > 1,
paste0(hours, " hrs (", pct, "%)"),
"")),
position = position_stack(vjust = 0.5),
color = "white", size = 4.5, fontface = "bold") +
coord_flip() +
scale_fill_manual(values = c(
"Sedentary" = "#A8576E",
"Lightly Active" = "#D9A6A0",
"Fairly Active" = "#6E8898",
"Very Active" = "#3D3838"
)) +
labs(
title = "16.5 hours of every tracked day is sedentary",
subtitle = "Only ~35 minutes is spent in fairly or very active states",
caption = "Source: FitBit Fitness Tracker Data (Mobius, 2016)",
x = NULL,
y = "Hours per Day",
fill = NULL
) +
theme_bellabeat() +
theme(legend.position = "top",
axis.text.y = element_blank())
p6
ggsave("../visualizations/06_time_breakdown.png", p6,
width = 9, height = 5, dpi = 300)
```
**The story:** The biggest behavioral opportunity isn't more workouts
— it's reducing prolonged sedentary periods. Hourly stand reminders
address the largest gap in the data.
---
## Chart 7: 88% of users tracked for 21+ days — churn isn't the problem
```{r chart-7-engagement, fig.width=8, fig.height=5}
engagement <- usage_frequency %>%
count(usage_category) %>%
mutate(pct = round(n / sum(n) * 100, 1),
usage_category = factor(usage_category,
levels = c("Low use (1-10 days)",
"Moderate use (11-20 days)",
"High use (21-31 days)")))
p7 <- engagement %>%
ggplot(aes(x = usage_category, y = n, fill = usage_category)) +
geom_col(width = 0.6) +
geom_text(aes(label = paste0(n, " users (", pct, "%)")),
vjust = -0.4, size = 4, color = "#3D3838") +
scale_fill_manual(values = c(
"Low use (1-10 days)" = "#D9A6A0",
"Moderate use (11-20 days)" = "#6E8898",
"High use (21-31 days)" = "#A8576E"
)) +
scale_y_continuous(limits = c(0, 33), expand = c(0, 0)) +
labs(
title = "88% of users tracked for 21+ days — the problem isn't churn",
subtitle = "Once users adopt the device, they stick. Focus shifts to acquisition and depth.",
caption = "Source: FitBit Fitness Tracker Data (Mobius, 2016) | n = 33 users",
x = NULL,
y = "Number of Users"
) +
theme_bellabeat() +
theme(legend.position = "none")
p7
ggsave("../visualizations/07_engagement.png", p7,
width = 8, height = 5, dpi = 300)
```
**The story:** This contradicts the common smart device narrative.
Bellabeat's marketing dollars should prioritize **acquisition** and
**deepening engagement** — not retention.
---
## Summary
| # | Visualization | Headline Insight |
|---|---------------|------------------|
| 1 | User segments | 51% of users are in lower-activity tiers |
| 2 | Day of week | Sunday is the laziest day |
| 3 | Steps vs calories | Moderate correlation (r = 0.59) — intensity matters |
| 4 | Hourly pattern | 6 PM is the peak hour |
| 5 | Sleep gap | 39 restless minutes nightly |
| 6 | Time breakdown | 16.5 sedentary hours per day |
| 7 | Engagement | 88% tracked 21+ days — high commitment |
All charts exported to `visualizations/` at 300 DPI for high-quality
display on GitHub and in presentations.
Proceed to **Phase 6: Act** in `docs/06_act.md` for recommendations.