Skip to content

Instantly share code, notes, and snippets.

@akshat3096
Last active May 3, 2019 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akshat3096/c00403ccbb73033bafbed6792cc12c97 to your computer and use it in GitHub Desktop.
Save akshat3096/c00403ccbb73033bafbed6792cc12c97 to your computer and use it in GitHub Desktop.
# 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