Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #110 #111

Merged
merged 2 commits into from
Jan 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions R/ggcoxfunctional.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ ggcoxfunctional <- function (formula, data, iter = 0, f = 0.6,

#' @param x an object of class ggcoxfunctional
#' @param ... further arguments passed to print, but really it's unused
#' @param newpage open a new page. See \code{\link{grid.arrange}}.
#' @method print ggcoxfunctional
#' @rdname ggcoxfunctional
#' @export
print.ggcoxfunctional <- function(x, ...){
print.ggcoxfunctional <- function(x, ..., newpage = TRUE){
if(!inherits(x, "ggcoxfunctional"))
stop("An object of class ggcoxfunctional is required.")
plots <- x
Expand All @@ -111,6 +112,6 @@ print.ggcoxfunctional <- function(x, ...){
grobs[[i]]$widths[2:5] <- as.list(maxwidth)
}
y.text <- attr(plots, "y.text")
do.call(gridExtra::grid.arrange, c(grobs, left = y.text))
do.call(gridExtra::grid.arrange, c(grobs, left = y.text, newpage = newpage))
}

5 changes: 3 additions & 2 deletions R/ggcoxzph.R
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,11 @@ ggcoxzph <- function (fit, resid = TRUE, se = TRUE, df = 4, nsmo = 40, var,

#' @param x an object of class ggcoxzph
#' @param ... further arguments passed to print, but really it's unused
#' @param newpage open a new page. See \code{\link{grid.arrange}}.
#' @method print ggcoxzph
#' @rdname ggcoxzph
#' @export
print.ggcoxzph <- function(x, ...){
print.ggcoxzph <- function(x, ..., newpage = TRUE){
if(!inherits(x, "ggcoxzph"))
stop("An object of class ggcoxzph is required.")
plots <- x
Expand All @@ -173,6 +174,6 @@ print.ggcoxzph <- function(x, ...){

if(!is.null(pval)) main <- paste0("Global Schoenfeld Test p: ", signif(pval, 4), "\n")
else main <- NULL
do.call(gridExtra::grid.arrange, c(grobs, top = main))
do.call(gridExtra::grid.arrange, c(grobs, top = main, newpage = newpage))
}

5 changes: 3 additions & 2 deletions R/ggsurvplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,11 @@ ggsurvplot <- function(fit, fun = NULL,
}

#' @param x an object of class ggsurvplot
#' @param newpage open a new page. See \code{\link{grid.arrange}}.
#' @method print ggsurvplot
#' @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){
if(!inherits(x, "ggsurvplot"))
stop("An object of class ggsurvplot is required.")

Expand Down Expand Up @@ -581,7 +582,7 @@ print.ggsurvplot <- function(x, surv.plot.height = NULL, risk.table.height = NUL
for (i in 1:length(grobs)) {
grobs[[i]]$widths[2:5] <- as.list(maxwidth)
}
do.call(gridExtra::grid.arrange, c(grobs, nrow = nplot, heights = heights ))
do.call(gridExtra::grid.arrange, c(grobs, nrow = nplot, heights = heights, newpage = newpage))
}
}

Expand Down
5 changes: 3 additions & 2 deletions R/surv_cutpoint.R
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,11 @@ plot.surv_cutpoint <- function(x, variables = NULL, ggtheme = theme_classic2(),
p
}

#' @param newpage open a new page. See \code{\link{grid.arrange}}.
#' @method print plot_surv_cutpoint
#' @rdname surv_cutpoint
#' @export
print.plot_surv_cutpoint <- function(x, ...){
print.plot_surv_cutpoint <- function(x, ..., newpage = TRUE){
if(!inherits(x, "plot_surv_cutpoint"))
stop("x must be an object of class plot_surv_cutpoint.")
x$distribution <- x$distribution + theme(legend.position = "none")+labs(x = NULL)
Expand All @@ -264,7 +265,7 @@ print.plot_surv_cutpoint <- function(x, ...){
cutpoint <- attr(x, "cutpoint")
main <- name <- attr(x, "name")
# main <- paste0(name,"- cutpoint: ", attr(x, "cutpoint"))
do.call(gridExtra::grid.arrange, c(grobs, top = main))
do.call(gridExtra::grid.arrange, c(grobs, top = main, newpage = newpage))
}


Expand Down
4 changes: 3 additions & 1 deletion man/ggcoxfunctional.Rd

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

4 changes: 3 additions & 1 deletion man/ggcoxzph.Rd

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

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.

4 changes: 3 additions & 1 deletion man/surv_cutpoint.Rd

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