Data on Blood Pressure Measurements

Loading the necessary packages and getting the data:

setwd("C:/Users/uroy/Dropbox/personal")
library(tidyverse)
library(readxl)
library(lubridate)
library(plotly)
bp <- read_xlsx(
  path = "C:/Users/uroy/Dropbox/personal/blood-pressure/blood-pressure-Omron.xlsx",
  range = "A1:D300",
  col_names = TRUE
) 

Are the systolic and diastolic measures of my blood pressure correlated?

p1 <- ggplot(bp) +
  geom_point(aes(Sys, Dia), alpha = 0.5)
ggplotly(p1)

They certainly are. The correlation coefficient is 0.82.

How has my blood pressure varied over time?

p2 <- ggplot(bp, aes(x = Date)) +
  geom_line(aes(y = Sys, colour = "Sys")) +
  geom_line(aes(y = Dia, colour = "Dia")) +
  labs(x = NULL, y = NULL)
ggplotly(p2)

Another way to get the same chart we just saw

bp_long <- bp %>%
  pivot_longer(c("Sys", "Dia"), names_to = "Measure", values_to = "Amount")
p3 <- ggplot(bp_long, aes(x = Date, y = Amount, colour = Measure)) +
  geom_line() +
  labs(x = NULL, y = NULL)
ggplotly(p3)

Does my blood pressure depend on the day of the week? Not really.

p4 <- group_by(bp_long, day = wday(Date, label = TRUE), Measure) %>% 
  summarise(mean = mean(Amount, na.rm = TRUE)) %>%
  ggplot(aes(x=day, y=mean, fill = Measure)) +
  geom_bar(stat="identity", position = "dodge")
ggplotly(p4)

R Techniques Used

The End