Skip to content

Instantly share code, notes, and snippets.

@jenniferthompson
Created February 15, 2018 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jenniferthompson/ce15a110532d78b949314fb936f6d264 to your computer and use it in GitHub Desktop.
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
---
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
```
@jenniferthompson
Copy link
Author

This seems to be unique to output: html_notebook; when I knit using output: html_document, I don't get the blank spaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment