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

Add byrow and layout_matrix parameters to arrange_ggsurvplot(). #347

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
20 changes: 14 additions & 6 deletions R/arrange_ggsurvplots.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@
#'@param x a list of ggsurvplots.
#'@param print logical value. If TRUE, the arranged plots are displayed.
#'@param title character vector specifying page title. Default is NA.
#'@param ncol,nrow the number of columns and rows, respectively.
#'@param risk.table.height the height of the risk table on the grid. Increase
#' the value when you have many strata. Default is 0.25. Ignored when
#' risk.table = FALSE.
#'@param ncol the number of columns.
#'@param nrow the number of rows.
#'@param byrow logical value. Whether to fill the plot matrix by rows, or by columns.
#' Default is FALSE (by columns).
#'@param layout_matrix optional layout matrix. If not specified, automatically
#' created from ncol, nrow, and byrow parameters.
#'@param surv.plot.height the height of the survival plot on the grid. Default
#' is 0.75. Ignored when risk.table = FALSE. \code{1-risk.table.height -
#' ncensor.plot.height} when \code{risk.table = TRUE} and \code{ncensor.plot =
#' TRUE}
#'@param risk.table.height the height of the risk table on the grid. Increase
#' the value when you have many strata. Default is 0.25. Ignored when
#' risk.table = FALSE.
#'@param ncensor.plot.height The height of the censor plot. Used when
#' \code{ncensor.plot = TRUE}.
#'@param ... not used
Expand Down Expand Up @@ -47,7 +52,9 @@
#'
#'@rdname arrange_ggsurvplots
#'@export
arrange_ggsurvplots <- function(x, print = TRUE, title = NA, ncol = 2, nrow = 1, surv.plot.height = NULL,
arrange_ggsurvplots <- function(x, print = TRUE, title = NA, ncol = 2, nrow = 1, byrow=FALSE,
layout_matrix = matrix(seq_len(nrow*ncol), nrow=nrow,
ncol=ncol, byrow=byrow), surv.plot.height = NULL,
risk.table.height = NULL, ncensor.plot.height = NULL, ...)
{

Expand All @@ -59,7 +66,8 @@ arrange_ggsurvplots <- function(x, print = TRUE, title = NA, ncol = 2, nrow = 1

# Arrange multiple ggsurvplots
survs <- do.call(gridExtra::marrangeGrob,
list(grobs = survs, ncol = ncol, nrow = nrow, top = title))
list(grobs = survs, ncol = ncol, nrow = nrow, byrow = byrow,
layout_matrix = layout_matrix, top = title))

if(print) print(survs)

Expand Down
12 changes: 11 additions & 1 deletion man/arrange_ggsurvplots.Rd

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