knitr::opts_chunk$set( collapse = TRUE, comment = "#>", out.width = "100%" )
We are using the same example from the ezcox package vignette.
Load the package and data.
library(bregr) data <- survival::lung data <- data |> dplyr::mutate( ph.ecog = factor(ph.ecog), sex = ifelse(sex == 1, "Male", "Female") )
Construct grouped batch survival models to determine if the variable ph.ecog
has different survival effects under different sex groups.
mds <- br_pipeline( data, y = c("time", "status"), x = "ph.ecog", group_by = "sex", method = "coxph" )
We can examine the constructed models.
br_get_models(mds)
Now, display the results using a forest plot.
br_show_forest(mds)
We can optimize the plot for better visualization, for example, by removing the second column of the table and eliminating the row with NA
results.
br_show_forest( mds, drop = 2, subset = !(Group_variable == "2" & variable == "ph.ecog" & label == 3) )
To subset the data rows, we can input an R expression using variables from br_get_results(mds)
. For example, we can use Group_variable == "Female" & variable == "ph.ecog" & label == 3
to locate the row we want to remove, and then use !()
to select the negated rows.
If drop All
group is necessary, update the subset
with:
br_show_forest( mds, drop = 2, subset = !((Group_variable == "Female" & variable == "ph.ecog" & label == 3) | (Group_variable == "All")) )
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.