I am trying to show a ggforest
plot, the plot gets rendered perfectly in r-studio but it does not show up in r-notebook.
Here is a reproducible example.
library(ggplot2)
library(survival)
library(survminer)
data("veteran")
cox = coxph(Surv(time, status) ~ karno+celltype, data = veteran)
ggforest(cox, data = veteran)
When I run the above code, it creates a plot in R-studio (r-script), but does not create any plot in r-notebook
> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Edit:
I looked at the definition of ggforest
and the last statement of that function is invisible(p)
where p
is a ggplot
object. Could that be somehow related to graph not showing up in the notebook. I also tried to write the same function without invisible(p)
but ran into errors as it could not find certain functions like .get_data()
and tidy()
.