Dear Posit Community
Issue = LOS values so much lower than TotalAmount and Revenue
Repex = at the end of the post
Aim = these 3 variables must be in the same plot for doctors to understand the impact of HAC (Hospital Acquired Complications) on cost and revenue, and length of stay
Request = to have an independent y axis for LOS but still in the same plot
I hope you will help me in this.
G
# data
appendicitis <- tibble::tribble(
~drg, ~HAC, ~fy, ~variable, ~n, ~min, ~max, ~median, ~iqr, ~mean, ~sd, ~se, ~ci,
"G07A", "No", "FY23", "TotalAmount", 18L, 6183.31, 45712.1, 13648.705, 9378.748, 15971.993, 9961.483, 2347.944, 4953.729,
"G07A", "No", "FY23", "Revenue", 18L, 16409.21, 23549.27, 17341.87, 2543.158, 18305.757, 2127.115, 501.366, 1057.789,
"G07A", "No", "FY23", "LengthOfStay", 18L, 1.151, 7.756, 3.359, 2.43, 3.866, 1.811, 0.427, 0.901,
"G07A", "Yes", "FY23", "TotalAmount", 4L, 27620.41, 73944.01, 45659.025, 33327.578, 48220.618, 22505.973, 11252.987, 35812.026,
"G07A", "Yes", "FY23", "Revenue", 4L, 18880.28, 56790.64, 34602.445, 30623.757, 36218.952, 19378.046, 9689.023, 30834.795,
"G07A", "Yes", "FY23", "LengthOfStay", 4L, 9.078, 21.965, 14.783, 11.041, 15.152, 6.78, 3.39, 10.789
)
appendicitis
#> # A tibble: 6 × 13
#> drg HAC fy variable n min max median iqr mean sd
#> <chr> <chr> <chr> <chr> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 G07A No FY23 TotalAmount 18 6.18e3 4.57e4 1.36e4 9.38e3 1.60e4 9.96e3
#> 2 G07A No FY23 Revenue 18 1.64e4 2.35e4 1.73e4 2.54e3 1.83e4 2.13e3
#> 3 G07A No FY23 LengthOfStay 18 1.15e0 7.76e0 3.36e0 2.43e0 3.87e0 1.81e0
#> 4 G07A Yes FY23 TotalAmount 4 2.76e4 7.39e4 4.57e4 3.33e4 4.82e4 2.25e4
#> 5 G07A Yes FY23 Revenue 4 1.89e4 5.68e4 3.46e4 3.06e4 3.62e4 1.94e4
#> 6 G07A Yes FY23 LengthOfStay 4 9.08e0 2.20e1 1.48e1 1.10e1 1.52e1 6.78e0
#> # ℹ 2 more variables: se <dbl>, ci <dbl>
# drg = diagnosis related group
# HAC = Hospital Acquired Complications
# fy = financial year
# TotalAmount = cost
# Revenue = funding received
# LengthOfStay = hospital stay in days
# library
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(ggpubr)
#> Loading required package: ggplot2
library(ggh4x)
#> Warning: package 'ggh4x' was built under R version 4.3.3
appendicitis %>%
ggbarplot(x = 'drg', y = 'mean', fill = 'HAC',
position = position_dodge()) +
facet_nested(~variable + HAC)
Created on 2024-04-13 with reprex v2.1.0