Created
February 15, 2018 15:53
-
-
Save jenniferthompson/ce15a110532d78b949314fb936f6d264 to your computer and use it in GitHub Desktop.
Trying to figure out causes for blank spaces when using the survminer package
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "Testing survminer blank spaces" | |
output: html_notebook | |
--- | |
I'm getting a huge blank space when printing results from `ggsurvminer()`, as noted in [this StackOverflow post](https://stackoverflow.com/questions/42479112/survival-plots-with-survminer-blank-plot). Let's see if it does the same in a fresh session/other OS. | |
```{r} | |
library(survival) | |
library(survminer) | |
fit <- survfit(Surv(time, status) ~ sex, data = lung) | |
p <- ggsurvplot(fit, data = lung) | |
``` | |
```{r} | |
p | |
``` | |
Boo, getting the same thing. Let's try some options. | |
```{r, results = "asis"} | |
p | |
``` | |
```{r} | |
print(p, newpage = FALSE) | |
``` | |
```{r} | |
p$plot | |
``` | |
Just printing the plot is fine, but one of the benefits of `survminer` is that it creates lovely tables for N at risk. | |
```{r} | |
p2 <- ggsurvplot(fit, data = lung, risk.table = "nrisk_cumevents") | |
p2 | |
``` | |
Printing just the plot doesn't give me that nice table. | |
```{r} | |
p2$plot | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This seems to be unique to
output: html_notebook
; when I knit usingoutput: html_document
, I don't get the blank spaces.