Studying the relationship between Intensity and
Time.
int_new <- intensities %>%
group_by(time) %>%
drop_na() %>%
summarise(mean_total_int = mean(TotalIntensity))
ggplot(data=int_new, aes(x=time, y=mean_total_int)) + geom_histogram(stat = "identity", fill='darkblue') +
theme(axis.text.x = element_text(angle = 90)) +
labs(title="Average Total Intensity vs. Time")
## Warning in geom_histogram(stat = "identity", fill = "darkblue"): Ignoring
## unknown parameters: `binwidth`, `bins`, and `pad`
- From the graph, we can conclude that people are more active between
5 am and 10 pm.
- Most activity happens between 5 pm and 7 pm. During this window,
Bellabeat app can remind and motivate user to go for a run or walk.
Visualize Minutes Asleep vs. Sedentary Minutes
ggplot(data=combined_sleep_activity, aes(x=TotalMinutesAsleep, y=SedentaryMinutes)) +
geom_point(color='darkblue') + geom_smooth() +
labs(title="Minutes Asleep vs. Sedentary Minutes")
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
- From the graph, we can conclude that there exists a negative
relationship between Minutes Asleep and Sedentary Minutes.
- To improve our customers’ sleep, Bellabeat app can recommend
reducing sedentary time.
- To further analyse the situation, we need more data.
Merging Steps data and Calories data
combined_steps_calories <- merge(steps, calories, by = c("Id", "ActivityHour"))
glimpse(combined_steps_calories)
## Rows: 22,099
## Columns: 8
## $ Id <dbl> 1503960366, 1503960366, 1503960366, 1503960366, 150396036…
## $ ActivityHour <dttm> 2016-04-12 00:00:00, 2016-04-12 01:00:00, 2016-04-12 02:…
## $ StepTotal <int> 373, 160, 151, 0, 0, 0, 0, 0, 250, 1864, 676, 360, 253, 2…
## $ time.x <chr> "00:00:00", "01:00:00", "02:00:00", "03:00:00", "04:00:00…
## $ date.x <chr> "04/12/16", "04/12/16", "04/12/16", "04/12/16", "04/12/16…
## $ Calories <int> 81, 61, 59, 47, 48, 48, 48, 47, 68, 141, 99, 76, 73, 66, …
## $ time.y <chr> "00:00:00", "01:00:00", "02:00:00", "03:00:00", "04:00:00…
## $ date.y <chr> "04/12/16", "04/12/16", "04/12/16", "04/12/16", "04/12/16…