Skip to content

Commit

Permalink
newpage argument added again in print.ggsurvplot() #110 #111
Browse files Browse the repository at this point in the history
  • Loading branch information
kassambara committed Feb 19, 2017
1 parent bcdc415 commit f22749d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

- The R package `maxstat` doesn't support very well an object of class `tbl_df`. To fix this issue, now, in the `surv_cutpoint()` function, the input data is systematically transformed into a standard data.frame format ([@MarcinKosinski, #104](https://github.com/kassambara/survminer/issues/104)).

- It's now possible to print the output of the survminer packages in a powerpoint created with the ReporteRs package. Thanks to ([@abossenbroek, #110](https://github.com/kassambara/survminer/issues/110)) and ([@zzawadz, #111](https://github.com/kassambara/survminer/issues/110)). For instance:
- It's now possible to print the output of the survminer packages in a powerpoint created with the ReporteRs package. You should use the argument *newpage = FALSE* in the `print()` function when printing the output in the powerpoint. Thanks to ([@abossenbroek, #110](https://github.com/kassambara/survminer/issues/110)) and ([@zzawadz, #111](https://github.com/kassambara/survminer/issues/111)). For instance:


```r
Expand All @@ -67,7 +67,7 @@ require(ReporteRs)
doc = pptx(title = "Survival plots")
doc = addSlide(doc, slide.layout = "Title and Content")
doc = addTitle(doc, "First try")
doc = addPlot(doc, function() print(survplot), vector.graphic = TRUE)
doc = addPlot(doc, function() print(survplot, newpage = FALSE), vector.graphic = TRUE)
writeDoc(doc, "test.pptx")
```

Expand Down
4 changes: 3 additions & 1 deletion R/ggsurvplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -635,13 +635,15 @@ ggsurvplot <- function(fit, data = NULL, fun = NULL,

#' @param x an object of class ggsurvplot
#' @method print ggsurvplot
#' @param newpage open a new page. See \code{\link{grid.arrange}}
#' @rdname ggsurvplot
#' @export
print.ggsurvplot <- function(x, surv.plot.height = NULL, risk.table.height = NULL, ncensor.plot.height = NULL, ...){
print.ggsurvplot <- function(x, surv.plot.height = NULL, risk.table.height = NULL, ncensor.plot.height = NULL, newpage = TRUE, ...){

res <- .build_ggsurvplot(x = x, surv.plot.height = surv.plot.height,
risk.table.height = risk.table.height,
ncensor.plot.height = ncensor.plot.height)
if(newpage) grid::grid.newpage()
grid::grid.draw(res)

}
Expand Down
5 changes: 4 additions & 1 deletion man/ggsurvplot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f22749d

Please sign in to comment.