This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
Step 1: Importation of BP and Survey Datasets, adding libraries for further use.
setwd("C:/Users/Hiroshi/Desktop/BPProject")
library(data.table)
## Warning: package 'data.table' was built under R version 3.5.3
library(dplyr)
## Warning: package 'dplyr' was built under R version 3.5.3
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:data.table':
##
## between, first, last
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(dtplyr)
## Warning: package 'dtplyr' was built under R version 3.5.3
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.5.3
library(reshape2)
##
## Attaching package: 'reshape2'
## The following objects are masked from 'package:data.table':
##
## dcast, melt
library(tidyr)
## Warning: package 'tidyr' was built under R version 3.5.3
##
## Attaching package: 'tidyr'
## The following object is masked from 'package:reshape2':
##
## smiths
library(ggthemes)
## Warning: package 'ggthemes' was built under R version 3.5.3
library(RColorBrewer)
## Warning: package 'RColorBrewer' was built under R version 3.5.2
bp_dataset <- tbl_dt(fread('BP1.csv'))
fp_survey <- tbl_dt(fread('FP.csv'))
Step 2: Initial formatting pass. Formatted all “Date” fields as a date. Formatted Categorical Values as factors.
#Step 2A Format Date Variables to be as Date
dater <- function(x) {
x <- as.Date(x, format = "%m/%d/%Y")
return(x)
}
dater(bp_dataset$Start_Date)
## [1] "2018-11-09" "2018-09-27" "2018-09-27" "2018-09-27" "2018-09-27"
## [6] "2018-09-28" "2018-10-26" "2018-10-12" "2018-09-28" "2018-09-28"
## [11] "2018-09-28" "2018-10-19" "2018-09-28" "2018-09-28" "2018-09-28"
## [16] "2018-10-19" "2018-10-19" "2018-10-12" "2018-09-28" "2018-10-26"
## [21] "2018-10-26" "2018-10-26" "2018-11-02" "2018-11-09" "2018-11-09"
## [26] "2018-11-16" "2018-12-07" "2018-08-02" "2018-07-19" "2018-01-11"
## [31] "2018-07-19" "2018-07-19" "2018-02-01" "2017-10-19" "2018-06-21"
## [36] "2017-09-21" "2019-08-16" "2018-07-19" "2017-09-21" "2018-08-16"
## [41] "2017-09-28" "2017-09-07" "2017-09-21" "2018-04-05" "2018-08-02"
## [46] "2018-11-01" "2017-09-27" "2018-08-30" "2017-10-19" "2018-02-01"
## [51] "2018-01-11" "2018-01-18" "2017-09-07" "2018-02-15" "2017-09-28"
## [56] "2017-09-07" "2017-09-14" "2017-09-07" "2018-09-20" "2018-09-20"
## [61] "2018-11-01" "2018-11-08" "2018-09-13" "2018-09-20" "2018-11-08"
## [66] "2018-10-04" "2018-09-13" "2018-09-20" "2018-11-01" "2018-10-25"
## [71] "2018-10-11" "2018-11-01" "2018-10-25" "2018-10-11" "2018-09-27"
## [76] "2018-10-11" "2018-10-11" "2018-09-27" "2018-09-27" "2018-09-20"
## [81] "2018-10-11" "2018-10-04" "2018-09-20" "2018-10-18" "2018-10-25"
## [86] "2018-10-04" "2017-08-09" "2017-07-05" "2017-07-05" "2017-07-19"
## [91] "2017-07-19" "2017-07-12" "2017-07-19" "2017-07-27" "2017-07-12"
## [96] "2017-07-05" "2017-07-05" "2017-07-12" "2017-07-12" "2017-08-02"
## [101] "2017-07-12" "2017-07-05" "2017-07-05" "2017-07-05" "2017-08-02"
## [106] "2017-07-05" "2017-08-16" "2017-07-19" "2017-07-19" "2017-07-26"
## [111] "2017-07-26" "2017-08-09" "2017-08-16" "2017-08-23" "2017-09-20"
## [116] "2017-09-20" "2017-09-27" "2017-09-27" "2017-11-01" "2017-11-29"
## [121] "2017-11-29" "2017-12-06" "2017-12-06" "2017-12-06" "2017-12-20"
## [126] "2017-12-20" "2017-12-20" "2018-01-03" "2018-01-03" "2018-01-03"
## [131] "2018-01-10" "2018-01-10" "2018-01-24" "2018-02-07" "2018-02-14"
## [136] "2018-02-14" "2018-02-28" "2018-03-17" "2018-03-21" "2018-04-18"
## [141] "2018-04-25" "2018-04-25" "2018-05-16" "2018-07-18" "2018-08-01"
## [146] "2018-08-08" "2018-08-29" "2018-08-29" "2018-09-19" "2018-09-26"
## [151] "2018-09-26" "2018-10-24" "2018-11-21"
dater(bp_dataset$End_Date)
## [1] "2018-12-14" "2018-12-07" "2018-11-09" "2019-01-25" "2019-01-25"
## [6] "2018-11-02" "2018-12-21" "2018-12-21" "2018-12-21" "2019-01-25"
## [11] "2018-12-21" "2019-01-25" "2019-01-25" "2019-01-25" "2018-12-14"
## [16] "2018-12-14" "2018-11-16" "2018-12-14" "2018-12-14" "2018-11-30"
## [21] "2019-01-25" "2018-12-21" "2018-12-07" "2018-12-14" "2018-12-21"
## [26] "2019-01-25" "2019-01-25" "2018-12-20" "2018-12-20" "2019-01-03"
## [31] "2019-01-31" "2018-12-06" "2019-01-03" "2018-09-06" "2019-01-31"
## [36] "2018-11-29" "2019-01-31" "2018-12-20" "2019-01-31" "2019-01-31"
## [41] "2018-11-15" "2019-01-03" "2019-01-31" "2019-01-31" "2018-11-15"
## [46] "2019-01-03" "2019-01-31" "2018-12-06" "2019-01-31" "2019-01-31"
## [51] "2018-02-15" "2018-04-05" "2018-01-18" "2018-04-19" "2018-05-17"
## [56] "2018-02-01" "2018-04-19" "2019-01-31" "2019-01-29" "2018-11-29"
## [61] "2018-12-06" "2018-11-29" "2018-11-29" "2018-12-06" "2018-12-06"
## [66] "2018-10-18" "2018-11-15" "2018-11-15" "2018-11-15" "2018-11-29"
## [71] "2018-12-06" "2018-12-06" "2018-12-06" "2019-01-29" "2019-01-29"
## [76] "2018-11-15" "2018-12-06" "2018-12-06" "2019-01-29" "2019-01-29"
## [81] "2018-11-01" "2019-01-29" "2018-12-06" "2018-11-15" "2018-12-06"
## [86] "2018-12-06" "2019-01-09" "2017-12-20" "2017-08-30" "2019-01-23"
## [91] "2018-12-19" "2017-08-30" "2018-03-07" "2018-11-28" "2018-12-19"
## [96] "2018-06-13" "2018-02-21" "2019-01-30" "2017-09-27" "2018-12-19"
## [101] "2019-01-30" "2018-11-21" "2018-10-31" "2019-01-30" "2017-10-04"
## [106] "2018-02-21" "2018-10-17" "2019-01-30" "2019-01-30" "2017-09-20"
## [111] "2019-01-30" "2019-01-23" "2017-11-22" "2017-11-22" "2017-11-22"
## [116] "2018-05-30" "2019-01-23" "2018-02-28" "2018-11-28" "2018-08-22"
## [121] "2018-03-14" "2019-01-23" "2018-06-13" "2019-01-23" "2018-11-14"
## [126] "2018-06-27" "2018-06-27" "2019-01-30" "2018-03-28" "2018-12-12"
## [131] "2018-02-21" "2018-02-07" "2018-08-08" "2019-01-30" "2018-03-21"
## [136] "2018-12-19" "2019-01-15" "2018-10-31" "2019-01-30" "2019-01-23"
## [141] "2018-12-26" "2018-06-27" "2018-07-11" "2018-12-12" "2018-11-28"
## [146] "2018-11-07" "2019-01-30" "2018-11-07" "2019-01-30" "2019-01-30"
## [151] "2018-10-31" "2018-12-12" "2018-12-26"
dater(bp_dataset$Before_Date1)
## [1] "2019-08-09" "2018-06-29" "2018-06-21" "2018-02-15" "2017-05-19"
## [6] "2018-08-24" "2018-07-10" "2018-08-21" "2018-07-13" "2018-09-07"
## [11] "2018-07-17" "2018-08-07" NA "2018-08-29" "2018-05-11"
## [16] "2018-08-17" "2018-10-18" "2018-09-05" "2018-09-26" "2018-10-15"
## [21] "2018-08-21" "2018-10-05" "2018-10-19" "2018-10-05" NA
## [26] "2018-10-16" NA "2018-07-25" "2018-05-24" "2017-10-18"
## [31] "2018-06-26" "2018-07-18" "2018-01-29" "2017-08-24" "2018-06-11"
## [36] "2017-09-19" "2018-01-24" "2018-06-19" "2017-08-31" "2018-09-12"
## [41] "2017-09-26" "2017-08-25" "2017-09-13" "2018-03-07" "2018-08-01"
## [46] "2018-11-01" "2017-08-28" "2018-08-10" "2017-08-10" "2018-01-22"
## [51] "2017-12-15" "2017-09-14" "2017-07-05" "2018-01-31" "2016-10-02"
## [56] "2017-09-01" "2017-08-29" "2017-08-28" "2018-09-19" "2018-09-19"
## [61] "2018-10-15" "2018-11-06" "2018-09-04" "2018-09-13" "2018-09-18"
## [66] "2018-09-20" "2018-09-10" "2018-08-06" NA "2018-08-28"
## [71] "2018-06-05" "2018-10-15" "2018-10-16" "2018-10-10" "2018-09-13"
## [76] "2018-10-09" "2018-10-05" "2018-08-23" "2018-09-14" "2018-09-18"
## [81] "2018-09-24" "2018-09-19" "2018-09-06" "2018-10-10" "2018-10-15"
## [86] "2018-10-02" "2017-07-28" "2017-06-19" "2016-10-24" "2017-07-11"
## [91] "2017-06-21" "2017-06-26" "2017-05-11" "2017-04-27" "2017-04-11"
## [96] "2017-06-19" "2017-06-27" "2017-07-21" "2017-07-12" "2017-02-13"
## [101] "2017-06-29" "2017-05-24" "2017-06-29" "2017-05-02" "2017-05-01"
## [106] "2017-06-06" "2017-06-16" "2017-07-17" "2017-06-23" "2017-07-17"
## [111] "2017-07-17" "2017-03-07" "2017-08-14" "2017-07-18" "2017-09-12"
## [116] "2017-04-06" "2017-09-19" "2017-06-02" NA "2017-10-02"
## [121] "2017-11-28" "2017-02-01" "2017-12-01" "2017-02-03" "2017-12-08"
## [126] "2017-11-03" "2017-12-18" "2017-12-19" "2018-12-15" "2017-12-27"
## [131] "2018-01-05" "2017-12-29" "2018-01-24" "2017-11-27" "2017-08-04"
## [136] "2017-01-25" "2017-05-26" "2017-03-01" "2018-03-16" "2018-04-12"
## [141] "2017-12-01" "2018-04-12" NA "2018-02-09" "2018-07-13"
## [146] "2018-06-20" "2018-08-13" "2018-08-03" "2018-09-17" "2018-08-09"
## [151] "2018-09-18" "2018-10-15" "2018-11-20"
dater(bp_dataset$Before_Date2)
## [1] "2019-09-27" "2018-08-09" "2018-08-15" "2018-06-12" NA
## [6] "2018-07-20" "2018-05-29" "2018-07-11" "2018-08-31" "2018-06-14"
## [11] "2018-06-05" "2018-04-03" NA "2018-07-11" "2018-10-26"
## [16] "2018-07-23" "2018-08-30" "2018-06-27" "2018-08-15" "2018-08-16"
## [21] "2018-04-12" "2018-09-06" "2018-07-17" "2018-07-24" NA
## [26] "2018-08-24" NA "2018-01-23" "2018-03-30" "2017-09-22"
## [31] "2018-05-16" "2018-05-24" "2017-11-28" "2017-09-21" "2018-03-20"
## [36] "2017-07-17" "2017-11-10" "2018-05-24" "2017-05-15" "2018-06-12"
## [41] "2017-09-12" "2017-07-26" "2017-03-09" "2018-01-26" "2018-06-26"
## [46] "2018-05-07" "2017-05-22" "2018-05-18" "2017-06-01" "2017-11-16"
## [51] "2017-10-13" "2017-08-17" "2017-03-06" "2017-11-06" "2016-09-13"
## [56] "2017-06-29" "2017-07-25" "2017-05-22" "2018-08-24" "2018-08-16"
## [61] "2018-08-06" "2018-10-02" "2018-06-05" "2018-05-02" "2018-08-01"
## [66] "2018-08-22" "2018-08-07" "2018-06-05" NA "2018-07-07"
## [71] "2018-01-31" "2018-08-15" "2018-08-29" "2018-09-11" "2018-08-08"
## [76] "2018-07-13" "2018-08-31" "2018-07-17" "2018-07-20" "2018-08-14"
## [81] "2018-08-20" "2018-08-08" "2018-07-31" "2018-08-29" "2018-08-13"
## [86] "2018-08-27" "2017-06-29" "2017-04-24" "2016-08-09" "2017-03-21"
## [91] "2016-11-03" "2017-05-03" "2017-02-09" "2017-02-15" "2016-09-15"
## [96] "2016-12-12" "2017-05-23" "2017-06-05" "2017-05-22" "2017-01-05"
## [101] "2017-05-05" "2017-04-06" "2017-05-30" "2017-01-13" "2017-03-31"
## [106] "2017-01-17" "2017-04-18" "2017-06-19" "2017-06-07" "2017-06-05"
## [111] "2017-06-21" "2016-09-16" "2017-07-17" "2017-05-31" "2017-08-15"
## [116] "2016-12-22" "2017-07-25" "2016-08-25" NA "2017-08-22"
## [121] "2017-10-18" "2016-11-16" "2017-09-21" "2017-01-13" "2017-11-09"
## [126] "2017-06-21" "2017-07-26" "2017-10-16" "2017-11-06" "2017-11-17"
## [131] "2017-10-20" "2017-11-21" "2018-01-02" "2017-08-28" "2017-08-08"
## [136] "2017-10-19" "2017-03-17" "2018-02-22" "2018-01-05" "2017-12-31"
## [141] "2017-10-17" "2018-02-22" NA "2019-07-20" "2018-01-26"
## [146] "2018-05-24" "2018-05-14" NA "2018-08-17" NA
## [151] "2018-04-30" "2018-08-27" "2018-09-12"
dater(bp_dataset$Before_Date3)
## [1] "2019-11-09" "2018-09-11" "2018-09-21" "2018-09-04" NA
## [6] "2018-06-19" "2018-03-20" "2018-06-15" "2018-09-27" "2018-05-31"
## [11] "2018-05-07" "2018-02-02" NA "2018-06-06" "2017-08-01"
## [16] "2018-06-22" "2018-08-01" "2018-05-02" "2018-07-10" "2018-07-24"
## [21] "2018-02-02" "2018-08-02" "2018-06-12" "2018-06-20" NA
## [26] "2018-04-30" NA "2016-10-13" "2017-09-28" "2017-08-09"
## [31] "2018-01-31" "2018-04-26" "2017-10-30" "2016-12-15" "2017-09-19"
## [36] "2017-08-09" "2017-10-13" "2018-04-12" "2017-06-26" "2018-05-04"
## [41] "2017-04-05" "2017-06-08" "2017-07-06" "2017-09-28" "2018-05-30"
## [46] "2018-02-07" "2017-02-23" "2018-03-02" "2017-05-17" "2017-10-06"
## [51] "2017-11-03" "2017-06-26" "2016-12-12" "2017-10-18" "2015-08-31"
## [56] "2017-07-20" "2016-09-09" "2017-02-23" "2018-07-27" "2018-07-18"
## [61] "2018-05-25" "2018-08-30" "2018-04-07" "2018-01-04" "2018-06-11"
## [66] "2018-07-25" "2018-06-27" "2018-04-24" NA "2018-05-04"
## [71] "2017-11-29" "2018-07-25" "2018-06-08" "2018-07-25" "2018-07-11"
## [76] "2017-10-19" "2018-03-07" "2018-05-15" "2018-05-25" "2018-07-12"
## [81] "2018-06-05" "2018-06-27" "2018-06-07" "2018-06-20" "2018-06-22"
## [86] "2018-06-18" "2017-03-27" "2017-03-17" "2015-04-06" "2017-04-14"
## [91] "2016-09-28" "2017-04-11" "2016-12-27" "2016-10-13" "2015-12-18"
## [96] "2016-11-16" "2017-04-24" "2017-03-06" "2017-04-24" "2017-07-20"
## [101] "2017-03-23" "2016-06-24" "2017-02-08" "2016-09-23" "2017-07-20"
## [106] "2016-10-07" "2017-01-17" "2015-02-25" "2017-05-11" "2017-04-11"
## [111] "2017-05-02" "2015-10-02" "2017-05-13" "2017-03-29" "2017-07-19"
## [116] "2016-10-19" "2017-05-13" "2016-07-08" NA "2017-06-02"
## [121] "2017-10-16" "2017-04-11" "2016-04-22" "2017-01-05" "2017-10-05"
## [126] "2017-04-07" "2017-09-26" "2017-09-12" "2017-08-31" "2017-10-12"
## [131] "2017-11-13" "2017-10-17" "2017-11-15" "2017-10-02" "2018-02-08"
## [136] "2017-07-06" "2017-08-11" NA "2017-03-27" "2017-11-30"
## [141] "2017-08-15" "2018-01-16" NA "2017-06-21" "2016-08-24"
## [146] "2016-04-28" "2017-11-06" NA "2018-07-24" NA
## [151] "2017-11-02" "2018-07-23" "2017-12-15"
dater(bp_dataset$After_Date1)
## [1] "2018-12-17" "2019-01-02" "2019-11-21" "2019-02-06" "2019-01-29"
## [6] "2018-11-05" "2019-03-22" "2018-12-22" "2019-04-12" "2019-02-13"
## [11] "2019-02-05" "2019-02-05" NA "2019-03-18" NA
## [16] "2019-02-04" "2019-01-25" "2019-05-08" "2018-12-31" "2018-12-28"
## [21] NA "2019-01-11" "2018-12-11" "2019-01-16" NA
## [26] "2019-03-22" NA "2019-01-28" "2019-03-13" "2019-01-20"
## [31] "2019-02-14" "2019-01-10" "2019-01-03" "2018-09-06" "2019-02-26"
## [36] "2019-01-25" "2019-03-06" "2019-01-31" "2019-03-20" "2019-02-27"
## [41] "2018-12-03" "2019-01-25" "2019-03-28" "2019-02-07" "2018-11-20"
## [46] "2019-01-11" "2019-04-19" "2018-12-14" "2019-02-12" "2019-02-11"
## [51] "2018-02-28" "2019-03-06" "2018-01-29" "2018-07-30" "2018-08-14"
## [56] "2018-04-10" "2018-08-16" "2019-04-19" "2019-01-30" "2019-12-19"
## [61] "2019-02-08" "2019-01-31" "2018-12-12" "2019-04-08" "2019-01-23"
## [66] "2018-10-31" "2019-12-12" "2018-12-18" NA "2019-03-04"
## [71] "2019-01-09" "2019-01-07" "2018-12-13" "2019-02-20" "2019-02-22"
## [76] "2019-02-26" "2019-06-05" "2018-12-13" "2019-05-20" "2019-02-11"
## [81] "2019-07-24" "2019-01-30" "2019-01-24" "2019-11-28" "2019-01-23"
## [86] "2018-12-11" "2019-02-14" "2018-01-04" "2017-09-21" "2019-02-05"
## [91] "2019-06-12" "2017-10-30" "2018-04-10" "2018-12-18" "2019-03-04"
## [96] "2018-12-03" "2018-03-02" "2019-02-19" "2017-09-29" "2019-01-31"
## [101] "2019-02-28" "2019-04-02" "2019-05-11" "2019-02-12" "2018-02-16"
## [106] "2018-05-17" "2018-10-30" "2019-05-09" "2019-02-13" "2017-11-30"
## [111] "2019-04-26" NA "2017-12-19" "2017-12-08" "2018-02-13"
## [116] "2018-06-13" "2019-02-01" "2018-09-20" NA "2018-12-26"
## [121] "2018-05-02" "2019-04-30" "2018-06-19" NA "2018-12-28"
## [126] "2018-11-29" "2018-08-28" "2019-02-26" "2018-04-09" "2018-12-13"
## [131] "2018-02-23" "2018-02-13" "2018-11-20" "2019-02-04" "2019-04-24"
## [136] "2018-12-21" "2019-01-24" NA "2019-04-23" "2019-01-10"
## [141] "2019-01-07" "2018-07-27" NA "2018-12-20" "2018-02-04"
## [146] "2018-12-06" "2019-03-04" NA "2019-02-25" "2019-02-08"
## [151] "2018-11-21" NA "2018-12-26"
dater(bp_dataset$After_Date2)
## [1] "2019-01-24" "2019-02-05" "2019-01-16" NA "2019-03-26"
## [6] "2018-12-04" "2019-04-24" "2019-04-11" NA "2019-05-10"
## [11] "2019-03-26" "2019-03-06" NA "2019-06-26" NA
## [16] "2019-03-08" "2019-03-08" NA "2019-02-20" "2018-01-22"
## [21] NA "2019-03-20" "2019-01-08" "2019-02-20" NA
## [26] "2019-06-07" NA "2019-03-25" NA "2019-02-15"
## [31] "2019-04-14" "2019-03-06" "2019-02-21" "2019-02-14" "2019-05-21"
## [36] NA "2019-04-30" "2019-04-12" "2019-04-11" "2019-03-18"
## [41] "2019-04-29" "2019-02-22" NA "2019-03-13" NA
## [46] "2019-02-08" "2019-07-18" "2019-01-29" "2019-06-04" "2019-03-11"
## [51] "2018-06-05" "2018-04-05" "2019-03-25" "2018-08-28" "2019-03-29"
## [56] "2018-06-03" "2018-09-20" "2019-07-18" "2019-02-26" "2019-01-30"
## [61] "2019-04-12" "2019-05-10" "2019-03-12" "2019-07-15" "2019-04-11"
## [66] "2019-03-01" "2019-01-30" "2019-01-22" NA NA
## [71] "2019-02-07" "2019-02-20" "2019-01-18" "2019-03-18" "2019-03-28"
## [76] "2019-05-01" NA "2018-01-02" NA "2019-03-15"
## [81] NA "2019-02-27" "2019-04-16" "2019-02-22" "2019-02-22"
## [86] "2019-01-11" "2019-03-19" "2018-02-02" "2018-06-04" "2019-05-10"
## [91] NA "2018-02-05" "2018-05-17" "2019-02-04" "2019-04-16"
## [96] "2019-06-13" "2018-04-05" "2019-03-21" "2017-11-06" "2019-03-04"
## [101] "2019-04-11" "2019-05-02" NA "2019-03-18" "2018-08-31"
## [106] NA "2018-12-11" "2019-05-08" "2019-03-14" NA
## [111] "2019-06-20" NA "2018-03-26" "2018-02-13" "2018-04-19"
## [116] "2018-08-07" "2019-03-05" "2019-01-29" NA "2019-01-28"
## [121] "2018-08-01" NA "2018-11-06" NA "2019-05-07"
## [126] "2019-03-19" "2018-10-30" NA "2018-07-18" "2019-01-14"
## [131] "2018-03-30" "2018-03-13" "2018-12-20" "2019-03-18" NA
## [136] "2019-01-22" "2019-06-11" NA NA NA
## [141] "2019-02-22" "2018-10-20" NA NA "2019-02-19"
## [146] "2019-02-07" "2019-04-15" NA "2019-03-25" "2019-03-08"
## [151] "2018-12-17" NA NA
dater(bp_dataset$After_Date3)
## [1] "2019-03-14" "2019-03-21" "2019-04-11" NA "2019-04-25"
## [6] "2019-02-01" "2019-07-24" "2019-05-16" NA "2019-06-26"
## [11] "2019-06-04" "2019-06-13" NA NA NA
## [16] "2019-04-12" "2019-04-15" NA "2019-04-07" "2019-02-19"
## [21] NA "2019-05-30" "2019-03-04" "2019-03-20" NA
## [26] NA NA "2019-05-20" NA NA
## [31] "2019-05-23" "2019-04-18" "2019-03-27" "2019-03-14" NA
## [36] NA NA "2019-05-24" NA NA
## [41] "2019-05-28" "2019-04-05" NA NA NA
## [46] "2019-03-15" NA "2019-03-22" NA "2019-04-16"
## [51] "2018-12-21" "2019-04-10" NA "2018-09-24" "2019-04-30"
## [56] "2018-07-10" "2018-10-31" "2019-07-25" "2019-03-30" "2019-03-13"
## [61] "2019-05-22" "2019-06-18" "2019-04-23" NA "2019-06-12"
## [66] "2019-04-15" "2019-03-26" "2019-02-26" NA NA
## [71] "2019-04-10" "2019-03-19" "2019-04-08" "2019-04-17" "2019-04-29"
## [76] "2019-07-19" NA "2018-02-11" NA "2019-04-25"
## [81] NA "2019-03-27" "2019-07-11" "2019-03-22" "2019-05-03"
## [86] "2019-03-22" "2019-07-10" "2018-03-13" "2018-09-04" NA
## [91] NA "2018-04-23" "2018-06-19" "2019-04-24" "2019-05-20"
## [96] NA "2018-05-03" "2019-04-18" "2017-12-11" "2019-04-18"
## [101] "2019-05-17" "2019-06-25" NA "2019-04-17" "2018-10-09"
## [106] NA "2019-04-16" NA "2019-04-28" NA
## [111] NA NA "2018-06-15" "2018-03-15" "2018-06-29"
## [116] "2018-11-14" "2019-05-01" "2019-06-18" NA "2019-02-28"
## [121] "2018-10-24" NA "2019-05-24" NA "2019-07-10"
## [126] "2019-04-15" "2018-02-08" NA "2018-09-18" "2019-02-11"
## [131] "2018-04-27" "2018-04-05" "2019-05-14" "2019-04-22" NA
## [136] "2019-03-05" NA NA NA NA
## [141] "2019-03-27" NA NA NA "2019-03-19"
## [146] "2019-05-02" "2019-07-01" NA "2019-06-11" NA
## [151] "2019-05-01" NA NA
dater(bp_dataset$BMI_Before_Date1)
## [1] "2019-08-09" "2019-06-29" "2018-06-21" "2018-02-15" NA
## [6] "2018-08-24" "2018-07-10" "2018-08-21" "2018-09-27" "2018-09-07"
## [11] "2018-07-17" "2018-08-07" NA "2014-08-22" "2018-05-11"
## [16] "2018-08-17" "2018-10-18" "2018-09-05" "2018-07-10" "2018-07-24"
## [21] "2018-08-21" "2018-10-05" "2018-10-17" "2018-10-05" NA
## [26] "2018-10-16" NA "2018-07-25" "2018-05-24" "2017-10-18"
## [31] "2018-06-26" "2018-07-19" "2017-10-30" "2016-12-15" "2018-06-11"
## [36] "2017-08-09" NA "2018-06-19" "2017-05-15" "2018-09-12"
## [41] "2017-09-26" "2017-08-25" "2017-09-07" "2018-03-07" "2018-08-01"
## [46] "2018-11-01" "2017-09-27" "2018-08-10" "2017-08-10" "2018-01-22"
## [51] "2017-11-17" "2017-09-14" "2017-07-05" "2017-11-06" "2016-10-02"
## [56] "2017-07-20" "2017-08-29" "2017-08-28" "2018-09-19" "2018-09-19"
## [61] "2018-10-15" "2018-11-06" "2018-09-07" "2018-09-13" "2018-09-18"
## [66] "2018-09-20" "2018-08-07" "2018-08-07" NA "2018-08-28"
## [71] "2018-06-05" "2018-09-26" "2018-08-15" "2018-10-10" "2018-09-13"
## [76] "2018-10-09" "2018-10-05" "2018-08-23" "2018-09-14" "2018-09-18"
## [81] "2018-09-24" "2018-09-12" "2018-09-06" NA "2018-09-28"
## [86] "2018-10-02" "2019-07-28" "2016-12-30" "2016-10-24" "2017-03-21"
## [91] "2017-06-21" "2017-07-27" "2017-05-11" "2017-04-27" "2017-04-11"
## [96] "2017-06-19" "2017-06-26" "2017-06-05" "2017-07-12" "2017-07-20"
## [101] "2017-06-29" "2017-05-04" "2017-06-29" "2017-05-02" "2017-07-20"
## [106] "2017-06-06" "2017-06-16" "2017-07-17" "2017-06-23" "2017-07-17"
## [111] "2017-07-17" "2017-03-07" "2017-08-14" "2017-07-18" "2017-09-12"
## [116] "2017-04-06" "2017-09-19" "2017-06-02" NA "2017-08-22"
## [121] "2017-11-28" "2017-04-11" "2017-12-01" "2017-02-03" "2017-12-08"
## [126] "2017-11-03" "2017-12-18" "2017-12-19" "2018-12-15" "2017-12-27"
## [131] "2018-01-05" "2017-12-22" "2018-01-24" "2017-11-27" "2017-08-04"
## [136] "2017-01-25" "2017-05-26" "2018-02-22" "2018-03-16" "2018-04-12"
## [141] "2017-12-01" "2018-04-12" NA "2018-02-09" "2016-08-24"
## [146] "2018-06-20" "2018-08-13" "2018-08-03" "2018-09-17" "2018-08-09"
## [151] "2018-09-18" "2018-06-28" "2018-09-12"
dater(bp_dataset$BMI_Before_Date2)
## [1] "2019-09-27" "2019-08-09" "2018-08-15" "2018-06-12" NA
## [6] "2018-07-20" "2018-05-29" "2018-06-15" "2018-08-31" "2018-05-25"
## [11] "2018-05-29" "2018-04-03" NA "2018-06-06" "2018-10-26"
## [16] "2018-07-23" "2018-08-16" "2018-06-27" NA "2018-06-26"
## [21] "2018-04-12" "2018-09-06" "2018-07-17" "2018-07-24" NA
## [26] "2018-08-24" NA "2018-01-23" "2018-03-30" "2017-08-09"
## [31] "2018-05-16" "2018-05-24" "2019-11-27" "2017-08-24" "2017-01-04"
## [36] "2017-09-19" NA "2018-05-24" "2017-08-24" "2018-06-12"
## [41] "2017-09-12" "2017-06-08" "2017-07-06" "2017-09-28" "2018-06-26"
## [46] "2018-05-07" "2017-05-22" "2018-05-18" "2017-06-12" "2017-11-16"
## [51] "2017-10-13" "2017-08-17" "2017-03-06" "2017-10-18" "2016-09-13"
## [56] "2017-02-10" "2017-07-25" "2017-05-22" "2018-08-24" "2018-08-16"
## [61] "2018-08-06" "2018-10-02" "2018-06-06" "2018-05-02" "2018-08-01"
## [66] "2018-09-20" "2018-01-30" "2018-06-05" NA "2018-07-27"
## [71] "2018-01-31" "2018-08-01" "2018-06-08" "2018-09-11" "2018-08-08"
## [76] "2018-07-03" "2018-08-31" "2018-07-17" "2018-07-20" "2018-08-14"
## [81] "2018-08-20" "2018-08-08" "2018-07-31" NA "2018-08-13"
## [86] "2018-09-18" "2017-01-19" "2016-10-24" "2016-08-09" "2017-07-11"
## [91] "2016-11-03" "2017-05-03" "2017-02-09" "2017-02-15" "2016-09-15"
## [96] "2016-12-12" "2017-05-23" "2017-03-06" "2016-07-15" "2017-02-13"
## [101] "2017-05-05" "2017-04-04" "2017-05-30" "2017-01-13" "2017-05-01"
## [106] "2017-01-17" "2017-04-18" "2017-06-19" "2017-06-07" "2017-06-05"
## [111] "2017-06-21" "2016-09-16" "2017-07-17" "2017-05-31" "2017-08-15"
## [116] "2016-10-19" "2017-07-06" "2016-08-25" NA "2017-05-16"
## [121] "2017-10-18" "2017-02-01" "2017-09-21" "2017-01-13" "2017-11-09"
## [126] "2017-06-21" "2017-07-26" "2017-09-12" "2017-11-06" "2017-11-17"
## [131] "2017-10-20" "2017-11-21" "2018-01-02" "2017-08-28" "2017-08-08"
## [136] "2017-10-19" "2017-03-17" "2017-03-01" "2018-01-05" "2018-10-27"
## [141] "2017-10-05" "2018-02-22" NA "2019-07-20" "2016-07-21"
## [146] "2018-05-24" "2018-05-14" NA "2018-07-24" NA
## [151] "2018-04-30" "2017-12-21" "2017-12-15"
dater(bp_dataset$BMI_Before_Date3)
## [1] "2019-11-09" "2019-09-11" "2018-09-21" "2018-09-04" NA
## [6] "2018-06-19" "2018-02-14" "2018-02-14" "2018-07-13" "2018-04-13"
## [11] "2018-05-07" "2018-02-02" NA "2018-02-28" "2017-08-01"
## [16] "2018-06-22" "2018-07-17" "2018-05-02" NA "2018-05-29"
## [21] "2018-02-02" "2018-08-02" "2018-06-12" "2018-06-20" NA
## [26] "2018-02-09" NA "2016-10-31" "2017-09-28" "2017-07-10"
## [31] "2018-01-31" "2018-04-26" "2018-01-29" "2017-09-21" "2016-10-24"
## [36] "2017-07-17" NA "2018-04-12" "2017-04-07" "2018-05-04"
## [41] "2017-03-28" "2017-06-08" "2017-03-09" "2018-01-26" "2018-05-30"
## [46] "2018-02-05" "2017-02-23" "2018-03-02" "2017-05-17" "2017-09-25"
## [51] "2017-09-01" "2017-06-26" "2016-12-12" "2017-09-06" "2015-08-31"
## [56] "2016-09-29" "2016-09-09" "2017-02-23" "2018-07-27" "2018-07-18"
## [61] "2018-05-28" "2018-08-30" "2018-04-17" "2018-01-04" "2018-05-15"
## [66] "2018-07-25" "2017-07-20" "2018-04-24" NA "2018-05-24"
## [71] "2017-11-29" "2018-07-25" "2018-05-01" "2018-07-25" "2018-07-11"
## [76] "2017-11-22" "2018-03-07" "2018-05-15" "2018-05-25" "2018-07-12"
## [81] "2018-06-05" "2018-06-27" "2018-06-07" NA "2018-06-26"
## [86] "2018-06-18" "2016-06-03" NA "2015-04-16" "2017-04-14"
## [91] "2016-09-28" "2017-03-20" "2016-12-27" "2016-10-13" "2015-12-18"
## [96] "2016-10-28" "2017-04-25" "2016-12-05" "2016-06-17" "2017-01-05"
## [101] "2017-03-23" "2016-06-24" "2017-02-08" "2016-09-23" "2017-03-31"
## [106] "2016-10-07" "2017-01-17" "2015-02-25" "2017-05-11" "2017-04-13"
## [111] "2017-05-02" "2016-03-25" "2017-05-13" "2017-03-29" "2017-07-19"
## [116] "2016-05-23" "2017-05-13" "2016-07-08" NA "2017-03-27"
## [121] "2017-10-16" "2016-10-31" "2016-04-22" "2017-01-05" "2017-10-05"
## [126] "2017-04-07" "2017-05-02" "2017-05-10" "2017-08-31" "2017-10-12"
## [131] "2017-06-06" "2017-10-02" "2017-12-05" "2017-05-01" "2018-02-08"
## [136] "2017-07-06" "2017-05-26" NA NA "2017-09-28"
## [141] "2017-07-26" "2018-01-16" NA "2017-06-21" "2016-06-10"
## [146] "2016-04-28" "2017-11-06" NA "2018-03-20" NA
## [151] "2017-11-02" NA NA
dater(bp_dataset$BMI_After_Date1)
## [1] "2019-12-17" "2019-01-02" "2019-11-21" "2019-02-06" "2019-01-29"
## [6] "2018-11-05" "2019-03-22" "2018-12-22" "2019-04-12" "2019-05-10"
## [11] "2019-02-12" "2019-02-22" NA "2019-03-18" NA
## [16] "2019-03-08" "2019-02-11" "2019-05-08" "2019-02-20" "2018-12-28"
## [21] NA "2019-01-11" "2018-12-11" "2019-01-16" NA
## [26] "2019-03-22" NA "2019-01-28" "2019-03-13" "2019-01-20"
## [31] "2019-02-14" "2018-01-10" "2019-01-03" "2018-09-06" "2019-02-26"
## [36] "2018-10-25" NA "2019-01-31" "2019-01-25" "2019-02-27"
## [41] "2018-12-03" "2019-01-25" "2019-03-28" "2019-03-13" "2018-11-20"
## [46] "2019-05-06" NA "2019-01-29" "2019-02-12" "2019-02-11"
## [51] "2018-02-28" "2019-03-06" "2018-01-29" "2018-08-06" "2018-08-14"
## [56] "2018-06-03" "2018-08-30" "2019-07-25" "2019-01-30" "2018-12-19"
## [61] "2019-02-06" "2019-01-31" "2018-12-12" "2019-04-08" "2019-01-23"
## [66] "2018-10-31" "2018-12-12" "2018-12-18" NA "2019-03-04"
## [71] "2019-01-09" "2019-01-07" "2019-01-18" "2019-02-20" "2019-02-22"
## [76] "2019-02-06" "2019-06-05" "2018-01-02" "2019-05-20" "2019-02-11"
## [81] "2019-07-24" "2019-02-04" "2019-01-24" NA "2019-01-23"
## [86] "2018-12-11" "2019-02-14" "2018-09-18" "2018-06-04" "2019-05-10"
## [91] NA "2017-10-30" "2018-04-10" "2018-12-19" "2019-03-04"
## [96] "2018-12-03" "2018-03-02" "2019-03-21" "2018-08-17" "2019-01-31"
## [101] "2019-02-28" "2019-04-02" "2019-05-11" "2019-02-12" "2018-02-16"
## [106] "2018-05-17" "2018-10-30" "2018-12-26" "2019-02-13" "2017-11-30"
## [111] "2019-06-20" NA "2017-12-19" "2017-12-08" "2018-02-13"
## [116] "2018-06-13" "2019-02-01" "2018-09-20" NA "2018-12-26"
## [121] "2018-05-02" "2019-04-30" "2018-06-19" NA "2018-12-20"
## [126] "2019-03-19" "2018-08-28" "2019-02-26" "2018-04-09" "2018-12-13"
## [131] "2018-02-23" "2018-02-13" "2018-11-20" "2019-03-25" "2019-04-24"
## [136] "2018-12-21" "2019-01-24" NA "2019-04-25" "2019-01-10"
## [141] "2019-01-07" "2018-07-27" NA "2018-12-20" NA
## [146] "2018-12-06" "2019-03-04" NA "2019-02-25" "2019-02-08"
## [151] "2018-12-07" NA NA
dater(bp_dataset$BMI_After_Date2)
## [1] "2019-01-24" "2019-02-05" "2019-01-16" NA NA
## [6] "2018-12-04" "2019-04-24" "2019-04-11" NA "2019-02-13"
## [11] "2019-03-26" "2019-03-06" NA "2019-06-26" NA
## [16] "2019-04-12" "2019-04-15" NA "2019-04-07" "2018-01-22"
## [21] NA "2019-03-20" "2019-01-08" "2019-02-20" NA
## [26] "2019-06-07" NA NA NA NA
## [31] "2019-04-23" "2019-03-06" "2019-02-21" "2019-02-14" NA
## [36] NA NA "2019-04-12" NA "2019-03-18"
## [41] "2019-04-29" "2019-02-22" NA NA NA
## [46] "2019-07-18" NA "2019-03-22" "2019-06-04" "2019-03-11"
## [51] "2018-12-21" "2018-04-05" "2019-03-25" "2018-08-28" "2019-03-29"
## [56] "2018-08-30" "2018-10-31" NA "2019-03-30" "2019-01-30"
## [61] "2019-04-12" "2019-05-10" "2019-03-12" "2019-07-15" "2019-04-11"
## [66] "2019-03-01" "2019-01-30" "2019-01-22" NA NA
## [71] "2019-02-07" "2019-02-20" "2019-04-08" "2019-03-18" "2019-04-29"
## [76] "2019-05-01" NA "2018-03-05" NA "2019-03-15"
## [81] NA "2019-03-13" "2019-04-16" NA "2019-05-03"
## [86] "2019-01-11" "2019-03-19" "2018-11-15" "2018-09-04" NA
## [91] NA "2018-02-05" "2018-05-17" "2019-02-04" "2019-04-16"
## [96] "2019-06-13" "2018-04-05" "2019-04-18" NA "2019-03-04"
## [101] "2019-04-11" NA NA "2019-03-18" "2018-08-31"
## [106] NA "2018-12-11" NA "2019-03-14" NA
## [111] NA NA "2018-03-26" "2018-02-13" "2018-04-19"
## [116] "2018-08-07" "2019-03-05" "2019-01-29" NA "2019-01-28"
## [121] "2018-08-01" NA "2018-11-09" NA "2019-05-07"
## [126] "2019-04-15" "2018-10-30" NA "2018-09-18" "2019-01-14"
## [131] "2018-03-30" "2018-04-05" "2018-12-20" "2019-07-15" NA
## [136] "2019-01-22" "2019-06-11" NA NA NA
## [141] "2019-02-22" "2018-10-20" NA NA NA
## [146] "2019-02-07" "2019-04-15" NA "2019-03-25" "2019-03-08"
## [151] "2018-12-17" NA NA
dater(bp_dataset$BMI_After_Date3)
## [1] "2019-03-14" "2019-03-21" "2019-04-11" NA NA
## [6] "2019-02-19" "2019-07-24" "2019-05-16" NA "2019-06-26"
## [11] "2019-06-04" "2019-06-13" NA NA NA
## [16] "2019-04-26" "2019-06-07" NA NA "2019-02-19"
## [21] NA "2019-05-30" "2019-03-04" "2019-03-20" NA
## [26] NA NA NA NA NA
## [31] "2019-05-23" "2019-04-24" "2019-07-11" "2019-06-06" NA
## [36] NA NA "2019-05-24" NA NA
## [41] "2019-05-28" "2019-04-05" NA NA NA
## [46] NA NA "2019-06-04" NA "2019-04-16"
## [51] "2019-04-07" "2019-04-10" NA "2018-10-02" "2019-04-30"
## [56] "2019-02-21" "2018-12-06" NA "2019-05-21" "2018-03-13"
## [61] "2019-05-22" "2019-07-11" "2019-04-23" NA "2019-06-12"
## [66] "2019-04-15" "2019-03-26" "2019-02-26" NA NA
## [71] "2019-04-10" "2019-03-19" NA "2019-04-17" NA
## [76] "2019-07-19" NA "2018-04-02" NA "2019-04-25"
## [81] NA "2019-04-24" "2019-07-11" NA "2019-06-21"
## [86] "2019-03-22" "2019-07-10" "2019-04-01" "2019-04-18" NA
## [91] NA "2018-05-14" "2018-06-19" "2019-04-24" "2019-05-20"
## [96] NA "2018-05-03" "2019-07-01" NA "2019-04-18"
## [101] "2019-05-21" NA NA "2019-04-23" "2018-10-09"
## [106] NA "2019-04-16" NA "2019-04-28" NA
## [111] NA NA "2018-06-15" "2018-03-20" "2018-06-29"
## [116] "2019-02-07" "2019-05-01" "2019-06-18" NA "2019-03-21"
## [121] "2018-12-19" NA "2019-05-24" NA "2019-07-10"
## [126] "2019-05-01" "2019-02-08" NA "2018-11-09" "2019-02-11"
## [131] "2018-04-23" "2018-07-24" "2019-05-14" NA NA
## [136] "2019-03-05" NA NA NA NA
## [141] "2019-03-27" NA NA NA NA
## [146] "2019-05-02" "2019-07-01" NA "2019-06-11" NA
## [151] "2019-05-01" NA NA
dater(bp_dataset$A1C_After_Date1)
## [1] "2019-02-07" NA "2019-04-11" "2019-04-12" NA
## [6] "2019-02-19" NA NA "2018-12-07" "2019-07-31"
## [11] "2019-06-05" "2018-12-27" NA "2019-06-26" "2019-06-18"
## [16] NA NA NA "2019-03-02" "2019-06-06"
## [21] NA "2019-01-11" "2019-03-04" NA NA
## [26] "2019-03-25" NA NA "2019-03-13" NA
## [31] NA "2018-11-14" "2019-03-14" NA NA
## [36] NA NA NA "2019-06-21" NA
## [41] "2019-04-29" "2019-05-21" "2019-01-25" "2019-07-19" NA
## [46] "2019-07-18" "2018-09-25" "2018-12-14" "2019-06-04" "2019-01-07"
## [51] "2019-04-19" NA NA NA "2019-03-29"
## [56] NA "2019-04-18" "2019-07-25" "2019-07-24" NA
## [61] NA NA NA NA "2019-04-17"
## [66] NA "2019-06-19" "2019-02-26" NA NA
## [71] NA "2019-06-26" "2019-01-18" NA "2019-07-10"
## [76] "2019-05-01" "2019-06-05" NA "2019-05-20" NA
## [81] "2019-07-24" "2019-05-08" NA NA NA
## [86] "2019-02-01" "2019-07-10" "2018-07-17" "2019-03-25" "2019-05-07"
## [91] NA "2017-11-06" NA "2019-06-27" "2019-05-20"
## [96] "2019-05-30" NA "2019-07-01" "2018-05-04" NA
## [101] "2019-02-28" "2019-03-14" "2018-02-27" "2019-04-23" NA
## [106] "2018-05-10" "2019-04-16" "2018-12-05" NA NA
## [111] NA NA "2018-08-16" "2019-04-03" "2019-01-31"
## [116] "2019-02-12" "2019-03-05" "2018-09-20" NA "2019-06-13"
## [121] "2019-01-31" "2019-03-01" NA NA NA
## [126] NA NA "2019-03-26" "2018-12-13" "2018-12-31"
## [131] "2018-03-30" "2018-06-15" "2019-05-14" "2019-02-04" "2019-04-23"
## [136] NA NA NA "2019-01-24" NA
## [141] NA NA NA NA NA
## [146] "2019-05-02" NA NA "2019-06-13" "2019-02-01"
## [151] NA NA NA
dater(bp_dataset$A1C_After_Date2)
## [1] "2019-07-18" NA "2019-01-23" "2019-01-14" NA
## [6] NA NA NA NA NA
## [11] "2019-02-05" NA NA NA NA
## [16] NA NA NA NA "2019-01-08"
## [21] NA "2019-03-22" NA NA NA
## [26] "2019-02-01" NA NA NA NA
## [31] NA NA NA NA NA
## [36] NA NA NA NA NA
## [41] NA NA NA "2019-02-27" NA
## [46] "2019-02-20" NA NA NA NA
## [51] NA NA NA NA NA
## [56] NA "2018-08-30" NA NA NA
## [61] NA NA NA NA "2019-01-23"
## [66] NA "2018-12-12" NA NA NA
## [71] NA NA NA NA "2019-03-13"
## [76] "2019-02-06" NA NA NA NA
## [81] NA "2019-02-13" NA NA NA
## [86] NA "2019-02-03" "2018-09-27" "2018-07-30" NA
## [91] NA "2018-05-14" NA NA "2019-02-04"
## [96] "2018-12-20" NA "2019-03-15" "2018-08-17" NA
## [101] NA NA NA NA NA
## [106] NA NA NA NA NA
## [111] NA NA NA NA "2018-05-04"
## [116] NA NA NA NA "2019-02-25"
## [121] NA NA NA NA NA
## [126] NA NA NA "2018-06-15" NA
## [131] "2018-09-28" "2018-12-28" NA NA NA
## [136] NA NA NA NA NA
## [141] NA NA NA NA NA
## [146] "2018-12-06" NA NA NA NA
## [151] NA NA NA
dater(bp_dataset$A1C_Before_Date1)
## [1] "2017-12-27" NA "2018-01-15" "2018-05-21" NA
## [6] "2018-06-04" "2017-12-12" "2018-02-14" "2018-08-24" "2018-07-25"
## [11] "2017-12-21" "2017-10-07" NA "2018-06-06" "2018-06-20"
## [16] NA NA "2018-03-16" "2018-07-03" "2018-08-07"
## [21] "2018-02-02" "2018-07-03" "2018-02-27" "2018-08-31" NA
## [26] "2018-08-24" NA NA "2018-05-11" NA
## [31] NA "2018-04-20" "2017-10-30" NA NA
## [36] NA NA NA "2017-08-25" NA
## [41] "2016-09-29" "2017-08-21" "2017-07-06" "2018-03-07" NA
## [46] "2018-11-01" "2017-08-28" "2018-08-09" "2016-11-28" "2017-07-05"
## [51] "2017-01-27" NA NA NA "2016-09-13"
## [56] NA "2016-06-03" "2017-08-28" "2018-07-05" NA
## [61] NA NA NA "2018-09-20" "2018-08-01"
## [66] NA "2018-06-12" "2018-08-07" NA "2018-05-04"
## [71] "2018-10-16" "2018-07-11" "2018-08-15" "2018-09-11" "2018-07-11"
## [76] "2018-07-03" "2018-08-31" NA "2018-06-22" "2018-08-14"
## [81] "2018-02-05" "2018-09-12" NA NA NA
## [86] "2018-09-18" "2017-04-13" "2017-03-10" "2016-06-30" "2017-06-23"
## [91] NA "2017-06-26" NA "2017-02-13" "2016-08-26"
## [96] "2017-06-19" NA "2017-06-06" "2017-03-20" NA
## [101] "2017-02-27" "2017-03-30" "2017-08-15" "2017-08-08" NA
## [106] "2017-06-23" "2017-04-18" "2017-07-17" NA "2017-03-27"
## [111] NA NA "2017-05-30" "2016-07-11" "2017-07-26"
## [116] "2016-05-23" "2017-06-06" "2014-08-07" NA "2017-08-08"
## [121] "2017-10-16" "2017-02-01" NA NA "2017-10-03"
## [126] NA NA "2017-12-19" "2017-12-07" "2017-12-05"
## [131] "2017-12-18" "2017-12-29" "2017-12-05" "2017-11-20" "2017-08-04"
## [136] NA "2017-03-08" NA "2018-01-05" NA
## [141] "2017-06-16" "2018-01-16" "2017-11-29" "2017-07-20" "2018-07-23"
## [146] "2017-03-10" "2016-07-25" NA "2018-06-18" "2018-07-31"
## [151] "2016-12-28" NA "2018-09-12"
dater(bp_dataset$A1C_After_Date2)
## [1] "2019-07-18" NA "2019-01-23" "2019-01-14" NA
## [6] NA NA NA NA NA
## [11] "2019-02-05" NA NA NA NA
## [16] NA NA NA NA "2019-01-08"
## [21] NA "2019-03-22" NA NA NA
## [26] "2019-02-01" NA NA NA NA
## [31] NA NA NA NA NA
## [36] NA NA NA NA NA
## [41] NA NA NA "2019-02-27" NA
## [46] "2019-02-20" NA NA NA NA
## [51] NA NA NA NA NA
## [56] NA "2018-08-30" NA NA NA
## [61] NA NA NA NA "2019-01-23"
## [66] NA "2018-12-12" NA NA NA
## [71] NA NA NA NA "2019-03-13"
## [76] "2019-02-06" NA NA NA NA
## [81] NA "2019-02-13" NA NA NA
## [86] NA "2019-02-03" "2018-09-27" "2018-07-30" NA
## [91] NA "2018-05-14" NA NA "2019-02-04"
## [96] "2018-12-20" NA "2019-03-15" "2018-08-17" NA
## [101] NA NA NA NA NA
## [106] NA NA NA NA NA
## [111] NA NA NA NA "2018-05-04"
## [116] NA NA NA NA "2019-02-25"
## [121] NA NA NA NA NA
## [126] NA NA NA "2018-06-15" NA
## [131] "2018-09-28" "2018-12-28" NA NA NA
## [136] NA NA NA NA NA
## [141] NA NA NA NA NA
## [146] "2018-12-06" NA NA NA NA
## [151] NA NA NA
dater(fp_survey$date_completed)
## [1] "2017-07-05" "2017-07-05" "2017-07-05" "2017-07-05" "2017-07-05"
## [6] "2017-07-05" "2017-07-05" "2017-07-05" "2017-07-05" "2017-07-11"
## [11] "2017-07-12" "2017-07-12" "2017-07-12" "2017-07-12" "2017-07-12"
## [16] "2017-07-12" "2017-07-12" "2017-07-15" "2017-07-18" "2017-07-19"
## [21] "2017-07-19" "2017-07-19" "2017-07-19" "2017-07-19" "2017-07-26"
## [26] "2017-08-02" "2017-08-02" "2017-08-09" "2017-08-16" "2017-08-16"
## [31] "2017-08-23" "2017-08-23" "2017-08-23" "2017-09-20" "2017-09-20"
## [36] "2017-09-27" "2017-09-27" "2017-09-20" NA NA
## [41] "2017-09-07" "2017-09-07" "2017-09-07" "2017-09-07" "2017-09-07"
## [46] "2017-09-07" "2017-09-07" "2017-09-07" "2017-09-18" "2017-09-21"
## [51] "2017-09-21" "2017-09-21" "2017-09-21" "2017-09-21" "2017-09-21"
## [56] "2017-09-28" "2017-09-28" "2017-09-28" "2017-09-28" "2017-09-28"
## [61] "2017-09-28" "2017-09-29" "2017-10-05" "2017-10-05" "2017-10-05"
## [66] "2017-10-12" "2017-10-26" "2017-10-26" "2017-10-26" "2017-10-26"
## [71] "2018-01-11" "2018-01-11" NA "2018-01-18" NA
## [76] NA "2018-01-18" NA NA NA
## [81] NA NA NA NA NA
## [86] NA NA "2017-09-08" NA "2017-09-08"
## [91] NA NA "2017-09-09" "2017-09-08" "2017-09-15"
## [96] "2017-09-08" "2017-09-08" "2017-09-08" NA NA
## [101] NA NA "2017-09-08" "2017-09-08" NA
## [106] "2017-09-15" "2017-09-15" NA "2017-09-09" NA
## [111] "2017-11-01" "2017-10-18" "2017-12-06" NA NA
## [116] "2018-01-24" "2017-11-29" NA NA "2018-01-17"
## [121] "2018-02-01" "2018-01-26" NA "2018-02-09" "2018-01-26"
## [126] "2018-02-01" "2018-08-01" "2017-09-08" NA NA
## [131] "2018-06-15" "2017-09-15" NA "2018-02-02" "2018-02-01"
## [136] "2018-02-15" "2018-04-25" "2018-05-23" "2018-02-15" "2018-02-16"
## [141] "2018-05-16" "2018-07-19" "2018-03-30" "2018-02-09" "2018-03-27"
## [146] "2018-04-25" "2018-06-27" NA "2018-04-13" "2017-09-28"
## [151] "2018-02-16" "2018-07-18" "2018-08-02" "2017-09-08" NA
## [156] "2018-02-16" "2018-02-16" "2018-03-13" NA NA
## [161] "2018-02-15" "2018-02-01" NA "2018-04-13" "2018-06-15"
## [166] "2018-08-02" "2018-05-17" "2018-04-13" "2018-04-25" NA
## [171] "2018-02-15" NA "2018-09-27" "2019-01-29" "2018-09-13"
## [176] "2018-09-27" NA "2018-10-11" NA "2018-11-01"
## [181] "2018-09-09" NA "2018-11-17" "2018-01-03" "2018-08-29"
## [186] "2018-08-22" "2018-08-08" "2018-08-18" "2018-08-29" "2018-08-29"
## [191] "2018-10-24" "2018-10-24" "2018-08-30" "2018-10-03" "2018-09-26"
## [196] "2018-09-19" "2018-09-26" "2018-09-27" "2018-09-27" "2018-09-27"
## [201] "2018-09-27" "2018-09-27" "2018-09-29" "2018-11-07" "2018-09-13"
## [206] "2018-11-01" "2018-04-13" "2018-10-04" "2018-10-04" "2018-10-04"
## [211] NA "2018-10-05" "2018-09-27" "2018-10-11" "2018-10-11"
## [216] "2018-10-11" "2018-10-25" "2018-10-05" "2018-10-25" "2018-10-25"
## [221] "2018-10-25" "2018-09-20" "2018-09-20" "2018-09-20" "2018-09-20"
## [226] "2018-09-20" "2018-09-20" NA "2018-09-13" "2019-01-16"
## [231] "2019-02-22" "2019-02-22" "2019-02-22" NA NA
## [236] "2019-01-29" "2019-01-29" "2019-02-05" "2019-02-27" "2019-02-13"
## [241] "2019-02-20" "2019-02-06" "2019-02-06" NA "2019-03-26"
## [246] "2019-03-26" "2019-03-26" "2019-03-26" "2019-03-26" "2019-04-02"
## [251] NA "2019-03-19" "2019-04-16" "2019-02-26" NA
## [256] NA NA "2019-04-17" NA "2019-01-17"
## [261] "2019-01-17" NA "2018-06-07" "2018-01-03" "2017-12-20"
## [266] "2017-12-06" "2018-01-10" "2018-11-01" NA "2018-11-01"
## [271] "2018-11-01" "2018-11-01" "2018-10-25" "2018-10-17" "2018-10-18"
## [276] "2018-10-18" "2018-10-11" "2018-10-11" "2019-01-23" "2017-12-14"
## [281] NA "2019-06-25" "2019-06-25" "2019-06-25" "2019-06-11"
## [286] "2019-06-25" "2019-06-25" "2019-02-26" "2019-02-26" NA
## [291] NA "2018-03-05" NA NA "2019-03-05"
## [296] NA "2019-02-01" "2019-03-12" "2019-03-12" NA
## [301] "2019-03-12" "2019-03-12" NA "2019-02-15" NA
## [306] NA "2019-03-27" "2019-03-27" "2019-03-20" "2019-03-13"
## [311] "2019-03-13" "2019-02-20" "2019-04-09" NA "2019-05-07"
## [316] "2019-05-07" "2019-05-28" "2018-05-23" "2019-05-21" "2019-05-28"
## [321] "2019-05-24" NA "2019-05-24" "2019-04-17" "2019-02-06"
## [326] "2019-01-17" "2018-03-28" NA NA "2018-02-07"
## [331] "1973-07-26" "2019-07-23" NA "2018-04-18" "2018-03-07"
## [336] "2019-07-09" NA NA "2019-07-09" "2018-02-28"
## [341] NA "2019-06-25"
dater(fp_survey$date_completed2)
## [1] NA NA "2017-10-18" NA "2017-09-13"
## [6] NA NA NA "2017-09-20" NA
## [11] NA NA NA NA NA
## [16] NA NA "2018-10-31" NA NA
## [21] NA "2018-03-14" NA NA "2017-11-01"
## [26] NA NA "2017-12-06" NA NA
## [31] NA NA NA "2017-12-16" "2018-02-04"
## [36] NA "2017-12-16" NA NA NA
## [41] "2017-12-07" NA NA NA "2017-11-30"
## [46] "2017-11-30" NA "2017-11-30" NA NA
## [51] NA NA NA NA NA
## [56] NA NA NA NA "2017-11-30"
## [61] NA NA NA NA NA
## [66] NA NA NA NA NA
## [71] NA NA NA NA NA
## [76] NA NA NA NA NA
## [81] "2017-11-30" NA "2017-11-30" NA NA
## [86] NA NA NA "2018-04-13" "2017-11-17"
## [91] "2017-11-16" NA NA "2017-11-17" NA
## [96] NA NA "2018-04-03" "2017-11-17" "1967-01-19"
## [101] "2017-11-17" NA NA NA NA
## [106] NA NA NA NA NA
## [111] NA NA NA "2018-04-18" NA
## [116] "2018-08-08" NA NA "2018-07-18" NA
## [121] NA NA NA NA NA
## [126] NA NA NA NA NA
## [131] NA NA NA NA NA
## [136] NA "2018-09-26" NA NA NA
## [141] NA NA NA NA NA
## [146] "2018-06-20" NA NA "2018-04-13" NA
## [151] NA NA NA "2017-11-16" NA
## [156] NA NA NA NA NA
## [161] NA NA NA NA "2018-08-03"
## [166] NA NA NA NA NA
## [171] NA NA "2018-11-01" NA "2018-11-01"
## [176] "2018-11-01" "2019-04-16" "2018-11-15" "2018-11-15" "2018-11-29"
## [181] "2018-11-01" "2018-01-24" NA "2018-07-25" NA
## [186] NA NA NA NA NA
## [191] NA NA NA "2019-01-29" NA
## [196] NA NA NA NA NA
## [201] NA NA NA NA NA
## [206] NA NA NA NA NA
## [211] NA NA NA NA NA
## [216] NA NA NA NA NA
## [221] NA NA NA NA NA
## [226] NA NA NA NA NA
## [231] NA NA NA NA NA
## [236] NA NA NA NA NA
## [241] NA NA NA NA NA
## [246] NA NA NA NA NA
## [251] NA NA NA "2019-04-16" "2019-04-19"
## [256] "2019-04-19" "2019-04-19" NA "2019-04-10" NA
## [261] NA NA NA NA NA
## [266] NA NA NA NA NA
## [271] NA NA NA NA NA
## [276] NA NA NA NA NA
## [281] NA NA NA NA NA
## [286] NA NA NA NA NA
## [291] NA NA NA NA NA
## [296] NA NA NA NA NA
## [301] NA NA NA NA NA
## [306] NA NA NA NA NA
## [311] NA NA NA NA NA
## [316] NA NA NA NA NA
## [321] NA NA NA NA NA
## [326] NA "2018-05-20" "2018-05-02" "2018-06-27" NA
## [331] NA NA NA NA NA
## [336] NA NA NA NA "2019-02-06"
## [341] NA NA
dater(fp_survey$date_of_birth3)
## [1] "1969-03-01" NA "1959-03-17" NA "1956-07-07"
## [6] NA NA NA NA NA
## [11] NA NA "1962-01-05" NA NA
## [16] "1946-07-07" NA "1958-08-02" NA NA
## [21] NA "1963-07-03" NA NA "1961-02-18"
## [26] NA NA "1948-05-02" NA NA
## [31] NA NA NA "1965-05-26" "1958-05-29"
## [36] NA "1953-11-02" NA NA "1978-03-22"
## [41] NA NA NA NA "1946-11-22"
## [46] "1946-03-05" NA "1967-09-03" NA NA
## [51] NA NA NA NA NA
## [56] NA NA NA NA "1958-02-10"
## [61] NA NA NA NA NA
## [66] NA NA NA NA NA
## [71] NA NA NA NA NA
## [76] NA NA NA NA NA
## [81] "1953-04-12" NA "1953-04-12" NA NA
## [86] NA NA NA "1969-10-31" "1968-01-05"
## [91] "1962-03-11" NA NA "1963-04-04" NA
## [96] NA NA "1958-08-15" "1961-11-02" NA
## [101] "1954-12-27" NA NA NA NA
## [106] "1947-03-26" NA NA NA NA
## [111] NA NA NA "1972-04-12" "1954-04-21"
## [116] "1974-09-01" NA NA "1987-09-29" NA
## [121] NA NA "1958-04-14" NA NA
## [126] NA NA NA NA NA
## [131] NA NA NA NA NA
## [136] NA NA NA NA NA
## [141] NA NA NA NA NA
## [146] "1971-02-13" NA "1954-09-03" "1951-02-10" NA
## [151] NA NA NA "1962-11-12" NA
## [156] NA NA NA NA NA
## [161] NA NA NA NA "1954-01-15"
## [166] NA NA NA NA NA
## [171] NA "1964-06-20" "1963-02-25" NA "1955-09-02"
## [176] "1956-09-09" "1956-09-09" "1959-11-19" "1957-02-25" "1977-07-16"
## [181] "1951-03-13" "1963-11-09" NA "1954-03-28" NA
## [186] NA NA NA NA NA
## [191] NA NA NA "1938-01-07" NA
## [196] NA NA NA NA NA
## [201] NA NA NA NA NA
## [206] NA NA NA NA NA
## [211] NA NA NA NA NA
## [216] NA NA NA NA NA
## [221] NA NA NA NA NA
## [226] NA NA NA NA NA
## [231] NA NA NA NA NA
## [236] NA NA NA NA NA
## [241] NA NA NA NA NA
## [246] NA NA NA NA NA
## [251] NA NA NA "1944-08-07" "1960-03-07"
## [256] "1949-09-01" NA NA "1964-02-10" NA
## [261] NA NA NA NA NA
## [266] NA NA NA NA NA
## [271] NA NA NA NA NA
## [276] NA NA NA NA NA
## [281] NA NA NA NA NA
## [286] NA NA NA NA NA
## [291] NA NA NA NA NA
## [296] NA NA NA NA NA
## [301] NA NA NA NA NA
## [306] NA NA NA NA NA
## [311] NA NA NA NA NA
## [316] NA NA NA NA NA
## [321] NA NA NA NA NA
## [326] NA "1943-05-20" "1959-01-21" "1953-07-11" NA
## [331] NA NA NA NA NA
## [336] NA NA NA NA "1991-01-03"
## [341] NA NA
#Step 2B: Format Categorical Variables as Factors
bp_dataset$Clinic <- as.factor(bp_dataset$Clinic)
bp_dataset$six<- as.factor(bp_dataset$six)
bp_dataset$GtMSS <- as.factor(bp_dataset$GtMSS)
bp_dataset$GTMO <- as.factor(bp_dataset$GTMO)
bp_dataset$Gt3SS <- as.factor(bp_dataset$Gt3SS)
bp_dataset$Gt3O <- as.factor(bp_dataset$Gt3O)
bp_dataset$Consis <- as.factor(bp_dataset$Consis)
bp_dataset$Hypertension <- as.factor(bp_dataset$Hypertension)
bp_dataset$`Diabetic_ Status` <- as.factor(bp_dataset$`Diabetic_ Status`)
fp_survey$clinic <- as.factor(fp_survey$clinic)
fp_survey$n_children <- as.factor(fp_survey$n_children)
fp_survey$n_adults <- as.factor(fp_survey$n_adults)
fp_survey$race_ethnicity <- as.factor(fp_survey$race_ethnicity)
fp_survey$primary_language <- as.factor(fp_survey$primary_language)
fp_survey$highest_education <- as.factor(fp_survey$highest_education)
fp_survey$health_status_pre <- as.factor(fp_survey$health_status_pre)
Step 3: Merge Both Survey and BP Datasets into One datset. Prune dataset into analysis chunks
mega <- merge(bp_dataset, fp_survey, by = "ID")
mega <- as.data.frame(mega)
Step 4: Population Description
#Segmenting attendance, changing it from an integer to a factor
df6 <- mega %>% select(Clinic, ID, Num_Visits, Average_SYS, Average_SYS2, Average_DIA, Average_DIA2, Delta_Sys, Delta_Dia)
df6$Visit <- cut(df6$Num_Visits, c(1, 5, 10, 15, 30, Inf), right = 1)
summary(df6$Visit)
## (1,5] (5,10] (10,15] (15,30] (30,Inf]
## 43 30 15 13 12
pl13 <- ggplot(df6, aes(Visit)) + geom_bar(aes(fill = Visit)) + xlab("Visit Count") + ylab("Patient Count") + theme_minimal()
pl13
#Further Segmenting it by Clinical Location
pl14 <- pl13 + facet_grid(~Clinic)
pl14
df4 <- mega %>% select(ID, race_ethnicity, Average_SYS, Average_SYS2, Average_DIA, Average_DIA2, Delta_Sys, Delta_Dia)
summary(df4$race_ethnicity)
## asian
## 13 4
## Asian or Pacific Ilander black
## 0 66
## black, asian black, native
## 1 4
## black, white black,native,white
## 1 0
## hispanic, other latino
## 1 6
## latino, asian latino, black
## 0 1
## latino, native latino, white
## 0 0
## latino, white, black, native, asian native
## 2 1
## other white
## 5 6
## white, black white, black, native
## 1 1
eth_black <- 1 + 1 + 2 + 1 + 66 + 4 + 1 + 1
eth_black
## [1] 77
count(df4, vars = "ID")
## # A tibble: 1 x 2
## vars n
## <chr> <int>
## 1 ID 113
eth_black_percentage = 77/113
eth_black_percentage
## [1] 0.6814159
eth_black_strict <- 66/113
eth_black_strict
## [1] 0.5840708
Let’s take a look at Age Demographics next.
df5 <- mega %>% select(Clinic, age_calculated, ID, Num_Visits, Average_SYS, Average_SYS2, Average_DIA, Average_DIA2, Delta_Sys, Delta_Dia)
df5$Age <- cut(df5$age_calculated, c(20, 30, 40, 50, 60, 70, Inf), right = 0)
#Drops NA Values
df5 <- df5 %>% drop_na(Age)
summary(df5$Age)
## [20,30) [30,40) [40,50) [50,60) [60,70) [70,Inf)
## 0 1 10 39 36 15
summary(df5$age_calculated)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 31.00 54.00 60.00 60.12 65.00 85.00
pl16 <- ggplot(df5, aes(Age)) + geom_bar(aes(fill = Age)) + xlab("Age") + ylab("Patient Count") + theme_minimal()
pl16
#For Fun
pl17 <- pl16 + facet_grid(~Clinic)
pl17
Step 5: Analysis of BP Data, independent of other classfications: Population 153 - Number of N/A’s
summary(mega$Average_DIA)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 65.33 76.00 80.33 81.66 86.00 110.00 4
summary(mega$Average_DIA2)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 60.00 73.00 78.33 78.54 84.17 97.33 9
summary(mega$Delta_Dia)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## -27.000 -6.333 -1.750 -2.691 2.083 17.333 9
#Checking for normal data
#creating temp dataframe with the variables we are interested in specifically
df <- mega %>% select(ID, Average_DIA, Average_DIA2)
df <- df %>% gather(key = "BP", value = "Readings", Average_DIA:Average_DIA2)
#creation of Box Plots to assess visually
pl <- ggplot(df,aes( x= BP, y = Readings)) + geom_boxplot() + theme_gray() + xlab("Before and After") + ylab("Blood Pressure (mmHg)") + labs(c("Before", "After"))
pl2 <- ggplot(mega, aes(x = ID, y = Delta_Dia)) + geom_boxplot() + theme_gray() + xlab("Change in Disatolic Pressure") + ylab("Blood Pressure (mmHg)")
#creation of Quantile Plots (QQ) to Check visually
pl3 <- ggplot(df, aes(sample = Readings)) +stat_qq()
pl4 <- ggplot(mega, aes(sample = Delta_Dia)) + stat_qq()
pl
## Warning: Removed 13 rows containing non-finite values (stat_boxplot).
pl2
## Warning: Continuous x aesthetic -- did you forget aes(group=...)?
## Warning: Removed 9 rows containing non-finite values (stat_boxplot).
pl3
## Warning: Removed 13 rows containing non-finite values (stat_qq).
pl4
## Warning: Removed 9 rows containing non-finite values (stat_qq).
t.test(mega$Average_DIA, mega$Average_DIA2)
##
## Welch Two Sample t-test
##
## data: mega$Average_DIA and mega$Average_DIA2
## t = 2.7906, df = 210.42, p-value = 0.005744
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.9166364 5.3273944
## sample estimates:
## mean of x mean of y
## 81.66208 78.54006
Step 4B: Analysis of Systolic BP: Average Sys is before, Average Sys 2 is after, Delta is Change
summary(mega$Average_SYS)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 109.0 127.0 136.3 137.1 144.0 188.7 4
summary(mega$Average_SYS2)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 93.0 122.3 132.2 132.4 140.2 205.0 9
summary(mega$Delta_Sys)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## -46.167 -11.333 -3.333 -4.418 3.333 36.333 9
df <- mega %>% select(ID, Average_SYS, Average_SYS2)
df <- df %>% gather(key = "BP", value = "Readings", Average_SYS:Average_SYS2)
#creation of Box Plots to assess visually
pl5 <- ggplot(df,aes( x= BP, y = Readings)) + geom_boxplot() + theme_gray() + xlab("Before and After") + ylab("Blood Pressure (mmHg)") + labs(c("Before", "After"))
pl6 <- ggplot(mega, aes(x = ID, y = Delta_Sys)) + geom_boxplot() + theme_gray() + xlab("Change in Systolic Pressure") + ylab("Blood Pressure (mmHg)")
#creation of Quantile Plots (QQ) to Check visually
pl7 <- ggplot(df, aes(sample = Readings)) +stat_qq()
pl8 <- ggplot(mega, aes(sample = Delta_Sys)) + stat_qq()
pl5
## Warning: Removed 13 rows containing non-finite values (stat_boxplot).
pl6
## Warning: Continuous x aesthetic -- did you forget aes(group=...)?
## Warning: Removed 9 rows containing non-finite values (stat_boxplot).
pl7
## Warning: Removed 13 rows containing non-finite values (stat_qq).
pl8
## Warning: Removed 9 rows containing non-finite values (stat_qq).
Step 4C: Tests Entire population of all BP users for significance
t.test(mega$Average_SYS, mega$Average_SYS2)
##
## Welch Two Sample t-test
##
## data: mega$Average_SYS and mega$Average_SYS2
## t = 2.321, df = 208.33, p-value = 0.02125
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.7081224 8.6942829
## sample estimates:
## mean of x mean of y
## 137.1483 132.4471
Both tests indicate that, among the entire population, there is a significant difference in both systolic and diastolic pressure before and afterwards. Let’s continue by testing the different subsets.
Our first varaible mesaures the amount of times that people visited at least 6 times. a 0 indicate no, 6 indicates yes.
#There are 42 people who visisted less than 6 times, and 70 who visisted more than 6 times.
summary(mega$six)
## 0 1
## 43 70
#Creation of temp dataset to analyze
df <- mega %>% select(ID, six, Average_SYS, Average_SYS2)
df <- df %>% gather(key = "BP", value = "Readings", Average_SYS:Average_SYS2)
#creation of Box Plots to assess visually
pl9 <- ggplot(df,aes( x= BP, y = Readings, fill = six)) + geom_boxplot() + theme_gray() + xlab("Before and After") + ylab("Blood Pressure (mmHg)") + labs(c("Before", "After"))
pl10 <- ggplot(mega, aes(x = ID, y = Delta_Sys, fill = six)) + geom_boxplot() + theme_gray() + xlab("Change in Systolic Blood Pressure") + ylab("Blood Pressure (mmHg)")
pl9
## Warning: Removed 13 rows containing non-finite values (stat_boxplot).
pl10
## Warning: Removed 9 rows containing non-finite values (stat_boxplot).
print("6 or more Visits")
## [1] "6 or more Visits"
df2 <- mega %>% subset(six == 1)
summary(df2$Clinic)
## Campus SAFHC SEHC TWHC
## 13 37 10 10
summary(df2$Average_SYS)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 109.0 127.3 136.8 137.5 144.0 176.3 2
summary(df2$Average_SYS2)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 93.0 122.3 132.0 132.5 139.2 205.0 7
summary(df2$Delta_Sys)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## -41.333 -10.833 -4.333 -4.545 2.833 36.333 7
t.test(df2$Average_SYS, df2$Average_SYS2)
##
## Welch Two Sample t-test
##
## data: df2$Average_SYS and df2$Average_SYS2
## t = 1.8183, df = 122.54, p-value = 0.07146
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.442084 10.414617
## sample estimates:
## mean of x mean of y
## 137.4730 132.4868
print("5 or fewer visits")
## [1] "5 or fewer visits"
df3 <- mega %>% subset(six == 0)
summary(df3$clinic)
## CAMPUS FHC PHHC RFPC SAFHC SAHC SEHC TWUHC
## 1 8 3 0 1 17 0 8 5
summary(df3$Average_SYS)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 114.7 126.7 135.3 136.6 143.3 188.7 2
summary(df3$Average_SYS2)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 103.0 126.0 133.0 132.4 141.7 162.0 2
summary(df3$Delta_Sys)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## -46.167 -11.333 -2.000 -4.224 5.333 24.667 2
t.test(df3$Average_SYS, df3$Average_SYS2)
##
## Welch Two Sample t-test
##
## data: df3$Average_SYS and df3$Average_SYS2
## t = 1.4177, df = 78.989, p-value = 0.1602
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -1.70640 10.15355
## sample estimates:
## mean of x mean of y
## 136.6098 132.3862
Diastoic Blood Pressure for Patients, 6 or more or fewer than six
df <- mega %>% select(ID, six, Average_DIA, Average_DIA2)
df <- df %>% gather(key = "BP", value = "Readings", Average_DIA:Average_DIA2)
pl11 <- ggplot(df,aes( x= BP, y = Readings, fill = six)) + geom_boxplot() + theme_gray() + xlab("Before and After") + ylab("Blood Pressure (mmHg)") + labs(c("Before", "After"))
pl12 <- ggplot(mega, aes(x = ID, y = Delta_Dia, fill = six)) + geom_boxplot() + theme_gray() + xlab("Change in Systolic Blood Pressure") + ylab("Blood Pressure (mmHg)")
pl11
## Warning: Removed 13 rows containing non-finite values (stat_boxplot).
pl12
## Warning: Removed 9 rows containing non-finite values (stat_boxplot).
print("6 or more Visits")
## [1] "6 or more Visits"
summary(df2$Clinic)
## Campus SAFHC SEHC TWHC
## 13 37 10 10
summary(df2$Average_DIA)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 65.33 75.33 80.50 81.70 85.50 110.00 2
summary(df2$Average_DIA2)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 60.00 73.50 78.33 78.37 85.50 96.00 7
summary(df2$Delta_Dia)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## -27.000 -6.333 -1.333 -2.624 1.833 17.333 7
t.test(df2$Average_DIA, df2$Average_DIA2)
##
## Welch Two Sample t-test
##
## data: df2$Average_DIA and df2$Average_DIA2
## t = 2.1941, df = 128.92, p-value = 0.03002
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.3275301 6.3393700
## sample estimates:
## mean of x mean of y
## 81.69853 78.36508
print("5 or fewer visits")
## [1] "5 or fewer visits"
summary(df3$clinic)
## CAMPUS FHC PHHC RFPC SAFHC SAHC SEHC TWUHC
## 1 8 3 0 1 17 0 8 5
summary(df3$Average_DIA)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 68.33 77.67 80.33 81.60 86.00 97.33 2
summary(df3$Average_DIA2)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 65.00 73.00 79.00 78.81 83.00 97.33 2
summary(df3$Delta_Dia)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## -21.500 -5.000 -1.833 -2.793 2.667 5.667 2
t.test(df3$Average_DIA, df3$Average_DIA2)
##
## Welch Two Sample t-test
##
## data: df3$Average_DIA and df3$Average_DIA2
## t = 1.7309, df = 78.286, p-value = 0.08741
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.4192304 6.0045962
## sample estimates:
## mean of x mean of y
## 81.60163 78.80894
Results seem to indicate that people who attend FP more have a better result. Lets take a deeper look. df3 has people subsetted based on their total visit count
tester <- function(dd, x, y, z, q) {
pltemp <- ggplot(dd, aes(sample = x + y)) +stat_qq()
print(pltemp)
pltemp2 <- ggplot(dftemp, aes(sample = z + q)) +stat_qq()
print(pltemp2)
dd <- dd %>% gather(key = "BP", value = "Readings", Average_SYS:Average_DIA2)
pltemp3 <- ggplot(dd,aes( x = BP, y = Readings)) + geom_boxplot() + theme_gray() + xlab("Before and After") + ylab("Blood Pressure (mmHg)") + labs(c("Before", "After"))
print(pltemp3)
print("Sys Result")
test <- t.test(x, y)
print(test)
print("Dia Result")
test2 <- t.test(z, q)
print(test2)
}
#The Filter
dftemp <- df6 %>% filter(Visit == '(1,5]')
tester(dftemp, dftemp$Average_SYS, dftemp$Average_SYS2, dftemp$Average_DIA, dftemp$Average_DIA2)
## Warning: Removed 2 rows containing non-finite values (stat_qq).
## Warning: Removed 2 rows containing non-finite values (stat_qq).
## Warning: Removed 8 rows containing non-finite values (stat_boxplot).
## [1] "Sys Result"
##
## Welch Two Sample t-test
##
## data: x and y
## t = 1.4177, df = 78.989, p-value = 0.1602
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -1.70640 10.15355
## sample estimates:
## mean of x mean of y
## 136.6098 132.3862
##
## [1] "Dia Result"
##
## Welch Two Sample t-test
##
## data: z and q
## t = 1.7309, df = 78.286, p-value = 0.08741
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.4192304 6.0045962
## sample estimates:
## mean of x mean of y
## 81.60163 78.80894
The above results are for 1-5 Visits. Let’s look at 6-10.
dftemp <- df6 %>% filter(Visit == '(5,10]')
tester(dftemp, dftemp$Average_SYS, dftemp$Average_SYS2, dftemp$Average_DIA, dftemp$Average_DIA2)
## Warning: Removed 4 rows containing non-finite values (stat_qq).
## Warning: Removed 4 rows containing non-finite values (stat_qq).
## Warning: Removed 12 rows containing non-finite values (stat_boxplot).
## [1] "Sys Result"
##
## Welch Two Sample t-test
##
## data: x and y
## t = 1.001, df = 48.876, p-value = 0.3218
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -5.495175 16.401769
## sample estimates:
## mean of x mean of y
## 138.9405 133.4872
##
## [1] "Dia Result"
##
## Welch Two Sample t-test
##
## data: z and q
## t = 1.5201, df = 51.27, p-value = 0.1346
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -1.106480 8.011242
## sample estimates:
## mean of x mean of y
## 83.03571 79.58333
dftemp <- df6 %>% filter(Visit == '(10,15]')
tester(dftemp, dftemp$Average_SYS, dftemp$Average_SYS2, dftemp$Average_DIA, dftemp$Average_DIA2)
## [1] "Sys Result"
##
## Welch Two Sample t-test
##
## data: x and y
## t = 1.2299, df = 27.843, p-value = 0.229
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -3.847886 15.403442
## sample estimates:
## mean of x mean of y
## 134.1111 128.3333
##
## [1] "Dia Result"
##
## Welch Two Sample t-test
##
## data: z and q
## t = 2.1543, df = 27.999, p-value = 0.03997
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.2583992 10.2527119
## sample estimates:
## mean of x mean of y
## 77.04444 71.78889
dftemp <- df6 %>% filter(Num_Visits > 15)
summary(dftemp$Visit)
## (1,5] (5,10] (10,15] (15,30] (30,Inf]
## 0 0 0 13 12
tester(dftemp, dftemp$Average_SYS, dftemp$Average_SYS2, dftemp$Average_DIA, dftemp$Average_DIA2)
## Warning: Removed 3 rows containing non-finite values (stat_qq).
## Warning: Removed 3 rows containing non-finite values (stat_qq).
## Warning: Removed 6 rows containing non-finite values (stat_boxplot).
## [1] "Sys Result"
##
## Welch Two Sample t-test
##
## data: x and y
## t = 1.1282, df = 42.475, p-value = 0.2656
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -2.924393 10.344999
## sample estimates:
## mean of x mean of y
## 137.8467 134.1364
##
## [1] "Dia Result"
##
## Welch Two Sample t-test
##
## data: z and q
## t = 0.61334, df = 44.881, p-value = 0.5428
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -3.618557 6.787042
## sample estimates:
## mean of x mean of y
## 82.99333 81.40909
The analysis seems to indicate that we don’t have enough people to discover significance if we break them up into smaller chunks based on visist numbers. Let’s test the AA population. For that, we’ll use DF 4
dftemp <- df4 %>% filter(race_ethnicity == 'black' | race_ethnicity == 'black, native' | race_ethnicity == 'black, white' | race_ethnicity == 'white, black, native' | race_ethnicity == 'latino, white, black, native, asian' | race_ethnicity == 'latino, black' | race_ethnicity == 'white, black' | race_ethnicity == 'black, asian')
tester(dftemp, dftemp$Average_SYS, dftemp$Average_SYS2, dftemp$Average_DIA, dftemp$Average_DIA2)
## Warning: Removed 4 rows containing non-finite values (stat_qq).
## Warning: Removed 4 rows containing non-finite values (stat_qq).
## Warning: Removed 12 rows containing non-finite values (stat_boxplot).
## [1] "Sys Result"
##
## Welch Two Sample t-test
##
## data: x and y
## t = 2.0569, df = 145.86, p-value = 0.04148
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.1840284 9.2150583
## sample estimates:
## mean of x mean of y
## 137.4667 132.7671
##
## [1] "Dia Result"
##
## Welch Two Sample t-test
##
## data: z and q
## t = 2.3558, df = 145.24, p-value = 0.01982
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.4792826 5.4730462
## sample estimates:
## mean of x mean of y
## 82.12000 79.14384
dftemp <- df4 %>% filter(race_ethnicity == 'black')
tester(dftemp, dftemp$Average_SYS, dftemp$Average_SYS2, dftemp$Average_DIA, dftemp$Average_DIA2)
## Warning: Removed 4 rows containing non-finite values (stat_qq).
## Warning: Removed 4 rows containing non-finite values (stat_qq).
## Warning: Removed 12 rows containing non-finite values (stat_boxplot).
## [1] "Sys Result"
##
## Welch Two Sample t-test
##
## data: x and y
## t = 1.6769, df = 123.51, p-value = 0.09608
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.7538962 9.1151193
## sample estimates:
## mean of x mean of y
## 138.2344 134.0538
##
## [1] "Dia Result"
##
## Welch Two Sample t-test
##
## data: z and q
## t = 2.1922, df = 122.97, p-value = 0.03025
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.3015158 5.9115218
## sample estimates:
## mean of x mean of y
## 82.19792 79.09140
The results indicate that, among all people who identified as African American there was a signficiant difference in Sys and Diastolic BP.
Let’s take a look at age next. For that, we’ll use DF5.
Individually, none of the data seems to coorelate with age.
dftemp <- df5 %>% filter(age_calculated < 50)
summary(dftemp$Age)
## [20,30) [30,40) [40,50) [50,60) [60,70) [70,Inf)
## 0 1 10 0 0 0
tester(dftemp, dftemp$Average_SYS, dftemp$Average_SYS2, dftemp$Average_DIA, dftemp$Average_DIA2)
## Warning: Removed 1 rows containing non-finite values (stat_qq).
## Warning: Removed 1 rows containing non-finite values (stat_qq).
## Warning: Removed 2 rows containing non-finite values (stat_boxplot).
## [1] "Sys Result"
##
## Welch Two Sample t-test
##
## data: x and y
## t = 1.596, df = 16.278, p-value = 0.1297
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -3.610935 25.738208
## sample estimates:
## mean of x mean of y
## 141.0303 129.9667
##
## [1] "Dia Result"
##
## Welch Two Sample t-test
##
## data: z and q
## t = 0.89828, df = 16.813, p-value = 0.3817
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -5.327151 13.215030
## sample estimates:
## mean of x mean of y
## 86.39394 82.45000
dftemp <- df5 %>% filter(age_calculated < 60 & age_calculated >= 50)
summary(dftemp$Age)
## [20,30) [30,40) [40,50) [50,60) [60,70) [70,Inf)
## 0 0 0 39 0 0
tester(dftemp, dftemp$Average_SYS, dftemp$Average_SYS2, dftemp$Average_DIA, dftemp$Average_DIA2)
## Warning: Removed 1 rows containing non-finite values (stat_qq).
## Warning: Removed 1 rows containing non-finite values (stat_qq).
## Warning: Removed 4 rows containing non-finite values (stat_boxplot).
## [1] "Sys Result"
##
## Welch Two Sample t-test
##
## data: x and y
## t = 1.6338, df = 73.591, p-value = 0.1066
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -1.078333 10.894123
## sample estimates:
## mean of x mean of y
## 135.8158 130.9079
##
## [1] "Dia Result"
##
## Welch Two Sample t-test
##
## data: z and q
## t = 1.4514, df = 73.909, p-value = 0.1509
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.9404505 5.9843102
## sample estimates:
## mean of x mean of y
## 82.60526 80.08333
dftemp <- df5 %>% filter(age_calculated < 70 & age_calculated >= 60)
summary(dftemp$Age)
## [20,30) [30,40) [40,50) [50,60) [60,70) [70,Inf)
## 0 0 0 0 36 0
tester(dftemp, dftemp$Average_SYS, dftemp$Average_SYS2, dftemp$Average_DIA, dftemp$Average_DIA2)
## Warning: Removed 3 rows containing non-finite values (stat_qq).
## Warning: Removed 3 rows containing non-finite values (stat_qq).
## Warning: Removed 10 rows containing non-finite values (stat_boxplot).
## [1] "Sys Result"
##
## Welch Two Sample t-test
##
## data: x and y
## t = 0.62073, df = 64.569, p-value = 0.537
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -6.068367 11.540738
## sample estimates:
## mean of x mean of y
## 139.0392 136.3030
##
## [1] "Dia Result"
##
## Welch Two Sample t-test
##
## data: z and q
## t = 1.5955, df = 63.746, p-value = 0.1155
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.7588299 6.7772494
## sample estimates:
## mean of x mean of y
## 81.19608 78.18687
dftemp <- df5 %>% filter(age_calculated >= 70)
summary(dftemp$Age)
## [20,30) [30,40) [40,50) [50,60) [60,70) [70,Inf)
## 0 0 0 0 0 15
tester(dftemp, dftemp$Average_SYS, dftemp$Average_SYS2, dftemp$Average_DIA, dftemp$Average_DIA2)
## [1] "Sys Result"
##
## Welch Two Sample t-test
##
## data: x and y
## t = 0.77404, df = 27.835, p-value = 0.4454
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -5.453725 12.075947
## sample estimates:
## mean of x mean of y
## 135.7556 132.4444
##
## [1] "Dia Result"
##
## Welch Two Sample t-test
##
## data: z and q
## t = 0.94643, df = 27.248, p-value = 0.3522
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -2.619350 7.108239
## sample estimates:
## mean of x mean of y
## 75.82222 73.57778
Let’s try Bigger Buckets
dftemp <- df5 %>% filter(age_calculated < 70 & age_calculated >= 50)
summary(dftemp$Age)
## [20,30) [30,40) [40,50) [50,60) [60,70) [70,Inf)
## 0 0 0 39 36 0
tester(dftemp, dftemp$Average_SYS, dftemp$Average_SYS2, dftemp$Average_DIA, dftemp$Average_DIA2)
## Warning: Removed 4 rows containing non-finite values (stat_qq).
## Warning: Removed 4 rows containing non-finite values (stat_qq).
## Warning: Removed 14 rows containing non-finite values (stat_boxplot).
## [1] "Sys Result"
##
## Welch Two Sample t-test
##
## data: x and y
## t = 1.499, df = 140.91, p-value = 0.1361
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -1.250498 9.095438
## sample estimates:
## mean of x mean of y
## 137.3380 133.4155
##
## [1] "Dia Result"
##
## Welch Two Sample t-test
##
## data: z and q
## t = 2.1428, df = 140.72, p-value = 0.03385
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.2118517 5.2640221
## sample estimates:
## mean of x mean of y
## 81.93981 79.20188
dftemp <- df5 %>% filter(age_calculated >= 50)
summary(dftemp$Age)
## [20,30) [30,40) [40,50) [50,60) [60,70) [70,Inf)
## 0 0 0 39 36 15
tester(dftemp, dftemp$Average_SYS, dftemp$Average_SYS2, dftemp$Average_DIA, dftemp$Average_DIA2)
## Warning: Removed 4 rows containing non-finite values (stat_qq).
## Warning: Removed 4 rows containing non-finite values (stat_qq).
## Warning: Removed 14 rows containing non-finite values (stat_boxplot).
## [1] "Sys Result"
##
## Welch Two Sample t-test
##
## data: x and y
## t = 1.676, df = 170.86, p-value = 0.09557
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.6789142 8.3169343
## sample estimates:
## mean of x mean of y
## 137.0651 133.2461
##
## [1] "Dia Result"
##
## Welch Two Sample t-test
##
## data: z and q
## t = 2.2608, df = 170.91, p-value = 0.02503
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.3380543 4.9902002
## sample estimates:
## mean of x mean of y
## 80.88506 78.22093
dftemp <- df5 %>% filter(age_calculated < 70 & age_calculated >= 40)
summary(dftemp$Age)
## [20,30) [30,40) [40,50) [50,60) [60,70) [70,Inf)
## 0 0 10 39 36 0
tester(dftemp, dftemp$Average_SYS, dftemp$Average_SYS2, dftemp$Average_DIA, dftemp$Average_DIA2)
## Warning: Removed 5 rows containing non-finite values (stat_qq).
## Warning: Removed 5 rows containing non-finite values (stat_qq).
## Warning: Removed 16 rows containing non-finite values (stat_boxplot).
## [1] "Sys Result"
##
## Welch Two Sample t-test
##
## data: x and y
## t = 1.952, df = 159.14, p-value = 0.05269
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.05649847 9.65985214
## sample estimates:
## mean of x mean of y
## 137.6829 132.8812
##
## [1] "Dia Result"
##
## Welch Two Sample t-test
##
## data: z and q
## t = 2.3444, df = 159.98, p-value = 0.02029
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.4665897 5.4548534
## sample estimates:
## mean of x mean of y
## 82.48780 79.52708
So, excluding the oldest patients and the youngest patient also gets significant results.
dftemp <- bp_dataset %>% select(Clinic)
pl20 <- ggplot(dftemp, aes(Clinic)) + geom_bar(aes(fill = Clinic), width = .7) + ggtitle("Patients by Clinic") + theme_minimal() + coord_flip() + theme(axis.title.x=element_blank()) + theme(legend.position = "none") + scale_fill_brewer(palette="Spectral")
pl20