Skip to content

Commit

Permalink
Merge pull request #52 from nutterb/new-latex-tables
Browse files Browse the repository at this point in the history
Upgrade to 0.7.0
  • Loading branch information
nutterb committed Apr 17, 2016
2 parents b008bdf + 4bd2b7f commit bf13431
Show file tree
Hide file tree
Showing 64 changed files with 3,950 additions and 1,569 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
^README-.*\.png$
^xtable_vs_pixiedust.html$
^xtable_vs_pixiedust.Rmd$
^\inst\save_sprinkles_rda.R$
51 changes: 27 additions & 24 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
Package: pixiedust
Date: 2016-01-08
Title: Tables so Beautifully Fine-Tuned You Will Believe It's Magic
Version: 0.6.1
Version: 0.7.0
Authors@R: person("Benjamin", "Nutter", email = "nutter@battelle.org", role = c("aut", "cre"))
Description: The introduction of the broom package has made converting model objects into data
frames as simple as a single function. While the broom package focuses on providing tidy
data frames that can be used in advanced analysis, it deliberately stops short of providing
functionality for reporting models in publication-ready tables. pixiedust provides this
functionality with a programming interface intended to be similar to ggplot2's system of
layers with fine tuned control over each cell of the table. Options for output include
printing to the console and to the common markdown formats (markdown, HTML, and LaTeX).
With a little pixiedust (and happy thoughts) tables can really fly.
Depends: R (>= 3.2.1)
Imports:
ArgumentCheck,
broom,
dplyr,
Hmisc (>= 3.14-6),
htmltools,
knitr,
lazyWeave,
magrittr,
stringr,
tidyr
Description: The introduction of the broom package has made converting model
objects into data frames as simple as a single function. While the broom
package focuses on providing tidy data frames that can be used in advanced
analysis, it deliberately stops short of providing functionality for reporting
models in publication-ready tables. pixiedust provides this functionality with
a programming interface intended to be similar to ggplot2's system of layers
with fine tuned control over each cell of the table. Options for output include
printing to the console and to the common markdown formats (markdown, HTML, and
LaTeX). With a little pixiedust (and happy thoughts) tables can really fly.
Depends:
R (>= 3.2.1)
Imports:
ArgumentCheck,
broom,
checkmate,
dplyr,
Hmisc (>= 3.14-6),
htmltools,
knitr,
lazyWeave,
magrittr,
stringr,
tidyr
Suggests:
rmarkdown,
testthat
rmarkdown,
testthat
License: MIT + file LICENSE
LazyData: true
VignetteBuilder: knitr
URL: https://github.com/nutterb/pixiedust
BugReports: https://github.com/nutterb/pixiedust/issues
RoxygenNote: 5.0.1
20 changes: 18 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
# Generated by roxygen2 (4.1.1): do not edit by hand
# Generated by roxygen2: do not edit by hand

S3method(as.data.frame,dust)
S3method(as.data.frame,dust_list)
S3method(dust,default)
S3method(dust,grouped_df)
S3method(dust,list)
S3method(print,dust)
S3method(print,dust_list)
S3method(redust,default)
S3method(redust,dust_list)
S3method(sprinkle,default)
S3method(sprinkle,dust_list)
S3method(sprinkle_colnames,default)
S3method(sprinkle_colnames,dust_list)
S3method(sprinkle_print_method,default)
S3method(sprinkle_print_method,dust_list)
S3method(sprinkle_table,default)
S3method(sprinkle_table,dust_list)
export("%<>%")
export("%>%")
export(dust)
export(get_pixie_count)
export(increment_pixie_count)
export(medley_all_borders)
export(medley_bw)
export(medley_model)
export(pixieply)
export(pvalString)
export(redust)
export(set_pixie_count)
Expand All @@ -17,7 +34,6 @@ export(sprinkle_colnames)
export(sprinkle_print_method)
export(sprinkle_table)
importFrom(ArgumentCheck,addError)
importFrom(ArgumentCheck,addMessage)
importFrom(ArgumentCheck,addWarning)
importFrom(ArgumentCheck,finishArgCheck)
importFrom(ArgumentCheck,match_arg)
Expand Down
48 changes: 48 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,51 @@
#### 0.7.0 (15 April 2016)
* Backward compatibility: The way `pixiedust` deals with
colors has changed. If you are using custom defined colors in your
LaTeX preamble, these will no longer work. `pixiedust` will only accept
colors names in `colors()`, or in the `rgb`, `rgba`, `#RRGGBB`, or
`#RRDDBBAA` formats. This only affects LaTeX output, and provides a
better interface for ensuring all HTML and LaTeX output are as similar
as possible.
* Added justification for tables. Use the `justify` argument in
`dust` and the `justify` sprinkle to move the table to the left,
or right side of the page. Defaults to centered.
* Added auto-detection of the print method. When a document is being
knit, the output format is read from `knitr::opts_knit$get("rmarkdown.pandoc.to")`.
If this resolves to `NULL`, the value of `getOption("pixiedust_print_method")`
is used.
* Added `docx` as a valid print method, which is synonymous with `markdown`.
* labels for HTML and LaTeX tables are automatically generated when
`label = NULL`. First, an attempt is made to generate a label from the
chunk label, and if that fails, a label is generated from `getOption("pixie_count")`
* Added default horizontal alignments for HTML tables
* Added default rounding for numerical values. If the user does not give a value,
the value of `getOption("digits")` is used. This effectively prints as many
decimal places as would be printed in the console.
* Sprinkle recycling is added with `recycle` argument.
* Fixed coordinate pairs is added with `fixed` argument.
* Added recognition of all colors in `colors()`

