Skip to content

Commit

Permalink
prepare deprecating pander.return and pander.option
Browse files Browse the repository at this point in the history
  • Loading branch information
daroczig committed May 16, 2015
1 parent 87e29b4 commit cad58db
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 10 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export(pander)
export(pander.option)
export(pander.return)
export(panderOptions)
export(pander_return)
export(pandoc.date)
export(pandoc.date.return)
export(pandoc.emphasis)
Expand Down
29 changes: 20 additions & 9 deletions R/S3.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,26 @@ pander <- function(x = NULL, ...) {
}


#' Pander and capture output
#' Deprecated pander_return
#'
#' This is a wrapper function around \code{pander} but instead of printing to \code{stdout}, this function returns a character vector of the captured lines.
#' @param ... everything passed to \code{pander}
#' @export pander.return
#' @usage pander.return(...)
#' @seealso pander
pander.return <- function(...)
pander.return <- function(...) {
.Deprecated('pander_return')
capture.output(pander(...))
}


#' Pander and capture output
#'
#' This is a wrapper function around \code{pander} but instead of printing to \code{stdout}, this function returns a character vector of the captured lines.
#' @param ... everything passed to \code{pander}
#' @export
#' @seealso pander
pander_return <- function(...)
capture.output(pander(...))


Expand Down Expand Up @@ -1543,9 +1555,9 @@ pander.function <- function(x, add.name = FALSE, verbatim = TRUE, syntax.highlig
#' s[even] <- sprintf("(%s)", s[even])
#' s
#' }
#' tab <- tabular( Justify(c)*Heading()*z*Sex*Heading(Statistic)*Format(fmt())*(mean+sd)
#' tab <- tabular( Justify(c)*Heading()*z*Sex*Heading(Statistic)*Format(fmt())*(mean+sd)
#' ~ Status )
#' pander(tab, emphasize.rownames = FALSE)
#' pander(tab, emphasize.rownames = FALSE)
pander.tabular <- function(x, caption = attr(x, 'caption'), emphasize.rownames = TRUE, digits = panderOptions('digits'), ...) {
if (is.null(caption) & !is.null(storage$caption))
caption <- get.caption()
Expand All @@ -1557,17 +1569,16 @@ pander.tabular <- function(x, caption = attr(x, 'caption'), emphasize.rownames =
if (!is.null(colnames(rlabels))) { # needed for case of more complex tabular structure (see examples)
cl <- colnames(rlabels)
data <- cbind(rlabels, data)
clabels <- cbind(rbind(matrix("",
nrow = (nrow(clabels) - 1),
clabels <- cbind(rbind(matrix("",
nrow = (nrow(clabels) - 1),
ncol = length(cl)),
colnames(rlabels)),
colnames(rlabels)),
clabels)
}
}
clabels <- apply(clabels, c(2), paste, collapse = "\\ \n")
colnames(data) <- clabels
if (emphasize.rownames)
pandoc.table(data, caption = caption, keep.line.breaks = TRUE, emphasize.cols = 1:length(cl), ...)
else
pandoc.table(data, caption = caption, keep.line.breaks = TRUE, ...)
}

1 change: 1 addition & 0 deletions R/options.R
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ panderOptions <- function(o, value) {
#' @export pander.option
#' @seealso panderOptions
pander.option <- function(x, ...) {
.Deprecated('panderOptions')
mc <- match.call(panderOptions)
mc[[1]] <- quote(panderOptions)
eval(mc)
Expand Down
2 changes: 1 addition & 1 deletion man/pander.return.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
% Please edit documentation in R/S3.R
\name{pander.return}
\alias{pander.return}
\title{Pander and capture output}
\title{Deprecated pander_return}
\usage{
pander.return(...)
}
Expand Down
18 changes: 18 additions & 0 deletions man/pander_return.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/S3.R
\name{pander_return}
\alias{pander_return}
\title{Pander and capture output}
\usage{
pander_return(...)
}
\arguments{
\item{...}{everything passed to \code{pander}}
}
\description{
This is a wrapper function around \code{pander} but instead of printing to \code{stdout}, this function returns a character vector of the captured lines.
}
\seealso{
pander
}

0 comments on commit cad58db

Please sign in to comment.