Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# calendar heatmap: year wise calories burned
f <- df %>%
filter(type == 'HKQuantityTypeIdentifierActiveEnergyBurned') %>%
filter(year==2018) %>%
mutate(week_date = ceiling(day(creationDate) / 7)) %>%
group_by(week_date, month, dayofweek) %>%
summarise(total_cal = sum(value))
p <- ggplot(f,
aes(dayofweek, week_date, fill = f$total_cal)) +
geom_tile(colour = "white") +
facet_wrap(~month) +
theme_bw() +
scale_fill_gradient(name = "Total \nCalories",
low ="#56B1F7" , high = "#132B43") +
labs(x = "Week of the Month",
y = "Week number") +
scale_y_continuous(trans = "reverse")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.