#### 0.6.3 (8 April 2016)
* Converted `dust`, `sprinkle` functions, and `print` to S3 methods.
This allows for lists of data frames to be processed as
separate tables.
* Added `dust.grouped_df` to give the option of ungrouping a
grouped_df object, or splitting it.
* Added the `bookdown` attribute (and sprinkle) to allow use with
the `bookdown` package.
* Added labeling.
* Added `caption`, `hhline`, and `float` as sprinkles.
* Changed the default colors for `bg_pattern` to "#FFFFFF#" and "#DDDDDD".
The gray in this pattern is a little lighter and should do better when
printed in black and white.

#### 0.6.2 (15 March 2016)
* Implemented a new printing method that makes use of the `hhline`
LaTeX package. This allows borders to be drawn over background
colors. In the existing method, the cell borders are hidden
by background colors. The hhline method can be used by setting
`options(pixiedust_latex_hhline = TRUE)`.

#### 0.6.1 (8 January 2016)
* Table Captions are now implemented.
* Added parameter to place LaTeX tables in a float environment. This was
Expand Down
14 changes: 12 additions & 2 deletions R/as.data.frame.dust.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' @name as.data.frame.dust
#'
#' @title Convert \code{dust} Object to Data Frame
#' @title Convert \code{dust} Object to Data Frame
#' @description Sprinkles are applied to the \code{dust} object
#' as if it were being prepared for printing to the console.
#' However, instead of printing, the object is returned
Expand Down Expand Up @@ -54,7 +54,7 @@ as.data.frame.dust <- function(x, ..., sprinkled = TRUE){

classes <- dplyr::group_by(x$body, col) %>%
dplyr::summarise(col_class = col_class[1])
classes <- paste0("as.", classes$col_class)
classes <- sprintf("as.%s", classes$col_class)

for (i in seq_along(X)){
X[[i]] <- get(classes[i])(X[[i]])
Expand All @@ -67,4 +67,14 @@ as.data.frame.dust <- function(x, ..., sprinkled = TRUE){

}

#' @rdname as.data.frame.dust
#' @export

as.data.frame.dust_list <- function(x, ...)
{
lapply(x,
as.data.frame.dust)
}


utils::globalVariables(c("value", "col_name", "col_class"))
51 changes: 51 additions & 0 deletions R/assert_match_arg.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#' @name assert_match_arg
#' @title Checkmate Compatible Version of \code{match.arg}
#'
#' @description Matches arguments as \code{match.arg} and returns
#' the value of the selected argument.
#'
#' @param x A character vecotr (of length one unless \code{several.ok} is \code{TRUE}
#' or \code{NULL}.
#' @param choices A character vector of candidate values
#' @param several_ok logical specifying if \code{arg} should be allowed to have more
#' than one element.
#' @param .var.name \code{character(1)}, name of the checked object to print in
#' assertions. Defaults to the heuristic implemented in
#' \code{\link[checkmate]{vname}}
#' @param add \code{AssertCollection}, Colleciton to store assertion messages.
#' See \code{link[checkmate]{AssertCollection}}.
#' @param ... Additional arguments to pass to either
#' \code{\link[checkmate]{assertChoice}} or \code{\link[checkmate]{assertSubset}}.
#' \code{assertChoice} is used when \code{several_ok = FALSE}, otherwise
#' \code{assertSubset} is used.
#'
#' @seealso \code{\link{match.arg}}, \code{\link[checkmate]{assertChoice}},
#' \code{\link[checkmate]{assertSubset}}

assert_match_arg <- function(x, choices, several_ok = FALSE,
.var.name = checkmate::vname(x), add = NULL)
{
if (identical(x, choices))
if (several_ok) return(x) else return(x[1])

if (!several_ok)
{
if (!checkmate::checkCharacter(x, len = 1))
{
add$push(sprintf("Assertions on '%s' failed: must have length 1, but has length %s",
.var.name, length(x)))
#* If an AssertCollection is used, we want to mimic a failure
#* to find a match.
return(character(0))
}
}

x <- choices[pmatch(x, choices, nomatch = 0L, duplicates.ok = several_ok)]
if (several_ok) checkmate::assertSubset(x, choices, empty.ok = FALSE,
.var.name = .var.name, add = add)
else checkmate::assertChoice(x, choices,
.var.name = .var.name, add = add)
#* If a match(es) is found, return it. If no match is found
#* and an AssertCollection is used, return character(0)
x
}

0 comments on commit bf13431

Please sign in to comment.