我在flexdashboard的顶部显示了运行时光泽,如下所示:
---
title: "Provider Dashboard"
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: fill
runtime: shiny
---
```{r global, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(tibbletime)
library(scales)
source("\\clean_names.R")
source("Functions\\optimal_bin_size.R")
df_los <- readr::read_csv(
"data\\los.csv"
) %>%
clean_names() %>%
filter(ward_cd != "EMER") %>%
filter(med_staff_dept != "?") %>%
filter(med_staff_dept != "Pathology")
df_los$dsch_date <- lubridate::mdy(df_los$dsch_date)
df_los <- as_tbl_time(df_los, index = dsch_date)
df_ra <- readr::read_csv(
"data\\ra.csv"
) %>%
clean_names() %>%
filter(ward_cd != "EMER") %>%
filter(med_staff_dept != "?") %>%
filter(med_staff_dept != "Pathology")
df_ra <- rename(df_ra, pt_id = "pt_no_num")
df_ra$dsch_date <- lubridate::mdy(df_ra$dsch_date)
df_ra$adm_date <- lubridate::mdy(df_ra$adm_date)
df_ra <- as_tbl_time(df_ra, index = dsch_date)
df_a <- df_los %>%
dplyr::select(
pt_id
, dsch_date
, los
, performance
, z_minus_score
, lihn_service_line
, hosim
, severity_of_illness
, pyr_group2
, med_staff_dept
, ward_cd
)
df_b <- df_ra %>%
dplyr::select(
pt_id
, readmit_count
, readmit_rate_bench
, z_minus_score
)
df_los_ra <- dplyr::inner_join(df_a, df_b, by = "pt_id") %>%
as_tbl_time(index = dsch_date)
```
我使用`glimpse(df_los_ra)输出df_los_ra并得到以下信息:
Observations: 10,147
Variables: 14
$ pt_id [3m[90m<dbl>[39m[23m 14597637, 14597371, 14598064, 14596696, 14...
$ dsch_date [3m[90m<date>[39m[23m 2018-01-01, 2018-01-01, 2018-01-01, 2018-...
$ los [3m[90m<dbl>[39m[23m 5, 6, 4, 8, 3, 1, 5, 5, 3, 2, 1, 5, 4, 2, ...
$ performance [3m[90m<dbl>[39m[23m 3.812128, 3.968809, 4.326577, 3.737013, 6....
$ z_minus_score.x [3m[90m<dbl>[39m[23m 0.1551, 0.2653, -0.0427, 0.5568, -0.4428, ...
$ lihn_service_line [3m[90m<chr>[39m[23m "GI Hemorrhage", "COPD", "CVA", "Medical",...
$ hosim [3m[90m<chr>[39m[23m "Hospitalist", "Hospitalist", "Hospitalist...
$ severity_of_illness [3m[90m<dbl>[39m[23m 2, 2, 2, 2, 3, 3, 4, 2, 1, 2, 1, 2, 3, 3, ...
$ pyr_group2 [3m[90m<chr>[39m[23m "Medicaid", "Medicaid HMO", "HMO", "Medica...
$ med_staff_dept [3m[90m<chr>[39m[23m "Internal Medicine", "Internal Medicine", ...
$ ward_cd [3m[90m<chr>[39m[23m "2PED", "4SOU", "2CAD", "2NOR", "2CAD", "2...
$ readmit_count [3m[90m<dbl>[39m[23m 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, ...
$ readmit_rate_bench [3m[90m<dbl>[39m[23m 0.1566, 0.1705, 0.0200, 0.0843, 0.2515, 0....
$ z_minus_score.y [3m[90m<dbl>[39m[23m -0.4828, -0.5256, -0.0617, 2.8229, -0.7753...
然后我尝试运行以下内容:
gmc_los_ra <- reactive(
{
df_los_ra %>%
filter(
long filter statement, works in other document locations
) %>%
#collapse_by("monthly") %>%
dplyr::group_by(dsch_date, add = T) <-- forgotten pipe
dplyr::summarize(
excess_ra = round(mean(readmit_count - readmit_rate_bench), 2)
, excess_los = round(mean(los.x - performance), 2)
)
}
)
renderPlot({
print(gmc_los_ra())
})
仅收到Error: object 'readmit_count' not found
的错误,但显然我看到glimpse
输出了错误,我的语法关闭了吗?
会话信息
> sessionInfo()
R version 3.5.3 (2019-03-11)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] scales_1.0.0 tibbletime_0.1.2 forcats_0.4.0
[4] stringr_1.4.0 dplyr_0.8.3 purrr_0.3.2
[7] readr_1.3.1 tidyr_0.8.3 tibble_2.1.3
[10] ggplot2_3.2.0 tidyverse_1.2.1 flexdashboard_0.5.1.1
loaded via a namespace (and not attached):
[1] Rcpp_1.0.2 lubridate_1.7.4 lattice_0.20-38
[4] prettyunits_1.0.2 ps_1.3.0 utf8_1.1.4
[7] assertthat_0.2.1 zeallot_0.1.0 digest_0.6.20
[10] R6_2.4.0 cellranger_1.1.0 backports_1.1.4
[13] stats4_3.5.3 evaluate_0.14 httr_1.4.0
[16] pillar_1.4.2 rlang_0.4.0 lazyeval_0.2.2
[19] readxl_1.3.1 rstudioapi_0.10 callr_3.3.1
[22] rmarkdown_1.14 loo_2.1.0 munsell_0.5.0
[25] broom_0.5.2 compiler_3.5.3 modelr_0.1.4
[28] xfun_0.8 rstan_2.19.2 pkgconfig_2.0.2
[31] pkgbuild_1.0.3 htmltools_0.3.6 tidyselect_0.2.5
[34] gridExtra_2.3 matrixStats_0.54.0 fansi_0.4.0
[37] crayon_1.3.4 withr_2.1.2 grid_3.5.3
[40] nlme_3.1-137 jsonlite_1.6 gtable_0.3.0
[43] magrittr_1.5 StanHeaders_2.18.1-10 cli_1.1.0
[46] stringi_1.4.3 xml2_1.2.1 generics_0.0.2
[49] vctrs_0.2.0 tools_3.5.3 glue_1.3.1
[52] hms_0.5.0 processx_3.4.1 parallel_3.5.3
[55] yaml_2.2.0 inline_0.3.15 colorspace_1.4-1
[58] rvest_0.3.4 knitr_1.23 haven_2.1.1