johnschwenck / bp Goto Github PK
View Code? Open in Web Editor NEWAn R package for analyzing blood pressure data
An R package for analyzing blood pressure data
with the bp_children data processed such as
children_proc <- process_data(bp_children, sbp = 'sbp', dbp = 'dbp', id = 'id', visit = 'visit)
and run the bp_hist() function
bp_hist(children_proc)
I get the following error...
Error in eval(predvars, data, env) : object 'DAY_OF_WEEK' not found
In running the example in ?bp_report
l I discovered that when the output is directed to the screen, multiple windows are opened, many plots are made and eventually things are plotted on top of each other. Complete chaos! Looks like the plot calls are being duplicated. It goes on for more than 3 minutes but does eventually quit w/o error.
This is really hard to describe so I made a screen recording. I'm sending the first minute to John's e-mail since it is so big.
Plotting to a file works correctly and quickly.
Thanks!
R > sessionInfo()
R Under development (unstable) (2021-03-04 r80062)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] bp_1.0.1
loaded via a namespace (and not attached):
[1] fansi_0.4.2 assertthat_0.2.1 dplyr_1.0.4 crayon_1.4.1 utf8_1.1.4 grid_4.1.0
[7] R6_2.5.0 DBI_1.1.1 lifecycle_1.0.0 gtable_0.3.0 magrittr_2.0.1 scales_1.1.1
[13] ggplot2_3.3.3 pillar_1.5.0 rlang_0.4.10 generics_0.1.0 vctrs_0.3.6 ellipsis_0.3.1
[19] glue_1.4.2 purrr_0.3.4 munsell_0.5.0 compiler_4.1.0 pkgconfig_2.0.3 colorspace_2.0-0
[25] tidyselect_1.1.0 tibble_3.1.0
Hey,
I was testing the packages and noticed that the aggregate feature does not seem to work.
See reprex below, with data points well below the 3 min threshold.
The output seems to be the same, no matter if I include 'agg = TRUE' or not.
Please let me know if I missed anything obvious.
Thanks!
Edit: Improved reprex to have side by side example with agg = F and agg = T
library(bp)
data_raw_reprex<-tibble::tribble(
~DATE.TIME, ~SYST, ~DIAST, ~HR,
"2022-06-28 17:01:56", "129", "76", "86",
"2022-06-28 17:02:46", "138", "76", "83",
"2022-06-28 17:03:40", "130", "66", "80",
"2022-06-29 15:11:07", "127", "77", "75",
"2022-06-29 15:12:00", "124", "79", "76",
"2022-06-29 15:12:50", "127", "76", "76",
"2022-06-30 14:03:22", "134", "81", "74",
"2022-06-30 14:04:18", "139", "81", "72",
"2022-06-30 14:05:17", "130", "77", "74",
"2022-06-30 18:59:43", "734", "74", "72",
"2022-06-30 19:00:33", "131", "78", "73",
"2022-06-30 19:01:31", "146", "72", "74",
"2022-06-30 19:02:28", "125", "73", "72"
)
data_proc_agg_F<-process_data(data_raw_reprex,
sbp = 'syst',
dbp = 'diast',
date_time = 'date.time',
hr = 'hr')
#> 1 values that exceeded the SUL or SLL thresholds were coerced to NA.
#> DATE column created from DATE_TIME column.
#> No PP column found or specified. Automatically generated from SBP and DBP columns.
#> No RPP column found or specified. Automatically generated from SBP and HR columns.
#> No MAP column found or specified. Automatically generated from SBP and DBP columns.
bp_report(data_proc_agg_F, save_report = 0)
#> Report not saved to a file. To save, specify save_report = TRUE.
data_proc_agg_T<-process_data(data_raw_reprex,
sbp = 'syst',
dbp = 'diast',
date_time = 'date.time',
hr = 'hr',
agg = TRUE,
agg_thresh = '5',
collapse_df = TRUE)
#> 1 values that exceeded the SUL or SLL thresholds were coerced to NA.
#> DATE column created from DATE_TIME column.
#> No PP column found or specified. Automatically generated from SBP and DBP columns.
#> No RPP column found or specified. Automatically generated from SBP and HR columns.
#> No MAP column found or specified. Automatically generated from SBP and DBP columns.
bp_report(data_proc_agg_T, save_report = 0)
#> Report not saved to a file. To save, specify save_report = TRUE.
Created on 2022-07-02 by the reprex package (v2.0.1)
Hi,
I am trying to re-create the plots I have seen in your publication using bp_hypnos data that is already in bp package. I installed bp package with vignettes. However, when I use either dip_class_plot(hypnos_proc) or dip_class_plot(hypnos_proc, subj = 70417), I get the following error:
Error in check_aesthetics()
:
! Aesthetics must be either length 1 or the same as the data (1): colour, shape, x and y
Run rlang::last_error()
to see where the error occurred.
Do you know any work around this issue? I tried debugging, but it did not solve the issue as I am not much experienced with R.
I finally figured out what I needed to do to preprocess a data table from my OMRON blood pressure cuff for the process_data() function. It worked, but would have been quicker with concise documentation by output field of the expected input. Eg; 'required', 'optional', and 'calculated'. Maybe I missed it, but a table would be very nice.
Here's a link to the preprocessor script I ended up with, in case someone else is wrangling OMRON data: https://github.com/chasbecker/bp/blob/main/main.R
I have the bp_hypnos data processed such as...
hypnos_proc <- process_data(bp_hypnos, bp_type = 'abpm', sbp = "syst", dbp = "DIAST", date_time = "date.time", id = "id", wake = "wake", visit = "visit", hr = "hr", map = "map", rpp = "rpp", pp = "pp", ToD_int = c(5, 13, 18, 23))
We have the following different ID's we can use in the subj argument of the bp_scatter function...
70417, 70422, 70424, 70435,70439
When running the code with all the subjects selected bp_scatter(data = hypnos_proc, subj = c(70417, 70422, 70424, 70435,70439))
and none of the subjects selected bp_scatter(data = hypnos_proc, subj = NULL)
, I would expect the same plot to be produced, but this is not the case.
Moreover, the following warning occurs,
Warning message: In ID == subj : longer object length is not a multiple of shorter object length
but this only happens when more than 2 subjects are selected, that is bp_scatter(data = hypnos_proc, subj = c(70424, 70435))
would not produce the warning, but bp_scatter(data = hypnos_proc, subj = c(70424, 70435, 70439))
would produce the warning.
bp installed with devtools::install_github("johnschwenck/bp")
I have import my data into data frame bp, and if I run:
bp_proc <- process_data(bp, sbp = 'SYS', dbp = 'DIA', hr = 'PUL', date_time = 'DT')
head(bp_proc)
The result is for process_data is:
No PP column found. Automatically generated from SBP and DBP columns.
No MAP column found. Automatically generated from SBP and DBP columns.
NOTE: Created DATE column from DATE_TIME column
and head gives:
DATE DATE_TIME HOUR SBP DBP BP_CLASS HR MAP PP
1 2021-06-20 2021-06-20 09:53:00 9 114 75 Normal 61 88.00000 39
2 2021-06-20 2021-06-20 09:47:00 9 123 78 Elevated 61 93.00000 45
3 2021-06-18 2021-06-18 20:46:00 20 125 84 IDH - S1 64 97.66667 41
4 2021-06-18 2021-06-18 20:40:00 20 133 87 Stage 1 64 102.33333 46
5 2021-06-17 2021-06-17 19:17:00 19 116 81 IDH - S1 66 92.66667 35
6 2021-06-17 2021-06-17 19:11:00 19 132 85 Stage 1 62 100.66667 47
SBP_CATEGORY DBP_CATEGORY ID GROUP TIME_OF_DAY DAY_OF_WEEK BP_TYPE
1 Normal Normal 1 1 Morning Sun HBPM
2 Elevated Normal 1 1 Morning Sun HBPM
3 Elevated Stage 1 1 1 Evening Fri HBPM
4 Stage 1 Stage 1 1 1 Evening Fri HBPM
5 Normal Stage 1 1 1 Evening Thu HBPM
6 Stage 1 Stage 1 1 1 Evening Thu HBPM
The names function gives:
> names(bp_proc)
[1] "DATE" "DATE_TIME" "HOUR" "SBP" "DBP"
[6] "BP_CLASS" "HR" "MAP" "PP" "SBP_CATEGORY"
[11] "DBP_CATEGORY" "ID" "GROUP" "TIME_OF_DAY" "DAY_OF_WEEK"
[16] "BP_TYPE"
If I run bp_hist(bp_proc) I get:
Error in `[.data.frame`(SBP_ToD, , c(3, 1, 2, 4, 5)) :
undefined columns selected
This also happens with the version installed with install.packages("bp").
What am I doing wrong?
thanks,
Chris
First: Many thanks for this great package!
Just tried it with some own values, and received a perfect bp-Report ( bp_report() ). As I used the bp_ts_plots() function it only resulted in the BP-by-hour-plot, omitting the the BP-by-DATE_TIME-plot (for a series of >150 values from approx. a month's period). Perhaps my fault (as I didn't have read the complete manual, just the vignette) or some issue?
Keep up your great work!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.