Mark checked blood pressure and it was high, then went to the doctor for a checkup.
library("kableExtra")
library("dplyr")
library("beeswarm")
Load the data.
x <- read.csv("measurements.csv")
x %>% kbl(caption="Home bp measurement") %>% kable_paper("hover", full_width = F)
date | arm | systolic | diastolic | hr |
---|---|---|---|---|
20230606 | L | 148 | 107 | 76 |
20230606 | L | 162 | 107 | 75 |
20230606 | L | 159 | 102 | 71 |
20230606 | R | 173 | 106 | 76 |
20230606 | R | 161 | 107 | 70 |
20230606 | R | 160 | 103 | 79 |
20230611 | L | 145 | 92 | 73 |
20230611 | L | 123 | 97 | 76 |
20230611 | L | 143 | 86 | 70 |
20230611 | R | 151 | 92 | 72 |
20230611 | R | 139 | 92 | 68 |
20230611 | R | 129 | 92 | 70 |
Subset baseline and day 3 values.
#baseline
bl <- subset(x,date==20230606)
#day3
d3 <- subset(x,date==20230611)
bl_s <- bl$systolic
bl_d <- bl$diastolic
bl_hr <- bl$hr
d3_s <- d3$systolic
d3_d <- d3$diastolic
d3_hr <- d3$hr
Run a t-test for systolic (top number).
t.test(bl_s,d3_s)
##
## Welch Two Sample t-test
##
## data: bl_s and d3_s
## t = 4.1238, df = 9.3325, p-value = 0.002391
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 10.07248 34.26085
## sample estimates:
## mean of x mean of y
## 160.5000 138.3333
ls <- list("baseline"=bl_s,"day3"=d3_s)
boxplot(ls,main="Systolic",cex=0)
beeswarm(ls,add=TRUE,pch=19,cex=1)
Run a t-test for diastolic (lower number).
t.test(bl_d,d3_d)
##
## Welch Two Sample t-test
##
## data: bl_d and d3_d
## t = 7.9657, df = 8.5489, p-value = 3.088e-05
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 9.635121 17.364879
## sample estimates:
## mean of x mean of y
## 105.33333 91.83333
l3 <- list("baseline"=bl_d,"day3"=d3_d)
boxplot(l3,main="Diastolic",cex=0)
beeswarm(l3,add=TRUE,pch=19,cex=1)
Run a t-test for pulse/heart rate.
t.test(bl_hr,d3_hr)
##
## Welch Two Sample t-test
##
## data: bl_hr and d3_hr
## t = 1.6684, df = 9.6671, p-value = 0.1273
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -1.025302 7.025302
## sample estimates:
## mean of x mean of y
## 74.5 71.5
lhr <- list("baseline"=bl_hr,"day3"=d3_hr)
boxplot(lhr,main="Heart rate",cex=0)
beeswarm(lhr,add=TRUE,pch=19,cex=1)
Systolic and diastolic are lower after 3 days of meds. Heart rate is slightly lower.
sessionInfo()
## R version 4.3.0 (2023-04-21)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 22.04.2 LTS
##
## Matrix products: default
## BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
##
## locale:
## [1] LC_CTYPE=en_AU.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_AU.UTF-8 LC_COLLATE=en_AU.UTF-8
## [5] LC_MONETARY=en_AU.UTF-8 LC_MESSAGES=en_AU.UTF-8
## [7] LC_PAPER=en_AU.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C
##
## time zone: Australia/Melbourne
## tzcode source: system (glibc)
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] dplyr_1.1.2 kableExtra_1.3.4 beeswarm_0.4.0
##
## loaded via a namespace (and not attached):
## [1] jsonlite_1.8.4 compiler_4.3.0 highr_0.10 webshot_0.5.4
## [5] tidyselect_1.2.0 xml2_1.3.4 stringr_1.5.0 jquerylib_0.1.4
## [9] systemfonts_1.0.4 scales_1.2.1 yaml_2.3.7 fastmap_1.1.1
## [13] R6_2.5.1 generics_0.1.3 knitr_1.42 tibble_3.2.1
## [17] munsell_0.5.0 svglite_2.1.1 bslib_0.4.2 pillar_1.9.0
## [21] rlang_1.1.1 utf8_1.2.3 cachem_1.0.7 stringi_1.7.12
## [25] xfun_0.39 sass_0.4.5 viridisLite_0.4.1 cli_3.6.1
## [29] magrittr_2.0.3 digest_0.6.31 rvest_1.0.3 rstudioapi_0.14
## [33] lifecycle_1.0.3 vctrs_0.6.2 evaluate_0.20 glue_1.6.2
## [37] fansi_1.0.4 colorspace_2.1-0 rmarkdown_2.21 httr_1.4.5
## [41] tools_4.3.0 pkgconfig_2.0.3 htmltools_0.5.5