[
  {
    "path": ".Rbuildignore",
    "content": "^CRAN-RELEASE$\n^.*\\.Rproj$\n^\\.Rproj\\.user$\n^\\.gitignore$\n^\\.travis.yml$\n^\\.travis\\.yml$\n^cran-comments.md$\n^README\\.Rmd$\n^README-.*\\.png$\n^xtable_vs_pixiedust.html$\n^xtable_vs_pixiedust.Rmd$\n^\\\\inst\\\\save_sprinkles_rda.R$\n^revdep$\n"
  },
  {
    "path": ".gitignore",
    "content": "# History files\n.Rhistory\n.Rapp.history\n\n# Example code in package build process\n*-Ex.R\n\n# RStudio files\n.Rproj.user/\n\n# produced vignettes\nvignettes/*.html\nvignettes/*.pdf\n.Rproj.user\n\n# comparisons document\nxtable_vs_pixiedust.html\nLaTeX_Table_Tests.pdf\n\n# Reverse Dependency check\n/revdep/*"
  },
  {
    "path": ".travis.yml",
    "content": "# Sample .travis.yml for R projects\n\nlanguage: r\nwarnings_are_errors: true\nsudo: setuid root\n\nenv:\n global:\n   - CRAN: http://cran.rstudio.com\n   - WARNINGS_ARE_ERRORS=1\n   - R_BUILD_ARGS=--no-manual\n   - R_CHECK_ARGS=--no-manual \n\nr_github_packages:\n  - Rexamine/stringi\n\nnotifications:\n  email:\n    on_success: change\n    on_failure: change\n\nr_github_packages:\n  - jimhester/covr\nafter_success:\n  - Rscript -e 'library(covr);coveralls()'\n"
  },
  {
    "path": "CRAN-RELEASE",
    "content": "This package was submitted to CRAN on 2021-01-15.\nOnce it is accepted, delete this file and tag the release (commit b38adae).\n"
  },
  {
    "path": "DESCRIPTION",
    "content": "Package: pixiedust\nTitle: Tables so Beautifully Fine-Tuned You Will Believe It's Magic\nVersion: 0.9.4\nAuthors@R: c(person(\"Benjamin\", \"Nutter\", email = \"benjamin.nutter@gmail.com\", role = c(\"aut\", \"cre\")),\n             person(\"David\", \"Kretch\", role = c(\"ctb\")))\nDescription: The introduction of the 'broom' package has made converting model\n    objects into data frames as simple as a single function. While the 'broom'\n    package focuses on providing tidy data frames that can be used in advanced\n    analysis, it deliberately stops short of providing functionality for reporting\n    models in publication-ready tables. 'pixiedust' provides this functionality with\n    a programming interface intended to be similar to 'ggplot2's system of layers\n    with fine tuned control over each cell of the table. Options for output include\n    printing to the console and to the common markdown formats (markdown, HTML, and\n    LaTeX). With a little 'pixiedust' (and happy thoughts) tables can really fly.\nDepends:\n    R (>= 3.1.2)\nImports:\n    broom,\n    checkmate (>= 1.8.0),\n    htmltools,\n    knitr,\n    labelVector,\n    magrittr,\n    reshape2,\n    scales\nSuggests:\n    dplyr,\n    rmarkdown,\n    testthat\nLicense: GPL (>= 2)\nLazyData: true\nVignetteBuilder: knitr\nURL: https://github.com/nutterb/pixiedust\nBugReports: https://github.com/nutterb/pixiedust/issues\nRoxygenNote: 7.2.3\nNeedsCompilation: no\n"
  },
  {
    "path": "NAMESPACE",
    "content": "# Generated by roxygen2: do not edit by hand\n\nS3method(as.data.frame,dust)\nS3method(as.data.frame,dust_list)\nS3method(dust,default)\nS3method(dust,grouped_df)\nS3method(dust,list)\nS3method(knit_print,dust)\nS3method(knit_print,dust_list)\nS3method(print,dust)\nS3method(print,dust_list)\nS3method(redust,default)\nS3method(redust,dust_list)\nS3method(sprinkle,default)\nS3method(sprinkle,dust_list)\nS3method(sprinkle_align,default)\nS3method(sprinkle_align,dust_list)\nS3method(sprinkle_bg,default)\nS3method(sprinkle_bg,dust_list)\nS3method(sprinkle_bg_pattern,default)\nS3method(sprinkle_bg_pattern,dust_list)\nS3method(sprinkle_bookdown,default)\nS3method(sprinkle_bookdown,dust_list)\nS3method(sprinkle_border,default)\nS3method(sprinkle_border,dust_list)\nS3method(sprinkle_border_collapse,default)\nS3method(sprinkle_border_collapse,dust_list)\nS3method(sprinkle_caption,default)\nS3method(sprinkle_caption,dust_list)\nS3method(sprinkle_caption_number,default)\nS3method(sprinkle_caption_number,dust_list)\nS3method(sprinkle_colnames,default)\nS3method(sprinkle_colnames,dust_list)\nS3method(sprinkle_discrete,default)\nS3method(sprinkle_discrete,dust_list)\nS3method(sprinkle_fixed_header,default)\nS3method(sprinkle_fixed_header,dust_list)\nS3method(sprinkle_float,default)\nS3method(sprinkle_float,dust_list)\nS3method(sprinkle_fn,default)\nS3method(sprinkle_fn,dust_list)\nS3method(sprinkle_font,default)\nS3method(sprinkle_font,dust_list)\nS3method(sprinkle_gradient,default)\nS3method(sprinkle_gradient,dust_list)\nS3method(sprinkle_height,default)\nS3method(sprinkle_height,dust_list)\nS3method(sprinkle_hhline,default)\nS3method(sprinkle_hhline,dust_list)\nS3method(sprinkle_html_preserve,default)\nS3method(sprinkle_html_preserve,dust_list)\nS3method(sprinkle_justify,default)\nS3method(sprinkle_justify,dust_list)\nS3method(sprinkle_label,default)\nS3method(sprinkle_label,dust_list)\nS3method(sprinkle_longtable,default)\nS3method(sprinkle_longtable,dust_list)\nS3method(sprinkle_merge,default)\nS3method(sprinkle_merge,dust_list)\nS3method(sprinkle_na_string,default)\nS3method(sprinkle_na_string,dust_list)\nS3method(sprinkle_pad,default)\nS3method(sprinkle_pad,dust_list)\nS3method(sprinkle_print_method,default)\nS3method(sprinkle_print_method,dust_list)\nS3method(sprinkle_replace,default)\nS3method(sprinkle_replace,dust_list)\nS3method(sprinkle_rotate_degree,default)\nS3method(sprinkle_rotate_degree,dust_list)\nS3method(sprinkle_round,default)\nS3method(sprinkle_round,dust_list)\nS3method(sprinkle_sanitize,default)\nS3method(sprinkle_sanitize,dust_list)\nS3method(sprinkle_tabcolsep,default)\nS3method(sprinkle_tabcolsep,dust_list)\nS3method(sprinkle_table,default)\nS3method(sprinkle_table,dust_list)\nS3method(sprinkle_width,default)\nS3method(sprinkle_width,dust_list)\nexport(\"%<>%\")\nexport(\"%>%\")\nexport(dust)\nexport(fixed_header_css)\nexport(gaze)\nexport(get_dust_part)\nexport(get_pixie_count)\nexport(increment_pixie_count)\nexport(is_valid_color)\nexport(is_valid_color_single)\nexport(medley_all_borders)\nexport(medley_bw)\nexport(medley_model)\nexport(pixiemap)\nexport(pixieply)\nexport(pvalString)\nexport(pval_string)\nexport(redust)\nexport(sanitize_latex)\nexport(set_pixie_count)\nexport(sprinkle)\nexport(sprinkle_align)\nexport(sprinkle_background)\nexport(sprinkle_bg)\nexport(sprinkle_bg_pattern)\nexport(sprinkle_bookdown)\nexport(sprinkle_border)\nexport(sprinkle_border_collapse)\nexport(sprinkle_caption)\nexport(sprinkle_caption_number)\nexport(sprinkle_colnames)\nexport(sprinkle_discrete)\nexport(sprinkle_fixed_header)\nexport(sprinkle_float)\nexport(sprinkle_fn)\nexport(sprinkle_font)\nexport(sprinkle_gradient)\nexport(sprinkle_height)\nexport(sprinkle_hhline)\nexport(sprinkle_html_preserve)\nexport(sprinkle_justify)\nexport(sprinkle_label)\nexport(sprinkle_longtable)\nexport(sprinkle_merge)\nexport(sprinkle_na_string)\nexport(sprinkle_pad)\nexport(sprinkle_print_method)\nexport(sprinkle_replace)\nexport(sprinkle_rotate_degree)\nexport(sprinkle_round)\nexport(sprinkle_sanitize)\nexport(sprinkle_tabcolsep)\nexport(sprinkle_table)\nexport(sprinkle_width)\nimportFrom(knitr,knit_print)\nimportFrom(magrittr,\"%<>%\")\nimportFrom(magrittr,\"%>%\")\n"
  },
  {
    "path": "NEWS",
    "content": "### 0.9.0 (2020-05-10)\n\n* Package now carries fewer dependencies.\n* No new features. \n* Note: There is no plan for further development of pixiedust. I consider this a usable and stable package. Maintenance will be limited to tasks necessary to retain current features and to remain on CRAN.\n\n### 0.8.4 (2018-06-29)\n\n* Added `gaze` function to produce model summaries side-by-side (#80)\n* Small adjustments to work with upcoming version of `broom`.\n\n### 0.8.3 (2018-03-22)\n\n* Repaired recycling in several sprinkles.  Sprinkles that permit more than \n  one value will return an error if given multiple values and \n  `recycle = \"none\"`. The user must explicitly designate if recycling \n  should be done over rows or columns.\n* Mapped \"slidy\" output to HTML.\n* Added several tests, bring test coverage up to 96%\n\n### 0.8.2 (2018-02-23)\n\n* Added `caption_number` sprinkle, allowing numbering of tables to be\n  turned off (#108)\n* Changed the license in order to redistribute code from the\n  `Hmisc` package.\n* Added `fixed_header` sprinkle. Allows HTML tables to have a fixed\n  header over a scrollable body.\n* Added lots of tests.\n* Added `knit_print` method to allow printing in Rmarkdown documents to \n  operate more smoothly (#96).\n* Fixed text wrapping around left and right justified HTML tables (#107)\n* Added tabcolsep argument to \\code{dust}\n\n### 0.8.0 (2017-08-26)\n\n* Backward Compatibility Break: the `border_collapse` argument was changed\n  to a character argument.  This allows the full options available in HTML.\n  The new default is `border_collapse = \"collapse\"`, which is the equivalent\n  of `border_collapse = TRUE`. Backward compatibility will be broken only\n  if the `border_collapse` argument was changed.\n* All sprinkles have individual functions to perform their specific task. Now\n  `sprinkle(bg = \"blue\")` may also be done via `sprinkle_bg(bg = 'blue')`. \n  Although this isn't a much of a change to the user, it makes infrastructure\n  changes possible that will make the codebase easier to support.\n* Added the `discrete` and `discrete_colors` sprinkles. (Issue #56)\n* Added the `gradient`, `gradient_n`, `gradient_cut`, and `gradient_colors`\n  sprinkles. (Issue #56)\n* Fix hexadecimal color transparency bug (Issue #66)\n* Added `get_dust_part` to assist with generation of custom headers and \n  footers (Issue #72)\n* Removed CSS styling for tables from the vignettes.  (Issue #69)\n* Reduced spacing between table and caption in the LaTeX `longtable` \n  environment.\n* Fixes to support dplyr 0.5.0 (thanks to David Kretch)\n* Better control over when to print to interactive environment viewer.\n  (Issue #88)\n\n### 0.7.5 (26 August 2016)\n* Add `pixiemap` for applying differing sprinkles across a `dust_list`\n* Add the argument `logical_rows` for dynamically locating rows to sprinkle\n* Include a link to the pixiedust webpage for documentation augmentation.\n\n### 0.7.4 (17 June 2016)\n* Guard against changes to `options()$scipen` (Issue #62)\n* Remove remaining use of `ArgumentCheck` and replace with `checkmate`\n\n#### 0.7.3 (10 June 2016)\n* Fixed rotation in HTML tables\n* Created a new argument for `print_dust_html` (Issue #57) to \n  give the user control over the amount of white space \n  following HTML tables.\n* The `replace` sprinkle is now applied during printing.  It \n  had been applied in `sprinkle`, which violated the philosophy\n  of not changing the content of the data frame until the last\n  possible moment.\n* Added some extra unit tests.\n\n#### 0.7.2 (19 May 2016)\n* Fixed the padding specification in HTML tables.\n\n#### 0.7.1 (4 May 2016)\n* the sprinkles `bg`, `border_color` and `font_color` now interpret\n  \"transparent\" as a valid color. In HTML, it is interpreted as \n  `\"rgba(255,255,255,0)\"`; in LaTeX it is interpreted as `\"\"`.\n* New Sprinkle: `sanitize`. Defaults to `FALSE` and replaces automatic\n  sanitization of text in LaTeX output via `Hmisc::latexTranslate`.\n  This is not backward compatible with 0.7.0, but _is_ consistent with\n  earlier versions of `pixiedust`.  You must opt in to sanitization now.\n* New Sprinkle: `sanitize_args`. Takes a list of arguments to pass \n  to `Hmisc::latexTranslate`, allowing sanitization to be extended to\n  character sets defined by the user.\n\n\n#### 0.7.0 (15 April 2016)\n* Backward compatibility: The way `pixiedust` deals with \n  colors has changed.  If you are using custom defined colors in your \n  LaTeX preamble, these will no longer work.  `pixiedust` will only accept\n  colors names in `colors()`, or in the `rgb`, `rgba`, `#RRGGBB`, or\n  `#RRDDBBAA` formats.  This only affects LaTeX output, and provides a \n  better interface for ensuring all HTML and LaTeX output are as similar\n  as possible.\n* Added justification for tables.  Use the `justify` argument in \n  `dust` and the `justify` sprinkle to move the table to the left,\n  or right side of the page.  Defaults to centered.\n* Added auto-detection of the print method.  When a document is being\n  knit, the output format is read from `knitr::opts_knit$get(\"rmarkdown.pandoc.to\")`.\n  If this resolves to `NULL`, the value of `getOption(\"pixiedust_print_method\")`\n  is used.\n* Added `docx` as a valid print method, which is synonymous with `markdown`.\n* labels for HTML and LaTeX tables are automatically generated when \n  `label = NULL`.  First, an attempt is made to generate a label from the \n  chunk label, and if that fails, a label is generated from `getOption(\"pixie_count\")`\n* Added default horizontal alignments for HTML tables\n* Added default rounding for numerical values. If the user does not give a value,\n  the value of `getOption(\"digits\")` is used. This effectively prints as many\n  decimal places as would be printed in the console.\n* Sprinkle recycling is added with `recycle` argument.\n* Fixed coordinate pairs is added with `fixed` argument.\n* Added recognition of all colors in `colors()`\n\n#### 0.6.3 (8 April 2016)\n* Converted `dust`, `sprinkle` functions, and `print` to S3 methods. \n  This allows for lists of data frames to be processed as \n  separate tables.\n* Added `dust.grouped_df` to give the option of ungrouping a \n  grouped_df object, or splitting it.\n* Added the `bookdown` attribute (and sprinkle) to allow use with \n  the `bookdown` package.\n* Added labeling.\n* Added `caption`, `hhline`, and `float` as sprinkles.\n* Changed the default colors for `bg_pattern` to \"#FFFFFF#\" and \"#DDDDDD\".\n  The gray in this pattern is a little lighter and should do better when \n  printed in black and white.\n\n#### 0.6.2 (15 March 2016)\n* Implemented a new printing method that makes use of the `hhline` \n  LaTeX package.  This allows borders to be drawn over background\n  colors.  In the existing method, the cell borders are hidden \n  by background colors.  The hhline method can be used by setting\n  `options(pixiedust_latex_hhline = TRUE)`.\n\n#### 0.6.1 (8 January 2016)\n* Table Captions are now implemented.\n* Added parameter to place LaTeX tables in a float environment.  This was \n  necessary to make table captions functional in non-longtable situations.\n\n#### 0.6.0 (09 December 2015)\n* LaTeX output is fully implemented\n* `tabrowsep` element was removed from the `dust` object since it apparently \n  isn't a real thing.\n* Implemented rotated text.\n* Pushed version to 0.6.0\n\n#### 0.5.6 (06 December 2015)\n* Finished the borders for LaTeX output.  This completes the baseline LaTeX output.\n\n#### 0.5.5 (04 December 2015)\n* Revamped the LateX output again, pretty much started over entirely.  But now\n  the only thing missing is cell borders, and my previous work will accommodate \n  those.\n* Added `tablewidth`, `tabcolsep`, and `tabrowsep` elements to the dust object.\n  `tablewidth` allows the user to define cell width in terms of a percentage of \n  the total expected table width.  Not really recommended, but at least preserves\n  some continuity between HTML and LaTeX output.\n* `tabcolsep` and `tabrowsep` control the distance between columns and rows in tables, \n  but this feature isn't yet implemented.\n* Documentation is lacking on `tablewidth`, `tabcolsep`, and `tabrowsep`\n\n#### 0.5.4 (10 November 2015)\n* Added the `font_family` sprinkle for HTML output\n\n#### 0.5.3 (5 November 2015)\n* Due to a great deal of difficulty getting the last couple of \n  features to play nicely, I decided to take a different \n  approach to the LaTeX output.  Most features are \n  available, but I have yet to include column widths, \n  column heights, or multirow output.\n* An option is added to the print method that \n  turns off the `knitr::asis_output` return.\n  The motivation behind this was to be able to \n  use the HTML code in shiny applications.\n\n#### 0.5.2 (4 November 2015)\n* Longtable support is added\n* Documentation on cell borders is up to date\n\n#### 0.5.1 (3 November 2015)\n* Cell borders.  Documentation still needs review.\n\n#### 0.5.0 (Change Log Highlights since last CRAN Release)\n* `pixiedust` no longer uses the `+` operator.  \n   Please use `%>%` instead.\n* Complete support for HTML tables is available.\n* Limited support for LaTeX tables is available.\n* New vignette: Advanced Magic.\n* Added the `replace` sprinkle to replace values in \n  table columns, rows, or cells.  \n* Added the `longtable` sprinkle: allows tables to \n  be printed in multiple sections.\n* Added the `na_string` sprinkle.\n* Added support for multirow headers and footers.\n* Added support for multicell output using the \n  `merge` sprinkle.\n* Added an option `glance_foot`, which places model\n  summary statistics in the foot of a table.\n* Added options for including variables labels and\n  more detailed descriptions of factors and levels.\n* Introduces \"medleys\", functions that can apply\n  multiple sprinkles to a `dust` object in a \n  single line.\n* Adds `as.data.frame.dust` method\n\n\n#### 0.4.3-0 (13 October 2015)\n* The majority of LaTeX sprinkles are available, with\n  the exception of borders, longtable, merging cells,\n  and rotated text.\n\n#### 0.4.2-0 (5 October 2015)\n* Added basic medleys\n* Adds as.data.frame.dust method. Closes Issue #33\n\n#### 0.4.1-0 (1 October 2015)\n* Started LaTeX Output\n\n#### 0.4.0-0 (25 September 2015)\n* Fixed a bug described in Issue #26\n* Changes to Advance Magic vignette use a linear model and\n  glance statistics for examples.\n\n#### 0.3.1-0 (18 September 2015)\n* Glance footer is implemented.  Vignettes need to be updated\n* Variable labels and levels are implemented (well ahead of\n  schedule!).  Vignettes need to be updated\n\n#### 0.3.0-0 (15 September 2015)\n* Multi-cell output for HTML is fully supported.\n* Data frame row names may be captured in the output with `dust` \n  argument `keep_rownames`\n* A new sprinkle is added.  `na_string` defaults to \"\", and controls how\n  `NA` is printed in tables.\n\n#### 0.2.0-1 (31 August 2015)\n* Multi-cell output is functional for HTML, Markdown, and Console output\n* A poor example is added to the `advancedMagic` vignette, but a better\n  example is really needed.\n\n#### 0.1.1-7 (17 August 2015)\n* Finished the Advanced Magic vignette, which serves as the tests for advanced\n  output since I haven't bothered to code a way to check the results directly.\n* Configure the repository for coveralls.\n* Adds `covr` and `Hmisc` to Suggests:\n\n#### 0.1.1-6 (12 August 2015)\n* Removed 'longtable' option from `print.dust` and made it a sprinkle. This\n  allows it to be used without having to explicitly call `print`.\n* Implemented longtable capacity.  Users may now break tables into multiple\n  divisions of either a default size (25 rows for console, markdown, or HTML)\n  or a user-specified number of rows.\n* Began an \"advanced magic\" vignette to demonstrate the capabilities of \n  longtable and eventually multicolumn and multirow support.  Similar \n  vignettes will be needed for console, markdown, and html output, though\n  not all of them will need to be bundled with the package.\n* Added the `roundSafe` helper function to allow rounding to succeed while\n  skipping true character values.\n\n#### 0.1.1-5 (11 August 2015)\n* Added the `longtable` option to `print.dust`.  Not yet active, but lays\n  the groundwork for multipage tables.\n* Added multirow headers and footers (but not interfoot)\n* Added the `redust` function for adding and/or switching table components.  For\n  example, adding a multirow header, or a foot.\n\n#### 0.1.1-4 (5 August 2015)\n* Added the `replace` sprinkle to replace values in table columns, rows, or cells.\n  This closes Issue #12\n\n#### 0.1.1-3 (4 August 2015)\n* Optimizations related to removing ifelse calls.  \n* Initial values for table attributes are now stored as \"\" instead of NA.\n  This increases the object size, but cuts down on the processing time.\n* Removed `object` element from the `dust` object. In Issue #13, matthieugomez\n  pointed out that very large models could create storage space problems. \n  There's no sense in keeping an extra copy of the model object.\n* Removed the `+.dust` method and rewrote the sprinkles as pipable functions.\n  This resolves Issue #8\n\n#### 0.1.1 (3 August 2015)\n* Added the necessary fields to DESCRIPTION to get the vignettes to build.\n\n#### 0.1.0 (1 August 2015)\n* CRAN checks are passed.  Prepared for release.\n\n#### 0.0.0-9 (31 July 2015)\n* Finished tests\n* Finished vignettes\n\n#### 0.0.0-8 (30 July 2015)\n* Finished HTML rendering\n* Adds pixiedust vignette\n* Removes old vignettes\n\n#### 0.0.0-7 (29 July 2015)\n* Replace nearly all dust bunny functions with `sprinkle`\n* Replace `dust_print_method` with `sprinkle_print_method`\n* Replace `dust_colnames` with `sprinkle_colnames`\n* It occurred to me as I studied the code base that instead\n  of rows and cols in the ... argument of the dust bunnies, \n  it made more sense to add the dust bunnies in ... with\n  formal arguments for row and col.  I also came up \n  with the idea of naming the package `pixiedust` and \n  sprinkling the dust around.  It sounded like fun so \n  let's hope CRAN lets me get away with it.\n* All functionality has been rewritten to support the\n  pixiedust paradigm, but new tests and vignettes need \n  to be written to confirm that it all works.\n* R CMD check has _NOT_ been run.\n\n#### 0.0.0-6 (28 July 2015)\n* Adds `dust_rotate_text`\n\n#### 0.0.0-5 (27 July 2015)\n* Adds `dust_cell_valign`\n* Adds `dust_border_collapse`\n* Adds `dust_table_border`\n* Adds `dust_cell_border`\n* Adds `dust_cell_padding`\n\n#### 0.0.0-4 (26 July 2015)\n* Improved the Dustbunnies vignette to use a color coded table indicating which \n  dust bunnies are planned, available, and functional for different printing \n  methods.\n* Dropped leading zeroes from the version number.\n* Adds `dust_font_color`, `dust_font_size`\n* Adds `dust_cell_height`, `dust_cell_width`\n\n#### 0.0.0-003 (25 July 2015)\n* Adds halign and valign attributes to `dust$obj`. valign is not yet implemented.\n* Adds `dust_cell_halign`\n* Adds `dust_head_halign`\n* Adds dustbunnies vignette\n* Removed the `col_names` attribute of the `dust` object and replaced it with the\n  `head` object.  The `head` object is a data frame holding the attributes of the\n  table header.\n* Renamed the `obj` attributes of the `dust` object to `body`.\n* Adds a lot of tests\n* Adds `dust_cell_bg` and `dust_bg_pattern`\n\n#### 0.0.0-002 (24 July 2015)\n* 'col_names` attribute is now named.  The names are the original \n  column names from the `broom` output.\n* Adds `dust_fn`\n* Adds `dust_bold`\n* Adds `dust_italic`\n* Adds `dust_print_format`\n* Imports knitr\n* Imports `lazyWeave::pvalString`\n\n\n#### 0.0.0-001 (23 July 2015)\n* Adds `dust` and `print.dust`.\n* Only the method for printing to the console is available.\n* `+.dust` added\n* `dust_colnames` added\n"
  },
  {
    "path": "R/as.data.frame.dust.R",
    "content": "#' @name as.data.frame.dust\n#' \n#' @title Convert \\code{dust} Object to Data Frame \n#' @description Sprinkles are applied to the \\code{dust} object\n#'   as if it were being prepared for printing to the console.\n#'   However, instead of printing, the object is returned \n#'   as a single data frame.\n#'   \n#' @param x A \\code{dust} object.\n#' @param ... Arguments to be passed to other methods.  Currently unused.\n#' @param sprinkled Logical.  If \\code{TRUE}, the sprinkles attached to the\n#'   \\code{dust} object are applied before returning the data frame. \n#'   Sprinkles are applied via the same mechanism that prints to the console,\n#'   so only sprinkles that are applicable to console output are used.\n#'   When \\code{FALSE}, \\code{pixiedust} attempts to reconstruct the \n#'   data frame (or tidied output from \\code{broom::tidy} \n#'   originally given to \\code{dust}.\n#' \n#' @details In its current state, this can be a fairly inefficient function\n#'   as the table, if the longtable option is in use, will be built in \n#'   a \\code{for} loop and bound together using \\code{rbind}.  This isn't \n#'   really intended for large tables, but may be of assistance when \n#'   there isn't a sprinkle that does what you want to do.  (You can \n#'   at least pull out the object as a data frame and do your own \n#'   post processing).\n#'   \n#' @author Benjamin Nutter\n#' \n#' @section Functional Requirements: \n#' \\enumerate{\n#'  \\item Accepts an object of class \\code{dust} or \\code{dust_list}\n#'  \\item Accepts a \\code{logical(1)} indicating if the sprinkles should\n#'    be applied to the data.\n#'  \\item For a \\code{dust} object, returns an object of class \n#'    \\code{data.frame}\n#'  \\item For a \\code{dust_list} object, returns a list of objects of class\n#'    \\code{data.frame}\n#' }\n#' \n#' @examples \n#' fit <- lm(mpg ~ qsec + factor(am) + wt * factor(gear), data = mtcars)\n#' Dust <- dust(fit) %>%\n#'   sprinkle(cols = 2:4, round = 2) %>%\n#'   sprinkle(cols = 5, fn = quote(pvalString(value))) %>%\n#'   sprinkle(cols = 3, font_color = \"#DA70D6\") %>%\n#'   sprinkle_print_method(\"html\")\n#'   \n#' as.data.frame(Dust)\n#' \n#' @export\n\nas.data.frame.dust <- function(x, ..., sprinkled = TRUE)\n{\n  coll <- checkmate::makeAssertCollection()\n  \n  checkmate::assert_class(x = x,\n                          classes = \"dust\",\n                          add = coll)\n  \n  checkmate::assert_logical(x = sprinkled,\n                            len = 1,\n                            add = coll)\n  \n  checkmate::reportAssertions(coll)\n  \n  \n  if (sprinkled)\n  {\n    return(print_dust_console(x, return_df = TRUE))\n  }\n  else \n  {\n    X <- x$body[c(\"row\", \"col\", \"value\")]\n    X <- reshape2::dcast(X, \n                         formula = row ~ col, \n                         value.var = \"value\")\n    X <- X[!names(X) %in% \"row\"]\n\n    col_names <- tapply(X = x$body$col_name, \n                        INDEX = x$body$col, \n                        FUN = function(x) x[1])\n    \n    col_names <- unname(col_names)\n    names(X) <- col_names\n    \n    classes <- tapply(X = x$body$col_class, \n                      INDEX = x$body$col, \n                      FUN = function(x) x[1])\n    classes <- unname(classes)\n    classes <- sprintf(\"as.%s\", classes)\n    \n    for (i in seq_along(X)){\n      X[[i]] <- get(classes[i])(X[[i]])\n    }\n    \n    X\n  }\n  \n}\n\n#' @rdname as.data.frame.dust\n#' @export\n\nas.data.frame.dust_list <- function(x, ...)\n{\n  checkmate::assert_class(x = x,\n                          classes = \"dust_list\")\n  \n  lapply(x,\n         as.data.frame.dust,\n         ...)\n}\n"
  },
  {
    "path": "R/chain.R",
    "content": "#' @name %>%\n#' @rdname chain\n#' @importFrom magrittr %>%\n#' @export %>%\n#' @usage lhs \\%>\\% rhs\n#' \n#' @title magrittr forward-pipe operator\n#' @description Pipe an object forward into a function or call expression\n#'\n#' @param lhs,rhs A dataset and function to apply to it\n\nNULL\n\n#' @name %<>%\n#' @rdname compoundAssignment\n#' @importFrom magrittr %<>%\n#' @export %<>%\n#' @usage lhs \\%<>\\% rhs\n#' \n#' @title Chain together multiple operations\n#' @description Chain together multiple operations and save to the object\n#'   at the start of the chain.  See `magrittr` documentation for details.\n#'   \n#' @param lhs,rhs A data set and function to apply it to\n\nNULL\n"
  },
  {
    "path": "R/dust.R",
    "content": "#' @name dust\n#' @export dust\n#' \n#' @title Dust Table Construction\n#' @description Dust tables consist of four primary components that are \n#'   built together to create a full table.  Namely, the \\code{head}, the \n#'   \\code{body}, the \\code{interfoot}, and the \\code{foot}.  Dust tables \n#'   also contain a table-wide attributes \\code{border_collapse} and \n#'   \\code{longtable} as well as a \\code{print_method} element.\n#'   \n#' @param object An object that has a \\code{tidy} method in \\code{broom}\n#' @param tidy_df When \\code{object} is an object that inherits the \n#'   \\code{data.frame} class, the default behavior is to assume that the \n#'   object itself is the basis of the table.  If the summarized table is \n#'   desired, set to \\code{TRUE}.\n#' @param keep_rownames When \\code{tidy_df} is \\code{FALSE}, setting \n#'   \\code{keep_rownames} binds the row names to the data frame as the first\n#'   column, allowing them to be preserved in the tabulated output.  This \n#'   is only to data frame like objects, as the \\code{broom::tidy.matrix} method \n#'   performs this already.\n#' @param glance_foot Arrange the glance statistics for the \\code{foot} of the\n#'   table. (Not scheduled for implementation until version 0.4.0)\n#' @param glance_stats A character vector giving the names of the glance statistics\n#'   to put in the output.  When \\code{NULL}, the default, all of the available \n#'   statistics are retrieved.  In addition to controlling which statistics are \n#'   printed, this also controls the order in which they are printed.\n#' @param col_pairs An integer indicating the number of column-pairings for the \n#'   glance output.  This must be less than half the total number of columns,\n#'   as each column-pairing includes a statistic name and value. See the full\n#'   documentation for the unexported function \\code{\\link{glance_foot}}.\n#' @param byrow A logical, defaulting to \\code{FALSE}, that indicates if the \n#'   requested statistics are placed with priority to rows or columns.  \n#'   See the full documentation for the unexported function \\code{\\link{glance_foot}}.\n#' @param descriptors A character vector indicating the descriptors to\n#'   be used in the table.  Acceptable inputs are \\code{\"term\"}, \n#'   \\code{\"term_plain\"}, \\code{\"label\"}, \\code{\"level\"}, and \n#'   \\code{\"level_detail\"}.  These may be used in any combination and\n#'   any order, with the descriptors appearing in the table from left\n#'   to right in the order given.  The default, \\code{\"term\"}, returns\n#'   only the term descriptor and is identical to the output provided\n#'   by \\code{broom::tidy} methods.  See Details for a full explanation\n#'   of each option and the Examples for sample output.\n#'   See the full documentation for the unexported function \\code{\\link{tidy_levels_labels}}.\n#' @param numeric_level A character string that determines which descriptor\n#'   is used for numeric variables in the \\code{\"level_detail\"} descriptor\n#'   when a numeric has an interaction with a factor.  Acceptable inputs\n#'   are \\code{\"term\"}, \\code{\"term_plain\"}, and \\code{\"label\"}.\n#'   See the full documentation for the unexported function \\code{\\link{tidy_levels_labels}}.\n#' @param caption A character string giving the caption for the table.\n#' @param caption_number \\code{logical(1)}. Should the table caption be prefixed \n#'   with the table number?\n#' @param float A logical used only in LaTeX output.  When \\code{TRUE}, the table is \n#'   set within a \\code{table} environment.  The default is \\code{TRUE}, as with \n#'   \\code{xtable}.\n#' @param longtable Allows the user to print a table in multiple sections.  \n#'     This is useful when \n#'     a table has more rows than will fit on a printed page.  Acceptable inputs are \\code{FALSE},\n#'     indicating that only one table is printed (default); \\code{TRUE} that the table should be \n#'     split into multiple tables with the default number of rows per table (see \"Longtable\"); or a \n#'     positive integer indicating how many rows per table to include. All other values are \n#'     interpreted as \\code{FALSE}.  In LaTeX output, remember that after each section, a page \n#'     break is forced. This setting may also be set from \\code{sprinkle}. \n#' @param hhline Logical.  When \\code{FALSE}, the default, horizontal LaTeX cell borders \n#'   are drawn using the \\code{\\\\cline} command.  These don't necessarily \n#'   play well with cell backgrounds, however.  Using \\code{hhline = TRUE} \n#'   prints horizontal borders using the \\code{\\\\hhline} command.  While the \n#'   \\code{hhline} output isn't disrupted by cell backgrounds, it may require \n#'   more careful coding of the desired borders.  In \\code{hhline}, cells with \n#'   adjoining borders tend to double up and look thicker than when using \n#'   \\code{cline}.\n#' @param label \\code{character(1)}. An optional string for assigning labels with \n#'   which tables can be referenced elsewhere in the document.  If \\code{NULL}, \n#'   \\code{pixiedust} attempts to name the label \\code{tab:[chunk-name]}, where \n#'   \\code{[chunk-name]} is the name of the \\code{knitr} chunk.  If this also\n#'   resolves to \\code{NULL} (for instance, when you aren't using \\code{knitr}, \n#'   the label \\code{tab:pixie-[n]} is assigned, where \\code{[n]} is the current value \n#'   of \\code{options()$pixie_count}.  Note that rendering multiple tables in a \n#'   chunk without specifying a label will result in label conflicts.\n#' @param justify \\code{character(1)}. Specifies the justification of the table on \n#'   the page.  May be \\code{\"center\"} (default), \\code{\"left\"}, or \\code{\"right\"}.\n#' @param bookdown Logical. When \\code{TRUE}, \\code{bookdown} style labels are\n#'   generated.  Defaults to \\code{FALSE}.\n#' @param border_collapse \\code{character(1)}. One of \\code{\"collapse\"}, \n#'   \\code{\"separate\"}, \\code{\"initial\"}, or \\code{\"inherit\"}.\n#' @param tabcolsep \\code{integerish(1)}. For LaTeX output, the distance in \n#'   \\code{pt} between columns of the table.\n#' @param fixed_header \\code{logical(1)}. For HTML tables, should the \n#'   header rows be fixed in place over a scrollable body.\n#' @param html_preserve \\code{logical(1)}. When \\code{TRUE}, HTML output is returned\n#'   wrapped in \\code{htmltools::htmlPreserve}. If using LaTeX style equations in \n#'   an HTML table, it may be necessary to set this to \\code{FALSE}. Do this at\n#'   your own risk; this has not been thoroughly field tested.\n#' @param ... Additional arguments to pass to \\code{tidy}\n#' @param ungroup Used when a \\code{grouped_df} object is passed to \\code{dust}.\n#'   When \\code{TRUE} (the default), the object is ungrouped and dusted \n#'   as a single table. When \\code{FALSE}, the object is split and each element\n#'   is dusted separately.\n#' \n#' @details The \\code{head} object describes what each column of the table\n#'   represents.  By default, the head is a single row, but multi row headers\n#'   may be provided.  Note that multirow headers may not render in markdown\n#'   or console output as intended, though rendering in HTML and LaTeX is \n#'   fairly reliable. In longtables (tables broken over multiple pages), \n#'   the \\code{head} appears at the top of each table portion.\n#'   \n#'   The \\code{body} object gives the main body of information.  In long tables,\n#'   this section is broken into portions, ideally with one portion per page.\n#'   \n#'   The \\code{interfoot} object is an optional table to be placed at the \n#'   bottom of longtable portions with the exception of the last portion.  A \n#'   well designed \\code{interfoot} can convey to the user that the table \n#'   continues on the next page.\n#'   \n#'   The \\code{foot} object is the table that appears at the end of the \n#'   completed table.  For model objects, it is recommended that the \n#'   \\code{\\link[broom]{glance}} statistics be used to display model fit \n#'   statistics.\n#'   \n#'   The \\code{border_collapse} object applies to an entire HTML table.  It\n#'   indicates if the borders should form a single line or distinct lines.\n#'   \n#'   The \\code{longtable} object determines how many rows per page are printed.\n#'   By default, all content is printed as a single table.  Using the \n#'   \\code{longtable} argument in the \\code{\\link{sprinkle}} function can change this\n#'   setting.\n#'   \n#'   The \\code{table_width} element is specific to LaTeX tables.  This is a reference\n#'   value for when column widths are specified in terms of the \\code{\\%} units.  For\n#'   example, a column width of \\code{20\\%} will be defined as \\code{table_width * .20}.\n#'   The value in \\code{table_width} is assumed to be in inches and defaults to 6.\n#'   \n#'   The \\code{tabcolsep} object determines the spacing between columns in a \n#'   LaTeX table in pt.  By default, it is set at 6.\n#'   \n#'   The \\code{print_method} object determines how the table is rendered when \n#'   the \\code{print} method is invoked.  The default is to print to the \n#'   console.\n#'   \n#'   Many of these options may be set globally.  See \n#'   \\code{\\link{pixiedust}} for a complete list of package options.\n#'   \n#' @return Returns an object of class \\code{dust}\n#' \n#' @section Symbols and Greek Letters:\n#' When using markdown, math symbols and greek letters may be employed as \n#' they would within a markdown document.  For example, \\code{\"$\\alpha$\"}\n#' will render as the lower case Greek alpha.  Math symbols may be rendered\n#' in the same manner.\n#' \n#' @seealso \\code{\\link[broom]{tidy}} \\code{\\link{glance_foot}} \n#'   \\code{\\link{tidy_levels_labels}} \\code{\\link{pixiedust}}\n#' \n#' \\code{\\link{get_dust_part}} for extracting parts of the \\code{dust} object\n#' in order to build custom headers and/or footers.\n#' \n#' @author Benjamin Nutter\n#' \n#' @examples \n#' x <- dust(lm(mpg ~ qsec + factor(am), data = mtcars))\n#' x\n\ndust <- function(object, ...)\n{\n  UseMethod(\"dust\")\n}\n\n#' @rdname dust\n#' @export\ndust.default <- function(object, ..., \n                 tidy_df = FALSE, keep_rownames = FALSE,\n                 glance_foot = FALSE, glance_stats = NULL, \n                 col_pairs = 2, byrow = FALSE,\n                 descriptors = \"term\", \n                 numeric_level = c(\"term\", \"term_plain\", \"label\"),\n                 label = NULL,\n                 caption = NULL,\n                 caption_number = getOption(\"pixied_caption_number\", TRUE),\n                 justify = getOption(\"pixie_justify\", \"center\"),\n                 float = getOption(\"pixie_float\", TRUE),\n                 longtable = getOption(\"pixie_longtable\", FALSE),\n                 hhline = getOption(\"pixie_hhline\", FALSE),\n                 bookdown = getOption(\"pixie_bookdown\", FALSE),\n                 border_collapse = getOption(\"pixie_border_collapse\", \"collapse\"),\n                 tabcolsep = getOption(\"pixie_tabcolsep\", 6),\n                 fixed_header = getOption(\"pixie_fixed_header\", FALSE),\n                 html_preserve = getOption(\"pixie_html_preserve\", TRUE))\n{\n  coll <- checkmate::makeAssertCollection()\n  \n  descriptors <- checkmate::matchArg(x = descriptors,\n                                  choices = c(\"term\", \"term_plain\", \"label\",\n                                              \"level\", \"level_detail\"),\n                                  several.ok = TRUE,\n                                  add = coll)\n  \n  #* By default, we assume data.frame-like objects are to be printed\n  #* as given.  All other objects are tidied.\n  if (!inherits(object, \"data.frame\") | tidy_df)\n  {\n    tidy_object <- as.data.frame(broom::tidy(object, ...))\n  }\n  else if (inherits(object, \"data.frame\"))\n  {\n    if (inherits(object, \"data.table\"))\n    {\n      object <- as.data.frame(object)\n    }\n    if (keep_rownames)\n    {\n      tidy_object <- cbind(rownames(object), \n                           object)\n      rownames(tidy_object) <- NULL\n      tidy_object[, 1] <- as.character(tidy_object[, 1])\n      \n      names(tidy_object)[1] <- \".rownames\"\n    }\n    else\n    {\n      tidy_object <- object\n    }\n  }\n\n  if (!inherits(object, \"data.frame\") & any(!descriptors %in% \"term\"))\n  {\n    nms <- names(tidy_object)\n    \n    tll <- tidy_levels_labels(object,\n                              descriptors = descriptors,\n                              numeric_level = numeric_level,\n                              argcheck = coll) \n    tidy_object <- \n      merge(tidy_object, \n            tll, \n            by = \"term\", \n            all.x = TRUE)\n      \n     if (\"label\" %in% names(tidy_object))\n     {\n       is_intercept <- grepl(pattern = \"([(]|)Intercept([)]|)\", \n                             x = tidy_object[[\"term\"]])\n       \n       tidy_object[[\"label\"]][is_intercept] <- \n         tidy_object[[\"term\"]][is_intercept]\n     }\n\n    if (\"term_plain\" %in% names(tidy_object))\n    {\n      is_intercept <- grepl(pattern = \"([(]|)Intercept([)]|)\", \n                            x = tidy_object[[\"term\"]])\n      \n      tidy_object[[\"label\"]][is_intercept] <- \n        tidy_object[[\"term_plain\"]][is_intercept]\n    }\n\n    if (!\"term\" %in% descriptors)\n    {\n      nms <- nms[!nms %in% \"term\"]\n    }\n    \n    tidy_object <- tidy_object[unique(c(descriptors, nms))]\n  }\n\n  checkmate::reportAssertions(coll)\n\n  #* Create the table head\n  head <- as.data.frame(t(names(tidy_object)),\n                        stringsAsFactors=FALSE)\n \n  names(head) <- names(tidy_object)\n\n  if (glance_foot)\n  {\n    foot <- glance_foot(object,\n                        col_pairs = col_pairs,\n                        total_cols = ncol(tidy_object),\n                        glance_stats = glance_stats,\n                        byrow = byrow) %>%\n      component_table()\n  }\n  else \n  {\n    foot <- NULL\n  }\n\n  #* Eventually, by default, glance statistics will be inserted into\n  #* the 'foot' object.  Objects passed as data frames should not have\n  #* glance statistics by default.  Perhaps an option for glance_df should\n  #* be provided here.\n  \n  out <- structure(list(head = component_table(head, tidy_object),\n                 body = component_table(tidy_object),\n                 interfoot = NULL,\n                 foot = foot,\n                 border_collapse = border_collapse,\n                 caption = caption,\n                 caption_number = caption_number,\n                 label = label,\n                 justify = justify,\n                 float = float,\n                 longtable = longtable,\n                 table_width = 6,\n                 tabcolsep = tabcolsep,\n                 hhline = hhline,\n                 bookdown = bookdown,\n                 fixed_header = fixed_header,\n                 include_fixed_header_css = FALSE, #Flag for if fixed header CSS \n                                            #should be generated with the table\n                 fixed_header_param = \n                   list(\n                     fixed_header_class_name = \"pixie-fixed\",\n                     scroll_body_height = 300,\n                     scroll_body_height_units = \"px\",\n                     scroll_body_background_color = \"white\",\n                     fixed_header_height = 20,\n                     fixed_header_height_units = \"px\",\n                     fixed_header_text_height = 10,\n                     fixed_header_text_height_units = \"px\",\n                     fixed_header_background_color = \"white\"\n                   ),\n                 html_preserve = html_preserve,\n                 print_method = pixiedust_print_method()),\n            class = \"dust\")\n\n  out\n}\n\n#' @rdname dust\n#' @export\n\ndust.grouped_df <- function(object, ungroup = TRUE, ...)\n{\n  if (ungroup)\n  {\n    dust.default(as.data.frame(object), ...)\n  }\n  else\n  {\n    split_var <- attr(object, \"var\")\n    # dplyr 0.8.0 replaces the var attribute with groups attribute\n    if (is.null(split_var)){\n      split_var <- utils::head(names(attr(object, \"groups\")), -1)\n    }\n    object <- as.data.frame(object)\n    object <- split(object, object[, as.character(split_var)])\n    dust.list(object, ...)\n  }\n}\n\n#' @rdname dust\n#' @export\n\ndust.list <- function(object, ...)\n{\n  structure(\n    lapply(X = object, \n           FUN = dust, \n           ...),\n    class = \"dust_list\"\n  )\n}\n\n#***********************************************************\n#* Utilities\n\ncomponent_table <- function(tbl, object)\n{\n  #* Get the classes of each column in the data frame.\n  #* These will be needed later for the 'round' sprinkle.\n  if (missing(object)) object <- tbl\n  \n  Classes <- data.frame(col_name = colnames(object),\n                        col_class = vapply(X = object, \n                                           FUN = primaryClass, \n                                           FUN.VALUE = character(1)), \n                        stringsAsFactors = FALSE)\n  #* Initialize the table with row index, column index, and value\n  tab <- gather_tbl(tbl)\n\n  #* Initialize default values of table attributes\n  tab <-\n    merge(x = tab,\n          y = cell_attributes_frame(nrow(tbl), ncol(tbl)),\n          by = c(\"row\", \"col\"),\n          all.x = TRUE, \n          sort = FALSE)\n\n  #* Join with column classes\n  tab <- merge(x = tab,\n               y = Classes,\n               by = \"col_name\",\n               all.x = TRUE, \n               sort = FALSE)\n\n  return(tab)\n}\n\n#*********************************************\n\ngather_tbl <- function(tbl)\n{\n  tbl_name <- names(tbl)\n  #* Assign the row indices\n  tbl[[\"row\"]] <- seq_len(nrow(tbl))\n\n  \n  \n  tbl <- stats::reshape(data = as.data.frame(tbl), \n                        direction = \"long\", \n                        varying = list(names(tbl)[!names(tbl) %in% \"row\"]))\n  \n  names(tbl)[names(tbl) %in% \"time\"] <- \"col\"\n  names(tbl)[3] <- \"value\"\n  tbl <- tbl[names(tbl)[!names(tbl) %in% \"id\"]]\n\n    tbl$col_name <- factor(tbl$col, labels = tbl_name)\n  tbl$col <- as.numeric(tbl$col_name)\n  tbl$col_name <- as.character(tbl$col_name)\n  tbl$value <- as.character(tbl$value)\n\n  tbl\n}\n\n#*********************************************\n\ncell_attributes_frame <- function(nrow, ncol)\n{\n  frame <- \n    expand.grid(row = 1:nrow,\n                col = 1:ncol,\n                fn = NA,\n                round = \"\",\n                bold = FALSE,\n                italic = FALSE,\n                halign = \"\",\n                valign = \"\",\n                bg = \"\",\n                font_family = \"\",\n                font_color = \"\",\n                font_size = \"\",\n                font_size_units = \"\",\n                left_border = \"\",\n                right_border = \"\",\n                top_border = \"\",\n                bottom_border = \"\",\n                height = \"\",\n                height_units = \"\",\n                width = \"\",\n                width_units = \"\",\n                replace = NA,\n                rotate_degree = \"\",\n                sanitize = FALSE,\n                sanitize_args = \"\",\n                pad = \"\",\n                rowspan = 1L,\n                colspan = 1L,\n                na_string = NA,\n                stringsAsFactors=FALSE) \n  frame[[\"html_row\"]] <- frame[[\"row\"]]\n  frame[[\"html_col\"]] <- frame[[\"col\"]]\n  frame[[\"merge_rowval\"]] <- frame[[\"row\"]]\n  frame[[\"merge_colval\"]] <- frame[[\"col\"]]\n  frame[[\"merge\"]] <- FALSE\n  \n  frame\n}\n\n\nprimaryClass <- function(x)\n{\n  acceptedClasses <- c(\"integer\", \"double\", \"numeric\", \n                       \"character\", \"factor\", \"logical\")\n  class_vector <- class(x)\n  class_vector[class_vector %in% acceptedClasses][1]\n}\n\n"
  },
  {
    "path": "R/fixed_header_css.R",
    "content": "#' @name fixed_header_css\r\n#' @title Generate CSS Code for Fixed Header Tables\r\n#' \r\n#' @description Tables with a fixed header may be generated to permit the \r\n#'   headings to remain visible with the data.  The CSS is not difficult, \r\n#'   but it not-trivial and requires some coordination across a few \r\n#'   parts.  This functions standardizes the generation of the CSS code \r\n#'   using as few elements as possible.  Note that there is potential for\r\n#'   conflicts with existing CSS in this method.\r\n#'   \r\n#' @param scroll_body_height \\code{integerish(1)}. Sets the height of the scrollable\r\n#'   table body.\r\n#' @param scroll_body_height_units \\code{character(1)}. Determines the units for the\r\n#'   height of the scrollable table.  Defaults to \\code{\"px\"}.  Must be one\r\n#'   of \\code{c(\"px\", \"pt\", \"\\%\", \"em\")}.\r\n#' @param scroll_body_background_color \\code{character(1)}. The color of the background\r\n#'   of the body.  Must be a valid color.  It defaults to white, which may\r\n#'   override CSS settings provided by the user.  If this needs to be avoided,\r\n#'   you may use the \\code{\\link{fixed_header_css}} function to assist in\r\n#'   generating CSS code to use to define the CSS. See Avoiding CSS Conflicts.\r\n#' @param fixed_header_height \\code{integerish(1)}. Sets the height of the header\r\n#'   row.\r\n#' @param fixed_header_height_units \\code{character(1)}. Determines the units for the\r\n#'   height of the header row. Defaults to \\code{\"px\"}. Must be one of\r\n#'   \\code{c(\"px\", \"pt\", \"\\%\", \"em\")}.\r\n#' @param fixed_header_text_height \\code{numeric(1)}. Sets the height at which the\r\n#'   header text appears.  By default it is set to half of the header height.\r\n#'   This should be approximately centered, but you may alter this to get the\r\n#'   precise look you want.\r\n#' @param fixed_header_text_height_units \\code{character(1)}. Determines the units for\r\n#'   placing the header text.  Defaults to \\code{\"px\"}. Must be one of\r\n#'   \\code{c(\"px\", \"pt\", \"\\%\", \"em\")}.\r\n#' @param fixed_header_background_color \\code{character(1)}. Sets the background color for\r\n#'   the header row.  This defaults to white and may override the user's CSS\r\n#'   settings.  See Avoiding CSS Conflicts.\r\n#' @param fixed_header_class_name \\code{character(1)}. When \r\n#'   \\code{include_fixed_header_css = FALSE}, this\r\n#'   class name is used to reference CSS classes provided by the user to\r\n#'   format the table correctly.\r\n#' @param pretty \\code{logical(1)}. When \\code{TRUE}, the result is printed\r\n#'   to the console using \\code{cat}, making it easy to copy and paste the\r\n#'   code to another document.  When \\code{FALSE}, it is returned as a\r\n#'   character string.\r\n#'   \r\n#' @details CSS doesn't make this kind of table natural.  The solution to \r\n#'   generate the fixed headers used by \\code{pixiedust} is probably not the \r\n#'   best solution in terms of CSS design.  It is, however, the most conducive \r\n#'   to generating dynamically on the fly. \r\n#'   \r\n#'   The fixed header table requires nesting several HTML elements. \r\n#'   \\enumerate{\r\n#'    \\item a \\code{div} tag is used to control the alignment of the table\r\n#'    \\item a \\code{section} tag is used to set up the header row that remains fixed.\r\n#'    \\item a \\code{div} that sets the height of the scrollable body\r\n#'    \\item the \\code{table} tag establishes the actual table.\r\n#'    \\item The \\code{th} tags inside the table are set to full transparency and\r\n#'      the content of the headers is duplicated in a \\code{div} within the \r\n#'      \\code{th} tag to display the content.\r\n#'   }\r\n#'   \r\n#'   To accomplish these tasks, some CSS is exported with the table and placed\r\n#'   in the document immediately before the table.  Read further to understand\r\n#'   the conflicts that may arise if you are using custom CSS specifications \r\n#'   in your documents.\r\n#'\r\n#' @section Avoiding CSS Conflicts: \r\n#' Because of all of the shenanigans involved, exporting the CSS with the tables\r\n#' may result in conflicts with your custom CSS. Most importantly, any CSS\r\n#' you have applied to the \\code{th} or \\code{td} tags may be overwritten.\r\n#' If you are using custom CSS, you may want to consider using \r\n#' \\code{include_fixed_header_css = FALSE} and then utilizing \r\n#' \\code{\\link{fixed_header_css}} to generate CSS you can include in your \r\n#' CSS file to provide the fixed headers.  The code generated by \r\n#' \\code{fixed_header_css} ought to be placed before your definitions for\r\n#' \\code{td} and \\code{th}.  \r\n#' \r\n#' To get the same header design in the fixed table, you will want to modify \r\n#' the \\code{.th-pixie-fixed div} definition in the CSS to match your desired\r\n#' \\code{th} definition.\r\n#' \r\n#' The code produced by \\code{fixed_header_css} will include comments where\r\n#' there is potential for a CSS conflict.\r\n#'   \r\n#' @source Jonas Schubert Erlandsson. https://jsfiddle.net/dPixie/byB9d/3/\r\n#'   \r\n#' @section Functional Requirements:\r\n#' \\enumerate{\r\n#'  \\item If \\code{pretty = TRUE} print results to the console.\r\n#'  \\item If \\code{pretty = FALSE} Return a character string of length 1.\r\n#'  \\item Cast an error if \\code{scroll_body_height} is not \\code{integerish(1)}\r\n#'  \\item Cast an error if \\code{scroll_body_height_units} is not \\code{character(1)}\r\n#'  \\item Cast an error if \\code{scroll_body_background_color} is not \\code{character(1)}\r\n#'  \\item Cast an error if \\code{scroll_body_background_color} is not a valid color.\r\n#'  \\item Cast an error if \\code{fixed_header_height} is not \\code{integerish(1)}\r\n#'  \\item Cast an error if \\code{fixed_header_height_units} is not \\code{character(1)}\r\n#'  \\item Cast an error if \\code{fixed_header_text_height} is not \\code{numeric(1)}\r\n#'  \\item Cast an error if \\code{fixed_header_text_height_units} is not \\code{character(1)}\r\n#'  \\item Cast an error if \\code{fixed_header_background_color} is not \\code{character(1)}\r\n#'  \\item Cast an error if \\code{fixed_header_background_color} is not a valid color.\r\n#'  \\item Cast an error if \\code{pretty} is not \\code{logical(1)}\r\n#' }\r\n#'   \r\n#' @export\r\n\r\nfixed_header_css <- function(fixed_header_class_name = \"pixie-fixed\",\r\n                             scroll_body_height = 300,\r\n                             scroll_body_height_units = \"px\",\r\n                             scroll_body_background_color = \"white\",\r\n                             fixed_header_height = 20,\r\n                             fixed_header_height_units = \"px\",\r\n                             fixed_header_text_height = fixed_header_height / 2,\r\n                             fixed_header_text_height_units = \"px\",\r\n                             fixed_header_background_color = \"white\",\r\n                             pretty = TRUE)\r\n{\r\n  coll <- checkmate::makeAssertCollection()\r\n  \r\n  checkmate::assert_integerish(x = scroll_body_height,\r\n                               len = 1,\r\n                               add = coll)\r\n  \r\n  checkmate::assert_character(x = scroll_body_height_units,\r\n                              len = 1,\r\n                              add = coll)\r\n  \r\n  checkmate::assert_character(x = scroll_body_background_color,\r\n                              len = 1,\r\n                              add = coll)\r\n  \r\n  if (!any(is_valid_color(scroll_body_background_color))){\r\n    coll$push(\"'scroll_body_background_color' is not a valid color\")\r\n  }\r\n  \r\n  checkmate::assert_integerish(x = fixed_header_height,\r\n                               len = 1,\r\n                               add = coll)\r\n  \r\n  checkmate::assert_character(x = fixed_header_height_units,\r\n                              len = 1,\r\n                              add = coll)\r\n  \r\n  checkmate::assert_numeric(x = fixed_header_text_height,\r\n                            len = 1,\r\n                            add = coll)\r\n  \r\n  checkmate::assert_character(x = fixed_header_text_height_units,\r\n                              len = 1,\r\n                              add = coll)\r\n  \r\n  checkmate::assert_character(x = fixed_header_background_color,\r\n                              len = 1,\r\n                              add = coll)\r\n  \r\n  if (!any(is_valid_color(fixed_header_background_color))){\r\n    coll$push(\"'fixed_header_background_color' is not a valid color\")\r\n  }\r\n  \r\n  checkmate::assert_character(x = fixed_header_class_name,\r\n                              len = 1,\r\n                              add = coll)\r\n  \r\n  checkmate::assert_logical(x = pretty,\r\n                            len = 1, \r\n                            add = coll)\r\n  \r\n  checkmate::reportAssertions(coll)\r\n  \r\n  \r\n  \r\n  css <- \r\n    paste0(\"<style>\r\n.\", fixed_header_class_name, \"-section {\r\n  position: relative;\r\n  display: inline-block;\r\n  padding-top: \", fixed_header_height, fixed_header_height_units,\";\r\n  background:\", fixed_header_background_color, \"; <!-- need a color to make the header non-transparent -->\r\n              <!-- This is a potential CSS conflict -->\r\n}\r\n\r\n.\", fixed_header_class_name, \"-container {\r\n  overflow-y: auto;\r\n  height: \", scroll_body_height, scroll_body_height_units, \";  <!-- Sets the height of the scrollable table -->\r\n}\r\n\r\n.th-\", fixed_header_class_name, \"{\r\n  line-height: 0;\r\n  color: transparent; <!-- hide text of the header-->\r\n}\r\n\r\n\r\n.th-\", fixed_header_class_name, \" div{\r\n  position: absolute;\r\n  top: \", fixed_header_text_height, fixed_header_text_height_units, \";\r\n  color: black; <!-- the extra div makes the displayable header -->\r\n                <!-- This is a potential source of CSS Conflict -->\r\n}\r\n\r\n\r\n\r\nth:first-child div{\r\n  border: none;\r\n}\r\n\r\ntd, th {\r\n  background:white; <!-- Set the default background of the table to white.\r\n                         This can be overruled in the individual cells \r\n                         This is a potential source of CSS conflict -->\r\n}\r\n</style>\")\r\n  \r\n  if (pretty) cat(css)\r\n  else css\r\n}"
  },
  {
    "path": "R/gaze.R",
    "content": "#' @name gaze\n#' @title Mimic Stargazer Output to Display Multiple Models\n#' \n#' @description Tidy multiple models and display coefficients and \n#'   test statistics in a side-by-side format.\n#'   \n#' @param ... models to be tidied.  Arguments may be named or unnamed.\n#'   For named arguments, the model will be identfied by the argument \n#'   name; for unnamed arguments, the object name will be the identifier.\n#' @param include_glance \\code{logical(1)} Determines if \\code{glance} (fit)\n#'   statistics are displayed under the models.\n#' @param glance_vars \\code{character}. A vector of statistics returned by\n#'   \\code{glance} that are to be displayed for each model. Defaults are \n#'   subject to change in future versions.\n#' @param digits \\code{numeric(1)} The number of digits used for rounding.\n#' \n#' @details This function is still in development.  Significant stars \n#'   will be added in a future version. Note that function defaults may \n#'   be subject to change.\n#' \n#' @section Functional Requirements:\n#' \\enumerate{\n#'   \\item Return a data frame object\n#'   \\item Cast an error if \\code{include_glance} is not \\code{logical(1)}\n#'   \\item Cast an error if \\code{glance_vars} is not a \\code{character} \n#'     vector.\n#'   \\item Cast an error if \\code{digits} is not \\code{\"integerish(1)\"}.\n#' }\n#'\n#' @examples \n#' fit1 <- lm(mpg ~ qsec + am + wt + gear + factor(vs), data = mtcars)\n#' fit2 <- lm(mpg ~ am + wt + gear + factor(vs), data = mtcars)\n#' \n#' gaze(fit1, fit2)\n#' gaze(with_qsec = fit1, \n#'      without_qsec = fit2)\n#' gaze(fit1, fit2, include_glance = FALSE)\n#' gaze(fit1, fit2, glance_vars = c(\"AIC\", \"BIC\"))\n#' \n#' @export\n\ngaze <- function(..., include_glance = TRUE,\n                 glance_vars = c(\"adj.r.squared\", \"sigma\", \"AIC\"),\n                 digits = 3){\n  \n  coll <- checkmate::makeAssertCollection()\n  \n  checkmate::assert_logical(x = include_glance,\n                            len = 1,\n                            add = coll)\n  \n  checkmate::assert_character(x = glance_vars,\n                              add = coll)\n  \n  checkmate::assert_integerish(x = digits,\n                               len = 1,\n                               add = coll)\n  \n  checkmate::reportAssertions(coll)\n  \n  fits <- list(...)\n  if (is.null(names(fits))) names(fits) <- character(length(fits))\n  \n  # If a fit isn't named, use the object name\n  dots <- match.call(expand.dots = FALSE)$...\n  fit_names <- vapply(dots, deparse, character(1))\n  names(fits)[names(fits) == \"\"] <- fit_names[names(fits) == \"\"]\n\n  res <- prep_gaze_tidy(fits, names(fits), digits)\n  if (include_glance){\n    res <- rbind(res, \n                 prep_gaze_glance(fits, names(fits), glance_vars, digits))\n  }\n  res\n}\n\n\n# UNEXPORTED METHODS ------------------------------------------------\n\nprep_gaze_tidy <- function(fits, fit_names, digits){\n  res <- \n    mapply(\n      FUN = \n        function(fit, name)\n        {\n          data.frame(model = name,\n                     broom::tidy(fit),\n                     stringsAsFactors = FALSE)\n        },\n      fit = fits,\n      name = fit_names,\n      SIMPLIFY = FALSE\n    ) \n  \n  res <- do.call(\"rbind\", res)\n  \n  res <- res[c(\"model\", \"term\", \"estimate\", \"statistic\")]\n  res[[\"term\"]] <- factor(res[[\"term\"]], \n                          levels = unique(res[[\"term\"]]))\n  \n  res <-\n    stats::reshape(\n      data = res,\n      direction = \"long\",\n      varying = list(value = c(\"estimate\", \"statistic\")),\n      v.names = \"value\",\n      timevar = \"variable\",\n      times = c(\"estimate\", \"statistic\")\n    )\n  \n  rownames(res) <- NULL\n  \n  res[[\"value\"]] <- round(res[[\"value\"]], digits)\n  statistic_row <- res[[\"variable\"]] == \"statistic\"\n  res[[\"value\"]][statistic_row] <- \n    sprintf(\"(%s)\",\n            res[[\"value\"]][statistic_row])\n  \n  res <- \n    stats::reshape(\n      data = res[!names(res) %in% \"id\"],\n      direction = \"wide\",\n      v.names = \"value\",\n      idvar = c(\"term\", \"variable\"),\n      timevar = c(\"model\"))\n  \n  res <- res[order(res[[\"term\"]], res[[\"variable\"]]), ]\n  names(res) <- sub(\"^value\\\\.\", \"\", names(res))\n  res[!names(res) %in% \"variable\"]\n}\n\n\nprep_gaze_glance <- function(fits, fit_names, glance_vars, digits){\n  res <- \n    mapply(\n      FUN = \n        function(fit, name)\n        {\n          data.frame(model = name,\n                     broom::glance(fit),\n                     stringsAsFactors = FALSE)\n        },\n      fit = fits,\n      name = fit_names,\n      SIMPLIFY = FALSE\n    ) \n  \n  res <- do.call(\"rbind\", res)\n  res <- res[c(\"model\", glance_vars)]\n  \n  res <- \n    stats::reshape(\n      data = res,\n      direction = \"long\",\n      times = glance_vars,\n      varying = list(value = glance_vars)\n    )\n  \n  names(res)[2:3] <- c(\"term\", \"value\")\n  res[[\"value\"]] <- round(res[[\"value\"]], digits)\n  \n  \n  res <-\n    stats::reshape(\n      data = res[!names(res) %in% \"id\"],\n      direction = \"wide\",\n      v.names = \"value\",\n      idvar = c(\"term\"),\n      timevar = c(\"model\"))\n  \n  names(res) <- sub(\"^value\\\\.\", \"\", names(res))\n  rownames(res) <- NULL\n  res\n}\n"
  },
  {
    "path": "R/get_dust_part.R",
    "content": "#' @name get_dust_part\n#' @title Get a Portion of the Table Stored in a \\code{dust} Object\n# Documentation -----------------------------------------------------\n#' @description Making customized table headers and footers requires a\n#'   data frame be added to the \\code{dust} object that has the same\n#'   column dimension as the rest of the table.  In order to reduce the \n#'   inconvenience of counting columns, \\code{get_dust_part} extracts the \n#'   data frame portion currently in use.  This ensures the column dimension\n#'   is correct with the current values, and provides an object suitable\n#'   for editing.\n#'   \n#' @param x An object of class \\code{dust}\n#' @param part \\code{character(1)}, naming the part of the table to \n#'   retrieve.  May be one of \\code{\"head\"}, \\code{\"foot\"}, \\code{\"interfoot\"},\n#'   or \\code{\"body\"}.\n#'   \n#' @return an object of class \\code{data.frame}\n#' \n#' @section Functional Requirements:\n#' \\enumerate{\n#'   \\item Return, as a data frame, the part of the table requested in \\code{part}\n#'   \\item Cast an error if \\code{x} is not a \\code{dust} object.\n#'   \\item Cast an error if \\code{part} is not one of \\code{c(\"head\", \"foot\",\n#'     \"interfoot\", \"body\")}\n#' }\n#' \n#' @export\n\n# Function Definition -----------------------------------------------\nget_dust_part <- function(x, part = c(\"head\", \"foot\", \"interfoot\", \"body\"))\n{\n  \n# Argument Validations ----------------------------------------------\n  coll <- checkmate::makeAssertCollection()\n  \n  checkmate::assert_class(x = x,\n                          classes = \"dust\",\n                          add = coll)\n  \n  part <- \n    checkmate::matchArg(x = part,\n                        choices = c(\"head\", \"foot\", \"interfoot\", \"body\"),\n                        add = coll)\n  \n  checkmate::reportAssertions(coll)\n  \n# Functional Code ---------------------------------------------------\n  \n  if (!is.null(x[[part]]))\n  {\n    X <- x[[part]][c(\"row\", \"col\", \"value\")]\n    X <- stats::reshape(X, \n                 direction = \"wide\",\n                 timevar = \"col\",\n                 idvar = \"row\")\n    X <- X[-1]\n    names(X) <- unique(x[[part]][[\"col_name\"]])\n  }\n  else\n  {\n    col_names <- unique(x[[\"body\"]][[\"col_name\"]])\n    X <- matrix(nrow=0, \n                ncol=length(col_names)) \n    X <- data.frame(X)\n    names(X) <- col_names\n  }\n  \n  X\n}"
  },
  {
    "path": "R/glance_foot.R",
    "content": "#' @name glance_foot\n#' \n#' @title Prepare Glance Statistics for \\code{pixiedust} Table Footer\n#' @description Retrieves the \\code{broom::glance} output for a model object and \n#'   structures it into a table suitable to be placed in the footer.  By default,\n#'   the statistics are displayed in two column-pairings (see Details).  This \n#'   function is not exported but is documented to maintain clarity of its \n#'   behavior.  It is intended for use within \\code{dust}, but may be useful\n#'   elsewhere if used with caution.\n#'   \n#' @param fit A model object with a \\code{broom::glance} method.\n#' @param col_pairs An integer indicating the number of column-pairings for the \n#'   glance output.  This must be less than half the total number of columns,\n#'   as each column-pairing includes a statistic name and value.\n#' @param total_cols The total number of columns in the body of the pixiedust table\n#' @param glance_stats A character vector giving the names of the glance statistics\n#'   to put in the output.  When \\code{NULL}, the default, all of the available \n#'   statistics are retrieved.  In addition to controlling which statistics are \n#'   printed, this also controls the order in which they are printed.\n#' @param byrow A logical, defaulting to \\code{FALSE}, that indicates if the \n#'   requested statistics are placed with priority to rows or columns.  See Details.\n#'   \n#' @details Statistics are placed in column-pairings.  Each column pair consists of \n#'   two columns named \\code{stat_name_x} and \\code{stat_value_x}, where \\code{x} is \n#'   the integer index of the column pair.  The column-pairings are used to allow \n#'   the user to further customize the output, more-so than pasting the name and \n#'   value together would allow.  With this design, statistics can be rounded \n#'   differently by applying sprinkles to the resulting table.\n#'   \n#'   The total number of column-pairings must be less than or equal to half the \n#'   number of total columns.  This constraint prevents making glance tables that \n#'   have more columns than the model table it accompanies.  \n#'   \n#'   When the total number of column-parings is strictly less than half the total \n#'   number of columns, \"filler\" columns are placed between the column pairings.\n#'   As much as possible, the filler columns are placed evenly between the \n#'   column pairings, but when the number of filler columns is unequal between \n#'   column-pairings, there will be more space placed on the left side.  For example,\n#'   if a table has 7 columns and 3 column-pairings, the order of placement would be\n#'   column-pair-1, filler, column-pair-2, column-pair-3.  Since there was only room\n#'   for one column of filler, it was placed in the left most fill position.\n#'   \n#'   The \\code{byrow} arguments acts similarly to the \\code{byrow} argument in the\n#'   \\code{matrix} function, but defaults to \\code{FALSE}.  If four statistics are \n#'   requested and \\code{byrow = FALSE}, the left column-pair will have statistics \n#'   one and two, while the right column-pair will have statistics three and four.\n#'   If \\code{byrow = TRUE}, however, the left column-pair will have statistics\n#'   one and three, while the right column-pair will have statistics two and four.\n#'   \n#' @author Benjamin Nutter\n#' \n\nglance_foot <- function(fit, col_pairs, total_cols, \n                        glance_stats = NULL, byrow = FALSE){\n  #* col_pairs is less then half of total_cols\n  #* glance_stats are all found in names(tidy(fit))\n  \n  g <- broom::glance(fit)\n  \n  coll <- checkmate::makeAssertCollection()\n  \n  if (col_pairs > total_cols/2)\n  {\n    coll$push(\"'col_pairs' must be less than 'total_cols/2'\")\n  }\n  \n  if (is.null(glance_stats)) \n    glance_stats <- names(g)\n  else \n  {\n    invalid_stats <- glance_stats[!glance_stats %in% names(g)]\n    glance_stats <- glance_stats[glance_stats %in% names(g)]\n    if (length(invalid_stats) > 0)\n    {\n      warning(\"The following statistics were requested but are not \",\n              \"available for models of class \", \n              paste0(class(fit), collapse = \"; \"), \":\",\n              \"\\n    \", paste0(invalid_stats, collapse = \", \"))\n    }\n    \n    if (length(glance_stats) == 0)\n    {\n      coll$push(\n        sprintf(\"None of the statistics requested are available for models of class %s\", \n                paste0(class(fit), collapse = \"; \"))\n      )\n    }\n  }\n  \n  checkmate::reportAssertions(coll)\n  \n  g <- data.frame(.rownames = names(g[glance_stats]),\n                  unrowname.x. = unname(unlist(g[glance_stats][1, ])),\n                  stringsAsFactors = FALSE)\n  # return(g)\n  if (nrow(g) %% col_pairs > 0){\n    n_fill <- (col_pairs - nrow(g) %% col_pairs)\n    stat_fill <- data.frame(.rownames = rep(\"\", n_fill),\n                            x = rep(NA, n_fill),\n                            stringsAsFactors = FALSE)\n    g <- .rbind_internal(g, stat_fill)\n  }\n\n  g$col <- \n    if (byrow) rep(1:col_pairs, length.out = nrow(g))\n    else rep(1:col_pairs, each = nrow(g) / col_pairs)\n  g$col <- factor(g$col)\n\n  fill_cols <- total_cols - (col_pairs * 2)\n  fill_gaps <- col_pairs - 1\n  \n  cols_per_gap <- ceiling(fill_cols / fill_gaps)\n  total_fills <- fill_gaps * cols_per_gap\n  \n  fills_per_gap_times <- fill_cols %/% cols_per_gap\n  if (!is.finite(fills_per_gap_times)) fills_per_gap_times <- 0\n  fills_per_gap <- \n    c(rep(cols_per_gap, fills_per_gap_times),\n      fill_cols %% cols_per_gap)\n  fills_per_gap <- fills_per_gap[fills_per_gap > 0]\n  \n  Filler <- lapply(fills_per_gap,\n         build_fill,\n         rows = nrow(g) / col_pairs)\n  \n  G <- split(g, g$col)\n  \n  if (length(Filler) < length(G)) \n    Filler <- c(Filler, lapply(1:(length(G) - length(Filler)),\n                               function(i) NULL))\n  \n  G <- mapply(intersplice_fill,\n         G,\n         Filler,\n         SIMPLIFY = FALSE) \n  G <- do.call(\"cbind\", G)\n  \n  names(G) <- make.unique(names(G))\n  G\n\n}\n  \n\nbuild_fill <- function(fills_per_gap, rows){\n  if (is.na(fills_per_gap)) return(NULL)\n  Fills <- lapply(1:fills_per_gap,\n                  function(f)\n                    data.frame(fill = rep(\"\", rows),\n                               stringsAsFactors = FALSE)) \n  do.call(\"cbind\", Fills)\n}\n\nintersplice_fill <- function(G, Fill){\n  if (!is.null(Fill)) return(cbind(G[1:2], Fill))\n  else return(G[1:2])\n}\n"
  },
  {
    "path": "R/index_to_sprinkle.R",
    "content": "#' @name index_to_sprinkle\n#' @title Determine the Indices to Sprinkle\n#' \n#' @description The sprinkle methods accept the rows and columns that are\n#'   to be modified as matrix coordinates.  The \\code{dust} object stores\n#'   the table data in a long form.  The tabular coordinates are translated\n#'   into row indices using this function.\n#'   \n#' @param x An object of class \\code{dust}.\n#' @param rows Either a numeric vector of rows in the tabular object to be \n#'   modified or an object of class \\code{call}.  When a \\code{call}, \n#'   generated by \\code{quote(expression)}, the expression resolves to \n#'   a logical vector the same length as the number of rows in the table.\n#'   Sprinkles are applied to where the expression resolves to \\code{TRUE}.\n#' @param cols Either a numeric vector of columns in the tabular object to\n#'   be modified, or a character vector of column names. A mixture of \n#'   character and numeric indices is permissible.\n#' @param fixed \\code{logical(1)} indicating if the values in \\code{rows} and \n#'   \\code{cols} should be read as fixed coordinate pairs.  See Details.\n#' @param part \\code{character} string.  Specifies if the sprinkles are \n#'   being applied to the head, body, foot, or interfoot of the table. Partial\n#'   matching is supported.\n#' @param recycle \\code{character} string. Indicates how recycling is to be\n#'   performed.  Partial matching is supported. See Details.\n#' @param coll An optional \\code{AssertCollection} object. When \\code{NULL},\n#'   an \\code{AssertCollection} object will be created and reported within\n#'   the call to this function.  When not \\code{NULL}, any failed assertions\n#'   will be added to the object in reported in the function that called\n#'   \\code{index_to_sprinkle}.\n#'   \n#' @details When \\code{fixed = FALSE}, sprinkles are applied at the \n#'   intersection of \\code{rows} and \\code{cols}, meaning that the arguments \n#'   do not have to share the same length.  When \\code{fixed = TRUE}, they must\n#'   share the same length.\n#'   \n#'   The value of \\code{recycle} determines how sprinkles are \n#'   managed when the sprinkle input doesn't match the length of the region\n#'   to be sprinkled.  By default, recycling is turned off.  Recycling \n#'   may be performed across rows first (left to right, top to bottom), \n#'   or down columns first (top to bottom, left to right).  \\code{\"cols\"} \n#'   and \\code{\"columns\"} have the same effect. The two choices to specify \n#'   are motivated by the fact that I sometimes get confused about which\n#'   it should be. :)\n#'   \n#' @author Benjamin Nutter\n#' \n#' @seealso \\code{sprinkle}\n#' \n#' @section Functional Requirements:\n#' \\enumerate{\n#'  \\item Return the indices of the intersection of \\code{rows} and \\code{cols}\n#'  \\item If \\code{rows = NULL}, assume all rows.\n#'  \\item If \\code{rows} is an expression where no values resolve to \n#'    \\code{TRUE}, return \\code{x} unchanged.\n#'  \\item If any value in \\code{rows} is not a valid row in the table,\n#'    cast an error.\n#'  \\item If \\code{cols = NULL}, assume all columns.\n#'  \\item If any value in \\code{cols} does not identify a column in the table,\n#'    cast an error.\n#'  \\item If \\code{fixed = TRUE}, \\code{length(rows)} (or \\code{sum(rows),\n#'    if an expression}) and \\code{cols} must have the same length.\n#'  \\item Cast an error if \\code{fixed} is not a \\code{logical(1)}\n#'  \\item Cast an error if \\code{part} is not one of \\code{\"body\"}, \n#'    \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}.\n#' }\n#'   \n\nindex_to_sprinkle <- function(x, rows = NULL, cols = NULL, fixed = FALSE,\n                              part = c(\"body\", \"head\", \"foot\", \"interfoot\"),\n                              recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                              coll = NULL)\n{\n  report_here <- is.null(coll)\n  \n  if (report_here) coll <- checkmate::makeAssertCollection()\n\n# First pass at argument validation ---------------------------------\n  # The first pass validates the arguments are of the correct type.\n  # The second pass will validate characteristics that depend on \n  # the types being correct.\n  \n  checkmate::assert_class(x = x,\n                          classes = \"dust\",\n                          add = coll,\n                          .var.name = \"x\")\n  \n  if (!is.null(rows))\n  {\n    if (!is.numeric(rows) & !is.call(rows))\n    {\n      coll$push(\"`rows` must be either numeric or a call object (via `quote`)\")\n    }\n  }\n  \n  if (!is.null(cols))\n  {\n    if (!is.numeric(cols) & !is.character(cols))\n    {\n      coll$push(\"`cols` must be a numeric or character vector\")\n    }\n  }\n  \n  checkmate::assert_logical(x = fixed,\n                            len = 1,\n                            add = coll,\n                            .var.name = \"fixed\")\n  \n  part <- \n    checkmate::matchArg(x = part,\n                        choices = c(\"body\", \"head\", \"foot\", \n                                    \"interfoot\", \"table\"),\n                        add = coll,\n                        .var.name = \"part\")\n  \n  recycle <- \n    checkmate::matchArg(x = recycle,\n                        choices = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                        add = coll,\n                        .var.name = \"recycle\")\n  \n  if (report_here) checkmate::reportAssertions(coll)\n  else if (!length(part) | \n           !length(recycle) |\n           !checkmate::test_logical(x = fixed,\n                                    len = 1)) \n  {\n    # If there is no match for `part`, there is no need to proceed to \n    # the rest of the function.  If this function is called from \n    # another with a `coll` object, return to that function's execution\n    # and report the error there.\n    return(invisible(NULL))\n  }\n  \n# Second pass at argument validations -------------------------------\n\n  if (fixed)\n  {\n    if (length(rows) != length(cols))\n    {\n      coll$push(\"When `fixed = TRUE`, rows and cols must have the same length\")\n    }\n  }\n\n  if (is.null(rows)) rows <- unique(x[[part]][[\"row\"]])\n  \n  if (inherits(rows, \"class\"))\n  {\n    rows <- which(eval(rows))\n  }\n\n  invalid_row <- which(!rows %in% unique(x[[part]][[\"row\"]]))\n  if (length(invalid_row))\n  {\n    coll$push(sprintf(\"The following rows given are not valid row indices: %s\",\n                      paste0(rows[invalid_row], collapse = \", \")))\n  }\n\n  if (is.null(cols))\n  {\n    cols <- unique(x[[part]][[\"col\"]])\n  }\n  else\n  {\n    # The cols argument allows character and numeric values to be \n    # given simultaneously. This block matches the character values\n    # to numeric column indices\n    cols_num <- suppressWarnings(as.numeric(cols))\n    cols_num <- cols_num[!is.na(cols_num)]\n    \n    cols_str <- match(cols, \n                      unique(x[[\"head\"]][[\"col_name\"]]))\n    \n    # We don't want to restrict ourselves to just the unique \n    # columns if we are doing fixed coordinate pairs\n    if (!fixed) cols <- unique(c(cols_num, cols_str))\n    \n    cols <- cols[!is.na(cols)]\n  }\n\n  invalid_col <-  which(!cols %in% unique(x[[part]][[\"col\"]]))\n    \n  if (length(invalid_col))\n  {\n    coll$push(sprintf(\"The following columns given are not valid columns: %s\",\n                      paste0(cols[invalid_col], collapse = \", \")))\n  }\n  \n  if (report_here) checkmate::reportAssertions(coll)\n  \n  # There's no point in continuing if there are any errors by now\n  # We return a full vector of indices just to maintain the same input.\n  if (!coll$isEmpty()) return(1)\n  \n# Functional Code ---------------------------------------------------\n\n  # Determine the index order for recycling\n  \n  if (recycle == \"columns\")\n  {\n    recycle <- \"cols\"\n  }\n  \n  recycle_arrange <- \n    if (recycle == \"rows\")\n    {\n      c(\"row\", \"col\")\n    }\n    else\n    {\n      c(\"col\", \"row\")\n    }  \n  \n  # Determine and arrange the indices\n  \n  if (!fixed)\n  {\n    indices <- expand.grid(rows = rows,\n                           cols = cols)\n    indices$i <- rep(TRUE, nrow(indices))\n    \n    indices <- merge(x[[part]][c(\"row\", \"col\")], \n                     indices, \n                     by.x = c(\"col\", \"row\"), \n                     by.y = c(\"cols\", \"rows\"), \n                     all.x = TRUE)\n    \n    indices[[\"index\"]] <- seq_len(nrow(indices))\n\n    indices <- indices[do.call(\"order\", indices[recycle_arrange]), ]\n\n    indices[[\"i\"]][is.na(indices[[\"i\"]])] <- FALSE\n    indices <- indices[[\"index\"]][indices[[\"i\"]]]\n  }\n  else\n  {\n    indices <- \n      which(x[[part]][[\"row\"]] %in% rows & \n              x[[part]][[\"col\"]] %in% cols)\n  }\n\n  indices\n}\n"
  },
  {
    "path": "R/is_valid_color.R",
    "content": "#' @name is_valid_color\n#' @title Test a Character String For Pixiedust Recognized Color Format\n#' \n#' @description \\code{pixiedust} recognizes colors as dvips names, \n#'   \\code{rgb(R,G,B)}, \\code{rgba(R,G,B,A)}, \\code{#RRGGBB}, or \n#'   \\code{#RRGGBBAA}.  This code returns a logical indicating if \n#'   the given character strings are valid.\n#'   \n#' @param color A character vector of color names.\n#' \n#' @section Functional Requirements:\n#' \\enumerate{\n#'  \\item Returns a logical vector correctly identifying valid color formats.\n#'  \\item Casts an error if \\code{color} is not a character object.\n#' }\n#'   \n#' @export\n\nis_valid_color <- function(color){\n  \n  checkmate::assert_character(x = color)\n  \n  vapply(X = color,\n         FUN = is_valid_color_single,\n         FUN.VALUE = logical(1),\n         USE.NAMES = FALSE)\n  \n}\n\n#' @rdname is_valid_color\n#' @export\n  \nis_valid_color_single <- function(color)\n{\n  checkmate::assert_character(x = color,\n                              len = 1)\n  \n  color <- tolower(color)\n  color <- gsub(\"\\\\s\", \"\", color)\n  \n  regex_0_255 <- \"\\\\b([0-9]|[0-9][0-9]|0[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\\\b\"\n  regex_0_1 <- \",((\\\\.\\\\d+)?|0(\\\\.\\\\d+)?|1(\\\\.0+)?)[)]$\" \n  \n  regex_rgb <- sprintf(\"^rgb[(]%s[)]$\",\n                       paste0(rep(regex_0_255, 3), collapse = \",\"))\n  \n  regex_rgba <- sprintf(\"^rgba[(]%s%s$\",\n                        paste0(rep(regex_0_255, 3), collapse = \",\"),\n                        regex_0_1)\n  \n  regex_html <- \"^#[a-f0-9]{6}$\"\n  regex_html_alpha <- \"^#[a-f0-9]{8}$\"\n  \n  grepl(regex_rgb, color) | grepl(regex_rgba, color) | \n    grepl(regex_html, color) | grepl(regex_html_alpha, color) | \n    color %in% c(grDevices::colors(), \"transparent\")\n}\n"
  },
  {
    "path": "R/knit_print.dust.R",
    "content": "#' @name knit_print.dust\n#' @title \\code{knitr} Printing Function \n#' \n#' @description Custom printing functions for displaying \\code{dust} and \n#'   \\code{dust_list} objects in R Markdown documents.\n#'   \n#' @param x A dust object\n#' @param options A list of options received from the chunk options.\n#' @param ... Additional arguments to pass to other methods.\n#' \n#' @importFrom knitr knit_print\n#' @method knit_print dust\n#' @export\n\nknit_print.dust <- function(x, options, ...){\n  if (missing(options)) options <- list()\n  print.dust(x, \n             ..., \n             asis = TRUE, \n             interactive = is.null(options$results))\n}\n\n#' @rdname knit_print.dust\n#' @method knit_print dust_list\n#' @export\n\nknit_print.dust_list <- function(x, options, ...){\n  if (missing(options)) options <- list()\n  print.dust_list(x, \n                  ..., \n                  asis = TRUE,\n                  interactive = is.null(options$results))\n}"
  },
  {
    "path": "R/medley.R",
    "content": "#' @name medley\n#' \n#' @title Sprinkle Medleys\n#' @description \\code{pixiedust} can get to be pretty verbose if you are doing\n#'   a great deal of customization.  Sprinkle medleys can take out some of that\n#'   code by bundling much of the formatting sprinkling into a single function.\n#'   \n#'   \\code{pixiedust} comes with a couple very basic medleys that are mostly \n#'   for illustration of how to write medleys.  Once you get the hang of \n#'   sprinkling, you need only bundle your most common sprinkles into a \n#'   medley function of your own and cut down on some of the time \n#'   coding your most basic formatting.\n#'   \n#' @param x a \\code{dust} object.\n#' @param round A numerical value passed to the \\code{round} sprinkle.\n#' \n#' @author Benjamin Nutter\n#' \n#' @examples \n#' \\dontrun{\n#' fit <- lm(mpg ~ qsec + factor(am) + wt * factor(gear), data = mtcars)\n#' \n#' dust(fit) %>%\n#'   medley_bw() %>%\n#'   sprinkle_print_method(\"html\")\n#'   \n#' dust(fit, glance_foot = TRUE) %>%\n#'   medley_model() %>%\n#'   sprinkle_print_method(\"html\")\n#'   \n#' # Medleys are not generics and do not have methods.\n#' # Using a medley on a dust_list object requires pixieply\n#' \n#' library(dplyr)\n#' mtcars %>% \n#'   group_by(gear) %>% \n#'   dust(ungroup = FALSE) %>% \n#'   pixieply(medley_bw) %>% \n#'   sprinkle_print_method(\"html\")\n#' }\n#' \n\n#' @export\n\nmedley_bw <- function(x){\n  x %>%\n    sprinkle(rows = 1, border = \"top\", part = \"head\") %>%\n    sprinkle(rows = 1, border = \"top\", part = \"body\") %>%\n    sprinkle(rows = max(x$body$row), border = \"bottom\", part = \"body\")\n}\n\n#' @rdname medley\n#' @export\nmedley_model <- function(x, round = 2){\n  not_pval <- unique(x$body$col_name)\n  not_pval <- not_pval[!not_pval %in% \"p.value\"]\n  \n  x <- x %>%\n    #* Borders\n    sprinkle(rows = 1, border = \"top\", part = \"head\") %>%\n    sprinkle(rows = 1, border = \"top\", part = \"body\") %>%\n    sprinkle(rows = max(x$body$row), border = \"bottom\", part = \"body\") %>%\n    #* Rounding\n    sprinkle(cols = not_pval, round = round, part = \"body\") %>%\n    sprinkle(cols = \"p.value\", fn = quote(pvalString(value)))\n  \n  if (!is.null(x$foot)){\n    x <- x %>%\n      sprinkle(rows = max(x$foot$row), border = \"bottom\", part = \"foot\") %>%\n      sprinkle(round = round, na_string = \"\", part = \"foot\")\n  }\n  x\n}\n\n\n"
  },
  {
    "path": "R/medley_all_borders.R",
    "content": "#' @name medley_all_borders\n#' @title Apply Cell Borders to All Cells in a Region\n#' \n#' @description For most output, specifying a region of cells with borders\n#'   on all sides is as simple as giving the sprinkle \\code{border = \"all\"}.\n#'   In LaTeX output, however, this can result in thicker than expected \n#'   vertical borders.  This medley provides a LaTeX save approach to \n#'   drawing borders on all sides without getting the double vertical \n#'   border effect.\n#'   \n#' @param x An object of class dust \n#' @param rows The rows over which the borders are to be drawn.\n#' @param cols The cols over which the borders are to be drawn.\n#' @param horizontal Logical.  Toggles horizontal borders.\n#' @param vertical Logical. Toggles vertical borders\n#' @param part A character vector.  May contain any of \\code{\"body\", \n#'   \"head\", \"interfoot\", \"foot\", \"table\"}.  When any element is \n#'   \\code{\"table\"}, the borders are drawn in all parts of the table.\n#'   \n#' @author Benjamin Nutter\n#'   \n#' @export\n\nmedley_all_borders <- function(x, rows=NULL, cols=NULL, \n                               horizontal = TRUE, vertical = TRUE,\n                               part = \"body\")\n{\n  checkmate::assertClass(x, \n                         classes = \"dust\")\n  \n  part <- part <- \n    match.arg(part, \n              c(\"table\", \"head\", \"body\", \"interfoot\", \"foot\"),\n              several.ok = TRUE)\n  if (\"table\" %in% part)\n  {\n    part <- c(\"head\", \"body\", \"interfoot\", \"foot\")\n  }\n  \n  for (p in part)\n  {\n    if (!is.null(x[[p]]))\n    {\n      part_rows <- if (is.null(rows)) 1:max(x[[p]][[\"row\"]]) else rows\n      part_cols <- if (is.null(cols)) 1:max(x[[p]][[\"col\"]]) else cols\n      \n      x <- sprinkle(x, \n                    rows = part_rows,\n                    cols = part_cols,\n                    border = c(if (vertical) \"left\" else NULL, \n                               if (horizontal) \"bottom\" else NULL),\n                    part = p)\n      if (horizontal)\n      {\n        x <- sprinkle(x,\n                      rows = utils::head(part_rows, 1),\n                      cols = part_cols,\n                      border = \"top\",\n                      part = p)\n      }\n      if (vertical)\n      {\n        x <- sprinkle(x,\n                      rows = part_rows,\n                      cols = utils::tail(part_cols, 1),\n                      border = \"right\",\n                      part = p)\n      }\n    }\n  }\n  x\n}\n"
  },
  {
    "path": "R/perform_function.R",
    "content": "#* perform_function\n#* An internal function for dustpan\n#* applies the requested function.  \n#* Applying the function wasn't really straight forward because\n#* in dustpan$obj, all of the values are stored as \n#* character strings.  Handling the conversions has to\n#* be done with care to get things to format correctly\n\nperform_function <- function(obj)\n{\n  #* Determine which cells in the table have a function assigned.\n  have_fn <- which(!is.na(obj$fn))\n  \n  for (i in have_fn){\n    #* All of the elements in 'value' are stored as character \n    #* strings. The if clause allows numeric functions to be\n    #* performed.\n    if (obj$col_class[i] %in% c(\"double\", \"numeric\", \"integer\"))\n      value <- do.call(sprintf(\"as.%s\", obj$col_class[i]), \n                       list(obj$value[i]))\n    #* The else statement allows functions to act on character strings.\n    else value <- obj$value[i]\n      \n    res <- eval(parse(text = obj$fn[i]))\n    \n    obj$value[i] <- res\n    obj$col_class[i] <- primaryClass(res)\n  }\n  \n  obj\n}\n\n#*** roundSafe\n#* An internal function to perform rounding on dust objects.\n#* All values in a dust object are stored as character values, but some may\n#* represent numeric values.  The roundSafe function will skip true character\n#* values when attempting to round.\n\nroundSafe <- function(x, digits){\n  y <- suppressWarnings(as.numeric(x))\n  if (length(y[!is.na(y)]) == 0) return(x)\n  \n  y[!is.na(y)] <- round(y[!is.na(y)], digits[!is.na(y)])\n  x[!is.na(y)] <- y[!is.na(y)]\n  x\n}"
  },
  {
    "path": "R/pixie_count.R",
    "content": "#' @name pixie_count\n#' @title Access and manipulate table numbers counters\n#' \n#' @description While LaTeX provides the ability to automatically number tables, this \n#' functionality is not readily available with console, HTML, or Word output.  By \n#' keep track of the number of (captioned) tables, we can mimic the behavior of \n#' LaTeX tables to provide (mostly) consistent table numbering between formats.  The \n#' table numbering is stored in the \\code{pixie_count} option.\n#' \n#' @param value The value at which to set the pixie counter.\n#' @param increment The value to add to the current pixie count.  Defaults to 1.\n#' \n#' @details The pixie count is stored in the options and may also be accessed using\n#' \\code{getOption(\"pixie_count\")}.  \n#' \n#' \\code{get_pixie_count} returns the current value of the counter.\n#' \n#' \\code{set_pixie_count} sets the value to the user-specification.\n#' \n#' \\code{increment_pixie_count} increments the pixie count, usually by 1.  This is called\n#'   within \\code{print.dust} any time a \\code{dust} object has a caption.\n#'   \n#' @author Benjamin Nutter\n#' \n#' @source \n#' The concept for these functions is loosely based on a hook meant to work with \n#' \\code{knitr} to automatically number tables. \n#' http://stackoverflow.com/a/18672268/1017276\n#'   \n#' @export\n\nget_pixie_count <- function()\n{\n  getOption(\"pixie_count\")\n}\n\n#' @rdname pixie_count\n#' @export\n\nset_pixie_count <- function(value)\n{\n  checkmate::assertIntegerish(value)\n  options(pixie_count = as.integer(value))\n}\n\n#' @rdname pixie_count\n#' @export\n\nincrement_pixie_count <- function(increment = 1)\n{\n  checkmate::assertIntegerish(increment)\n  options(pixie_count = getOption(\"pixie_count\") + as.integer(increment))\n}"
  },
  {
    "path": "R/pixiedust-pkg.R",
    "content": "#' Tables So Beautifully Fine-Tuned You Will Believe It's Magic.\n#' \n#' The \\code{pixiedust} mission is to provide a user friendly \n#' and flexible interface by which report-quality tables may \n#' be rendered in multiple output formats.  Initially, \n#' \\code{pixiedust} will support markdown, HTML, and LaTeX\n#' formats, as well as methods for console output.\n#' \n#' The advantage of \\code{pixiedust} is that it gives you the\n#' control to alter the appearance of a table by as little \n#' as one cell at a time.  This fine-tuned control gives you\n#' enormous flexibility in how the final table looks with \n#' minimal pre and post processing.\n#' \n#' Additionally, \\code{pixiedust} is largely built on top \n#' of the \\code{broom} package, allowing for simple and \n#' fast generation of tables based on analytical results.\n#' \n#' The chief disadvantage of \\code{pixiedust} is that it \n#' can be extremely verbose.  If you are applying many\n#' customizations, you will find yourself writing a \n#' great deal of code.  \n#' \n#' @section Options: \n#' \n#' \\code{pixie_bookdown} determines if references and labels are \n#' managed using the \\code{bookdown} package methods.  This should be set \n#' to \\code{TRUE} if you are rendering documents via the \\code{bookdown} \n#' package.\n#' \n#' \\code{border_collapse} determines the settings for border styles in HTML\n#' tables.  The most common values are \\code{\"collapse\"} - which presses all\n#' of the borders between cells on top of each other - and \\code{\"separate\"} - \n#' which allows each cell to have its own, distinct border.  \n#' \n#' \\code{pixie_count} is used to manage table numbering in non-LaTeX tables.\n#' See \\code{\\link{set_pixie_count}} for methods to manipulate the numbering.\n#'\n#' \\code{pixie_discrete_pal } controls the colors for shading by discrete values.\n#'     \n#' \\code{pixie_float} determines if tables in LaTeX output are placed in \n#' floating environments.\n#' \n#' \\code{pixie_gradient_pal} controls the colors giving the\n#'    endpoints of the color scale on which to shade numeric values.\n#' \n#' \\code{pixie_hhline} determins if tables in LaTeX output use the \n#' \\code{hhline} package for constructing table cells.\n#' \n#' \\code{pixie_html_linebreak} controls the number of line breaks placed \n#' after a table in HTML output.\n#' \n#' \\code{pixie_interactive} Allows control over whether HTML and markdown \n#'   tables are printed to the viewer or to the document.\n#' \n#' \\code{pixie_justify} controls the positioning of the complete table in the\n#' document.  Note that \\code{\"none\"} renders the table to the left side of \n#' the page, and subsequent elements will appear below the table.  When using\n#' \\code{\"left\"}, subsequent elements will appear to the right of the table.\n#' When using \\code{\"right\"}, subsequent elements will appear to the left of \n#' the table.\n#' \n#' \\code{pixie_longtable} determines if the \\code{longtable} environment is \n#' used in LaTeX output.\n#' \n#' \\code{pixie_na_string} sets the default character set for replacing \n#' \\code{NA} values in tables.\n#' \n#' \\code{pixie_tabcolsep} determines the spacing placed between cells in \n#' LaTeX output.  \n#' \n#' \\code{pixiedust_print_method} Sets the default printing method for tables. \n#' When \\code{pixiedust} is being used with \\code{knitr} and \\code{rmarkdown},\n#' the default is the value of \\code{knitr::opts_knit$get(\"rmarkdown.pandoc.to\")},\n#' otherwise it is \\code{\"console\"} \n#'   \n#' @section Table-Valued Options:\n#' \\tabular{lll}{\n#'  Option Name          \\tab Default         \\tab Permissible Values        \\cr\n#'  \\code{pixie_bookdown} \\tab \\code{FALSE}   \\tab \\code{logical}            \\cr\n#'  \\code{pixie_border_collapse} \\tab \\code{\"collapse\"} \\tab \\code{collapse, separate, initial, inherit} \\cr\n#'  \\code{pixie_count}   \\tab 0               \\tab \\code{integer} like value  \\cr\n#'  \\code{pixie_float}   \\tab \\code{TRUE}     \\tab \\code{logical}               \\cr\n#'  \\code{pixie_hhline}  \\tab \\code{FALSE}    \\tab \\code{logical}             \\cr\n#'  \\code{pixie_html_linebreak} \\tab 2        \\tab \\code{integer} like value  \\cr\n#'  \\code{pixie_justify} \\tab \\code{\"center\"} \\tab \\code{center, none, left, right} \\cr\n#'  \\code{pixie_longtable} \\tab \\code{FALSE}  \\tab \\code{logical}             \\cr\n#'  \\code{pixie_tabcolsep} \\tab 6             \\tab \\code{integer} like value  \\cr\n#'  \\code{pixiedust_print_method} \\tab  \\tab \\code{console, html, latex, markdown, beamer}\n#' }\n#' \n#' \n#' @section Cell-Valued Options:\n#' \\tabular{lll}{\n#'  Option Name          \\tab Default         \\tab Permissible Values        \\cr\n#'  \\code{pixie_discrete_pal} \\tab \\code{scales::hue_pal()} \\tab \\code{character} of valid colors \\cr\n#'  \\code{pixie_gradient_pal} \\tab \\code{c(\"#132B43\", \"#56B1F7\")} \\tab \\code{character(2)} of valid colors \\cr\n#'  \\code{pixie_na_string} \\tab \\code{NA}            \\tab \\code{character}     \n#' }\n#' \n#' @name pixiedust\n#' @keywords internal\n\n\"_PACKAGE\""
  },
  {
    "path": "R/pixiedust_print_method.R",
    "content": "#' @name pixiedust_print_method\n#' @title Determine the Current Print Method\n#' \n#' @description The user has the option of designating the print method to use, or \n#'   allowing package to select one from the \\code{knitr} settings.  This \n#'   function manages the logic of assigning the correct print method within the\n#'   \\code{dust} call.\n#'   \n#' @details The function \\code{pixiedust_print_method} first uses \n#'   \\code{getOption(\"pixiedust_print_method\")} to determine if the user has set \n#'   a print method.  If the user has not, it then looks to \n#'   \\code{knitr::opts_knit$get(\"rmarkdown.pandoc.to\")}. Finally, if this is also\n#'   \\code{NULL}, then the option is set to \\code{\"console\"}.\n\npixiedust_print_method <- function()\n{\n  print_method <- \n    getOption(\"pixiedust_print_method\",\n              knitr::opts_knit$get(\"rmarkdown.pandoc.to\"))\n  \n  if (is.null(print_method))\n  {\n    print_method <- \"console\"\n  }\n  \n  switch(print_method,\n         \"beamer\" = \"latex\",\n         print_method)\n}\n"
  },
  {
    "path": "R/pixieply.R",
    "content": "#' @name pixieply\n#' @title Apply Functions Over `dust_list` Objects\n#' \n#' @description The \\code{sprinkle} methods work with \\code{dust_list} \n#'   objects very naturally, but medleys pose a slightly more difficult problem.\n#'   Medleys are intended to be predefined collections of sprinkles that reduce\n#'   the time required to format a table with a particular look and style.  \n#'   It seems counter-productive to expect a user to define each of her or his\n#'   medleys as a method that can work with both \\code{dust} and \\code{dust_list}\n#'   objects.  \\code{pixieply} is a wrapper to \\code{lapply} that preserves the\n#'   \\code{dust_list} class of the object.\n#'   \n#'   \\code{pixiemap} provides functionality to apply differing sprinkles over\n#'   each element of a \\code{dust_list}.  The most common example is probably\n#'   adding a unique caption to each table.\n#'  \n#' @param X An object of class \\code{dust_list}.\n#' @param FUN A function to apply to each element of \\code{X}\n#' @param ... Additional arguments to pass to \\code{FUN}\n#' @param MoreArgs a list of other arguments to FUN\n#' @param SIMPLIFY logical or character string; attempt to reduce the result \n#'   to a vector, matrix or higher dimensional array; see the \\code{simplify} \n#'   argument of \\code{\\link{sapply}}\n#' @param USE.NAMES logical; use names if the first ... argument has names, \n#'   or if it is a character vector, use that character vector as the names.\n#' \n#' @examples \n#' \\dontrun{\n#' #* This example will only display the last table \n#' #* in the viewer pane.  To see the full output,\n#' #* run this example in an Rmarkdown document.\n#' x <- split(mtcars, list(mtcars$am, mtcars$vs))\n#' dust(x) %>%\n#'   sprinkle_print_method(\"html\") %>%\n#'   pixieply(medley_bw)\n#' }\n#' \n#' \\dontrun{\n#' #* This is the full text of an RMarkdown script \n#' #* for the previous example.\n#' ---\n#' title: \"Pixieply\"\n#' output: html_document\n#' ---\n#' \n#' ```{r}\n#' library(pixiedust)\n#' x <- dplyr::group_by(mtcars, am, vs)\n#' dust(x, ungroup = FALSE) %>%\n#'   sprinkle_print_method(\"html\") %>%\n#'     pixieply(medley_bw)\n#' ```\n#' }\n#' \n#' @export\n\npixieply <- function(X, FUN, ...)\n{\n  checkmate::assertClass(X, \"dust_list\")\n  \n  structure(\n    lapply(X = X,\n           FUN = FUN,\n           ...),\n    class = \"dust_list\"\n  )\n}\n\n#' @rdname pixieply\n#' @export\n\npixiemap <- function(X, FUN, ..., MoreArgs = NULL, SIMPLIFY = FALSE, USE.NAMES = TRUE)\n{\n  checkmate::assertClass(X, \"dust_list\")\n  \n  structure(\n    mapply(FUN = FUN, \n           X,\n           ...,\n           MoreArgs = MoreArgs,\n           SIMPLIFY = SIMPLIFY,\n           USE.NAMES = USE.NAMES),\n    class = \"dust_list\"\n  )\n}"
  },
  {
    "path": "R/print.dust.R",
    "content": "#' @name print.dust\n#' @export \n#' @method print dust\n#' \n#' @title Print A \\code{dust} Table\n#' @description Apply the formatting to a \\code{dust} object and print the table.\n#' \n#' @param x An object of class \\code{dust}\n#' @param ... Additional arguments to pass to the print method.  Currently ignored.\n#' @param asis A logical value that controls if the output is printed using\n#'   \\code{knitr::asis_output}.  See Details.\n#' @param linebreak_at_end Used only in HTML tables; defines the number of \n#'   line break tags \\code{</br>} appended to the end of the table in order to \n#'   generate whitespace between then end of the table and the subsequent\n#'   element.  By default, two line breaks are used.\n#'   \n#' @details The printing format is drawn from \\code{options()$dustpan_output} and may take any of\n#'   the values \\code{\"console\"}, \\code{\"markdown\"}, \\code{\"html\"}, or \\code{\"latex\"}\n#'   \n#'   The markdown, html, and latex output is returned via \\code{\\link[knitr]{asis_output}},\n#'   which forces the output into the 'asis' environment.  It is intended to work \n#'   with Rmarkdown, and the tables will be rendered regardless of the \n#'   chunk's \\code{results} argument.  Currently, there is no way to to capture\n#'   the code for additional post processing.\n#'   \n#'   When \\code{asis = TRUE} (the default), the output is returned via \\code{knitr::asis_output},\n#'   which renders the output as if the chunk options included \\code{results = 'asis'}.  Under \n#'   this setting, the table will be rendered regardless of the value of the \\code{results} \n#'   option.  Using \\code{asis = FALSE} returns a character string with the code for the table.\n#'   This may be rendered in a markdown document via \\code{cat(print(x, asis = FALSE))} with the \n#'   chunk option \\code{results = 'asis'}.  (If working with an Rnw file, the chunk option is \n#'   \\code{results = tex}).  The only way to use the \\code{asis} argument is with an explicit\n#'   call to \\code{print.dust}.\n#'   \n#'   \n#' @author Benjamin Nutter\n#' \n#' @examples \n#' dust(lm(mpg ~ qsec + factor(am), data = mtcars))\n\nprint.dust <- function(x, ..., asis = TRUE, linebreak_at_end = 2)\n{\n  print_method <- x$print_method\n  if (print_method == \"latex\" & x$hhline)\n    print_method <- \"latex_hhline\"\n  \n  switch(print_method,\n        \"console\"      = print_dust_console(x, ..., asis = asis),\n        \"docx\"         = print_dust_markdown(x, ..., asis = asis),\n        \"markdown\"     = print_dust_markdown(x, ..., asis = asis),\n        \"html\"         = print_dust_html(x, ..., asis = asis, linebreak_at_end = linebreak_at_end),\n        \"latex\"        = print_dust_latex(x, ..., asis = asis),\n        \"latex_hhline\" = print_dust_latex_hhline(x, ..., asis = asis),\n        \"slidy\"        = print_dust_html(x, ..., asis = asis, linebreak_at_end = linebreak_at_end),\n        stop(sprintf(\"'%s' is not an valid print method\",\n                     x[[\"print_method\"]])))\n}\n\n#' @rdname print.dust\n#' @export\n\nprint.dust_list <- function(x, ..., asis = TRUE)\n{\n  lapply(X = x,\n         FUN = print.dust,\n         asis = asis, \n         ...)\n}\n"
  },
  {
    "path": "R/print_dust_console.R",
    "content": "print_dust_console <- function(x, ..., return_df = FALSE, asis=TRUE)\n{\n  \n  if (!is.null(x$caption) & x$caption_number) increment_pixie_count()\n  caption_number_prefix <- \n    if (x$caption_number) sprintf(\"Table %s: \", get_pixie_count())\n    else \"\"\n  \n  #* Determine the number of divisions\n  #* It looks more complicated than it is, but the gist of it is\n  #* total number of divisions: ceiling(total_rows / longtable_rows)\n  #* The insane looking data frame is just to make a reference of what rows \n  #*   go in what division.\n  if (!is.numeric(x$longtable) & x$longtable) longtable_rows <- 25L\n  else if (!is.numeric(x$longtable) & !x$longtable) longtable_rows <- as.integer(max(x$body$row))\n  else longtable_rows <- as.integer(x$longtable)\n  \n  Divisions <- data.frame(div_num = rep(1:ceiling(max(x$body$row) / longtable_rows),\n                                        each = longtable_rows)[1:max(x$body$row)],\n                          row_num = 1:max(x$body$row))\n  total_div <- max(Divisions$div_num)\n  \n  #* Format table parts\n  head <- part_prep_console(x$head)\n  body <- part_prep_console(x$body)\n  foot <- if (!is.null(x$foot)) part_prep_console(x$foot) else NULL\n  interfoot <- if (!is.null(x$interfoot)) part_prep_console(x$interfoot) else NULL\n  \n  names(body) <- names(head) <- head[1, ]\n  \n  if (!is.null(foot)) names(foot) <- names(head)\n  if (!is.null(interfoot)) names(interfoot) <- names(head)\n  \n  if (return_df) DF <- NULL\n  \n  #* Run a loop to print all the divisions\n  for (i in 1:total_div){\n    tbl <- \n      .rbind_internal(if (nrow(head) > 1) head[-1, ] else NULL, \n                      body[Divisions$row_num[Divisions$div_num == i], ], \n                      if (i == total_div) foot else interfoot)\n    if (return_df) DF <- rbind(DF, tbl)\n    else {\n      if (!is.null(x$caption)) cat(caption_number_prefix, x$caption, \"\\n\\n\",\n                                   sep = \"\")\n      print(as.data.frame(tbl))\n      cat(\"\\n\\n\")\n    }\n  }\n  \n  if (return_df) return(as.data.frame(DF))\n}\n\n#**** Helper functions\n\npart_prep_console <- function(part)\n{\n  #* values in the dust object are all stored as character strings.\n  #* These classes need to be converted to numerics for rounding\n  #* to have the appropriate effect.\n  numeric_classes <- c(\"double\", \"numeric\")\n  \n  #* If functions are assigned, perform the function.\n  part <- perform_function(part)\n  \n  #* Perform any rounding\n  logic <- part$round == \"\" & part$col_class %in% numeric_classes\n  part$round[logic] <- getOption(\"digits\")\n  \n  logic <- part$col_class %in% numeric_classes\n  if (any(logic)){\n    part$value[logic] <-\n      as.character(roundSafe(part$value[logic], as.numeric(part$round[logic])))\n  }\n  #* Replacement\n  logic <- !is.na(part[[\"replace\"]])\n  part[[\"value\"]][logic] <- part[[\"replace\"]][logic]\n  \n    #* Bold text.  In the console, bold text is denoted by \"**\".  In order\n    #* to keep the all of the formatting lined up in columns, the data \n    #* frame is grouped by column, and if any cell in the column has bold \n    #* text, the unbolded text gets two spaces on either side to make the \n    #* columns the same width.\n    part <- split(part, part$col)\n    part <- lapply(part, \n                   function(x){\n                     if (any(x$bold)){\n                       x$value <- ifelse(x$bold, \n                                         sprintf(\"**%s**\", x$value),\n                                         sprintf(\"  %s  \", x$value))\n                     }\n                     if (any(x$italic)){\n                       x$value <- ifelse(x$italic, \n                                         sprintf(\"_%s_\", x$value),\n                                         sprintf(\" %s_\", x$value))\n                     }\n                     x\n                   })\n    part <- do.call(\"rbind\", part)\n    \n    part$value <- ifelse(part$rowspan == 0, \"\", part$value)\n    part$value <- ifelse(part$colspan == 0, \"\", part$value)\n    \n    part$value <- ifelse(is.na(part$value) & !is.na(part$na_string), \n                         part$na_string, \n                         part$value)\n    \n    part <- .make_dataframe_wide(part)\n\n    part\n}"
  },
  {
    "path": "R/print_dust_html.R",
    "content": "print_dust_html <- function(x, ..., asis=TRUE, \n                            linebreak_at_end = getOption(\"pixie_html_linebreak\", 2),\n                            interactive = getOption(\"pixie_interactive\"))\n{\n  if (is.null(interactive)) interactive <- interactive()\n  if (!is.null(x$caption) & x$caption_number) increment_pixie_count()\n  caption_number_prefix <- \n    if (x$caption_number) sprintf(\"Table %s: \", get_pixie_count())\n    else \"\"\n  \n  label <-\n    if (is.null(x[[\"label\"]]))\n    {\n      chunk_label <- knitr::opts_current$get(\"label\")\n      if (is.null(chunk_label))\n        sprintf(\"tab:pixie-%s\", getOption(\"pixie_count\"))\n      else\n        sprintf(\"tab:%s\", chunk_label)\n    }\n    else\n    {\n     sprintf(\"tab:%s\", x[[\"label\"]])\n    }\n  \n  label <-\n    if (x[[\"bookdown\"]])\n    {\n      sprintf(\"(\\\\#%s)\", label)\n    }\n    else\n    {\n      caption_number_prefix\n    }\n  \n  \n  #* Determine the number of divisions\n  #* It looks more complicated than it is, but the gist of it is\n  #* total number of divisions: ceiling(total_rows / longtable_rows)\n  #* The insane looking data frame is just to make a reference of what rows\n  #*   go in what division.\n  if (!is.numeric(x$longtable) & x$longtable) longtable_rows <- 25L\n  else if (!is.numeric(x$longtable) & !x$longtable) longtable_rows <- as.integer(max(x$body$row))\n  else longtable_rows <- as.integer(x$longtable)\n  \n  Divisions <- data.frame(div_num = rep(1:ceiling(max(x$body$row) / longtable_rows),\n                                        each = longtable_rows)[1:max(x$body$row)],\n                          row_num = 1:max(x$body$row))\n  total_div <- max(Divisions$div_num)\n  \n  \n  #* Format the table parts\n  head <- part_prep_html(x$head, head = TRUE, \n                         fixed_header = x[[\"fixed_header\"]],\n                         fixed_header_class_name = x[[\"fixed_header_param\"]][[\"fixed_header_class_name\"]])\n  body <- part_prep_html(x$body)\n  foot <- if (!is.null(x$foot)) part_prep_html(x$foot) else NULL\n  interfoot <- if (!is.null(x$interfoot)) part_prep_html(x$interfoot) else NULL\n  \n  tmpfile <- tempfile(fileext=\".html\")\n  non_interactive <- \"\"\n  \n  #* Run a for loop to build all the table divisions\n  for (i in 1:total_div){\n    tbl <- .rbind_internal(head,\n                           body[Divisions$row_num[Divisions$div_num == i], , drop=FALSE],\n                           if (i == total_div) foot else interfoot)\n    rows <- apply(tbl, 1, paste0, collapse = \"\\n\")\n    rows <- sprintf(\"<tr>\\n%s\\n</tr>\", rows)\n    \n    justify <- \n      if (x[[\"justify\"]] == \"center\") \"margin:auto\"\n      else sprintf(\"float:%s\", x[[\"justify\"]])\n    \n    # Tables aligned to the left or right of the page need a barrier with the\n    # clear propert set to prevent text from being placed next to the table.\n    float_guard <- \n      if (x[[\"justify\"]] == \"center\") \"\"\n      else \"<div style = 'clear:both'></div>\"\n    \n    fixed_head_css <- \n      if (x[[\"fixed_header\"]] & x[[\"include_fixed_header_css\"]])\n        do.call(fixed_header_css,\n                c(x[[\"fixed_header_param\"]],\n                  list(pretty = FALSE)))\n      else \"\"\n    \n    if (x[[\"fixed_header\"]]){\n      fixed_head_open_tag <- \n        sprintf(\"<div style = 'text-align:%s'><section class='%s-section'><div class='%s-container'><div>\",\n                x[[\"justify\"]],\n                x[[\"fixed_header_param\"]][[\"fixed_header_class_name\"]],\n                x[[\"fixed_header_param\"]][[\"fixed_header_class_name\"]])\n      fixed_head_close_tag <- \"</div></section></div>\"\n    }\n    else{\n      fixed_head_open_tag <- fixed_head_close_tag <- \"\"\n    }\n    \n    \n    html_code <- sprintf(\"%s%s%s<table style = '%s;border-collapse:%s;'>\\n%s\\n</table>%s%s%s\",\n                         float_guard,\n                         fixed_head_css,\n                         fixed_head_open_tag,\n                         justify,\n                         x$border_collapse, \n                         paste0(rows, collapse = \"\\n\"),\n                         fixed_head_close_tag,\n                         float_guard,\n                         paste0(rep(\"</br>\", linebreak_at_end), collapse = \"\"))\n    \n    if (!is.null(x$caption))\n      html_code <- sub(\">\",\n                       sprintf(\">\\n<caption>%s %s</caption>\", \n                              label, x$caption),\n                       html_code)\n    \n    #* When interactive, write to a temporary file so that it\n    #* can be displayed in the viewer\n    if (interactive & asis){\n      write(html_code, tmpfile, append = i > 1)\n    }\n    else non_interactive <- paste0(non_interactive, html_code)\n  }\n  # print(html_code)\n  if (interactive & asis){\n    getOption(\"viewer\")(tmpfile)\n  }\n  else if (asis){\n    if (x$html_preserve) knitr::asis_output(htmltools::htmlPreserve(non_interactive))\n    else knitr::asis_output(non_interactive)\n  }\n  else { \n    if (x$html_preserve) htmltools::htmlPreserve(non_interactive)\n    else non_interactive\n  }\n  \n}\n\n#**** Helper functions\n\npart_prep_html <- function(part, head=FALSE, \n                           fixed_header = FALSE, fixed_header_class_name = \"\")\n{\n  numeric_classes <- c(\"double\", \"numeric\")\n  \n  dh <- \n    if (head)\n    {\n      if (fixed_header){\n        sprintf(\"th class = 'th-%s'\", fixed_header_class_name)\n      }\n      else\n      {\n        \"th\"\n      }\n    }\n    else \n    {\n      \"td\"\n    }\n  \n  #* apply a function, if any is indicated\n  part <- perform_function(part)\n  \n  #* Perform any rounding\n  logic <- part$round == \"\" & part$col_class %in% numeric_classes\n  part$round[logic] <- getOption(\"digits\")\n  \n  logic <- part$col_class %in% numeric_classes\n  if (any(logic))\n    part$value[logic] <-\n    as.character(roundSafe(part$value[logic], as.numeric(part$round[logic])))\n  \n  #* Replacement\n  logic <- !is.na(part[[\"replace\"]])\n  part[[\"value\"]][logic] <- part[[\"replace\"]][logic]\n  \n  #* Bold and italic\n  boldify <- part$bold\n  part$bold[boldify] <- \"font-weight:bold;\"\n  part$bold[!boldify] <- \"\"\n  \n  italicize <- part$italic\n  part$italic[italicize] <- \"font-style:italic;\"\n  part$italic[!italicize] <- \"\"\n  \n  #* Alignments. With horizontal alignment, first we determine\n  #* default alignment for any cell without a given designation.\n  #* The defaults are right aligned for numeric, left aligned for\n  #* all otheres.  The `default_halign` function is defined in\n  #* `print_dust_latex.R`\n  \n  logic <- part$halign == \"\"\n  part$halign[logic] <- vapply(X = part$col_class[logic],\n                               FUN = default_halign,\n                               FUN.VALUE = character(1),\n                               print_method = \"html\")\n  part$halign <-\n    with(part, sprintf(\"text-align:%s;\", halign))\n  \n  logic <- part$valign != \"\"\n  part$valign[logic] <-\n    with(part, sprintf(\"vertical-align:%s;\", valign[logic]))\n  \n  #** Background\n  logic <- part$bg != \"\"\n  part$bg[logic] <-\n    with(part, sprintf(\"background-color:%s;\", bg[logic]))\n  \n  #* Font Family\n  logic <- part$font_family != \"\"\n  part$font_family[logic] <-\n    with(part, sprintf(\"font-family:%s;\", font_family[logic]))\n  \n  #* Font Color\n  logic <- part$font_color != \"\"\n  part$font_color[logic] <-\n    with(part, sprintf(\"color:%s;\", font_color[logic]))\n  \n  #* Font size\n  logic <- part$font_size != \"\"\n  part$font_size[logic] <-\n    with(part, sprintf(\"font-size:%s%s;\", \n                       font_size[logic],\n                       font_size_units[logic]))\n  \n  #* cell height and width\n  logic <- part$height != \"\"\n  part$height[logic] <-\n    with(part, sprintf(\"height:%s%s;\", height[logic], height_units[logic]))\n  \n  logic <- part$width != \"\"\n  part$width[logic] <-\n    with(part, sprintf(\"width:%s%s;\", width[logic], width_units[logic]))\n  \n  #* Borders\n  logic <- part$top_border != \"\"\n  part$top_border[logic] <-\n    with(part, sprintf(\"border-top:%s;\", top_border[logic]))\n  \n  logic <- part$bottom_border != \"\"\n  part$bottom_border[logic] <-\n    with(part, sprintf(\"border-bottom:%s;\", bottom_border[logic]))\n  \n  logic <- part$left_border != \"\"\n  part$left_border[logic] <-\n    with(part, sprintf(\"border-left:%s;\", left_border[logic]))\n  \n  logic <- part$right_border != \"\"\n  part$right_border[logic] <-\n    with(part, sprintf(\"border-right:%s;\", right_border[logic]))\n  \n  #* Set NA (missing) values to na_string\n  logic <- is.na(part$value) & !is.na(part$na_string)\n  part$value[logic] <-\n    part$na_string[logic]\n  \n  #* Padding\n  logic <- part$pad != \"\"\n  part$pad[logic] <-\n    with(part, sprintf(\"padding:%spx;\", pad[logic]))\n  \n  #* Text Rotation\n  logic <- part$rotate_degree != \"\"\n  part$rotate_degree[logic] <-\n    with(part, rotate_tag(rotate_degree[logic]))\n  \n  #* Generate css style definitions for each cell.\n  part$value <-\n    with(part, sprintf(\"<%s colspan = '%s'; rowspan = '%s'; style='%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s'>%s %s</%s>\",\n                       dh, colspan, rowspan, \n                       bold, italic, halign, valign, bg, font_family, #6\n                       font_color, font_size, height, width,          #4\n                       top_border, bottom_border, left_border, right_border, #4\n                       rotate_degree, pad,  #2\n                       value, \n                       if (fixed_header) paste0(\"<div>\", value, \"</div>\") else \"\",\n                       substr(dh, 1, 2)))\n\n  ncol <- max(part$col)\n  \n  part <- part[!(part$rowspan == 0 | part$colspan == 0), ]\n  \n  logic <-\n    part[[\"row\"]] == part[[\"html_row\"]] & \n    part[[\"col\"]] == part[[\"html_col\"]] & \n    part[[\"colspan\"]] > 1\n  \n  if (\"html_row_pos\" %in% names(part))\n    part[[\"html_row\"]][logic] <- part[[\"html_row_pos\"]][logic]\n  \n  if (\"html_col_pos\" %in% names(part))\n    part[[\"html_col\"]][logic] <- part[[\"html_col_pos\"]][logic]\n  \n  #* Spread to wide format for printing\n  part <- part[c(\"html_row\", \"html_col\", \"value\")]  \n  part <- reshape2::dcast(part,\n                          html_row ~ html_col,\n                          value.var = \"value\",\n                          fill = \"\")\n  part <- part[!names(part) %in% \"html_row\"]\n  \n  if (ncol(part) != ncol){\n    part <- cbind(part,\n                  do.call(\"cbind\",\n                          lapply(1:(ncol - ncol(part)),\n                                 function(i) data.frame(value = \"\", \n                                                        stringsAsFactors = FALSE))))\n    names(part) <- 1:ncol\n  }\n  part\n}\n\n#***********************************\n\n#* Rotation tags vary by browser.  To make the rotation as robust as\n#* possible, specifying a rotation applies tags for webkit (Chrome?),\n#* Mozilla, Internet Explorer, Opera, and a generic transformation.\n\nrotate_tag <- function(degree)\n{\n  sprintf(\n    paste0(\"-webkit-transform:rotate(%sdeg);\",\n           \"-moz-transform:rotate(%sdeg);\",\n           \"-ms-transform:rotate(%sdeg);\",\n           \"-o-transform:rotate(%sdeg);\",\n           \"transform:rotate(%sdeg);\"),\n    degree, degree, degree, degree, degree)\n}\n"
  },
  {
    "path": "R/print_dust_latex.R",
    "content": "\nprint_dust_latex <- function(x, ..., asis=TRUE)\n{\n  \n  if (!is.null(x$caption) & x$caption_number) increment_pixie_count()\n  \n  label <- \n    if (is.null(x[[\"label\"]]))\n    {\n      chunk_label <- knitr::opts_current$get(\"label\")\n      if (is.null(chunk_label))\n        paste0(\"tab:pixie-\", getOption(\"pixie_count\"))\n      else\n        paste0(\"tab:\", chunk_label)\n    }\n    else\n    {\n      paste0(\"tab:\", x[[\"label\"]])\n    }\n  \n  label <- \n    if (x[[\"bookdown\"]])\n    {\n      paste0(\"(\\\\#\", label, \")\")\n    }\n    else\n    {\n      paste0(\"\\\\label{\", label, \"}\")\n    }\n  \n  #* Determine the number of divisions\n  #* It looks more complicated than it is, but the gist of it is\n  #* total number of divisions: ceiling(total_rows / longtable_rows)\n  #* The insane looking data frame is just to make a reference of what rows \n  #*   go in what division.\n  if (!is.numeric(x$longtable) & x$longtable) longtable_rows <- 25L\n  else if (!is.numeric(x$longtable) & !x$longtable) longtable_rows <- as.integer(max(x$body$row))\n  else longtable_rows <- as.integer(x$longtable)\n  \n  tab_env <- if (is.numeric(x$longtable) || x$longtable) \"longtable\" else \"tabular\"\n  \n  Joint <- joint_reference_table(x)\n\n  col_width <- determine_column_width(Joint)\n  col_halign_default <- get_column_halign(Joint)\n  \n  row_height <- lapply(list(x$head, x$body, x$foot, x$interfoot), \n                       determine_row_height)\n                       \n\n  #* Format the table parts\n  head <- part_prep_latex(x$head, col_width, col_halign_default, head = TRUE)\n  body <- part_prep_latex(x$body, col_width, col_halign_default)\n  foot <- if (!is.null(x$foot)) part_prep_latex(x$foot, col_width, col_halign_default) else NULL\n  interfoot <- if (!is.null(x$interfoot)) part_prep_latex(x$interfoot, col_width, col_halign_default) else NULL\n  \n  #* Write the LaTeX Code\n  prebegin <- numeric_longtable_newline(longtable_rows, is.numeric(x$longtable))\n  prebegin <- paste0(prebegin, \n                     \"\\\\setlength{\\\\tabcolsep}{\", x$tabcolsep, \"pt}\", sep = \"\\n\")\n  \n  if (tab_env == \"longtable\")\n  {\n    begin <- paste0(\"\\\\begin{longtable}[\",\n                    gsub(\"n\", \"l\", substr(x[[\"justify\"]], 1, 1)), \"]{\",\n                    paste0(col_halign_default$default_halign, collapse = \"\"), \"}\\n\",\n                    if (!is.null(x$caption))\n                      paste0(\"\\\\caption\", \n                            if (x$caption_number) \"\" else \"*\", \n                            \"{\", x$caption, \"}\")\n                    else \"\", \n                    \"\\n\", label, \"\\\\\\\\ \\n\")\n    end <- \"\\\\end{longtable}\"\n  }\n  else if (x$float)\n  {\n    begin <- paste0(\"\\\\begin{table}\\n\",\n                    if (x[[\"justify\"]] == \"center\") \"\\\\centering\\n\" else \"\",\n                    if (!is.null(x$caption))\n                      paste0(\"\\\\caption\", \n                             if (x$caption_number) \"\" else \"*\", \n                             \"{\", x$caption, \"}\")\n                    else \"\", \n                    \"\\n\", label,\n                    \"\\\\begin{tabular}{\",\n                    paste0(col_halign_default$default_halign, collapse = \"\"), \"}\\n\")\n    \n    end <- paste0(\"\\\\end{tabular}\\n\\\\end{table}\\n\")\n  }\n  else\n  {\n    begin <- paste0(if (x[[\"justify\"]] == \"center\")\n                      \"\\\\begin{center}\\n\"\n                    else\n                      \"\",\n                    if (!is.null(x$caption))\n                     paste0(\"\\\\captionof{table}{\", x$caption, \"}\")\n                    else \"\", \n                    \"\\n\", label,\n                    \"\\\\begin{tabular}{\",\n                    paste0(col_halign_default$default_halign, collapse = \"\"), \"}\\n\")\n    end <- paste0(\"\\\\end{tabular}\\n\",\n                  if (x[[\"justify\"]] == \"center\")\n                    \"\\\\end{center}\\n\"\n                  else\n                    \"\")\n  }\n  \n  \n  #* Convert each part into a character string\n  #* Returns a character vector of length 4.\n  tbl <- mapply(paste_latex_part,\n                list(head, body, foot, interfoot),\n                row_height,\n                MoreArgs = list(newline = if (is.numeric(x$longtable)) \" \\\\ltabnewline\" else \" \\\\\\\\\"))\n\n  #* Append longtable tags\n  if (is.numeric(x$longtable) || x$longtable){\n    tbl <- paste0(tbl[c(1, 4, 3, 2)], \n                  c(\"\\n\\\\endhead\\n\", \"\\n\\\\endfoot\\n\", \"\\n\\\\endlastfoot\\n\", \"\"))\n  }\n  \n  tbl <- paste(tbl, collapse = \"\\n\")\n  \n  if (asis) knitr::asis_output(paste(prebegin, begin, tbl, end, collapse = \"\\n\"))\n  else paste(prebegin, begin, tbl, end, collapse = \"\\n\")\n\n \n}\n\n#* Prepare Cell Values for Printing\npart_prep_latex <- function(part, col_width, col_halign_default, head=FALSE)\n{\n  part <- part[!names(part) %in% \"width\"]\n  part <- merge(part, \n                col_width, \n                by = \"col\", \n                all.x = TRUE, \n                sort = FALSE)\n  part <- merge(part, \n                col_halign_default, \n                by = \"col\", \n                all.x = TRUE, \n                sort = FALSE)\n  part$width_units <- rep(\"pt\", nrow(part))\n  part$halign <- ifelse(part$halign == \"\", \n                        part$default_halign, \n                        part$halign)\n   \n    #* Calculate the row cell width for multicolumn cells\n    \n  Widths <- part[c(\"html_row\", \"html_col\", \"width\", \"merge\")]\n  Widths <- Widths[!duplicated(Widths), ]\n  Widths <- split(Widths, Widths[c(\"html_row\", \"html_col\")])\n  Widths <- lapply(Widths, \n                   function(x){\n                     x$width <- ifelse(x$merge == TRUE, \n                                       sum(x$width[x$merge]), \n                                       x$width)\n                     x\n                   })\n  Widths <- do.call(\".rbind_internal\", Widths)\n   \n  \n  numeric_classes <- c(\"double\", \"numeric\")\n  \n  #* apply a function, if any is indicated\n  part <- perform_function(part) \n  \n  #* Perform any rounding\n  logic <- part$round == \"\" & part$col_class %in% numeric_classes\n  part$round[logic] <- getOption(\"digits\")\n  \n  logic <- part$col_class %in% numeric_classes\n  if (any(logic))\n    part$value[logic] <-\n    as.character(roundSafe(part$value[logic], as.numeric(part$round[logic])))\n\n  #* Replacement\n  logic <- !is.na(part[[\"replace\"]])\n  part[[\"value\"]][logic] <- part[[\"replace\"]][logic]\n  \n  #* Set NA (missing) values to na_string\n  logic <- is.na(part$value) & !is.na(part$na_string)\n  part$value[logic] <- \n    part$na_string[logic]\n  \n  #* Sanitize value strings\n  logic <- part[[\"sanitize\"]]\n  part[[\"value\"]][logic] <- sanitize(part[[\"value\"]][logic],\n                                     part[[\"sanitize_args\"]][logic])\n\n\n  \n  #* Bold and italic\n  boldify <- part$bold\n  part$value[boldify] <- paste0(\"\\\\textbf{\", part$value[boldify], \"}\")\n\n  italicize <- part$italic\n  part$value[italicize] <- paste0(\"\\\\emph{\", part$value[italicize], \"}\")\n  \n  #* Font Color\n  logic <- part$font_color != \"\"\n  part$font_color <- vapply(part$font_color, \n                            convertColor,\n                            character(1))\n  part$value[logic] <- \n    paste0(\"\\\\textcolor\", part$font_color[logic], \"{\", part$value[logic], \"}\")\n  \n  #* Font size\n  logic <- part$font_size != \"\"\n  part$font_size_units[logic] <- ifelse(part$font_size_units[logic] %in% c(\"%\", \"px\"),\n                                        \"pt\",\n                                        part$font_size_units[logic])\n  \n  part$value[logic] <- \n    paste0(\"{\\\\fontsize{\", part$font_size[logic],\n           part$font_size_units[logic], \"}{1em}\\\\selectfont \",\n           part$value[logic], \"}\")\n  \n  logic <- part$rotate_degree != \"\"\n  part$value[logic] <- \n    paste0(\"\\\\rotatebox{\", part$rotate_degree[logic], \"}{\", part$value[logic], \"}\")\n  \n  #** Background\n  logic <- part$bg != \"\"\n  part$bg[logic] <- \n    paste0(\"{\\\\cellcolor\", vapply(part$bg[logic],\n                                 convertColor,\n                                 character(1)), \"}\")\n  \n  part$value[logic] <- paste(part$bg[logic], part$value[logic])\n  \n  #** Borders\n  logic <- part$left_border != \"\"\n  part$left_border[logic] <- \n    vapply(part$left_border[logic], latex_vertical_border_code, character(1))\n  \n  logic <- part$right_border != \"\"\n  part$right_border[logic] <- \n    vapply(part$right_border[logic], latex_vertical_border_code, character(1))\n  \n  logic <- part$bottom_border != \"\"\n  part$bottom_border[logic] <- \n    mapply(latex_horizontal_border_code, \n           part$bottom_border[logic],\n           part$col[logic])\n  bottom_borders <- part[c(\"row\", \"col\", \"bottom_border\")]\n  bottom_borders <- reshape2::dcast(bottom_borders,\n                                    row ~ col, \n                                    value.var = \"bottom_border\")\n  bottom_borders <- bottom_borders[!names(bottom_borders) %in% \"row\"]\n  bottom_borders <- apply(bottom_borders, \n                          MARGIN = 1, \n                          paste0, \n                          collapse = \"\")\n  \n  logic <- part$top_border != \"\"\n  part$top_border[logic] <- \n    mapply(latex_horizontal_border_code, \n           part$top_border[logic],\n           part$col[logic])\n  top_borders <- part[c(\"row\", \"col\", \"top_border\")]\n  top_borders <- reshape2::dcast(top_borders, \n                                 row ~ col, \n                                 value.var = \"top_border\", \n                                 fill = \"\")\n  top_borders <- top_borders[!names(top_borders) %in% \"row\"]\n  top_borders <- apply(top_borders, \n                       MARGIN = 1, \n                       FUN = paste0, \n                       collapse = \"\")\n\n\n  parbox <- needs_parbox(part)\n  \n  part$halign_parbox <- part$halign\n  part$halign_parbox[parbox] <- \n    c(\"r\" = \"\\\\raggedleft\", \n      \"c\" = \"\\\\centering\", \n      \"l\" = \"\\\\raggedright\", \n      \"p\" = \"\\\\raggedright\")[substr(part$halign[parbox], 1, 1)]\n  \n  part$value[parbox] <- \n    paste0(\"\\\\parbox[\", substr(part$valign[parbox], 1, 1), \"]{\", part$width[parbox], \"pt}{\", \n               part$halign_parbox[parbox], \" \",\n               part$value[parbox], \"}\")\n  \n  #* Add the multirow tag where appropriate\n  logic <- part$rowspan > 1\n  part$value[logic] <- \n    paste0(\"\\\\multirow{\", part$rowspan[logic], \"}{*}{\", part$value[logic], \"}\")\n  \n  #* Add blank multicolumn tags to fill multirow spaces\n  #* set the colspan and rowspan to prevent deletion.\n  #*   They are set to -1 to indicate that they are fillers\n  logic <- part$html_row != part$row & part$html_col == part$col\n  part$value[logic] <- paste0(\"\\\\multicolumn{\", part$colspan[logic], \"}\",\n                              \"{\", part$left_border[logic], \"c\", part$right_border[logic], \"}{}\")\n  part$rowspan[logic] <- -1\n  part$colspan[logic] <- part$colspan[logic] * -1\n  \n  #* Place multicolumn tags where needed\n  logic <- part$colspan > 1 | (part$left_border != \"\" | part$right_border != \"\") | \n            !(part$html_row != part$row & part$html_col == part$col)\n  part$value[logic] <- \n    paste0(\"\\\\multicolumn{\", part$colspan[logic], \"}{\", \n           part$left_border[logic],\n           #* 'p' isn't a valid alignment in 'multicol', so we replace it with 'r'\n           sub(\"p\", \"r\", substr(part$halign[logic], 1, 1)), \n           part$right_border[logic], \"}{\", part$value[logic], \"}\")\n  \n  #* Remove value where a merged cell is not the display cell\n  ncol <- max(part$col)\n  \n  part <- part[!(part$rowspan == 0 | part$colspan == 0), ]\n\n  #* In order to get the multirow to render correctly, the cell with \n  #* the multirow needs to be at the top of the block.  This \n  #* rearranges the merged cells so that the multirow is at the top.\n  \n  proper_multirow <- part[part$colspan != 1, ] \n  proper_multirow$group <- paste0(proper_multirow$html_row,\n                                  proper_multirow$html_col)\n  proper_multirow <- split(proper_multirow,\n                           proper_multirow$group)\n  proper_multirow <- lapply(proper_multirow,\n                            function(x){\n                              x[order(x$colspan, decreasing = TRUE), ]\n                              x$row <- sort(x$row)\n                              x\n                            })\n  proper_multirow <- do.call(\".rbind_internal\", proper_multirow)\n  \n  part <- part[part$colspan == 1, ]\n  part <- .rbind_internal(part, proper_multirow)\n\n  part <- .make_dataframe_wide(part)\n  \n  cbind(top_borders, \n        bottom_borders,\n        part)\n}\n\n#* Converts the data frame object to one line of LaTeX\n#* code per row.\npaste_latex_part <- function(part, row_height, newline = \" \\\\\\\\\"){\n  paste_row <- function(r) paste(r[!is.na(r)], collapse = \" & \")\n  \n  if (is.null(part)) return(\"\")\n  #* This commented line existed when I had horizontal \n  #* borders worked out.  It may be needed again.\n  apply(part[, -(1:2), drop = FALSE], 1, paste_row) %>%\n    # apply(part[, , drop = FALSE], 1, paste_row) %>%\n    paste(row_height) %>%\n    paste(newline) %>%\n    paste(part[, 2]) %>%     #* also from borders\n    paste(part[, 1], .) %>%  #* also from borders\n    paste0(collapse = \"\\n\")\n}\n\n#**************************************************\n#**************************************************\nconvertColor <- function(color){\n  if (length(color) == 0) return(character(0))\n  \n  color <- gsub(\"rgba[(]255,255,255,0[)]\", \"\", color)\n  \n  if (grepl(\"#\", color)){\n    return(paste0(\"[HTML]{\", sub(\"#\", \"\", color), \"}\"))\n  }\n  else if (grepl(\"rgb\", color, ignore.case = TRUE)){\n    rgb <- str_extract_base(color, \"\\\\d{1,3}\")[1, 1:3]\n    return(paste0(\"[RGB]{\", paste0(rgb, collapse=\",\"), \"}\"))\n  }\n  else return(paste0(\"{\", color, \"}\"))\n}\n\n#**************************************************\n#**************************************************\n#* Writes the code that is necessary to force\n#* longtable breaks at the user-specified number \n#* of lines\nnumeric_longtable_newline <- function(n, redefine = FALSE){\n  if (redefine)\n    return(paste0(\"\\\\newcount\\\\mylineno \\n\",\n                  \"\\\\mylineno=0 \\n\",\n                  \"\\\\def\\\\ltabnewline{% \\n\", \n                  \"\\\\global\\\\advance\\\\mylineno by 1 \\n\", \n                  \"\\\\ifnum\\\\mylineno=\", n, \" \\n\",\n                  \"\\\\global\\\\mylineno=0 \\n\",\n                  \"\\\\\\\\ \\n\",\n                  \"\\\\newpage \\n\",\n                  \"\\\\else \\n\",\n                  \"\\\\\\\\ \\n\",\n                  \"\\\\fi \\n\",\n                  \"}\"))\n  else return(\"\")\n}\n\n#**************************************************\n#**************************************************\n#* Determine if the cell needs a parbox\n\nneeds_parbox <- function(x)\n{\n  is.finite(x$width) | \n    (x$halign != x$default_halign) | \n    x$valign != \"\" | \n    x$merge\n}\n\n#**************************************************\n#**************************************************\n#* Combine the four table parts for convenience of looking for common traits\njoint_reference_table <- function(x){\n  numeric_classes <- c(\"double\", \"numeric\")\n  \n  addPartCol <- function(p, part_name) {\n    if (is.null(p)) return(NULL)\n    p$part <- part_name \n    return(p)\n  }\n\n  Joint <- \n    mapply(addPartCol,\n         x[c(\"head\", \"body\", \"foot\", \"interfoot\")],\n         part_name = c(\"head\", \"body\", \"foot\", \"interfoot\"),\n         SIMPLIFY = FALSE) \n  Joint <- do.call(\".rbind_internal\", Joint)\n  Joint$width <- as.numeric(Joint$width)\n  Joint$table_width <- x$table_width * 72.27\n  Joint$width <- ifelse(Joint$width_units == \"in\",\n                        Joint$width * 72.27, \n                        ifelse(Joint$width_units == \"cm\", \n                               Joint$width * 27.45,\n                               ifelse(Joint$width_units == \"%\",\n                                      Joint$width/100 * Joint$table_width, \n                                      Joint$width)))\n  \n  #* apply a function, if any is indicated\n  Joint <- perform_function(Joint) \n  \n  #* Perform any rounding\n  logic <- Joint$round != \"\" & Joint$col_class %in% numeric_classes\n  if (any(logic))\n    Joint$value[logic] <- \n    as.character(roundSafe(Joint$value[logic], as.numeric(Joint$round[logic])))\n  \n  Joint$halign[Joint$halign == \"\"] <- \n    vapply(Joint$col_class[Joint$halign == \"\"],\n           default_halign,\n           character(1))\n  \n  Joint$halign <- substr(Joint$halign, 1, 1)\n  Joint <- split(Joint, Joint$col)\n  Joint <- lapply(Joint, \n                  function(x){\n                    x$default_halign <- names(sort(table(x$halign), \n                                                   decreasing = TRUE))[1]\n                    x\n                  })\n  Joint <- do.call(\".rbind_internal\", Joint)\n  Joint$parbox <- needs_parbox(Joint)\n  Joint$width_by_char <- nchar(Joint$value) * 4.5\n  Joint <- split(Joint, Joint$col)\n  Joint <- lapply(Joint, \n                  function(x){\n                    x$replace <- all(is.na(x$width)) & any(x$parbox)\n                    x$width_by_char <- max(x$width_by_char, na.rm = TRUE)\n                    x\n                  })\n  Joint <- do.call(\".rbind_internal\", Joint)\n  Joint$width <- ifelse(Joint$replace, \n                        Joint$width_by_char, \n                        Joint$width)  \n  Joint <- Joint[c(\"col\", \"row\", \"width\", \"default_halign\")]\n  Joint\n}\n\n#**************************************************\n#**************************************************\n#* Get the default column alignments.\n#* Right aligned for numeric, otherwise, left aligned\ndetermine_column_width <- function(Joint, x)\n{\n  Joint <- Joint[c(\"row\", \"col\", \"width\")]\n  suppressWarnings(Joint <- tapply(Joint$width, Joint$col, max, na.rm = TRUE))\n  Joint <- data.frame(col = names(Joint),\n                      width = unname(Joint),\n                      stringsAsFactors = FALSE)\n  Joint$width <- ifelse(is.finite(Joint$width),\n                        Joint$width,\n                        NA)\n  Joint\n}\n\ndetermine_row_height <- function(part)\n{\n  if (is.null(part)) return(\"\")\n  part <- part[c(\"row\", \"col\", \"height\", \"height_units\")]\n  part$height <- as.numeric(part$height)\n  part$height <- ifelse(part$height_units == \"in\", \n                        part$height * 72.27, \n                        ifelse(part$height_units == \"cm\",\n                               part$height * 28.45,\n                               part$height))\n  \n  suppressWarnings(part <- tapply(part$height, \n                                  INDEX = part$row,\n                                  FUN = max, \n                                  na.rm = TRUE))\n  part <- data.frame(row = names(part), \n                     height = unname(part), \n                     stringsAsFactors = FALSE)\n  part$height <- ifelse(!is.finite(part$height),\n                        \"\", \n                        paste0(\"\\\\\\\\[\", part$height, \"pt]\"))\n  part$height\n}\n\n#**************************************************\n#**************************************************\n#* Get the default column alignments.\n#* Right aligned for numeric, otherwise, left aligned\n\nget_column_halign <- function(Joint){\n  Joint$default_halign <- ifelse(is.na(Joint$width),\n                                 Joint$default_halign,\n                                 paste0(\"p{\", Joint$width, \"pt}\"))\n  Joint <- Joint[c(\"row\", \"col\", \"default_halign\")]\n  Joint <- tapply(Joint$default_halign, \n                  Joint$col, \n                  function(x) x[1])\n  Joint <- data.frame(col = names(Joint), \n                      default_halign = unname(Joint),\n                      stringsAsFactors = FALSE)\n  Joint\n}\n\ndefault_halign <- function(col_class, print_method = \"latex\"){\n  tag <- \n    if (print_method == \"latex\") c(\"r\", \"l\") \n    else c(\"right\", \"left\")\n  \n  if (col_class %in% c(\"numeric\", \"int\", \"double\")) tag[1] else tag[2]\n}\n\n#**************************************************\n#**************************************************\n#* Prepares code for vertical borders\nlatex_vertical_border_code <- function(x){\n  border <- str_split_fixed_base(x, \" \", 3)\n  border[, 1] <- gsub(\"px\", \"pt\", border[, 1])\n  border[, 2] <- ifelse(border[, 2] %in% c(\"dashed\", \"dotted\"), \n                        \"dashed\",\n                        ifelse(border[, 2] %in% c(\"groove\", \"ridge\", \"inset\", \"outset\", \"hidden\"),\n                               \"solid\", border[, 2]))\n  if (border[, 2] %in% c(\"hidden\", \"none\")) return(\"\")\n  if (border[, 2] == \"dashed\"){\n    border_code <- paste(\"!{\\\\color\", convertColor(border[, 3]), \"\\\\vdashline}\")\n    return(border_code)\n  }\n  if (border[, 2] %in% c(\"solid\", \"double\")){\n    border_code <- paste0(\"!{\\\\color\", convertColor(border[, 3]), \"\\\\vrule width \", border[, 1], \"}\")\n    return(border_code)\n  }\n}\n\n#**************************************************\n#**************************************************\n#* Prepares code for horizontal borders\nlatex_horizontal_border_code <- function(x, col){\n  border <- str_split_fixed_base(x, \" \", 3)\n  border[, 1] <- gsub(\"px\", \"pt\", border[, 1])\n  border[, 2] <- ifelse(border[, 2] %in% c(\"dashed\", \"dotted\"), \n                        \"dashed\",\n                        ifelse(border[, 2] %in% c(\"groove\", \"ridge\", \"inset\", \"outset\", \"hidden\"),\n                               \"solid\", border[, 2]))\n  if (border[, 2] %in% c(\"hidden\", \"none\")) return(\"\")\n  if (border[, 2] == \"dashed\"){\n    border_code <- paste0(\"\\\\arrayrulecolor\", convertColor(border[, 3]), \n                          \"\\\\cdashline{\", col, \"-\", col, \"}\")\n    return(border_code)\n  }\n  if (border[, 2] %in% c(\"solid\", \"double\")){\n    border_code <- paste0(\"\\\\arrayrulecolor\", convertColor(border[, 3]), \n                          \"\\\\cline{\", col, \"-\", col, \"}\")\n    return(border_code)\n  }\n}\n\n#* NA safe sanitization function\nsanitize <- function(x, args)\n{\n  sanitize_index <- !is.na(x)\n  if (sum(sanitize_index))\n  {\n    x[sanitize_index] <- \n      do.call(what = sanitize_latex,\n              args = c(list(object = x[sanitize_index]),\n                       eval(parse(text = args[sanitize_index])))\n      )\n  }\n  x\n}\n\n\nutils::globalVariables(c(\"halign\", \"left_border\", \"right_border\", \n                         \"bottom_border\", \"top_border\",\n                         \"require_multicol\", \"height\", \"width\",\n                         \"height_units\", \"width_units\", \"table_width\",\n                         \"parbox\", \"width_by_char\", \"html_row\", \n                         \"html_col\", \"rowspan\", \"colspan\", \"value\", \"col_name\",\n                         \"col_class\", \"group\", \".\"))\n"
  },
  {
    "path": "R/print_dust_latex_hhline.R",
    "content": "#* This provides an alternative method for generating horizontal lines in \n#* LaTeX tables, using the hhline package.  The advantage to hhline is that\n#* when both backgrounds and borders are applied, the cell background won't \n#* overshadow the borders as is the case when using \\cline (the approach\n#* used by print_dust_latex.\n#* Use of the hhline method is determined by the package option\n#* getOption(\"pixiedust_latex_hhline\"), with the default being TRUE.\n\nprint_dust_latex_hhline <- function(x, ..., asis=TRUE)\n{\n  \n  if (!is.null(x$caption) & x$caption_number) increment_pixie_count()\n  \n  label <- \n    if (is.null(x[[\"label\"]]))\n    {\n      chunk_label <- knitr::opts_current$get(\"label\")\n      if (is.null(chunk_label))\n        paste0(\"tab:pixie-\", getOption(\"pixie_count\"))\n      else\n        paste0(\"tab:\", chunk_label)\n    }\n  else\n  {\n    paste0(\"tab:\", x[[\"label\"]])\n  }\n  \n  label <- \n    if (x[[\"bookdown\"]])\n    {\n      paste0(\"(\\\\#\", label, \")\")\n    }\n  else\n  {\n    paste0(\"\\\\label{\", label, \"}\")\n  }\n  \n  #* Determine the number of divisions\n  #* It looks more complicated than it is, but the gist of it is\n  #* total number of divisions: ceiling(total_rows / longtable_rows)\n  #* The insane looking data frame is just to make a reference of what rows \n  #*   go in what division.\n  if (!is.numeric(x$longtable) & x$longtable) longtable_rows <- 25L\n  else if (!is.numeric(x$longtable) & !x$longtable) longtable_rows <- as.integer(max(x$body$row))\n  else longtable_rows <- as.integer(x$longtable)\n  \n  tab_env <- if (is.numeric(x$longtable) || x$longtable) \"longtable\" else \"tabular\"\n  \n  Joint <- joint_reference_table(x)\n  \n  col_width <- determine_column_width(Joint)\n  col_halign_default <- get_column_halign(Joint)\n  \n  row_height <- lapply(list(x$head, x$body, x$foot, x$interfoot), \n                       determine_row_height)\n                       \n\n  #* Format the table parts\n  head <- part_prep_latex_hhline(x$head, col_width, col_halign_default, head = TRUE)\n  body <- part_prep_latex_hhline(x$body, col_width, col_halign_default)\n  foot <- if (!is.null(x$foot)) part_prep_latex_hhline(x$foot, col_width, col_halign_default) else NULL\n  interfoot <- if (!is.null(x$interfoot)) part_prep_latex_hhline(x$interfoot, col_width, col_halign_default) else NULL\n  \n  #* Write the LaTeX Code\n  prebegin <- numeric_longtable_newline(longtable_rows, is.numeric(x$longtable))\n  prebegin <- paste0(prebegin, \n                     \"\\\\setlength{\\\\tabcolsep}{\", x$tabcolsep, \"pt}\", sep = \"\\n\")\n  \n  if (tab_env == \"longtable\")\n  {\n    begin <- paste0(\"\\\\begin{longtable}[\",\n                    sub(\"n\", \"l\", substr(x[[\"justify\"]], 1, 1)), \"]{\",\n                    paste0(col_halign_default$default_halign, collapse = \"\"), \"}\\n\",\n                    if (!is.null(x$caption))\n                      paste(\"\\\\caption\", \n                            if (x$caption_number) \"\" else \"*\",\n                            \"{\", x$caption, \"}\")\n                    else \"\", \n                    \"\\n\", label, \"\\\\\\\\ \\n\")\n    end <- \"\\\\end{longtable}\"\n  }\n  else if (x$float)\n  {\n    begin <- paste0(\"\\\\begin{table}\\n\",\n                    if (x[[\"justify\"]] == \"center\") \"\\\\centering\\n\" else \"\",\n                    if (!is.null(x$caption))\n                      paste0(\"\\\\caption\", \n                             if (x$caption_number) \"\" else \"*\", \n                             \"{\", x$caption, \"}\")\n                    else \"\", \n                    \"\\n\", label,\n                    \"\\\\begin{tabular}{\",\n                    paste0(col_halign_default$default_halign, collapse = \"\"), \"}\\n\")\n    \n    end <- paste0(\"\\\\end{tabular}\\n\\\\end{table}\\n\")\n  }\n  else\n  {\n    begin <- paste0(if (x[[\"justify\"]] == \"center\")\n      \"\\\\begin{center}\\n\"\n      else\n        \"\",\n      if (!is.null(x$caption))\n        paste0(\"\\\\captionof{table}{\", x$caption, \"}\")\n      else \"\", \n      \"\\n\", label,\n      \"\\\\begin{tabular}{\",\n      paste0(col_halign_default$default_halign, collapse = \"\"), \"}\\n\")\n    end <- paste0(\"\\\\end{tabular}\\n\",\n                  if (x[[\"justify\"]] == \"center\")\n                    \"\\\\end{center}\\n\"\n                  else\n                    \"\")\n  }\n  \n  \n  \n  \n  #* Convert each part into a character string\n  #* Returns a character vector of length 4.\n  tbl <- mapply(paste_latex_part,\n                list(head, body, foot, interfoot),\n                row_height,\n                MoreArgs = list(newline = if (is.numeric(x$longtable)) \" \\\\ltabnewline\" else \" \\\\\\\\\"))\n\n  #* Append longtable tags\n  if (is.numeric(x$longtable) || x$longtable){\n    tbl <- paste0(tbl[c(1, 4, 3, 2)], \n                  c(\"\\n\\\\endhead\\n\", \"\\n\\\\endfoot\\n\", \"\\n\\\\endlastfoot\\n\", \"\"))\n  }\n  \n  tbl <- paste(tbl, collapse = \"\\n\")\n  \n  if (asis) knitr::asis_output(paste(prebegin, begin, tbl, end, collapse = \"\\n\"))\n  else paste(prebegin, begin, tbl, end, collapse = \"\\n\")\n\n \n}\n\n#* Prepare Cell Values for Printing\npart_prep_latex_hhline <- function(part, col_width, col_halign_default, head=FALSE)\n{\n  part <- part[!names(part) %in% \"width\"]\n  part <- merge(part, \n                col_width, \n                by = \"col\", \n                all.x = TRUE, \n                sort = FALSE)\n  part <- merge(part, \n                col_halign_default, \n                by = \"col\", \n                all.x = TRUE, \n                sort = FALSE)\n  part$width_units <- rep(\"pt\", nrow(part))\n  part$halign <- ifelse(part$halign == \"\", \n                        part$default_halign, \n                        part$halign)\n   \n    #* Calculate the row cell width for multicolumn cells\n    \n  Widths <- part[c(\"html_row\", \"html_col\", \"width\", \"merge\")]\n  Widths <- Widths[!duplicated(Widths), ]\n  Widths <- split(Widths, Widths[c(\"html_row\", \"html_col\")])\n  Widths <- lapply(Widths, \n                   function(x){\n                     x$width <- ifelse(x$merge == TRUE, \n                                       sum(x$width[x$merge]), \n                                       x$width)\n                     x\n                   })\n  Widths <- do.call(\".rbind_internal\", Widths)\n    \n  numeric_classes <- c(\"double\", \"numeric\")\n  \n  #* apply a function, if any is indicated\n  part <- perform_function(part) \n  \n  #* Perform any rounding\n  logic <- part$round == \"\" & part$col_class %in% numeric_classes\n  part$round[logic] <- getOption(\"digits\")\n  \n  logic <- part$col_class %in% numeric_classes\n  if (any(logic))\n    part$value[logic] <-\n    as.character(roundSafe(part$value[logic], as.numeric(part$round[logic])))\n  \n  #* Replacement\n  logic <- !is.na(part[[\"replace\"]])\n  part[[\"value\"]][logic] <- part[[\"replace\"]][logic]\n  \n  #* Set NA (missing) values to na_string\n  logic <- is.na(part$value) & !is.na(part$na_string)\n  part$value[logic] <- \n    part$na_string[logic]\n  \n  #* Sanitize value strings\n  #* `sanitize` is defined in `print_dust_latex.R`\n  logic <- part[[\"sanitize\"]]\n  part[[\"value\"]][logic] <- sanitize(part[[\"value\"]][logic],\n                                     part[[\"sanitize_args\"]][logic])\n\n  #* Bold and italic\n  boldify <- part$bold\n  part$value[boldify] <- paste0(\"\\\\textbf{\", part$value[boldify], \"}\")\n\n  italicize <- part$italic\n  part$value[italicize] <- paste0(\"\\\\emph{\", part$value[italicize], \"}\")\n  \n  #* Font Color\n  logic <- part$font_color != \"\"\n  part$font_color <- vapply(part$font_color, \n                            convertColor,\n                            character(1))\n  part$value[logic] <- \n    paste0(\"\\\\textcolor\", part$font_color[logic], \"{\", part$value[logic], \"}\")\n  \n  #* Font size\n  logic <- part$font_size != \"\"\n  part$font_size_units[logic] <- ifelse(part$font_size_units[logic] %in% c(\"%\", \"px\"),\n                                        \"pt\",\n                                        part$font_size_units[logic])\n  \n  part$value[logic] <- \n    paste0(\"{\\\\fontsize{\", part$font_size[logic],\n           part$font_size_units[logic], \"}{1em}\\\\selectfont \",\n           part$value[logic], \"}\")\n  \n  logic <- part$rotate_degree != \"\"\n  part$value[logic] <- \n    paste0(\"\\\\rotatebox{\", part$rotate_degree[logic], \"}{\", part$value[logic], \"}\")\n  \n  #** Background\n  logic <- part$bg != \"\"\n  part$bg[logic] <- \n    paste0(\"\\\\cellcolor\", vapply(part$bg[logic],\n                                 convertColor,\n                                 character(1)))\n  \n  part$value[logic] <- paste(part$bg[logic], part$value[logic])\n  \n  #** Borders\n  logic <- part$left_border != \"\"\n  part$left_border[logic] <- \n    vapply(part$left_border[logic], latex_vertical_border_code, character(1))\n  \n  logic <- part$right_border != \"\"\n  part$right_border[logic] <- \n    vapply(part$right_border[logic], latex_vertical_border_code, character(1))\n  \n  logic <- part$bottom_border != \"\"\n  part$bottom_border[logic] <- \n    mapply(latex_horizontal_border_code_hhline, \n           part$bottom_border[logic],\n           part$col[logic])\n  part$bottom_border[!logic] <- \"~\"\n  bottom_borders <- part[c(\"row\", \"col\", \"bottom_border\")]\n  bottom_borders <- reshape2::dcast(bottom_borders,\n                                    row ~ col, \n                                    value.var = \"bottom_border\")\n  bottom_borders <- bottom_borders[!names(bottom_borders) %in% \"row\"]\n  bottom_borders <- apply(bottom_borders, \n                          MARGIN = 1, \n                          paste0, \n                          collapse = \"\")\n  bottom_borders <- paste0(\"\\\\hhline{\", bottom_borders, \"}\")\n  \n  logic <- part$top_border != \"\"\n  part$top_border[logic] <- \n    mapply(latex_horizontal_border_code_hhline, \n           part$top_border[logic],\n           part$col[logic])\n  part$top_border[!logic] <- \"~\"\n  top_borders <- part[c(\"row\", \"col\", \"top_border\")]\n  top_borders <- reshape2::dcast(top_borders, \n                                 row ~ col, \n                                 value.var = \"top_border\", \n                                 fill = \"\")\n  top_borders <- top_borders[!names(top_borders) %in% \"row\"]\n  top_borders <- apply(top_borders, \n                       MARGIN = 1, \n                       FUN = paste0, \n                       collapse = \"\")\n  top_borders <- paste0(\"\\\\hhline{\", top_borders, \"}\")\n  \n  \n  \n  \n  parbox <- needs_parbox(part)\n  \n  \n  part$halign_parbox <- part$halign\n  part$halign_parbox[parbox] <- \n    c(\"r\" = \"\\\\raggedleft\", \n      \"c\" = \"\\\\centering\", \n      \"l\" = \"\\\\raggedright\", \n      \"p\" = \"\\\\raggedright\")[substr(part$halign[parbox], 1, 1)]\n  \n  part$value[parbox] <- \n    paste0(\"\\\\parbox[\", substr(part$valign[parbox], 1, 1), \"]{\", part$width[parbox], \"pt}{\", \n               part$halign_parbox[parbox], \" \",\n               part$value[parbox], \"}\")\n  \n  #* Add the multirow tag where appropriate\n  logic <- part$rowspan > 1\n  part$value[logic] <- \n    paste0(\"\\\\multirow{\", part$rowspan[logic], \"}{*}{\", part$value[logic], \"}\")\n  \n  #* Add blank multicolumn tags to fill multirow spaces\n  #* set the colspan and rowspan to prevent deletion.\n  #*   They are set to -1 to indicate that they are fillers\n  logic <- part$html_row != part$row & part$html_col == part$col\n  part$value[logic] <- paste0(\"\\\\multicolumn{\", part$colspan[logic], \"}\",\n                              \"{\", part$left_border[logic], \"c\", part$right_border[logic], \"}{}\")\n  part$rowspan[logic] <- -1\n  part$colspan[logic] <- part$colspan[logic] * -1\n  \n  #* Place multicolumn tags where needed\n  logic <- part$colspan > 1 | (part$left_border != \"\" | part$right_border != \"\") | \n            !(part$html_row != part$row & part$html_col == part$col)\n  part$value[logic] <- \n    paste0(\"\\\\multicolumn{\", part$colspan[logic], \"}{\", \n           part$left_border[logic], \n           #* 'p' isn't a valid alignment in 'multicol', so we replace it with 'r'\n           sub(\"p\", \"r\", substr(part$halign[logic], 1, 1)), \n           part$right_border[logic], \"}{\", part$value[logic], \"}\")\n  \n  #* Remove value where a merged cell is not the display cell\n  ncol <- max(part$col)\n  part <- part[!(part$rowspan == 0 | part$colspan == 0), ]\n  \n  #* In order to get the multirow to render correctly, the cell with \n  #* the multirow needs to be at the top of the block.  This \n  #* rearranges the merged cells so that the multirow is at the top.\n  \n  proper_multirow <- part[part$colspan != 1, ] \n  proper_multirow$group <- paste0(proper_multirow$html_row,\n                                  proper_multirow$html_col)\n  proper_multirow <- split(proper_multirow,\n                           proper_multirow$group)\n  proper_multirow <- lapply(proper_multirow,\n                            function(x){\n                              x[order(x$colspan, decreasing = TRUE), ]\n                              x$row <- sort(x$row)\n                              x\n                            })\n  proper_multirow <- do.call(\".rbind_internal\", proper_multirow)\n  \n  part <- part[part$colspan == 1, ]\n  part <- .rbind_internal(part, proper_multirow)\n  \n  part <- .make_dataframe_wide(part)\n  \n  cbind(top_borders, \n        bottom_borders,\n        part)\n}\n\n#**************************************************\n#**************************************************\n#* Prepares code for horizontal borders\nlatex_horizontal_border_code_hhline <- function(x, col){\n  border <- str_split_fixed_base(x, \" \", 3)\n  border[, 1] <- gsub(\"px\", \"pt\", border[, 1])\n  border[, 2] <- ifelse(test= border[, 2] %in% c(\"dashed\", \"dotted\", \"groove\", \n                                                \"ridge\", \"inset\", \"outset\"),\n                        yes = \"solid\", \n                        no = border[, 2])\n  if (border[, 2] %in% c(\"hidden\", \"none\")) return(\"~\")\n  if (border[, 2] == \"solid\"){\n    border_code <- paste0(\"<{\\\\arrayrulecolor\", \n                          convertColor(border[, 3]), \n                          \"}-\")\n    return(border_code)\n  }\n  if (border[, 2] %in% c(\"double\")){\n    border_code <- paste0(\">{\\\\arrayrulecolor\", \n                          convertColor(border[, 3]), \n                          \"}=\")\n    return(border_code)\n  }\n}\n\n\nutils::globalVariables(c(\"halign\", \"left_border\", \"right_border\", \n                         \"bottom_border\", \"top_border\",\n                         \"require_multicol\", \"height\", \"width\",\n                         \"height_units\", \"width_units\", \"table_width\",\n                         \"parbox\", \"width_by_char\", \"html_row\", \n                         \"html_col\", \"rowspan\", \"colspan\", \"group\"))\n"
  },
  {
    "path": "R/print_dust_markdown.R",
    "content": "print_dust_markdown <- function(x, ..., asis=TRUE,\n                                interactive = getOption(\"pixie_interactive\"))\n{\n  if (is.null(interactive)) interactive <- interactive()\n  if (!is.null(x$caption) & x$caption_number) increment_pixie_count()\n  caption_number_prefix <- \n    if (x$caption_number) sprintf(\"Table %s: \", get_pixie_count())\n    else \"\"\n  \n  #* Determine the number of divisions\n  #* It looks more complicated than it is, but the gist of it is\n  #* total number of divisions: ceiling(total_rows / longtable_rows)\n  #* The insane looking data frame is just to make a reference of what rows \n  #*   go in what division.\n  if (!is.numeric(x$longtable) & x$longtable) longtable_rows <- 25L\n  else if (!is.numeric(x$longtable) & !x$longtable) longtable_rows <- as.integer(max(x$body$row))\n  else longtable_rows <- as.integer(x$longtable)\n  \n  Divisions <- data.frame(div_num = rep(1:ceiling(max(x$body$row) / longtable_rows),\n                                        each = longtable_rows)[1:max(x$body$row)],\n                          row_num = 1:max(x$body$row))\n  total_div <- max(Divisions$div_num)\n  \n  #* If the table is not being run interactively (ie, in an rmarkdown script)\n  #* detect the type of output.  The spacing between tables is output-specific\n  if (!interactive){\n    output_type <- knitr::opts_knit$get('rmarkdown.pandoc.to')\n    linebreak <- if (is.null(output_type)) \"  \"\n    else if (output_type == \"html\") \"<br>\"\n    else if (output_type == \"latex\") \"\\\\ \\\\linebreak\"\n    else \"  \"\n  }\n  else linebreak <- \"  \"\n  \n\n  \n  #* Format the table divisions\n  head <- part_prep_markdown(x$head)\n  body <- part_prep_markdown(x$body)\n  foot <- if (!is.null(x$foot)) part_prep_markdown(x$foot) else NULL\n  interfoot <- if (!is.null(x$interfoot)) part_prep_markdown(x$interfoot) else NULL\n  \n  names(body) <- names(head) <- head[1, ]\n  \n  if (!is.null(foot)) names(foot) <- names(head)\n  if (!is.null(interfoot)) names(interfoot) <- names(head)\n  \n  subhead <- head[-1, ]\n  subhead <- lapply(subhead, function(v) paste0(\"**\", v, \"**\")) %>%\n    as.data.frame(stringsAsFactors=FALSE)\n\n  numeric_classes <- c(\"numeric\", \"double\", \"int\")\n  \n  #* Determine the alignments.  Alignments in 'knitr::kable' are assigned\n  #* by the first letter of the HTML alignment.  If no alignment is \n  #* assigned, a default is chosen based on the variable type.  Numerics\n  #* are aligned right, characters are aligned left.\n  alignments <- x$head[x$head$row == 1, ]\n  alignments <- alignments[c(\"row\", \"col\", \"halign\", \"col_class\")]\n\n  alignments$halign <- ifelse(alignments$halign == \"\",\n                              ifelse(alignments$col_class %in% numeric_classes, \n                                     \"r\",\n                                     \"l\"),\n                              substr(alignments$halign, 1, 1))\n\n  #* Run a for loop to generate all the code.\n  #* Not the most efficient way to do this, probably, but \n  #* it's easy to read and understand.\n  tbl_code <- \"\"\n  for (i in 1:total_div){\n    tbl <- .rbind_internal(if (nrow(head) > 1) subhead else NULL, \n                           body[Divisions$row_num[Divisions$div_num == i], ], \n                           if (i == total_div) foot else interfoot)\n  \n    tbl_code <- paste0(tbl_code,\n                       paste(c(\"\", \"\", \n                               knitr::kable(tbl,\n                                            format = \"markdown\",\n                                            align = substr(alignments$halign, 1, 1)),\n                               \"\\n\", linebreak, \"\\n\", linebreak, \"\\n\"), \n                             collapse = \"\\n\"))\n    \n    if (!is.null(x$caption)) \n      tbl_code <- paste0(caption_number_prefix, x$caption, \"\\n\", tbl_code)\n  }\n  if (asis) knitr::asis_output(tbl_code)\n  else tbl_code\n  \n}\n\n#**** Helper functions\n\npart_prep_markdown <- function(part)\n{\n  numeric_classes <- c(\"double\", \"numeric\")\n  \n  part <- perform_function(part)\n  \n  #* Perform any rounding\n  logic <- part$round == \"\" & part$col_class %in% numeric_classes\n  part$round[logic] <- getOption(\"digits\")\n  \n  logic <- part$col_class %in% numeric_classes\n  if (any(logic))\n    part$value[logic] <-\n    as.character(roundSafe(part$value[logic], as.numeric(part$round[logic])))\n  \n  #* Replacement\n  logic <- !is.na(part[[\"replace\"]])\n  part[[\"value\"]][logic] <- part[[\"replace\"]][logic]\n  \n  #* Bold text\n  logic <- part$bold\n  part$value[logic] <- \n    with(part, paste0(\"**\", value[logic], \"**\"))\n  \n  #* Italic text\n  logic <- part$italic\n  part$value[logic] <- \n    with(part, paste0(\"_\", value[logic], \"_\"))\n  \n  part$value[part$rowspan == 0] <- \"\"\n  part$value[part$colspan == 0] <- \"\"\n  \n  #* Set NA (missing) values to na_string\n  logic <- is.na(part$value) & !is.na(part$na_string)\n  part$value[logic] <- \n    part$na_string[logic]\n\n\n  #* Spread to wide format for printing\n  .make_dataframe_wide(part)\n}"
  },
  {
    "path": "R/pval_string.R",
    "content": "#' @name pval_string\n#' @export pval_string\n#' \n#' @title Format P-values for Reports\n#' @description Convert numeric p-values to character strings according to\n#' pre-defined formatting parameters.  Additional formats may be added\n#' for required or desired reporting standards.\n#' \n#' @param p a numeric vector of p-values.\n#' @param format A character string indicating the desired format for \n#'   the p-values.  See Details for full descriptions.\n#' @param digits For \\code{\"exact\"} and \\code{\"scientific\"}; indicates the \n#'   number of digits to precede scientific notation.\n#' @param ... Additional arguments to be passed to \\code{format}\n#' \n#' @details When \\code{format = \"default\"}, p-values are formatted:\n#' \\enumerate{\n#'   \\item \\emph{p > 0.99}: \"> 0.99\"\n#'   \\item \\emph{0.99 > p > 0.10}: Rounded to two digits\n#'   \\item \\emph{0.10 > p > 0.001}: Rounded to three digits\n#'   \\item \\emph{0.001 > p}: \"< 0.001\"\n#'  }\n#'  \n#'  When \\code{format = \"exact\"}, the exact p-value is printed with the \n#'  number of places after the deimal equal to \\code{digits}.  P-values smaller\n#'  that 1*(10^-\\code{digits}) are printed in scientific notation.\n#'  \n#'  When \\code{format = \"scientific\"}, all values are printed in scientific\n#'  notation with \\code{digits} digits printed before the \\code{e}.\n#'  \n#' @section Functional Requirements:\n#'  \\enumerate{\n#'   \\item When \\code{format = \"default\"}, print p-values greater than \n#'     0.99 as \"> 0.99\"; greater than 0.10 with two digits; \n#'     greater than 0.001 with three digits; and less than 0.001 as \n#'     \"< 0.001\".\n#'   \\item when \\code{format = \"exact\"}, print the exact p-value out to at most\n#'     \\code{digits} places past the decimal place.\n#'   \\item When \\code{format = \"scientific\"}, print the p-value in \n#'     scientific notation with up to \\code{digits} values ahead of the \n#'     \\code{e}.\n#'   \\item Cast an error if \\code{p} is not numeric on the interval [0, 1]\n#'   \\item Cast an error if format is not one of \\code{c(\"default\", \"exact\",\n#'     \"scientific\")}.\n#'   \\item Cast an error if \\code{digits} is not \\code{integerish(1)}.\n#'  }\n#'  \n#' @author Benjamin Nutter\n#'  \n#' @examples\n#'  p <- c(1, .999, .905, .505, .205, .125, .09531,\n#'         .05493, .04532, .011234, .0003431, .000000342)\n#'  pvalString(p, format=\"default\")\n#'  pvalString(p, format=\"exact\", digits=3)\n#'  pvalString(p, format=\"exact\", digits=2)\n#'  pvalString(p, format=\"scientific\", digits=3)\n#'  pvalString(p, format=\"scientific\", digits=4)\n#'  \n\npval_string <- function(p, format=c(\"default\", \"exact\", \"scientific\"),\n                       digits=3, ...){\n  \n  coll <- checkmate::makeAssertCollection()\n  \n  checkmate::assert_numeric(x = p,\n                            lower = 0,\n                            upper = 1,\n                            add = coll)\n  \n  format <- checkmate::matchArg(x = format,\n                                choices = c(\"default\", \"exact\", \"scientific\"),\n                                add = coll)\n  \n  checkmate::assert_integerish(x = digits,\n                               len = 1,\n                               add = coll)\n  \n  checkmate::reportAssertions(coll)\n  \n  #* Alpha beta format\n  if (format == \"default\"){\n    ps <- ifelse(p > .99, \n                 \"> 0.99\",\n                 ifelse(p > 0.10, \n                        format(round(p, 2), \n                               digits = 2),\n                        ifelse(p >= 0.001, \n                               format(round(p, 3), \n                                      digits = 3), \n                               \"< 0.001\")))\n  }\n  \n  #* exact format\n  else if (format == \"exact\"){\n    ps <- ifelse(p < 1*(10^-digits),\n                 format(p, \n                        scientific = TRUE, \n                        digits=digits),\n                 format(round(p, digits), \n                        digits = digits))\n  }\n  \n  #* scientific notation format\n  else if (format == \"scientific\"){\n    ps <- format(p, \n                 scientific = TRUE, \n                 digits = digits) \n  }\n  ps \n}\n\n#' @rdname pval_string\n#' @export\n\npvalString <- pval_string"
  },
  {
    "path": "R/rbind_internal.R",
    "content": "#' @name rbind_internal\n#' @title Bind Rows in Base R\n#' \n#' @description Stack data frames on top of each other. Data frames do not have to \n#'   have all of the same columns.\n#'   \n#' @param ... data frames\n#' @param deparse.level See \\code{deparse.level} in \\code{rbind}.\n#' \n#' @author Benjamin Nutter\n\n.rbind_internal <- function(..., deparse.level = 1){\n  df_list <- list(...)\n  \n  df_list <- df_list[!vapply(df_list, is.null, logical(1))]\n  \n  all_data_frame <- vapply(X = df_list, \n                           FUN = inherits, \n                           FUN.VALUE = logical(1), \n                           what = \"data.frame\")\n  \n  if (!all(all_data_frame)){\n    stop(\"All objects in ... must be data frames\")\n  }\n  \n  all_name <- unique(unlist(lapply(df_list, names)))\n  \n  df_list <-\n    lapply(df_list, \n           function(d){\n             miss_var <- setdiff(all_name, names(d))\n             miss_frame <- lapply(miss_var, \n                                  function(x) rep(NA, nrow(d)))\n             miss_frame <- as.data.frame(miss_frame, \n                                         stringsAsFactors = FALSE)\n             names(miss_frame) <- miss_var\n             if (nrow(miss_frame) > 0){\n               cbind(d, miss_frame)\n             } else {\n               d\n             }\n             \n           })\n  \n  do.call(\"rbind\", df_list)\n}\n"
  },
  {
    "path": "R/redust.R",
    "content": "#' @rdname dust\n#' \n#' @param x A dust object\n#' @param table A data frame of similar dimensions of the part being replaced.\n#' @param part The part of the table to replace with \\code{table}\n\n#' @export \n\nredust <- function(x, table, part = c(\"head\", \"foot\", \"interfoot\", \"body\"))\n{\n  UseMethod(\"redust\")\n}\n\n#' @rdname dust\n#' @export\n\nredust.default <- function(x, table, part = c(\"head\", \"foot\", \"interfoot\", \"body\"))\n{\n  coll <- checkmate::makeAssertCollection()\n\n  #* x must have class 'dust'\n  checkmate::assertClass(x = x,\n                         classes = \"dust\",\n                         add = coll)\n\n  part_str <- checkmate::matchArg(x = part, \n                               choices = c(\"head\", \"foot\",\n                                           \"interfoot\", \"body\"),\n                               add = coll)\n  \n  \n  \n  colCounts <- vapply(x[c(\"head\", \"body\", \"foot\", \"interfoot\")], \n                      col_count, 1)\n  n_colCounts <- unique(colCounts[!is.na(colCounts)])\n  \n  if (length(n_colCounts) > 1){\n      coll$push(\n        paste0(\"All parts of the table must have the same number of columns (or none).\\n\", \n               \"    Currently: \", \n               paste0(paste0(c(\"head\", \"body\", \"foot\", \"interfoot\"), \" (\", colCounts, \")\"),\n                      collapse = \", \"))\n      )\n  }\n  \n  if (!all(colCounts[!is.na(colCounts)] %in% ncol(table)))\n    coll$push(\n      paste0(\"The current table has \", paste0(n_colCounts, collapse = \"/\"), \" columns and you \",\n             \"are attempting to impose a part\\n\",\n             \"    with \", ncol(table), \" columns.\")\n    )\n  \n  checkmate::reportAssertions(coll)\n  \n  col_name_class <- \n    x[[\"head\"]][x[[\"head\"]][[\"row\"]] == 1, ]\n  col_name_class <- col_name_class[c(\"row\", \"col\", \"col_name\", \"col_class\")]\n  col_name_class <- col_name_class[order(col_name_class[[\"row\"]],\n                                         col_name_class[[\"col\"]]), ]\n  \n  part <- component_table(table)\n  part$col_name <- rep(col_name_class$col_name, each = nrow(table))\n  part$col_class <- rep(col_name_class$col_class, each = nrow(table))\n\n  x[[part_str]] <- part\n  \n  x\n}\n\n#' @rdname dust\n#' @export\n\nredust.dust_list <- function(x, table, part = c(\"head\", \"foot\", \"interfoot\", \"body\"))\n{\n  structure(\n    lapply(X = x,\n           FUN = redust.default,\n           table = table,\n           part = part),\n    class = \"dust_list\"\n  )\n}\n\n#*****\n\ncol_count <- function(p){\n  if (is.null(p)) return(NA) else return(max(p$col))\n}"
  },
  {
    "path": "R/reshape_data_internal.R",
    "content": "#' @name reshape_data_internal\n#' \n#' @title Reshape data frames for Pixiedust\n#' @description Pixiedust reshapes data to have one row per cell in the table. This \n#'   permits adjustments to be made to individual cells.  These internal functions\n#'   are provided to simplify the reshaping process. It is slower than using \n#'   the tidyr functions `gather` and `spread` (or whatever their newer counterparts \n#'   are), but keeps me off of other people's development schedules.\n#'   \n#' @param data A \\code{data.frame}\n#' \n#' @details No validations are performed in these functions, and it is assumed that\n#'   the input data set has the components it needs.\n#'   \n#' @author Benjamin Nutter\n#'\n\n.make_dataframe_long <- function(data){\n  out <- stats::reshape(data = data, \n                        varying = list(names(data)),\n                        direction = \"long\")\n  \n  names(out) <- c(\"col\", \"value\", \"row\")\n  \n  out$col_name <- names(data)[match(out$col, seq_along(names(data)))]\n  \n  out <- out[c(\"row\", \"col\", \"col_name\", \"value\")]\n  \n  rownames(out) <- NULL\n  \n  out\n}\n\n.make_dataframe_wide <- function(data){\n  col_order <- unique(data$col_name)\n  \n  out <- reshape2::dcast(data, \n                         row ~ col_name, \n                         value.var = \"value\")\n  \n  out[col_order]\n}"
  },
  {
    "path": "R/sanitize_latex.R",
    "content": "#' @name sanitize_latex\n#' @title Escape Characters for Printing in LaTeX Output\n#' \n#' @description \\code{sanitize_latex} translates particular items in \n#' character strings to LaTeX format, e.g., makes \\code{a^2 = a\\$^2\\$} \n#' for superscript within variable labels. LaTeX names of greek letters \n#' (e.g., \"alpha\") will have backslashes added if \\code{greek==TRUE}. \n#' Math mode is inserted as needed. \\code{sanitize_latex} assumes that \n#' input text always has matches, e.g. \\code{[) [] (] ()}, and that \n#' surrounding by \\code{\\$\\$} is OK.\n#' \n#' @param object \\code{character} vector of strings to translate.\n#'    Any NAs are set to blank strings before conversion.\n#' @param inn \\code{character} vector. Additional strings to translate.\n#' @param out \\code{character} vector the same length as \\code{inn}.\n#'   This gives the translated value of the corresonding element in \n#'   \\code{inn}\n#' @param greek \\code{logical(1)}. set to \\code{TRUE} to have \n#'   \\code{sanitize_latex} put names for greek letters in math mode and \n#'   add backslashes.\n#' @param pb \\code{logical(1)} If \\code{pb=TRUE}, \\code{sanitize_latex} also \n#'   translates \\code{[()]} to math mode using \\code{\\\\left}, \\code{\\\\right}.\n#' @param na \\code{character(1)} Single character string to translate \n#'   \\code{NA} values to.\n#' @param ... Additional arguments for other methods. Currently ignored.\n#' \n#' @return \n#' Vector of chracter strings.\n#' \n#' @author \n#' This code is lifted from the \\code{Hmisc} package in order to \n#' avoid depending on that package.\n#' \n#' Frank E. Harrell Jr.\\cr\n#' Department of Biostatistics,\\cr\n#' Vanderbilt University,\\cr\n#' f.harrell@@vanderbilt.edu\\cr\n#' \n#' Richard M. Heiberger,\\cr\n#' Department of Statistics,\\cr\n#' Temple University, Philadelphia, PA.\\cr\n#' rmh@@temple.edu\\cr\n#' \n#' David R. Whiting,\\cr\n#' School of Clinical Medical Sciences (Diabetes),\\cr\n#' University of Newcastle upon Tyne, UK.\\cr\n#' david.whiting@@ncl.ac.uk\\cr\n#' \n#' @seealso \\code{Hmisc::latexTranslate}, \\code{Hmisc::sedit}\n#' \n#' @examples \n#' sanitize_latex(\"75% of the cars were | more than $20,000 Delta = 1.30\", greek = TRUE)\n#' \n#' @export\n\nsanitize_latex <- function(object, inn=NULL, out=NULL, pb=FALSE,\n                           greek=FALSE, na='', ...)\n{\n  text <- ifelse(is.na(object), na, as.character(object))\n  \n  inn <- c(\"|\",  \"%\",  \"#\",   \"<=\",     \"<\",  \">=\",     \">\",  \"_\", \"\\\\243\",\n           \"&\", inn, \n           if(pb)\n             c(\"[\", \"(\", \"]\", \")\"))\n  \n  out <- c(\"$|$\", \"\\\\%\", \"\\\\#\", \"$\\\\leq$\", \"$<$\", \"$\\\\geq$\", \"$>$\", \"\\\\_\",\n           \"\\\\pounds\", \"\\\\&\", out, \n           if(pb)\n             c(\"$\\\\left[\", \"$\\\\left(\", \"\\\\right]$\", \"\\\\right)$\"))\n  \n  text <- sedit(text, '$', 'DOLLARS', wild.literal=TRUE)\n  text <- sedit(text, inn, out)\n  \n  ##See if string contains an ^ - superscript followed by a number\n  ## (number condition added 31aug02)\n  \n  dig <- c('0','1','2','3','4','5','6','7','8','9')\n  \n  for(i in seq_along(text)) {\n    lt <- nchar(text[i])\n    x <- substring(text[i], 1 : lt, 1 : lt)\n    j <- x == '^'\n    if(any(j)) {\n      is <- ((1 : lt)[j])[1]  #get first ^\n      remain <- x[-(1 : is)]\n      k <- remain %in% c(' ',',',')',']','\\\\','$')\n      if(remain[1] %in% dig ||\n         (length(remain) > 1 && remain[1] == '-' && remain[2] %in% dig))\n        k[-1] <- k[-1] | !remain[-1] %in% dig\n      \n      ie <- if(any(k)) is + ((1 : length(remain))[k])[1]\n      else\n        length(x)+1\n      \n      ##See if math mode already turned on (odd number of $ to left of ^)\n      dol <- if(sum(x[1 : is] == '$') %% 2) ''\n      else '$'\n      \n      substring2(text[i],is,ie-1) <-\n        paste(dol, '^{', substring(text[i], is + 1, ie - 1), '}', dol,sep='')\n    }\n    \n    if(greek) {\n      gl <- c('alpha','beta','gamma','delta','epsilon','varepsilon','zeta',\n              'eta','theta','vartheta','iota','kappa','lambda','mu','nu',\n              'xi','pi','varpi','rho','varrho','sigma','varsigma','tau',\n              'upsilon','phi','carphi','chi','psi','omega','Gamma','Delta',\n              'Theta','Lambda','Xi','Pi','Sigma','Upsilon','Phi','Psi','Omega')\n      for(w in gl)\n        text[i] <- gsub(paste('\\\\b', w, '\\\\b', sep=''),\n                        paste('$\\\\\\\\',w,'$',   sep=''),\n                        text[i])\n    }\n  }\n  \n  sedit(text, 'DOLLARS', '\\\\$', wild.literal=TRUE)\n}\n\n\n# UNEXPORTED --------------------------------------------------------\n\nsedit <- function(text, from, to, test=NULL, wild.literal=FALSE)\n{\n  to <- rep(to, length=length(from))\n  for(i in seq_along(text)) {\n    s <- text[i]\n    if(length(s))\n      for(j in 1:length(from)) {\n        old <- from[j]\n        front <- back <- FALSE\n        if(!wild.literal) {\n          if(substring(old,1,1) == '^') {\n            front <- TRUE;\n            old <- substring(old,2)\n          }\n          \n          if(substring(old,nchar(old)) == '$') { \n            back <- TRUE; old <- substring(old, 1, nchar(old)-1)\n          }\n        }\n        \n        new <- to[j]\n        \n        lold <- nchar(old)\n        if(lold > nchar(s))\n          next\n        \n        ex.old <- substring(old, 1:lold, 1:lold)\n        if(!wild.literal && any(ex.old == '*')) \n          s <- replace.substring.wild(s, old, new, test=test, front=front, back=back)\n        else {\n          l.s <- nchar(s)\n          is <- 1:(l.s-lold+1)\n          if(front)\n            is <- 1\n          \n          ie <- is + lold - 1\n          if(back)\n            ie <- l.s\n          \n          ss <- substring(s, is, ie)\n          k <- ss == old\n          if(!any(k))\n            next\n          \n          k <- is[k]\n          substring2(s, k, k+lold-1) <- new\n        }\n      }\n    \n    text[i] <- s\n  }\n  \n  text\n}\n\n'substring2<-' <- function(text, first, last=100000, value)\n{\n  if(is.character(first)) {\n    if(!missing(last))\n      stop('wrong # arguments')\n    \n    return(sedit(text, first, value))  ## value was setto 25May01\n  }\n  \n  lf <- length(first)\n  \n  if(length(text) == 1 && lf > 1) {\n    if(missing(last))\n      last <- nchar(text)\n    \n    last <- rep(last, length=lf)\n    for(i in 1:lf) {\n      text <- paste(if(first[i]>1) \n        substring(text, 1, first[i]-1),\n        value,\n        substring(text, last[i]+1), sep='')\n      \n      if(i < lf) {\n        j <- (i+1):lf\n        w <- nchar(value) - (last[i]-first[i]+1)\n        first[j] <- first[j] + w  \n        last[j] <- last[j] +  w\n      }\n    }\n    \n    return(text)\n  }\n  text <- paste(ifelse(first>1,substring(text, 1, first-1),''), value,\n                substring(text, last+1), sep='')\n  text\n}\n\n\nreplace.substring.wild <- function(text, old, new, test=NULL, \n                                   front=FALSE, back=FALSE)\n{\n  if(length(text)>1)\n    stop('only works with a single character string')\n  \n  if(missing(front) && missing(back)) {\n    if(substring(old,1,1) == '^') {\n      front <- TRUE;\n      old <- substring(old,2)\n    }\n    \n    if(substring(old, nchar(old)) == '$') {\n      back <- TRUE\n      old <- substring(old, 1, nchar(old)-1)\n    }\n  }\n  if((front || back) && old!='*') \n    stop('front and back (^ and $) only work when the rest of old is *')\n  \n  star.old <- substring.location(old,'*')\n  if(length(star.old$first)>1)\n    stop('does not handle > 1 * in old')\n  \n  if(sum(star.old$first) == 0)\n    stop('no * in old')\n  \n  star.new <- substring.location(new,'*')\n  if(length(star.new$first)>1)\n    stop('cannot have > 1 * in new')\n  \n  if(old == '*' && (front | back)) {\n    if(front && back)\n      stop('may not specify both front and back (or ^ and $) with old=*')\n    \n    if(length(test) == 0)\n      stop('must specify test= with old=^* or *$')\n    \n    et <- nchar(text)\n    if(front) {\n      st <- rep(1, et);\n      en <- et:1\n    } else {\n      st <- 1:et;\n      en <- rep(et,et)\n    }\n    \n    qual <- test(substring(text, st, en))\n    if(!any(qual))\n      return(text)\n    \n    st <- (st[qual])[1]\n    en <- (en[qual])[1]\n    text.before <- if(st == 1)''\n    else substring(text, 1, st-1)\n    \n    text.after  <- if(en == et)''\n    else substring(text, en+1, et)\n    \n    text.star   <- substring(text, st, en)\n    new.before.star <-\n      if(star.new$first>1) \n        substring(new, 1, star.new$first-1)\n    else ''\n    \n    new.after.star <- if(star.new$last == length(new))''\n    else substring(new, star.new$last+1)\n    \n    return(paste(text.before, new.before.star, text.star, new.after.star,\n                 text.after, sep=''))\n  }\n  \n  old.before.star <- if(star.old$first == 1)''\n  else substring(old, 1, star.old$first-1)\n  \n  old.after.star  <- if(star.old$last == nchar(old))''\n  else substring(old, star.old$first+1)\n  \n  if(old.before.star == '')\n    loc.before <- list(first=0, last=0)\n  else {\n    loc.before <- substring.location(text, old.before.star)\n    loc.before <- list(first=loc.before$first[1], last=loc.before$last[1])\n  }\n  \n  if(sum(loc.before$first+loc.before$last) == 0)\n    return(text)\n  \n  loc.after <- if(old.after.star == '') list(first=0, last=0)\n  else {\n    la <- substring.location(text, old.after.star, \n                             restrict=c(loc.before$last+1,1e10))\n    lastpos <- length(la$first)\n    la <- list(first=la$first[lastpos], last=la$last[lastpos])\n    if(la$first+la$last == 0)\n      return(text)\n    \n    la\n  }\n  \n  loc.star <- list(first=loc.before$last+1, \n                   last=if(loc.after$first == 0) nchar(text)\n                   else loc.after$first-1)\n  \n  star.text <- substring(text, loc.star$first, loc.star$last)\n  if(length(test) && !test(star.text))\n    return(text)\n  \n  if(star.new$first == 0)\n    return(paste(if(loc.before$first>1)substring(text,1,loc.before$first-1),\n                 new, sep=''))\n  \n  new.before.star <- if(star.new$first == 1)''\n  else substring(new, 1, star.new$first-1)\n  new.after.star  <- if(star.new$last == nchar(new)) ''\n  else substring(new, star.new$first+1)\n  \n  paste(if(loc.before$first>1)substring(text,1,loc.before$first-1),\n        new.before.star,\n        substring(text,loc.star$first,loc.star$last),\n        new.after.star,\n        if(loc.after$last<nchar(text) && loc.after$last>0) \n          substring(text,loc.after$last+1),\n        sep='')\n}\n\nsubstring.location <- function(text, string, restrict)\n{\n  if(length(text) > 1)\n    stop('only works with a single character string')\n  \n  l.text <- nchar(text)\n  l.string <- nchar(string)\n  if(l.string > l.text)\n    return(list(first=0,last=0))\n  \n  if(l.string == l.text)\n    return(if(text == string)\n      list(first=1,last=l.text)\n      else \n        list(first=0,last=0))\n  \n  is <- 1:(l.text-l.string+1)\n  ss <- substring(text, is, is+l.string-1)\n  k <- ss == string\n  if(!any(k))\n    return(list(first=0,last=0))\n  \n  k <- is[k]\n  if(!missing(restrict))\n    k <- k[k>=restrict[1] & k<=restrict[2]]\n  \n  if(length(k) == 0)\n    return(list(first=0,last=0))\n  \n  list(first=k, last=k+l.string-1)\n}\n\n\n## if(version$major < 5)  14Sep00\nsubstring2 <- function(text, first, last=100000L)\n  base::substring(text, first, last)"
  },
  {
    "path": "R/sprinkle.R",
    "content": "#' @name sprinkle\n#' @export sprinkle\n#' \n#' @title Define Customizations to a Table\n#' @description Customizations to a \\code{dust} table are added by \"sprinkling\"\n#'   with a little extra pixie dust.  Sprinkles are a collection of attributes\n#'   to be applied over a subset of table cells.  They may be added to any \n#'   part of the table, or to the table as a whole.\n# Parameters --------------------------------------------------------  \n#' @param x A dust object\n#' @param rows A numeric vector specifying the rows of the table to sprinkle.\n#'   See details for more about sprinkling.\n#' @param cols A numeric (or character) vector specifying the columns (or \n#'   column names) to sprinkle.  See details for more about sprinkling.\n#' @param part A character string denoting which part of the table to modify.\n#' @param fixed \\code{logical(1)} indicating if the values in \\code{rows} \n#'   and \\code{cols} should be read as fixed coordinate pairs.  By default, \n#'   sprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \n#'   meaning that the arguments do not have to share the same length.  \n#'   When \\code{fixed = TRUE}, they must share the same length.\n#' @param recycle A \\code{character} one that determines how sprinkles are \n#'   managed when the sprinkle input doesn't match the length of the region\n#'   to be sprinkled.  By default, recycling is turned off.  Recycling \n#'   may be performed across rows first (left to right, top to bottom), \n#'   or down columns first (top to bottom, left to right).\n#' @param ... named arguments, each of length 1, defining the customizations\n#'   for the given cells.  See \"Sprinkles\" for a listing of these arguments.\n#'   \n# Details -----------------------------------------------------------\n#' @details Sprinkling is done over the intersection of rows and columns \n#'   (unless \\code{fixed = TRUE}.  If\n#'   rows but no columns are specified, sprinkling is performed over all columns\n#'   of the given given rows. The reverse is true for when columns but no rows\n#'   are specified.  If neither columns nor rows are specified, the attribute \n#'   is applied over all of the cells in the table part denoted in \\code{part}.\n#'\n#'   If at least one of \\code{border}, \\code{border_thickness}, \\code{border_units},\n#'   \\code{border_style} or \\code{border_color} is specified, the remaining\n#'   unspecified attributes assume their default values.\n#'   \n#'   Other sprinkle pairings are \\code{height} and \\code{height_units}; \n#'   \\code{width} and \\code{width_units}; \\code{font_size} and \\code{font_size_units};\n#'   \\code{bg_pattern} and \\code{bg_pattern_by}\n#'   \n#'   The sprinkles \\code{bg} and \\code{bg_pattern} may not be used together.\n#'   \n#'   A more detailed demonstration of the use of sprinkles is available in \n#'   \\code{vignette(\"pixiedust\", package = \"pixiedust\")}\n#'   \n#'   Using \\code{sprinkle_table}, sprinkles may be applied to the columns of multiple tables. Table\n#'   parts are required to have the same number of columns, but not necessarily the same number \n#'   of rows, which is why the \\code{rows} argument is not available for the \\code{sprinkle_table}.\n#'   In contrast to \\code{sprinkle}, the \\code{part} argument in \\code{sprinkle_table} will \n#'   accept multiple parts.  If any of the named parts is \\code{\"table\"}, the sprinkle will be \n#'   applied to the columns of all of the parts.\n#'   \n# Sprinkles ---------------------------------------------------------  \n#' @section Sprinkles:\n#' The following table describes the valid sprinkles that may be defined in the \n#' \\code{...} dots argument.  All sprinkles may be defined for any output type, but \n#' only sprinkles recognized by that output type will be applied when printed.  \n#' A more readable format of this information is available in  \n#' \\code{vignette(\"sprinkles\", package = \"pixiedust\")}.\n#' \n#' \\tabular{lll}{\n#' bg  \\tab           \\tab  \\cr\n#'     \\tab action    \\tab Modifies the background color of a cell. \\cr\n#'     \\tab default   \\tab  \\cr\n#'     \\tab accepts   \\tab dvips color names; rgb(R,G,B); rgba(R,G,B,A); \\cr\n#'     \\tab           \\tab  #RRGGBB; #RRGGBBAA. See the \"Colors\" section \\cr\n#'     \\tab           \\tab  for further details. \\cr\n#'     \\tab console   \\tab Not recognized \\cr\n#'     \\tab markdown  \\tab Not recognized \\cr\n#'     \\tab html      \\tab Accepts any of the listed formats; \\cr\n#'     \\tab           \\tab recognizes transparency \\cr\n#'     \\tab latex     \\tab Accepts any of the listed formats, \\cr\n#'     \\tab           \\tab but ignores transparency \\cr\n#' bg_pattern \\tab    \\tab  \\cr\n#'  \\tab action       \\tab Generates a pattern of background colors.  \\cr\n#'  \\tab              \\tab Can be used to make striping \\cr\n#'  \\tab              \\tab by rows or by columns. \\cr\n#'  \\tab default      \\tab c(\"#FFFFFF\", \"#DDDDDD\") \\cr\n#'  \\tab accepts      \\tab A vector of color names: \\cr\n#'  \\tab              \\tab dvips color names; rgb(R,G,B); rgba(R,G,B,A); \\cr \n#'  \\tab              \\tab #RRGGBB; #RRGGBBAA \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Accepts any of the listed formats; \\cr\n#'  \\tab              \\tab recognizes transparency \\cr\n#'  \\tab latex        \\tab Accepts any of the listed formats, \\cr\n#'  \\tab              \\tab but ignores transparency \\cr\n#' bg_pattern_by  \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Determines if a `bg_pattern` is patterned \\cr \n#'  \\tab              \\tab by row or by columns. \\cr\n#'  \\tab default      \\tab \"rows\" \\cr\n#'  \\tab accepts      \\tab \"rows\", \"columns\", \"cols\" \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Recognized \\cr\n#' bold \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Renders text within a cell in bold. \\cr\n#'  \\tab default      \\tab FALSE \\cr\n#'  \\tab accepts      \\tab logical(1) \\cr\n#'  \\tab console      \\tab Recognized; rendered as double asterisks on either\\cr\n#'  \\tab              \\tab side of the text \\cr\n#'  \\tab markdown     \\tab Recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Recognized \\cr\n#' border_collapse \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Sets the `border-collapse` property in an \\cr\n#'  \\tab              \\tab HTML table.  The property sets whether the \\cr\n#'  \\tab              \\tab table borders are collapsed into a  \\cr\n#'  \\tab              \\tab single border or detached as in standard HTML. \\cr\n#'  \\tab default      \\tab TRUE \\cr\n#'  \\tab accepts      \\tab logical(1) \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Not recognized \\cr\n#' border \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Sets a border on the specified side of a cell. \\cr\n#'  \\tab default      \\tab  \\cr\n#'  \\tab accepts      \\tab Any combination of \"all\", \"bottom\", \"left\", \"top\",\\cr\n#'  \\tab              \\tab \"right\".  Using  \"all\" results in all borders \\cr\n#'  \\tab              \\tab being drawn, regardless of what other values are \\cr\n#'  \\tab              \\tab passed with it. \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Recognized \\cr\n#' border_color \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Sets the color of the borders specified for a cell. \\cr\n#'  \\tab default      \\tab \"Black\" \\cr\n#'  \\tab accepts      \\tab character(1) \\cr\n#'  \\tab              \\tab dvips color names; rgb(R,G,B); rgba(R,G,B,A); \\cr\n#'  \\tab              \\tab #RRGGBB; #RRGGBBAA. See the \"Colors\" section \\cr\n#'     \\tab           \\tab  for further details. \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Recognized \\cr\n#' border_style \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Sets the border style for a specified cell \\cr\n#'  \\tab default      \\tab \"solid\" \\cr\n#'  \\tab accepts      \\tab character(1) \\cr\n#'  \\tab              \\tab \"solid\", \"dashed\", \"dotted\", \"double\", \"groove\", \\cr\n#'  \\tab              \\tab \"ridge\", \"inset\", \"outset\", \"hidden\", \"none\" \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Accepts any of the values listed. \\cr\n#'  \\tab latex; hhline = FALSE \\tab accepts \"solid\", \"dashed\", \"dotted\",  \\cr\n#'  \\tab              \\tab  \"hidden\", \"none\" \\cr\n#'  \\tab              \\tab \"dotted\" is silently changed to \"dashed\" \\cr\n#'  \\tab              \\tab \"hidden\" and \"none\" are equivalent. \\cr\n#'  \\tab latex; hhline = TRUE \\tab accepts \"solid\", \"double\", \"hidden\", \"none\" \\cr\n#'  \\tab              \\tab \"hidden\" and \"none\" are equivalent. \\cr\n#' border_thickness \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Sets the thickness of the specified border \\cr\n#'  \\tab default      \\tab 1 \\cr\n#'  \\tab accepts      \\tab numeric(1) \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Recognized \\cr\n#' border_units \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Sets the unit of measure for the specified border \\cr\n#'  \\tab              \\tab thickness \\cr\n#'  \\tab default      \\tab \"pt\" \\cr\n#'  \\tab accepts      \\tab \"pt\", \"px\" \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Silently changes \"px\" to \"pt\" \\cr\n#' caption \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Adds or alters the `caption` property \\cr\n#'  \\tab default      \\tab  \\cr\n#'  \\tab accepts      \\tab character(1) \\cr\n#'  \\tab console      \\tab Recognized \\cr\n#'  \\tab markdown     \\tab Recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Recognized \\cr\n#' discrete \\tab \\tab \\cr\n#'  \\tab action       \\tab Adds distinct background colors based on \\cr\n#'  \\tab              \\tab discrete values in the selected region. \\cr\n#'  \\tab              \\tab May not be used concurrently with \\code{bg}. \\cr\n#'  \\tab              \\tab \\code{\"font\"} is an alias for \\code{\"font_color\"} \\cr\n#'  \\tab              \\tab and \\code{\"border\"} is an alias for \\cr\n#'  \\tab              \\tab all borders. \\cr\n#'  \\tab default      \\tab \"bg\" \\cr\n#'  \\tab accepts      \\tab \"bg\", \"font\", \"font_color\", \"border\", \\cr\n#'  \\tab              \\tab \"left_border\", \"top_border\", \"right_border\", \\cr\n#'  \\tab              \\tab \"bottom_border\" \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Recognized \\cr\n#' discrete_color \\tab \\tab \\cr\n#'  \\tab action       \\tab Sets the color palette from which \\code{discrete} \\cr\n#'  \\tab              \\tab selects background colors. If \\code{NULL} \\cr\n#'  \\tab              \\tab colors are automatically selected using \\cr\n#'  \\tab              \\tab the \\code{scales} package. \\cr\n#'  \\tab default      \\tab \\code{getOption(\"pixie_discrete_pal\", NULL)} \\cr\n#'  \\tab accepts      \\tab character \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Recognized \\cr\n#' float \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Sets the `float` property \\cr\n#'  \\tab default      \\tab TRUE \\cr\n#'  \\tab accepts      \\tab logical(1) \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Not recognized \\cr\n#'  \\tab latex        \\tab Recognized \\cr\n#' fn \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Applies a function to the value of a cell. \\cr\n#'  \\tab              \\tab The function should be an \\cr\n#'  \\tab              \\tab expression that acts on the variable `value`.  \\cr \n#'  \\tab              \\tab For example, \\code{quote(format(value, nsmall = 3))} \\cr\n#'  \\tab default      \\tab  \\cr\n#'  \\tab accepts      \\tab call \\cr\n#'  \\tab console      \\tab Recognized \\cr\n#'  \\tab markdown     \\tab Recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Recognized \\cr\n#' font_color \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Sets the color of the cell text \\cr\n#'  \\tab default      \\tab Black \\cr\n#'  \\tab accepts      \\tab dvips color names; rgb(R,G,B); rgba(R,G,B,A); \\cr\n#'  \\tab              \\tab #RRGGBB; #RRGGBBAA. See the \"Colors\" section \\cr\n#'     \\tab           \\tab  for further details. \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Recognized; transparency recognized \\cr\n#'  \\tab latex        \\tab Recognized; transparency ignored \\cr\n#' font_family \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Sets the font for the text \\cr\n#'  \\tab default      \\tab Times New Roman \\cr\n#'  \\tab accepts      \\tab character(1) \\cr\n#'  \\tab              \\tab http://www.w3schools.com/cssref/css_websafe_fonts.asp \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Not recognized \\cr\n#' font_size \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Sets the size of the font in the cell \\cr\n#'  \\tab default      \\tab  \\cr\n#'  \\tab accepts      \\tab numeric(1) \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Recognized \\cr\n#' font_size_units \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Determines the units in which `font_size` \\cr\n#'  \\tab              \\tab is measured \\cr\n#'  \\tab default      \\tab \"px\" \\cr\n#'  \\tab accepts      \\tab \"px\", \"pt\", \"\\%\", \"em\" \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Only recognizes \"pt\" and \"em\".  \\cr\n#'  \\tab              \\tab All others are coerced to \"pt\" \\cr\n#' gradient \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Adds distinct background colors based on \\cr\n#'  \\tab              \\tab progressively increasing values in the \\cr\n#'  \\tab              \\tab selected region. May not be used concurrently \\cr \n#'  \\tab              \\tab with \\code{bg}. \\cr\n#'  \\tab              \\tab \\code{\"font\"} is an alias for \\code{\"font_color\"} \\cr\n#'  \\tab              \\tab and \\code{\"border\"} is an alias for \\cr\n#'  \\tab              \\tab all borders. \\cr\n#'  \\tab default      \\tab \"bg\" \\cr\n#'  \\tab accepts      \\tab \"bg\", \"font\", \"font_color\", \"border\", \\cr\n#'  \\tab              \\tab \"left_border\", \"top_border\", \"right_border\", \\cr\n#'  \\tab              \\tab \"bottom_border\" \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Recognized \\cr\n#' gradient_colors \\tab \\tab \\cr\n#'  \\tab action       \\tab Provides the colors between which to \\cr\n#'  \\tab              \\tab shade gradients. \\cr\n#'  \\tab default      \\tab \\code{getOptions(\"pixie_gradient_pal\", NULL)} \\cr\n#'  \\tab accepts      \\tab character \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Recognized \\cr\n#' gradient_cut \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Determines the breaks points for the \\cr\n#'  \\tab              \\tab gradient shading. When \\code{NULL}  \\cr\n#'  \\tab              \\tab equally spaced quantiles are used, the \\cr\n#'  \\tab              \\tab number of which are determined by \\cr\n#'  \\tab              \\tab \\code{gradient_n}. \\cr\n#'  \\tab default      \\tab NULL \\cr\n#'  \\tab accepts      \\tab numeric \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Recognized \\cr\n#' gradient_n \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Determines the number of shades to use \\cr\n#'  \\tab              \\tab between the colors in \\code{gradient_colors}.\\cr\n#'  \\tab default      \\tab 10 \\cr\n#'  \\tab accepts      \\tab numeric \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Recognized \\cr\n#' gradient_na \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Sets the color of NA values when gradients \\cr\n#'  \\tab              \\tab are shaded. \\cr\n#'  \\tab default      \\tab grey \\cr\n#'  \\tab accepts      \\tab character(1) \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Recognized \\cr\n#' halign \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Sets the horizontal alignment of the text in \\cr\n#'  \\tab              \\tab the cell \\cr\n#'  \\tab default      \\tab  \\cr\n#'  \\tab accepts      \\tab \"left\", \"center\", \"right\" \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Recognized; numeric values will auto align to the \\cr\n#'  \\tab              \\tab right if no value given. \\cr\n#'  \\tab html         \\tab Recognized.  Does not currently employ auto \\cr\n#'  \\tab              \\tab alignment of numeric values, but this may change. \\cr\n#'  \\tab latex        \\tab Recognized; numeric values will auto align to \\cr\n#'  \\tab              \\tab the right if no value given. \\cr\n#' height \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Sets the height of the cell \\cr\n#'  \\tab default      \\tab  \\cr\n#'  \\tab accepts      \\tab numeric(1) \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Recognized \\cr\n#' height_units \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Determines the units in which `height` is measured \\cr\n#'  \\tab default      \\tab \"pt\" \\cr\n#'  \\tab accepts      \\tab \"px\", \"pt\", \"cm\", \"in\", \"\\%\" \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Recognized; \"px\" is coerced to \"pt\" \\cr\n#' hhline \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Toggles the option for cell border drawing with \\cr \n#'  \\tab              \\tab the `hhline` LaTeX package \\cr\n#'  \\tab default      \\tab FALSE \\cr\n#'  \\tab accepts      \\tab logical(1) \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Not recognized \\cr\n#'  \\tab latex        \\tab Recognized.  When `FALSE` double borders are \\cr \n#'  \\tab              \\tab not available. \\cr\n#'  \\tab              \\tab When `TRUE`, colored and dashed borders are not \\cr\n#'  \\tab              \\tab available. This is usually the better option \\cr\n#'  \\tab              \\tab when using colored backgrounds in table cells. \\cr\n#' italic \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Renders the text in the cell in italic \\cr\n#'  \\tab default      \\tab FALSE \\cr\n#'  \\tab accepts      \\tab logical(1) \\cr\n#'  \\tab console      \\tab Recognized; rendered as an underscore on either \\cr\n#'  \\tab              \\tab side of the text. \\cr\n#'  \\tab markdown     \\tab Recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Recognized \\cr\n#' justify \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Justifies the entire table on the page. \\cr\n#'  \\tab default      \\tab \"center\" \\cr\n#'  \\tab accepts      \\tab character(1) \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Recognizes \"center\", but both \"left\" and \"right\" \\cr\n#'  \\tab              \\tab are rendered as left justified.  This may change \\cr\n#'  \\tab              \\tab if a satisfactory solution is found.  \\cr\n#'  \\tab              \\tab Usually, tables are best left centered. \\cr\n#' longtable \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Toggles the use of the LaTeX `longtable` style \\cr\n#'  \\tab              \\tab tables, namely allowing long tables to be broken \\cr\n#'  \\tab              \\tab into multiple sections. The table header appears \\cr \n#'  \\tab              \\tab at the top of each section. The table interfoot \\cr\n#'  \\tab              \\tab appears at the bottom of each section, except \\cr\n#'  \\tab              \\tab for the last. \\cr\n#'  \\tab              \\tab The table foot appears at the bottom of the \\cr\n#'  \\tab              \\tab last section. \\cr\n#'  \\tab              \\tab May accept either a logical or a numerical value.  \\cr\n#'  \\tab              \\tab If numerical, each section will have the specified \\cr\n#'  \\tab              \\tab number of rows. \\cr\n#'  \\tab default      \\tab FALSE \\cr\n#'  \\tab accepts      \\tab logical(1); numeric(1) \\cr\n#'  \\tab console      \\tab Recognized; when `TRUE`, defaults to 25 rows \\cr\n#'  \\tab              \\tab per section. \\cr\n#'  \\tab markdown     \\tab Recognized; when `TRUE`, defaults to 25 rows \\cr\n#'  \\tab              \\tab per section. \\cr\n#'  \\tab html         \\tab Recognized; when `TRUE`, defaults to 25 rows \\cr\n#'  \\tab              \\tab per section. \\cr\n#'  \\tab latex        \\tab Recognized; when `TRUE`, `longtable`'s own algorithm \\cr \n#'  \\tab              \\tab will determine the number of rows per section. \\cr\n#'  \\tab              \\tab When numeric, breaks are forced at the specified \\cr\n#'  \\tab              \\tab number of rows. \\cr\n#' merge \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Merges cells in the specified range into a \\cr\n#'  \\tab              \\tab single cell. In cases where \\cr\n#'  \\tab              \\tab either `merge_rowval` or `merge_colval` is \\cr\n#'  \\tab              \\tab specified, they will only be  \\cr\n#'  \\tab              \\tab honored if `merge = TRUE`.  You must opt in to \\cr\n#'  \\tab              \\tab this action. \\cr\n#'  \\tab default      \\tab FALSE \\cr\n#'  \\tab accepts      \\tab logical(1) \\cr\n#'  \\tab console      \\tab Recognized \\cr\n#'  \\tab markdown     \\tab Recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Recognized \\cr\n#' merge_rowval \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Specifies the row value of the merged range to \\cr\n#'  \\tab              \\tab print in the table \\cr\n#'  \\tab default      \\tab minimum row value of the merged range \\cr\n#'  \\tab accepts      \\tab numeric(1) \\cr\n#'  \\tab console      \\tab Recognized \\cr\n#'  \\tab markdown     \\tab Recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Recognized \\cr\n#' merge_colval \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Specifies the column value of the merged range \\cr\n#'  \\tab              \\tab to print in the table \\cr\n#'  \\tab default      \\tab minimum col value of the merged range \\cr\n#'  \\tab accepts      \\tab numeric(1) \\cr\n#'  \\tab console      \\tab Recognized \\cr\n#'  \\tab markdown     \\tab Recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Recognized \\cr\n#' na_string \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Designates the character string to use in place \\cr\n#'  \\tab              \\tab of missing values \\cr\n#'  \\tab default      \\tab NA \\cr\n#'  \\tab accepts      \\tab character(1) \\cr\n#'  \\tab console      \\tab Recognized \\cr\n#'  \\tab markdown     \\tab Recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Recognized \\cr\n#' pad \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Designates the padding to place between cell \\cr\n#'  \\tab              \\tab text and boundaries \\cr\n#'  \\tab              \\tab Measured in pixels. \\cr\n#'  \\tab default      \\tab 0 \\cr\n#'  \\tab accepts      \\tab numeric(1) \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Not recognized \\cr\n#' replace \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Replaces existing cell values with user-specified \\cr\n#'  \\tab              \\tab content. Replacement occurs moving down columns \\cr\n#'  \\tab              \\tab from left to right. \\cr\n#'  \\tab default      \\tab  \\cr\n#'  \\tab accepts      \\tab character vector of the same length as the number \\cr\n#'  \\tab              \\tab of cells being replaced. \\cr\n#'  \\tab console      \\tab Recognized \\cr\n#'  \\tab markdown     \\tab Recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Recognized \\cr\n#' rotate_degree \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Rotates text in cells by the designated angle \\cr\n#'  \\tab              \\tab in degrees \\cr\n#'  \\tab default      \\tab  \\cr\n#'  \\tab accepts      \\tab numeric(1) \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Recognized \\cr\n#' round \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Applies the `round` function to values in the \\cr \n#'  \\tab              \\tab cell.  Skips any character values it encounters. \\cr\n#'  \\tab default      \\tab \\code{getOption(\"digits\")} \\cr\n#'  \\tab accepts      \\tab numeric(1) \\cr\n#'  \\tab console      \\tab Recognized \\cr\n#'  \\tab markdown     \\tab Recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Recognized \\cr\n#' sanitize \\tab  \\tab  \\cr\n#'  \\tab action\t      \\tab Sanitizes character values that may cause \\cr\n#'  \\tab              \\tab difficulties for the rendered format.  \\cr\n#'  \\tab default\t    \\tab FALSE      \\cr\n#'  \\tab accepts\t    \\tab logical(1) \\cr\n#'  \\tab console\t    \\tab Not recognized \\cr\n#'  \\tab markdown\t    \\tab Not recognized \\cr\n#'  \\tab html         \\tab Not recognized \\cr\n#'  \\tab latex\t      \\tab Recognized.  Sanitization is performed using \\cr\n#'  \\tab              \\tab \\code{\\link[Hmisc]{latexTranslate}} \\cr\n#' sanitize_args\t\\tab \\tab \\cr\n#'  \\tab action\t      \\tab Passes additional arguments to \\code{\\link[Hmisc]{latexTranslate}} \\cr\n#'  \\tab default\t    \\tab \\code{list()} \\cr\n#'  \\tab accepts\t    \\tab list.  See documentation for \\code{\\link[Hmisc]{latexTranslate}} \\cr\n#'  \\tab              \\tab for details \\cr\n#'  \\tab console\t    \\tab Not recognized \\cr\n#'  \\tab markdown\t    \\tab Not recognized \\cr\n#'  \\tab html\t        \\tab Not recognized \\cr\n#'  \\tab latex\t      \\tab Recognized \\cr\n#' tabcolsep \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Modifies the LaTeX `tabcolsep` parameter of tables \\cr\n#'  \\tab              \\tab This is similar to `pad` for HTML tables, but only  \\cr\n#'  \\tab              \\tab affects the space between columns. Measured in \"pt\" \\cr\n#'  \\tab default      \\tab 6 \\cr\n#'  \\tab accepts      \\tab numeric(1) \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Not recognized \\cr\n#'  \\tab latex        \\tab Recognized \\cr\n#' valign \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Designates the vertical alignment of a cell. \\cr\n#'  \\tab default      \\tab  \\cr\n#'  \\tab accepts      \\tab \"top\", \"middle\", \"bottom\" \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Recognized \\cr\n#' width \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Sets the width of the cell \\cr\n#'  \\tab default      \\tab  \\cr\n#'  \\tab accepts      \\tab numeric(1) \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Recognized \\cr\n#' width_units \\tab  \\tab  \\cr\n#'  \\tab action       \\tab Determines the units in which `width` is measured \\cr\n#'  \\tab default      \\tab \"pt\" \\cr\n#'  \\tab accepts      \\tab \"px\", \"pt\", \"cm\", \"in\", \"\\%\" \\cr\n#'  \\tab console      \\tab Not recognized \\cr\n#'  \\tab markdown     \\tab Not recognized \\cr\n#'  \\tab html         \\tab Recognized \\cr\n#'  \\tab latex        \\tab Recognized; \"px\" is coerced to \"pt\" \\cr\n#' }\n#' \n# Longtable details -------------------------------------------------\n#' @section Longtable:\n#' The \\code{longtable} feature is named for the LaTeX package used to break very large \n#' tables into multiple pages.  \n#' \n#' When using the \\code{longtable=TRUE} option, the default number of rows per table is 25 for \n#' console, HTML, and markdown output.  For LaTeX output, the number of rows is determined by \n#' the LaTeX \\code{longtable} package's algorithm. The number of rows per table only considers \n#' the content in the body of the table.  Consideration for the number of rows in the head and \n#' foot are the responsibility of the user.\n#'   \n#' Whenever a table is broken into multiple parts, each part retains the table head.  If any \n#' \\code{interfoot} is provided, it is appended to the bottom of each section, with the \n#' exception of the last section.  The last section has the \\code{foot} appended.\n#'\n# Colors ------------------------------------------------------------\n#' @section Colors:\n#' Colors may be declared as any of the color names in \\code{colors()}, \n#' as rgb character strings such as \\code{\"rgb(rrr,ggg,bbb)\"} or as \n#' hexadecimal character strings such as \\code{\"#rrggbb\"}.  \n#' \n#' Transparency is also recognized by HTML output, and may be indicated \n#' in the rgba format \\code{\"rgba(rrr,ggg,bbb,aa)\"}, where \\code{aa} is a \n#' number between 0 and 1, inclusive.  Alternative, transparency may be \n#' given as \\code{\"#rrggbbAA\"}, where \\code{AA} is a hexadecimal \n#' representation of transparency with \"00\" being completely transparent \n#' and \"FF\" being completely opaque.\n#' \n#' LaTeX output does not recognize transparency and will quietly drop the \n#' transparency parameter.\n#'\n#' All colors are internally translated into rgb format and are case insensitive.\n#' \n# LaTeX Packages ----------------------------------------------------\n#' @section Required LaTeX Packages:\n#' \n#' If you will be using the LaTeX output, some sprinkles will require you \n#' to include additional LaTeX packages in your document preamble.  In \n#' \\code{.Rnw} files, additional packages can be included with the \n#' \\code{\\\\usepackage\\{[package]\\}} syntax.  In markdown, additional packages\n#' are included using \\code{header-includes:} in the YAML front matter with \n#' a line of the format \\code{\\\\usepackage\\{[package]\\}} for each package to \n#' be used.  Sprinkles that require additional packages, and the LaTeX packages\n#' required, are listed below:\n#' \n#' \\tabular{ll}{\n#'   Sprinkle \\tab LaTeX Package(s) \\cr\n#'   \\code{font_color} \\tab \\code{\\\\usepackage[dvipsnames]\\{xcolor\\}} \\cr\n#'   \\code{bg, bg_pattern} \\tab \\code{\\\\usepackage[dvipsnames,table]\\{xcolor\\}} \\cr\n#'   \\code{border_style} \\tab \\code{\\\\usepackage\\{arydshln\\}} \\cr\n#'       \\tab  \\code{\\\\usepackage\\{amssymb\\}} \\cr\n#'       \\tab  \\code{\\\\usepackage\\{hhline\\}} \\cr\n#'       (with vertical dashed lines) \\tab \\\\usepackage\\{graphicx\\} \\cr\n#'       \\tab \\code{\\\\makeatletter} \\cr\n#'       \\tab \\code{\\\\newcommand*\\\\vdashline\\{\\\\rotatebox[origin=c]\\{90\\}\\{\\$\\\\dabar@@\\\\dabar@@\\\\dabar@@\\$\\}\\}} \\cr\n#'       \\tab \\code{\\\\makeatother} \\cr\n#'   \\code{longtable} \\tab \\code{\\\\usepackage\\{longtable\\}} \\cr\n#'       \\tab (Must be loaded before \\code{arydshln}) \\cr\n#'   \\code{merge} \\tab \\code{\\\\usepackage\\{multirow\\}} \\cr\n#'   \\code{captions} for non floats \\tab \\code{\\\\usepackage\\{caption\\}} \n#' }\n#' \n#' Note that \\code{hhline} is used to make horizontal lines when \n#' \\code{options(pixiedust_latex_hhline = TRUE)} (the package default is \\code{FALSE}), \n#' otherwise the \\code{cline} command is used.  \n#' \n#' Use of \\code{cline} permits colored borders and dashed borders, but \n#' borders around cells with background colors are sometimes (often) lost.\n#' \n#' Use of \\code{hhline} preserves borders around cells with background colors \n#' and permits double borders, but colored and dashed borders are not available.\n#' \n#' In order to ensure all features are available, the recommended code block (accounting for \n#' the proper order to load packages) is:\n#' \n#' \\code{header-includes:} \\cr\n#' \\code{ - \\\\usepackage\\{amssymb\\}} \\cr\n#' \\code{ - \\\\usepackage\\{arydshln\\}} \\cr\n#' \\code{ - \\\\usepackage\\{caption\\}}  \\cr\n#' \\code{ - \\\\usepackage\\{graphicx\\}} \\cr\n#' \\code{ - \\\\usepackage\\{hhline\\}} \\cr\n#' \\code{ - \\\\usepackage\\{longtable\\}} \\cr\n#' \\code{ - \\\\usepackage\\{multirow\\}} \\cr\n#' \\code{ - \\\\usepackage[dvipsnames,table]\\{xcolor\\}} \\cr\n#' \\code{ - \\\\makeatletter} \\cr\n#' \\code{ - \\\\newcommand*\\\\vdashline\\{\\\\rotatebox[origin=c]\\{90\\}\\{\\$\\\\dabar@@\\\\dabar@@\\\\dabar@@\\$\\}\\}} \\cr\n#' \\code{ - \\\\makeatother}\n#' \n# Remaining Documentation -------------------------------------------\n#' @seealso \n#' \\code{\\link{sprinkle_colnames}} for changing column names in a table.\n#' \n#' @source \n#' Altering the number of rows in a LaTeX longtable \\cr\n#' http://tex.stackexchange.com/questions/19710/how-can-i-set-the-maximum-number-of-rows-in-a-page-for-longtable\n#' \n#' Vertical dashed cell borders in LaTeX table \\cr\n#' http://www.latex-community.org/forum/viewtopic.php?f=45&t=3149\n#' \n#' Colored Cell border \\cr\n#' http://tex.stackexchange.com/questions/40666/how-to-change-line-color-in-tabular\n#' \n#' @author Benjamin Nutter\n#' \n#' @examples \n#' x <- dust(lm(mpg ~ qsec + factor(am), data = mtcars))\n#' x %>% sprinkle(cols = 2:4, round = 3) %>% \n#'   sprinkle(cols = 5, fn = quote(pvalString(value))) %>% \n#'   sprinkle(rows = 2, bold = TRUE)\n#'\n\n#' @rdname sprinkle\n#' @export\n\n# sprinkle method ---------------------------------------------------\nsprinkle <- function(x, rows = NULL, cols = NULL, ...,\n                     part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"))\n{\n  UseMethod(\"sprinkle\")\n}\n\n# sprinkle.default --------------------------------------------------\n#' @rdname sprinkle\n#' @export\n\nsprinkle.default <- function(x, rows = NULL, cols = NULL, ...,\n                             part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                             fixed = FALSE, \n                             recycle = c(\"none\", \"rows\", \"cols\", \"columns\"))\n{\n  \n  sprinkles <- list(...)\n  \n# Argument validations ----------------------------------------------\n  coll <- checkmate::makeAssertCollection()\n\n  checkmate::assertClass(x = x,\n                         classes = \"dust\",\n                         add = coll)\n\n  if (!length(sprinkles)){\n    coll$push(\"At least one sprinkle must be declared in ...\")\n  }\n  else\n  {\n    sprinkle_match <- \n      unlist(sprinkle_groups)[pmatch(names(sprinkles), \n                                     unlist(sprinkle_groups))]\n    \n    unmatched_sprinkle <- \n      names(sprinkles)[which(is.na(sprinkle_match))]\n    \n    names(sprinkles) <- sprinkle_match\n    \n    if (length(unmatched_sprinkle))\n    {\n      coll$push(\n        sprintf(\"The following arguments could not be matched to an existing sprinkle (check spelling and partial matching): %s\",\n                paste(unmatched_sprinkle, collapse = \", \"))\n      )\n      \n      sprinkles <- sprinkles[!is.na(names(sprinkles))]\n    }\n  }\n  \n  if (!checkmate::test_named(sprinkles)){\n    coll$push(\"Arguments to ... must be named\")\n  }\n  \n  not_sprinkles <- \n    sprinkles[!names(sprinkles) %in% unlist(sprinkle_groups)]\n  \n  if (length(not_sprinkles)){\n    coll$push(sprintf(\"The following are not valid sprinkles: %s\",\n                      paste0(names(not_sprinkles), collapse = \", \")))\n  }\n\n  indices <- index_to_sprinkle(x = x, \n                               rows = rows, \n                               cols = cols, \n                               fixed = fixed,\n                               part = part,\n                               recycle = recycle,\n                               coll = coll)\n  \n  recycle <- recycle[1]\n\n  for (i in seq_along(sprinkle_groups))\n  {\n    if (any(sprinkle_groups[[i]] %in% names(sprinkles)))\n    {\n      sprinkle_arg <- c(sprinkles[sprinkle_groups[[i]]], \"recycle\" = recycle)\n      sprinkle_arg <- sprinkle_arg[names(sprinkle_arg) %in% sprinkle_groups[[i]]]\n      sprinkle_arg <- sprinkle_arg[!vapply(sprinkle_arg, is.null, logical(1))]\n     \n      if (!\"fn\" %in% names(sprinkle_arg))\n      {\n        args_list <- \n          if (names(sprinkle_groups)[i] == \"replace\")\n          {\n            list(indices = indices, \n                 coll = coll)\n          }\n          else\n          {\n            list(coll = coll)\n          }\n\n        do.call(what = sprintf(\"sprinkle_%s_index_assert\",\n                               names(sprinkle_groups)[[i]]),\n                args = c(sprinkle_arg,\n                         args_list))\n      }\n    }\n  }\n  \n  if (\"fn\" %in% names(sprinkles))\n  {\n    sprinkle_fn_index_assert(fn = sprinkles$fn, \n                             coll = coll)\n  }\n\n  #* Return any errors found.\n  checkmate::reportAssertions(coll)\n\n# Functional Code ---------------------------------------------------\n\n  part <- part[1]\n  \n  for (i in seq_along(sprinkle_groups))\n  {\n    if (any(sprinkle_groups[[i]] %in% names(sprinkles)))\n    {\n      sprinkle_arg <- sprinkles[sprinkle_groups[[i]]]\n      sprinkle_arg <- sprinkle_arg[!vapply(sprinkle_arg, is.null, logical(1))]\n\n      if (!\"fn\" %in% names(sprinkle_arg))\n      {\n        x <- do.call(what = sprintf(\"sprinkle_%s_index\",\n                                    names(sprinkle_groups)[[i]]),\n                     args = c(sprinkle_arg,\n                              list(x = x,\n                                   indices = indices,\n                                   part = part)))\n      }\n    }\n  }\n\n  if (\"fn\" %in% names(sprinkles))\n  {\n    x <- sprinkle_fn_index(x = x,\n                           indices = indices,\n                           fn = sprinkles$fn,\n                           part = part)\n  }\n  \n  x\n}\n\n\n# sprinkle.dust_list ------------------------------------------------\n#' @rdname sprinkle\n#' @export\n\nsprinkle.dust_list <- function(x, rows = NULL, cols = NULL, ...,\n                               part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"))\n{\n  structure(\n    lapply(X = x,\n           FUN = sprinkle,\n           rows = rows,\n           cols = cols,\n           part = part,\n           ...),\n    class = \"dust_list\"\n  )\n}\n\n# Unexported --------------------------------------------------------\n\nsprinkle_groups <-  \n  list(\n    align = c(\"halign\", \"valign\", \"recycle\"),\n    bg = c(\"bg\", \"recycle\"),\n    bg_pattern = c(\"bg_pattern\", \"bg_pattern_by\"),\n    bookdown = \"bookdown\",\n    border = c(\"border\", \"border_color\", \"border_style\", \n               \"border_thickness\", \"border_units\", \"recycle\"),\n    border_collapse = \"border_collapse\",\n    caption = \"caption\", \n    caption_number = \"caption_number\",\n    discrete = c(\"discrete\", \"discrete_colors\"),\n    fixed_header = c(\"fixed_header\", \"include_fixed_header_css\",\n                     \"fixed_header_class_name\", \n                     \"scroll_body_height\", \"scroll_body_height_units\",\n                     \"scroll_body_background_color\",\n                     \"fixed_header_height\", \"fixed_header_height_units\",\n                     \"fixed_header_text_height\", \"fixed_header_text_height_units\",\n                     \"fixed_header_background_color\"),\n    float = \"float\",\n    fn = c(\"fn\"),\n    font = c(\"bold\", \"italic\", \"font_size\", \"font_size_units\",\n             \"font_color\", \"font_family\", \"recycle\"),\n    gradient = c(\"gradient\", \"gradient_colors\", \"gradient_cut\",\n                 \"gradient_n\", \"gradient_na\"),\n    height = c(\"height\", \"height_units\", \"recycle\"),\n    hhline = \"hhline\",\n    justify = \"justify\",\n    label = \"label\",\n    longtable = \"longtable\",\n    merge = c(\"merge\", \"merge_rowval\", \"merge_colval\"),\n    na_string = c(\"na_string\", \"recycle\"),\n    pad = c(\"pad\", \"recycle\"),\n    replace = \"replace\",\n    rotate_degree = c(\"rotate_degree\"),#, \"recycle\"),\n    round = c(\"round\"),#, \"recycle\"),\n    sanitize = c(\"sanitize\", \"sanitize_args\"),\n    tabcolsep = \"tabcolsep\",\n    width = c(\"width\", \"width_units\", \"recycle\")\n  )\n"
  },
  {
    "path": "R/sprinkle_align.R",
    "content": "#' @name sprinkle_align\n#' @title Sprinkle Alignment of Table Cells\n#' \n#' @description The alignment refers to the positioning of the text within\n#'   a cell.  Alignment may be given relative to the left, center, or right\n#'   of a cell, and the top, middle, or bottom of the cell.\n#'   \n#' @param x An object of class \\code{dust}\n#' @param rows Either a numeric vector of rows in the tabular object to be \n#'   modified or an object of class \\code{call}.  When a \\code{call}, \n#'   generated by \\code{quote(expression)}, the expression resolves to \n#'   a logical vector the same length as the number of rows in the table.\n#'   Sprinkles are applied to where the expression resolves to \\code{TRUE}.\n#' @param cols Either a numeric vector of columns in the tabular object to\n#'   be modified, or a character vector of column names. A mixture of \n#'   character and numeric indices is permissible.\n#' @param halign \\code{character} One of \\code{\"left\"}, \\code{\"center\"}, \n#'   or \\code{\"right\"}. Defaults to \\code{NULL}, for no change to the \n#'   current value.\n#' @param valign \\code{character} One of \\code{\"top\"}, \\code{\"middle\"}, \n#'   or \\code{\"bottom\"}. Defaults to \\code{NULL}, for no change to the \n#'   current value.\n#' @param part A character string denoting which part of the table to modify.\n#' @param fixed \\code{logical(1)} indicating if the values in \\code{rows} \n#'   and \\code{cols} should be read as fixed coordinate pairs.  By default, \n#'   sprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \n#'   meaning that the arguments do not have to share the same length.  \n#'   When \\code{fixed = TRUE}, they must share the same length.\n#' @param recycle A \\code{character} one that determines how sprinkles are \n#'   managed when the sprinkle input doesn't match the length of the region\n#'   to be sprinkled.  By default, recycling is turned off.  Recycling \n#'   may be performed across rows first (left to right, top to bottom), \n#'   or down columns first (top to bottom, left to right).\n#' @param ... Additional arguments to pass to other methods. Currently ignored.\n#' \n#' @section Functional Requirements:\n#' \\enumerate{\n#'  \\item Correctly reassigns the appropriate elements of \\code{halign} \n#'    and \\code{valign} columns in the table part.\n#'  \\item Casts an error if \\code{x} is not a \\code{dust} object.\n#'  \\item Casts an error if \\code{halign} is not a \\code{character}\n#'  \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n#'    \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n#'  \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\n#'  \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\n#'    \\code{\"rows\"}, or \\code{\"cols\"}\n#'  \\item Casts an error if \\code{valign} is not a \\code{character}\n#'  \\item Cast an error if \\code{recycle = \"none\"} and \\code{halign} does\n#'    not have length 1.\n#'  \\item Cast an error if \\code{recycle = \"none\"} and \\code{valign} does\n#'    not have length 1.\n#'  \\item Cast an error if \\code{halign} is not one of \\code{c(\"left\", \"center\", \"right\")}\n#'  \\item Cast an error if \\code{valign} is not one of \\code{c(\"top\", \"middle\", \"bottom\")}\n#' }\n#' \n#' The functional behavior of the \\code{fixed} and \\code{recycle} arguments \n#' is not tested for this function. It is tested and validated in the\n#' tests for \\code{\\link{index_to_sprinkle}}.\n#' \n#' @seealso \\code{\\link{sprinkle}}, \n#'   \\code{\\link{index_to_sprinkle}}\n#'\n#' @export\n\nsprinkle_align <- function(x, rows = NULL, cols = NULL, \n                           halign = NULL, valign = NULL,\n                           part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                           fixed = FALSE, \n                           recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                           ...)\n{\n  UseMethod(\"sprinkle_align\")\n}\n\n#' @rdname sprinkle_align\n#' @export\n\nsprinkle_align.default <- function(x, rows = NULL, cols = NULL, \n                                   halign = NULL, valign = NULL,\n                                   part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                                   fixed = FALSE, \n                                   recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                                   ...)\n{\n  coll <- checkmate::makeAssertCollection()\n\n  indices <- index_to_sprinkle(x = x, \n                               rows = rows, \n                               cols = cols, \n                               fixed = fixed,\n                               part = part,\n                               recycle = recycle,\n                               coll = coll)\n  \n  recycle <- recycle[1]\n  \n  sprinkle_align_index_assert(halign = halign,\n                              valign = valign,\n                              recycle = recycle,\n                              coll = coll)\n\n  checkmate::reportAssertions(coll)\n  \n  if (is.null(halign) & is.null(valign))\n  {\n    return(x)\n  }\n  \n  # At this point, part should have passed the assertions in \n  # index_to_sprinkle. The first element is expected to be valid.\n  \n  part <- part[1]\n\n  sprinkle_align_index(x = x, \n                       indices = indices, \n                       halign = halign, \n                       valign = valign, \n                       part = part)\n}\n\n#' @rdname sprinkle_align\n#' @export\n\nsprinkle_align.dust_list <- function(x, rows = NULL, cols = NULL,\n                                     halign = NULL, valign = NULL, \n                                     part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                                     fixed = FALSE, \n                                     recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                                     ...)\n{\n  structure(\n    lapply(X = x,\n           FUN = sprinkle_align.default,\n           rows = rows,\n           cols = cols,\n           halign = halign,\n           valign = valign,\n           part = part,\n           fixed = fixed,\n           recycle = recycle,\n           ...),\n    class = \"dust_list\"\n  )\n}\n\n# Unexported Utility ------------------------------------------------\n\n# These functions are to be used inside of the general `sprinkle` call\n# When used inside `sprinkle`, the indices are already determined, \n# the only the `halign` and `valign` arguments needs to be validated. \n# The assert function is kept separate so it may be called earlier\n# without attempting to perform the assignment.\n\nsprinkle_align_index_assert <- function(halign = NULL, valign = NULL, recycle = \"none\", coll)\n{\n  if (!is.null(halign))\n  {\n    checkmate::assert_subset(x = halign,\n                             choices = c(\"left\", \"center\", \"right\"),\n                             add = coll,\n                             .var.name = \"halign\")\n    \n    if (recycle == \"none\" && length(halign) != 1)\n      coll$push(paste0(\"When `recycle = none`, `halign` must have length 1\"))\n  }\n  \n  if (!is.null(valign))\n  {\n    checkmate::assert_subset(x = valign,\n                             choices = c(\"top\", \"middle\", \"bottom\"),\n                             add = coll,\n                             .var.name = \"valign\")\n    \n    if (recycle == \"none\" && length(valign) != 1)\n      coll$push(paste0(\"When `recycle = none`, `valign` must have length 1\"))\n  }\n}\n\nsprinkle_align_index <- function(x, indices, halign = \"left\", valign = \"top\", part)\n{\n  if (!is.null(halign))\n  {\n    x[[part]][[\"halign\"]][indices] <- halign\n  }\n  \n  if (!is.null(valign))\n  {\n    x[[part]][[\"valign\"]][indices] <- valign\n  }\n  \n  x\n}"
  },
  {
    "path": "R/sprinkle_bg.R",
    "content": "#' @name sprinkle_bg\n#' @title Sprinkle the Background Color of a Cell\n#' \n#' @description Background colors may be used to highlight the contents \n#'   of cells, rows, or columns.  Most commonly, backgrounds are used to\n#'   provide row discrimination; the \\code{sprinkle_bg_pattern} function\n#'   is better suited to that purpose.  \n#'   \n#' @param x An object of class \\code{dust}\n#' @param rows Either a numeric vector of rows in the tabular object to be \n#'   modified or an object of class \\code{call}.  When a \\code{call}, \n#'   generated by \\code{quote(expression)}, the expression resolves to \n#'   a logical vector the same length as the number of rows in the table.\n#'   Sprinkles are applied to where the expression resolves to \\code{TRUE}.\n#' @param cols Either a numeric vector of columns in the tabular object to\n#'   be modified, or a character vector of column names. A mixture of \n#'   character and numeric indices is permissible.\n#' @param bg \\code{character(1)} A character string giving a color for the \n#'   background of the chosen cells.  \n#' @param part A character string denoting which part of the table to modify.\n#' @param fixed \\code{logical(1)} indicating if the values in \\code{rows} \n#'   and \\code{cols} should be read as fixed coordinate pairs.  By default, \n#'   sprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \n#'   meaning that the arguments do not have to share the same length.  \n#'   When \\code{fixed = TRUE}, they must share the same length.\n#' @param recycle A \\code{character} one that determines how sprinkles are \n#'   managed when the sprinkle input doesn't match the length of the region\n#'   to be sprinkled.  By default, recycling is turned off.  Recycling \n#'   may be performed across rows first (left to right, top to bottom), \n#'   or down columns first (top to bottom, left to right).\n#' @param ... Additional arguments to pass to other methods. Currently ignored.\n#'   \n#' @details Colors may be a dvips color name, or in the rgb(R, G, B), \n#' rgba(R, G, B, A), #RRGGBB, or #RRGGBBAA formats. \n#'   \n#' This sprinkle is ignored in console and markdown outputs.  HTML output\n#' will accept any of the color formats and recognize transparency.  LaTeX\n#' output will accept any of the color formats but ignore transparency.\n#' \n#' As long as \\code{bg} is required to be a \\code{character(1)}, the \n#' \\code{recycle} argument is kind of useless. It is included to maintain\n#' consistency with the \\code{index_to_sprinkle} function. Future development\n#' may permit a character vector of colors.\n#' \n#' @section Functional Requirements:\n#' \\enumerate{\n#'  \\item Correctly reassigns the appropriate elements \\code{bg} column\n#'    in the table part.\n#'  \\item Casts an error if \\code{x} is not a \\code{dust} object.\n#'  \\item Casts an error if \\code{bg} is not a \\code{character(1)}\n#'  \\item Casts an error if \\code{bg} is not a valid color format.\n#'  \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n#'    \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n#'  \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\n#'  \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\n#'    \\code{\"rows\"}, or \\code{\"cols\"}\n#'  \\item Casts an error if \\code{recycle = \"none\"} and \\code{bg} does not\n#'    have length 1.\n#' }\n#' \n#' The functional behavior of the \\code{fixed} and \\code{recycle} arguments \n#' is not tested for this function. It is tested and validated in the\n#' tests for \\code{\\link{index_to_sprinkle}}.\n#' \n#' @seealso \\code{\\link{sprinkle}}, \\code{\\link{sprinkle_bg_pattern}}, \n#'   \\code{\\link{index_to_sprinkle}}\n#'   \n#' @author Benjamin Nutter\n#' \n#' @export\n\nsprinkle_bg <- function(x, rows = NULL, cols = NULL, bg = \"\", \n                        part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                        fixed = FALSE, \n                        recycle = c(\"none\", \"rows\", \"cols\", \"columns\"), \n                        ...)\n{\n  UseMethod(\"sprinkle_bg\")\n}\n\n#' @rdname sprinkle_bg\n#' @export\n\nsprinkle_bg.default <- function(x, rows = NULL, cols = NULL, bg = \"\", \n                                part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                                fixed = FALSE, \n                                recycle = c(\"none\", \"rows\", \"cols\", \"columns\"), \n                                ...)\n{\n  coll <- checkmate::makeAssertCollection()\n  \n  checkmate::assert_class(x = x,\n                          classes = \"dust\",\n                          add = coll)\n  \n  indices <- index_to_sprinkle(x = x, \n                               rows = rows, \n                               cols = cols, \n                               fixed = fixed,\n                               part = part,\n                               recycle = recycle,\n                               coll = coll)\n  \n  recycle <- recycle[1]\n  \n  sprinkle_bg_index_assert(bg = bg,\n                           recycle = recycle,\n                           coll = coll)\n  \n  checkmate::reportAssertions(coll)\n  \n  # At this point, part should have passed the assertions in \n  # index_to_sprinkle. The first element is expected to be valid.\n  \n  part <- part[1]\n  \n  sprinkle_bg_index(x = x, \n                    indices = indices, \n                    bg = bg, \n                    part = part)\n  \n}\n\n#' @rdname sprinkle_bg\n#' @export\n\nsprinkle_bg.dust_list <- function(x, rows = NULL, cols = NULL, bg = \"\", \n                                  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                                  fixed = FALSE, \n                                  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"), \n                                  ...)\n{\n  structure(\n    lapply(X = x,\n           FUN = sprinkle_bg.default,\n           rows = rows,\n           cols = cols,\n           bg = bg,\n           part = part,\n           fixed = fixed,\n           recycle = recycle,\n           ...),\n    class = \"dust_list\"\n  )\n}\n\n#' @rdname sprinkle_bg\n#' @export\n\nsprinkle_background <- sprinkle_bg\n\n\n\n# Unexported Utility ------------------------------------------------\n\n# These functions are to be used inside of the general `sprinkle` call\n# When used inside `sprinkle`, the indices are already determined, \n# the only the `bg` argument needs to be validated. \n# The assert function is kept separate so it may be called earlier\n# without attempting to perform the assignment.\n\nsprinkle_bg_index_assert <- function(bg = \"\", recycle = \"none\", coll)\n{\n  checkmate::assert_character(x = bg,\n                              add = coll,\n                              .var.name = \"bg\")\n  \n  if (recycle == \"none\" && length(bg) != 1)\n  {\n    coll$push(\"When `recycle` = 'none', `bg` must have length 1.\")\n  }\n  \n  if (!any(is_valid_color(bg)))\n  {\n    invalid_color <- bg[!is_valid_color(bg)]\n    coll$push(sprintf(\"The following colors are not valid: %s\",\n                      paste0(invalid_color, collapse = \", \")))\n  }\n}\n\nsprinkle_bg_index <- function(x, indices, bg, part)\n{\n  x[[part]][[\"bg\"]][indices] <- bg\n  \n  x\n}"
  },
  {
    "path": "R/sprinkle_bg_pattern.R",
    "content": "#' @name sprinkle_bg_pattern\n#' @title Row and Column Background Striping\n#' \n#' @description Provides background color striping based on row or column.\n#'   Striping may be done with any number of colors. The most common use of \n#'   striping is to provide row discrimination in tables.\n#'   \n#' @param x An object of class \\code{dust}\n#' @param rows Either a numeric vector of rows in the tabular object to be \n#'   modified or an object of class \\code{call}.  When a \\code{call}, \n#'   generated by \\code{quote(expression)}, the expression resolves to \n#'   a logical vector the same length as the number of rows in the table.\n#'   Sprinkles are applied to where the expression resolves to \\code{TRUE}.\n#' @param cols Either a numeric vector of columns in the tabular object to\n#'   be modified, or a character vector of column names. A mixture of \n#'   character and numeric indices is permissible.\n#' @param bg_pattern A character vector giving the colors to be iterated in \n#'   the pattern.  \n#' @param bg_pattern_by A subset of \\code{c(\"rows\", \"cols\")}, with partial\n#'   matching accepted.  Only the first value is used, and determines the \n#'   direction of the pattern.\n#' @param part A character string denoting which part of the table to modify.\n#' @param ... Additional arguments to pass to other methods. Currently ignored.\n#' \n#' @section Functional Requirements:\n#' \\enumerate{\n#'   \\item Correctly reassigns the appropriate elements \\code{bg} column\n#'    in the table part.\n#'  \\item Casts an error if \\code{x} is not a \\code{dust} object.\n#'  \\item Casts an error if \\code{bg_pattern} is not a character vector.\n#'  \\item Casts an error if any element in \\code{bg_pattern} is not a valid\n#'    color name.\n#'  \\item Casts an error if \\code{bg_pattern_by} is not a subset of \n#'    \\code{c(\"rows\", \"columns\")} (with partial matching).\n#'  \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n#'    \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n#' }\n#' \n#' This is a rare sprinkle that doesn't use the \\code{fixed} and \\code{recycle}\n#' arguments.  They are assumed to be \\code{FALSE} and \\code{\"none\"}, \n#' respectively, in order to pass through \\code{index_to_sprinkle}. \n#' \n#' @seealso \\code{\\link{sprinkle_bg}}, \\code{\\link{sprinkle}}, \n#'   \\code{\\link{index_to_sprinkle}}\n#' \n#' @export\n\nsprinkle_bg_pattern <- function(x, rows = NULL, cols = NULL, \n                                bg_pattern = c(\"transparent\", \"#DCDCDC\"),\n                                bg_pattern_by = c(\"rows\", \"cols\"),\n                                ..., part = c(\"body\", \"head\", \"foot\", \"interoot\", \"table\"))\n{\n  UseMethod(\"sprinkle_bg_pattern\")\n}\n\n#' @rdname sprinkle_bg_pattern\n#' @export\n\nsprinkle_bg_pattern.default <- function(x, rows = NULL, cols = NULL, \n                                     bg_pattern = c(\"transparent\", \"#DCDCDC\"),\n                                     bg_pattern_by = c(\"rows\", \"cols\"),\n                                     ...,\n                                     part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"))\n{\n  coll <- checkmate::makeAssertCollection()\n  \n  checkmate::assert_class(x = x,\n                          classes = \"dust\",\n                          add = coll)\n  \n  bg_pattern_by <- \n    sprinkle_bg_pattern_index_assert(bg_pattern = bg_pattern,\n                                     bg_pattern_by = bg_pattern_by, \n                                     coll = coll)\n  \n  indices <- index_to_sprinkle(x = x, \n                               rows = rows, \n                               cols = cols, \n                               fixed = FALSE,\n                               part = part,\n                               recycle = \"none\",\n                               coll = coll)\n  \n  checkmate::reportAssertions(coll)\n  \n  part <- part[1]\n  \n  sprinkle_bg_pattern_index(x = x, \n                            indices = indices, \n                            bg_pattern = bg_pattern,\n                            bg_pattern_by = bg_pattern_by, \n                            part = part)\n}\n\n#' @rdname sprinkle_bg_pattern\n#' @export\n\nsprinkle_bg_pattern.dust_list <- function(x, rows = NULL, cols = NULL, \n                                          bg_pattern = c(\"transparent\", \"#DCDCDC\"),\n                                          bg_pattern_by = c(\"rows\", \"cols\"),\n                                          ...,\n                                          part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"))\n{\n  structure(\n    lapply(X = x,\n           FUN = sprinkle_na_string.default,\n           rows = rows,\n           cols = cols,\n           bg_pattern = bg_pattern,\n           bg_pattern_by = bg_pattern_by,\n           part = part,\n           fixed = FALSE,\n           recycle = \"none\",\n           ...),\n    class = \"dust_list\"\n  )\n}\n\n# Unexported Utility ------------------------------------------------\n\n# These functions are to be used inside of the general `sprinkle` call\n# When used inside `sprinkle`, the indices are already determined, \n# the only the `na_string` argument needs to be validated. \n# The assert function is kept separate so it may be called earlier\n# without attempting to perform the assignment.\n\nsprinkle_bg_pattern_index_assert <- function(bg_pattern = c(\"transparent\", \"#DCDCDC\"),\n                                             bg_pattern_by = c(\"rows\", \"cols\"),\n                                             coll)\n{\n  checkmate::assert_character(x = bg_pattern,\n                              add = coll,\n                              .var.name = \"bg_pattern\")\n  \n  if (!all(is_valid_color(bg_pattern)))\n  {\n    coll$push(sprintf(\"The following elements in `bg_pattern` are not valid colors: %s\",\n                      paste0(bg_pattern[!is_valid_color(bg_pattern)],\n                             collapse = \", \")))\n  }\n  \n  bg_pattern_by <- \n    checkmate::matchArg(x = bg_pattern_by,\n                        choices = c(\"rows\", \"cols\"),\n                        add = coll,\n                        .var.name = \"bg_pattern_by\")\n  \n  bg_pattern_by\n}\n\nsprinkle_bg_pattern_index <- function(x, indices, \n                                      bg_pattern = c(\"transparent\", \"#DCDCDC\"),\n                                      bg_pattern_by = c(\"rows\"), \n                                      part)\n{\n  if (bg_pattern_by == \"rows\")\n  {\n    pattern <- data.frame(row = sort(unique(x[[part]][[\"row\"]][indices])))\n    pattern[[\"bg\"]] <- rep(bg_pattern, \n                           length.out = nrow(pattern))\n    \n    pattern <- merge(pattern, \n                     x[[part]][indices, c(\"row\", \"col\")], \n                     by = c(\"row\"), \n                     sort = FALSE, \n                     all.x = TRUE)\n\n    pattern <- pattern[order(pattern$col, pattern$row), ]\n    \n    x[[part]][[\"bg\"]][indices] <- pattern[[\"bg\"]]\n  }\n  else \n  {\n    pattern <- data.frame(col = sort(unique(x[[part]][[\"col\"]][indices])))\n    pattern[[\"bg\"]] <- rep(bg_pattern, \n                           length.out = nrow(pattern))\n    \n    pattern <- \n      merge(pattern, \n            x[[part]][indices, c(\"row\", \"col\")], \n            by = c(\"col\"), \n            all.x = TRUE)\n\n    pattern <- pattern[order(pattern$col, pattern$row), ]\n    \n    x[[part]][[\"bg\"]][indices] <- pattern[[\"bg\"]]\n  }\n  \n  x\n}"
  },
  {
    "path": "R/sprinkle_bookdown.R",
    "content": "#' @name sprinkle_bookdown\r\n#' @title Change the Bookdown Property in a Dust Table\r\n#' \r\n#' @description Tables built for the \\code{bookdown} package can be referenced\r\n#'   in a manner that is consistent between HTML and LaTeX documents.\r\n#'   \r\n#' @param x An object of class \\code{dust}\r\n#' @param bookdown \\code{logical(1)} indicating if the table is being produced\r\n#'   in a \\code{bookdown} document.\r\n#' @param ... Additional arguments to pass to other methods. Currently ignored.\r\n#'\r\n#' @details \\code{bookdown} is a package that facilitates the writing of books.\r\n#'   One of the advantages of \\code{bookdown} is the ability to reference \r\n#'   tables in a manner similar to LaTeX. The key difference in how \r\n#'   \\code{pixiedust} handles output is the reference specification. See \r\n#'   \\url{https://bookdown.org/yihui/bookdown/tables.html} for details on how\r\n#'   \\code{bookdown} uses labels and references.\r\n#'   \r\n#' @author Benjamin Nutter\r\n#' \r\n#' @seealso \\code{\\link{dust}}, \\code{\\link{sprinkle}}\r\n#' \r\n#' @source \r\n#' \\url{https://bookdown.org/yihui/bookdown/tables.html}\r\n#' \r\n#' @section Functional Requirements:\r\n#' \\enumerate{\r\n#'  \\item Change the \\code{bookdown} attribute of the \\code{dust} object.\r\n#'  \\item Cast an error if \\code{x} is not a \\code{dust} object.\r\n#'  \\item Cast an error if \\code{bookdown} is not a logical object.\r\n#'  \\item Cast an error if \\code{bookdown} has length greater than 1.\r\n#' }\r\n#' \r\n#' @export\r\n\r\nsprinkle_bookdown <- function(x, \r\n                              bookdown = getOption(\"pixie_bookdown\", FALSE), \r\n                              ...)\r\n{\r\n  UseMethod(\"sprinkle_bookdown\")\r\n}\r\n\r\n#' @rdname sprinkle_bookdown\r\n#' @export\r\n\r\nsprinkle_bookdown.default <- function(x, \r\n                                      bookdown = getOption(\"pixie_bookdown\", FALSE),\r\n                                      ...)\r\n{\r\n  coll <- checkmate::makeAssertCollection()\r\n  \r\n  checkmate::assert_class(x = x,\r\n                          classes = \"dust\",\r\n                          add = coll)\r\n  \r\n  sprinkle_bookdown_index_assert(bookdown = bookdown,\r\n                                 coll = coll)\r\n  \r\n  checkmate::reportAssertions(coll)\r\n  \r\n  sprinkle_bookdown_index(x = x,\r\n                          bookdown = bookdown)\r\n}\r\n\r\n#' @rdname sprinkle_bookdown\r\n#' @export\r\n\r\nsprinkle_bookdown.dust_list <- function(x, \r\n                                        bookdown = getOption(\"pixie_bookdown\", FALSE),\r\n                                        ...)\r\n{\r\n  structure(\r\n    lapply(x,\r\n           sprinkle_bookdown.default,\r\n           bookdown),\r\n    class = \"dust_list\"\r\n  )\r\n}\r\n\r\n# Unexported utilities ----------------------------------------------\r\n# These functions carry the the `_index` suffix for consistency with \r\n# the cell-valued sprinkles, but they don't actually require an \r\n# index, since they change table-valued sprinkles\r\n\r\nsprinkle_bookdown_index_assert <- function(bookdown = getOption(\"pixie_bookdown\", FALSE), \r\n                                           coll)\r\n{\r\n  checkmate::assert_logical(x = bookdown,\r\n                            len = 1,\r\n                            add = coll,\r\n                            .var.name = \"bookdown\")\r\n}\r\n\r\n# indices argument is only present to avoid errors when the argument is passed \r\n# from sprinkle\r\nsprinkle_bookdown_index <- function(x, bookdown, indices = NULL)\r\n{\r\n  x[[\"bookdown\"]] <- bookdown\r\n  \r\n  x\r\n}"
  },
  {
    "path": "R/sprinkle_border.R",
    "content": "#' @name sprinkle_border\n#' @title Sprinkle Changes to Cell Borders\n#' \n#' @description Cell borders may be used to give visual structure to a table.\n#'   Borders may generate distinction between sets of results, groups, \n#'   or types of output.\n#'   \n#' @param x An object of class \\code{dust}\n#' @param rows Either a numeric vector of rows in the tabular object to be \n#'   modified or an object of class \\code{call}.  When a \\code{call}, \n#'   generated by \\code{quote(expression)}, the expression resolves to \n#'   a logical vector the same length as the number of rows in the table.\n#'   Sprinkles are applied to where the expression resolves to \\code{TRUE}.\n#' @param cols Either a numeric vector of columns in the tabular object to\n#'   be modified, or a character vector of column names. A mixture of \n#'   character and numeric indices is permissible.\n#' @param border One or more of \\code{\"all\"}, \\code{\"bottom\"}, \\code{\"left\"},\n#'   \\code{\"top\"}, or \\code{\"right\"}. Partial matching is supported. Designates\n#'   the side of the chosen cells for which borders should be modified.\n#' @param border_color \\code{character(1)} A character string giving a color for the \n#'   background of the chosen cells. \\code{NULL} makes no change to the current\n#'   value.\n#' @param border_style \\code{character(1)} setting the border style for the \n#'   cell.  One of \\code{\"solid\"}, \\code{\"dashed\"}, \\code{\"dotted\"}, \n#'   \\code{\"double\"}, \\code{\"groove\"}, \\code{\"ridge\"}, \\code{\"inset\"},\n#'   \\code{\"outset\"}, \\code{\"hidden\"}, or \\code{\"none\"}. \\code{NULL} makes no \n#'   change to the current value.\n#' @param border_thickness \\code{numeric(1)}. Sets the thickness of the border.\n#'   \\code{NULL} makes no change to the current value.\n#' @param border_units \\code{character(1)}. Sets the unit of measure for the\n#'   border thickness.  May be either \\code{\"pt\"}, \\code{\"px\"}. \\code{NULL} \n#'   makes no change to the current value.\n#' @param part A character string denoting which part of the table to modify.\n#' @param fixed \\code{logical(1)} indicating if the values in \\code{rows} \n#'   and \\code{cols} should be read as fixed coordinate pairs.  By default, \n#'   sprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \n#'   meaning that the arguments do not have to share the same length.  \n#'   When \\code{fixed = TRUE}, they must share the same length.\n#' @param recycle A \\code{character} one that determines how sprinkles are \n#'   managed when the sprinkle input doesn't match the length of the region\n#'   to be sprinkled.  By default, recycling is turned off.  Recycling \n#'   may be performed across rows first (left to right, top to bottom), \n#'   or down columns first (top to bottom, left to right).\n#' @param ... Additional arguments to pass to other methods. Currently ignored.\n#'   \n#' @details This sprinkle has no effect on console and markdown output.\n#' \n#' HTML output accepts all of the possible values of \\code{border_style}.\n#' \n#' For LaTeX output, when \\code{hhline = FALSE}, \\code{\"solid\"}, \\code{\"dashed\"},\n#' \\code{\"dotted\"}, \\code{\"hidden\"}, and \\code{\"none\"} are accepted.  \n#' \\code{\"dotted\"} will silently be treated as \\code{\"dashed\"}, and \n#' \\code{\"hidden\"} is the equivalent of \\code{\"none\"}.\n#' \n#' For LaTeX output when \\code{hhline = TRUE}, \\code{\"solid\"}, \\code{\"double\"},\n#' \\code{\"hidden\"}, and \\code{\"none\"} are accepted.  \\code{\"hidden\"} is the\n#' equivalent of \\code{\"none\"}.\n#' \n#' When a value of \\code{border_style} is not recognized by an output format, \n#' it is silently ignored.\n#' \n#' @section Functional Requirements:\n#' \\enumerate{\n#'  \\item Correctly reassigns the \\code{left_border}, \\code{right_border},\n#'    \\code{top_border} and \\code{bottom_border} columns in the table part.\n#'  \\item Casts an error if \\code{x} is not a \\code{dust} object.\n#'  \\item Casts an error if any element of \\code{border} is not one of \n#'    \\code{\"all\"}, \\code{\"bottom\"}, \\code{\"left\"}, \\code{\"top\"}, or \n#'    \\code{\"right\"}.\n#'  \\item Casts an error if \\code{border_color} is not a \\code{character(1)}\n#'  \\item Casts an error if \\code{border_color} is not a valid color format.\n#'  \\item Casts an error if \\code{border_style} is not one of \\code{\"solid\"}, \n#'    \\code{\"dashed\"}, \\code{\"dotted\"}, \\code{\"double\"}, \\code{\"groove\"},\n#'    \\code{\"ridge\"}, \\code{\"inset\"}, \\code{\"outset\"}, \\code{\"hidden\"}, \n#'    \\code{\"none\"}\n#'  \\item Casts an error if \\code{border_thickness} is not a \\code{numeric(1)}.\n#'  \\item Casts an error if \\code{border_units} is not one of \\code{\"pt\"} or \n#'    \\code{\"px\"}.\n#'  \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n#'    \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n#'  \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\n#'  \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\n#'    \\code{\"rows\"}, or \\code{\"cols\"}\n#'  \\item Cast an error if \\code{recycle = \"none\"} and \\code{border_color}\n#'    does not have length 1.\n#'  \\item Cast an error if \\code{recycle = \"none\"} and \\code{border_style}\n#'    does not have length 1.\n#'  \\item Cast an error if \\code{recycle = \"none\"} and \\code{border_thickness}\n#'    does not have length 1.\n#'  \\item Quietly restrict \\code{border_units} to just the first element if\n#'    is has length > 1 and \\code{recycle = \"none\"}.\n#' }\n#' \n#' @author Benjamin Nutter\n#' \n#' @seealso \\code{\\link{sprinkle}}, \\code{\\link{index_to_sprinkle}}\n#' \n#' @export\n\nsprinkle_border <- function(x, rows, cols, \n                            border = c(\"all\", \"bottom\", \"left\", \"top\", \"right\"), \n                            border_color = \"black\",\n                            border_style = \"solid\", border_thickness = 1,\n                            border_units = c(\"pt\", \"px\"), \n                            part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                            fixed = FALSE, \n                            recycle = c(\"none\", \"rows\", \"cols\", \"columns\"), \n                            ...)\n{\n  UseMethod(\"sprinkle_border\")\n}\n\n#' @rdname sprinkle_border\n#' @export\n\nsprinkle_border.default <- function(x, rows = NULL, cols = NULL, \n                                    border = c(\"all\", \"bottom\", \"left\", \"top\", \"right\"), \n                                    border_color = \"black\",\n                                    border_style = \"solid\", border_thickness = 1,\n                                    border_units = c(\"pt\", \"px\"),  \n                                    part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                                    fixed = FALSE, \n                                    recycle = c(\"none\", \"rows\", \"cols\", \"columns\"), \n                                    ...)\n{\n  coll <- checkmate::makeAssertCollection()\n  \n  checkmate::assert_class(x = x,\n                          classes = \"dust\")\n\n  indices <- index_to_sprinkle(x = x, \n                               rows = rows, \n                               cols = cols, \n                               fixed = fixed,\n                               part = part,\n                               recycle = recycle,\n                               coll = coll)\n    \n  recycle <- recycle[1]\n  \n  sprinkle_border_index_assert(border = border,\n                               border_color = border_color,\n                               border_style = border_style,\n                               border_thickness = border_thickness,\n                               border_units = border_units,\n                               recycle = recycle,\n                               coll = coll)\n  \n\n  \n  checkmate::reportAssertions(coll)\n  \n  # At this point, part should have passed the assertions in \n  # index_to_sprinkle. The first element is expected to be valid.\n  \n  sprinkle_border_index(x = x,\n                        indices = indices,\n                        border = border,\n                        border_color = border_color,\n                        border_style = border_style,\n                        border_thickness = border_thickness,\n                        border_units = border_units,\n                        part = part)\n}\n\n#' @rdname sprinkle_border\n#' @export\n\nsprinkle_border.dust_list <- function(x, rows = NULL, cols = NULL, \n                                      border = c(\"all\", \"bottom\", \"left\", \"top\", \"right\"), \n                                      border_color = \"black\",\n                                      border_style = \"solid\", border_thickness = 1,\n                                      border_units = c(\"pt\", \"px\"),  \n                                      part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                                      fixed = FALSE, \n                                      recycle = c(\"none\", \"rows\", \"cols\", \"columns\"), \n                                      ...)\n{\n  structure(\n    lapply(X = x,\n           FUN = sprinkle_border.default,\n           rows = rows,\n           cols = cols,\n           border = border,\n           border_color = border_color,\n           border_style = border_style,\n           border_units = border_units,\n           part = part,\n           fixed = fixed,\n           recycle = recycle,\n           ...),\n    class = \"dust_list\"\n  )\n}\n\n# Unexported Utility ------------------------------------------------\n\n# These functions are to be used inside of the general `sprinkle` call\n# When used inside `sprinkle`, the indices are already determined, \n# the only the `bg` argument needs to be validated. \n# The assert function is kept separate so it may be called earlier\n# without attempting to perform the assignment.\n\nsprinkle_border_index_assert <- function(border = c(\"all\", \"bottom\", \"left\", \"top\", \"right\"), \n                                         border_color = \"black\",\n                                         border_style = \"solid\", \n                                         border_thickness = 1,\n                                         border_units = c(\"pt\", \"px\"),\n                                         recycle = \"none\",\n                                         coll)\n{\n  checkmate::assert_subset(x = border,\n                           choices = c(\"all\", \"bottom\", \"left\", \"top\", \"right\"),\n                           add = coll)\n  \n  checkmate::assert_character(x = border_color,\n                              add = coll)\n  \n  if (recycle == \"none\" && length(border_color) != 1)\n    coll$push(\"When `recycle` = 'none', border_color must have length 1.\")\n  \n  if (!any(is_valid_color(border_color)))\n  {\n    invalid_color <- border_color[!is_valid_color(border_color)]\n    coll$push(sprintf(\"The following colors are not valid: %s\",\n                      paste0(invalid_color, collapse = \", \")))\n  }\n  \n  checkmate::assert_subset(x = border_style,\n                           choices = c(\"solid\", \"dashed\", \"dotted\", \n                                       \"double\", \"groove\", \"ridge\", \"inset\",\n                                       \"outset\", \"hidden\", \"none\"),\n                           add = coll)\n  \n  if (recycle == \"none\" && length(border_style) != 1)\n    coll$push(\"When `recycle` = 'none', border_style must have length 1.\")\n  \n  checkmate::assert_numeric(x = border_thickness,\n                            add = coll)\n  if (recycle == \"none\" && length(border_thickness) != 1)\n    coll$push(\"When `recycle` = 'none', border_thickness must have length 1.\")\n  \n  checkmate::assert_subset(x = border_units,\n                           choices = c(\"pt\", \"px\"),\n                           add = coll)\n  \n  if (recycle == \"none\" && length(border_units) != 1)\n    border_units <- border_units[1]\n}\n\n\n\nsprinkle_border_index <- function(x, indices, border = NULL, \n                                  border_color = NULL, border_style = NULL,\n                                  border_thickness = NULL, border_units = NULL,\n                                  part)\n{\n  if (is.null(border)) border <- \"all\"\n  if (is.null(border_color)) border_color <- \"black\"\n  if (is.null(border_style)) border_style <- \"solid\"\n  if (is.null(border_thickness)) border_thickness <- 1\n  if (is.null(border_units)) border_units <- \"pt\"\n  \n  part <- part[1]\n  border_units <- border_units[1]\n  \n  if (any(border == \"all\")) border <- c(\"bottom\", \"left\", \"top\", \"right\")\n  \n  border_define <- sprintf(\"%s%s %s %s\",\n                           border_thickness,\n                           border_units,\n                           border_style,\n                           border_color)\n  for (side in border){\n    x[[part]][[sprintf(\"%s_border\", side)]][indices] <- border_define\n  }\n  \n  x\n}"
  },
  {
    "path": "R/sprinkle_border_collapse.R",
    "content": "#' @name sprinkle_border_collapse\r\n#' @title Change the Border Collapse Property in a Dust Table\r\n#' \r\n#' @description The \\code{border_collapse} property controls the appearance of \r\n#'   cell borders in HTML tables.  Be default, \\code{pixiedust} collapses \r\n#'   the borders so that the adjoining border of two cells appear as a \r\n#'   single border.\r\n#'   \r\n#' @param x An object of class \\code{dust}\r\n#' @param border_collapse \\code{character(1)}. Defaults to \\code{\"collapse\"}, \r\n#'   and may accept any of \\code{\"collapse\"}, \\code{\"separate\"}, \r\n#'   \\code{\"initial\"}, or \\code{\"inherit\"}.\r\n#' @param ... Additional arguments to pass to other methods. Currently ignored.\r\n#' \r\n#' @details See \\url{https://www.w3schools.com/cssref/pr_border-collapse.asp} \r\n#' for details on how each option affects the appearance of a table.\r\n#' \r\n#' This property has no effect on non-HTML output.\r\n#'   \r\n#' @author Benjamin Nutter\r\n#' \r\n#' @source \\url{https://www.w3schools.com/cssref/pr_border-collapse.asp}\r\n#' \r\n#' @seealso \\code{\\link{dust}}, \\code{\\link{sprinkle}}\r\n#' \r\n#' @section Functional Requirements:\r\n#' \\enumerate{\r\n#'  \\item Change the \\code{border_collapse} attribute of the \\code{dust} object.\r\n#'  \\item Cast an error if \\code{x} is not a \\code{dust} object.\r\n#'  \\item Cast an error if \\code{border_collapse} is not one of \r\n#'    \\code{\"collapse\"}, \\code{\"separate\"}, \\code{\"initial\"}, \\code{\"inherit\"}.\r\n#' }\r\n#' \r\n#' @export\r\n\r\nsprinkle_border_collapse <- function(x, \r\n                            border_collapse = getOption(\"pixie_border_collapse\", \"collapse\"), \r\n                            ...)\r\n{\r\n  UseMethod(\"sprinkle_border_collapse\")\r\n}\r\n\r\n#' @rdname sprinkle_border_collapse\r\n#' @export\r\n\r\nsprinkle_border_collapse.default <- function(x, \r\n                                    border_collapse = getOption(\"pixie_border_collapse\", \"collapse\"), \r\n                                    ...)\r\n{\r\n  coll <- checkmate::makeAssertCollection()\r\n  \r\n  checkmate::assert_class(x = x,\r\n                          classes = \"dust\",\r\n                          add = coll)\r\n  \r\n  border_collapse <- \r\n    sprinkle_border_collapse_index_assert(border_collapse = border_collapse,\r\n                                          coll = coll)\r\n  \r\n  checkmate::reportAssertions(coll)\r\n  \r\n  sprinkle_border_collapse_index(x = x,\r\n                                 border_collapse = border_collapse)\r\n}\r\n\r\n#' @rdname sprinkle_border_collapse\r\n#' @export\r\n\r\nsprinkle_border_collapse.dust_list <- function(x, \r\n                                      border_collapse = getOption(\"pixie_border_collapse\", \"collapse\"),\r\n                                      ...)\r\n{\r\n  structure(\r\n    lapply(x,\r\n           sprinkle_border_collapse.default,\r\n           border_collapse),\r\n    class = \"dust_list\"\r\n  )\r\n}\r\n\r\n# Unexported utilities ----------------------------------------------\r\n# These functions carry the the `_index` suffix for consistency with \r\n# the cell-valued sprinkles, but they don't actually require an \r\n# index, since they change table-valued sprinkles\r\n\r\nsprinkle_border_collapse_index_assert <- function(border_collapse = getOption(\"pixie_border_collapse\", \"collapse\"), \r\n                                                  coll)\r\n{\r\n  checkmate::matchArg(x = border_collapse,\r\n                      choices = c(\"collapse\", \"separate\", \"initial\",\r\n                                  \"inherit\"),\r\n                      add = coll,\r\n                      .var.name = \"border_collapse\")\r\n}\r\n\r\n# indices argument is only present to avoid errors when the argument is passed \r\n# from sprinkle\r\nsprinkle_border_collapse_index <- function(x, border_collapse, indices = NULL,\r\n                                           part = NULL)\r\n{\r\n  x[[\"border_collapse\"]] <- border_collapse\r\n  \r\n  x\r\n}"
  },
  {
    "path": "R/sprinkle_caption.R",
    "content": "#' @name sprinkle_caption\r\n#' @title Change the Caption in a Dust Table\r\n#' \r\n#' @description The table caption is often used as a brief title, but may also \r\n#'   be used to provide a longer statement explaining how to interpret the \r\n#'   table results.\r\n#'   \r\n#' @param x An object of class \\code{dust}\r\n#' @param caption \\code{character(1)} giving the new caption for the table.\r\n#' @param ... Additional arguments to pass to other methods. Currently ignored.\r\n#'\r\n#' @details The caption may be set during the initial \\code{dust} call.  This\r\n#'   method allows for modification afterward, such as in the case of when a \r\n#'   \\code{dust} object is loaded from memory and the initial call cannot be\r\n#'   accessed.\r\n#'   \r\n#' @author Benjamin Nutter\r\n#' \r\n#' @seealso \\code{\\link{dust}}, \\code{\\link{sprinkle}}\r\n#' \r\n#' @section Functional Requirements:\r\n#' \\enumerate{\r\n#'  \\item Change the \\code{caption} attribute of the \\code{dust} object.\r\n#'  \\item Cast an error if \\code{x} is not a \\code{dust} object.\r\n#'  \\item Cast an error if \\code{caption} is not a character object.\r\n#'  \\item Cast an error if \\code{caption} has length greater than 1.\r\n#' }\r\n#' \r\n#' @export\r\n\r\nsprinkle_caption <- function(x, caption, ...)\r\n{\r\n  UseMethod(\"sprinkle_caption\")\r\n}\r\n\r\n#' @rdname sprinkle_caption\r\n#' @export\r\n\r\nsprinkle_caption.default <- function(x, caption, ...)\r\n{\r\n  coll <- checkmate::makeAssertCollection()\r\n  \r\n  checkmate::assert_class(x = x,\r\n                          classes = \"dust\",\r\n                          add = coll)\r\n  \r\n  sprinkle_caption_index_assert(caption = caption,\r\n                                coll = coll)\r\n  \r\n  checkmate::reportAssertions(coll)\r\n  \r\n  sprinkle_caption_index(x = x,\r\n                         caption = caption)\r\n}\r\n\r\n#' @rdname sprinkle_caption\r\n#' @export\r\n\r\nsprinkle_caption.dust_list <- function(x, caption, ...)\r\n{\r\n  structure(\r\n    lapply(x,\r\n           sprinkle_caption.default,\r\n           caption),\r\n    class = \"dust_list\"\r\n  )\r\n}\r\n\r\n# Unexported utilities ----------------------------------------------\r\n# These functions carry the the `_index` suffix for consistency with \r\n# the cell-valued sprinkles, but they don't actually require an \r\n# index, since they change table-valued sprinkles\r\n\r\nsprinkle_caption_index_assert <- function(caption, coll)\r\n{\r\n  if (!missing(caption)){\r\n    checkmate::assert_character(x = caption,\r\n                                len = 1,\r\n                                add = coll,\r\n                                .var.name = \"caption\")\r\n  }\r\n}\r\n\r\n# indices argument is only present to avoid errors when the argument is passed \r\n# from sprinkle\r\nsprinkle_caption_index <- function(x, caption, indices = NULL, part = NULL)\r\n{\r\n  x[[\"caption\"]] <- caption\r\n  \r\n  x\r\n}"
  },
  {
    "path": "R/sprinkle_caption_number.R",
    "content": "#' @name sprinkle_caption_number\n#' @title Change the Caption in a Dust Table\n#' \n#' @description The table caption is often used as a brief title, but may also \n#'   be used to provide a longer statement explaining how to interpret the \n#'   table results.\n#'   \n#' @param x An object of class \\code{dust}\n#' @param caption_number \\code{logical(1)} When \\code{TRUE}, the table caption \n#'   is prefixed with \"Table #\". Table numbering is suppressed when \n#'   \\code{FALSE}.  When numbering is suppressed, the table number counter\n#'   will not increment.\n#' @param ... Additional arguments to pass to other methods. Currently ignored.\n#'\n#' @details Table numbering makes it possible to reference tables within a \n#'   document.  In some cases, the numbering is not desired. Suppressing \n#'   numbering may restrict the ability to make reference to the table.\n#'   \n#' @author Benjamin Nutter\n#' \n#' @seealso \\code{\\link{dust}}, \\code{\\link{sprinkle}}\n#' \n#' @section Functional Requirements:\n#' \\enumerate{\n#'  \\item Change the \\code{caption_number} attribute of the \\code{dust} object.\n#'  \\item Cast an error if \\code{x} is not a \\code{dust} object.\n#'  \\item Cast an error if \\code{caption_number} is not a logical object.\n#'  \\item Cast an error if \\code{caption_number} has length greater than 1.\n#' }\n#' \n#' @export\n\nsprinkle_caption_number <- function(x, caption_number, ...)\n{\n  UseMethod(\"sprinkle_caption_number\")\n}\n\n#' @rdname sprinkle_caption_number\n#' @export\n\nsprinkle_caption_number.default <- function(x, \n                                            caption_number = getOption(\"pixie_caption_number\", TRUE), \n                                            ...)\n{\n  coll <- checkmate::makeAssertCollection()\n  \n  checkmate::assert_class(x = x,\n                          classes = \"dust\",\n                          add = coll)\n  \n  sprinkle_caption_number_index_assert(caption_number = caption_number,\n                                       coll = coll)\n  \n  checkmate::reportAssertions(coll)\n  \n  sprinkle_caption_number_index(x = x,\n                                caption_number = caption_number)\n}\n\n#' @rdname sprinkle_caption_number\n#' @export\n\nsprinkle_caption_number.dust_list <- function(x, \n                                              caption_number = getOption(\"pixie_caption_number\", TRUE), \n                                              ...)\n{\n  structure(\n    lapply(x,\n           sprinkle_caption_number.default,\n           caption_number),\n    class = \"dust_list\"\n  )\n}\n\n# Unexported utilities ----------------------------------------------\n# These functions carry the the `_index` suffix for consistency with \n# the cell-valued sprinkles, but they don't actually require an \n# index, since they change table-valued sprinkles\n\nsprinkle_caption_number_index_assert <- function(caption_number, coll)\n{\n  if (!missing(caption_number)){\n    checkmate::assert_logical(x = caption_number,\n                                len = 1,\n                                add = coll,\n                                .var.name = \"caption_number\")\n  }\n}\n\n# indices argument is only present to avoid errors when the argument is passed \n# from sprinkle\nsprinkle_caption_number_index <- function(x, caption_number = getOption(\"pixie_caption_number\", TRUE), \n                                   indices = NULL, part = NULL)\n{\n  x[[\"caption_number\"]] <- caption_number\n  \n  x\n}"
  },
  {
    "path": "R/sprinkle_colnames.R",
    "content": "#' @name sprinkle_colnames\n#' @export sprinkle_colnames\n#' \n#' @title Column Names for \\code{dust} Tables\n#' @description Assigns new column names to a table\n#' \n#' @param x A dust object.\n#' @param ... Column names for the table.  See 'Input Formats'\n#' \n#' @section Input Formats:\n#' \\itemize{\n#'   \\item{named arguments}{ Using \\code{dust_colnames(term = \"Term\", estimate = \"Estimate\")}, \n#'     column names may be passed for all or a subset of the columns.  The existing column\n#'     name will be matched against the argument name.}\n#'   \\item{unnamed arguments}{ Using \\code{dust_colnames(\"Term\", \"Estimate\", \"SE\", ...)}, \n#'     column names may be passed for all of the columns.  If the arguments are unnamed, the \n#'     number of arguments passed must match the number of columns in the table.}\n#'  }\n#'  When using named arguments (or a named vector), you may not mix named and unnamed elements.  \n#'  In other words, if one element is named, they must all be named.  Unnamed elements are assigned\n#'  to columns in sequential order.\n#'  \n#' @author Benjamin Nutter\n#' \n#' @seealso \\code{\\link{sprinkle}}\n#' \n#' @examples\n#' x <- dust(lm(mpg ~ qsec + factor(am), data = mtcars)) \n#' x\n#' x %>% sprinkle_colnames(term = \"Term\", statistic = \"T\")\n#' x %>% sprinkle_colnames(\"Term\", \"Estimate\", \"SE\", \"T-statistic\", \"p-value\")\n#' \\dontrun{\n#' # Causes an error due to too few unnamed arguments\n#' x %>% sprinkle_colnames(\"Term\", \"Estimate\")\n#' }\n\n#' @rdname sprinkle_colnames\n#' @export\n\nsprinkle_colnames <- function(x, ...)\n{\n  UseMethod(\"sprinkle_colnames\")\n}\n\n#' @rdname sprinkle_colnames\n#' @export\n\nsprinkle_colnames.default <- function(x, ...)\n{\n  coll <- checkmate::makeAssertCollection()\n\n  checkmate::assertClass(x = x,\n                         classes = \"dust\")\n\n  new_names <- list(...)\n  \n  if (any(names(new_names) %in% \"\"))\n  {\n    coll$push(\"Elements of '...' must either all be named or all be unnamed\")\n  }\n  #* Return an error if any element in ... has length greater than 1.\n  else if (any(vapply(new_names, length, 1) != 1)){\n    coll$push(\"Arguments to '...' should have length 1\")\n    checkmate::reportAssertions(coll)\n  }\n  \n  #* Return the vector when no names are used\n  else if (is.null(names(new_names))){\n    new_names <- vapply(X = new_names, \n                        FUN = identity, \n                        FUN.VALUE = \"character\", \n                        USE.NAMES = FALSE)\n  }\n  \n  #* Return the vector when names are used\n  else if (!is.null(names(new_names))){\n    new_names <- vapply(X = new_names, \n                        FUN = identity,\n                        FUN.VALUE = \"character\",\n                        USE.NAMES = TRUE)\n  }\n\n  if (!is.null(names(new_names))){\n    if (any(!names(new_names) %in% x$head$col_name))\n    {\n      bad_names <- names(new_names)[!names(new_names) %in% x$head$col_name]\n      coll$push(sprintf(\"The following variable names are not found in the dust table:\\n    %s\",\n                        paste0(bad_names, collapse=\", \")))\n    }\n    checkmate::reportAssertions(coll)\n    \n    x$head$value[match(names(new_names), x$head$col_name)] <- new_names\n  } \n  else{\n    checkmate::assertCharacter(x = new_names,\n                               len = max(x[[\"head\"]][[\"col\"]]),\n                               add = coll)\n    x$head$value <- new_names\n  }\n  x\n}\n\n#' @rdname sprinkle_colnames\n#' @export\n\nsprinkle_colnames.dust_list <- function(x, ...)\n{\n  structure(\n    lapply(X = x,\n           FUN = sprinkle_colnames,\n           ...),\n    class = \"dust_list\"\n  )\n}\n"
  },
  {
    "path": "R/sprinkle_discrete.R",
    "content": "#' @name sprinkle_discrete\n#' @title Change Color Features by Discrete Values\n#' \n#' @description Distinct values within a range will be assigned a color and\n#'   the designated attribute of the table will be modified accordingly.\n#'   \n#' @param x An object of class \\code{dust}\n#' @param rows Either a numeric vector of rows in the tabular object to be \n#'   modified or an object of class \\code{call}.  When a \\code{call}, \n#'   generated by \\code{quote(expression)}, the expression resolves to \n#'   a logical vector the same length as the number of rows in the table.\n#'   Sprinkles are applied to where the expression resolves to \\code{TRUE}.\n#' @param cols Either a numeric vector of columns in the tabular object to\n#'   be modified, or a character vector of column names. A mixture of \n#'   character and numeric indices is permissible.\n#' @param discrete \\code{character}. A subset of \\code{c(\"bg\", \"font\", \n#'   \"font_color\", \"border\", \"left_border\", \"top_border\", \"right_border\",\n#'   \"bottom_border\")}.\n#' @param discrete_colors \\code{character}. Gives the color palette to be \n#'   used. Each value must be a valid color.  Defaults to evenly spaced\n#'   colors over the color space.\n#' @param part A character string denoting which part of the table to modify.\n#' @param fixed \\code{logical(1)} indicating if the values in \\code{rows} \n#'   and \\code{cols} should be read as fixed coordinate pairs.  By default, \n#'   sprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \n#'   meaning that the arguments do not have to share the same length.  \n#'   When \\code{fixed = TRUE}, they must share the same length.\n#' @param recycle A \\code{character} one that determines how sprinkles are \n#'   managed when the sprinkle input doesn't match the length of the region\n#'   to be sprinkled.  By default, recycling is turned off.  Recycling \n#'   may be performed across rows first (left to right, top to bottom), \n#'   or down columns first (top to bottom, left to right).\n#' @param ... Additional arguments to pass to other methods. Currently ignored.\n#' \n#' @details This sprinkle is only recognized by HTML and LaTeX.  All of the \n#'   \\code{height_units} values are recognized by HTML.  For LaTeX, \\code{\"px\"}\n#'   is converted to \\code{\"pt\"}. \n#'   \n#' \\code{\"font\"} and \\code{\"font_color\"} both change the font color.\n#' \n#' \\code{\"border\"} is a shortcut to specify all borders.\n#'   \n#' @section Functional Requirements:\n#' \\enumerate{\n#'  \\item Correctly reassigns the appropriate elements of the \\code{bg},\n#'    \\code{font_color}, \\code{left_border}, \\code{top_border},\n#'    \\code{right_border}, or \\code{bottom_border} column in the table part.\n#'  \\item Casts an error if \\code{x} is not a \\code{dust} object.\n#'  \\item Casts an error if \\code{discrete} is not a subset of \n#'    \\code{c(\"bg\", \"font\", \"font_color\", \"border\", \"left_border\",\n#'            \"right_border\", \"top_border\", \"bottom_border\")}\n#'  \\item Casts an error if \\code{discrete_colors} is not a \\code{character}\n#'    value.\n#'  \\item Casts an error if any value of \\code{discrete_colors} is not a\n#'    recognized color value.\n#'  \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n#'    \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n#'  \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\n#'  \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\n#'    \\code{\"rows\"}, or \\code{\"cols\"}\n#' }\n#' \n#' The functional behavior of the \\code{fixed} and \\code{recycle} arguments \n#' is not tested for this function. It is tested and validated in the\n#' tests for \\code{\\link{index_to_sprinkle}}.\n#' \n#' @seealso \\code{\\link{sprinkle}}, \n#'   \\code{\\link{index_to_sprinkle}}\n#'   \n#' @export\n\nsprinkle_discrete <- function(x, rows = NULL, cols = NULL, \n                              discrete = \"bg\",\n                              discrete_colors = getOption(\"pixie_discrete_pal\", NULL),\n                              part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                              fixed = FALSE, \n                              recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                            ...)\n{\n  UseMethod(\"sprinkle_discrete\")\n}\n\n#' @rdname sprinkle_discrete\n#' @export\n\nsprinkle_discrete.default <- function(x, rows = NULL, cols = NULL, \n                                   discrete = \"bg\",\n                                   discrete_colors = getOption(\"pixie_discrete_pal\", NULL),\n                                   part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                                   fixed = FALSE, \n                                   recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                                   ...)\n{\n  coll <- checkmate::makeAssertCollection()\n  \n  checkmate::assert_class(x = x,\n                          classes = \"dust\",\n                          add = coll)\n  \n  sprinkle_discrete_index_assert(discrete = discrete,\n                                 discrete_colors = discrete_colors,\n                                 coll = coll) \n  \n  indices <- index_to_sprinkle(x = x, \n                               rows = rows, \n                               cols = cols, \n                               fixed = fixed,\n                               part = part,\n                               recycle = recycle,\n                               coll = coll)\n  \n  checkmate::reportAssertions(coll)\n  \n  sprinkle_discrete_index(x = x, \n                          indices = indices, \n                          discrete = discrete, \n                          discrete_colors = discrete_colors, \n                          part = part)\n}\n\n#' @rdname sprinkle_discrete\n#' @export\n\nsprinkle_discrete.dust_list <- function(x, rows = NULL, cols = NULL, \n                                        discrete = \"bg\",\n                                        discrete_colors = getOption(\"pixie_discrete_pal\", NULL),\n                                      part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                                      fixed = FALSE, \n                                      recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                                      ...)\n{\n  structure(\n    lapply(X = x,\n           FUN = sprinkle_discrete.default,\n           rows = rows,\n           cols = cols,\n           discrete = discrete,\n           discrete_colors = discrete_colors,\n           part = part,\n           fixed = fixed,\n           recycle = recycle,\n           ...),\n    class = \"dust_list\"\n  )\n}\n\n# Unexported Utility ------------------------------------------------\n\n# These functions are to be used inside of the general `sprinkle` call\n# When used inside `sprinkle`, the indices are already determined, \n# the only the `height` and `height_units` arguments needs to be validated. \n# The assert function is kept separate so it may be called earlier\n# without attempting to perform the assignment.\n\nsprinkle_discrete_index_assert <- function(discrete = \"bg\", \n                                           discrete_colors = getOption(\"pixie_discrete_pal\", NULL), \n                                           coll)\n{\n  checkmate::assert_subset(x = discrete,\n                           choices = c(\"bg\", \"font\", \"font_color\",\n                                       \"border\", \"left_border\", \n                                       \"top_border\", \"right_border\",\n                                       \"bottom_border\"),\n                           add = coll)\n  \n  if (!is.null(discrete_colors))\n  {\n    checkmate::assert_character(x = discrete_colors,\n                                add = coll)\n    \n    valid_color <- is_valid_color(discrete_colors)  \n    if (!all(valid_color))\n    {\n      coll$push(sprintf(\"The following are not valid colors: %s\",\n                        paste0(discrete_colors[!valid_color], \n                               collapse = \", \")))\n    }\n  }  \n}\n\nsprinkle_discrete_index <- function(x, indices, \n                                    discrete = \"bg\", \n                                    discrete_colors = getOption(\"pixie_discrete_pal\", NULL), \n                                    part,\n                                    ...)\n{\n  part <- part[1]\n  \n  if (\"border\" %in% discrete)\n  {\n    discrete <- c(sprintf(\"%s_border\", \n                          c(\"top\", \"left\", \"right\", \"bottom\")),\n                  discrete)\n    discrete <- unique(discrete[!discrete %in% \"border\"])\n  }\n  \n  if (\"font\" %in% discrete)\n  {\n    discrete <- c(\"font_color\", discrete)\n    discrete <- unique(discrete[!discrete %in% \"font\"])\n  }\n  \n  ux <- unique(x[[part]][[\"value\"]][indices])\n  \n  if (is.null(discrete_colors)) \n  {\n    discrete_colors <- getOption(\"pixie_discrete_pal\", NULL)\n  }\n  \n  if (is.null(discrete_colors))\n  {\n    discrete_colors <- scales::hue_pal()(length(ux))\n  }\n  \n  checkmate::makeAssertion(x = discrete_colors,\n                           if (length(discrete_colors) >= length(ux))\n                           {\n                             TRUE\n                           }\n                           else\n                           {\n                             sprintf(\"`discrete_colors` must have at least the same length as the number of unique values (>= %s)\",\n                                     length(ux))\n                           },\n                           var.name = \"discrete_colors\",\n                           collection = NULL)\n  \n  args <- list(...)\n  \n  border_thickness <- \n    if (\"border_thickness\" %in% names(args)) args[[\"border_thickness\"]] else 1\n  \n  border_units <- \n    if (\"border_units\" %in% names(args)) args[[\"border_units\"]] else \"px\"\n  \n  border_style <- \n    if (\"border_style\" %in% names(args)) args[[\"border_style\"]] else \"solid\"\n  \n  for (i in seq_along(discrete))\n  {\n    if (grepl(\"border\", discrete[i]))\n    {\n      x[[part]][[discrete[i]]][indices] <- \n        sprintf(\"%s%s %s %s\",\n                border_thickness,\n                border_units,\n                border_style,\n                discrete_colors[as.numeric(as.factor(x[[part]][[\"value\"]][indices]))])\n    }\n    else \n    {\n      x[[part]][[discrete[i]]][indices] <- \n        discrete_colors[as.numeric(as.factor(x[[part]][[\"value\"]][indices]))]\n    }\n  }\n  \n  x\n}"
  },
  {
    "path": "R/sprinkle_fixed_header.R",
    "content": "#' @name sprinkle_fixed_header\r\n#' @title Assign a Fixed Header to an HTML Table\r\n#'\r\n#' @description Long tables to be displayed on-screen may benefit by keeping\r\n#'   the header fixed in position while scrolling through the body of the\r\n#'   table.  This allows the user to maintain visual contact between the\r\n#'   column name and the data.\r\n#'\r\n#' @param x An object of class \\code{dust}\r\n#' @param fixed_header \\code{logical(1)}. When \\code{TRUE}, HTML output will\r\n#'   produce a table with a fixed header and a scrollable body.\r\n#' @param scroll_body_height \\code{integerish(1)}. Sets the height of the scrollable\r\n#'   table body.\r\n#' @param scroll_body_height_units \\code{character(1)}. Determines the units for the\r\n#'   height of the scrollable table.  Defaults to \\code{\"px\"}.  Must be one\r\n#'   of \\code{c(\"px\", \"pt\", \"\\%\", \"em\")}.\r\n#' @param scroll_body_background_color \\code{character(1)}. The color of the background\r\n#'   of the body.  Must be a valid color.  It defaults to white, which may\r\n#'   override CSS settings provided by the user.  If this needs to be avoided,\r\n#'   you may use the \\code{\\link{fixed_header_css}} function to assist in\r\n#'   generating CSS code to use to define the CSS. See Avoiding CSS Conflicts.\r\n#' @param fixed_header_height \\code{integerish(1)}. Sets the height of the header\r\n#'   row.\r\n#' @param fixed_header_height_units \\code{character(1)}. Determines the units for the\r\n#'   height of the header row. Defaults to \\code{\"px\"}. Must be one of\r\n#'   \\code{c(\"px\", \"pt\", \"\\%\", \"em\")}.\r\n#' @param fixed_header_text_height \\code{numeric(1)}. Sets the height at which the\r\n#'   header text appears.  By default it is set to half of the header height.\r\n#'   This should be approximately centered, but you may alter this to get the\r\n#'   precise look you want.\r\n#' @param fixed_header_text_height_units \\code{character(1)}. Determines the units for\r\n#'   placing the header text.  Defaults to \\code{\"px\"}. Must be one of\r\n#'   \\code{c(\"px\", \"pt\", \"\\%\", \"em\")}.\r\n#' @param fixed_header_background_color \\code{character(1)}. Sets the background color for\r\n#'   the header row.  This defaults to white and may override the user's CSS\r\n#'   settings.  See Avoiding CSS Conflicts.\r\n#' @param include_fixed_header_css \\code{logical(1)}. When \\code{TRUE}, the CSS code to\r\n#'   produce the table is inserted directly ahead of the HTML code for the\r\n#'   table.  When \\code{FALSE}, the CSS is omitted and assumed to be provided\r\n#'   by the user.  This may be beneficial if the user has defined CSS styles\r\n#'   for their tables.  In this case, the user will need to add CSS classes\r\n#'   to their customized CSS to accomodate the fixed headers.  See Avoiding\r\n#'   CSS Conflicts.\r\n#' @param fixed_header_class_name \\code{character(1)}. When \r\n#'   \\code{include_fixed_header_css = FALSE}, this\r\n#'   class name is used to reference CSS classes provided by the user to\r\n#'   format the table correctly.\r\n#' @param ... Arguments to pass to other methods.\r\n#'\r\n#' @details CSS doesn't make this kind of table natural.  The solution to \r\n#'   generate the fixed headers used by \\code{pixiedust} is probably not the \r\n#'   best solution in terms of CSS design.  It is, however, the most conducive \r\n#'   to generating dynamically on the fly. \r\n#'   \r\n#'   The fixed header table requires nesting several HTML elements. \r\n#'   \\enumerate{\r\n#'    \\item a \\code{div} tag is used to control the alignment of the table\r\n#'    \\item a \\code{section} tag is used to set up the header row that remains fixed.\r\n#'    \\item a \\code{div} that sets the height of the scrollable body\r\n#'    \\item the \\code{table} tag establishes the actual table.\r\n#'    \\item The \\code{th} tags inside the table are set to full transparency and\r\n#'      the content of the headers is duplicated in a \\code{div} within the \r\n#'      \\code{th} tag to display the content.\r\n#'   }\r\n#'   \r\n#'   To accomplish these tasks, some CSS is exported with the table and placed\r\n#'   in the document immediately before the table.  Read further to understand\r\n#'   the conflicts that may arise if you are using custom CSS specifications \r\n#'   in your documents.\r\n#'\r\n#' @section Avoiding CSS Conflicts: \r\n#' Because of all of the shenanigans involved, exporting the CSS with the tables\r\n#' may result in conflicts with your custom CSS. Most importantly, any CSS\r\n#' you have applied to the \\code{th} or \\code{td} tags may be overwritten.\r\n#' If you are using custom CSS, you may want to consider using \r\n#' \\code{include_fixed_header_css = FALSE} and then utilizing \r\n#' \\code{\\link{fixed_header_css}} to generate CSS you can include in your \r\n#' CSS file to provide the fixed headers.  The code generated by \r\n#' \\code{fixed_header_css} ought to be placed before your definitions for\r\n#' \\code{td} and \\code{th}.  \r\n#' \r\n#' To get the same header design in the fixed table, you will want to modify \r\n#' the \\code{.th-pixie-fixed div} definition in the CSS to match your desired\r\n#' \\code{th} definition.\r\n#' \r\n#' The code produced by \\code{fixed_header_css} will include comments where\r\n#' there is potential for a CSS conflict.\r\n#'\r\n#' @section Functional Requirements:\r\n#' \\enumerate{\r\n#'  \\item Set the \\code{fixed_header} element of the \\code{dust} object correctly.\r\n#'  \\item Set the \\code{include_fixed_header_css} element of the \\code{dust}\r\n#'    object correctly.\r\n#'  \\item Set the \\code{fixed_header_param} element of the \\code{dust} object\r\n#'    correctly.\r\n#'  \\item Cast an error if \\code{x} does not inherit class \\code{dust}\r\n#'  \\item Cast an error if \\code{scroll_body_height} is not \\code{integerish(1)}\r\n#'  \\item Cast an error if \\code{scroll_body_height_units} is not \\code{character(1)}\r\n#'  \\item Cast an error if \\code{scroll_body_background_color} is not \\code{character(1)}\r\n#'  \\item Cast an error if \\code{scroll_body_background_color} is not a valid color.\r\n#'  \\item Cast an error if \\code{fixed_header_height} is not \\code{integerish(1)}\r\n#'  \\item Cast an error if \\code{fixed_header_height_units} is not \\code{character(1)}\r\n#'  \\item Cast an error if \\code{fixed_header_text_height} is not \\code{numeric(1)}\r\n#'  \\item Cast an error if \\code{fixed_header_text_height_units} is not \\code{character(1)}\r\n#'  \\item Cast an error if \\code{fixed_header_background_color} is not \\code{character(1)}\r\n#'  \\item Cast an error if \\code{fixed_header_background_color} is not a valid color.\r\n#'  \\item Cast an error if \\code{include_fixed_header_css} is not \\code{logical(1)}\r\n#'  \\item Cast an error if \\code{fixed_header_class_name} is not \\code{character(1)}\r\n#' }\r\n#'\r\n#' @export\r\n\r\nsprinkle_fixed_header <- function(x,\r\n                                  fixed_header = TRUE,\r\n                                  include_fixed_header_css = TRUE,\r\n                                  fixed_header_class_name = \"pixie-fixed\",\r\n                                  scroll_body_height = 300,\r\n                                  scroll_body_height_units = \"px\",\r\n                                  scroll_body_background_color = \"white\",\r\n                                  fixed_header_height = 20,\r\n                                  fixed_header_height_units = \"px\",\r\n                                  fixed_header_text_height = fixed_header_height / 2,\r\n                                  fixed_header_text_height_units = \"px\",\r\n                                  fixed_header_background_color = \"white\", ...)\r\n{\r\n  UseMethod(\"sprinkle_fixed_header\")\r\n}\r\n\r\n#' @rdname sprinkle_fixed_header\r\n#' @export\r\n\r\nsprinkle_fixed_header.default <- function(x,\r\n                                          fixed_header = TRUE,\r\n                                          include_fixed_header_css = TRUE,\r\n                                          fixed_header_class_name = \"pixie-fixed\",\r\n                                          scroll_body_height = 300,\r\n                                          scroll_body_height_units = \"px\",\r\n                                          scroll_body_background_color = \"white\",\r\n                                          fixed_header_height = 20,\r\n                                          fixed_header_height_units = \"px\",\r\n                                          fixed_header_text_height = fixed_header_height / 2,\r\n                                          fixed_header_text_height_units = \"px\",\r\n                                          fixed_header_background_color = \"white\", \r\n                                          ...)\r\n{\r\n  coll <- checkmate::makeAssertCollection()\r\n  \r\n  checkmate::assert_class(x = x,\r\n                          classes = \"dust\",\r\n                          add = coll)\r\n  \r\n  sprinkle_fixed_header_index_assert(\r\n    fixed_header = fixed_header,\r\n    include_fixed_header_css = include_fixed_header_css,\r\n    fixed_header_class_name = fixed_header_class_name,\r\n    scroll_body_height = scroll_body_height,\r\n    scroll_body_height_units = scroll_body_height_units,\r\n    scroll_body_background_color = scroll_body_background_color,\r\n    fixed_header_height = fixed_header_height,\r\n    fixed_header_height_units = fixed_header_height_units,\r\n    fixed_header_text_height = fixed_header_text_height,\r\n    fixed_header_text_height_units = fixed_header_text_height_units,\r\n    fixed_header_background_color = fixed_header_background_color,\r\n    coll = coll\r\n  )\r\n  \r\n  checkmate::reportAssertions(coll)\r\n  \r\n  sprinkle_fixed_header_index(\r\n    x = x,\r\n    fixed_header = fixed_header,\r\n    include_fixed_header_css = include_fixed_header_css,\r\n    fixed_header_class_name = fixed_header_class_name,\r\n    scroll_body_height = scroll_body_height,\r\n    scroll_body_height_units = scroll_body_height_units,\r\n    scroll_body_background_color = scroll_body_background_color,\r\n    fixed_header_height = fixed_header_height,\r\n    fixed_header_height_units = fixed_header_height_units,\r\n    fixed_header_text_height = fixed_header_text_height,\r\n    fixed_header_text_height_units = fixed_header_text_height_units,\r\n    fixed_header_background_color = fixed_header_background_color\r\n  )\r\n}\r\n\r\n#' @rdname sprinkle_fixed_header\r\n#' @export\r\n\r\nsprinkle_fixed_header.dust_list <- function(x,\r\n                                            fixed_header = TRUE,\r\n                                            include_fixed_header_css = TRUE,\r\n                                            fixed_header_class_name = \"pixie-fixed\",\r\n                                            scroll_body_height = 300,\r\n                                            scroll_body_height_units = \"px\",\r\n                                            scroll_body_background_color = \"white\",\r\n                                            fixed_header_height = 20,\r\n                                            fixed_header_height_units = \"px\",\r\n                                            fixed_header_text_height = fixed_header_height / 2,\r\n                                            fixed_header_text_height_units = \"px\",\r\n                                            fixed_header_background_color = \"white\", \r\n                                            ...)\r\n{\r\n  structure(\r\n    lapply(x,\r\n           sprinkle_fixed_header.default,\r\n           fixed_header = fixed_header,\r\n           include_fixed_header_css = include_fixed_header_css,\r\n           fixed_header_class_name = fixed_header_class_name,\r\n           scroll_body_height = scroll_body_height,\r\n           scroll_body_height_units = scroll_body_height_units,\r\n           scroll_body_background_color = scroll_body_background_color,\r\n           fixed_header_height = fixed_header_height,\r\n           fixed_header_height_units = fixed_header_height_units,\r\n           fixed_header_text_height = fixed_header_text_height,\r\n           fixed_header_text_height_units = fixed_header_text_height_units,\r\n           fixed_header_background_color = fixed_header_background_color),\r\n    class = \"dust_list\"\r\n  )\r\n}\r\n\r\n# Unexported utilities ----------------------------------------------\r\n# These functions carry the the `_index` suffix for consistency with \r\n# the cell-valued sprinkles, but they don't actually require an \r\n# index, since they change table-valued sprinkles\r\n\r\n\r\nsprinkle_fixed_header_index_assert <- function(x,\r\n                                               fixed_header = TRUE,\r\n                                               include_fixed_header_css = TRUE,\r\n                                               fixed_header_class_name = \"pixie-fixed\",\r\n                                               scroll_body_height = 300,\r\n                                               scroll_body_height_units = \"px\",\r\n                                               scroll_body_background_color = \"white\",\r\n                                               fixed_header_height = 20,\r\n                                               fixed_header_height_units = \"px\",\r\n                                               fixed_header_text_height = fixed_header_height / 2,\r\n                                               fixed_header_text_height_units = \"px\",\r\n                                               fixed_header_background_color = \"white\",\r\n                                               coll)\r\n{\r\n  checkmate::assert_logical(x = fixed_header,\r\n                            len = 1,\r\n                            .var.name = \"fixed_header\",\r\n                            add = coll)\r\n  \r\n  checkmate::assert_integerish(x = scroll_body_height,\r\n                               len = 1,\r\n                               add = coll,\r\n                               .var.name = \"scroll_body_height\")\r\n  \r\n  checkmate::assert_character(x = scroll_body_height_units,\r\n                              len = 1,\r\n                              add = coll,\r\n                              .var.name = \"scroll_body_height_units\")\r\n  \r\n  checkmate::assert_character(x = scroll_body_background_color,\r\n                              len = 1,\r\n                              add = coll,\r\n                              .var.name = \"scroll_body_background_color\")\r\n  \r\n  if (any(!is_valid_color(scroll_body_background_color))){\r\n    coll$push(\"'scroll_body_background_color' is not a valid color\")\r\n  }\r\n  \r\n  checkmate::assert_integerish(x = fixed_header_height,\r\n                               len = 1,\r\n                               .var.name = \"fixed_header_height\",\r\n                               add = coll)\r\n  \r\n  checkmate::assert_character(x = fixed_header_height_units,\r\n                              len = 1,\r\n                              .var.name = \"fixed_header_height_units\",\r\n                              add = coll)\r\n  \r\n  checkmate::assert_numeric(x = fixed_header_text_height,\r\n                            len = 1,\r\n                            .var.name = \"fixed_header_text_height\",\r\n                            add = coll)\r\n  \r\n  checkmate::assert_character(x = fixed_header_text_height_units,\r\n                              len = 1,\r\n                              .var.name = \"fixed_header_text_height_units\",\r\n                              add = coll)\r\n  \r\n  checkmate::assert_character(x = fixed_header_background_color,\r\n                              len = 1,\r\n                              .var.name = \"fixed_header_background_color\",\r\n                              add = coll)\r\n  \r\n  if (!any(is_valid_color(fixed_header_background_color))){\r\n    coll$push(\"'fixed_header_background_color' is not a valid color\")\r\n  }\r\n  \r\n  checkmate::assert_logical(x = include_fixed_header_css,\r\n                            len = 1,\r\n                            .var.name = \"include_fixed_header_css\",\r\n                            add = coll)\r\n  \r\n  checkmate::assert_character(x = fixed_header_class_name,\r\n                              len = 1,\r\n                              .var.name = \"fixed_header_class_name\",\r\n                              add = coll)\r\n\r\n}\r\n\r\n# indices argument is only present to avoid errors when the argument is passed \r\n# from sprinkle\r\n\r\nsprinkle_fixed_header_index <- function(x,\r\n                                        fixed_header = TRUE,\r\n                                        include_fixed_header_css = TRUE,\r\n                                        fixed_header_class_name = \"pixie-fixed\",\r\n                                        scroll_body_height = 300,\r\n                                        scroll_body_height_units = \"px\",\r\n                                        scroll_body_background_color = \"white\",\r\n                                        fixed_header_height = 20,\r\n                                        fixed_header_height_units = \"px\",\r\n                                        fixed_header_text_height = fixed_header_height / 2,\r\n                                        fixed_header_text_height_units = \"px\",\r\n                                        fixed_header_background_color = \"white\",\r\n                                        indices = NULL,\r\n                                        part = NULL)\r\n{\r\n  x[[\"fixed_header\"]] <- fixed_header\r\n  x[[\"include_fixed_header_css\"]] <- include_fixed_header_css\r\n  x[[\"fixed_header_param\"]] <- \r\n    list(fixed_header_class_name = fixed_header_class_name,\r\n         scroll_body_height = scroll_body_height,\r\n         scroll_body_height_units = scroll_body_height_units,\r\n         scroll_body_background_color = scroll_body_background_color,\r\n         fixed_header_height = fixed_header_height,\r\n         fixed_header_height_units = fixed_header_height_units,\r\n         fixed_header_text_height = fixed_header_text_height,\r\n         fixed_header_text_height_units = fixed_header_text_height_units,\r\n         fixed_header_background_color = fixed_header_background_color)\r\n  \r\n  x\r\n}"
  },
  {
    "path": "R/sprinkle_float.R",
    "content": "#' @name sprinkle_float\r\n#' @title Change the float Property in a Dust Table\r\n#' \r\n#' @description Alter the floating behavior of tables rendered in \r\n#' LaTeX documents.  Floating tables are moved to a position deemed ideal \r\n#' by the typesetter.  Setting \\code{float = FALSE} causes the table to \r\n#' be rendered in the position in which it is generated in the code.\r\n#'   \r\n#' @param x An object of class \\code{dust}\r\n#' @param float \\code{logical(1)} indicating if the table should be placed in\r\n#'   a floating environment.\r\n#' @param ... Additional arguments to pass to other methods. Currently ignored.\r\n#'\r\n#' @details See \\url{https://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions}\r\n#' for more about floating environments in LaTeX.\r\n#' \r\n#' This property has no effect on non-LaTeX output.\r\n#'   \r\n#' @author Benjamin Nutter\r\n#' \r\n#' @source \\url{https://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions}\r\n#' \r\n#' @seealso \\code{\\link{dust}}, \\code{\\link{sprinkle}}\r\n#' \r\n#' @section Functional Requirements:\r\n#' \\enumerate{\r\n#'  \\item Change the \\code{float} attribute of the \\code{dust} object.\r\n#'  \\item Cast an error if \\code{x} is not a \\code{dust} object.\r\n#'  \\item Cast an error if \\code{float} is not logical or length 1.\r\n#' }\r\n#' \r\n#' @export\r\n\r\nsprinkle_float <- function(x, \r\n                               float = getOption(\"pixie_float\", FALSE), \r\n                               ...)\r\n{\r\n  UseMethod(\"sprinkle_float\")\r\n}\r\n\r\n#' @rdname sprinkle_float\r\n#' @export\r\n\r\nsprinkle_float.default <- function(x, \r\n                                       float = getOption(\"pixie_float\", FALSE), \r\n                                       ...)\r\n{\r\n  coll <- checkmate::makeAssertCollection()\r\n  \r\n  checkmate::assert_class(x = x,\r\n                          classes = \"dust\",\r\n                          add = coll)\r\n  \r\n  sprinkle_float_index_assert(float = float,\r\n                              coll = coll)\r\n  \r\n  checkmate::reportAssertions(coll)\r\n  \r\n  sprinkle_float_index(x = x,\r\n                       float = float)\r\n}\r\n\r\n#' @rdname sprinkle_float\r\n#' @export\r\n\r\nsprinkle_float.dust_list <- function(x, \r\n                                         float = getOption(\"pixie_float\", FALSE),\r\n                                         ...)\r\n{\r\n  structure(\r\n    lapply(x,\r\n           sprinkle_float.default,\r\n           float),\r\n    class = \"dust_list\"\r\n  )\r\n}\r\n\r\n# Unexported utilities ----------------------------------------------\r\n# These functions carry the the `_index` suffix for consistency with \r\n# the cell-valued sprinkles, but they don't actually require an \r\n# index, since they change table-valued sprinkles\r\n\r\nsprinkle_float_index_assert <- function(float = getOption(\"pixie_float\", FALSE), coll)\r\n{\r\n  checkmate::assert_logical(x = float,\r\n                            len = 1,\r\n                            add = coll,\r\n                            .var.name = \"float\")\r\n}\r\n\r\n# indices argument is only present to avoid errors when the argument is passed \r\n# from sprinkle\r\nsprinkle_float_index <- function(x, float, indices = NULL, part = NULL)\r\n{\r\n  x[[\"float\"]] <- float\r\n  \r\n  x\r\n}"
  },
  {
    "path": "R/sprinkle_fn.R",
    "content": "#' @name sprinkle_fn\r\n#' @title Apply a function to a selection of cells\r\n#' \r\n#' @description The pre-defined sprinkles do not always provide the \r\n#'   desired impact on the tables. Applying a function allows for \r\n#'   highly customized output without having to pre-process that data \r\n#'   frame.\r\n#' \r\n#' @param x An object of class \\code{dust}\r\n#' @param rows Either a numeric vector of rows in the tabular object to be \r\n#'   modified or an object of class \\code{call}.  When a \\code{call}, \r\n#'   generated by \\code{quote(expression)}, the expression resolves to \r\n#'   a logical vector the same length as the number of rows in the table.\r\n#'   Sprinkles are applied to where the expression resolves to \\code{TRUE}.\r\n#' @param cols Either a numeric vector of columns in the tabular object to\r\n#'   be modified, or a character vector of column names. A mixture of \r\n#'   character and numeric indices is permissible.\r\n#' @param fn An object of class \\code{call}. The function should act on \r\n#'   an object \\code{value} (which is an internal column in the \\code{dust}\r\n#'   object). It is recommend to wrap the function call in \\code{quote}.\r\n#'   For example, \\code{quote(pvalString(value))} or \r\n#'   \\code{quote(format(value, nsmall = 3))}.\r\n#' @param part A character string denoting which part of the table to modify.\r\n#' @param fixed \\code{logical(1)} indicating if the values in \\code{rows} \r\n#'   and \\code{cols} should be read as fixed coordinate pairs.  By default, \r\n#'   sprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \r\n#'   meaning that the arguments do not have to share the same length.  \r\n#'   When \\code{fixed = TRUE}, they must share the same length.\r\n#' @param recycle A \\code{character} one that determines how sprinkles are \r\n#'   managed when the sprinkle input doesn't match the length of the region\r\n#'   to be sprinkled.  By default, recycling is turned off.  Recycling \r\n#'   may be performed across rows first (left to right, top to bottom), \r\n#'   or down columns first (top to bottom, left to right).\r\n#' @param ... Additional arguments to pass to other methods. Currently ignored.\r\n#' \r\n#'\r\n#' @details \\code{dust} objects transform tabular objects so that each cell\r\n#'   in the table comprises one row in the data frame of cell attributes.  \r\n#'   The function to be applied needs to act on the \\code{value} column of\r\n#'   that data frame. \r\n#' \r\n#' @author Benjamin Nutter\r\n#' \r\n#' @section Functional Requirements:\r\n#' \\enumerate{\r\n#'  \\item Correctly reassigns the appropriate elements \\code{fn} column\r\n#'    in the table part.\r\n#'  \\item Casts an error if \\code{x} is not a \\code{dust} object.\r\n#'  \\item Casts an error if \\code{fn} is not a \\code{call} object.\r\n#'  \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \r\n#'    \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\r\n#'  \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\r\n#'  \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\r\n#'    \\code{\"rows\"}, or \\code{\"cols\"}\r\n#' }\r\n#'\r\n#' @export\r\n\r\nsprinkle_fn <- function(x, rows = NULL, cols = NULL, fn = NULL, \r\n                        part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\r\n                        fixed = FALSE,\r\n                        recycle = c(\"none\", \"rows\", \"cols\"), ...)\r\n{\r\n  UseMethod(\"sprinkle_fn\")\r\n}\r\n\r\n#' @rdname sprinkle_fn\r\n#' @export\r\n\r\nsprinkle_fn.default <- function(x, rows = NULL, cols = NULL, fn = NULL,\r\n                                part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\r\n                                fixed = FALSE,\r\n                                recycle = c(\"none\", \"rows\", \"cols\", \"columns\"), \r\n                                ...)\r\n{\r\n  coll <- checkmate::makeAssertCollection()\r\n  \r\n  indices <- index_to_sprinkle(x = x, \r\n                               rows = rows, \r\n                               cols = cols, \r\n                               fixed = fixed,\r\n                               part = part,\r\n                               recycle = recycle,\r\n                               coll = coll)\r\n  \r\n  sprinkle_fn_index_assert(fn = fn,\r\n                           coll = coll)\r\n  \r\n  checkmate::reportAssertions(coll)\r\n \r\n  if (is.null(fn)) return(x)\r\n   \r\n  part <- part[1]\r\n  \r\n  sprinkle_fn_index(x = x, \r\n                    indices = indices,\r\n                    fn = fn,\r\n                    part = part)\r\n}\r\n\r\n#' @rdname sprinkle_fn\r\n#' @export\r\n\r\nsprinkle_fn.dust_list <- function(x, rows = NULL, cols = NULL, fn = NULL,\r\n                                  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\r\n                                  fixed = FALSE,\r\n                                  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\r\n                                  ...)\r\n{\r\n  structure(\r\n    lapply(X = x,\r\n           FUN = sprinkle_fn.default,\r\n           rows = rows,\r\n           cols = cols,\r\n           fn = fn,\r\n           part = part,\r\n           fixed = fixed,\r\n           recycle = recycle,\r\n           ...),\r\n    class = \"dust_list\"\r\n  )\r\n}\r\n\r\n# Unexported Utility ------------------------------------------------\r\n\r\n# These functions are to be used inside of the general `sprinkle` call\r\n# When used inside `sprinkle`, the indices are already determined, \r\n# the only the `fn` argument needs to be validated. \r\n# The assert function is kept separate so it may be called earlier\r\n# without attempting to perform the assignment.\r\n\r\nsprinkle_fn_index_assert <- function(fn = NULL, coll)\r\n{\r\n  checkmate::assert_class(x = fn,\r\n                          class = \"call\",\r\n                          null.ok = TRUE,\r\n                          add = coll)\r\n}\r\n\r\nsprinkle_fn_index <- function(x, indices, fn, part)\r\n{\r\n  x[[part]][[\"fn\"]][indices] <- deparse(fn)\r\n  \r\n  x\r\n}\r\n"
  },
  {
    "path": "R/sprinkle_font.R",
    "content": "#' @name sprinkle_font\n#' @title Sprinkle the Characteristics of Text in a Cell\n#' \n#' @description Text can be made to stand out (or fade away) by using font \n#'   features such as bold and italic text, color, size, or different fonts.\n#'   \n#' @param x An object of class \\code{dust}\n#' @param rows Either a numeric vector of rows in the tabular object to be \n#'   modified or an object of class \\code{call}.  When a \\code{call}, \n#'   generated by \\code{quote(expression)}, the expression resolves to \n#'   a logical vector the same length as the number of rows in the table.\n#'   Sprinkles are applied to where the expression resolves to \\code{TRUE}.\n#' @param cols Either a numeric vector of columns in the tabular object to\n#'   be modified, or a character vector of column names. A mixture of \n#'   character and numeric indices is permissible.\n#' @param bold \\code{logical(1)} indicating if the text in the selected cells\n#'   should be made bold.\n#' @param italic \\code{logical(1)} indicating if the text in the selected \n#'   cells should be made italic.\n#' @param font_size \\code{numeric(1)} giving the font size.\n#' @param font_size_units \\code{character(1)} giving the units of the font \n#'   size.  May be any of \\code{c(\"px\", \"pt\", \"\\%\", \"em\")}. LaTeX output only\n#'   recognizes \\code{\"pt\"} and \\code{\"em\"}. For LaTeX output, \\code{\"px\"} is\n#'   quietly changed to \\code{\"pt\"} when printing.\n#' @param font_color \\code{character(1)} giving a valid color name for the \n#'   text.\n#' @param font_family \\code{character(1)} giving the font name for the text. \n#'   This is only recognized in HTML output.   \n#' @param part A character string denoting which part of the table to modify.\n#' @param fixed \\code{logical(1)} indicating if the values in \\code{rows} \n#'   and \\code{cols} should be read as fixed coordinate pairs.  By default, \n#'   sprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \n#'   meaning that the arguments do not have to share the same length.  \n#'   When \\code{fixed = TRUE}, they must share the same length.\n#' @param recycle A \\code{character} one that determines how sprinkles are \n#'   managed when the sprinkle input doesn't match the length of the region\n#'   to be sprinkled.  By default, recycling is turned off.  Recycling \n#'   may be performed across rows first (left to right, top to bottom), \n#'   or down columns first (top to bottom, left to right).\n#' @param ... Additional arguments to pass to other methods. Currently ignored.\n#' \n#' @details The \\code{bold} and \\code{italic} features are recognized by all \n#'   formats.  \n#'   \n#'   Font size features are recognized by HTML and LaTeX. LaTeX only recognizes \n#'   the font size unit options of \\code{\"pt\"} and \\code{\"em\"}, but will quietly\n#'   change \\code{\"px\"} to \\code{\"pt\"} when printing.\n#'   \n#'   Font color features are recognized by HTML and LaTeX.\n#'   \n#'   Font family is only recognized by HTML.\n#' \n#' @seealso \\code{\\link{sprinkle}}\n#' \n#' @section Functional Requirements:\n#' \\enumerate{\n#'   \\item Correctly change the \\code{bold} column of the table part for \n#'     the selected cells.\n#'   \\item Correctly change the \\code{italic} column of the table part for \n#'     the selected cells.\n#'   \\item Correctly change the \\code{font_size} column of the table part for \n#'     the selected cells.\n#'   \\item Correctly change the \\code{font_size_units} column of the table part for \n#'     the selected cells.\n#'   \\item Correctly chagne the \\code{font_color} column of the table part \n#'     for the selected cells.\n#'   \\item Correctly change the \\code{font_family} column of the table part for \n#'     the selected cells.\n#'   \\item Cast an error if \\code{x} is not a dust object.\n#'   \\item Cast an error if \\code{bold} is not \\code{logical(1)}\n#'   \\item Cast an error if \\code{italic} is not \\code{logical(1)}\n#'   \\item Cast an error if \\code{font_size} is not \\code{numeric(1)}\n#'   \\item Cast an error if \\code{font_size_units} is not \\code{character(1)}\n#'   \\item Cast an error if \\code{font_size_units} is not one of \n#'     px, pt, em, or %\n#'   \\item Cast an error if \\code{font_color} is not \\code{character(1)}\n#'   \\item Cast an error if \\code{font_family} is not \\code{character(1)}\n#'   \\item Cast an error if \\code{part} is not a subset of \\code{c(\"body\", \n#'     \"head\", \"foot\", \"interfoot\")}\n#'  \\item Cast an error if \\code{recycle = \"none\"} and \\code{bold}\n#'    does not have length 1.\n#'  \\item Cast an error if \\code{recycle = \"none\"} and \\code{italic}\n#'    does not have length 1.\n#'  \\item Cast an error if \\code{recycle = \"none\"} and \\code{font_size}\n#'    does not have length 1.\n#'  \\item Cast an error if \\code{recycle = \"none\"} and \\code{font_size_units}\n#'    does not have length 1.\n#'  \\item Cast an error if \\code{recycle = \"none\"} and \\code{font_color}\n#'    does not have length 1.\n#'  \\item Cast an error if \\code{recycle = \"none\"} and \\code{font_family}\n#'    does not have length 1.\n#' }\n#' \n#' The functional behavior of the \\code{fixed} and \\code{recycle} arguments \n#' is not tested for this function. It is tested and validated in the\n#' tests for \\code{\\link{index_to_sprinkle}}.\n#' \n#' @author Benjamin Nutter\n#' \n#' @export\n\nsprinkle_font <- function(x, rows = NULL, cols = NULL,\n                          bold = NULL, italic = NULL,\n                          font_size = NULL, font_size_units = NULL,\n                          font_color = NULL, font_family = NULL,\n                          ...,\n                          part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                          fixed = FALSE,\n                          recycle = \"none\")\n{\n  UseMethod(\"sprinkle_font\")\n}\n\n#' @rdname sprinkle_font\n#' @export\n\nsprinkle_font.default <- function(x, rows = NULL, cols = NULL,\n                               bold = NULL, italic = NULL,\n                               font_size = NULL, font_size_units = NULL,\n                               font_color = NULL, font_family = NULL,\n                               ...,\n                               part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                               fixed = FALSE,\n                               recycle = \"none\")\n{\n  coll <- checkmate::makeAssertCollection()\n  \n  checkmate::assert_class(x = x,\n                          classes = \"dust\",\n                          add = coll)\n  \n  indices <- index_to_sprinkle(x = x, \n                               rows = rows, \n                               cols = cols, \n                               fixed = fixed,\n                               part = part,\n                               recycle = recycle,\n                               coll = coll)\n  \n  recycle <- recycle[1]\n  \n  sprinkle_font_index_assert(bold = bold, \n                             italic = italic,\n                             font_size = font_size, \n                             font_size_units = font_size_units,\n                             font_color = font_color, \n                             font_family = font_family,\n                             recycle = recycle,\n                             coll = coll)\n  \n  checkmate::reportAssertions(coll)\n  \n  part <- part[1]\n  \n  sprinkle_font_index(x = x, \n                      indices = indices, \n                      bold = bold, \n                      italic = italic,\n                      font_size = font_size, \n                      font_size_units = font_size_units,\n                      font_color = font_color, \n                      font_family = font_family, \n                      part = part)\n}\n\n#' @rdname sprinkle_font\n#' @export\n\nsprinkle_font.dust_list <- function(x, rows = NULL, cols = NULL,\n                                    bold = NULL, italic = NULL,\n                                    font_size = NULL, font_size_units = NULL,\n                                    font_color = NULL, font_family = NULL,\n                                    ...,\n                                    part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                                    fixed = FALSE,\n                                    recycle = \"none\")\n{\n  structure(\n    lapply(x,\n           sprinkle_font.default,\n           rows = rows,\n           cols = cols,\n           bold = bold,\n           italic = italic,\n           font_size = font_size,\n           font_size_units = font_size_units,\n           font_color = font_color,\n           font_family = font_family,\n           part = part,\n           fixed = fixed,\n           recycle = recycle,\n           ...),\n    class = \"dust_list\"\n  )\n}\n\n# Unexported Utility ------------------------------------------------\n\n# These functions are to be used inside of the general `sprinkle` call\n# When used inside `sprinkle`, the indices are already determined, \n# the only the `halign` and `valign` arguments needs to be validated. \n# The assert function is kept separate so it may be called earlier\n# without attempting to perform the assignment.\n\nsprinkle_font_index_assert <- function(bold = NULL, italic = NULL,\n                                       font_size = NULL, font_size_units = NULL,\n                                       font_color = NULL, font_family = NULL,\n                                       recycle = \"none\",\n                                       coll = coll)\n{\n  if (!is.null(bold))\n  {\n    checkmate::assert_logical(x = bold,\n                              add = coll,\n                              .var.name = \"bold\")\n    \n    if (recycle == \"none\" && length(bold) != 1)\n      coll$push(\"When `recycle` = 'none', bold must have length 1.\")\n  }\n  \n  if (!is.null(italic))\n  {\n    checkmate::assert_logical(x = italic,\n                              add = coll,\n                              .var.name = \"italic\")\n    \n    if (recycle == \"none\" && length(italic) != 1)\n      coll$push(\"When `recycle` = 'none', italic must have length 1.\")\n  }\n  \n  if (!is.null(font_size))\n  {\n    checkmate::assert_numeric(x = font_size,\n                              add = coll,\n                              .var.name = \"font_size\")\n    \n    if (recycle == \"none\" && length(font_size) != 1)\n      coll$push(\"When `recycle` = 'none', font_size must have length 1.\")\n  }\n  \n  if (!is.null(font_size_units))\n  {\n    checkmate::assert_character(x = font_size_units,\n                                add = coll,\n                                .var.name = \"font_size_units\")\n    \n    checkmate::assert_subset(x = font_size_units,\n                             choices = c(\"px\", \"pt\", \"em\", \"%\"),\n                             add = coll,\n                             .var.name = \"font_size_units\")\n    \n    if (recycle == \"none\" && length(font_size_units) != 1)\n      coll$push(\"When `recycle` = 'none', font_size_units must have length 1.\")\n  }\n  \n  if (!is.null(font_color))\n  {\n    checkmate::assert_character(x = font_color,\n                                add = coll,\n                                .var.name = \"font_color\")\n    \n    if (recycle == \"none\" && length(font_color) != 1)\n      coll$push(\"When `recycle` = 'none', font_color must have length 1.\")\n    \n    if (!all(is_valid_color(font_color)))\n    {\n      coll$push(sprintf(\"`font_color` has invalid colors: %s\",\n                        font_color[!is_valid_color(font_color)]))\n    }\n  }\n  \n  if (!is.null(font_family))\n  {\n    checkmate::assert_character(x = font_family,\n                                add = coll,\n                                .var.name = \"font_family\")\n    \n    if (recycle == \"none\" && length(font_family) != 1)\n      coll$push(\"When `recycle` = 'none', font_family must have length 1.\")\n  }\n}\n\nsprinkle_font_index <- function(x, indices, \n                                bold = NULL, italic = NULL,\n                                font_size = NULL, font_size_units = NULL,\n                                font_color = NULL, font_family = NULL, part)\n{\n  if (!is.null(bold))\n  {\n    x[[part]][[\"bold\"]][indices] <- bold\n  }\n  \n  if (!is.null(italic))\n  {\n    x[[part]][[\"italic\"]][indices] <- italic\n  }\n  \n  if (!is.null(font_size))\n  {\n    x[[part]][[\"font_size\"]][indices] <- font_size\n  }\n  \n  if (!is.null(font_size_units))\n  {\n    x[[part]][[\"font_size_units\"]][indices] <- font_size_units\n  }\n  \n  if (!is.null(font_color))\n  {\n    x[[part]][[\"font_color\"]][indices] <- font_color\n  }\n  \n  if (!is.null(font_family))\n  {\n    x[[part]][[\"font_family\"]][indices] <- font_family\n  }\n  \n  x\n}"
  },
  {
    "path": "R/sprinkle_gradient.R",
    "content": "#' @name sprinkle_gradient\n#' @title Change Color Features by Binning Numeric Values\n#' \n#' @description Numeric values within a range of cells are binned and colors\n#'   assigned to show gradual increases in the numeric value.\n#'   \n#' @param x An object of class \\code{dust}\n#' @param rows Either a numeric vector of rows in the tabular object to be \n#'   modified or an object of class \\code{call}.  When a \\code{call}, \n#'   generated by \\code{quote(expression)}, the expression resolves to \n#'   a logical vector the same length as the number of rows in the table.\n#'   Sprinkles are applied to where the expression resolves to \\code{TRUE}.\n#' @param cols Either a numeric vector of columns in the tabular object to\n#'   be modified, or a character vector of column names. A mixture of \n#'   character and numeric indices is permissible.\n#' @param gradient \\code{character}. A subset of \\code{c(\"bg\", \"font\", \n#'   \"font_color\", \"border\", \"left_border\", \"top_border\", \"right_border\",\n#'   \"bottom_border\")}.\n#' @param gradient_colors \\code{character(2)}. Gives the colors between \n#'   which to shared gradients.\n#' @param gradient_cut \\code{numeric}. Determines the breaks points for the \n#'   gradient shading. When \\code{NULL} equally spaced quantiles are used, \n#'   the number of which are determined by \\code{gradient_n}.\n#' @param gradient_n \\code{numeric(1)}. Determines the number of shades to use \n#'   between the colors in \\code{gradient_colors} \n#' @param gradient_na \\code{character(1)} A valid color that sets the color of \n#'   \\code{NA} values when shading a numeric range.\n#' @param part A character string denoting which part of the table to modify.\n#' @param fixed \\code{logical(1)} indicating if the values in \\code{rows} \n#'   and \\code{cols} should be read as fixed coordinate pairs.  By default, \n#'   sprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \n#'   meaning that the arguments do not have to share the same length.  \n#'   When \\code{fixed = TRUE}, they must share the same length.\n#' @param recycle A \\code{character} one that determines how sprinkles are \n#'   managed when the sprinkle input doesn't match the length of the region\n#'   to be sprinkled.  By default, recycling is turned off.  Recycling \n#'   may be performed across rows first (left to right, top to bottom), \n#'   or down columns first (top to bottom, left to right).\n#' @param ... Additional arguments to pass to other methods. Currently ignored.\n#' \n#' @details This sprinkle is only recognized by HTML and LaTeX.  All of the \n#'   \\code{height_units} values are recognized by HTML.  For LaTeX, \\code{\"px\"}\n#'   is converted to \\code{\"pt\"}. \n#'   \n#' \\code{\"font\"} and \\code{\"font_color\"} both change the font color.\n#' \n#' \\code{\"border\"} is a shortcut to specify all borders.\n#'   \n#' @section Functional Requirements:\n#' \\enumerate{\n#'  \\item Correctly reassigns the appropriate elements of the \\code{bg},\n#'    \\code{font_color}, \\code{left_border}, \\code{top_border},\n#'    \\code{right_border}, or \\code{bottom_border} column in the table part.\n#'  \\item Casts an error if \\code{x} is not a \\code{dust} object.\n#'  \\item Casts an error if \\code{gradient} is not a subset of \n#'    \\code{c(\"bg\", \"font\", \"font_color\", \"border\", \"left_border\",\n#'            \"right_border\", \"top_border\", \"bottom_border\")}\n#'  \\item Casts an error if \\code{gradient_colors} is not a \\code{character(2)}\n#'    value.\n#'  \\item Casts an error if any value of \\code{gradient_colors} is not a\n#'    recognized color value.\n#'  \\item Casts an error if \\code{gradient_cut} is not \\code{numeric}.\n#'  \\item Casts an error if \\code{gradient_n} is not \\code{numeric(1)}.\n#'  \\item Casts an error if \\code{gradient_na} is not \\code{character(1)}.\n#'  \\item Casts an error if \\code{gradient_na} is not a valid color.\n#'  \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n#'    \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n#'  \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\n#'  \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\n#'    \\code{\"rows\"}, or \\code{\"cols\"}\n#' }\n#' \n#' The functional behavior of the \\code{fixed} and \\code{recycle} arguments \n#' is not tested for this function. It is tested and validated in the\n#' tests for \\code{\\link{index_to_sprinkle}}.\n#' \n#' @seealso \\code{\\link{sprinkle}}, \n#'   \\code{\\link{index_to_sprinkle}}\n#'   \n#' @export\n\nsprinkle_gradient <- function(x, rows = NULL, cols = NULL, \n                              gradient = \"bg\",\n                              gradient_colors = getOption(\"pixie_gradient_pal\", NULL),\n                              gradient_cut = NULL,\n                              gradient_n = 10,\n                              gradient_na = \"grey\",\n                              part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                              fixed = FALSE, \n                              recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                            ...)\n{\n  UseMethod(\"sprinkle_gradient\")\n}\n\n#' @rdname sprinkle_gradient\n#' @export\n\nsprinkle_gradient.default <- function(x, rows = NULL, cols = NULL, \n                                   gradient = \"bg\",\n                                   gradient_colors = getOption(\"pixie_gradient_pal\", \n                                                               c(\"#132B43\", \"#56B1F7\")),\n                                   gradient_cut = NULL,\n                                   gradient_n = 10,\n                                   gradient_na = \"grey\",\n                                   part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                                   fixed = FALSE, \n                                   recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                                   ...)\n{\n  coll <- checkmate::makeAssertCollection()\n  \n  checkmate::assert_class(x = x,\n                          classes = \"dust\",\n                          add = coll)\n  \n  sprinkle_gradient_index_assert(gradient = gradient, \n                                 gradient_colors = gradient_colors, \n                                 gradient_cut = gradient_cut,\n                                 gradient_n = gradient_n,\n                                 gradient_na = gradient_na,\n                                 coll = coll)\n  \n  indices <- index_to_sprinkle(x = x, \n                               rows = rows, \n                               cols = cols, \n                               fixed = fixed,\n                               part = part,\n                               recycle = recycle,\n                               coll = coll)\n  \n  checkmate::reportAssertions(coll)\n  \n  sprinkle_gradient_index(x = x, \n                          indices = indices, \n                          gradient = gradient, \n                          gradient_colors = gradient_colors, \n                          gradient_cut = gradient_cut, \n                          gradient_n = gradient_n, \n                          gradient_na = gradient_na, \n                          part = part, \n                          ...)\n}\n\n#' @rdname sprinkle_gradient\n#' @export\n\nsprinkle_gradient.dust_list <- function(x, rows = NULL, cols = NULL, \n                                        gradient = \"bg\",\n                                        gradient_colors = getOption(\"pixie_gradient_pal\", \n                                                                    c(\"#132B43\", \"#56B1F7\")),\n                                        gradient_cut = NULL,\n                                        gradient_n = 10,\n                                        gradient_na = \"grey\",\n                                        part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                                      fixed = FALSE, \n                                      recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                                      ...)\n{\n  structure(\n    lapply(X = x,\n           FUN = sprinkle_gradient.default,\n           rows = rows,\n           cols = cols,\n           gradient = gradient,\n           gradient_colors = gradient_colors,\n           gradient_cut = gradient_cut,\n           gradient_n = gradient_n,\n           gradient_na = gradient_na,\n           part = part,\n           fixed = fixed,\n           recycle = recycle,\n           ...),\n    class = \"dust_list\"\n  )\n}\n\n# Unexported Utility ------------------------------------------------\n\n# These functions are to be used inside of the general `sprinkle` call\n# When used inside `sprinkle`, the indices are already determined, \n# the only the `height` and `height_units` arguments needs to be validated. \n# The assert function is kept separate so it may be called earlier\n# without attempting to perform the assignment.\n\nsprinkle_gradient_index_assert <- function(gradient = \"bg\",\n                                           gradient_colors = getOption(\"pixie_gradient_pal\", NULL),\n                                           gradient_cut = NULL,\n                                           gradient_n = 10,\n                                           gradient_na = \"grey\",\n                                           coll)\n{\n  checkmate::assert_subset(x = gradient,\n                           choices = c(\"bg\", \"font\", \"font_color\",\n                                       \"border\", \"left_border\", \n                                       \"top_border\", \"right_border\",\n                                       \"bottom_border\"),\n                           add = coll)\n  \n  if (!is.null(gradient_colors))\n  {\n    checkmate::assert_character(x = gradient_colors,\n                                len = 2,\n                                add = coll)\n    \n    valid_color <-  is_valid_color(gradient_colors)  \n    if (!all(valid_color))\n    {\n      coll$push(sprintf(\"The following are not valid colors: %s\",\n                        paste0(gradient_colors[!valid_color], \n                               collapse = \", \")))\n    }\n  }\n  \n  if (!is.null(gradient_cut))\n  {\n    checkmate::assert_numeric(x = gradient_cut,\n                              add = coll)\n  }\n  \n  if (!is.null(gradient_n))\n  {\n    checkmate::assert_numeric(x = gradient_n,\n                              len = 1,\n                              add = coll)\n  }\n  \n  if (!is.null(gradient_na))\n  {\n    checkmate::assert_character(x = gradient_na,\n                              len = 1,\n                              add = coll)\n    \n    if (any(!is_valid_color(gradient_na)))\n    {\n      coll$push(\"`gradient_na` must be a valid color\")\n    }\n  }\n}\n\nsprinkle_gradient_index <- function(x, indices, \n                                    gradient = \"bg\",\n                                    gradient_colors = getOption(\"pixie_gradient_pal\", NULL),\n                                    gradient_cut = NULL,\n                                    gradient_n = 10,\n                                    gradient_na = \"grey\", \n                                    part, ...)\n{\n  part <- part[1]\n  \n  if (\"border\" %in% gradient)\n  {\n    gradient <- c(sprintf(\"%s_border\", \n                          c(\"top\", \"left\", \"right\", \"bottom\")),\n                  gradient)\n    gradient <- unique(gradient[!gradient %in% \"border\"])\n  }\n  \n  if (\"font\" %in% gradient)\n  {\n    gradient <- c(\"font_color\", gradient)\n    gradient <- unique(gradient[!gradient %in% \"font\"])\n  }\n  \n  ux <- unique(x[[part]][[\"value\"]][indices])\n  \n  if (is.null(gradient_colors)) \n  {\n    gradient_colors <- getOption(\"pixie_gradient_pal\", \n                                 c(\"#132B43\", \"#56B1F7\"))\n  }\n  \n  args <- list(...)\n  \n  border_thickness <- \n    if (\"border_thickness\" %in% names(args)) args[[\"border_thickness\"]] else 1\n  \n  border_units <- \n    if (\"border_units\" %in% names(args)) args[[\"border_units\"]] else \"px\"\n  \n  border_style <- \n    if (\"border_style\" %in% names(args)) args[[\"border_style\"]] else \"solid\"\n  \n  gradient[\"font\" %in% gradient] <- \"font_color\"\n  \n  if (is.null(gradient_n)) gradient_n <- 10\n  \n  if (is.null(gradient_na))\n  {\n    gradient_na <- \"grey\"\n  }\n  \n  gradient_colors <- \n    scales::gradient_n_pal(gradient_colors)(seq(0, 1, length.out = gradient_n))\n  \n  if (is.null(border_thickness)) border_thickness <- 1\n  if (is.null(border_units)) border_units <- \"px\"\n  if (is.null(border_style)) border_style <- \"solid\"\n  \n  gradient_split <- \n    if (is.null(gradient_cut))\n    {\n      cut(as.numeric(x[[part]][[\"value\"]][indices]),\n          breaks = stats::quantile(as.numeric(x[[part]][[\"value\"]][indices]), \n                                   probs = seq(0, 1, length.out = gradient_n),\n                                   na.rm = TRUE),\n          include.lowest = TRUE)\n    }\n  else\n  {\n    cut(as.numeric(x[[part]][[\"value\"]][indices]),\n        breaks = gradient_cut,\n        include.lowest = TRUE,\n        na.rm = TRUE)\n  }\n  \n  na_val <- which(is.na(gradient_split))\n  \n  for (i in seq_along(gradient))\n  {\n    if (grepl(\"border\", gradient[i]))\n    {\n      x[[part]][[gradient[i]]][indices] <- \n        sprintf(\"%s%s %s %s\",\n                border_thickness,\n                border_units,\n                border_style,\n                gradient_colors[as.numeric(gradient_split)])\n      \n      x[[part]][[gradient[i]]][indices][na_val] <- \n        sprintf(\"%s%s %s %s\",\n                border_thickness,\n                border_units,\n                border_style,\n                gradient_na)\n    }\n    else \n    {\n      x[[part]][[gradient[i]]][indices] <- \n        gradient_colors[as.numeric(gradient_split)]\n      \n      x[[part]][[gradient[i]]][indices][na_val] <- \n        gradient_na\n    }\n  }\n  \n  x\n}"
  },
  {
    "path": "R/sprinkle_height.R",
    "content": "#' @name sprinkle_height\n#' @title Adjust Table Cell Height\n#' \n#' @description Customize the height of a cell in a table. This may be done\n#'   to improve the appearance of cells with long text.\n#'   \n#' @param x An object of class \\code{dust}\n#' @param rows Either a numeric vector of rows in the tabular object to be \n#'   modified or an object of class \\code{call}.  When a \\code{call}, \n#'   generated by \\code{quote(expression)}, the expression resolves to \n#'   a logical vector the same length as the number of rows in the table.\n#'   Sprinkles are applied to where the expression resolves to \\code{TRUE}.\n#' @param cols Either a numeric vector of columns in the tabular object to\n#'   be modified, or a character vector of column names. A mixture of \n#'   character and numeric indices is permissible.\n#' @param height \\code{numeric(1)}. Gives the height of the cell.\n#' @param height_units \\code{character(1)}. Gives the units for \\code{height}.\n#'   One of \\code{c(\"pt\", \"px\", \"cm\", \"in\", \"\\%\")}\n#' @param part A character string denoting which part of the table to modify.\n#' @param fixed \\code{logical(1)} indicating if the values in \\code{rows} \n#'   and \\code{cols} should be read as fixed coordinate pairs.  By default, \n#'   sprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \n#'   meaning that the arguments do not have to share the same length.  \n#'   When \\code{fixed = TRUE}, they must share the same length.\n#' @param recycle A \\code{character} one that determines how sprinkles are \n#'   managed when the sprinkle input doesn't match the length of the region\n#'   to be sprinkled.  By default, recycling is turned off.  Recycling \n#'   may be performed across rows first (left to right, top to bottom), \n#'   or down columns first (top to bottom, left to right).\n#' @param ... Additional arguments to pass to other methods. Currently ignored.\n#' \n#' @details This sprinkle is only recognized by HTML and LaTeX.  All of the \n#'   \\code{height_units} values are recognized by HTML.  For LaTeX, \\code{\"px\"}\n#'   is converted to \\code{\"pt\"}. \n#'   \n#' @section Functional Requirements:\n#' \\enumerate{\n#'  \\item Correctly reassigns the appropriate elements of \\code{height} \n#'    and \\code{height_units} columns in the table part.\n#'  \\item Casts an error if \\code{x} is not a \\code{dust} object.\n#'  \\item Casts an error if \\code{height} is not a \\code{numeric(1)}\n#'  \\item Casts an error if \\code{height_units} is not a \\code{character(1)}\n#'  \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n#'    \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n#'  \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\n#'  \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\n#'    \\code{\"rows\"}, or \\code{\"cols\"}\n#'  \\item Cast an error if \\code{recycle = \"none\"} and \\code{height}\n#'    does not have length 1.\n#'  \\item When \\code{recycle = \"none\"}, quietly coerce \\code{height_units}\n#'    to just the first element given.\n#' }\n#' \n#' The functional behavior of the \\code{fixed} and \\code{recycle} arguments \n#' is not tested for this function. It is tested and validated in the\n#' tests for \\code{\\link{index_to_sprinkle}}.\n#' \n#' @seealso \\code{\\link{sprinkle}}, \n#'   \\code{\\link{index_to_sprinkle}}\n#'   \n#' @export\n\nsprinkle_height <- function(x, rows = NULL, cols = NULL, \n                            height = NULL, height_units = NULL,\n                            part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                            fixed = FALSE, \n                            recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                            ...)\n{\n  UseMethod(\"sprinkle_height\")\n}\n\n#' @rdname sprinkle_height\n#' @export\n\nsprinkle_height.default <- function(x, rows = NULL, cols = NULL, \n                                 height = NULL, height_units = NULL,\n                                 part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                                 fixed = FALSE, \n                                 recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                                 ...)\n{\n  coll <- checkmate::makeAssertCollection()\n  \n  checkmate::assert_class(x = x,\n                          classes = \"dust\",\n                          add = coll)\n  \n  indices <- index_to_sprinkle(x = x, \n                               rows = rows, \n                               cols = cols, \n                               fixed = fixed,\n                               part = part,\n                               recycle = recycle,\n                               coll = coll)\n  \n  recycle <- recycle[1]\n  \n  sprinkle_height_index_assert(height = height, \n                               height_units = height_units, \n                               recycle = recycle,\n                               coll = coll)\n  \n  checkmate::reportAssertions(coll)\n  \n  part <- part[1]\n  \n  sprinkle_height_index(x = x, \n                        indices = indices, \n                        height = height, \n                        height_units = height_units, \n                        part = part)\n}\n\n#' @rdname sprinkle_height\n#' @export\n\nsprinkle_height.dust_list <- function(x, rows = NULL, cols = NULL, \n                                      height = NULL, height_units = NULL,\n                                      part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                                      fixed = FALSE, \n                                      recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                                      ...)\n{\n  structure(\n    lapply(X = x,\n           FUN = sprinkle_height.default,\n           rows = rows,\n           cols = cols,\n           height = height,\n           height_units = height_units,\n           part = part,\n           fixed = fixed,\n           recycle = recycle,\n           ...),\n    class = \"dust_list\"\n  )\n}\n\n# Unexported Utility ------------------------------------------------\n\n# These functions are to be used inside of the general `sprinkle` call\n# When used inside `sprinkle`, the indices are already determined, \n# the only the `height` and `height_units` arguments needs to be validated. \n# The assert function is kept separate so it may be called earlier\n# without attempting to perform the assignment.\n\nsprinkle_height_index_assert <- function(height = NULL, height_units = NULL, \n                                         recycle = \"none\", coll)\n{\n  if (!is.null(height))\n  {\n    checkmate::assert_numeric(x = height,\n                              add = coll,\n                              .var.name = \"height\")\n    \n    if (recycle == \"none\" && length(height) != 1)\n      coll$push(\"When `recycle` = 'none', height must have length 1.\")\n  }\n  \n  if (!is.null(height_units))\n  {\n    checkmate::assert_subset(x = height_units,\n                             choices = c(\"px\", \"pt\", \"in\", \"cm\", \"%\"),\n                             add = coll,\n                             .var.name = \"height_units\")\n    \n    if (recycle == \"none\")\n      height_units <- height_units[1]\n  }\n}\n\nsprinkle_height_index <- function(x, indices, height = NULL, height_units = NULL, part)\n{\n  if (!is.null(height))\n  {\n    x[[part]][[\"height\"]][indices] <- height\n  }\n  \n  if (!is.null(height_units))\n  {\n    x[[part]][[\"height_units\"]][indices] <- height_units\n  }\n  \n  x\n}"
  },
  {
    "path": "R/sprinkle_hhline.R",
    "content": "#' @name sprinkle_hhline\r\n#' @title Change the hhline Property in a Dust Table\r\n#' \r\n#' @description The \\code{hhline} property controls the appearance of \r\n#'   cell borders in LaTeX tables.  There is a known limitation in the \r\n#'   LaTeX \\code{colortbl} package where cell borders can be hidden if\r\n#'   the cell has a background color.  If using both cell borders and\r\n#'   background colors, it is recommended that you use the \\code{hhline}\r\n#'   property to make cell borders appear as desired.\r\n#'   \r\n#' @param x An object of class \\code{dust}\r\n#' @param hhline \\code{logical(1)}. When \\code{TRUE}, the LaTeX hhline package\r\n#'   will be used for cell borderes.\r\n#' @param ... Additional arguments to pass to other methods. Currently ignored.\r\n#' \r\n#' @details When \\code{hhline = TRUE}, borders will be solid; dashed and dotted\r\n#'   borders are unsupported by hhline.\r\n#' \r\n#' This property has no effect on non-LaTeX output.\r\n#'   \r\n#' @author Benjamin Nutter\r\n#' \r\n#' @source \\url{https://www.ctan.org/pkg/hhline?lang=en}\r\n#' \r\n#' @seealso \\code{\\link{dust}}, \\code{\\link{sprinkle}}\r\n#' \r\n#' @section Functional Requirements:\r\n#' \\enumerate{\r\n#'  \\item Change the \\code{hhline} attribute of the \\code{dust} object.\r\n#'  \\item Cast an error if \\code{x} is not a \\code{dust} object.\r\n#'  \\item Cast an error if \\code{hhline} is not logical and length 1.\r\n#' }\r\n#' \r\n#' @export\r\n\r\nsprinkle_hhline <- function(x, \r\n                            hhline = getOption(\"pixie_hhline\", FALSE), \r\n                            ...)\r\n{\r\n  UseMethod(\"sprinkle_hhline\")\r\n}\r\n\r\n#' @rdname sprinkle_hhline\r\n#' @export\r\n\r\nsprinkle_hhline.default <- function(x, \r\n                                    hhline = getOption(\"pixie_hhline\", FALSE), \r\n                                    ...)\r\n{\r\n  coll <- checkmate::makeAssertCollection()\r\n  \r\n  checkmate::assert_class(x = x,\r\n                          classes = \"dust\",\r\n                          add = coll)\r\n  \r\n  sprinkle_hhline_index_assert(hhline = hhline,\r\n                               coll = coll)\r\n  \r\n  checkmate::reportAssertions(coll)\r\n  \r\n  sprinkle_hhline_index(x = x,\r\n                        hhline = hhline)\r\n}\r\n\r\n#' @rdname sprinkle_hhline\r\n#' @export\r\n\r\nsprinkle_hhline.dust_list <- function(x, \r\n                                      hhline = getOption(\"pixie_hhline\", FALSE),\r\n                                      ...)\r\n{\r\n  structure(\r\n    lapply(x,\r\n           sprinkle_hhline.default,\r\n           hhline),\r\n    class = \"dust_list\"\r\n  )\r\n}\r\n\r\n# Unexported utilities ----------------------------------------------\r\n# These functions carry the the `_index` suffix for consistency with \r\n# the cell-valued sprinkles, but they don't actually require an \r\n# index, since they change table-valued sprinkles\r\n\r\nsprinkle_hhline_index_assert <- function(hhline = getOption(\"pixie_hhline\", FALSE),\r\n                                         coll)\r\n{\r\n  checkmate::assert_logical(x = hhline,\r\n                            len = 1,\r\n                            add = coll,\r\n                            .var.name = \"hhline\")\r\n}\r\n\r\n# indices argument is only present to avoid errors when the argument is passed \r\n# from sprinkle\r\nsprinkle_hhline_index <- function(x, hhline, indices = NULL, part = NULL)\r\n{\r\n  x[[\"hhline\"]] <- hhline\r\n  \r\n  x\r\n}"
  },
  {
    "path": "R/sprinkle_html_preserve.R",
    "content": "#' @name sprinkle_html_preserve\n#' @title Change the HTML Preserve Property in a Dust Table\n#' \n#' @description By default \\code{pixiedust} makes use of \\code{htmltools::htmlPreserve}\n#'   to prevent certain symbols from rendering in unintended ways based on some \n#'   not-very-well-understood-by-the-author issues.  This property controls whether\n#'   the preservation is used or not.\n#'   \n#' @param x An object of class \\code{dust}\n#' @param html_preserve \\code{logical(1)} indicating if the table is being produced\n#'   in a \\code{htmltools::htmlPreserve} environment.\n#' @param ... Additional arguments to pass to other methods. Currently ignored.\n#'   \n#' @author Benjamin Nutter\n#' \n#' @seealso \\code{\\link{dust}}, \\code{\\link{sprinkle}}, \\code{\\link[htmltools]{htmlPreserve}}\n#' \n#' @section Functional Requirements:\n#' \\enumerate{\n#'  \\item Change the \\code{html_preserve} attribute of the \\code{dust} object.\n#'  \\item Cast an error if \\code{x} is not a \\code{dust} object.\n#'  \\item Cast an error if \\code{html_preserve} is not logical(1).\n#' }\n#' \n#' @export\n\nsprinkle_html_preserve <- function(x, \n                                   html_preserve = getOption(\"pixie_html_preserve\", TRUE), \n                                   ...)\n{\n  UseMethod(\"sprinkle_html_preserve\")\n}\n\n#' @rdname sprinkle_html_preserve\n#' @export\n\nsprinkle_html_preserve.default <- function(x, \n                                           html_preserve = getOption(\"pixie_html_preserve\", TRUE),\n                                           ...)\n{\n  coll <- checkmate::makeAssertCollection()\n  \n  checkmate::assert_class(x = x,\n                          classes = \"dust\",\n                          add = coll)\n  \n  sprinkle_html_preserve_index_assert(html_preserve = html_preserve,\n                                      coll = coll)\n  \n  checkmate::reportAssertions(coll)\n\n  sprinkle_html_preserve_index(x = x,\n                               html_preserve = html_preserve)\n}\n\n#' @rdname sprinkle_html_preserve\n#' @export\n\nsprinkle_html_preserve.dust_list <- function(x, \n                                             html_preserve = getOption(\"pixie_html_preserve\", TRUE),\n                                             ...)\n{\n  structure(\n    lapply(x,\n           sprinkle_html_preserve.default,\n           html_preserve),\n    class = \"dust_list\"\n  )\n}\n\n# Unexported utilities ----------------------------------------------\n# These functions carry the the `_index` suffix for consistency with \n# the cell-valued sprinkles, but they don't actually require an \n# index, since they change table-valued sprinkles\n\nsprinkle_html_preserve_index_assert <- function(html_preserve = getOption(\"pixie_html_preserve\", TRUE),\n                                                coll)\n{\n  checkmate::assert_logical(x = html_preserve,\n                            len = 1,\n                            add = coll,\n                            .var.name = \"html_preserve\")\n}\n\nsprinkle_html_preserve_index <- function(x, html_preserve = getOption(\"pixie_html_preserve\", TRUE), \n                                         indices = NULL, part = NULL)\n{\n  x[[\"html_preserve\"]] <- html_preserve\n  \n  x\n}"
  },
  {
    "path": "R/sprinkle_justify.R",
    "content": "#' @name sprinkle_justify\r\n#' @title Change the Caption in a Dust Table\r\n#' \r\n#' @description The justification of the table determines the horizontal \r\n#'   placing of the table on the page.\r\n#'   \r\n#' @param x An object of class \\code{dust}\r\n#' @param justify \\code{character} string giving the justification of the \r\n#'   entire table on the page. May be any one of \\code{\"center\"},\r\n#'   \\code{\"left\"}, or \\code{\"right\"}.\r\n#' @param ... Additional arguments to pass to other methods. Currently ignored.\r\n#'\r\n#' @details For HTML tables, the values \\code{\"center\"}, \r\n#'   \\code{\"left\"},  and \\code{\"right\"} all justify the table as expected.\r\n#'   It is important to note, however, that \\code{\"left\"} and \\code{\"right\"} \r\n#'   will cause subsequent elements to be rendered next to the table, not \r\n#'   below it. To render the table with left alignment without this side \r\n#'   effect, use \\code{\"none\"}.\r\n#'   \r\n#'   In LaTeX output, both \\code{\"right\"} and \\code{\"left\"} justify \r\n#'   to the left. This may change in the future if I find a resolution.  Using\r\n#'   \\code{\"none\"} also results in left justification.\r\n#'   \r\n#' @author Benjamin Nutter\r\n#' \r\n#' @seealso \\code{\\link{dust}}, \\code{\\link{sprinkle}}\r\n#' \r\n#' @section Functional Requirements:\r\n#' \\enumerate{\r\n#'  \\item Change the \\code{justify} attribute of the \\code{dust} object.\r\n#'  \\item Cast an error if \\code{x} is not a \\code{dust} object.\r\n#'  \\item Cast an error if \\code{justify} is not one of \\code{\"center\"}, \r\n#'        \\code{\"none\"}, \\code{\"left\"}, or \\code{\"right\"}.\r\n#'  \\item Ignore capitalization of the \\code{justify} argument.\r\n#' }\r\n#' \r\n#' @export\r\n\r\nsprinkle_justify <- function(x, \r\n                             justify = getOption(\"pixie_justify\", \"center\"), \r\n                             ...)\r\n{\r\n  UseMethod(\"sprinkle_justify\")\r\n}\r\n\r\n#' @rdname sprinkle_justify\r\n#' @export\r\n\r\nsprinkle_justify.default <- function(x, \r\n                                     justify = getOption(\"pixie_justify\", \"center\"), \r\n                                     ...)\r\n{\r\n  coll <- checkmate::makeAssertCollection()\r\n  \r\n  checkmate::assert_class(x = x,\r\n                          classes = \"dust\",\r\n                          add = coll)\r\n  \r\n  justify <- \r\n    sprinkle_justify_index_assert(justify = justify,\r\n                                  coll = coll)\r\n  \r\n  checkmate::reportAssertions(coll)\r\n  \r\n  sprinkle_justify_index(x = x,\r\n                         justify = justify)\r\n}\r\n\r\n#' @rdname sprinkle_justify\r\n#' @export\r\n\r\nsprinkle_justify.dust_list <- function(x, \r\n                                       justify = getOption(\"pixie_justify\", \"center\"),\r\n                                       ...)\r\n{\r\n  structure(\r\n    lapply(x,\r\n           sprinkle_justify.default,\r\n           justify),\r\n    class = \"dust_list\"\r\n  )\r\n}\r\n\r\n# Unexported utilities ----------------------------------------------\r\n# These functions carry the the `_index` suffix for consistency with \r\n# the cell-valued sprinkles, but they don't actually require an \r\n# index, since they change table-valued sprinkles\r\n\r\nsprinkle_justify_index_assert <- function(justify = getOption(\"pixie_justify\", \"center\"), coll)\r\n{\r\n  checkmate::matchArg(x = tolower(justify),\r\n                      choices = c(\"center\", \"none\", \"left\", \"right\"),\r\n                      add = coll,\r\n                      .var.name = \"justify\")\r\n}\r\n\r\n# indices argument is only present to avoid errors when the argument is passed \r\n# from sprinkle\r\nsprinkle_justify_index <- function(x, justify, indices = NULL, part = NULL)\r\n{\r\n  x[[\"justify\"]] <- justify\r\n  \r\n  x\r\n}"
  },
  {
    "path": "R/sprinkle_label.R",
    "content": "#' @name sprinkle_label\r\n#' @title Change the Border Collapse Property in a Dust Table\r\n#' \r\n#' @description The \\code{label} property is used to make references to a \r\n#'   table.  Labels may be used in LaTeX documents, or in both LaTeX and \r\n#'   HTML documents when using \\code{bookdown}.\r\n#'   \r\n#' @param x An object of class \\code{dust}\r\n#' @param label \\code{character(1)} or \\code{NULL} for no label.\r\n#' @param ... Additional arguments to pass to other methods. Currently ignored.\r\n#' \r\n#' @details For details about using labels in LaTeX documents, see \r\n#' \\url{https://en.wikibooks.org/wiki/LaTeX/Labels_and_Cross-referencing}.\r\n#' \r\n#' For details about using labels in \\code{bookdown} documents, see\r\n#' \\url{https://bookdown.org/yihui/bookdown/tables.html}\r\n#'   \r\n#' @author Benjamin Nutter\r\n#' \r\n#' @source \\url{https://en.wikibooks.org/wiki/LaTeX/Labels_and_Cross-referencing}\r\n#' \r\n#' \\url{https://bookdown.org/yihui/bookdown/tables.html}\r\n#' \r\n#' @seealso \\code{\\link{dust}}, \\code{\\link{sprinkle}}\r\n#' \r\n#' @section Functional Requirements:\r\n#' \\enumerate{\r\n#'  \\item Change the \\code{label} attribute of the \\code{dust} object.\r\n#'  \\item Cast an error if \\code{x} is not a \\code{dust} object.\r\n#'  \\item Cast an error if \\code{label} is not a \\code{character(1)}.\r\n#' }\r\n#' \r\n#' @export\r\n\r\nsprinkle_label <- function(x, label = NULL, ...)\r\n{\r\n  UseMethod(\"sprinkle_label\")\r\n}\r\n\r\n#' @rdname sprinkle_label\r\n#' @export\r\n\r\nsprinkle_label.default <- function(x, label = NULL, ...)\r\n{\r\n  coll <- checkmate::makeAssertCollection()\r\n  \r\n  checkmate::assert_class(x = x,\r\n                          classes = \"dust\",\r\n                          add = coll)\r\n  \r\n  sprinkle_label_index_assert(label = label,\r\n                              coll = coll)\r\n  \r\n  checkmate::reportAssertions(coll)\r\n  \r\n  sprinkle_label_index(x = x,\r\n                       label = label)\r\n}\r\n\r\n#' @rdname sprinkle_label\r\n#' @export\r\n\r\nsprinkle_label.dust_list <- function(x, label = NULL, ...)\r\n{\r\n  warning(\"The same label will be applied to each table in this list. \",\r\n          \"This will likely result in problems with referncing tables. \",\r\n          \"Consider using `pixiemap` instead.\")\r\n  structure(\r\n    lapply(x,\r\n           sprinkle_label.default,\r\n           label),\r\n    class = \"dust_list\"\r\n  )\r\n}\r\n\r\n# Unexported utilities ----------------------------------------------\r\n# These functions carry the the `_index` suffix for consistency with \r\n# the cell-valued sprinkles, but they don't actually require an \r\n# index, since they change table-valued sprinkles\r\n\r\nsprinkle_label_index_assert <- function(label = NULL, coll)\r\n{\r\n  checkmate::assert_character(x = label,\r\n                              len = 1,\r\n                              add = coll,\r\n                              null.ok = TRUE,\r\n                              .var.name = \"label\")\r\n}\r\n\r\n# indices argument is only present to avoid errors when the argument is passed \r\n# from sprinkle\r\nsprinkle_label_index <- function(x, label, indices = NULL, part = NULL)\r\n{\r\n  x[[\"label\"]] <- label\r\n  \r\n  x\r\n}"
  },
  {
    "path": "R/sprinkle_longtable.R",
    "content": "#' @name sprinkle_longtable\r\n#' @title Change the Longtable Property in a Dust Table\r\n#' \r\n#' @description The LaTeX \\code{longtable} package allows for long tables\r\n#' to be broken into multiple parts to be displayed on separate pages. \r\n#' \\code{pixiedust} will mimic this behavior for other output types.\r\n#'   \r\n#' @param x An object of class \\code{dust}\r\n#' @param longtable Either a \\code{logical(1)} or an \\code{numeric(1)} \r\n#'   integer-like value.  See Details.\r\n#' @param ... Additional arguments to pass to other methods. Currently ignored.\r\n#'\r\n#' @details When \\code{longtable = TRUE}, LaTeX tables will be divided \r\n#'   according to the LaTeX document settings.  In other table outputs, the \r\n#'   default is to use 25 rows per table.\r\n#'   \r\n#'   When \\code{longtable} is an integer (or integer-like) value, the table \r\n#'   is divided into that many rows per section. This applies to all output.\r\n#'   \r\n#' @author Benjamin Nutter\r\n#' \r\n#' @seealso \\code{\\link{dust}}, \\code{\\link{sprinkle}}\r\n#' \r\n#' @section Functional Requirements:\r\n#' \\enumerate{\r\n#'  \\item Change the \\code{longtable} attribute of the \\code{dust} object.\r\n#'  \\item Cast an error if \\code{x} is not a \\code{dust} object.\r\n#'  \\item Cast an error if \\code{longtable} is logical and has length not equal \r\n#'    to 1.\r\n#'  \\item when \\code{longtable} is not logical, cast an error if \r\n#'    it is not-integerish and has length not equal to 1.\r\n#' }\r\n#' \r\n#' @export\r\n\r\nsprinkle_longtable <- function(x, \r\n                               longtable = getOption(\"pixie_longtable\", FALSE), \r\n                               ...)\r\n{\r\n  UseMethod(\"sprinkle_longtable\")\r\n}\r\n\r\n#' @rdname sprinkle_longtable\r\n#' @export\r\n\r\nsprinkle_longtable.default <- function(x, \r\n                                       longtable = getOption(\"pixie_longtable\", FALSE), \r\n                                       ...)\r\n{\r\n  coll <- checkmate::makeAssertCollection()\r\n  \r\n  checkmate::assert_class(x = x,\r\n                          classes = \"dust\",\r\n                          add = coll)\r\n  \r\n  sprinkle_longtable_index_assert(longtable = longtable,\r\n                                  coll = coll)\r\n  \r\n  checkmate::reportAssertions(coll)\r\n  \r\n  sprinkle_longtable_index(x = x,\r\n                           longtable = longtable)\r\n}\r\n\r\n#' @rdname sprinkle_longtable\r\n#' @export\r\n\r\nsprinkle_longtable.dust_list <- function(x, \r\n                                         longtable = getOption(\"pixie_longtable\", FALSE),\r\n                                         ...)\r\n{\r\n  structure(\r\n    lapply(x,\r\n           sprinkle_longtable.default,\r\n           longtable),\r\n    class = \"dust_list\"\r\n  )\r\n}\r\n\r\n# Unexported utilities ----------------------------------------------\r\n# These functions carry the the `_index` suffix for consistency with \r\n# the cell-valued sprinkles, but they don't actually require an \r\n# index, since they change table-valued sprinkles\r\n\r\nsprinkle_longtable_index_assert <- function(longtable = getOption(\"pixie_longtable\", FALSE), coll)\r\n{\r\n  if (is.logical(longtable))\r\n  {\r\n    checkmate::assert_logical(x = longtable,\r\n                              len = 1,\r\n                              add = coll,\r\n                              .var.name = \"longtable\")\r\n  }\r\n  else\r\n  {\r\n    checkmate::assert_integerish(x = longtable,\r\n                                 len = 1, \r\n                                 add = coll,\r\n                                 .var.name = \"longtable\")\r\n  }\r\n}\r\n\r\n# indices argument is only present to avoid errors when the argument is passed \r\n# from sprinkle\r\nsprinkle_longtable_index <- function(x, longtable, indices = NULL, part = NULL)\r\n{\r\n  x[[\"longtable\"]] <- longtable\r\n  \r\n  x\r\n}"
  },
  {
    "path": "R/sprinkle_merge.R",
    "content": "#' @name sprinkle_merge\n#' @title Sprinkle Table Cells to Merge\n#' \n#' @description Merging cells creates more space for values to be displayed\n#'   without disrupting the appearance of other cells in the same row or \n#'   column.  The downside is that the content from only one of the cells\n#'   in the merge range will be displayed.\n#'   \n#' @param x An object of class \\code{dust}\n#' @param rows Either a numeric vector of rows in the tabular object to be \n#'   modified or an object of class \\code{call}.  When a \\code{call}, \n#'   generated by \\code{quote(expression)}, the expression resolves to \n#'   a logical vector the same length as the number of rows in the table.\n#'   Sprinkles are applied to where the expression resolves to \\code{TRUE}.\n#' @param cols Either a numeric vector of columns in the tabular object to\n#'   be modified, or a character vector of column names. A mixture of \n#'   character and numeric indices is permissible.\n#' @param merge \\code{logical} Defaults to \\code{FALSE}, prompting no \n#'   merging action.\n#' @param merge_rowval The row position of the cell whose content will be\n#'   displayed.  Defaults to the minimum of \\code{rows}.\n#' @param merge_colval The column position of the cell whose content will \n#'   be displayed.  Deafults to the minimum of \\code{cols}.\n#' @param part A character string denoting which part of the table to modify.\n#' @param fixed \\code{logical(1)} indicating if the values in \\code{rows} \n#'   and \\code{cols} should be read as fixed coordinate pairs.  By default, \n#'   sprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \n#'   meaning that the arguments do not have to share the same length.  \n#'   When \\code{fixed = TRUE}, they must share the same length.\n#' @param recycle A \\code{character} one that determines how sprinkles are \n#'   managed when the sprinkle input doesn't match the length of the region\n#'   to be sprinkled.  By default, recycling is turned off.  Recycling \n#'   may be performed across rows first (left to right, top to bottom), \n#'   or down columns first (top to bottom, left to right).\n#' @param ... Additional arguments to pass to other methods. Currently ignored.\n#' \n#' @section Functional Requirements:\n#' \\enumerate{\n#'  \\item Correctly reassigns the appropriate elements of \\code{merge}, \n#'    \\code{merge_rowval} and \\code{merge_colval} columns in the table part.\n#'  \\item Casts an error if \\code{x} is not a \\code{dust} object.\n#'  \\item Casts an error if \\code{merge} is not a \\code{logical(1)}\n#'  \\item Casts an error if \\code{merge_rowval} is not a \\code{numeric(1)}\n#'  \\item Casts an error if \\code{merge_colval} is not a \\code{numeric(1)}\n#'  \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n#'    \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n#'  \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\n#'  \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\n#'    \\code{\"rows\"}, or \\code{\"cols\"}\n#' }\n#' \n#' The functional behavior of the \\code{fixed} and \\code{recycle} arguments \n#' is not tested for this function. It is tested and validated in the\n#' tests for \\code{\\link{index_to_sprinkle}}.\n#' \n#' @seealso \\code{\\link{sprinkle}}, \n#'   \\code{\\link{index_to_sprinkle}}\n#'\n#' @export\n\nsprinkle_merge <- function(x, rows = NULL, cols = NULL, \n                           merge = FALSE, \n                           merge_rowval = NULL, merge_colval = NULL,\n                           part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                           fixed = FALSE, \n                           recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                           ...)\n{\n  UseMethod(\"sprinkle_merge\")\n}\n\n#' @rdname sprinkle_merge\n#' @export\n\nsprinkle_merge.default <- function(x, rows = NULL, cols = NULL, \n                                   merge = FALSE, \n                                   merge_rowval = NULL, merge_colval = NULL,\n                                   part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                                   fixed = FALSE, \n                                   recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                                   ...)\n{\n  coll <- checkmate::makeAssertCollection()\n\n  sprinkle_merge_index_assert(merge = merge,\n                              merge_rowval = merge_rowval,\n                              merge_colval = merge_colval,\n                              coll = coll)\n\n  indices <- index_to_sprinkle(x = x, \n                               rows = rows, \n                               cols = cols, \n                               fixed = fixed,\n                               part = part,\n                               recycle = recycle,\n                               coll = coll)\n\n  checkmate::reportAssertions(coll)\n  \n  if (!merge)\n  {\n    return(x)\n  }\n  \n  # At this point, part should have passed the assertions in \n  # index_to_sprinkle. The first element is expected to be valid.\n  \n  part <- part[1]\n\n  sprinkle_merge_index(x = x, \n                      indices = indices, \n                      merge = merge,\n                      merge_rowval = merge_rowval,\n                      merge_colval = merge_colval,\n                      part = part)\n}\n\n#' @rdname sprinkle_merge\n#' @export\n\nsprinkle_merge.dust_list <- function(x, rows = NULL, cols = NULL,\n                                     merge = FALSE, \n                                     merge_rowval = NULL, merge_colval = NULL,\n                                     part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                                     fixed = FALSE, \n                                     recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                                     ...)\n{\n  structure(\n    lapply(X = x,\n           FUN = sprinkle_merge.default,\n           rows = rows,\n           cols = cols,\n           merge = merge,\n           merge_rowval = merge_rowval,\n           merge_colval = merge_colval,\n           part = part,\n           fixed = fixed,\n           recycle = recycle,\n           ...),\n    class = \"dust_list\"\n  )\n}\n\n# Unexported Utility ------------------------------------------------\n\n# These functions are to be used inside of the general `sprinkle` call\n# When used inside `sprinkle`, the indices are already determined, \n# the only the `halign` and `valign` arguments needs to be validated. \n# The assert function is kept separate so it may be called earlier\n# without attempting to perform the assignment.\n\nsprinkle_merge_index_assert <- function(merge = FALSE, \n                                        merge_rowval = NULL, merge_colval = NULL,\n                                        coll)\n{\n  checkmate::assert_logical(x = merge,\n                            len = 1,\n                            .var.name = \"merge\",\n                            add = coll)\n  \n  checkmate::assert_numeric(x = merge_rowval,\n                            len = 1,\n                            .var.name = \"merge_rowval\",\n                            null.ok = TRUE,\n                            add = coll)\n  \n  checkmate::assert_numeric(x = merge_colval,\n                            len = 1,\n                            .var.name = \"merge_colval\",\n                            null.ok = TRUE,\n                            add = coll)\n  \n  if (!merge[1] & (!is.null(merge_rowval[1]) || !is.null(merge_colval[1])))\n  {\n    message(\"merge = FALSE while merge_rowval or merge_colval has a value. \",\n            \"No action is performed\")\n  }\n}\n\nsprinkle_merge_index <- function(x, indices, \n                                 merge = FALSE, \n                                 merge_rowval = NULL, merge_colval = NULL,\n                                 part)\n{\n  if (!merge) return(x)\n  \n  # convert the index positions to a logical vector.\n  # This was necessary after fixing the recycling in #111\n  i <- logical(nrow(x[[part]]))\n  i[indices] <- TRUE\n  indices <- i\n  \n  x[[part]][[\"merge\"]][indices] <- TRUE\n  \n  #* If the display row and column aren't specified, choose the \n  #* minimum row or cell.\n  if (is.null(merge_rowval)) merge_rowval <- min(x[[part]][[\"row\"]][indices])\n  if (is.null(merge_colval)) merge_colval <- min(x[[part]][[\"col\"]][indices])\n  \n  #* Map the cells to the display cell\n  x[[part]][[\"html_row\"]][indices] <- as.integer(merge_rowval)\n  x[[part]][[\"html_col\"]][indices] <- as.integer(merge_colval)\n  \n  #* Set colspan and rowspan of non-display cells to 0.  This suppresses \n  #* them from display.\n  x[[part]][[\"rowspan\"]][indices] [x[[part]][[\"row\"]][indices] != merge_rowval] <- 0L\n  x[[part]][[\"colspan\"]][indices] [x[[part]][[\"col\"]][indices] != merge_colval] <- 0L\n  \n  #* Record the upper left most cell of the merged area.\n  #* This will be needed for HTML table to place the cell in the correct\n  #* location.\n  x[[part]][[\"html_row_pos\"]][indices] <- as.integer(min(x[[part]][[\"row\"]][indices]))\n  x[[part]][[\"html_col_pos\"]][indices] <- as.integer(min(x[[part]][[\"col\"]][indices]))\n  \n  #* Set the colspan and rowspan of the display cells.\n  x[[part]][[\"rowspan\"]][indices] [x[[part]][[\"row\"]][indices] == merge_rowval] <- \n    as.integer(\n      length(\n        unique(\n          x[[part]][[\"row\"]][indices]\n        )\n      )\n    )\n    \n  x[[part]][[\"colspan\"]][indices] [x[[part]][[\"col\"]][indices] == merge_colval] <- \n    as.integer(\n      length(\n        unique(\n          x[[part]][[\"col\"]][indices]\n        )\n      )\n    )\n\n  x\n}"
  },
  {
    "path": "R/sprinkle_na_string.R",
    "content": "#' @name sprinkle_na_string\n#' @title Sprinkle Appearance of NA's\n#' \n#' @description The appearance of \\code{NA} values in a table may be dependent\n#'   on the context.  \\code{pixiedust} uses the \\code{na_string} sprinkle\n#'   to guide the appearance of missing values in the table.\n#'   \n#' @param x An object of class \\code{dust}\n#' @param rows Either a numeric vector of rows in the tabular object to be \n#'   modified or an object of class \\code{call}.  When a \\code{call}, \n#'   generated by \\code{quote(expression)}, the expression resolves to \n#'   a logical vector the same length as the number of rows in the table.\n#'   Sprinkles are applied to where the expression resolves to \\code{TRUE}.\n#' @param cols Either a numeric vector of columns in the tabular object to\n#'   be modified, or a character vector of column names. A mixture of \n#'   character and numeric indices is permissible.\n#' @param na_string \\code{character(1)} A character string giving desired\n#'   replacement for \\code{NA} values in the selected cells.\n#' @param part A character string denoting which part of the table to modify.\n#' @param fixed \\code{logical(1)} indicating if the values in \\code{rows} \n#'   and \\code{cols} should be read as fixed coordinate pairs.  By default, \n#'   sprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \n#'   meaning that the arguments do not have to share the same length.  \n#'   When \\code{fixed = TRUE}, they must share the same length.\n#' @param recycle A \\code{character} one that determines how sprinkles are \n#'   managed when the sprinkle input doesn't match the length of the region\n#'   to be sprinkled.  By default, recycling is turned off.  Recycling \n#'   may be performed across rows first (left to right, top to bottom), \n#'   or down columns first (top to bottom, left to right).\n#' @param ... Additional arguments to pass to other methods. Currently ignored.\n#' \n#' @section Functional Requirements:\n#' \\enumerate{\n#'  \\item Correctly reassigns the appropriate elements \\code{na_string} column\n#'    in the table part.\n#'  \\item Casts an error if \\code{x} is not a \\code{dust} object.\n#'  \\item Casts an error if \\code{bg} is not a \\code{character(1)}\n#'  \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n#'    \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n#'  \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\n#'  \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\n#'    \\code{\"rows\"}, or \\code{\"cols\"}\n#'  \\item Cast an error if \\code{recycle = \"none\"} and \\code{na_string}\n#'    does not have length 1.\n#' }\n#' \n#' The functional behavior of the \\code{fixed} and \\code{recycle} arguments \n#' is not tested for this function. It is tested and validated in the\n#' tests for \\code{\\link{index_to_sprinkle}}.\n#' \n#' @seealso \\code{\\link{sprinkle}}, \n#'   \\code{\\link{index_to_sprinkle}}\n#'\n#' @export\n\nsprinkle_na_string <- function(x, rows = NULL, cols = NULL,\n                               na_string = getOption(\"pixie_na_string\", NA), \n                               part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                               fixed = FALSE, \n                               recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                               ...)\n{\n  UseMethod(\"sprinkle_na_string\")\n}\n\n#' @rdname sprinkle_na_string\n#' @export\n\nsprinkle_na_string.default <- function(x, rows = NULL, cols = NULL,\n                                       na_string = getOption(\"pixie_na_string\", NA), \n                                       part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                                       fixed = FALSE, \n                                       recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                                       ...)\n{\n  coll <- checkmate::makeAssertCollection()\n  \n  checkmate::assert_class(x = x,\n                          classes = \"dust\",\n                          add = coll)\n  \n  indices <- index_to_sprinkle(x = x, \n                               rows = rows, \n                               cols = cols, \n                               fixed = fixed,\n                               part = part,\n                               recycle = recycle,\n                               coll = coll)\n  \n  recycle <- recycle[1]\n  \n  sprinkle_na_string_index_assert(na_string = na_string, \n                                  recycle = recycle,\n                                  coll = coll)\n\n  checkmate::reportAssertions(coll)\n  \n  # At this point, part should have passed the assertions in \n  # index_to_sprinkle. The first element is expected to be valid.\n  \n  part <- part[1]\n  \n  sprinkle_na_string_index(x = x, \n                           indices = indices, \n                           na_string= na_string, \n                           part = part)\n}\n\n#' @rdname sprinkle_na_string\n#' @export\n\nsprinkle_na_string.dust_list <- function(x, rows = NULL, cols = NULL,\n                                         na_string = getOption(\"pixie_na_string\", NA), \n                                         part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                                         fixed = FALSE, \n                                         recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                                         ...)\n{\n  structure(\n    lapply(X = x,\n           FUN = sprinkle_na_string.default,\n           rows = rows,\n           cols = cols,\n           na_string = na_string,\n           part = part,\n           fixed = fixed,\n           recycle = recycle,\n           ...),\n    class = \"dust_list\"\n  )\n}\n\n# Unexported Utility ------------------------------------------------\n\n# These functions are to be used inside of the general `sprinkle` call\n# When used inside `sprinkle`, the indices are already determined, \n# the only the `na_string` argument needs to be validated. \n# The assert function is kept separate so it may be called earlier\n# without attempting to perform the assignment.\n\nsprinkle_na_string_index_assert <- function(na_string = getOption(\"pixie_na_string\", NA), \n                                            recycle = recycle,\n                                            coll)\n{\n  checkmate::assert_character(x = na_string,\n                              add = coll,\n                              .var.name = \"na_string\")\n  \n  if (recycle == \"none\" && length(na_string) != 1)\n    coll$push(\"When `recycle` = 'none', na_string must have length 1.\")\n}\n\nsprinkle_na_string_index <- function(x, indices, na_string, part)\n{\n  x[[part]][[\"na_string\"]][indices] <- na_string\n  \n  x\n}"
  },
  {
    "path": "R/sprinkle_pad.R",
    "content": "#' @name sprinkle_pad\n#' @title Sprinkle the Padding of a Cell\n#' \n#' @description Padding for HTML tables indicates how many pixels should\n#' be placed between the cell's content and the outside border.\n#'   \n#' @param x An object of class \\code{dust}\n#' @param rows Either a numeric vector of rows in the tabular object to be \n#'   modified or an object of class \\code{call}.  When a \\code{call}, \n#'   generated by \\code{quote(expression)}, the expression resolves to \n#'   a logical vector the same length as the number of rows in the table.\n#'   Sprinkles are applied to where the expression resolves to \\code{TRUE}.\n#' @param cols Either a numeric vector of columns in the tabular object to\n#'   be modified, or a character vector of column names. A mixture of \n#'   character and numeric indices is permissible.\n#' @param pad \\code{numeric(1)} A character string giving a color for the \n#'   background of the chosen cells.  \n#' @param part A character string denoting which part of the table to modify.\n#' @param fixed \\code{logical(1)} indicating if the values in \\code{rows} \n#'   and \\code{cols} should be read as fixed coordinate pairs.  By default, \n#'   sprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \n#'   meaning that the arguments do not have to share the same length.  \n#'   When \\code{fixed = TRUE}, they must share the same length.\n#' @param recycle A \\code{character} one that determines how sprinkles are \n#'   managed when the sprinkle input doesn't match the length of the region\n#'   to be sprinkled.  By default, recycling is turned off.  Recycling \n#'   may be performed across rows first (left to right, top to bottom), \n#'   or down columns first (top to bottom, left to right).\n#' @param ... Additional arguments to pass to other methods. Currently ignored.\n#'   \n#' @details Colors may be a dvips color name, or in the rgb(R, G, B), \n#' rgba(R, G, B, A), #RRGGBB, or #RRGGBBAA formats. \n#'   \n#' This sprinkle is ignored in console and markdown outputs.  HTML output\n#' will accept any of the color formats and recognize transparency.  LaTeX\n#' output will accept any of the color formats but ignore transparency.\n#' \n#' As long as \\code{pad} is required to be a \\code{numeric(1)}, the \n#' \\code{recycle} argument is kind of useless. It is included to maintain\n#' consistency with the \\code{index_to_sprinkle} function. Future development\n#' may permit a character vector of colors.\n#' \n#' @section Functional Requirements:\n#' \\enumerate{\n#'  \\item Correctly reassigns the appropriate elements \\code{pad} column\n#'    in the table part.\n#'  \\item Casts an error if \\code{x} is not a \\code{dust} object.\n#'  \\item Casts an error if \\code{pad} is not a \\code{numeric(1)}\n#'  \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n#'    \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n#'  \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\n#'  \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\n#'    \\code{\"rows\"}, or \\code{\"cols\"}\n#'  \\item Cast an error if \\code{recycle = \"none\"} and \\code{pad}\n#'    does not have length 1.\n#' }\n#' \n#' The functional behavior of the \\code{fixed} and \\code{recycle} arguments \n#' is not tested for this function. It is tested and validated in the\n#' tests for \\code{\\link{index_to_sprinkle}}.\n#' \n#' @seealso \\code{\\link{sprinkle}},\n#'   \\code{\\link{index_to_sprinkle}}\n#'   \n#' @author Benjamin Nutter\n#' \n#' @export\n\nsprinkle_pad <- function(x, rows = NULL, cols = NULL, pad = 0, \n                        part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                        fixed = FALSE, \n                        recycle = c(\"none\", \"rows\", \"cols\", \"columns\"), \n                        ...)\n{\n  UseMethod(\"sprinkle_pad\")\n}\n\n#' @rdname sprinkle_pad\n#' @export\n\nsprinkle_pad.default <- function(x, rows = NULL, cols = NULL, pad = 0, \n                                part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                                fixed = FALSE, \n                                recycle = c(\"none\", \"rows\", \"cols\", \"columns\"), \n                                ...)\n{\n  coll <- checkmate::makeAssertCollection()\n  \n  checkmate::assert_class(x = x,\n                          classes = \"dust\",\n                          add = coll)\n  \n  indices <- index_to_sprinkle(x = x, \n                               rows = rows, \n                               cols = cols, \n                               fixed = fixed,\n                               part = part,\n                               recycle = recycle,\n                               coll = coll)\n  \n  recycle <- recycle[1]\n  \n  sprinkle_pad_index_assert(pad = pad,\n                            recycle = recycle,\n                            coll = coll)\n  \n  checkmate::reportAssertions(coll)\n  \n  # At this point, part should have passed the assertions in \n  # index_to_sprinkle. The first element is expected to be valid.\n  \n  part <- part[1]\n  \n  sprinkle_pad_index(x = x, \n                     indices = indices, \n                     pad = pad, \n                     part = part)\n  \n}\n\n#' @rdname sprinkle_pad\n#' @export\n\nsprinkle_pad.dust_list <- function(x, rows = NULL, cols = NULL, pad = 0, \n                                  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                                  fixed = FALSE, \n                                  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"), \n                                  ...)\n{\n  structure(\n    lapply(X = x,\n           FUN = sprinkle_pad.default,\n           rows = rows,\n           cols = cols,\n           pad = pad,\n           part = part,\n           fixed = fixed,\n           recycle = recycle,\n           ...),\n    class = \"dust_list\"\n  )\n}\n\n# Unexported Utility ------------------------------------------------\n\n# These functions are to be used inside of the general `sprinkle` call\n# When used inside `sprinkle`, the indices are already determined, \n# the only the `pad` argument needs to be validated. \n# The assert function is kept separate so it may be called earlier\n# without attempting to perform the assignment.\n\nsprinkle_pad_index_assert <- function(pad = 0, recycle = recycle, coll)\n{\n  checkmate::assert_numeric(x = pad,\n                            add = coll,\n                            .var.name = \"pad\")\n  if (recycle == \"none\" && length(pad) != 1)\n    coll$push(\"When `recycle` = 'none', pad must have length 1.\")\n}\n\nsprinkle_pad_index <- function(x, indices, pad, part)\n{\n  x[[part]][[\"pad\"]][indices] <- pad\n  \n  x\n}"
  },
  {
    "path": "R/sprinkle_print_method.R",
    "content": "#' @rdname sprinkle\n#' @param print_method A character string giving the print method for the table. \n#'   Note: \\code{\"docx\"} is synonymous with \\code{\"markdown\"}.  \n#' @export\n\nsprinkle_print_method <- function(x, \n                                  print_method = c(\"console\", \"markdown\", \"html\", \"latex\"))\n{\n  UseMethod(\"sprinkle_print_method\")\n}\n\n#' @rdname sprinkle\n#' @export\n\nsprinkle_print_method.default <- function(x, \n                                          print_method = c(\"console\", \"markdown\", \n                                                           \"html\", \"latex\", \"docx\"))\n{\n  coll <- checkmate::makeAssertCollection()\n  \n  checkmate::assertClass(x, \n                         classes = \"dust\",\n                         add = coll)\n  \n  checkmate::assertSubset(print_method,\n                          c(\"console\", \"markdown\", \"html\", \"latex\", \"docx\"),\n                          add = coll)\n\n  checkmate::reportAssertions(coll)\n\n  x[[\"print_method\"]] <- print_method\n  x\n}\n\n#' @rdname sprinkle\n#' @export\n\nsprinkle_print_method.dust_list <- function(x, \n                                          print_method = c(\"console\", \"markdown\", \n                                                           \"html\", \"latex\"))\n{\n  structure(\n    lapply(X = x,\n           FUN = sprinkle_print_method,\n           print_method = print_method),\n    class = \"dust_list\"\n  )\n}\n"
  },
  {
    "path": "R/sprinkle_replace.R",
    "content": "#' @name sprinkle_replace\n#' @title Replace Contents of Selected Cells\n#' \n#' @description At times it may be necessary to replace the contents of a \n#' cell with user-supplied values.\n#'   \n#' @param x An object of class \\code{dust}\n#' @param rows Either a numeric vector of rows in the tabular object to be \n#'   modified or an object of class \\code{call}.  When a \\code{call}, \n#'   generated by \\code{quote(expression)}, the expression resolves to \n#'   a logical vector the same length as the number of rows in the table.\n#'   Sprinkles are applied to where the expression resolves to \\code{TRUE}.\n#' @param cols Either a numeric vector of columns in the tabular object to\n#'   be modified, or a character vector of column names. A mixture of \n#'   character and numeric indices is permissible.\n#' @param replace \\code{character} A character vector giving the desired\n#'   content for the selected cells.\n#' @param part A character string denoting which part of the table to modify.\n#' @param fixed \\code{logical(1)} indicating if the values in \\code{rows} \n#'   and \\code{cols} should be read as fixed coordinate pairs.  By default, \n#'   sprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \n#'   meaning that the arguments do not have to share the same length.  \n#'   When \\code{fixed = TRUE}, they must share the same length.\n#' @param recycle A \\code{character} one that determines how sprinkles are \n#'   managed when the sprinkle input doesn't match the length of the region\n#'   to be sprinkled.  By default, recycling is turned off.  Recycling \n#'   may be performed across rows first (left to right, top to bottom), \n#'   or down columns first (top to bottom, left to right).\n#' @param ... Additional arguments to pass to other methods. Currently ignored.\n#' \n#' @section Functional Requirements:\n#' \\enumerate{\n#'  \\item Correctly reassigns the appropriate elements \\code{replace} column\n#'    in the table part.\n#'  \\item Casts an error if \\code{x} is not a \\code{dust} object.\n#'  \\item Casts an error if \\code{replace} is not a vector\n#'  \\item Casts an warning if the number of indices to replace is not a \n#'    multiple of \\code{replace} \n#'  \\item Casts an error if \\code{length(replace)} is greater than the \n#'    number of cells to replace.\n#'  \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n#'    \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n#'  \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\n#'  \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\n#'    \\code{\"rows\"}, or \\code{\"cols\"}\n#' }\n#' \n#' The functional behavior of the \\code{fixed} and \\code{recycle} arguments \n#' is not tested for this function. It is tested and validated in the\n#' tests for \\code{\\link{index_to_sprinkle}}.\n#' \n#' @seealso \\code{\\link{sprinkle}}, \n#'   \\code{\\link{index_to_sprinkle}}\n#'\n#' @export\n\nsprinkle_replace <- function(x, rows = NULL, cols = NULL,\n                               replace, \n                               part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                               fixed = FALSE, \n                               recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                               ...)\n{\n  UseMethod(\"sprinkle_replace\")\n}\n\n#' @rdname sprinkle_replace\n#' @export\n\nsprinkle_replace.default <- function(x, rows = NULL, cols = NULL,\n                                       replace,\n                                       part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                                       fixed = FALSE, \n                                       recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                                       ...)\n{\n  coll <- checkmate::makeAssertCollection()\n  \n  checkmate::assert_class(x = x,\n                          classes = \"dust\",\n                          add = coll)\n  \n  indices <- index_to_sprinkle(x = x, \n                               rows = rows, \n                               cols = cols, \n                               fixed = fixed,\n                               part = part,\n                               recycle = recycle,\n                               coll = coll)\n  \n  sprinkle_replace_index_assert(replace = replace, \n                                indices = indices,\n                                coll = coll)\n  \n  checkmate::reportAssertions(coll)\n  \n  sprinkle_replace_index(x = x, \n                         indices = indices, \n                         replace = replace, \n                         part = part)\n}\n\n#' @rdname sprinkle_replace\n#' @export\n\nsprinkle_replace.dust_list <- function(x, rows = NULL, cols = NULL,\n                                         replace,\n                                         part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                                         fixed = FALSE, \n                                         recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                                         ...)\n{\n  structure(\n    lapply(X = x,\n           FUN = sprinkle_replace.default,\n           rows = rows,\n           cols = cols,\n           replace = replace,\n           part = part,\n           fixed = fixed,\n           recycle = recycle,\n           ...),\n    class = \"dust_list\"\n  )\n}\n\n# Unexported Utility ------------------------------------------------\n\n# These functions are to be used inside of the general `sprinkle` call\n# When used inside `sprinkle`, the indices are already determined, \n# the only the `replace` argument needs to be validated. \n# The assert function is kept separate so it may be called earlier\n# without attempting to perform the assignment.\n\nsprinkle_replace_index_assert <- function(replace, indices, coll)\n{\n  checkmate::assert_atomic_vector(x = replace,\n                                  max.len = length(indices),\n                                  add = coll,\n                                  .var.name = \"replace\")\n}\n\nsprinkle_replace_index <- function(x, indices, replace, part)\n{\n  if (length(replace) != 1 & (length(indices) %% length(replace)) != 0)\n  {\n    warning(\"The number of cells to edit is not a multiple of \",\n            \"length(replace). Values may not recycle as expected.\")\n    \n    replace <- rep(replace, length.out = length(indices))\n  }\n  \n  # At this point, part should have passed the assertions in \n  # index_to_sprinkle. The first element is expected to be valid.\n  \n  part <- part[1]\n  \n  x[[part]][[\"replace\"]][indices] <- replace\n  \n  x\n}"
  },
  {
    "path": "R/sprinkle_rotate_degree.R",
    "content": "#' @name sprinkle_rotate_degree\n#' @title Sprinkle Appearance of NA's\n#' \n#' @description The content of cells may be rotated when it is desired to save\n#' space (such as long table column names), or to draw attention to the \n#' cells.\n#'   \n#' @param x An object of class \\code{dust}\n#' @param rows Either a numeric vector of rows in the tabular object to be \n#'   modified or an object of class \\code{call}.  When a \\code{call}, \n#'   generated by \\code{quote(expression)}, the expression resolves to \n#'   a logical vector the same length as the number of rows in the table.\n#'   Sprinkles are applied to where the expression resolves to \\code{TRUE}.\n#' @param cols Either a numeric vector of columns in the tabular object to\n#'   be modified, or a character vector of column names. A mixture of \n#'   character and numeric indices is permissible.\n#' @param rotate_degree \\code{numeric(1)} Indicates how much to rotate the \n#'   cell text in degrees.\n#' @param part A character string denoting which part of the table to modify.\n#' @param fixed \\code{logical(1)} indicating if the values in \\code{rows} \n#'   and \\code{cols} should be read as fixed coordinate pairs.  By default, \n#'   sprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \n#'   meaning that the arguments do not have to share the same length.  \n#'   When \\code{fixed = TRUE}, they must share the same length.\n#' @param recycle A \\code{character} one that determines how sprinkles are \n#'   managed when the sprinkle input doesn't match the length of the region\n#'   to be sprinkled.  By default, recycling is turned off.  Recycling \n#'   may be performed across rows first (left to right, top to bottom), \n#'   or down columns first (top to bottom, left to right).\n#' @param ... Additional arguments to pass to other methods. Currently ignored.\n#' \n#' @section Functional Requirements:\n#' \\enumerate{\n#'  \\item Correctly reassigns the appropriate elements \\code{rotate_degree} column\n#'    in the table part.\n#'  \\item Casts an error if \\code{x} is not a \\code{dust} object.\n#'  \\item Casts an error if \\code{rotate_degree} is not a \\code{numeric(1)}\n#'  \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n#'    \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n#'  \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\n#'  \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\n#'    \\code{\"rows\"}, or \\code{\"cols\"}\n#'  \\item Cast an error if \\code{recycle = \"none\"} and \\code{rotate_degree}\n#'    does not have length 1.\n#' }\n#' \n#' The functional behavior of the \\code{fixed} and \\code{recycle} arguments \n#' is not tested for this function. It is tested and validated in the\n#' tests for \\code{\\link{index_to_sprinkle}}.\n#' \n#' @seealso \\code{\\link{sprinkle}}, \n#'   \\code{\\link{index_to_sprinkle}}\n#'\n#' @export\n\nsprinkle_rotate_degree <- function(x, rows = NULL, cols = NULL,\n                               rotate_degree = NULL, \n                               part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                               fixed = FALSE, \n                               recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                               ...)\n{\n  UseMethod(\"sprinkle_rotate_degree\")\n}\n\n#' @rdname sprinkle_rotate_degree\n#' @export\n\nsprinkle_rotate_degree.default <- function(x, rows = NULL, cols = NULL,\n                                       rotate_degree = NULL, \n                                       part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                                       fixed = FALSE, \n                                       recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                                       ...)\n{\n  coll <- checkmate::makeAssertCollection()\n  \n  indices <- index_to_sprinkle(x = x, \n                               rows = rows, \n                               cols = cols, \n                               fixed = fixed,\n                               part = part,\n                               recycle = recycle,\n                               coll = coll)\n  \n  recycle <- recycle[1]\n  \n  sprinkle_rotate_degree_index_assert(rotate_degree = rotate_degree, \n                                      recycle = recycle,\n                                      coll = coll)\n  \n  checkmate::reportAssertions(coll)\n  \n  # At this point, part should have passed the assertions in \n  # index_to_sprinkle. The first element is expected to be valid.\n  \n  part <- part[1]\n  \n  sprinkle_rotate_degree_index(x = x, \n                               indices = indices, \n                               rotate_degree = rotate_degree, \n                               part = part)\n}\n\n#' @rdname sprinkle_rotate_degree\n#' @export\n\nsprinkle_rotate_degree.dust_list <- function(x, rows = NULL, cols = NULL,\n                                         rotate_degree = NULL, \n                                         part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                                         fixed = FALSE, \n                                         recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                                         ...)\n{\n  structure(\n    lapply(X = x,\n           FUN = sprinkle_rotate_degree.default,\n           rows = rows,\n           cols = cols,\n           rotate_degree = rotate_degree,\n           part = part,\n           fixed = fixed,\n           recycle = recycle,\n           ...),\n    class = \"dust_list\"\n  )\n}\n\n# Unexported Utility ------------------------------------------------\n\n# These functions are to be used inside of the general `sprinkle` call\n# When used inside `sprinkle`, the indices are already determined, \n# the only the `rotate_degree` argument needs to be validated. \n# The assert function is kept separate so it may be called earlier\n# without attempting to perform the assignment.\n\nsprinkle_rotate_degree_index_assert <- function(rotate_degree = NULL, \n                                                recycle = \"none\",\n                                                coll)\n{\n  if (!is.null(rotate_degree))\n  {\n    checkmate::assert_numeric(x = rotate_degree,\n                              add = coll,\n                              .var.name = \"rotate_degree\")\n    \n    if (recycle == \"none\" && length(rotate_degree) != 1)\n      coll$push(\"When `recycle` = 'none', rotate_degree must have length 1.\")\n  }\n}\n\nsprinkle_rotate_degree_index <- function(x, indices, rotate_degree, part)\n{\n  x[[part]][[\"rotate_degree\"]][indices] <- rotate_degree\n  \n  x\n}"
  },
  {
    "path": "R/sprinkle_round.R",
    "content": "#' @name sprinkle_round\n#' @title Sprinkle Appearance of NA's\n#' \n#' @description The appearance of \\code{NA} values in a table may be dependent\n#'   on the context.  \\code{pixiedust} uses the \\code{round} sprinkle\n#'   to guide the appearance of missing values in the table.\n#'   \n#' @param x An object of class \\code{dust}\n#' @param rows Either a numeric vector of rows in the tabular object to be \n#'   modified or an object of class \\code{call}.  When a \\code{call}, \n#'   generated by \\code{quote(expression)}, the expression resolves to \n#'   a logical vector the same length as the number of rows in the table.\n#'   Sprinkles are applied to where the expression resolves to \\code{TRUE}.\n#' @param cols Either a numeric vector of columns in the tabular object to\n#'   be modified, or a character vector of column names. A mixture of \n#'   character and numeric indices is permissible.\n#' @param round \\code{numeric(1)} A value to pass to the \\code{digits}\n#'   argument of \\code{\\link{round}}.\n#' @param part A character string denoting which part of the table to modify.\n#' @param fixed \\code{logical(1)} indicating if the values in \\code{rows} \n#'   and \\code{cols} should be read as fixed coordinate pairs.  By default, \n#'   sprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \n#'   meaning that the arguments do not have to share the same length.  \n#'   When \\code{fixed = TRUE}, they must share the same length.\n#' @param recycle A \\code{character} one that determines how sprinkles are \n#'   managed when the sprinkle input doesn't match the length of the region\n#'   to be sprinkled.  By default, recycling is turned off.  Recycling \n#'   may be performed across rows first (left to right, top to bottom), \n#'   or down columns first (top to bottom, left to right).\n#' @param ... Additional arguments to pass to other methods. Currently ignored.\n#' \n#' @section Functional Requirements:\n#' \\enumerate{\n#'  \\item Correctly reassigns the appropriate elements \\code{round} column\n#'    in the table part.\n#'  \\item Casts an error if \\code{x} is not a \\code{dust} object.\n#'  \\item Casts an error if \\code{round} is not a \\code{numeric(1)}\n#'  \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n#'    \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n#'  \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\n#'  \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\n#'    \\code{\"rows\"}, or \\code{\"cols\"}\n#'  \\item Cast an error if \\code{recycle = \"none\"} and \\code{round}\n#'    does not have length 1.\n#' }\n#' \n#' The functional behavior of the \\code{fixed} and \\code{recycle} arguments \n#' is not tested for this function. It is tested and validated in the\n#' tests for \\code{\\link{index_to_sprinkle}}.\n#' \n#' @seealso \\code{\\link{sprinkle}}, \n#'   \\code{\\link{index_to_sprinkle}}\n#'\n#' @export\n\nsprinkle_round <- function(x, rows = NULL, cols = NULL,\n                               round = NULL, \n                               part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                               fixed = FALSE, \n                               recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                               ...)\n{\n  UseMethod(\"sprinkle_round\")\n}\n\n#' @rdname sprinkle_round\n#' @export\n\nsprinkle_round.default <- function(x, rows = NULL, cols = NULL,\n                                       round = NULL, \n                                       part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                                       fixed = FALSE, \n                                       recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                                       ...)\n{\n  coll <- checkmate::makeAssertCollection()\n  \n  checkmate::assert_class(x = x,\n                          classes = \"dust\",\n                          add = coll)\n  \n  indices <- index_to_sprinkle(x = x, \n                               rows = rows, \n                               cols = cols, \n                               fixed = fixed,\n                               part = part,\n                               recycle = recycle,\n                               coll = coll)\n  \n  recycle <- recycle[1]\n  \n  sprinkle_round_index_assert(round = round, \n                              recycle = recycle,\n                              coll = coll)\n  \n  checkmate::reportAssertions(coll)\n  \n  # At this point, part should have passed the assertions in \n  # index_to_sprinkle. The first element is expected to be valid.\n  \n  part <- part[1]\n  \n  sprinkle_round_index(x = x, \n                       indices = indices, \n                       round = round, \n                       part = part)\n}\n\n#' @rdname sprinkle_round\n#' @export\n\nsprinkle_round.dust_list <- function(x, rows = NULL, cols = NULL,\n                                         round = NULL, \n                                         part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                                         fixed = FALSE, \n                                         recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                                         ...)\n{\n  structure(\n    lapply(X = x,\n           FUN = sprinkle_round.default,\n           rows = rows,\n           cols = cols,\n           round = round,\n           part = part,\n           fixed = fixed,\n           recycle = recycle,\n           ...),\n    class = \"dust_list\"\n  )\n}\n\n# Unexported Utility ------------------------------------------------\n\n# These functions are to be used inside of the general `sprinkle` call\n# When used inside `sprinkle`, the indices are already determined, \n# the only the `round` argument needs to be validated. \n# The assert function is kept separate so it may be called earlier\n# without attempting to perform the assignment.\n\nsprinkle_round_index_assert <- function(round = NULL, \n                                        recycle = \"none\",\n                                        coll)\n{\n  if (!is.null(round))\n  {\n    checkmate::assert_integerish(x = round,\n                                 add = coll,\n                                 .var.name = \"round\")\n    \n    if (recycle == \"none\" && length(round) != 1)\n      coll$push(\"When `recycle` = 'none', round must have length 1.\")\n  }\n}\n\nsprinkle_round_index <- function(x, indices, round, part)\n{\n  x[[part]][[\"round\"]][indices] <- round\n  \n  x\n}"
  },
  {
    "path": "R/sprinkle_sanitize.R",
    "content": "#' @name sprinkle_sanitize\r\n#' @title Sanitize Characters for LaTeX Outputs\r\n#' \r\n#' @description Certain characters in LaTeX code need to be escaped to \r\n#'   prevent errors during processing.  For example, \\code{\\%} is the \r\n#'   comment character in LaTeX, and needs to be escaped in \r\n#'   order to render correctly.  \r\n#'   \r\n#' @param x An object of class \\code{dust}\r\n#' @param rows Either a numeric vector of rows in the tabular object to be \r\n#'   modified or an object of class \\code{call}.  When a \\code{call}, \r\n#'   generated by \\code{quote(expression)}, the expression resolves to \r\n#'   a logical vector the same length as the number of rows in the table.\r\n#'   Sprinkles are applied to where the expression resolves to \\code{TRUE}.\r\n#' @param cols Either a numeric vector of columns in the tabular object to\r\n#'   be modified, or a character vector of column names. A mixture of \r\n#'   character and numeric indices is permissible.\r\n#' @param sanitize \\code{logical(1)}. Should the code for the cell be sanitized.\r\n#' @param sanitize_args A list of arguments to pass to \r\n#'   \\code{Hmisc::latexTranslate}\r\n#' @param part A character string denoting which part of the table to modify.\r\n#' @param fixed \\code{logical(1)} indicating if the values in \\code{rows} \r\n#'   and \\code{cols} should be read as fixed coordinate pairs.  By default, \r\n#'   sprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \r\n#'   meaning that the arguments do not have to share the same length.  \r\n#'   When \\code{fixed = TRUE}, they must share the same length.\r\n#' @param recycle A \\code{character} one that determines how sprinkles are \r\n#'   managed when the sprinkle input doesn't match the length of the region\r\n#'   to be sprinkled.  By default, recycling is turned off.  Recycling \r\n#'   may be performed across rows first (left to right, top to bottom), \r\n#'   or down columns first (top to bottom, left to right).\r\n#' @param ... Additional arguments to pass to other methods. Currently ignored.\r\n#' \r\n#' @details This sprinkle is only recognized by LaTeX output.  See \r\n#'   \\code{\\link[Hmisc]{latexTranslate}} for more details.\r\n#'   \r\n#' @section Functional Requirements:\r\n#' \\enumerate{\r\n#'  \\item Correctly reassigns the appropriate elements of \\code{sanitize} \r\n#'    and \\code{sanitize_args} columns in the table part.\r\n#'  \\item Casts an error if \\code{x} is not a \\code{dust} object.\r\n#'  \\item Casts an error if \\code{sanitize} is not a \\code{logical(1)}\r\n#'  \\item Casts an error if \\code{sanitize_args} is not a \\code{list}\r\n#'  \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \r\n#'    \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\r\n#'  \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\r\n#'  \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\r\n#'    \\code{\"rows\"}, or \\code{\"cols\"}\r\n#' }\r\n#' \r\n#' The functional behavior of the \\code{fixed} and \\code{recycle} arguments \r\n#' is not tested for this function. It is tested and validated in the\r\n#' tests for \\code{\\link{index_to_sprinkle}}.\r\n#' \r\n#' @seealso \\code{\\link{sprinkle}}, \r\n#'   \\code{\\link{index_to_sprinkle}}\r\n#'   \r\n#' @export\r\n\r\nsprinkle_sanitize <- function(x, rows = NULL, cols = NULL, \r\n                           sanitize = NULL, sanitize_args = NULL,\r\n                           part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\r\n                           fixed = FALSE, \r\n                           recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\r\n                           ...)\r\n{\r\n  UseMethod(\"sprinkle_sanitize\")\r\n}\r\n\r\n#' @rdname sprinkle_sanitize\r\n#' @export\r\n\r\nsprinkle_sanitize.default <- function(x, rows = NULL, cols = NULL, \r\n                                sanitize = NULL, sanitize_args = NULL,\r\n                                part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\r\n                                fixed = FALSE, \r\n                                recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\r\n                                ...)\r\n{\r\n  coll <- checkmate::makeAssertCollection()\r\n  \r\n  checkmate::assert_class(x = x,\r\n                          classes = \"dust\",\r\n                          add = coll)\r\n  \r\n  sprinkle_sanitize_index_assert(sanitize = sanitize,\r\n                                 sanitize_args = sanitize_args, \r\n                                 coll = coll)\r\n  \r\n  indices <- index_to_sprinkle(x = x, \r\n                               rows = rows, \r\n                               cols = cols, \r\n                               fixed = fixed,\r\n                               part = part,\r\n                               recycle = recycle,\r\n                               coll = coll)\r\n  \r\n  checkmate::reportAssertions(coll)\r\n  \r\n  part <- part[1]\r\n  \r\n  sprinkle_sanitize_index(x = x, \r\n                          indices = indices, \r\n                          sanitize = sanitize, \r\n                          sanitize_args = sanitize_args, \r\n                          part = part)\r\n}\r\n\r\n#' @rdname sprinkle_sanitize\r\n#' @export\r\n\r\nsprinkle_sanitize.dust_list <- function(x, rows = NULL, cols = NULL, \r\n                                     sanitize = NULL, sanitize_args = NULL,\r\n                                     part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\r\n                                     fixed = FALSE, \r\n                                     recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\r\n                                     ...)\r\n{\r\n  structure(\r\n    lapply(X = x,\r\n           FUN = sprinkle_sanitize.default,\r\n           rows = rows,\r\n           cols = cols,\r\n           sanitize = sanitize,\r\n           sanitize_args = sanitize_args,\r\n           part = part,\r\n           fixed = fixed,\r\n           recycle = recycle,\r\n           ...),\r\n    class = \"dust_list\"\r\n  )\r\n}\r\n\r\n# Unexported Utility ------------------------------------------------\r\n\r\n# These functions are to be used inside of the general `sprinkle` call\r\n# When used inside `sprinkle`, the indices are already determined, \r\n# the only the `sanitize` and `sanitize_args` arguments needs to be validated. \r\n# The assert function is kept separate so it may be called earlier\r\n# without attempting to perform the assignment.\r\n\r\nsprinkle_sanitize_index_assert <- function(sanitize = NULL, \r\n                                           sanitize_args = NULL, \r\n                                           coll)\r\n{\r\n  if (!is.null(sanitize))\r\n  {\r\n    checkmate::assert_logical(x = sanitize,\r\n                              len = 1,\r\n                              add = coll,\r\n                              .var.name = \"sanitize\")\r\n  }\r\n  \r\n  if (!is.null(sanitize_args))\r\n  {\r\n    checkmate::assert_list(x = sanitize_args,\r\n                           add = coll,\r\n                           .var.name = \"sanitize_args\")\r\n  }\r\n}\r\n\r\nsprinkle_sanitize_index <- function(x, indices, sanitize = NULL, sanitize_args = NULL, part)\r\n{\r\n  if (!is.null(sanitize))\r\n  {\r\n    x[[part]][[\"sanitize\"]][indices] <- sanitize\r\n  }\r\n  \r\n  if (!is.null(sanitize_args))\r\n  {\r\n    x[[part]][[\"sanitize_args\"]][indices] <- \r\n      paste0(\r\n        deparse(sanitize_args),\r\n        collapse = \"\"\r\n      )\r\n  }\r\n  \r\n  x\r\n}"
  },
  {
    "path": "R/sprinkle_tabcolsep.R",
    "content": "#' @name sprinkle_tabcolsep\r\n#' @title Change the tabcolsep Property in a Dust Table\r\n#' \r\n#' @description The \\code{tabcolsep} property controls the space between \r\n#'   columns in LaTeX output.  By default, it is set to 6 pt.\r\n#'   \r\n#' @param x An object of class \\code{dust}\r\n#' @param tabcolsep \\code{numeric(1)}, integer-like value.\r\n#' @param ... Additional arguments to pass to other methods. Currently ignored.\r\n#'\r\n#' @details Reading on the details of \\code{tabcolsep} may be done by \r\n#'   searching \"latex tabcolsep\" on the internet.\r\n#' \r\n#' This property has no effect on non-LaTeX output.\r\n#'   \r\n#' @author Benjamin Nutter\r\n#' \r\n#' @source \\url{https://www.google.com/webhp?sourceid=chrome-instant&rlz=1C1CHBF_enUS706US706&ion=1&espv=2&ie=UTF-8#q=latex+tabcolsep&*}\r\n#' \r\n#' @seealso \\code{\\link{dust}}, \\code{\\link{sprinkle}}\r\n#' \r\n#' @section Functional Requirements:\r\n#' \\enumerate{\r\n#'  \\item Change the \\code{tabcolsep} attribute of the \\code{dust} object.\r\n#'  \\item Cast an error if \\code{x} is not a \\code{dust} object.\r\n#'  \\item Cast an error if \\code{tabcolsep} is not integerish and length 1.\r\n#' }\r\n#' \r\n#' @export\r\n\r\nsprinkle_tabcolsep <- function(x, \r\n                               tabcolsep = getOption(\"pixie_tabcolsep\", 6), \r\n                               ...)\r\n{\r\n  UseMethod(\"sprinkle_tabcolsep\")\r\n}\r\n\r\n#' @rdname sprinkle_tabcolsep\r\n#' @export\r\n\r\nsprinkle_tabcolsep.default <- function(x, \r\n                                       tabcolsep = getOption(\"pixie_tabcolsep\", 6), \r\n                                       ...)\r\n{\r\n  coll <- checkmate::makeAssertCollection()\r\n  \r\n  checkmate::assert_class(x = x,\r\n                          classes = \"dust\",\r\n                          add = coll)\r\n  \r\n  sprinkle_tabcolsep_index_assert(tabcolsep = tabcolsep, \r\n                                  coll = coll)\r\n  \r\n  checkmate::reportAssertions(coll)\r\n  \r\n  sprinkle_tabcolsep_index(x = x, \r\n                           tabcolsep = tabcolsep)\r\n}\r\n\r\n#' @rdname sprinkle_tabcolsep\r\n#' @export\r\n\r\nsprinkle_tabcolsep.dust_list <- function(x, \r\n                                         tabcolsep = getOption(\"pixie_tabcolsep\", 6),\r\n                                         ...)\r\n{\r\n  structure(\r\n    lapply(x,\r\n           sprinkle_tabcolsep.default,\r\n           tabcolsep),\r\n    class = \"dust_list\"\r\n  )\r\n}\r\n\r\n# Unexported utilities ----------------------------------------------\r\n# These functions carry the the `_index` suffix for consistency with \r\n# the cell-valued sprinkles, but they don't actually require an \r\n# index, since they change table-valued sprinkles\r\n\r\nsprinkle_tabcolsep_index_assert <- function(tabcolsep = getOption(\"pixie_tabcolsep\", 6),\r\n                                            coll)\r\n{\r\n  checkmate::assert_integerish(x = tabcolsep,\r\n                               len = 1,\r\n                               add = coll,\r\n                               .var.name = \"tabcolsep\")\r\n}\r\n\r\n# indices argument is only present to avoid errors when the argument is passed \r\n# from sprinkle\r\nsprinkle_tabcolsep_index <- function(x, tabcolsep, \r\n                                     indices = NULL, part = NULL)\r\n{\r\n  x[[\"tabcolsep\"]] <- tabcolsep\r\n  \r\n  x\r\n}"
  },
  {
    "path": "R/sprinkle_table.R",
    "content": "#' @rdname sprinkle\n#' @export\n\nsprinkle_table <- function(x, cols = NULL, ..., part = \"table\")\n{\n  UseMethod(\"sprinkle_table\")\n}\n\n#' @rdname sprinkle\n#' @export\n\nsprinkle_table.default <- function(x, cols=NULL, ..., \n                                   part = \"table\"){\n\n  part_names <- checkmate::matchArg(x = part, \n                                 choices = c(\"table\", \"body\", \"head\", \"foot\", \"interfoot\"),\n                                 several.ok = TRUE)\n\n  if (length(part_names) > 0)\n    if (any(part_names %in% \"table\")) part_names <- c(\"body\", \"head\", \"foot\", \"interfoot\")\n  \n  if (\"body\" %in% part_names) x <- sprinkle(x, cols = cols, ..., part = \"body\")\n  if (\"head\" %in% part_names) x <- sprinkle(x, cols = cols, ..., part = \"head\")\n  if (\"foot\" %in% part_names & !is.null(x$foot)) x <- sprinkle(x, cols = cols, ..., part = \"foot\")\n  if (\"interfoot\" %in% part_names & !is.null(x$interfoot)) \n    x <- sprinkle(x, cols=cols, ..., part = \"interfoot\")\n  \n  return(x)\n}\n\n#' @rdname sprinkle\n#' @export\n\nsprinkle_table.dust_list <- function(x, cols=NULL, ..., \n                                     part = \"table\")\n{\n  structure(\n    lapply(X = x,\n           FUN = sprinkle_table,\n           cols = cols,\n           part = part,\n           ...),\n    class = \"dust_list\"\n  )\n}\n"
  },
  {
    "path": "R/sprinkle_width.R",
    "content": "#' @name sprinkle_width\n#' @title Adjust Table Cell Width\n#' \n#' @description Customize the width of a cell in a table. This may be done\n#'   to improve the appearance of cells with long text.\n#'   \n#' @param x An object of class \\code{dust}\n#' @param rows Either a numeric vector of rows in the tabular object to be \n#'   modified or an object of class \\code{call}.  When a \\code{call}, \n#'   generated by \\code{quote(expression)}, the expression resolves to \n#'   a logical vector the same length as the number of rows in the table.\n#'   Sprinkles are applied to where the expression resolves to \\code{TRUE}.\n#' @param cols Either a numeric vector of columns in the tabular object to\n#'   be modified, or a character vector of column names. A mixture of \n#'   character and numeric indices is permissible.\n#' @param width \\code{numeric(1)}. Gives the width of the cell.\n#' @param width_units \\code{character(1)}. Gives the units for \\code{width}.\n#'   One of \\code{c(\"pt\", \"px\", \"cm\", \"in\", \"\\%\")}\n#' @param part A character string denoting which part of the table to modify.\n#' @param fixed \\code{logical(1)} indicating if the values in \\code{rows} \n#'   and \\code{cols} should be read as fixed coordinate pairs.  By default, \n#'   sprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \n#'   meaning that the arguments do not have to share the same length.  \n#'   When \\code{fixed = TRUE}, they must share the same length.\n#' @param recycle A \\code{character} one that determines how sprinkles are \n#'   managed when the sprinkle input doesn't match the length of the region\n#'   to be sprinkled.  By default, recycling is turned off.  Recycling \n#'   may be performed across rows first (left to right, top to bottom), \n#'   or down columns first (top to bottom, left to right).\n#' @param ... Additional arguments to pass to other methods. Currently ignored.\n#' \n#' @details This sprinkle is only recognized by HTML and LaTeX.  All of the \n#'   \\code{width_units} values are recognized by HTML.  For LaTeX, \\code{\"px\"}\n#'   is converted to \\code{\"pt\"}. \n#'   \n#' @section Functional Requirements:\n#' \\enumerate{\n#'  \\item Correctly reassigns the appropriate elements of \\code{width} \n#'    and \\code{width_units} columns in the table part.\n#'  \\item Casts an error if \\code{x} is not a \\code{dust} object.\n#'  \\item Casts an error if \\code{width} is not \\code{numeric}\n#'  \\item Casts an error if \\code{width_units} is not one of\n#'    \\code{c(\"px\", \"pt\", \"in\", \"cm\", \"\\%\")}.\n#'  \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n#'    \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n#'  \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\n#'  \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\n#'    \\code{\"rows\"}, or \\code{\"cols\"}\n#'  \\item Casts an error if \\code{recycle = \"none\"} and \\code{width} does\n#'    not have length 1.\n#'  \\item Correctly assigns values when \\code{recycle} is not \\code{\"none\"}\n#'    and multiple values are given.\n#'  \\item Quietly accepts only the first value in \\code{width_units} when\n#'    \\code{recycle = \"none\"}.\n#' }\n#' \n#' The functional behavior of the \\code{fixed} and \\code{recycle} arguments \n#' is not tested for this function. It is tested and validated in the\n#' tests for \\code{\\link{index_to_sprinkle}}.\n#' \n#' @seealso \\code{\\link{sprinkle}}, \n#'   \\code{\\link{index_to_sprinkle}}\n#'   \n#' @export\n\nsprinkle_width <- function(x, rows = NULL, cols = NULL, \n                            width = NULL, width_units = NULL,\n                            part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                            fixed = FALSE, \n                            recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                            ...)\n{\n  UseMethod(\"sprinkle_width\")\n}\n\n#' @rdname sprinkle_width\n#' @export\n\nsprinkle_width.default <- function(x, rows = NULL, cols = NULL, \n                                 width = NULL, width_units = NULL,\n                                 part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                                 fixed = FALSE, \n                                 recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                                 ...)\n{\n  coll <- checkmate::makeAssertCollection()\n\n  indices <- index_to_sprinkle(x = x, \n                               rows = rows, \n                               cols = cols, \n                               fixed = fixed,\n                               part = part,\n                               recycle = recycle,\n                               coll = coll)\n  \n  recycle <- recycle[1]\n  \n  width_units <- sprinkle_width_index_assert(width = width,\n                                             width_units = width_units, \n                                             recycle = recycle,\n                                             coll = coll)\n\n  checkmate::reportAssertions(coll)\n  \n  part <- part[1]\n  \n  sprinkle_width_index(x = x, \n                       indices = indices, \n                       width = width, \n                       width_units = width_units, \n                       part = part)\n}\n\n#' @rdname sprinkle_width\n#' @export\n\nsprinkle_width.dust_list <- function(x, rows = NULL, cols = NULL, \n                                      width = NULL, width_units = NULL,\n                                      part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n                                      fixed = FALSE, \n                                      recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n                                      ...)\n{\n  structure(\n    lapply(X = x,\n           FUN = sprinkle_width.default,\n           rows = rows,\n           cols = cols,\n           width = width,\n           width_units = width_units,\n           part = part,\n           fixed = fixed,\n           recycle = recycle,\n           ...),\n    class = \"dust_list\"\n  )\n}\n\n# Unexported Utility ------------------------------------------------\n\n# These functions are to be used inside of the general `sprinkle` call\n# When used inside `sprinkle`, the indices are already determined, \n# the only the `width` and `width_units` arguments needs to be validated. \n# The assert function is kept separate so it may be called earlier\n# without attempting to perform the assignment.\n\nsprinkle_width_index_assert <- function(width = NULL, width_units = NULL, recycle = \"none\", coll)\n{\n  if (!is.null(width))\n  {\n    checkmate::assert_numeric(x = width,\n                              add = coll,\n                              .var.name = \"width\")\n    \n    if (recycle == \"none\" && length(width) != 1)\n      coll$push(paste0(\"When `recycle = none`, `width` must have length 1\"))\n  }\n  \n  if (!is.null(width_units))\n  {\n    if (recycle == \"none\")\n    {\n      width_units <- width_units[1]\n    }\n\n    checkmate::assert_subset(x = width_units,\n                             choices = c(\"px\", \"pt\", \"in\", \"cm\", \"%\"),\n                             add = coll,\n                             .var.name = \"width_units\")\n  }\n  \n  width_units\n}\n\nsprinkle_width_index <- function(x, indices, width = \"\", width_units = \"\", part)\n{\n  if (!is.null(width))\n  {\n    x[[part]][[\"width\"]][indices] <- width\n  }\n  \n  if (!is.null(width_units))\n  {\n    x[[part]][[\"width_units\"]][indices] <- width_units\n  }\n  \n  x\n}"
  },
  {
    "path": "R/str_extract_base.R",
    "content": "#' @name str_extract_base\n#' @title Extract Patterns from Character Strings\n#' \n#' @description This is a utility function that follow the pattern of\n#'   \\code{stringr::str_extract_all}.  It is provided to avoid the \n#'   dependency on the \\code{stringr} package.\n#'   \n#' @param x \\code{character} vector.\n#' @param pattern \\code{character(1)} of the pattern to find in \\code{x}\n#' @param n The number of splits.\n#' \n#' @seealso \\code{stringr::str_extract_all}\n#' \n#' @source \n#' https://stackoverflow.com/a/27274231/1017276\n#' \n\nstr_extract_base <- function(x, pattern){\n  do.call(\"rbind\",\n          regmatches(x, gregexpr(pattern, x)))\n}\n\n#' @rdname str_extract_base\n\nstr_split_fixed_base <- function(x, pattern, n){\n  spl <- strsplit(x, pattern)\n  \n  spl <-\n    lapply(spl,\n           function(y) c(utils::head(y, n - 1),\n                         paste0(utils::tail(y, -(n - 1)), collapse = \" \")))\n  \n  do.call(\"rbind\", spl)\n}\n"
  },
  {
    "path": "R/tidy_levels_labels.R",
    "content": "#' @name tidy_levels_labels \n#' \n#' @title Term and Level Descriptions for \\code{pixiedust} Tables\n#' \n#' @description Default model objects identify rows of results with \n#'   appropriate term name.  More often than not, the term name is \n#'   not suitable for formally reported output.  \\code{tidy_levels_labels}\n#'   performs some basic work to quickly provide more readable \n#'   descriptors for cases where they can easily be obtained.  These\n#'   descriptors are retrieved from the data, however, so the \n#'   utility is determined by the user's habits in providing \n#'   term labels and meaningful factor levels.  \n#'   \n#'   Due to the complexity of the terms that could be used for a model,\n#'   it isn't practical to attempt to recover human-ready descriptors\n#'   for every conceivable term.  This would require recovering variable\n#'   names for any number of functions.  \\code{pixiedust} only \n#'   goes after the easiest to obtain. Replacements no managed by \n#'   \\code{tidy_levels_labels} may still be made with the \\code{replace}\n#'   sprinkle.\n#'   \n#' @param object A model object, ideally with a \\code{model.frame} method.\n#'   It is unclear at the moment (18 Sept. 2015) what will happen if\n#'   an object is passed that does not have a \\code{model.frame} method.\n#' @param descriptors A character vector indicating the descriptors to\n#'   be used in the table.  Acceptable inputs are \\code{\"term\"}, \n#'   \\code{\"term_plain\"}, \\code{\"label\"}, \\code{\"level\"}, and \n#'   \\code{\"level_detail\"}.  These may be used in any combination and\n#'   any order, with the descriptors appearing in the table from left\n#'   to right in the order given.  The default, \\code{\"term\"}, returns\n#'   only the term descriptor and is identical to the output provided\n#'   by \\code{broom::tidy} methods.  See Details for a full explanation\n#'   of each option and the Examples for sample output.\n#' @param numeric_level A character string that determines which descriptor\n#'   is used for numeric variables in the \\code{\"level_detail\"} descriptor\n#'   when a numeric has an interaction with a factor.  Acceptable inputs\n#'   are \\code{\"term\"}, \\code{\"term_plain\"}, and \\code{\"label\"}.\n#' @param argcheck An assert collection created by \\code{checkmate::makeAssertCollection}.\n#'   Under normal circumstances, this is passed from \\code{dust}.  If \\code{NULL},\n#'   as in the case it is run outside of \\code{dust}, a new collection is\n#'   created and the assertions are reported within \\code{tidy_levels_labels}.\n#'   \n#' @details The user may select up to five columns of descriptors, \n#'   although doing so would certainly create some ambiguity.  See\n#'   the Examples for sample output.\n#'   \\itemize{\n#'     \\item{\\code{\"term\"} }{The term name used in the R model summary}\n#'     \\item{\\code{\"term_plain\"} }{The term name used in the formula.\n#'       For variables that produce multiple term names (such as factors),\n#'       the plain term name may be duplicated.  For example, a factor that\n#'       has term names \\code{FctrB} and \\code{FctrC}, indicating rows for \n#'       levels \\code{B} and \\code{C} of the variable \\code{Fctr}, will \n#'       have two rows of \\code{\"term_plain\"} of just \\code{Fctr}.}\n#'     \\item{\\code{\"label\"} }{Provides the label attached to the data using\n#'       \\code{labelVector::get_label}.  When a term is not associated with a label, \n#'       the value of \\code{term_plain} is returned instead. Note that, variable names\n#'       will disassociate with a label if they are used in a function (such\n#'       as \\code{factor(x)} or \\code{x^2}.}\n#'     \\item{\\code{\"level\"} }{Indicates the level being compared within a factor \n#'       (or an interaction involving a factor), otherwise it returns \\code{NA}.\n#'       It may also be said that this value is the appendix to a factor name.  \n#'       For the term \\code{FctrB}, this would just be \\code{B}.}\n#'     \\item{\\code{\"level_detail\"} }{Gives additional information to \\code{level}\n#'       by including the reference level of the factor.  For the term \\code{FctrB},\n#'       this would return \\code{\"B vs A\"}.  When an interaction with a numeric\n#'       variable is present, the \\code{level} for the numeric may be either \n#'       \\code{term_plain} or \\code{label}, the choice being controlled by the\n#'       \\code{level_detail} argument.}\n#'   }\n#'   \n#' @section Restrictions:\n#' The descriptors, other than \\code{\"term\"}, generally don't make sense for data \n#' frame objects.  The use of \\code{tidy_levels_labels} is not permitted within\n#' the \\code{dust} function, but is allowed if you really want it by \n#' \\code{pixiedust:::tidy_levels_labels}.\n#' \n#' Other special cases noted in future uses will be documented here, but in \n#' general, if it isn't a model object, you probably don't really want to \n#' use this.\n#'       \n#' @author Benjamin Nutter\n#' \n#' @examples \n#' #* Descriptors for lm output with no interactions\n#' mtcars2 <- mtcars\n#' mtcars2$mpg <- labelVector::set_label(mtcars2$mpg, \"Gas Mileage\")\n#' mtcars2$qsec <-  labelVector::set_label(mtcars2$qsec, \"Quarter Mile Time\")\n#' mtcars2$am <-  labelVector::set_label(mtcars2$am, \"Transmission\")\n#' mtcars2$wt <-  labelVector::set_label(mtcars2$wt, \"Weight\")\n#' mtcars2$gear <-  labelVector::set_label(mtcars2$gear, \"Gears\")\n#' \n#' #* Basic Output for a model with no interactions\n#' #* Note: numeric_level has no impact as there are no\n#' #*       interactions involving numeric variables.\n#' \n#' fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars2)\n#' \n#' pixiedust:::tidy_levels_labels(fit, \n#'   descriptors = c(\"term\", \"term_plain\", \"label\", \"level\", \"level_detail\"),\n#'   numeric_level = \"term\") \n#'   \n#' #* Assign factors ahead of the model. This allows \n#' #* the user to determine the levels that display.\n#' #* Compare the output for 'am' with the output for 'gear'\n#' \n#' mtcars2$am <- factor(mtcars2$am, 0:1, c(\"Automatic\", \"Manual\"))\n#' mtcars2$am <-  labelVector::set_label(mtcars2$am, \"Transmission\") \n#'     # Label was lost in variable conversion\n#' fit <- lm(mpg ~ qsec + am + wt + factor(gear), data = mtcars2)\n#' pixiedust:::tidy_levels_labels(fit, \n#'   descriptors = c(\"term\", \"term_plain\", \"label\", \"level\", \"level_detail\"),\n#'   numeric_level = \"term\") \n#'   \n#'   \n#' #* Include an interaction between a factor and numeric.\n#' \n#' fit <- lm(mpg ~ qsec + am * wt + factor(gear), data = mtcars2)\n#' pixiedust:::tidy_levels_labels(fit, \n#'   descriptors = c(\"term\", \"term_plain\", \"label\", \"level\", \"level_detail\"),\n#'   numeric_level = \"term\") \n#'   \n#' #* Now observe how 'level' and 'level_detail' change \n#' #* in the interaction terms as we choose different \n#' #* values for 'numeric_level'\n#' \n#' pixiedust:::tidy_levels_labels(fit, \n#'   descriptors = c(\"term\", \"term_plain\", \"label\", \"level\", \"level_detail\"),\n#'   numeric_level = \"term_plain\")\n#'   \n#' pixiedust:::tidy_levels_labels(fit, \n#'   descriptors = c(\"term\", \"term_plain\", \"label\", \"level\", \"level_detail\"),\n#'   numeric_level = \"label\")  \n\ntidy_levels_labels <- function(object, \n                               descriptors = \"term\", \n                               numeric_level = c(\"term\", \"term_plain\", \"label\"),\n                               argcheck = NULL){\n  independent_check <- is.null(argcheck)\n  if (is.null(argcheck)) argcheck <- checkmate::makeAssertCollection()\n  \n  numeric_level <- checkmate::matchArg(x = numeric_level,\n                                    choices = c(\"term\", \"term_plain\", \"label\"),\n                                    add = argcheck)\n  \n  descriptors <- checkmate::matchArg(x = descriptors,\n                                  choices = c(\"term\", \"term_plain\", \"label\",\n                                              \"level\", \"level_detail\"),\n                                  several.ok = TRUE,\n                                  add = argcheck)\n\n  if (independent_check) checkmate::reportAssertions(argcheck)\n  \n  lnl <- levels_and_labels(object) %>%\n    level_label_interactions(as.data.frame(broom::tidy(object)), numeric_level)\n  \n  if (! \"term\" %in% descriptors)\n    lnl[, c(\"term\", descriptors), drop = FALSE]\n  else \n    lnl[, descriptors, drop = FALSE]\n}\n\nlevels_and_labels <- function(object, ...){\n  model_data <- stats::model.frame(object)\n  Labels <- labelVector::get_label(model_data, names(model_data))\n  NLevels <- vapply(model_data, modelNLevels, 1)\n  Levels <- \n    lapply(model_data, \n           modelFriendlyLevels) \n  Levels <- do.call(.rbind_internal, Levels) \n  \n  Levels$term_plain <- rep(names(NLevels), NLevels)\n  Levels$term <- paste0(Levels$term, Levels$level)\n  Levels$label <- Labels[match(Levels$term_plain, names(Labels))]\n\n  Levels <- Levels[, c(\"term\", \"term_plain\", \"label\", \"level\", \"level_detail\")]\n  rownames(Levels) <- NULL\n  Levels\n}\n\n\n\nmodelFriendlyLevels <- function(f){\n  lev <- levels(f)\n  if (is.null(lev))\n    return(data.frame(level = \"\",\n                      level_detail = \"\",\n                      stringsAsFactors = FALSE))\n  else \n    return(data.frame(level = lev[-1],\n                      level_detail = paste0(lev[-1], \" vs. \", lev[1]),\n                      stringsAsFactors = FALSE))\n}\n\nmodelNLevels <- function(f){\n  nlev <- nlevels(f)\n  nlev <- if (nlev == 0) 1 else (nlev-1)\n  nlev\n}\n\n\nlevel_label_interactions <- function(lnl, tidy_fit, numeric_level){\n  if (!any(grepl(\"[:]\", tidy_fit$term)))\n    return(lnl)\n  else{\n    inters <- which(grepl(\"[:]\", tidy_fit$term))\n    splits <- strsplit(tidy_fit$term[inters], \"[:]\")\n    inters <- lapply(splits, form_interaction_labels, lnl, numeric_level) \n    inters <- do.call(\".rbind_internal\", inters)\n\n    .rbind_internal(lnl, inters)\n  }\n}\n\n\nform_interaction_labels <- function(s, lnl, numeric_level){\n  m <- match(s, lnl$term)\n\n  level <- ifelse(lnl$level[m] == \"\",\n                  lnl[[numeric_level]][m],\n                  lnl$level[m])\n\n  level_detail <- ifelse(lnl$level_detail[m] == \"\",\n                         lnl[[numeric_level]][m],\n                         lnl$level_detail[m])\n\n  data.frame(term = paste0(lnl$term[m], collapse = \":\"),\n             term_plain = paste0(lnl$term_plain[m], collapse = \":\"),\n             label = paste0(lnl$label[m], collapse = \":\"),\n             level = paste0(level, collapse = \":\"),\n             level_detail = paste0(level_detail, collapse = \":\"),\n             stringsAsFactors = FALSE)\n}"
  },
  {
    "path": "R/zzz.R",
    "content": ".onLoad <- function(libname,pkgname)\n{\n  options(pixie_count = 0L)\n}\n\n.onUnload <- function(libPath)\n{\n  options(pixie_count = NULL)\n}\n"
  },
  {
    "path": "README.Rmd",
    "content": "---\noutput:\n  md_document:\n    variant: markdown_github\n---\n\n<!-- README.md is generated from README.Rmd. Please edit that file -->\n\n```{r, echo = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#>\",\n  fig.path = \"README-\"\n)\n```\n\n# pixiedust\nAfter tidying up your analyses with the `broom` package, go ahead and grab the `pixiedust`.  Customize your table output and write it to markdown, HTML, LaTeX, or even just the console.  `pixiedust` makes it easy to customize the appearance of your tables in all of these formats by adding any number of \"sprinkles\", much in the same way you can add layers to a `ggplot`.\n\n```{r}\nfit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\nlibrary(pixiedust)\ndust(fit) %>% \n  sprinkle(col = 2:4, round = 3) %>% \n  sprinkle(col = 5, fn = quote(pvalString(value))) %>% \n  sprinkle_colnames(term = \"Term\", \n                    estimate = \"Estimate\", \n                     std.error = \"SE\",\n                     statistic = \"T-statistic\", \n                     p.value = \"P-value\") %>%\n  sprinkle_print_method(\"console\")\n```\n\n### Customizing with Sprinkles\n\nTables can be customized by row, column, or even by a single cell by adding sprinkles to the `dust` object.  The table below shows the currently planned and implemented sprinkles.  In the \"implemented\" column, an 'x' indicates a customization that has been implemented, while a blank cell suggests that the customization is planned but has not yet been implemented.  In the remaining columns, an 'x' indicates that the sprinkle is already implemented for the output format; an 'o' indicates that implementation is planned but not yet completed; and a blank cell indicates that the sprinkle will not be implemented (usually because the output format doesn't support the option).\n\n```{r, echo=FALSE}\nSprinkles <- read.csv(\"inst/sprinkles.csv\",\n                        stringsAsFactors=FALSE)\nSprinkles[,-1] <- lapply(Sprinkles[-1], stringr::str_trim)\n\ndust(Sprinkles) %>%\n  sprinkle(cols=1, halign = \"left\") %>%\n  sprinkle(cols=2:6, halign = \"center\") %>%\n  sprinkle_print_method(\"markdown\")\n```\n\n### A Brief Example\n\nTo demonstrate, let's look at a simple linear model.  We build the model and generate the standard summary.  \n\n```{r}\nfit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n\nsummary(fit)\n```\n\nWhile the summary is informative and useful, it is full of \"stats-speak\" and isn't necessarily in a format that is suitable for publication or submission to a client.  The `broom` package provides the summary in tidy format that, serendipitously, it a lot closer to what we would want for formal reports.\n\n```{r}\nlibrary(broom)\ntidy(fit)\n```\n\nIt has been observed by some, however, that even this summary isn't quite ready for publication.  There are too many decimal places, the p-value employ scientific notation, and column titles like \"statistic\" don't specify what type of statistic.  These kinds of details aren't the purview of `broom`, however, as `broom` is focused on tidying the results of a model for further analysis (particularly with respect to comparing slightly varying models).\n\nThe `pixiedust` package diverts from `broom`'s mission here and provides the ability to customize the `broom` output for presentation.  The initial `dust` object returns a table that is similar to the `broom` output.  \n\n```{r}\nlibrary(pixiedust)\ndust(fit) %>%\n  sprinkle_print_method(\"console\")\n```\n\nWhere `pixiedust` shows its strength is the ease of which these tables can be customized.  The code below rounds the columns `estimate`, `std.error`, and `statistic` to three decimal places each, and then formats the `p.value` into a format that happens to be one that I like.\n\n```{r}\nx <- dust(fit) %>% \n  sprinkle(col = 2:4, round = 3) %>% \n  sprinkle(col = 5, fn = quote(pvalString(value))) %>%\n  sprinkle_print_method(\"console\")\nx\n```\n\nNow we're almost there!  Let's change up the column names, and while we're add it, let's add some \"bold\" markers to the statistically significant terms in order to make them stand out some (I say \"bold\" because the console output doesn't show up in bold, but with the markdown tags for bold text.  In a rendered table, the text would actually be rendered in bold).\n\n```{r}\nx <- x %>% \n  sprinkle(col = c(\"estimate\", \"p.value\"), \n           row = c(2, 4), \n           bold = TRUE) %>% \n  sprinkle_colnames(term = \"Term\", \n                estimate = \"Estimate\", \n                std.error = \"SE\",\n                statistic = \"T-statistic\", \n                p.value = \"P-value\") %>%\n  sprinkle_print_method(\"console\")\n\nx\n```\n\n## A cool, free tip!\n\nThe markdown output from `pixiedust` is somewhat limited due to the limitations of `Rmarkdown` itself.  If/when more features become available for `Rmarkdown` output, I'll be sure to include them.  But what can you do if you _really_ want all of the flexibility of the HTML tables but need the MS Word document?\n\nWith a little help from the `Gmisc` package, you can have the best of both worlds.  `Gmisc` isn't available on CRAN yet, but if you're willing to install it from GitHub, you can render a `docx` file.  Install `Gmisc` with \n\n`install.packages(\"Gmisc\")`\n\nThen use in your YAML header\n\n```\n---\noutput: Gmisc::docx_document\n---\n```\n\nWhen you knit your document, it knits as an HTML file, but I've had no problems with the rendering when I right-click the file and open with MS Word.\n\nRead more at http://gforge.se/2014/07/fast-track-publishing-using-rmarkdown/ (but note that this blog post was written about the `Grmd` package before it was moved into the `Gmisc` package).\n"
  },
  {
    "path": "README.md",
    "content": "<!-- README.md is generated from README.Rmd. Please edit that file -->\n\n# pixiedust\n\nAfter tidying up your analyses with the `broom` package, go ahead and\ngrab the `pixiedust`. Customize your table output and write it to\nmarkdown, HTML, LaTeX, or even just the console. `pixiedust` makes it\neasy to customize the appearance of your tables in all of these formats\nby adding any number of “sprinkles”, much in the same way you can add\nlayers to a `ggplot`.\n\n``` r\nfit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\nlibrary(pixiedust)\ndust(fit) %>% \n  sprinkle(col = 2:4, round = 3) %>% \n  sprinkle(col = 5, fn = quote(pvalString(value))) %>% \n  sprinkle_colnames(term = \"Term\", \n                    estimate = \"Estimate\", \n                     std.error = \"SE\",\n                     statistic = \"T-statistic\", \n                     p.value = \"P-value\") %>%\n  sprinkle_print_method(\"console\")\n#>            Term Estimate    SE T-statistic P-value\n#> 1   (Intercept)    9.365 8.373       1.118    0.27\n#> 2          qsec    1.245 0.383       3.252   0.003\n#> 3   factor(am)1    3.151 1.941       1.624    0.12\n#> 4            wt   -3.926 0.743      -5.286 < 0.001\n#> 5 factor(gear)4   -0.268 1.655      -0.162    0.87\n#> 6 factor(gear)5    -0.27 2.063      -0.131     0.9\n```\n\n### Customizing with Sprinkles\n\nTables can be customized by row, column, or even by a single cell by\nadding sprinkles to the `dust` object. The table below shows the\ncurrently planned and implemented sprinkles. In the “implemented”\ncolumn, an ‘x’ indicates a customization that has been implemented,\nwhile a blank cell suggests that the customization is planned but has\nnot yet been implemented. In the remaining columns, an ‘x’ indicates\nthat the sprinkle is already implemented for the output format; an ‘o’\nindicates that implementation is planned but not yet completed; and a\nblank cell indicates that the sprinkle will not be implemented (usually\nbecause the output format doesn’t support the option).\n\n| sprinkle         | implemented | console | markdown | html | latex |\n|:-----------------|:------------|:--------|:---------|:-----|:------|\n| bg               | x           |         |          | x    | x     |\n| bg_pattern       | x           |         |          | x    | x     |\n| bg_pattern_by    | x           |         |          | x    | x     |\n| bold             | x           | x       | x        | x    | x     |\n| bookdown         | x           |         |          |      | x     |\n| border_collapse  | x           |         |          | x    | x     |\n| border           | x           |         |          | x    | x     |\n| border_thickness | x           |         |          | x    | x     |\n| border_units     | x           |         |          | x    | x     |\n| border_style     | x           |         |          | x    | x     |\n| border_color     | x           |         |          | x    | x     |\n| caption          | x           | x       | x        | x    | x     |\n| colnames         | x           | x       | x        | x    | x     |\n| discrete         | x           |         |          | x    | x     |\n| discrete_colors  | x           |         |          | x    | x     |\n| float            | x           |         |          |      | x     |\n| fn               | x           | x       | x        | x    | x     |\n| font_color       | x           |         |          | x    | x     |\n| font_family      | x           |         |          | x    |       |\n| font_size        | x           |         |          | x    | x     |\n| font_size_units  | x           |         |          | x    | x     |\n| gradient         | x           |         |          | x    | x     |\n| gradient_colors  | x           |         |          | x    | x     |\n| gradient_cut     | x           |         |          | x    | x     |\n| gradient_n       | x           |         |          | x    | x     |\n| gradient_na      | x           |         |          | x    | x     |\n| halign           | x           |         |          | x    | x     |\n| height           | x           |         |          | x    | x     |\n| height_units     | x           |         |          | x    | x     |\n| hhline           | x           |         |          |      | x     |\n| italic           | x           | x       | x        | x    | x     |\n| justify          | x           |         |          | x    | x     |\n| label            | x           |         |          | x    | x     |\n| longtable        | x           | x       | x        | x    | x     |\n| merge            | x           | x       | x        | x    | x     |\n| na_string        | x           | x       | x        | x    | x     |\n| padding          | x           |         |          | x    |       |\n| replace          | x           | x       | x        | x    | x     |\n| round            | x           | x       | x        | x    | x     |\n| rotate_degree    | x           |         |          | x    | x     |\n| sanitize         |             |         |          |      | x     |\n| sanitize_args    |             |         |          |      | x     |\n| tabcolsep        |             |         |          |      | x     |\n| valign           | x           |         |          | x    | x     |\n| width            | x           |         |          | x    | x     |\n| width_units      | x           |         |          | x    | x     |\n\n### A Brief Example\n\nTo demonstrate, let’s look at a simple linear model. We build the model\nand generate the standard summary.\n\n``` r\nfit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n\nsummary(fit)\n#> \n#> Call:\n#> lm(formula = mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n#> \n#> Residuals:\n#>     Min      1Q  Median      3Q     Max \n#> -3.5064 -1.5220 -0.7517  1.3841  4.6345 \n#> \n#> Coefficients:\n#>               Estimate Std. Error t value Pr(>|t|)    \n#> (Intercept)     9.3650     8.3730   1.118  0.27359    \n#> qsec            1.2449     0.3828   3.252  0.00317 ** \n#> factor(am)1     3.1505     1.9405   1.624  0.11654    \n#> wt             -3.9263     0.7428  -5.286 1.58e-05 ***\n#> factor(gear)4  -0.2682     1.6555  -0.162  0.87257    \n#> factor(gear)5  -0.2697     2.0632  -0.131  0.89698    \n#> ---\n#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1\n#> \n#> Residual standard error: 2.55 on 26 degrees of freedom\n#> Multiple R-squared:  0.8498, Adjusted R-squared:  0.8209 \n#> F-statistic: 29.43 on 5 and 26 DF,  p-value: 6.379e-10\n```\n\nWhile the summary is informative and useful, it is full of “stats-speak”\nand isn’t necessarily in a format that is suitable for publication or\nsubmission to a client. The `broom` package provides the summary in tidy\nformat that, serendipitously, it a lot closer to what we would want for\nformal reports.\n\n``` r\nlibrary(broom)\ntidy(fit)\n#> # A tibble: 6 × 5\n#>   term          estimate std.error statistic   p.value\n#>   <chr>            <dbl>     <dbl>     <dbl>     <dbl>\n#> 1 (Intercept)      9.37      8.37      1.12  0.274    \n#> 2 qsec             1.24      0.383     3.25  0.00317  \n#> 3 factor(am)1      3.15      1.94      1.62  0.117    \n#> 4 wt              -3.93      0.743    -5.29  0.0000158\n#> 5 factor(gear)4   -0.268     1.66     -0.162 0.873    \n#> 6 factor(gear)5   -0.270     2.06     -0.131 0.897\n```\n\nIt has been observed by some, however, that even this summary isn’t\nquite ready for publication. There are too many decimal places, the\np-value employ scientific notation, and column titles like “statistic”\ndon’t specify what type of statistic. These kinds of details aren’t the\npurview of `broom`, however, as `broom` is focused on tidying the\nresults of a model for further analysis (particularly with respect to\ncomparing slightly varying models).\n\nThe `pixiedust` package diverts from `broom`’s mission here and provides\nthe ability to customize the `broom` output for presentation. The\ninitial `dust` object returns a table that is similar to the `broom`\noutput.\n\n``` r\nlibrary(pixiedust)\ndust(fit) %>%\n  sprinkle_print_method(\"console\")\n#>            term   estimate std.error  statistic   p.value\n#> 1   (Intercept)  9.3650443 8.3730161  1.1184792 0.2735903\n#> 2          qsec  1.2449212 0.3828479  3.2517387 0.0031681\n#> 3   factor(am)1  3.1505178 1.9405171  1.6235455 0.1165367\n#> 4            wt -3.9263022 0.7427562 -5.2861251  1.58e-05\n#> 5 factor(gear)4  -0.268163 1.6554617 -0.1619868 0.8725685\n#> 6 factor(gear)5 -0.2697468 2.0631829  -0.130743  0.896985\n```\n\nWhere `pixiedust` shows its strength is the ease of which these tables\ncan be customized. The code below rounds the columns `estimate`,\n`std.error`, and `statistic` to three decimal places each, and then\nformats the `p.value` into a format that happens to be one that I like.\n\n``` r\nx <- dust(fit) %>% \n  sprinkle(col = 2:4, round = 3) %>% \n  sprinkle(col = 5, fn = quote(pvalString(value))) %>%\n  sprinkle_print_method(\"console\")\nx\n#>            term estimate std.error statistic p.value\n#> 1   (Intercept)    9.365     8.373     1.118    0.27\n#> 2          qsec    1.245     0.383     3.252   0.003\n#> 3   factor(am)1    3.151     1.941     1.624    0.12\n#> 4            wt   -3.926     0.743    -5.286 < 0.001\n#> 5 factor(gear)4   -0.268     1.655    -0.162    0.87\n#> 6 factor(gear)5    -0.27     2.063    -0.131     0.9\n```\n\nNow we’re almost there! Let’s change up the column names, and while\nwe’re add it, let’s add some “bold” markers to the statistically\nsignificant terms in order to make them stand out some (I say “bold”\nbecause the console output doesn’t show up in bold, but with the\nmarkdown tags for bold text. In a rendered table, the text would\nactually be rendered in bold).\n\n``` r\nx <- x %>% \n  sprinkle(col = c(\"estimate\", \"p.value\"), \n           row = c(2, 4), \n           bold = TRUE) %>% \n  sprinkle_colnames(term = \"Term\", \n                estimate = \"Estimate\", \n                std.error = \"SE\",\n                statistic = \"T-statistic\", \n                p.value = \"P-value\") %>%\n  sprinkle_print_method(\"console\")\n\nx\n#>            Term   Estimate    SE T-statistic     P-value\n#> 1   (Intercept)    9.365   8.373       1.118      0.27  \n#> 2          qsec  **1.245** 0.383       3.252   **0.003**\n#> 3   factor(am)1    3.151   1.941       1.624      0.12  \n#> 4            wt **-3.926** 0.743      -5.286 **< 0.001**\n#> 5 factor(gear)4   -0.268   1.655      -0.162      0.87  \n#> 6 factor(gear)5    -0.27   2.063      -0.131       0.9\n```\n\n## A cool, free tip!\n\nThe markdown output from `pixiedust` is somewhat limited due to the\nlimitations of `Rmarkdown` itself. If/when more features become\navailable for `Rmarkdown` output, I’ll be sure to include them. But what\ncan you do if you *really* want all of the flexibility of the HTML\ntables but need the MS Word document?\n\nWith a little help from the `Gmisc` package, you can have the best of\nboth worlds. `Gmisc` isn’t available on CRAN yet, but if you’re willing\nto install it from GitHub, you can render a `docx` file. Install `Gmisc`\nwith\n\n`install.packages(\"Gmisc\")`\n\nThen use in your YAML header\n\n    ---\n    output: Gmisc::docx_document\n    ---\n\nWhen you knit your document, it knits as an HTML file, but I’ve had no\nproblems with the rendering when I right-click the file and open with MS\nWord.\n\nRead more at\n<http://gforge.se/2014/07/fast-track-publishing-using-rmarkdown/> (but\nnote that this blog post was written about the `Grmd` package before it\nwas moved into the `Gmisc` package).\n"
  },
  {
    "path": "cran-comments.md",
    "content": "## Test environments\n* local Windows install (R-4.3.1; Windows 10 build 19045)\n* win-builder (release R 4.3.1; 2023-06-16)\n* win-builder-devel (2023-10-08 r85282 ucrt)\n\n## R CMD check results\nThis update to `pixiedust` was requested by CRAN to update the package\noverview help file that is generated by roxygen. Links to test coverage and \nTravis-CI have been removed from the README, as I am no longer able to \nkeep up with those systems.\n\nThere were no warnings, errors, or notes returned by CHECK on any of the \ntest environments.\n\n\n## Downstream dependencies\nReverse dependency checks showed the following:\n\n`goldfish` shows no warnings, errors, or notes.\n\nThanks,\nBenjamin\n"
  },
  {
    "path": "inst/save_sprinkles_rda.R",
    "content": "SprinkleRef <- \n  read.csv(\"inst/sprinkle_reference.csv\",\n           stringsAsFactors = FALSE,\n           na = \"\")\n\nsave(SprinkleRef,\n     file = \"R/sysdata.rda\")\n"
  },
  {
    "path": "inst/sprinkle_documentation.csv",
    "content": "sprinkle,action_format,description\nbg,,\n,action,Modifies the background color of a cell.\n,default,\n,accepts,\"dvips color names; rgb(R,G,B); rgba(R,G,B,A); #RRGGBB; #RRGGBBAA\"\n,console,Not recognized\n,markdown,Not recognized\n,html,Accepts any of the listed formats; recognizes transparency\n,latex,\"Accepts any of the listed formats, but ignores transparency\"\nbg_pattern,,\n,action,Generates a pattern of background colors.  Can be used to make striping by rows or by columns.\n,default,\"c(\"\"#FFFFFF\"\", \"\"#DDDDDD\"\")\"\n,accepts,\"A vector of color names: dvips color names; rgb(R,G,B); rgba(R,G,B,A); #RRGGBB; #RRGGBBAA\"\n,console,Not recognized\n,markdown,Not recognized\n,html,Accepts any of the listed formats; recognizes transparency\n,latex,\"Accepts any of the listed formats, but ignores transparency\"\nbg_pattern_by,,\n,action,Determines if a `bg_pattern` is patterned by row or by columns.\n,default,\"\"\"rows\"\"\"\n,accepts,\"\"\"rows\"\", \"\"columns\"\", \"\"cols\"\"\"\n,console,Not recognized\n,markdown,Not recognized\n,html,Recognized\n,latex,Recognized\nbold,,\n,action,Renders text within a cell in bold.\n,default,FALSE\n,accepts,logical(1)\n,console,Recognized; rendered as double asterisks on either side fo the text\n,markdown,Recognized\n,html,Recognized\n,latex,Recognized\nborder_collapse,,\n,action,Sets the `border-collapse` property in an HTML table.  The property sets whether the table borders are collapsed into a single border or detached as in standard HTML.\n,default,TRUE\n,accepts,logical(1)\n,console,Not recognized\n,markdown,Not recognized\n,html,Recognized\n,latex,Not recognized\nborder,,\n,action,Sets a border on the specified side of a cell.\n,default,\n,accepts,\"Any combination of \"\"all\"\", \"\"bottom\"\", \"\"left\"\", \"\"top\"\", \"\"right\"\".  Using \"\"all\"\" results in all borders being drawn, regardless of what other values are passed with it.\"\n,console,Not recognized\n,markdown,Not recognized\n,html,Recognized\n,latex,Recognized\nborder_color,,\n,action,Sets the color of the borders specified for a cell.\n,default,\"\"\"Black\"\"\"\n,accepts,\"character(1); dvips color names; rgb(R,G,B); rgba(R,G,B,A); #RRGGBB; #RRGGBBAA\"\n,console,Not recognized\n,markdown,Not recognized\n,html,Recognized\n,latex,Recognized\nborder_style,,\n,action,Sets the border style for a specified cell\n,default,\"\"\"solid\"\"\"\n,accepts,\"character(1); \"\"solid\"\", \"\"dashed\"\", \"\"dotted\"\", \"\"double\"\", \"\"groove\"\", \"\"ridge\"\", \"\"inset\"\", \"\"outset\"\", \"\"hidden\"\", \"\"none\"\"\"\n,console,Not recognized\n,markdown,Not recognized\n,html,Accepts any of the values listed.\n,latex; hhline = FALSE,\"accepts \"\"solid\"\", \"\"dashed\"\", \"\"dotted\"\", \"\"hidden\"\", \"\"none\"\". \"\"dotted\"\" is silently changed to \"\"dashed\"\". \"\"hidden\"\" and \"\"none\"\" are equivalent.\"\n,latex; hhline = TRUE,\"accepts \"\"solid\"\", \"\"double\"\", \"\"hidden\"\", \"\"none\"\". \"\"hidden\"\" and \"\"none\"\" are equivalent.\"\nborder_thickness,,\n,action,Sets the thickness of the specified border\n,default,1\n,accepts,numeric(1)\n,console,Not recognized\n,markdown,Not recognized\n,html,Recognized\n,latex,Recognized\nborder_units,,\n,action,Sets the unit of measure for the specified border thickness\n,default,\"\"\"pt\"\"\"\n,accepts,\"\"\"pt\"\", \"\"px\"\"\"\n,console,Not recognized\n,markdown,Not recognized\n,html,Recognized\n,latex,\"Silently changes \"\"px\"\" to \"\"pt\"\"\"\ncaption,,\n,action,Adds or alters the `caption` property\n,default,\n,accepts,character(1)\n,console,Recognized\n,markdown,Recognized\n,html,Recognized\n,latex,Recognized\ndiscrete,,\n,action,Adds distinct background colors based on discrete values in the selected region. May not be used concurrently with bg. \"font\" is an alias for \"font_color\" and \"border\" is an alias for all borders.\n,default,\"bg\",\n,accepts,\"bg, font, font_color, border, left_border, top_border, right_border, bottom_border\"\n,console,Not recognized\n,markdown,Not recognized\n,html,Recognized\n,latex,Recognized\ndiscrete_color,,\n,action,\"Sets the color palette from which discrete selects background colors. If NULL, colors are automatically selected using the scales package.\"\n,default,\"getOption('pixiedust_discrete_pal', NULL)\"\n,accepts,character\n,console,Not recognized\n,markdown,Not recognized\n,html,Recognized\n,latex,Recognized\nfloat,,\n,action,Sets the `float` property\n,default,TRUE\n,accepts,logical(1)\n,console,Not recognized\n,markdown,Not recognized\n,html,Not recognized\n,latex,Recognized\nfn,,\n,action,\"Applies a function to the value of a cell. The function should be an expression that acts on the variable `value`.  For example, `quote(format(value, nsmall = 3))`\"\n,default,\n,accepts,call\n,console,Recognized\n,markdown,Recognized\n,html,Recognized\n,latex,Recognized\nfont_color,,\n,action,Sets the color of the cell text\n,default,Black\n,accepts,\"dvips color names; rgb(R,G,B); rgba(R,G,B,A); #RRGGBB; #RRGGBBAA\"\n,console,Not recognized\n,markdown,Not recognized\n,html,Recognized; transparency recognized\n,latex,Recognized; transparency ignored\nfont_family,,\n,action,Sets the font for the text\n,default,Times New Roman\n,accepts,character(1)\n,,http://www.w3schools.com/cssref/css_websafe_fonts.asp\n,console,Not recognized\n,markdown,Not recognized\n,html,Recognized\n,latex,Not recognized\nfont_size,,\n,action,Sets the size of the font in the cell\n,default,\n,accepts,numeric(1)\n,console,Not recognized\n,markdown,Not recognized\n,html,Recognized\n,latex,Recognized\nfont_size_units,,\n,action,Determines the units in which `font_size` is measured\n,default,\"\"\"px\"\"\"\n,accepts,\"\"\"px\"\", \"\"pt\"\", \"\"%\"\", \"\"%em\"\"\"\n,console,Not recognized\n,markdown,Not recognized\n,html,Recognized\n,latex,\"Only recognizes \"\"pt\"\" and \"\"em\"\".  All others are coerced to \"\"pt\"\"\"\nhalign,,\n,action,Sets the horizontal alignment of the text in the cell\n,default,\n,accepts,\"\"\"left\"\", \"\"center\"\", \"\"right\"\"\"\n,console,Not recognized\n,markdown,Recognized; numeric values will auto align to the right if no\n,,value given.\n,html,Recognized.  Does not currently employ auto alignment of\n,,\"numeric values, but this may change.\"\n,latex,Recognized; numeric values will auto align to the right if no\n,,value given.\ngradient,,\n,action,Adds distinct background colors based on progressively increasing values in the selected region. May not be used concurrently with bg. \"font\" is an alias for \"font_color\" and \"border\" is an alias for all borders.\n,default,\"bg\"\n,accepts,\"bg, font, font_color, border, left_border, top_border, right_border, bottom_border\"\n,console,Not recognized\n,markdown,Not recognized\n,html,Recognized\n,latex,Recognized\ngradient_colors,,\n,action,Provides the colors between which to shade gradients.\n,default,\"getOptions('pixiedust_gradient_pal', NULL)\"\n,accepts,character\n,console,Not recognized\n,markdown,Not recognized\n,html,Recognized\n,latex,Recognized\ngradient_cut,,\n,action,\"Determines the break points for the gradient shading. When NULL, equally spaced quantiles are used, the number of which is determined by gradient_n.\"\n,default,NULL\n,accepts,numeric vector\n,console,Not recognized\n,markdown,Not recognized\n,html,Recognized\n,latex,Recognized\ngradient_n,,\n,action,Determines the number of shades to use between the colors in gradient_colors.\n,default,10\n,accepts,numeric\n,console,Not recognized\n,markdown,Not recognized\n,html,Recognized\n,latex,Recognized\ngradient_na,,\n,action,Sets the color of NA values when gradients are shaded.\n,default,grey,\n,accepts,character\n,console,Not recognized\n,markdown,Not recognized\n,html,Recognized\n,latex,Recognized\nheight,,\n,action,Sets the height of the cell\n,default,\n,accepts,numeric(1)\n,console,Not recognized\n,markdown,Not recognized\n,html,Recognized\n,latex,Recognized\nheight_units,,\n,action,Determines the units in which `height` is measured\n,default,\"\"\"pt\"\"\"\n,accepts,\"\"\"px\"\", \"\"pt\"\", \"\"cm\"\", \"\"in\"\", \"\"%\"\"\"\n,console,Not recognized\n,markdown,Not recognized\n,html,Recognized\n,latex,\"Recognized; \"\"px\"\" is coerced to \"\"pt\"\"\"\nhhline,,\n,action,Toggles the option for cell border drawing with the `hhline`\n,,LaTeX package\n,default,FALSE\n,accepts,logical(1)\n,console,Not recognized\n,markdown,Not recognized\n,html,Not recognized\n,latex,\"Recognized.  When `FALSE` double borders are not available. When `TRUE`, colored and dashed borders are not available. This is usually the better option when using colored backgrounds in table cells.\"\nitalic,,\n,action,Renders the text in the cell in italic\n,default,FALSE\n,accepts,logical(1)\n,console,Recognized; rendered as an underscore on either side of the text.\n,markdown,Recognized\n,html,Recognized\n,latex,Recognized\njustify,,\n,action,Justifies the entire table on the page.\n,default,\"\"\"center\"\"\"\n,accepts,character(1)\n,console,Not recognized\n,markdown,Not recognized\n,html,Recognized\n,latex,\"Recognizes \"\"center\"\", but both \"\"left\"\" and \"\"right\"\" are rendered as left justified.  This may change if a satisfactory solution is found.  Usually, tables are best left centered.\"\nlongtable,,\n,action,\"Toggles the use of the LaTeX `longtable` style tables, namely allowing long tables to be broken into multiple sections. The table header appears at the top of each section. The table interfoot appears at the bottom of each section, except the last The table foot appears at the bottom of the last section. May accept either a logical or a numerical value.  If numerical each section will have the specified number of rows.\"\n,default,FALSE\n,accepts,logical(1); numeric(1)\n,console,\"Recognized; when `TRUE`, defaults to 25 rows per section.\"\n,markdown,\"Recognized; when `TRUE`, defaults to 25 rows per section.\"\n,html,\"Recognized; when `TRUE`, defaults to 25 rows per section.\"\n,latex,\"Recognized; when `TRUE`, `longtable`'s own algorithm will determine the number of rows per section.  When numeric, breaks are forced at the specified number of rows.\"\nmerge,,\n,action,\"Merges cells in the specified range into a single cell. In cases where either `merge_rowval` or `merge_colval` is specified, they will only be honored if `merge = TRUE`.  You must opt in to this action.\"\n,default,FALSE\n,accepts,logical(1)\n,console,Recognized\n,markdown,Recognized\n,html,Recognized\n,latex,Recognized\nmerge_rowval,,\n,action,Specifies the row value of the merged range to print in the table\n,default,minimum row value of the merged range\n,accepts,numeric(1)\n,console,Recognized\n,markdown,Recognized\n,html,Recognized\n,latex,Recognized\nmerge_colval,,\n,action,Specifies the column value of the merged range to print in the table\n,default,minimum col value of the merged range\n,accepts,numeric(1)\n,console,Recognized\n,markdown,Recognized\n,html,Recognized\n,latex,Recognized\nna_string,,\n,action,Designates the character string to use in place of missing values\n,default,NA\n,accepts,character(1)\n,console,Recognized\n,markdown,Recognized\n,html,Recognized\n,latex,Recognized\npad,,\n,action,Designates the padding to place between cell text and boundaries Measured in pixels.\n,default,0\n,accepts,numeric(1)\n,console,Not recognized\n,markdown,Not recognized\n,html,Recognized\n,latex,Not recognized\nreplace,,\n,action,Replaces existing cell values with user-specified content. Replacement occurs moving down columns from left to right.\n,default,\n,accepts,character vector of the same length as the number of cells being replaced.\n,console,Recognized\n,markdown,Recognized\n,html,Recognized\n,latex,Recognized\nrotate_degree,,\n,action,Rotates text in cells by the designated angle in degrees\n,default,\n,accepts,numeric(1)\n,console,Not recognized\n,markdown,Not recognized\n,html,Recognized\n,latex,Recognized\nround,,\n,action,Applies the `round` function to values in the cell.  Skips any character values it encounters.\n,default,\"`getOption(\"\"digits\"\")`\"\n,accepts,numeric(1)\n,console,Recognized\n,markdown,Recognized\n,html,Recognized\n,latex,Recognized\nsanitize,,\n,action,Sanitizes character values that may cause difficulties for the rendered format.  \n,default,FALSE\n,accepts,logical(1)\n,console,Not recognized\n,markdown,Not recognized\n,html,Not recognized\n,latex,Recognized.  Sanitization is performed using `Hmisc::latexTranslate`\nsanitize_args,action,Passes additional arguments to `Hmisc::latexTranslate`\n,default,list()\n,accepts,list.  See documentation for `Hmisc::latexTranslate` for details\n,console,Not recognized\n,markdown,Not recognized\n,html,Not recognized\n,latex,Recognized\ntabcolsep,,\n,action,\"Modifies the LaTeX `tabcolsep` parameter of tables. This is similar to `pad` for HTML tables, but only affects the space between columns. Measured in \"\"pt\"\"\"\n,default,6\n,accepts,numeric(1)\n,console,Not recognized\n,markdown,Not recognized\n,html,Not recognized\n,latex,Recognized\nvalign,,\n,action,Designates the vertical alignment of a cell.\n,default,\n,accepts,\"\"\"top\"\", \"\"middle\"\", \"\"bottom\"\"\"\n,console,Not recognized\n,markdown,Not recognized\n,html,Recognized\n,latex,Recognized\nwidth,,\n,action,Sets the width of the cell\n,default,\n,accepts,numeric(1)\n,console,Not recognized\n,markdown,Not recognized\n,html,Recognized\n,latex,Recognized\nwidth_units,,\n,action,Determines the units in which `width` is measured\n,default,\"\"\"pt\"\"\"\n,accepts,\"\"\"px\"\", \"\"pt\"\", \"\"cm\"\", \"\"in\"\", \"\"%\"\"\"\n,console,Not recognized\n,markdown,Not recognized\n,html,Recognized\n,latex,\"Recognized; \"\"px\"\" is coerced to \"\"pt\"\"\"\n"
  },
  {
    "path": "inst/sprinkle_reference.csv",
    "content": "sprinkle,group,assert_fn,class,arg_len,arg_classes,arg_choices,arg_several.ok,default\nbg,simple,assertCharacter,character,1,,,,\nbg_pattern,bg_pattern,assertCharacter,character,,,,,\"c(\"\"#FFFFFF\"\", \"\"#DDDDDD\"\")\"\nbg_pattern_by,bg_pattern,matchArg,character,,,\"c(\"\"rows\"\", \"\"cols\"\", \"\"columns\"\")\",,\nbold,simple,assertLogical,logical,1,,,,\nbookdown,option,assertLogical,logical,1,,,,\nborder,border,matchArg,character,,,\"c(\"\"all\"\", \"\"bottom\"\", \"\"left\"\", \"\"top\"\", \"\"right\"\")\",TRUE,all\nborder_thickness,border,assertNumeric,numeric,1,,,,1\nborder_units,border,matchArg,character,,,\"c(\"\"px\"\", \"\"pt\"\")\",,px\nborder_style,border,matchArg,character,,,\"c(\"\"solid\"\", \"\"dashed\"\", \"\"dotted\"\", \"\"double\"\", \"\"groove\"\", \"\"ridge\"\", \"\"inset\"\", \"\"outset\"\", \"\"hidden\"\", \"\"none\"\")\",,solid\nborder_color,border,assertCharacter,,1,,,,Black\nborder_collapse,option,assertLogical,,1,,,,\ncaption,option,assertCharacter,,1,,,,\ndiscrete,discrete,matchArg,character,,,\"c(\"\"bg\"\", \"\"font\"\", \"\"font_color\"\", \"\"border\"\", \"\"left_border\"\", \"\"top_border\"\", \"\"right_border\"\", \"\"bottom_border\"\")\",TRUE,bg\ndiscrete_colors,discrete,assertCharacter,,,,,,\"getOption(\"pixiedust_discrete_pal\", NULL)\"\nfloat,option,assertLogical,,1,,,,\nfn,simple,assertClass,,,call,,,\nfont_family,simple,assertCharacter,,1,,,,\nfont_color,simple,assertCharacter,,1,,,,\nfont_size,font_size,assertNumeric,,1,,,,\nfont_size_units,font_size,matchArg,,,,\"c(\"\"px\"\", \"\"pt\"\", \"\"%\"\", \"\"em\"\")\",,pt\ngradient,gradient,matchArg,character,,,\"c(\"\"bg\"\", \"\"font\"\", \"\"font_color\"\", \"\"border\"\", \"\"left_border\"\", \"\"top_border\"\", \"\"right_border\"\", \"\"bottom_border\"\")\",TRUE,bg\ngradient_colors,gradient,assertCharacter,,,,,,\"getOption(\"pixiedust_gradient_pal\", 10)\"\ngradient_cut,gradient,assertNumeric,,,,,,\ngradient_n,gradient,assertNumeric,,1,,,,10\ngradient_na,gradient,assertCharacter,,1,,,,\"grey\"\nhalign,simple,matchArg,,,,\"c(\"\"left\"\", \"\"center\"\", \"\"right\"\")\",,\nheight,height,assertNumeric,,1,,,,\nheight_units,height,matchArg,,,,\"c(\"\"px\"\", \"\"pt\"\", \"\"cm\"\", \"\"in\"\", \"\"%\"\")\",,pt\nhhline,option,assertLogical,,1,,,,\nitalic,simple,assertLogical,,1,,,,\njustify,option,matchArg,character,,,\"c(\"\"center\"\", \"\"left\"\", \"\"right\"\")\",,\"\"\"center\"\"\"\nlabel,option,assertCharacter,,1,,,,\nlongtable,option,assertLogical,,1,,,,\nmerge,merge,assertLogical,,1,,,,\nmerge_rowval,merge,assertNumeric,,1,,,,\nmerge_colval,merge,assertNumeric,,1,,,,\nna_string,simple,assertCharacter,,1,,,,\npad,simple,assertNumeric,,1,,,,\nreplace,simple,assertVector,,,,,,\nrotate_degree,simple,assertNumeric,,1,,,,\nround,simple,assertNumeric,,1,,,,\nsanitize,simple,assertLogical,,1,,,,\nsanitize_args,simple,assertClass,,,list,,,\ntabcolsep,option,assertNumeric,,1,,,,\nvalign,simple,matchArg,,,,\"c(\"\"top\"\", \"\"middle\"\", \"\"bottom\"\")\",,\nwidth,width,assertNumeric,,1,,,,\nwidth_units,width,matchArg,,,,\"c(\"\"px\"\", \"\"pt\"\", \"\"cm\"\", \"\"in\"\", \"\"%\"\")\",,pt\n"
  },
  {
    "path": "inst/sprinkles.csv",
    "content": "sprinkle,        implemented,console,markdown,html,latex\nbg,                         x,      ,        ,   x,    x\nbg_pattern,                 x,      ,        ,   x,    x\nbg_pattern_by,              x,      ,        ,   x,    x\nbold,                       x,     x,       x,   x,    x\nbookdown,                   x,      ,        ,    ,    x\nborder_collapse,            x,      ,        ,   x,    x\nborder,                     x,      ,        ,   x,    x\nborder_thickness,           x,      ,        ,   x,    x\nborder_units,               x,      ,        ,   x,    x\nborder_style,               x,      ,        ,   x,    x\nborder_color,               x,      ,        ,   x,    x\ncaption,                    x,     x,       x,   x,    x\ncolnames,                   x,     x,       x,   x,    x\ndiscrete,                   x,      ,        ,   x,    x\ndiscrete_colors,            x,      ,        ,   x,    x\nfloat,                      x,      ,        ,    ,    x\nfn,                         x,     x,       x,   x,    x\nfont_color,                 x,      ,        ,   x,    x\nfont_family,                x,      ,        ,   x,     \nfont_size,                  x,      ,        ,   x,    x\nfont_size_units,            x,      ,        ,   x,    x\ngradient,                   x,      ,        ,   x,    x\ngradient_colors,            x,      ,        ,   x,    x\ngradient_cut,               x,      ,        ,   x,    x\ngradient_n,                 x,      ,        ,   x,    x\ngradient_na,                x,      ,        ,   x,    x\nhalign,                     x,      ,        ,   x,    x \nheight,                     x,      ,        ,   x,    x\nheight_units,               x,      ,        ,   x,    x\nhhline,                     x,      ,        ,    ,    x\nitalic,                     x,     x,       x,   x,    x\njustify,                    x,      ,        ,   x,    x\nlabel,                      x,      ,        ,   x,    x\nlongtable,                  x,     x,       x,   x,    x\nmerge,                      x,     x,       x,   x,    x\nna_string,                  x,     x,       x,   x,    x\npadding,                    x,      ,        ,   x,     \nreplace,                    x,     x,       x,   x,    x\nround,                      x,     x,       x,   x,    x\nrotate_degree,              x,      ,        ,   x,    x\nsanitize,                    ,      ,        ,    ,    x\nsanitize_args,               ,      ,        ,    ,    x\ntabcolsep,                   ,      ,        ,    ,    x\nvalign,                     x,      ,        ,   x,    x\nwidth,                      x,      ,        ,   x,    x\nwidth_units,                x,      ,        ,   x,    x\n"
  },
  {
    "path": "man/as.data.frame.dust.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/as.data.frame.dust.R\n\\name{as.data.frame.dust}\n\\alias{as.data.frame.dust}\n\\alias{as.data.frame.dust_list}\n\\title{Convert \\code{dust} Object to Data Frame}\n\\usage{\n\\method{as.data.frame}{dust}(x, ..., sprinkled = TRUE)\n\n\\method{as.data.frame}{dust_list}(x, ...)\n}\n\\arguments{\n\\item{x}{A \\code{dust} object.}\n\n\\item{...}{Arguments to be passed to other methods.  Currently unused.}\n\n\\item{sprinkled}{Logical.  If \\code{TRUE}, the sprinkles attached to the\n\\code{dust} object are applied before returning the data frame. \nSprinkles are applied via the same mechanism that prints to the console,\nso only sprinkles that are applicable to console output are used.\nWhen \\code{FALSE}, \\code{pixiedust} attempts to reconstruct the \ndata frame (or tidied output from \\code{broom::tidy} \noriginally given to \\code{dust}.}\n}\n\\description{\nSprinkles are applied to the \\code{dust} object\n  as if it were being prepared for printing to the console.\n  However, instead of printing, the object is returned \n  as a single data frame.\n}\n\\details{\nIn its current state, this can be a fairly inefficient function\n  as the table, if the longtable option is in use, will be built in \n  a \\code{for} loop and bound together using \\code{rbind}.  This isn't \n  really intended for large tables, but may be of assistance when \n  there isn't a sprinkle that does what you want to do.  (You can \n  at least pull out the object as a data frame and do your own \n  post processing).\n}\n\\section{Functional Requirements}{\n \n\\enumerate{\n \\item Accepts an object of class \\code{dust} or \\code{dust_list}\n \\item Accepts a \\code{logical(1)} indicating if the sprinkles should\n   be applied to the data.\n \\item For a \\code{dust} object, returns an object of class \n   \\code{data.frame}\n \\item For a \\code{dust_list} object, returns a list of objects of class\n   \\code{data.frame}\n}\n}\n\n\\examples{\nfit <- lm(mpg ~ qsec + factor(am) + wt * factor(gear), data = mtcars)\nDust <- dust(fit) \\%>\\%\n  sprinkle(cols = 2:4, round = 2) \\%>\\%\n  sprinkle(cols = 5, fn = quote(pvalString(value))) \\%>\\%\n  sprinkle(cols = 3, font_color = \"#DA70D6\") \\%>\\%\n  sprinkle_print_method(\"html\")\n  \nas.data.frame(Dust)\n\n}\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "man/chain.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/chain.R\n\\name{\\%>\\%}\n\\alias{\\%>\\%}\n\\title{magrittr forward-pipe operator}\n\\usage{\nlhs \\%>\\% rhs\n}\n\\arguments{\n\\item{lhs, rhs}{A dataset and function to apply to it}\n}\n\\description{\nPipe an object forward into a function or call expression\n}\n"
  },
  {
    "path": "man/compoundAssignment.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/chain.R\n\\name{\\%<>\\%}\n\\alias{\\%<>\\%}\n\\title{Chain together multiple operations}\n\\usage{\nlhs \\%<>\\% rhs\n}\n\\arguments{\n\\item{lhs, rhs}{A data set and function to apply it to}\n}\n\\description{\nChain together multiple operations and save to the object\n  at the start of the chain.  See `magrittr` documentation for details.\n}\n"
  },
  {
    "path": "man/dust.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/dust.R, R/redust.R\n\\name{dust}\n\\alias{dust}\n\\alias{dust.default}\n\\alias{dust.grouped_df}\n\\alias{dust.list}\n\\alias{redust}\n\\alias{redust.default}\n\\alias{redust.dust_list}\n\\title{Dust Table Construction}\n\\usage{\ndust(object, ...)\n\n\\method{dust}{default}(\n  object,\n  ...,\n  tidy_df = FALSE,\n  keep_rownames = FALSE,\n  glance_foot = FALSE,\n  glance_stats = NULL,\n  col_pairs = 2,\n  byrow = FALSE,\n  descriptors = \"term\",\n  numeric_level = c(\"term\", \"term_plain\", \"label\"),\n  label = NULL,\n  caption = NULL,\n  caption_number = getOption(\"pixied_caption_number\", TRUE),\n  justify = getOption(\"pixie_justify\", \"center\"),\n  float = getOption(\"pixie_float\", TRUE),\n  longtable = getOption(\"pixie_longtable\", FALSE),\n  hhline = getOption(\"pixie_hhline\", FALSE),\n  bookdown = getOption(\"pixie_bookdown\", FALSE),\n  border_collapse = getOption(\"pixie_border_collapse\", \"collapse\"),\n  tabcolsep = getOption(\"pixie_tabcolsep\", 6),\n  fixed_header = getOption(\"pixie_fixed_header\", FALSE),\n  html_preserve = getOption(\"pixie_html_preserve\", TRUE)\n)\n\n\\method{dust}{grouped_df}(object, ungroup = TRUE, ...)\n\n\\method{dust}{list}(object, ...)\n\nredust(x, table, part = c(\"head\", \"foot\", \"interfoot\", \"body\"))\n\n\\method{redust}{default}(x, table, part = c(\"head\", \"foot\", \"interfoot\", \"body\"))\n\n\\method{redust}{dust_list}(x, table, part = c(\"head\", \"foot\", \"interfoot\", \"body\"))\n}\n\\arguments{\n\\item{object}{An object that has a \\code{tidy} method in \\code{broom}}\n\n\\item{...}{Additional arguments to pass to \\code{tidy}}\n\n\\item{tidy_df}{When \\code{object} is an object that inherits the \n\\code{data.frame} class, the default behavior is to assume that the \nobject itself is the basis of the table.  If the summarized table is \ndesired, set to \\code{TRUE}.}\n\n\\item{keep_rownames}{When \\code{tidy_df} is \\code{FALSE}, setting \n\\code{keep_rownames} binds the row names to the data frame as the first\ncolumn, allowing them to be preserved in the tabulated output.  This \nis only to data frame like objects, as the \\code{broom::tidy.matrix} method \nperforms this already.}\n\n\\item{glance_foot}{Arrange the glance statistics for the \\code{foot} of the\ntable. (Not scheduled for implementation until version 0.4.0)}\n\n\\item{glance_stats}{A character vector giving the names of the glance statistics\nto put in the output.  When \\code{NULL}, the default, all of the available \nstatistics are retrieved.  In addition to controlling which statistics are \nprinted, this also controls the order in which they are printed.}\n\n\\item{col_pairs}{An integer indicating the number of column-pairings for the \nglance output.  This must be less than half the total number of columns,\nas each column-pairing includes a statistic name and value. See the full\ndocumentation for the unexported function \\code{\\link{glance_foot}}.}\n\n\\item{byrow}{A logical, defaulting to \\code{FALSE}, that indicates if the \nrequested statistics are placed with priority to rows or columns.  \nSee the full documentation for the unexported function \\code{\\link{glance_foot}}.}\n\n\\item{descriptors}{A character vector indicating the descriptors to\nbe used in the table.  Acceptable inputs are \\code{\"term\"}, \n\\code{\"term_plain\"}, \\code{\"label\"}, \\code{\"level\"}, and \n\\code{\"level_detail\"}.  These may be used in any combination and\nany order, with the descriptors appearing in the table from left\nto right in the order given.  The default, \\code{\"term\"}, returns\nonly the term descriptor and is identical to the output provided\nby \\code{broom::tidy} methods.  See Details for a full explanation\nof each option and the Examples for sample output.\nSee the full documentation for the unexported function \\code{\\link{tidy_levels_labels}}.}\n\n\\item{numeric_level}{A character string that determines which descriptor\nis used for numeric variables in the \\code{\"level_detail\"} descriptor\nwhen a numeric has an interaction with a factor.  Acceptable inputs\nare \\code{\"term\"}, \\code{\"term_plain\"}, and \\code{\"label\"}.\nSee the full documentation for the unexported function \\code{\\link{tidy_levels_labels}}.}\n\n\\item{label}{\\code{character(1)}. An optional string for assigning labels with \nwhich tables can be referenced elsewhere in the document.  If \\code{NULL}, \n\\code{pixiedust} attempts to name the label \\code{tab:[chunk-name]}, where \n\\code{[chunk-name]} is the name of the \\code{knitr} chunk.  If this also\nresolves to \\code{NULL} (for instance, when you aren't using \\code{knitr}, \nthe label \\code{tab:pixie-[n]} is assigned, where \\code{[n]} is the current value \nof \\code{options()$pixie_count}.  Note that rendering multiple tables in a \nchunk without specifying a label will result in label conflicts.}\n\n\\item{caption}{A character string giving the caption for the table.}\n\n\\item{caption_number}{\\code{logical(1)}. Should the table caption be prefixed \nwith the table number?}\n\n\\item{justify}{\\code{character(1)}. Specifies the justification of the table on \nthe page.  May be \\code{\"center\"} (default), \\code{\"left\"}, or \\code{\"right\"}.}\n\n\\item{float}{A logical used only in LaTeX output.  When \\code{TRUE}, the table is \nset within a \\code{table} environment.  The default is \\code{TRUE}, as with \n\\code{xtable}.}\n\n\\item{longtable}{Allows the user to print a table in multiple sections.\nThis is useful when \na table has more rows than will fit on a printed page.  Acceptable inputs are \\code{FALSE},\nindicating that only one table is printed (default); \\code{TRUE} that the table should be \nsplit into multiple tables with the default number of rows per table (see \"Longtable\"); or a \npositive integer indicating how many rows per table to include. All other values are \ninterpreted as \\code{FALSE}.  In LaTeX output, remember that after each section, a page \nbreak is forced. This setting may also be set from \\code{sprinkle}.}\n\n\\item{hhline}{Logical.  When \\code{FALSE}, the default, horizontal LaTeX cell borders \nare drawn using the \\code{\\\\cline} command.  These don't necessarily \nplay well with cell backgrounds, however.  Using \\code{hhline = TRUE} \nprints horizontal borders using the \\code{\\\\hhline} command.  While the \n\\code{hhline} output isn't disrupted by cell backgrounds, it may require \nmore careful coding of the desired borders.  In \\code{hhline}, cells with \nadjoining borders tend to double up and look thicker than when using \n\\code{cline}.}\n\n\\item{bookdown}{Logical. When \\code{TRUE}, \\code{bookdown} style labels are\ngenerated.  Defaults to \\code{FALSE}.}\n\n\\item{border_collapse}{\\code{character(1)}. One of \\code{\"collapse\"}, \n\\code{\"separate\"}, \\code{\"initial\"}, or \\code{\"inherit\"}.}\n\n\\item{tabcolsep}{\\code{integerish(1)}. For LaTeX output, the distance in \n\\code{pt} between columns of the table.}\n\n\\item{fixed_header}{\\code{logical(1)}. For HTML tables, should the \nheader rows be fixed in place over a scrollable body.}\n\n\\item{html_preserve}{\\code{logical(1)}. When \\code{TRUE}, HTML output is returned\nwrapped in \\code{htmltools::htmlPreserve}. If using LaTeX style equations in \nan HTML table, it may be necessary to set this to \\code{FALSE}. Do this at\nyour own risk; this has not been thoroughly field tested.}\n\n\\item{ungroup}{Used when a \\code{grouped_df} object is passed to \\code{dust}.\nWhen \\code{TRUE} (the default), the object is ungrouped and dusted \nas a single table. When \\code{FALSE}, the object is split and each element\nis dusted separately.}\n\n\\item{x}{A dust object}\n\n\\item{table}{A data frame of similar dimensions of the part being replaced.}\n\n\\item{part}{The part of the table to replace with \\code{table}}\n}\n\\value{\nReturns an object of class \\code{dust}\n}\n\\description{\nDust tables consist of four primary components that are \n  built together to create a full table.  Namely, the \\code{head}, the \n  \\code{body}, the \\code{interfoot}, and the \\code{foot}.  Dust tables \n  also contain a table-wide attributes \\code{border_collapse} and \n  \\code{longtable} as well as a \\code{print_method} element.\n}\n\\details{\nThe \\code{head} object describes what each column of the table\n  represents.  By default, the head is a single row, but multi row headers\n  may be provided.  Note that multirow headers may not render in markdown\n  or console output as intended, though rendering in HTML and LaTeX is \n  fairly reliable. In longtables (tables broken over multiple pages), \n  the \\code{head} appears at the top of each table portion.\n  \n  The \\code{body} object gives the main body of information.  In long tables,\n  this section is broken into portions, ideally with one portion per page.\n  \n  The \\code{interfoot} object is an optional table to be placed at the \n  bottom of longtable portions with the exception of the last portion.  A \n  well designed \\code{interfoot} can convey to the user that the table \n  continues on the next page.\n  \n  The \\code{foot} object is the table that appears at the end of the \n  completed table.  For model objects, it is recommended that the \n  \\code{\\link[broom]{glance}} statistics be used to display model fit \n  statistics.\n  \n  The \\code{border_collapse} object applies to an entire HTML table.  It\n  indicates if the borders should form a single line or distinct lines.\n  \n  The \\code{longtable} object determines how many rows per page are printed.\n  By default, all content is printed as a single table.  Using the \n  \\code{longtable} argument in the \\code{\\link{sprinkle}} function can change this\n  setting.\n  \n  The \\code{table_width} element is specific to LaTeX tables.  This is a reference\n  value for when column widths are specified in terms of the \\code{\\%} units.  For\n  example, a column width of \\code{20\\%} will be defined as \\code{table_width * .20}.\n  The value in \\code{table_width} is assumed to be in inches and defaults to 6.\n  \n  The \\code{tabcolsep} object determines the spacing between columns in a \n  LaTeX table in pt.  By default, it is set at 6.\n  \n  The \\code{print_method} object determines how the table is rendered when \n  the \\code{print} method is invoked.  The default is to print to the \n  console.\n  \n  Many of these options may be set globally.  See \n  \\code{\\link{pixiedust}} for a complete list of package options.\n}\n\\section{Symbols and Greek Letters}{\n\nWhen using markdown, math symbols and greek letters may be employed as \nthey would within a markdown document.  For example, \\code{\"$\\alpha$\"}\nwill render as the lower case Greek alpha.  Math symbols may be rendered\nin the same manner.\n}\n\n\\examples{\nx <- dust(lm(mpg ~ qsec + factor(am), data = mtcars))\nx\n}\n\\seealso{\n\\code{\\link[broom]{tidy}} \\code{\\link{glance_foot}} \n  \\code{\\link{tidy_levels_labels}} \\code{\\link{pixiedust}}\n\n\\code{\\link{get_dust_part}} for extracting parts of the \\code{dust} object\nin order to build custom headers and/or footers.\n}\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "man/fixed_header_css.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/fixed_header_css.R\n\\name{fixed_header_css}\n\\alias{fixed_header_css}\n\\title{Generate CSS Code for Fixed Header Tables}\n\\source{\nJonas Schubert Erlandsson. https://jsfiddle.net/dPixie/byB9d/3/\n}\n\\usage{\nfixed_header_css(\n  fixed_header_class_name = \"pixie-fixed\",\n  scroll_body_height = 300,\n  scroll_body_height_units = \"px\",\n  scroll_body_background_color = \"white\",\n  fixed_header_height = 20,\n  fixed_header_height_units = \"px\",\n  fixed_header_text_height = fixed_header_height/2,\n  fixed_header_text_height_units = \"px\",\n  fixed_header_background_color = \"white\",\n  pretty = TRUE\n)\n}\n\\arguments{\n\\item{fixed_header_class_name}{\\code{character(1)}. When \n\\code{include_fixed_header_css = FALSE}, this\nclass name is used to reference CSS classes provided by the user to\nformat the table correctly.}\n\n\\item{scroll_body_height}{\\code{integerish(1)}. Sets the height of the scrollable\ntable body.}\n\n\\item{scroll_body_height_units}{\\code{character(1)}. Determines the units for the\nheight of the scrollable table.  Defaults to \\code{\"px\"}.  Must be one\nof \\code{c(\"px\", \"pt\", \"\\%\", \"em\")}.}\n\n\\item{scroll_body_background_color}{\\code{character(1)}. The color of the background\nof the body.  Must be a valid color.  It defaults to white, which may\noverride CSS settings provided by the user.  If this needs to be avoided,\nyou may use the \\code{\\link{fixed_header_css}} function to assist in\ngenerating CSS code to use to define the CSS. See Avoiding CSS Conflicts.}\n\n\\item{fixed_header_height}{\\code{integerish(1)}. Sets the height of the header\nrow.}\n\n\\item{fixed_header_height_units}{\\code{character(1)}. Determines the units for the\nheight of the header row. Defaults to \\code{\"px\"}. Must be one of\n\\code{c(\"px\", \"pt\", \"\\%\", \"em\")}.}\n\n\\item{fixed_header_text_height}{\\code{numeric(1)}. Sets the height at which the\nheader text appears.  By default it is set to half of the header height.\nThis should be approximately centered, but you may alter this to get the\nprecise look you want.}\n\n\\item{fixed_header_text_height_units}{\\code{character(1)}. Determines the units for\nplacing the header text.  Defaults to \\code{\"px\"}. Must be one of\n\\code{c(\"px\", \"pt\", \"\\%\", \"em\")}.}\n\n\\item{fixed_header_background_color}{\\code{character(1)}. Sets the background color for\nthe header row.  This defaults to white and may override the user's CSS\nsettings.  See Avoiding CSS Conflicts.}\n\n\\item{pretty}{\\code{logical(1)}. When \\code{TRUE}, the result is printed\nto the console using \\code{cat}, making it easy to copy and paste the\ncode to another document.  When \\code{FALSE}, it is returned as a\ncharacter string.}\n}\n\\description{\nTables with a fixed header may be generated to permit the \n  headings to remain visible with the data.  The CSS is not difficult, \n  but it not-trivial and requires some coordination across a few \n  parts.  This functions standardizes the generation of the CSS code \n  using as few elements as possible.  Note that there is potential for\n  conflicts with existing CSS in this method.\n}\n\\details{\nCSS doesn't make this kind of table natural.  The solution to \n  generate the fixed headers used by \\code{pixiedust} is probably not the \n  best solution in terms of CSS design.  It is, however, the most conducive \n  to generating dynamically on the fly. \n  \n  The fixed header table requires nesting several HTML elements. \n  \\enumerate{\n   \\item a \\code{div} tag is used to control the alignment of the table\n   \\item a \\code{section} tag is used to set up the header row that remains fixed.\n   \\item a \\code{div} that sets the height of the scrollable body\n   \\item the \\code{table} tag establishes the actual table.\n   \\item The \\code{th} tags inside the table are set to full transparency and\n     the content of the headers is duplicated in a \\code{div} within the \n     \\code{th} tag to display the content.\n  }\n  \n  To accomplish these tasks, some CSS is exported with the table and placed\n  in the document immediately before the table.  Read further to understand\n  the conflicts that may arise if you are using custom CSS specifications \n  in your documents.\n}\n\\section{Avoiding CSS Conflicts}{\n \nBecause of all of the shenanigans involved, exporting the CSS with the tables\nmay result in conflicts with your custom CSS. Most importantly, any CSS\nyou have applied to the \\code{th} or \\code{td} tags may be overwritten.\nIf you are using custom CSS, you may want to consider using \n\\code{include_fixed_header_css = FALSE} and then utilizing \n\\code{\\link{fixed_header_css}} to generate CSS you can include in your \nCSS file to provide the fixed headers.  The code generated by \n\\code{fixed_header_css} ought to be placed before your definitions for\n\\code{td} and \\code{th}.  \n\nTo get the same header design in the fixed table, you will want to modify \nthe \\code{.th-pixie-fixed div} definition in the CSS to match your desired\n\\code{th} definition.\n\nThe code produced by \\code{fixed_header_css} will include comments where\nthere is potential for a CSS conflict.\n}\n\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item If \\code{pretty = TRUE} print results to the console.\n \\item If \\code{pretty = FALSE} Return a character string of length 1.\n \\item Cast an error if \\code{scroll_body_height} is not \\code{integerish(1)}\n \\item Cast an error if \\code{scroll_body_height_units} is not \\code{character(1)}\n \\item Cast an error if \\code{scroll_body_background_color} is not \\code{character(1)}\n \\item Cast an error if \\code{scroll_body_background_color} is not a valid color.\n \\item Cast an error if \\code{fixed_header_height} is not \\code{integerish(1)}\n \\item Cast an error if \\code{fixed_header_height_units} is not \\code{character(1)}\n \\item Cast an error if \\code{fixed_header_text_height} is not \\code{numeric(1)}\n \\item Cast an error if \\code{fixed_header_text_height_units} is not \\code{character(1)}\n \\item Cast an error if \\code{fixed_header_background_color} is not \\code{character(1)}\n \\item Cast an error if \\code{fixed_header_background_color} is not a valid color.\n \\item Cast an error if \\code{pretty} is not \\code{logical(1)}\n}\n}\n\n"
  },
  {
    "path": "man/gaze.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/gaze.R\n\\name{gaze}\n\\alias{gaze}\n\\title{Mimic Stargazer Output to Display Multiple Models}\n\\usage{\ngaze(\n  ...,\n  include_glance = TRUE,\n  glance_vars = c(\"adj.r.squared\", \"sigma\", \"AIC\"),\n  digits = 3\n)\n}\n\\arguments{\n\\item{...}{models to be tidied.  Arguments may be named or unnamed.\nFor named arguments, the model will be identfied by the argument \nname; for unnamed arguments, the object name will be the identifier.}\n\n\\item{include_glance}{\\code{logical(1)} Determines if \\code{glance} (fit)\nstatistics are displayed under the models.}\n\n\\item{glance_vars}{\\code{character}. A vector of statistics returned by\n\\code{glance} that are to be displayed for each model. Defaults are \nsubject to change in future versions.}\n\n\\item{digits}{\\code{numeric(1)} The number of digits used for rounding.}\n}\n\\description{\nTidy multiple models and display coefficients and \n  test statistics in a side-by-side format.\n}\n\\details{\nThis function is still in development.  Significant stars \n  will be added in a future version. Note that function defaults may \n  be subject to change.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n  \\item Return a data frame object\n  \\item Cast an error if \\code{include_glance} is not \\code{logical(1)}\n  \\item Cast an error if \\code{glance_vars} is not a \\code{character} \n    vector.\n  \\item Cast an error if \\code{digits} is not \\code{\"integerish(1)\"}.\n}\n}\n\n\\examples{\nfit1 <- lm(mpg ~ qsec + am + wt + gear + factor(vs), data = mtcars)\nfit2 <- lm(mpg ~ am + wt + gear + factor(vs), data = mtcars)\n\ngaze(fit1, fit2)\ngaze(with_qsec = fit1, \n     without_qsec = fit2)\ngaze(fit1, fit2, include_glance = FALSE)\ngaze(fit1, fit2, glance_vars = c(\"AIC\", \"BIC\"))\n\n}\n"
  },
  {
    "path": "man/get_dust_part.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/get_dust_part.R\n\\name{get_dust_part}\n\\alias{get_dust_part}\n\\title{Get a Portion of the Table Stored in a \\code{dust} Object}\n\\usage{\nget_dust_part(x, part = c(\"head\", \"foot\", \"interfoot\", \"body\"))\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{part}{\\code{character(1)}, naming the part of the table to \nretrieve.  May be one of \\code{\"head\"}, \\code{\"foot\"}, \\code{\"interfoot\"},\nor \\code{\"body\"}.}\n}\n\\value{\nan object of class \\code{data.frame}\n}\n\\description{\nMaking customized table headers and footers requires a\n  data frame be added to the \\code{dust} object that has the same\n  column dimension as the rest of the table.  In order to reduce the \n  inconvenience of counting columns, \\code{get_dust_part} extracts the \n  data frame portion currently in use.  This ensures the column dimension\n  is correct with the current values, and provides an object suitable\n  for editing.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n  \\item Return, as a data frame, the part of the table requested in \\code{part}\n  \\item Cast an error if \\code{x} is not a \\code{dust} object.\n  \\item Cast an error if \\code{part} is not one of \\code{c(\"head\", \"foot\",\n    \"interfoot\", \"body\")}\n}\n}\n\n"
  },
  {
    "path": "man/glance_foot.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/glance_foot.R\n\\name{glance_foot}\n\\alias{glance_foot}\n\\title{Prepare Glance Statistics for \\code{pixiedust} Table Footer}\n\\usage{\nglance_foot(fit, col_pairs, total_cols, glance_stats = NULL, byrow = FALSE)\n}\n\\arguments{\n\\item{fit}{A model object with a \\code{broom::glance} method.}\n\n\\item{col_pairs}{An integer indicating the number of column-pairings for the \nglance output.  This must be less than half the total number of columns,\nas each column-pairing includes a statistic name and value.}\n\n\\item{total_cols}{The total number of columns in the body of the pixiedust table}\n\n\\item{glance_stats}{A character vector giving the names of the glance statistics\nto put in the output.  When \\code{NULL}, the default, all of the available \nstatistics are retrieved.  In addition to controlling which statistics are \nprinted, this also controls the order in which they are printed.}\n\n\\item{byrow}{A logical, defaulting to \\code{FALSE}, that indicates if the \nrequested statistics are placed with priority to rows or columns.  See Details.}\n}\n\\description{\nRetrieves the \\code{broom::glance} output for a model object and \n  structures it into a table suitable to be placed in the footer.  By default,\n  the statistics are displayed in two column-pairings (see Details).  This \n  function is not exported but is documented to maintain clarity of its \n  behavior.  It is intended for use within \\code{dust}, but may be useful\n  elsewhere if used with caution.\n}\n\\details{\nStatistics are placed in column-pairings.  Each column pair consists of \n  two columns named \\code{stat_name_x} and \\code{stat_value_x}, where \\code{x} is \n  the integer index of the column pair.  The column-pairings are used to allow \n  the user to further customize the output, more-so than pasting the name and \n  value together would allow.  With this design, statistics can be rounded \n  differently by applying sprinkles to the resulting table.\n  \n  The total number of column-pairings must be less than or equal to half the \n  number of total columns.  This constraint prevents making glance tables that \n  have more columns than the model table it accompanies.  \n  \n  When the total number of column-parings is strictly less than half the total \n  number of columns, \"filler\" columns are placed between the column pairings.\n  As much as possible, the filler columns are placed evenly between the \n  column pairings, but when the number of filler columns is unequal between \n  column-pairings, there will be more space placed on the left side.  For example,\n  if a table has 7 columns and 3 column-pairings, the order of placement would be\n  column-pair-1, filler, column-pair-2, column-pair-3.  Since there was only room\n  for one column of filler, it was placed in the left most fill position.\n  \n  The \\code{byrow} arguments acts similarly to the \\code{byrow} argument in the\n  \\code{matrix} function, but defaults to \\code{FALSE}.  If four statistics are \n  requested and \\code{byrow = FALSE}, the left column-pair will have statistics \n  one and two, while the right column-pair will have statistics three and four.\n  If \\code{byrow = TRUE}, however, the left column-pair will have statistics\n  one and three, while the right column-pair will have statistics two and four.\n}\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "man/index_to_sprinkle.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/index_to_sprinkle.R\n\\name{index_to_sprinkle}\n\\alias{index_to_sprinkle}\n\\title{Determine the Indices to Sprinkle}\n\\usage{\nindex_to_sprinkle(\n  x,\n  rows = NULL,\n  cols = NULL,\n  fixed = FALSE,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\"),\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  coll = NULL\n)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}.}\n\n\\item{rows}{Either a numeric vector of rows in the tabular object to be \nmodified or an object of class \\code{call}.  When a \\code{call}, \ngenerated by \\code{quote(expression)}, the expression resolves to \na logical vector the same length as the number of rows in the table.\nSprinkles are applied to where the expression resolves to \\code{TRUE}.}\n\n\\item{cols}{Either a numeric vector of columns in the tabular object to\nbe modified, or a character vector of column names. A mixture of \ncharacter and numeric indices is permissible.}\n\n\\item{fixed}{\\code{logical(1)} indicating if the values in \\code{rows} and \n\\code{cols} should be read as fixed coordinate pairs.  See Details.}\n\n\\item{part}{\\code{character} string.  Specifies if the sprinkles are \nbeing applied to the head, body, foot, or interfoot of the table. Partial\nmatching is supported.}\n\n\\item{recycle}{\\code{character} string. Indicates how recycling is to be\nperformed.  Partial matching is supported. See Details.}\n\n\\item{coll}{An optional \\code{AssertCollection} object. When \\code{NULL},\nan \\code{AssertCollection} object will be created and reported within\nthe call to this function.  When not \\code{NULL}, any failed assertions\nwill be added to the object in reported in the function that called\n\\code{index_to_sprinkle}.}\n}\n\\description{\nThe sprinkle methods accept the rows and columns that are\n  to be modified as matrix coordinates.  The \\code{dust} object stores\n  the table data in a long form.  The tabular coordinates are translated\n  into row indices using this function.\n}\n\\details{\nWhen \\code{fixed = FALSE}, sprinkles are applied at the \n  intersection of \\code{rows} and \\code{cols}, meaning that the arguments \n  do not have to share the same length.  When \\code{fixed = TRUE}, they must\n  share the same length.\n  \n  The value of \\code{recycle} determines how sprinkles are \n  managed when the sprinkle input doesn't match the length of the region\n  to be sprinkled.  By default, recycling is turned off.  Recycling \n  may be performed across rows first (left to right, top to bottom), \n  or down columns first (top to bottom, left to right).  \\code{\"cols\"} \n  and \\code{\"columns\"} have the same effect. The two choices to specify \n  are motivated by the fact that I sometimes get confused about which\n  it should be. :)\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item Return the indices of the intersection of \\code{rows} and \\code{cols}\n \\item If \\code{rows = NULL}, assume all rows.\n \\item If \\code{rows} is an expression where no values resolve to \n   \\code{TRUE}, return \\code{x} unchanged.\n \\item If any value in \\code{rows} is not a valid row in the table,\n   cast an error.\n \\item If \\code{cols = NULL}, assume all columns.\n \\item If any value in \\code{cols} does not identify a column in the table,\n   cast an error.\n \\item If \\code{fixed = TRUE}, \\code{length(rows)} (or \\code{sum(rows),\n   if an expression}) and \\code{cols} must have the same length.\n \\item Cast an error if \\code{fixed} is not a \\code{logical(1)}\n \\item Cast an error if \\code{part} is not one of \\code{\"body\"}, \n   \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}.\n}\n}\n\n\\seealso{\n\\code{sprinkle}\n}\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "man/is_valid_color.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/is_valid_color.R\n\\name{is_valid_color}\n\\alias{is_valid_color}\n\\alias{is_valid_color_single}\n\\title{Test a Character String For Pixiedust Recognized Color Format}\n\\usage{\nis_valid_color(color)\n\nis_valid_color_single(color)\n}\n\\arguments{\n\\item{color}{A character vector of color names.}\n}\n\\description{\n\\code{pixiedust} recognizes colors as dvips names, \n  \\code{rgb(R,G,B)}, \\code{rgba(R,G,B,A)}, \\code{#RRGGBB}, or \n  \\code{#RRGGBBAA}.  This code returns a logical indicating if \n  the given character strings are valid.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item Returns a logical vector correctly identifying valid color formats.\n \\item Casts an error if \\code{color} is not a character object.\n}\n}\n\n"
  },
  {
    "path": "man/knit_print.dust.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/knit_print.dust.R\n\\name{knit_print.dust}\n\\alias{knit_print.dust}\n\\alias{knit_print.dust_list}\n\\title{\\code{knitr} Printing Function}\n\\usage{\n\\method{knit_print}{dust}(x, options, ...)\n\n\\method{knit_print}{dust_list}(x, options, ...)\n}\n\\arguments{\n\\item{x}{A dust object}\n\n\\item{options}{A list of options received from the chunk options.}\n\n\\item{...}{Additional arguments to pass to other methods.}\n}\n\\description{\nCustom printing functions for displaying \\code{dust} and \n  \\code{dust_list} objects in R Markdown documents.\n}\n"
  },
  {
    "path": "man/medley.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/medley.R\n\\name{medley}\n\\alias{medley}\n\\alias{medley_bw}\n\\alias{medley_model}\n\\title{Sprinkle Medleys}\n\\usage{\nmedley_bw(x)\n\nmedley_model(x, round = 2)\n}\n\\arguments{\n\\item{x}{a \\code{dust} object.}\n\n\\item{round}{A numerical value passed to the \\code{round} sprinkle.}\n}\n\\description{\n\\code{pixiedust} can get to be pretty verbose if you are doing\n  a great deal of customization.  Sprinkle medleys can take out some of that\n  code by bundling much of the formatting sprinkling into a single function.\n  \n  \\code{pixiedust} comes with a couple very basic medleys that are mostly \n  for illustration of how to write medleys.  Once you get the hang of \n  sprinkling, you need only bundle your most common sprinkles into a \n  medley function of your own and cut down on some of the time \n  coding your most basic formatting.\n}\n\\examples{\n\\dontrun{\nfit <- lm(mpg ~ qsec + factor(am) + wt * factor(gear), data = mtcars)\n\ndust(fit) \\%>\\%\n  medley_bw() \\%>\\%\n  sprinkle_print_method(\"html\")\n  \ndust(fit, glance_foot = TRUE) \\%>\\%\n  medley_model() \\%>\\%\n  sprinkle_print_method(\"html\")\n  \n# Medleys are not generics and do not have methods.\n# Using a medley on a dust_list object requires pixieply\n\nlibrary(dplyr)\nmtcars \\%>\\% \n  group_by(gear) \\%>\\% \n  dust(ungroup = FALSE) \\%>\\% \n  pixieply(medley_bw) \\%>\\% \n  sprinkle_print_method(\"html\")\n}\n\n}\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "man/medley_all_borders.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/medley_all_borders.R\n\\name{medley_all_borders}\n\\alias{medley_all_borders}\n\\title{Apply Cell Borders to All Cells in a Region}\n\\usage{\nmedley_all_borders(\n  x,\n  rows = NULL,\n  cols = NULL,\n  horizontal = TRUE,\n  vertical = TRUE,\n  part = \"body\"\n)\n}\n\\arguments{\n\\item{x}{An object of class dust}\n\n\\item{rows}{The rows over which the borders are to be drawn.}\n\n\\item{cols}{The cols over which the borders are to be drawn.}\n\n\\item{horizontal}{Logical.  Toggles horizontal borders.}\n\n\\item{vertical}{Logical. Toggles vertical borders}\n\n\\item{part}{A character vector.  May contain any of \\code{\"body\", \n\"head\", \"interfoot\", \"foot\", \"table\"}.  When any element is \n\\code{\"table\"}, the borders are drawn in all parts of the table.}\n}\n\\description{\nFor most output, specifying a region of cells with borders\n  on all sides is as simple as giving the sprinkle \\code{border = \"all\"}.\n  In LaTeX output, however, this can result in thicker than expected \n  vertical borders.  This medley provides a LaTeX save approach to \n  drawing borders on all sides without getting the double vertical \n  border effect.\n}\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "man/pixie_count.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/pixie_count.R\n\\name{pixie_count}\n\\alias{pixie_count}\n\\alias{get_pixie_count}\n\\alias{set_pixie_count}\n\\alias{increment_pixie_count}\n\\title{Access and manipulate table numbers counters}\n\\source{\nThe concept for these functions is loosely based on a hook meant to work with \n\\code{knitr} to automatically number tables. \nhttp://stackoverflow.com/a/18672268/1017276\n}\n\\usage{\nget_pixie_count()\n\nset_pixie_count(value)\n\nincrement_pixie_count(increment = 1)\n}\n\\arguments{\n\\item{value}{The value at which to set the pixie counter.}\n\n\\item{increment}{The value to add to the current pixie count.  Defaults to 1.}\n}\n\\description{\nWhile LaTeX provides the ability to automatically number tables, this \nfunctionality is not readily available with console, HTML, or Word output.  By \nkeep track of the number of (captioned) tables, we can mimic the behavior of \nLaTeX tables to provide (mostly) consistent table numbering between formats.  The \ntable numbering is stored in the \\code{pixie_count} option.\n}\n\\details{\nThe pixie count is stored in the options and may also be accessed using\n\\code{getOption(\"pixie_count\")}.  \n\n\\code{get_pixie_count} returns the current value of the counter.\n\n\\code{set_pixie_count} sets the value to the user-specification.\n\n\\code{increment_pixie_count} increments the pixie count, usually by 1.  This is called\n  within \\code{print.dust} any time a \\code{dust} object has a caption.\n}\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "man/pixiedust.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/pixiedust-pkg.R\n\\docType{package}\n\\name{pixiedust}\n\\alias{pixiedust}\n\\alias{pixiedust-package}\n\\title{Tables So Beautifully Fine-Tuned You Will Believe It's Magic.}\n\\description{\nThe \\code{pixiedust} mission is to provide a user friendly \nand flexible interface by which report-quality tables may \nbe rendered in multiple output formats.  Initially, \n\\code{pixiedust} will support markdown, HTML, and LaTeX\nformats, as well as methods for console output.\n}\n\\details{\nThe advantage of \\code{pixiedust} is that it gives you the\ncontrol to alter the appearance of a table by as little \nas one cell at a time.  This fine-tuned control gives you\nenormous flexibility in how the final table looks with \nminimal pre and post processing.\n\nAdditionally, \\code{pixiedust} is largely built on top \nof the \\code{broom} package, allowing for simple and \nfast generation of tables based on analytical results.\n\nThe chief disadvantage of \\code{pixiedust} is that it \ncan be extremely verbose.  If you are applying many\ncustomizations, you will find yourself writing a \ngreat deal of code.\n}\n\\section{Options}{\n \n\n\\code{pixie_bookdown} determines if references and labels are \nmanaged using the \\code{bookdown} package methods.  This should be set \nto \\code{TRUE} if you are rendering documents via the \\code{bookdown} \npackage.\n\n\\code{border_collapse} determines the settings for border styles in HTML\ntables.  The most common values are \\code{\"collapse\"} - which presses all\nof the borders between cells on top of each other - and \\code{\"separate\"} - \nwhich allows each cell to have its own, distinct border.  \n\n\\code{pixie_count} is used to manage table numbering in non-LaTeX tables.\nSee \\code{\\link{set_pixie_count}} for methods to manipulate the numbering.\n\n\\code{pixie_discrete_pal } controls the colors for shading by discrete values.\n    \n\\code{pixie_float} determines if tables in LaTeX output are placed in \nfloating environments.\n\n\\code{pixie_gradient_pal} controls the colors giving the\n   endpoints of the color scale on which to shade numeric values.\n\n\\code{pixie_hhline} determins if tables in LaTeX output use the \n\\code{hhline} package for constructing table cells.\n\n\\code{pixie_html_linebreak} controls the number of line breaks placed \nafter a table in HTML output.\n\n\\code{pixie_interactive} Allows control over whether HTML and markdown \n  tables are printed to the viewer or to the document.\n\n\\code{pixie_justify} controls the positioning of the complete table in the\ndocument.  Note that \\code{\"none\"} renders the table to the left side of \nthe page, and subsequent elements will appear below the table.  When using\n\\code{\"left\"}, subsequent elements will appear to the right of the table.\nWhen using \\code{\"right\"}, subsequent elements will appear to the left of \nthe table.\n\n\\code{pixie_longtable} determines if the \\code{longtable} environment is \nused in LaTeX output.\n\n\\code{pixie_na_string} sets the default character set for replacing \n\\code{NA} values in tables.\n\n\\code{pixie_tabcolsep} determines the spacing placed between cells in \nLaTeX output.  \n\n\\code{pixiedust_print_method} Sets the default printing method for tables. \nWhen \\code{pixiedust} is being used with \\code{knitr} and \\code{rmarkdown},\nthe default is the value of \\code{knitr::opts_knit$get(\"rmarkdown.pandoc.to\")},\notherwise it is \\code{\"console\"}\n}\n\n\\section{Table-Valued Options}{\n\n\\tabular{lll}{\n Option Name          \\tab Default         \\tab Permissible Values        \\cr\n \\code{pixie_bookdown} \\tab \\code{FALSE}   \\tab \\code{logical}            \\cr\n \\code{pixie_border_collapse} \\tab \\code{\"collapse\"} \\tab \\code{collapse, separate, initial, inherit} \\cr\n \\code{pixie_count}   \\tab 0               \\tab \\code{integer} like value  \\cr\n \\code{pixie_float}   \\tab \\code{TRUE}     \\tab \\code{logical}               \\cr\n \\code{pixie_hhline}  \\tab \\code{FALSE}    \\tab \\code{logical}             \\cr\n \\code{pixie_html_linebreak} \\tab 2        \\tab \\code{integer} like value  \\cr\n \\code{pixie_justify} \\tab \\code{\"center\"} \\tab \\code{center, none, left, right} \\cr\n \\code{pixie_longtable} \\tab \\code{FALSE}  \\tab \\code{logical}             \\cr\n \\code{pixie_tabcolsep} \\tab 6             \\tab \\code{integer} like value  \\cr\n \\code{pixiedust_print_method} \\tab  \\tab \\code{console, html, latex, markdown, beamer}\n}\n}\n\n\\section{Cell-Valued Options}{\n\n\\tabular{lll}{\n Option Name          \\tab Default         \\tab Permissible Values        \\cr\n \\code{pixie_discrete_pal} \\tab \\code{scales::hue_pal()} \\tab \\code{character} of valid colors \\cr\n \\code{pixie_gradient_pal} \\tab \\code{c(\"#132B43\", \"#56B1F7\")} \\tab \\code{character(2)} of valid colors \\cr\n \\code{pixie_na_string} \\tab \\code{NA}            \\tab \\code{character}     \n}\n}\n\n\\seealso{\nUseful links:\n\\itemize{\n  \\item \\url{https://github.com/nutterb/pixiedust}\n  \\item Report bugs at \\url{https://github.com/nutterb/pixiedust/issues}\n}\n\n}\n\\author{\n\\strong{Maintainer}: Benjamin Nutter \\email{benjamin.nutter@gmail.com}\n\nOther contributors:\n\\itemize{\n  \\item David Kretch [contributor]\n}\n\n}\n\\keyword{internal}\n"
  },
  {
    "path": "man/pixiedust_print_method.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/pixiedust_print_method.R\n\\name{pixiedust_print_method}\n\\alias{pixiedust_print_method}\n\\title{Determine the Current Print Method}\n\\usage{\npixiedust_print_method()\n}\n\\description{\nThe user has the option of designating the print method to use, or \n  allowing package to select one from the \\code{knitr} settings.  This \n  function manages the logic of assigning the correct print method within the\n  \\code{dust} call.\n}\n\\details{\nThe function \\code{pixiedust_print_method} first uses \n  \\code{getOption(\"pixiedust_print_method\")} to determine if the user has set \n  a print method.  If the user has not, it then looks to \n  \\code{knitr::opts_knit$get(\"rmarkdown.pandoc.to\")}. Finally, if this is also\n  \\code{NULL}, then the option is set to \\code{\"console\"}.\n}\n"
  },
  {
    "path": "man/pixieply.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/pixieply.R\n\\name{pixieply}\n\\alias{pixieply}\n\\alias{pixiemap}\n\\title{Apply Functions Over `dust_list` Objects}\n\\usage{\npixieply(X, FUN, ...)\n\npixiemap(X, FUN, ..., MoreArgs = NULL, SIMPLIFY = FALSE, USE.NAMES = TRUE)\n}\n\\arguments{\n\\item{X}{An object of class \\code{dust_list}.}\n\n\\item{FUN}{A function to apply to each element of \\code{X}}\n\n\\item{...}{Additional arguments to pass to \\code{FUN}}\n\n\\item{MoreArgs}{a list of other arguments to FUN}\n\n\\item{SIMPLIFY}{logical or character string; attempt to reduce the result \nto a vector, matrix or higher dimensional array; see the \\code{simplify} \nargument of \\code{\\link{sapply}}}\n\n\\item{USE.NAMES}{logical; use names if the first ... argument has names, \nor if it is a character vector, use that character vector as the names.}\n}\n\\description{\nThe \\code{sprinkle} methods work with \\code{dust_list} \n  objects very naturally, but medleys pose a slightly more difficult problem.\n  Medleys are intended to be predefined collections of sprinkles that reduce\n  the time required to format a table with a particular look and style.  \n  It seems counter-productive to expect a user to define each of her or his\n  medleys as a method that can work with both \\code{dust} and \\code{dust_list}\n  objects.  \\code{pixieply} is a wrapper to \\code{lapply} that preserves the\n  \\code{dust_list} class of the object.\n  \n  \\code{pixiemap} provides functionality to apply differing sprinkles over\n  each element of a \\code{dust_list}.  The most common example is probably\n  adding a unique caption to each table.\n}\n\\examples{\n\\dontrun{\n#* This example will only display the last table \n#* in the viewer pane.  To see the full output,\n#* run this example in an Rmarkdown document.\nx <- split(mtcars, list(mtcars$am, mtcars$vs))\ndust(x) \\%>\\%\n  sprinkle_print_method(\"html\") \\%>\\%\n  pixieply(medley_bw)\n}\n\n\\dontrun{\n#* This is the full text of an RMarkdown script \n#* for the previous example.\n---\ntitle: \"Pixieply\"\noutput: html_document\n---\n\n```{r}\nlibrary(pixiedust)\nx <- dplyr::group_by(mtcars, am, vs)\ndust(x, ungroup = FALSE) \\%>\\%\n  sprinkle_print_method(\"html\") \\%>\\%\n    pixieply(medley_bw)\n```\n}\n\n}\n"
  },
  {
    "path": "man/print.dust.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/print.dust.R\n\\name{print.dust}\n\\alias{print.dust}\n\\alias{print.dust_list}\n\\title{Print A \\code{dust} Table}\n\\usage{\n\\method{print}{dust}(x, ..., asis = TRUE, linebreak_at_end = 2)\n\n\\method{print}{dust_list}(x, ..., asis = TRUE)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{...}{Additional arguments to pass to the print method.  Currently ignored.}\n\n\\item{asis}{A logical value that controls if the output is printed using\n\\code{knitr::asis_output}.  See Details.}\n\n\\item{linebreak_at_end}{Used only in HTML tables; defines the number of \nline break tags \\code{</br>} appended to the end of the table in order to \ngenerate whitespace between then end of the table and the subsequent\nelement.  By default, two line breaks are used.}\n}\n\\description{\nApply the formatting to a \\code{dust} object and print the table.\n}\n\\details{\nThe printing format is drawn from \\code{options()$dustpan_output} and may take any of\n  the values \\code{\"console\"}, \\code{\"markdown\"}, \\code{\"html\"}, or \\code{\"latex\"}\n  \n  The markdown, html, and latex output is returned via \\code{\\link[knitr]{asis_output}},\n  which forces the output into the 'asis' environment.  It is intended to work \n  with Rmarkdown, and the tables will be rendered regardless of the \n  chunk's \\code{results} argument.  Currently, there is no way to to capture\n  the code for additional post processing.\n  \n  When \\code{asis = TRUE} (the default), the output is returned via \\code{knitr::asis_output},\n  which renders the output as if the chunk options included \\code{results = 'asis'}.  Under \n  this setting, the table will be rendered regardless of the value of the \\code{results} \n  option.  Using \\code{asis = FALSE} returns a character string with the code for the table.\n  This may be rendered in a markdown document via \\code{cat(print(x, asis = FALSE))} with the \n  chunk option \\code{results = 'asis'}.  (If working with an Rnw file, the chunk option is \n  \\code{results = tex}).  The only way to use the \\code{asis} argument is with an explicit\n  call to \\code{print.dust}.\n}\n\\examples{\ndust(lm(mpg ~ qsec + factor(am), data = mtcars))\n}\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "man/pval_string.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/pval_string.R\n\\name{pval_string}\n\\alias{pval_string}\n\\alias{pvalString}\n\\title{Format P-values for Reports}\n\\usage{\npval_string(p, format = c(\"default\", \"exact\", \"scientific\"), digits = 3, ...)\n\npvalString(p, format = c(\"default\", \"exact\", \"scientific\"), digits = 3, ...)\n}\n\\arguments{\n\\item{p}{a numeric vector of p-values.}\n\n\\item{format}{A character string indicating the desired format for \nthe p-values.  See Details for full descriptions.}\n\n\\item{digits}{For \\code{\"exact\"} and \\code{\"scientific\"}; indicates the \nnumber of digits to precede scientific notation.}\n\n\\item{...}{Additional arguments to be passed to \\code{format}}\n}\n\\description{\nConvert numeric p-values to character strings according to\npre-defined formatting parameters.  Additional formats may be added\nfor required or desired reporting standards.\n}\n\\details{\nWhen \\code{format = \"default\"}, p-values are formatted:\n\\enumerate{\n  \\item \\emph{p > 0.99}: \"> 0.99\"\n  \\item \\emph{0.99 > p > 0.10}: Rounded to two digits\n  \\item \\emph{0.10 > p > 0.001}: Rounded to three digits\n  \\item \\emph{0.001 > p}: \"< 0.001\"\n }\n \n When \\code{format = \"exact\"}, the exact p-value is printed with the \n number of places after the deimal equal to \\code{digits}.  P-values smaller\n that 1*(10^-\\code{digits}) are printed in scientific notation.\n \n When \\code{format = \"scientific\"}, all values are printed in scientific\n notation with \\code{digits} digits printed before the \\code{e}.\n}\n\\section{Functional Requirements}{\n\n \\enumerate{\n  \\item When \\code{format = \"default\"}, print p-values greater than \n    0.99 as \"> 0.99\"; greater than 0.10 with two digits; \n    greater than 0.001 with three digits; and less than 0.001 as \n    \"< 0.001\".\n  \\item when \\code{format = \"exact\"}, print the exact p-value out to at most\n    \\code{digits} places past the decimal place.\n  \\item When \\code{format = \"scientific\"}, print the p-value in \n    scientific notation with up to \\code{digits} values ahead of the \n    \\code{e}.\n  \\item Cast an error if \\code{p} is not numeric on the interval [0, 1]\n  \\item Cast an error if format is not one of \\code{c(\"default\", \"exact\",\n    \"scientific\")}.\n  \\item Cast an error if \\code{digits} is not \\code{integerish(1)}.\n }\n}\n\n\\examples{\n p <- c(1, .999, .905, .505, .205, .125, .09531,\n        .05493, .04532, .011234, .0003431, .000000342)\n pvalString(p, format=\"default\")\n pvalString(p, format=\"exact\", digits=3)\n pvalString(p, format=\"exact\", digits=2)\n pvalString(p, format=\"scientific\", digits=3)\n pvalString(p, format=\"scientific\", digits=4)\n \n}\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "man/rbind_internal.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/rbind_internal.R\n\\name{rbind_internal}\n\\alias{rbind_internal}\n\\alias{.rbind_internal}\n\\title{Bind Rows in Base R}\n\\usage{\n.rbind_internal(..., deparse.level = 1)\n}\n\\arguments{\n\\item{...}{data frames}\n\n\\item{deparse.level}{See \\code{deparse.level} in \\code{rbind}.}\n}\n\\description{\nStack data frames on top of each other. Data frames do not have to \n  have all of the same columns.\n}\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "man/reshape_data_internal.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/reshape_data_internal.R\n\\name{reshape_data_internal}\n\\alias{reshape_data_internal}\n\\alias{.make_dataframe_long}\n\\title{Reshape data frames for Pixiedust}\n\\usage{\n.make_dataframe_long(data)\n}\n\\arguments{\n\\item{data}{A \\code{data.frame}}\n}\n\\description{\nPixiedust reshapes data to have one row per cell in the table. This \n  permits adjustments to be made to individual cells.  These internal functions\n  are provided to simplify the reshaping process. It is slower than using \n  the tidyr functions `gather` and `spread` (or whatever their newer counterparts \n  are), but keeps me off of other people's development schedules.\n}\n\\details{\nNo validations are performed in these functions, and it is assumed that\n  the input data set has the components it needs.\n}\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "man/sanitize_latex.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sanitize_latex.R\n\\name{sanitize_latex}\n\\alias{sanitize_latex}\n\\title{Escape Characters for Printing in LaTeX Output}\n\\usage{\nsanitize_latex(\n  object,\n  inn = NULL,\n  out = NULL,\n  pb = FALSE,\n  greek = FALSE,\n  na = \"\",\n  ...\n)\n}\n\\arguments{\n\\item{object}{\\code{character} vector of strings to translate.\nAny NAs are set to blank strings before conversion.}\n\n\\item{inn}{\\code{character} vector. Additional strings to translate.}\n\n\\item{out}{\\code{character} vector the same length as \\code{inn}.\nThis gives the translated value of the corresonding element in \n\\code{inn}}\n\n\\item{pb}{\\code{logical(1)} If \\code{pb=TRUE}, \\code{sanitize_latex} also \ntranslates \\code{[()]} to math mode using \\code{\\\\left}, \\code{\\\\right}.}\n\n\\item{greek}{\\code{logical(1)}. set to \\code{TRUE} to have \n\\code{sanitize_latex} put names for greek letters in math mode and \nadd backslashes.}\n\n\\item{na}{\\code{character(1)} Single character string to translate \n\\code{NA} values to.}\n\n\\item{...}{Additional arguments for other methods. Currently ignored.}\n}\n\\value{\nVector of chracter strings.\n}\n\\description{\n\\code{sanitize_latex} translates particular items in \ncharacter strings to LaTeX format, e.g., makes \\code{a^2 = a\\$^2\\$} \nfor superscript within variable labels. LaTeX names of greek letters \n(e.g., \"alpha\") will have backslashes added if \\code{greek==TRUE}. \nMath mode is inserted as needed. \\code{sanitize_latex} assumes that \ninput text always has matches, e.g. \\code{[) [] (] ()}, and that \nsurrounding by \\code{\\$\\$} is OK.\n}\n\\examples{\nsanitize_latex(\"75\\% of the cars were | more than $20,000 Delta = 1.30\", greek = TRUE)\n\n}\n\\seealso{\n\\code{Hmisc::latexTranslate}, \\code{Hmisc::sedit}\n}\n\\author{\nThis code is lifted from the \\code{Hmisc} package in order to \navoid depending on that package.\n\nFrank E. Harrell Jr.\\cr\nDepartment of Biostatistics,\\cr\nVanderbilt University,\\cr\nf.harrell@vanderbilt.edu\\cr\n\nRichard M. Heiberger,\\cr\nDepartment of Statistics,\\cr\nTemple University, Philadelphia, PA.\\cr\nrmh@temple.edu\\cr\n\nDavid R. Whiting,\\cr\nSchool of Clinical Medical Sciences (Diabetes),\\cr\nUniversity of Newcastle upon Tyne, UK.\\cr\ndavid.whiting@ncl.ac.uk\\cr\n}\n"
  },
  {
    "path": "man/sprinkle.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle.R, R/sprinkle_print_method.R,\n%   R/sprinkle_table.R\n\\name{sprinkle}\n\\alias{sprinkle}\n\\alias{sprinkle.default}\n\\alias{sprinkle.dust_list}\n\\alias{sprinkle_print_method}\n\\alias{sprinkle_print_method.default}\n\\alias{sprinkle_print_method.dust_list}\n\\alias{sprinkle_table}\n\\alias{sprinkle_table.default}\n\\alias{sprinkle_table.dust_list}\n\\title{Define Customizations to a Table}\n\\source{\nAltering the number of rows in a LaTeX longtable \\cr\nhttp://tex.stackexchange.com/questions/19710/how-can-i-set-the-maximum-number-of-rows-in-a-page-for-longtable\n\nVertical dashed cell borders in LaTeX table \\cr\nhttp://www.latex-community.org/forum/viewtopic.php?f=45&t=3149\n\nColored Cell border \\cr\nhttp://tex.stackexchange.com/questions/40666/how-to-change-line-color-in-tabular\n}\n\\usage{\nsprinkle(\n  x,\n  rows = NULL,\n  cols = NULL,\n  ...,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\")\n)\n\n\\method{sprinkle}{default}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  ...,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\")\n)\n\n\\method{sprinkle}{dust_list}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  ...,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\")\n)\n\nsprinkle_print_method(\n  x,\n  print_method = c(\"console\", \"markdown\", \"html\", \"latex\")\n)\n\n\\method{sprinkle_print_method}{default}(\n  x,\n  print_method = c(\"console\", \"markdown\", \"html\", \"latex\", \"docx\")\n)\n\n\\method{sprinkle_print_method}{dust_list}(\n  x,\n  print_method = c(\"console\", \"markdown\", \"html\", \"latex\")\n)\n\nsprinkle_table(x, cols = NULL, ..., part = \"table\")\n\n\\method{sprinkle_table}{default}(x, cols = NULL, ..., part = \"table\")\n\n\\method{sprinkle_table}{dust_list}(x, cols = NULL, ..., part = \"table\")\n}\n\\arguments{\n\\item{x}{A dust object}\n\n\\item{rows}{A numeric vector specifying the rows of the table to sprinkle.\nSee details for more about sprinkling.}\n\n\\item{cols}{A numeric (or character) vector specifying the columns (or \ncolumn names) to sprinkle.  See details for more about sprinkling.}\n\n\\item{...}{named arguments, each of length 1, defining the customizations\nfor the given cells.  See \"Sprinkles\" for a listing of these arguments.}\n\n\\item{part}{A character string denoting which part of the table to modify.}\n\n\\item{fixed}{\\code{logical(1)} indicating if the values in \\code{rows} \nand \\code{cols} should be read as fixed coordinate pairs.  By default, \nsprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \nmeaning that the arguments do not have to share the same length.  \nWhen \\code{fixed = TRUE}, they must share the same length.}\n\n\\item{recycle}{A \\code{character} one that determines how sprinkles are \nmanaged when the sprinkle input doesn't match the length of the region\nto be sprinkled.  By default, recycling is turned off.  Recycling \nmay be performed across rows first (left to right, top to bottom), \nor down columns first (top to bottom, left to right).}\n\n\\item{print_method}{A character string giving the print method for the table. \nNote: \\code{\"docx\"} is synonymous with \\code{\"markdown\"}.}\n}\n\\description{\nCustomizations to a \\code{dust} table are added by \"sprinkling\"\n  with a little extra pixie dust.  Sprinkles are a collection of attributes\n  to be applied over a subset of table cells.  They may be added to any \n  part of the table, or to the table as a whole.\n}\n\\details{\nSprinkling is done over the intersection of rows and columns \n  (unless \\code{fixed = TRUE}.  If\n  rows but no columns are specified, sprinkling is performed over all columns\n  of the given given rows. The reverse is true for when columns but no rows\n  are specified.  If neither columns nor rows are specified, the attribute \n  is applied over all of the cells in the table part denoted in \\code{part}.\n\n  If at least one of \\code{border}, \\code{border_thickness}, \\code{border_units},\n  \\code{border_style} or \\code{border_color} is specified, the remaining\n  unspecified attributes assume their default values.\n  \n  Other sprinkle pairings are \\code{height} and \\code{height_units}; \n  \\code{width} and \\code{width_units}; \\code{font_size} and \\code{font_size_units};\n  \\code{bg_pattern} and \\code{bg_pattern_by}\n  \n  The sprinkles \\code{bg} and \\code{bg_pattern} may not be used together.\n  \n  A more detailed demonstration of the use of sprinkles is available in \n  \\code{vignette(\"pixiedust\", package = \"pixiedust\")}\n  \n  Using \\code{sprinkle_table}, sprinkles may be applied to the columns of multiple tables. Table\n  parts are required to have the same number of columns, but not necessarily the same number \n  of rows, which is why the \\code{rows} argument is not available for the \\code{sprinkle_table}.\n  In contrast to \\code{sprinkle}, the \\code{part} argument in \\code{sprinkle_table} will \n  accept multiple parts.  If any of the named parts is \\code{\"table\"}, the sprinkle will be \n  applied to the columns of all of the parts.\n}\n\\section{Sprinkles}{\n\nThe following table describes the valid sprinkles that may be defined in the \n\\code{...} dots argument.  All sprinkles may be defined for any output type, but \nonly sprinkles recognized by that output type will be applied when printed.  \nA more readable format of this information is available in  \n\\code{vignette(\"sprinkles\", package = \"pixiedust\")}.\n\n\\tabular{lll}{\nbg  \\tab           \\tab  \\cr\n    \\tab action    \\tab Modifies the background color of a cell. \\cr\n    \\tab default   \\tab  \\cr\n    \\tab accepts   \\tab dvips color names; rgb(R,G,B); rgba(R,G,B,A); \\cr\n    \\tab           \\tab  #RRGGBB; #RRGGBBAA. See the \"Colors\" section \\cr\n    \\tab           \\tab  for further details. \\cr\n    \\tab console   \\tab Not recognized \\cr\n    \\tab markdown  \\tab Not recognized \\cr\n    \\tab html      \\tab Accepts any of the listed formats; \\cr\n    \\tab           \\tab recognizes transparency \\cr\n    \\tab latex     \\tab Accepts any of the listed formats, \\cr\n    \\tab           \\tab but ignores transparency \\cr\nbg_pattern \\tab    \\tab  \\cr\n \\tab action       \\tab Generates a pattern of background colors.  \\cr\n \\tab              \\tab Can be used to make striping \\cr\n \\tab              \\tab by rows or by columns. \\cr\n \\tab default      \\tab c(\"#FFFFFF\", \"#DDDDDD\") \\cr\n \\tab accepts      \\tab A vector of color names: \\cr\n \\tab              \\tab dvips color names; rgb(R,G,B); rgba(R,G,B,A); \\cr \n \\tab              \\tab #RRGGBB; #RRGGBBAA \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Accepts any of the listed formats; \\cr\n \\tab              \\tab recognizes transparency \\cr\n \\tab latex        \\tab Accepts any of the listed formats, \\cr\n \\tab              \\tab but ignores transparency \\cr\nbg_pattern_by  \\tab  \\tab  \\cr\n \\tab action       \\tab Determines if a `bg_pattern` is patterned \\cr \n \\tab              \\tab by row or by columns. \\cr\n \\tab default      \\tab \"rows\" \\cr\n \\tab accepts      \\tab \"rows\", \"columns\", \"cols\" \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Recognized \\cr\nbold \\tab  \\tab  \\cr\n \\tab action       \\tab Renders text within a cell in bold. \\cr\n \\tab default      \\tab FALSE \\cr\n \\tab accepts      \\tab logical(1) \\cr\n \\tab console      \\tab Recognized; rendered as double asterisks on either\\cr\n \\tab              \\tab side of the text \\cr\n \\tab markdown     \\tab Recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Recognized \\cr\nborder_collapse \\tab  \\tab  \\cr\n \\tab action       \\tab Sets the `border-collapse` property in an \\cr\n \\tab              \\tab HTML table.  The property sets whether the \\cr\n \\tab              \\tab table borders are collapsed into a  \\cr\n \\tab              \\tab single border or detached as in standard HTML. \\cr\n \\tab default      \\tab TRUE \\cr\n \\tab accepts      \\tab logical(1) \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Not recognized \\cr\nborder \\tab  \\tab  \\cr\n \\tab action       \\tab Sets a border on the specified side of a cell. \\cr\n \\tab default      \\tab  \\cr\n \\tab accepts      \\tab Any combination of \"all\", \"bottom\", \"left\", \"top\",\\cr\n \\tab              \\tab \"right\".  Using  \"all\" results in all borders \\cr\n \\tab              \\tab being drawn, regardless of what other values are \\cr\n \\tab              \\tab passed with it. \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Recognized \\cr\nborder_color \\tab  \\tab  \\cr\n \\tab action       \\tab Sets the color of the borders specified for a cell. \\cr\n \\tab default      \\tab \"Black\" \\cr\n \\tab accepts      \\tab character(1) \\cr\n \\tab              \\tab dvips color names; rgb(R,G,B); rgba(R,G,B,A); \\cr\n \\tab              \\tab #RRGGBB; #RRGGBBAA. See the \"Colors\" section \\cr\n    \\tab           \\tab  for further details. \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Recognized \\cr\nborder_style \\tab  \\tab  \\cr\n \\tab action       \\tab Sets the border style for a specified cell \\cr\n \\tab default      \\tab \"solid\" \\cr\n \\tab accepts      \\tab character(1) \\cr\n \\tab              \\tab \"solid\", \"dashed\", \"dotted\", \"double\", \"groove\", \\cr\n \\tab              \\tab \"ridge\", \"inset\", \"outset\", \"hidden\", \"none\" \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Accepts any of the values listed. \\cr\n \\tab latex; hhline = FALSE \\tab accepts \"solid\", \"dashed\", \"dotted\",  \\cr\n \\tab              \\tab  \"hidden\", \"none\" \\cr\n \\tab              \\tab \"dotted\" is silently changed to \"dashed\" \\cr\n \\tab              \\tab \"hidden\" and \"none\" are equivalent. \\cr\n \\tab latex; hhline = TRUE \\tab accepts \"solid\", \"double\", \"hidden\", \"none\" \\cr\n \\tab              \\tab \"hidden\" and \"none\" are equivalent. \\cr\nborder_thickness \\tab  \\tab  \\cr\n \\tab action       \\tab Sets the thickness of the specified border \\cr\n \\tab default      \\tab 1 \\cr\n \\tab accepts      \\tab numeric(1) \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Recognized \\cr\nborder_units \\tab  \\tab  \\cr\n \\tab action       \\tab Sets the unit of measure for the specified border \\cr\n \\tab              \\tab thickness \\cr\n \\tab default      \\tab \"pt\" \\cr\n \\tab accepts      \\tab \"pt\", \"px\" \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Silently changes \"px\" to \"pt\" \\cr\ncaption \\tab  \\tab  \\cr\n \\tab action       \\tab Adds or alters the `caption` property \\cr\n \\tab default      \\tab  \\cr\n \\tab accepts      \\tab character(1) \\cr\n \\tab console      \\tab Recognized \\cr\n \\tab markdown     \\tab Recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Recognized \\cr\ndiscrete \\tab \\tab \\cr\n \\tab action       \\tab Adds distinct background colors based on \\cr\n \\tab              \\tab discrete values in the selected region. \\cr\n \\tab              \\tab May not be used concurrently with \\code{bg}. \\cr\n \\tab              \\tab \\code{\"font\"} is an alias for \\code{\"font_color\"} \\cr\n \\tab              \\tab and \\code{\"border\"} is an alias for \\cr\n \\tab              \\tab all borders. \\cr\n \\tab default      \\tab \"bg\" \\cr\n \\tab accepts      \\tab \"bg\", \"font\", \"font_color\", \"border\", \\cr\n \\tab              \\tab \"left_border\", \"top_border\", \"right_border\", \\cr\n \\tab              \\tab \"bottom_border\" \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Recognized \\cr\ndiscrete_color \\tab \\tab \\cr\n \\tab action       \\tab Sets the color palette from which \\code{discrete} \\cr\n \\tab              \\tab selects background colors. If \\code{NULL} \\cr\n \\tab              \\tab colors are automatically selected using \\cr\n \\tab              \\tab the \\code{scales} package. \\cr\n \\tab default      \\tab \\code{getOption(\"pixie_discrete_pal\", NULL)} \\cr\n \\tab accepts      \\tab character \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Recognized \\cr\nfloat \\tab  \\tab  \\cr\n \\tab action       \\tab Sets the `float` property \\cr\n \\tab default      \\tab TRUE \\cr\n \\tab accepts      \\tab logical(1) \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Not recognized \\cr\n \\tab latex        \\tab Recognized \\cr\nfn \\tab  \\tab  \\cr\n \\tab action       \\tab Applies a function to the value of a cell. \\cr\n \\tab              \\tab The function should be an \\cr\n \\tab              \\tab expression that acts on the variable `value`.  \\cr \n \\tab              \\tab For example, \\code{quote(format(value, nsmall = 3))} \\cr\n \\tab default      \\tab  \\cr\n \\tab accepts      \\tab call \\cr\n \\tab console      \\tab Recognized \\cr\n \\tab markdown     \\tab Recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Recognized \\cr\nfont_color \\tab  \\tab  \\cr\n \\tab action       \\tab Sets the color of the cell text \\cr\n \\tab default      \\tab Black \\cr\n \\tab accepts      \\tab dvips color names; rgb(R,G,B); rgba(R,G,B,A); \\cr\n \\tab              \\tab #RRGGBB; #RRGGBBAA. See the \"Colors\" section \\cr\n    \\tab           \\tab  for further details. \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Recognized; transparency recognized \\cr\n \\tab latex        \\tab Recognized; transparency ignored \\cr\nfont_family \\tab  \\tab  \\cr\n \\tab action       \\tab Sets the font for the text \\cr\n \\tab default      \\tab Times New Roman \\cr\n \\tab accepts      \\tab character(1) \\cr\n \\tab              \\tab http://www.w3schools.com/cssref/css_websafe_fonts.asp \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Not recognized \\cr\nfont_size \\tab  \\tab  \\cr\n \\tab action       \\tab Sets the size of the font in the cell \\cr\n \\tab default      \\tab  \\cr\n \\tab accepts      \\tab numeric(1) \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Recognized \\cr\nfont_size_units \\tab  \\tab  \\cr\n \\tab action       \\tab Determines the units in which `font_size` \\cr\n \\tab              \\tab is measured \\cr\n \\tab default      \\tab \"px\" \\cr\n \\tab accepts      \\tab \"px\", \"pt\", \"\\%\", \"em\" \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Only recognizes \"pt\" and \"em\".  \\cr\n \\tab              \\tab All others are coerced to \"pt\" \\cr\ngradient \\tab  \\tab  \\cr\n \\tab action       \\tab Adds distinct background colors based on \\cr\n \\tab              \\tab progressively increasing values in the \\cr\n \\tab              \\tab selected region. May not be used concurrently \\cr \n \\tab              \\tab with \\code{bg}. \\cr\n \\tab              \\tab \\code{\"font\"} is an alias for \\code{\"font_color\"} \\cr\n \\tab              \\tab and \\code{\"border\"} is an alias for \\cr\n \\tab              \\tab all borders. \\cr\n \\tab default      \\tab \"bg\" \\cr\n \\tab accepts      \\tab \"bg\", \"font\", \"font_color\", \"border\", \\cr\n \\tab              \\tab \"left_border\", \"top_border\", \"right_border\", \\cr\n \\tab              \\tab \"bottom_border\" \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Recognized \\cr\ngradient_colors \\tab \\tab \\cr\n \\tab action       \\tab Provides the colors between which to \\cr\n \\tab              \\tab shade gradients. \\cr\n \\tab default      \\tab \\code{getOptions(\"pixie_gradient_pal\", NULL)} \\cr\n \\tab accepts      \\tab character \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Recognized \\cr\ngradient_cut \\tab  \\tab  \\cr\n \\tab action       \\tab Determines the breaks points for the \\cr\n \\tab              \\tab gradient shading. When \\code{NULL}  \\cr\n \\tab              \\tab equally spaced quantiles are used, the \\cr\n \\tab              \\tab number of which are determined by \\cr\n \\tab              \\tab \\code{gradient_n}. \\cr\n \\tab default      \\tab NULL \\cr\n \\tab accepts      \\tab numeric \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Recognized \\cr\ngradient_n \\tab  \\tab  \\cr\n \\tab action       \\tab Determines the number of shades to use \\cr\n \\tab              \\tab between the colors in \\code{gradient_colors}.\\cr\n \\tab default      \\tab 10 \\cr\n \\tab accepts      \\tab numeric \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Recognized \\cr\ngradient_na \\tab  \\tab  \\cr\n \\tab action       \\tab Sets the color of NA values when gradients \\cr\n \\tab              \\tab are shaded. \\cr\n \\tab default      \\tab grey \\cr\n \\tab accepts      \\tab character(1) \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Recognized \\cr\nhalign \\tab  \\tab  \\cr\n \\tab action       \\tab Sets the horizontal alignment of the text in \\cr\n \\tab              \\tab the cell \\cr\n \\tab default      \\tab  \\cr\n \\tab accepts      \\tab \"left\", \"center\", \"right\" \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Recognized; numeric values will auto align to the \\cr\n \\tab              \\tab right if no value given. \\cr\n \\tab html         \\tab Recognized.  Does not currently employ auto \\cr\n \\tab              \\tab alignment of numeric values, but this may change. \\cr\n \\tab latex        \\tab Recognized; numeric values will auto align to \\cr\n \\tab              \\tab the right if no value given. \\cr\nheight \\tab  \\tab  \\cr\n \\tab action       \\tab Sets the height of the cell \\cr\n \\tab default      \\tab  \\cr\n \\tab accepts      \\tab numeric(1) \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Recognized \\cr\nheight_units \\tab  \\tab  \\cr\n \\tab action       \\tab Determines the units in which `height` is measured \\cr\n \\tab default      \\tab \"pt\" \\cr\n \\tab accepts      \\tab \"px\", \"pt\", \"cm\", \"in\", \"\\%\" \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Recognized; \"px\" is coerced to \"pt\" \\cr\nhhline \\tab  \\tab  \\cr\n \\tab action       \\tab Toggles the option for cell border drawing with \\cr \n \\tab              \\tab the `hhline` LaTeX package \\cr\n \\tab default      \\tab FALSE \\cr\n \\tab accepts      \\tab logical(1) \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Not recognized \\cr\n \\tab latex        \\tab Recognized.  When `FALSE` double borders are \\cr \n \\tab              \\tab not available. \\cr\n \\tab              \\tab When `TRUE`, colored and dashed borders are not \\cr\n \\tab              \\tab available. This is usually the better option \\cr\n \\tab              \\tab when using colored backgrounds in table cells. \\cr\nitalic \\tab  \\tab  \\cr\n \\tab action       \\tab Renders the text in the cell in italic \\cr\n \\tab default      \\tab FALSE \\cr\n \\tab accepts      \\tab logical(1) \\cr\n \\tab console      \\tab Recognized; rendered as an underscore on either \\cr\n \\tab              \\tab side of the text. \\cr\n \\tab markdown     \\tab Recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Recognized \\cr\njustify \\tab  \\tab  \\cr\n \\tab action       \\tab Justifies the entire table on the page. \\cr\n \\tab default      \\tab \"center\" \\cr\n \\tab accepts      \\tab character(1) \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Recognizes \"center\", but both \"left\" and \"right\" \\cr\n \\tab              \\tab are rendered as left justified.  This may change \\cr\n \\tab              \\tab if a satisfactory solution is found.  \\cr\n \\tab              \\tab Usually, tables are best left centered. \\cr\nlongtable \\tab  \\tab  \\cr\n \\tab action       \\tab Toggles the use of the LaTeX `longtable` style \\cr\n \\tab              \\tab tables, namely allowing long tables to be broken \\cr\n \\tab              \\tab into multiple sections. The table header appears \\cr \n \\tab              \\tab at the top of each section. The table interfoot \\cr\n \\tab              \\tab appears at the bottom of each section, except \\cr\n \\tab              \\tab for the last. \\cr\n \\tab              \\tab The table foot appears at the bottom of the \\cr\n \\tab              \\tab last section. \\cr\n \\tab              \\tab May accept either a logical or a numerical value.  \\cr\n \\tab              \\tab If numerical, each section will have the specified \\cr\n \\tab              \\tab number of rows. \\cr\n \\tab default      \\tab FALSE \\cr\n \\tab accepts      \\tab logical(1); numeric(1) \\cr\n \\tab console      \\tab Recognized; when `TRUE`, defaults to 25 rows \\cr\n \\tab              \\tab per section. \\cr\n \\tab markdown     \\tab Recognized; when `TRUE`, defaults to 25 rows \\cr\n \\tab              \\tab per section. \\cr\n \\tab html         \\tab Recognized; when `TRUE`, defaults to 25 rows \\cr\n \\tab              \\tab per section. \\cr\n \\tab latex        \\tab Recognized; when `TRUE`, `longtable`'s own algorithm \\cr \n \\tab              \\tab will determine the number of rows per section. \\cr\n \\tab              \\tab When numeric, breaks are forced at the specified \\cr\n \\tab              \\tab number of rows. \\cr\nmerge \\tab  \\tab  \\cr\n \\tab action       \\tab Merges cells in the specified range into a \\cr\n \\tab              \\tab single cell. In cases where \\cr\n \\tab              \\tab either `merge_rowval` or `merge_colval` is \\cr\n \\tab              \\tab specified, they will only be  \\cr\n \\tab              \\tab honored if `merge = TRUE`.  You must opt in to \\cr\n \\tab              \\tab this action. \\cr\n \\tab default      \\tab FALSE \\cr\n \\tab accepts      \\tab logical(1) \\cr\n \\tab console      \\tab Recognized \\cr\n \\tab markdown     \\tab Recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Recognized \\cr\nmerge_rowval \\tab  \\tab  \\cr\n \\tab action       \\tab Specifies the row value of the merged range to \\cr\n \\tab              \\tab print in the table \\cr\n \\tab default      \\tab minimum row value of the merged range \\cr\n \\tab accepts      \\tab numeric(1) \\cr\n \\tab console      \\tab Recognized \\cr\n \\tab markdown     \\tab Recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Recognized \\cr\nmerge_colval \\tab  \\tab  \\cr\n \\tab action       \\tab Specifies the column value of the merged range \\cr\n \\tab              \\tab to print in the table \\cr\n \\tab default      \\tab minimum col value of the merged range \\cr\n \\tab accepts      \\tab numeric(1) \\cr\n \\tab console      \\tab Recognized \\cr\n \\tab markdown     \\tab Recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Recognized \\cr\nna_string \\tab  \\tab  \\cr\n \\tab action       \\tab Designates the character string to use in place \\cr\n \\tab              \\tab of missing values \\cr\n \\tab default      \\tab NA \\cr\n \\tab accepts      \\tab character(1) \\cr\n \\tab console      \\tab Recognized \\cr\n \\tab markdown     \\tab Recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Recognized \\cr\npad \\tab  \\tab  \\cr\n \\tab action       \\tab Designates the padding to place between cell \\cr\n \\tab              \\tab text and boundaries \\cr\n \\tab              \\tab Measured in pixels. \\cr\n \\tab default      \\tab 0 \\cr\n \\tab accepts      \\tab numeric(1) \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Not recognized \\cr\nreplace \\tab  \\tab  \\cr\n \\tab action       \\tab Replaces existing cell values with user-specified \\cr\n \\tab              \\tab content. Replacement occurs moving down columns \\cr\n \\tab              \\tab from left to right. \\cr\n \\tab default      \\tab  \\cr\n \\tab accepts      \\tab character vector of the same length as the number \\cr\n \\tab              \\tab of cells being replaced. \\cr\n \\tab console      \\tab Recognized \\cr\n \\tab markdown     \\tab Recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Recognized \\cr\nrotate_degree \\tab  \\tab  \\cr\n \\tab action       \\tab Rotates text in cells by the designated angle \\cr\n \\tab              \\tab in degrees \\cr\n \\tab default      \\tab  \\cr\n \\tab accepts      \\tab numeric(1) \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Recognized \\cr\nround \\tab  \\tab  \\cr\n \\tab action       \\tab Applies the `round` function to values in the \\cr \n \\tab              \\tab cell.  Skips any character values it encounters. \\cr\n \\tab default      \\tab \\code{getOption(\"digits\")} \\cr\n \\tab accepts      \\tab numeric(1) \\cr\n \\tab console      \\tab Recognized \\cr\n \\tab markdown     \\tab Recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Recognized \\cr\nsanitize \\tab  \\tab  \\cr\n \\tab action\t      \\tab Sanitizes character values that may cause \\cr\n \\tab              \\tab difficulties for the rendered format.  \\cr\n \\tab default\t    \\tab FALSE      \\cr\n \\tab accepts\t    \\tab logical(1) \\cr\n \\tab console\t    \\tab Not recognized \\cr\n \\tab markdown\t    \\tab Not recognized \\cr\n \\tab html         \\tab Not recognized \\cr\n \\tab latex\t      \\tab Recognized.  Sanitization is performed using \\cr\n \\tab              \\tab \\code{\\link[Hmisc]{latexTranslate}} \\cr\nsanitize_args\t\\tab \\tab \\cr\n \\tab action\t      \\tab Passes additional arguments to \\code{\\link[Hmisc]{latexTranslate}} \\cr\n \\tab default\t    \\tab \\code{list()} \\cr\n \\tab accepts\t    \\tab list.  See documentation for \\code{\\link[Hmisc]{latexTranslate}} \\cr\n \\tab              \\tab for details \\cr\n \\tab console\t    \\tab Not recognized \\cr\n \\tab markdown\t    \\tab Not recognized \\cr\n \\tab html\t        \\tab Not recognized \\cr\n \\tab latex\t      \\tab Recognized \\cr\ntabcolsep \\tab  \\tab  \\cr\n \\tab action       \\tab Modifies the LaTeX `tabcolsep` parameter of tables \\cr\n \\tab              \\tab This is similar to `pad` for HTML tables, but only  \\cr\n \\tab              \\tab affects the space between columns. Measured in \"pt\" \\cr\n \\tab default      \\tab 6 \\cr\n \\tab accepts      \\tab numeric(1) \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Not recognized \\cr\n \\tab latex        \\tab Recognized \\cr\nvalign \\tab  \\tab  \\cr\n \\tab action       \\tab Designates the vertical alignment of a cell. \\cr\n \\tab default      \\tab  \\cr\n \\tab accepts      \\tab \"top\", \"middle\", \"bottom\" \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Recognized \\cr\nwidth \\tab  \\tab  \\cr\n \\tab action       \\tab Sets the width of the cell \\cr\n \\tab default      \\tab  \\cr\n \\tab accepts      \\tab numeric(1) \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Recognized \\cr\nwidth_units \\tab  \\tab  \\cr\n \\tab action       \\tab Determines the units in which `width` is measured \\cr\n \\tab default      \\tab \"pt\" \\cr\n \\tab accepts      \\tab \"px\", \"pt\", \"cm\", \"in\", \"\\%\" \\cr\n \\tab console      \\tab Not recognized \\cr\n \\tab markdown     \\tab Not recognized \\cr\n \\tab html         \\tab Recognized \\cr\n \\tab latex        \\tab Recognized; \"px\" is coerced to \"pt\" \\cr\n}\n}\n\n\\section{Longtable}{\n\nThe \\code{longtable} feature is named for the LaTeX package used to break very large \ntables into multiple pages.  \n\nWhen using the \\code{longtable=TRUE} option, the default number of rows per table is 25 for \nconsole, HTML, and markdown output.  For LaTeX output, the number of rows is determined by \nthe LaTeX \\code{longtable} package's algorithm. The number of rows per table only considers \nthe content in the body of the table.  Consideration for the number of rows in the head and \nfoot are the responsibility of the user.\n  \nWhenever a table is broken into multiple parts, each part retains the table head.  If any \n\\code{interfoot} is provided, it is appended to the bottom of each section, with the \nexception of the last section.  The last section has the \\code{foot} appended.\n}\n\n\\section{Colors}{\n\nColors may be declared as any of the color names in \\code{colors()}, \nas rgb character strings such as \\code{\"rgb(rrr,ggg,bbb)\"} or as \nhexadecimal character strings such as \\code{\"#rrggbb\"}.  \n\nTransparency is also recognized by HTML output, and may be indicated \nin the rgba format \\code{\"rgba(rrr,ggg,bbb,aa)\"}, where \\code{aa} is a \nnumber between 0 and 1, inclusive.  Alternative, transparency may be \ngiven as \\code{\"#rrggbbAA\"}, where \\code{AA} is a hexadecimal \nrepresentation of transparency with \"00\" being completely transparent \nand \"FF\" being completely opaque.\n\nLaTeX output does not recognize transparency and will quietly drop the \ntransparency parameter.\n\nAll colors are internally translated into rgb format and are case insensitive.\n}\n\n\\section{Required LaTeX Packages}{\n\n\nIf you will be using the LaTeX output, some sprinkles will require you \nto include additional LaTeX packages in your document preamble.  In \n\\code{.Rnw} files, additional packages can be included with the \n\\code{\\\\usepackage\\{[package]\\}} syntax.  In markdown, additional packages\nare included using \\code{header-includes:} in the YAML front matter with \na line of the format \\code{\\\\usepackage\\{[package]\\}} for each package to \nbe used.  Sprinkles that require additional packages, and the LaTeX packages\nrequired, are listed below:\n\n\\tabular{ll}{\n  Sprinkle \\tab LaTeX Package(s) \\cr\n  \\code{font_color} \\tab \\code{\\\\usepackage[dvipsnames]\\{xcolor\\}} \\cr\n  \\code{bg, bg_pattern} \\tab \\code{\\\\usepackage[dvipsnames,table]\\{xcolor\\}} \\cr\n  \\code{border_style} \\tab \\code{\\\\usepackage\\{arydshln\\}} \\cr\n      \\tab  \\code{\\\\usepackage\\{amssymb\\}} \\cr\n      \\tab  \\code{\\\\usepackage\\{hhline\\}} \\cr\n      (with vertical dashed lines) \\tab \\\\usepackage\\{graphicx\\} \\cr\n      \\tab \\code{\\\\makeatletter} \\cr\n      \\tab \\code{\\\\newcommand*\\\\vdashline\\{\\\\rotatebox[origin=c]\\{90\\}\\{\\$\\\\dabar@\\\\dabar@\\\\dabar@\\$\\}\\}} \\cr\n      \\tab \\code{\\\\makeatother} \\cr\n  \\code{longtable} \\tab \\code{\\\\usepackage\\{longtable\\}} \\cr\n      \\tab (Must be loaded before \\code{arydshln}) \\cr\n  \\code{merge} \\tab \\code{\\\\usepackage\\{multirow\\}} \\cr\n  \\code{captions} for non floats \\tab \\code{\\\\usepackage\\{caption\\}} \n}\n\nNote that \\code{hhline} is used to make horizontal lines when \n\\code{options(pixiedust_latex_hhline = TRUE)} (the package default is \\code{FALSE}), \notherwise the \\code{cline} command is used.  \n\nUse of \\code{cline} permits colored borders and dashed borders, but \nborders around cells with background colors are sometimes (often) lost.\n\nUse of \\code{hhline} preserves borders around cells with background colors \nand permits double borders, but colored and dashed borders are not available.\n\nIn order to ensure all features are available, the recommended code block (accounting for \nthe proper order to load packages) is:\n\n\\code{header-includes:} \\cr\n\\code{ - \\\\usepackage\\{amssymb\\}} \\cr\n\\code{ - \\\\usepackage\\{arydshln\\}} \\cr\n\\code{ - \\\\usepackage\\{caption\\}}  \\cr\n\\code{ - \\\\usepackage\\{graphicx\\}} \\cr\n\\code{ - \\\\usepackage\\{hhline\\}} \\cr\n\\code{ - \\\\usepackage\\{longtable\\}} \\cr\n\\code{ - \\\\usepackage\\{multirow\\}} \\cr\n\\code{ - \\\\usepackage[dvipsnames,table]\\{xcolor\\}} \\cr\n\\code{ - \\\\makeatletter} \\cr\n\\code{ - \\\\newcommand*\\\\vdashline\\{\\\\rotatebox[origin=c]\\{90\\}\\{\\$\\\\dabar@\\\\dabar@\\\\dabar@\\$\\}\\}} \\cr\n\\code{ - \\\\makeatother}\n}\n\n\\examples{\nx <- dust(lm(mpg ~ qsec + factor(am), data = mtcars))\nx \\%>\\% sprinkle(cols = 2:4, round = 3) \\%>\\% \n  sprinkle(cols = 5, fn = quote(pvalString(value))) \\%>\\% \n  sprinkle(rows = 2, bold = TRUE)\n\n}\n\\seealso{\n\\code{\\link{sprinkle_colnames}} for changing column names in a table.\n}\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "man/sprinkle_align.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_align.R\n\\name{sprinkle_align}\n\\alias{sprinkle_align}\n\\alias{sprinkle_align.default}\n\\alias{sprinkle_align.dust_list}\n\\title{Sprinkle Alignment of Table Cells}\n\\usage{\nsprinkle_align(\n  x,\n  rows = NULL,\n  cols = NULL,\n  halign = NULL,\n  valign = NULL,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\n\\method{sprinkle_align}{default}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  halign = NULL,\n  valign = NULL,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\n\\method{sprinkle_align}{dust_list}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  halign = NULL,\n  valign = NULL,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{rows}{Either a numeric vector of rows in the tabular object to be \nmodified or an object of class \\code{call}.  When a \\code{call}, \ngenerated by \\code{quote(expression)}, the expression resolves to \na logical vector the same length as the number of rows in the table.\nSprinkles are applied to where the expression resolves to \\code{TRUE}.}\n\n\\item{cols}{Either a numeric vector of columns in the tabular object to\nbe modified, or a character vector of column names. A mixture of \ncharacter and numeric indices is permissible.}\n\n\\item{halign}{\\code{character} One of \\code{\"left\"}, \\code{\"center\"}, \nor \\code{\"right\"}. Defaults to \\code{NULL}, for no change to the \ncurrent value.}\n\n\\item{valign}{\\code{character} One of \\code{\"top\"}, \\code{\"middle\"}, \nor \\code{\"bottom\"}. Defaults to \\code{NULL}, for no change to the \ncurrent value.}\n\n\\item{part}{A character string denoting which part of the table to modify.}\n\n\\item{fixed}{\\code{logical(1)} indicating if the values in \\code{rows} \nand \\code{cols} should be read as fixed coordinate pairs.  By default, \nsprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \nmeaning that the arguments do not have to share the same length.  \nWhen \\code{fixed = TRUE}, they must share the same length.}\n\n\\item{recycle}{A \\code{character} one that determines how sprinkles are \nmanaged when the sprinkle input doesn't match the length of the region\nto be sprinkled.  By default, recycling is turned off.  Recycling \nmay be performed across rows first (left to right, top to bottom), \nor down columns first (top to bottom, left to right).}\n\n\\item{...}{Additional arguments to pass to other methods. Currently ignored.}\n}\n\\description{\nThe alignment refers to the positioning of the text within\n  a cell.  Alignment may be given relative to the left, center, or right\n  of a cell, and the top, middle, or bottom of the cell.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item Correctly reassigns the appropriate elements of \\code{halign} \n   and \\code{valign} columns in the table part.\n \\item Casts an error if \\code{x} is not a \\code{dust} object.\n \\item Casts an error if \\code{halign} is not a \\code{character}\n \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n   \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\n \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\n   \\code{\"rows\"}, or \\code{\"cols\"}\n \\item Casts an error if \\code{valign} is not a \\code{character}\n \\item Cast an error if \\code{recycle = \"none\"} and \\code{halign} does\n   not have length 1.\n \\item Cast an error if \\code{recycle = \"none\"} and \\code{valign} does\n   not have length 1.\n \\item Cast an error if \\code{halign} is not one of \\code{c(\"left\", \"center\", \"right\")}\n \\item Cast an error if \\code{valign} is not one of \\code{c(\"top\", \"middle\", \"bottom\")}\n}\n\nThe functional behavior of the \\code{fixed} and \\code{recycle} arguments \nis not tested for this function. It is tested and validated in the\ntests for \\code{\\link{index_to_sprinkle}}.\n}\n\n\\seealso{\n\\code{\\link{sprinkle}}, \n  \\code{\\link{index_to_sprinkle}}\n}\n"
  },
  {
    "path": "man/sprinkle_bg.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_bg.R\n\\name{sprinkle_bg}\n\\alias{sprinkle_bg}\n\\alias{sprinkle_bg.default}\n\\alias{sprinkle_bg.dust_list}\n\\alias{sprinkle_background}\n\\title{Sprinkle the Background Color of a Cell}\n\\usage{\nsprinkle_bg(\n  x,\n  rows = NULL,\n  cols = NULL,\n  bg = \"\",\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\n\\method{sprinkle_bg}{default}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  bg = \"\",\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\n\\method{sprinkle_bg}{dust_list}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  bg = \"\",\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\nsprinkle_background(\n  x,\n  rows = NULL,\n  cols = NULL,\n  bg = \"\",\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{rows}{Either a numeric vector of rows in the tabular object to be \nmodified or an object of class \\code{call}.  When a \\code{call}, \ngenerated by \\code{quote(expression)}, the expression resolves to \na logical vector the same length as the number of rows in the table.\nSprinkles are applied to where the expression resolves to \\code{TRUE}.}\n\n\\item{cols}{Either a numeric vector of columns in the tabular object to\nbe modified, or a character vector of column names. A mixture of \ncharacter and numeric indices is permissible.}\n\n\\item{bg}{\\code{character(1)} A character string giving a color for the \nbackground of the chosen cells.}\n\n\\item{part}{A character string denoting which part of the table to modify.}\n\n\\item{fixed}{\\code{logical(1)} indicating if the values in \\code{rows} \nand \\code{cols} should be read as fixed coordinate pairs.  By default, \nsprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \nmeaning that the arguments do not have to share the same length.  \nWhen \\code{fixed = TRUE}, they must share the same length.}\n\n\\item{recycle}{A \\code{character} one that determines how sprinkles are \nmanaged when the sprinkle input doesn't match the length of the region\nto be sprinkled.  By default, recycling is turned off.  Recycling \nmay be performed across rows first (left to right, top to bottom), \nor down columns first (top to bottom, left to right).}\n\n\\item{...}{Additional arguments to pass to other methods. Currently ignored.}\n}\n\\description{\nBackground colors may be used to highlight the contents \n  of cells, rows, or columns.  Most commonly, backgrounds are used to\n  provide row discrimination; the \\code{sprinkle_bg_pattern} function\n  is better suited to that purpose.\n}\n\\details{\nColors may be a dvips color name, or in the rgb(R, G, B), \nrgba(R, G, B, A), #RRGGBB, or #RRGGBBAA formats. \n  \nThis sprinkle is ignored in console and markdown outputs.  HTML output\nwill accept any of the color formats and recognize transparency.  LaTeX\noutput will accept any of the color formats but ignore transparency.\n\nAs long as \\code{bg} is required to be a \\code{character(1)}, the \n\\code{recycle} argument is kind of useless. It is included to maintain\nconsistency with the \\code{index_to_sprinkle} function. Future development\nmay permit a character vector of colors.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item Correctly reassigns the appropriate elements \\code{bg} column\n   in the table part.\n \\item Casts an error if \\code{x} is not a \\code{dust} object.\n \\item Casts an error if \\code{bg} is not a \\code{character(1)}\n \\item Casts an error if \\code{bg} is not a valid color format.\n \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n   \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\n \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\n   \\code{\"rows\"}, or \\code{\"cols\"}\n \\item Casts an error if \\code{recycle = \"none\"} and \\code{bg} does not\n   have length 1.\n}\n\nThe functional behavior of the \\code{fixed} and \\code{recycle} arguments \nis not tested for this function. It is tested and validated in the\ntests for \\code{\\link{index_to_sprinkle}}.\n}\n\n\\seealso{\n\\code{\\link{sprinkle}}, \\code{\\link{sprinkle_bg_pattern}}, \n  \\code{\\link{index_to_sprinkle}}\n}\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "man/sprinkle_bg_pattern.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_bg_pattern.R\n\\name{sprinkle_bg_pattern}\n\\alias{sprinkle_bg_pattern}\n\\alias{sprinkle_bg_pattern.default}\n\\alias{sprinkle_bg_pattern.dust_list}\n\\title{Row and Column Background Striping}\n\\usage{\nsprinkle_bg_pattern(\n  x,\n  rows = NULL,\n  cols = NULL,\n  bg_pattern = c(\"transparent\", \"#DCDCDC\"),\n  bg_pattern_by = c(\"rows\", \"cols\"),\n  ...,\n  part = c(\"body\", \"head\", \"foot\", \"interoot\", \"table\")\n)\n\n\\method{sprinkle_bg_pattern}{default}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  bg_pattern = c(\"transparent\", \"#DCDCDC\"),\n  bg_pattern_by = c(\"rows\", \"cols\"),\n  ...,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\")\n)\n\n\\method{sprinkle_bg_pattern}{dust_list}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  bg_pattern = c(\"transparent\", \"#DCDCDC\"),\n  bg_pattern_by = c(\"rows\", \"cols\"),\n  ...,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\")\n)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{rows}{Either a numeric vector of rows in the tabular object to be \nmodified or an object of class \\code{call}.  When a \\code{call}, \ngenerated by \\code{quote(expression)}, the expression resolves to \na logical vector the same length as the number of rows in the table.\nSprinkles are applied to where the expression resolves to \\code{TRUE}.}\n\n\\item{cols}{Either a numeric vector of columns in the tabular object to\nbe modified, or a character vector of column names. A mixture of \ncharacter and numeric indices is permissible.}\n\n\\item{bg_pattern}{A character vector giving the colors to be iterated in \nthe pattern.}\n\n\\item{bg_pattern_by}{A subset of \\code{c(\"rows\", \"cols\")}, with partial\nmatching accepted.  Only the first value is used, and determines the \ndirection of the pattern.}\n\n\\item{...}{Additional arguments to pass to other methods. Currently ignored.}\n\n\\item{part}{A character string denoting which part of the table to modify.}\n}\n\\description{\nProvides background color striping based on row or column.\n  Striping may be done with any number of colors. The most common use of \n  striping is to provide row discrimination in tables.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n  \\item Correctly reassigns the appropriate elements \\code{bg} column\n   in the table part.\n \\item Casts an error if \\code{x} is not a \\code{dust} object.\n \\item Casts an error if \\code{bg_pattern} is not a character vector.\n \\item Casts an error if any element in \\code{bg_pattern} is not a valid\n   color name.\n \\item Casts an error if \\code{bg_pattern_by} is not a subset of \n   \\code{c(\"rows\", \"columns\")} (with partial matching).\n \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n   \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n}\n\nThis is a rare sprinkle that doesn't use the \\code{fixed} and \\code{recycle}\narguments.  They are assumed to be \\code{FALSE} and \\code{\"none\"}, \nrespectively, in order to pass through \\code{index_to_sprinkle}.\n}\n\n\\seealso{\n\\code{\\link{sprinkle_bg}}, \\code{\\link{sprinkle}}, \n  \\code{\\link{index_to_sprinkle}}\n}\n"
  },
  {
    "path": "man/sprinkle_bookdown.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_bookdown.R\n\\name{sprinkle_bookdown}\n\\alias{sprinkle_bookdown}\n\\alias{sprinkle_bookdown.default}\n\\alias{sprinkle_bookdown.dust_list}\n\\title{Change the Bookdown Property in a Dust Table}\n\\source{\n\\url{https://bookdown.org/yihui/bookdown/tables.html}\n}\n\\usage{\nsprinkle_bookdown(x, bookdown = getOption(\"pixie_bookdown\", FALSE), ...)\n\n\\method{sprinkle_bookdown}{default}(x, bookdown = getOption(\"pixie_bookdown\", FALSE), ...)\n\n\\method{sprinkle_bookdown}{dust_list}(x, bookdown = getOption(\"pixie_bookdown\", FALSE), ...)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{bookdown}{\\code{logical(1)} indicating if the table is being produced\nin a \\code{bookdown} document.}\n\n\\item{...}{Additional arguments to pass to other methods. Currently ignored.}\n}\n\\description{\nTables built for the \\code{bookdown} package can be referenced\n  in a manner that is consistent between HTML and LaTeX documents.\n}\n\\details{\n\\code{bookdown} is a package that facilitates the writing of books.\n  One of the advantages of \\code{bookdown} is the ability to reference \n  tables in a manner similar to LaTeX. The key difference in how \n  \\code{pixiedust} handles output is the reference specification. See \n  \\url{https://bookdown.org/yihui/bookdown/tables.html} for details on how\n  \\code{bookdown} uses labels and references.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item Change the \\code{bookdown} attribute of the \\code{dust} object.\n \\item Cast an error if \\code{x} is not a \\code{dust} object.\n \\item Cast an error if \\code{bookdown} is not a logical object.\n \\item Cast an error if \\code{bookdown} has length greater than 1.\n}\n}\n\n\\seealso{\n\\code{\\link{dust}}, \\code{\\link{sprinkle}}\n}\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "man/sprinkle_border.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_border.R\n\\name{sprinkle_border}\n\\alias{sprinkle_border}\n\\alias{sprinkle_border.default}\n\\alias{sprinkle_border.dust_list}\n\\title{Sprinkle Changes to Cell Borders}\n\\usage{\nsprinkle_border(\n  x,\n  rows,\n  cols,\n  border = c(\"all\", \"bottom\", \"left\", \"top\", \"right\"),\n  border_color = \"black\",\n  border_style = \"solid\",\n  border_thickness = 1,\n  border_units = c(\"pt\", \"px\"),\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\n\\method{sprinkle_border}{default}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  border = c(\"all\", \"bottom\", \"left\", \"top\", \"right\"),\n  border_color = \"black\",\n  border_style = \"solid\",\n  border_thickness = 1,\n  border_units = c(\"pt\", \"px\"),\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\n\\method{sprinkle_border}{dust_list}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  border = c(\"all\", \"bottom\", \"left\", \"top\", \"right\"),\n  border_color = \"black\",\n  border_style = \"solid\",\n  border_thickness = 1,\n  border_units = c(\"pt\", \"px\"),\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{rows}{Either a numeric vector of rows in the tabular object to be \nmodified or an object of class \\code{call}.  When a \\code{call}, \ngenerated by \\code{quote(expression)}, the expression resolves to \na logical vector the same length as the number of rows in the table.\nSprinkles are applied to where the expression resolves to \\code{TRUE}.}\n\n\\item{cols}{Either a numeric vector of columns in the tabular object to\nbe modified, or a character vector of column names. A mixture of \ncharacter and numeric indices is permissible.}\n\n\\item{border}{One or more of \\code{\"all\"}, \\code{\"bottom\"}, \\code{\"left\"},\n\\code{\"top\"}, or \\code{\"right\"}. Partial matching is supported. Designates\nthe side of the chosen cells for which borders should be modified.}\n\n\\item{border_color}{\\code{character(1)} A character string giving a color for the \nbackground of the chosen cells. \\code{NULL} makes no change to the current\nvalue.}\n\n\\item{border_style}{\\code{character(1)} setting the border style for the \ncell.  One of \\code{\"solid\"}, \\code{\"dashed\"}, \\code{\"dotted\"}, \n\\code{\"double\"}, \\code{\"groove\"}, \\code{\"ridge\"}, \\code{\"inset\"},\n\\code{\"outset\"}, \\code{\"hidden\"}, or \\code{\"none\"}. \\code{NULL} makes no \nchange to the current value.}\n\n\\item{border_thickness}{\\code{numeric(1)}. Sets the thickness of the border.\n\\code{NULL} makes no change to the current value.}\n\n\\item{border_units}{\\code{character(1)}. Sets the unit of measure for the\nborder thickness.  May be either \\code{\"pt\"}, \\code{\"px\"}. \\code{NULL} \nmakes no change to the current value.}\n\n\\item{part}{A character string denoting which part of the table to modify.}\n\n\\item{fixed}{\\code{logical(1)} indicating if the values in \\code{rows} \nand \\code{cols} should be read as fixed coordinate pairs.  By default, \nsprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \nmeaning that the arguments do not have to share the same length.  \nWhen \\code{fixed = TRUE}, they must share the same length.}\n\n\\item{recycle}{A \\code{character} one that determines how sprinkles are \nmanaged when the sprinkle input doesn't match the length of the region\nto be sprinkled.  By default, recycling is turned off.  Recycling \nmay be performed across rows first (left to right, top to bottom), \nor down columns first (top to bottom, left to right).}\n\n\\item{...}{Additional arguments to pass to other methods. Currently ignored.}\n}\n\\description{\nCell borders may be used to give visual structure to a table.\n  Borders may generate distinction between sets of results, groups, \n  or types of output.\n}\n\\details{\nThis sprinkle has no effect on console and markdown output.\n\nHTML output accepts all of the possible values of \\code{border_style}.\n\nFor LaTeX output, when \\code{hhline = FALSE}, \\code{\"solid\"}, \\code{\"dashed\"},\n\\code{\"dotted\"}, \\code{\"hidden\"}, and \\code{\"none\"} are accepted.  \n\\code{\"dotted\"} will silently be treated as \\code{\"dashed\"}, and \n\\code{\"hidden\"} is the equivalent of \\code{\"none\"}.\n\nFor LaTeX output when \\code{hhline = TRUE}, \\code{\"solid\"}, \\code{\"double\"},\n\\code{\"hidden\"}, and \\code{\"none\"} are accepted.  \\code{\"hidden\"} is the\nequivalent of \\code{\"none\"}.\n\nWhen a value of \\code{border_style} is not recognized by an output format, \nit is silently ignored.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item Correctly reassigns the \\code{left_border}, \\code{right_border},\n   \\code{top_border} and \\code{bottom_border} columns in the table part.\n \\item Casts an error if \\code{x} is not a \\code{dust} object.\n \\item Casts an error if any element of \\code{border} is not one of \n   \\code{\"all\"}, \\code{\"bottom\"}, \\code{\"left\"}, \\code{\"top\"}, or \n   \\code{\"right\"}.\n \\item Casts an error if \\code{border_color} is not a \\code{character(1)}\n \\item Casts an error if \\code{border_color} is not a valid color format.\n \\item Casts an error if \\code{border_style} is not one of \\code{\"solid\"}, \n   \\code{\"dashed\"}, \\code{\"dotted\"}, \\code{\"double\"}, \\code{\"groove\"},\n   \\code{\"ridge\"}, \\code{\"inset\"}, \\code{\"outset\"}, \\code{\"hidden\"}, \n   \\code{\"none\"}\n \\item Casts an error if \\code{border_thickness} is not a \\code{numeric(1)}.\n \\item Casts an error if \\code{border_units} is not one of \\code{\"pt\"} or \n   \\code{\"px\"}.\n \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n   \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\n \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\n   \\code{\"rows\"}, or \\code{\"cols\"}\n \\item Cast an error if \\code{recycle = \"none\"} and \\code{border_color}\n   does not have length 1.\n \\item Cast an error if \\code{recycle = \"none\"} and \\code{border_style}\n   does not have length 1.\n \\item Cast an error if \\code{recycle = \"none\"} and \\code{border_thickness}\n   does not have length 1.\n \\item Quietly restrict \\code{border_units} to just the first element if\n   is has length > 1 and \\code{recycle = \"none\"}.\n}\n}\n\n\\seealso{\n\\code{\\link{sprinkle}}, \\code{\\link{index_to_sprinkle}}\n}\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "man/sprinkle_border_collapse.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_border_collapse.R\n\\name{sprinkle_border_collapse}\n\\alias{sprinkle_border_collapse}\n\\alias{sprinkle_border_collapse.default}\n\\alias{sprinkle_border_collapse.dust_list}\n\\title{Change the Border Collapse Property in a Dust Table}\n\\source{\n\\url{https://www.w3schools.com/cssref/pr_border-collapse.asp}\n}\n\\usage{\nsprinkle_border_collapse(\n  x,\n  border_collapse = getOption(\"pixie_border_collapse\", \"collapse\"),\n  ...\n)\n\n\\method{sprinkle_border_collapse}{default}(\n  x,\n  border_collapse = getOption(\"pixie_border_collapse\", \"collapse\"),\n  ...\n)\n\n\\method{sprinkle_border_collapse}{dust_list}(\n  x,\n  border_collapse = getOption(\"pixie_border_collapse\", \"collapse\"),\n  ...\n)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{border_collapse}{\\code{character(1)}. Defaults to \\code{\"collapse\"}, \nand may accept any of \\code{\"collapse\"}, \\code{\"separate\"}, \n\\code{\"initial\"}, or \\code{\"inherit\"}.}\n\n\\item{...}{Additional arguments to pass to other methods. Currently ignored.}\n}\n\\description{\nThe \\code{border_collapse} property controls the appearance of \n  cell borders in HTML tables.  Be default, \\code{pixiedust} collapses \n  the borders so that the adjoining border of two cells appear as a \n  single border.\n}\n\\details{\nSee \\url{https://www.w3schools.com/cssref/pr_border-collapse.asp} \nfor details on how each option affects the appearance of a table.\n\nThis property has no effect on non-HTML output.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item Change the \\code{border_collapse} attribute of the \\code{dust} object.\n \\item Cast an error if \\code{x} is not a \\code{dust} object.\n \\item Cast an error if \\code{border_collapse} is not one of \n   \\code{\"collapse\"}, \\code{\"separate\"}, \\code{\"initial\"}, \\code{\"inherit\"}.\n}\n}\n\n\\seealso{\n\\code{\\link{dust}}, \\code{\\link{sprinkle}}\n}\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "man/sprinkle_caption.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_caption.R\n\\name{sprinkle_caption}\n\\alias{sprinkle_caption}\n\\alias{sprinkle_caption.default}\n\\alias{sprinkle_caption.dust_list}\n\\title{Change the Caption in a Dust Table}\n\\usage{\nsprinkle_caption(x, caption, ...)\n\n\\method{sprinkle_caption}{default}(x, caption, ...)\n\n\\method{sprinkle_caption}{dust_list}(x, caption, ...)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{caption}{\\code{character(1)} giving the new caption for the table.}\n\n\\item{...}{Additional arguments to pass to other methods. Currently ignored.}\n}\n\\description{\nThe table caption is often used as a brief title, but may also \n  be used to provide a longer statement explaining how to interpret the \n  table results.\n}\n\\details{\nThe caption may be set during the initial \\code{dust} call.  This\n  method allows for modification afterward, such as in the case of when a \n  \\code{dust} object is loaded from memory and the initial call cannot be\n  accessed.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item Change the \\code{caption} attribute of the \\code{dust} object.\n \\item Cast an error if \\code{x} is not a \\code{dust} object.\n \\item Cast an error if \\code{caption} is not a character object.\n \\item Cast an error if \\code{caption} has length greater than 1.\n}\n}\n\n\\seealso{\n\\code{\\link{dust}}, \\code{\\link{sprinkle}}\n}\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "man/sprinkle_caption_number.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_caption_number.R\n\\name{sprinkle_caption_number}\n\\alias{sprinkle_caption_number}\n\\alias{sprinkle_caption_number.default}\n\\alias{sprinkle_caption_number.dust_list}\n\\title{Change the Caption in a Dust Table}\n\\usage{\nsprinkle_caption_number(x, caption_number, ...)\n\n\\method{sprinkle_caption_number}{default}(\n  x,\n  caption_number = getOption(\"pixie_caption_number\", TRUE),\n  ...\n)\n\n\\method{sprinkle_caption_number}{dust_list}(\n  x,\n  caption_number = getOption(\"pixie_caption_number\", TRUE),\n  ...\n)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{caption_number}{\\code{logical(1)} When \\code{TRUE}, the table caption \nis prefixed with \"Table #\". Table numbering is suppressed when \n\\code{FALSE}.  When numbering is suppressed, the table number counter\nwill not increment.}\n\n\\item{...}{Additional arguments to pass to other methods. Currently ignored.}\n}\n\\description{\nThe table caption is often used as a brief title, but may also \n  be used to provide a longer statement explaining how to interpret the \n  table results.\n}\n\\details{\nTable numbering makes it possible to reference tables within a \n  document.  In some cases, the numbering is not desired. Suppressing \n  numbering may restrict the ability to make reference to the table.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item Change the \\code{caption_number} attribute of the \\code{dust} object.\n \\item Cast an error if \\code{x} is not a \\code{dust} object.\n \\item Cast an error if \\code{caption_number} is not a logical object.\n \\item Cast an error if \\code{caption_number} has length greater than 1.\n}\n}\n\n\\seealso{\n\\code{\\link{dust}}, \\code{\\link{sprinkle}}\n}\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "man/sprinkle_colnames.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_colnames.R\n\\name{sprinkle_colnames}\n\\alias{sprinkle_colnames}\n\\alias{sprinkle_colnames.default}\n\\alias{sprinkle_colnames.dust_list}\n\\title{Column Names for \\code{dust} Tables}\n\\usage{\nsprinkle_colnames(x, ...)\n\n\\method{sprinkle_colnames}{default}(x, ...)\n\n\\method{sprinkle_colnames}{dust_list}(x, ...)\n}\n\\arguments{\n\\item{x}{A dust object.}\n\n\\item{...}{Column names for the table.  See 'Input Formats'}\n}\n\\description{\nAssigns new column names to a table\n}\n\\section{Input Formats}{\n\n\\itemize{\n  \\item{named arguments}{ Using \\code{dust_colnames(term = \"Term\", estimate = \"Estimate\")}, \n    column names may be passed for all or a subset of the columns.  The existing column\n    name will be matched against the argument name.}\n  \\item{unnamed arguments}{ Using \\code{dust_colnames(\"Term\", \"Estimate\", \"SE\", ...)}, \n    column names may be passed for all of the columns.  If the arguments are unnamed, the \n    number of arguments passed must match the number of columns in the table.}\n }\n When using named arguments (or a named vector), you may not mix named and unnamed elements.  \n In other words, if one element is named, they must all be named.  Unnamed elements are assigned\n to columns in sequential order.\n}\n\n\\examples{\nx <- dust(lm(mpg ~ qsec + factor(am), data = mtcars)) \nx\nx \\%>\\% sprinkle_colnames(term = \"Term\", statistic = \"T\")\nx \\%>\\% sprinkle_colnames(\"Term\", \"Estimate\", \"SE\", \"T-statistic\", \"p-value\")\n\\dontrun{\n# Causes an error due to too few unnamed arguments\nx \\%>\\% sprinkle_colnames(\"Term\", \"Estimate\")\n}\n}\n\\seealso{\n\\code{\\link{sprinkle}}\n}\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "man/sprinkle_discrete.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_discrete.R\n\\name{sprinkle_discrete}\n\\alias{sprinkle_discrete}\n\\alias{sprinkle_discrete.default}\n\\alias{sprinkle_discrete.dust_list}\n\\title{Change Color Features by Discrete Values}\n\\usage{\nsprinkle_discrete(\n  x,\n  rows = NULL,\n  cols = NULL,\n  discrete = \"bg\",\n  discrete_colors = getOption(\"pixie_discrete_pal\", NULL),\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\n\\method{sprinkle_discrete}{default}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  discrete = \"bg\",\n  discrete_colors = getOption(\"pixie_discrete_pal\", NULL),\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\n\\method{sprinkle_discrete}{dust_list}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  discrete = \"bg\",\n  discrete_colors = getOption(\"pixie_discrete_pal\", NULL),\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{rows}{Either a numeric vector of rows in the tabular object to be \nmodified or an object of class \\code{call}.  When a \\code{call}, \ngenerated by \\code{quote(expression)}, the expression resolves to \na logical vector the same length as the number of rows in the table.\nSprinkles are applied to where the expression resolves to \\code{TRUE}.}\n\n\\item{cols}{Either a numeric vector of columns in the tabular object to\nbe modified, or a character vector of column names. A mixture of \ncharacter and numeric indices is permissible.}\n\n\\item{discrete}{\\code{character}. A subset of \\code{c(\"bg\", \"font\", \n\"font_color\", \"border\", \"left_border\", \"top_border\", \"right_border\",\n\"bottom_border\")}.}\n\n\\item{discrete_colors}{\\code{character}. Gives the color palette to be \nused. Each value must be a valid color.  Defaults to evenly spaced\ncolors over the color space.}\n\n\\item{part}{A character string denoting which part of the table to modify.}\n\n\\item{fixed}{\\code{logical(1)} indicating if the values in \\code{rows} \nand \\code{cols} should be read as fixed coordinate pairs.  By default, \nsprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \nmeaning that the arguments do not have to share the same length.  \nWhen \\code{fixed = TRUE}, they must share the same length.}\n\n\\item{recycle}{A \\code{character} one that determines how sprinkles are \nmanaged when the sprinkle input doesn't match the length of the region\nto be sprinkled.  By default, recycling is turned off.  Recycling \nmay be performed across rows first (left to right, top to bottom), \nor down columns first (top to bottom, left to right).}\n\n\\item{...}{Additional arguments to pass to other methods. Currently ignored.}\n}\n\\description{\nDistinct values within a range will be assigned a color and\n  the designated attribute of the table will be modified accordingly.\n}\n\\details{\nThis sprinkle is only recognized by HTML and LaTeX.  All of the \n  \\code{height_units} values are recognized by HTML.  For LaTeX, \\code{\"px\"}\n  is converted to \\code{\"pt\"}. \n  \n\\code{\"font\"} and \\code{\"font_color\"} both change the font color.\n\n\\code{\"border\"} is a shortcut to specify all borders.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item Correctly reassigns the appropriate elements of the \\code{bg},\n   \\code{font_color}, \\code{left_border}, \\code{top_border},\n   \\code{right_border}, or \\code{bottom_border} column in the table part.\n \\item Casts an error if \\code{x} is not a \\code{dust} object.\n \\item Casts an error if \\code{discrete} is not a subset of \n   \\code{c(\"bg\", \"font\", \"font_color\", \"border\", \"left_border\",\n           \"right_border\", \"top_border\", \"bottom_border\")}\n \\item Casts an error if \\code{discrete_colors} is not a \\code{character}\n   value.\n \\item Casts an error if any value of \\code{discrete_colors} is not a\n   recognized color value.\n \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n   \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\n \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\n   \\code{\"rows\"}, or \\code{\"cols\"}\n}\n\nThe functional behavior of the \\code{fixed} and \\code{recycle} arguments \nis not tested for this function. It is tested and validated in the\ntests for \\code{\\link{index_to_sprinkle}}.\n}\n\n\\seealso{\n\\code{\\link{sprinkle}}, \n  \\code{\\link{index_to_sprinkle}}\n}\n"
  },
  {
    "path": "man/sprinkle_fixed_header.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_fixed_header.R\n\\name{sprinkle_fixed_header}\n\\alias{sprinkle_fixed_header}\n\\alias{sprinkle_fixed_header.default}\n\\alias{sprinkle_fixed_header.dust_list}\n\\title{Assign a Fixed Header to an HTML Table}\n\\usage{\nsprinkle_fixed_header(\n  x,\n  fixed_header = TRUE,\n  include_fixed_header_css = TRUE,\n  fixed_header_class_name = \"pixie-fixed\",\n  scroll_body_height = 300,\n  scroll_body_height_units = \"px\",\n  scroll_body_background_color = \"white\",\n  fixed_header_height = 20,\n  fixed_header_height_units = \"px\",\n  fixed_header_text_height = fixed_header_height/2,\n  fixed_header_text_height_units = \"px\",\n  fixed_header_background_color = \"white\",\n  ...\n)\n\n\\method{sprinkle_fixed_header}{default}(\n  x,\n  fixed_header = TRUE,\n  include_fixed_header_css = TRUE,\n  fixed_header_class_name = \"pixie-fixed\",\n  scroll_body_height = 300,\n  scroll_body_height_units = \"px\",\n  scroll_body_background_color = \"white\",\n  fixed_header_height = 20,\n  fixed_header_height_units = \"px\",\n  fixed_header_text_height = fixed_header_height/2,\n  fixed_header_text_height_units = \"px\",\n  fixed_header_background_color = \"white\",\n  ...\n)\n\n\\method{sprinkle_fixed_header}{dust_list}(\n  x,\n  fixed_header = TRUE,\n  include_fixed_header_css = TRUE,\n  fixed_header_class_name = \"pixie-fixed\",\n  scroll_body_height = 300,\n  scroll_body_height_units = \"px\",\n  scroll_body_background_color = \"white\",\n  fixed_header_height = 20,\n  fixed_header_height_units = \"px\",\n  fixed_header_text_height = fixed_header_height/2,\n  fixed_header_text_height_units = \"px\",\n  fixed_header_background_color = \"white\",\n  ...\n)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{fixed_header}{\\code{logical(1)}. When \\code{TRUE}, HTML output will\nproduce a table with a fixed header and a scrollable body.}\n\n\\item{include_fixed_header_css}{\\code{logical(1)}. When \\code{TRUE}, the CSS code to\nproduce the table is inserted directly ahead of the HTML code for the\ntable.  When \\code{FALSE}, the CSS is omitted and assumed to be provided\nby the user.  This may be beneficial if the user has defined CSS styles\nfor their tables.  In this case, the user will need to add CSS classes\nto their customized CSS to accomodate the fixed headers.  See Avoiding\nCSS Conflicts.}\n\n\\item{fixed_header_class_name}{\\code{character(1)}. When \n\\code{include_fixed_header_css = FALSE}, this\nclass name is used to reference CSS classes provided by the user to\nformat the table correctly.}\n\n\\item{scroll_body_height}{\\code{integerish(1)}. Sets the height of the scrollable\ntable body.}\n\n\\item{scroll_body_height_units}{\\code{character(1)}. Determines the units for the\nheight of the scrollable table.  Defaults to \\code{\"px\"}.  Must be one\nof \\code{c(\"px\", \"pt\", \"\\%\", \"em\")}.}\n\n\\item{scroll_body_background_color}{\\code{character(1)}. The color of the background\nof the body.  Must be a valid color.  It defaults to white, which may\noverride CSS settings provided by the user.  If this needs to be avoided,\nyou may use the \\code{\\link{fixed_header_css}} function to assist in\ngenerating CSS code to use to define the CSS. See Avoiding CSS Conflicts.}\n\n\\item{fixed_header_height}{\\code{integerish(1)}. Sets the height of the header\nrow.}\n\n\\item{fixed_header_height_units}{\\code{character(1)}. Determines the units for the\nheight of the header row. Defaults to \\code{\"px\"}. Must be one of\n\\code{c(\"px\", \"pt\", \"\\%\", \"em\")}.}\n\n\\item{fixed_header_text_height}{\\code{numeric(1)}. Sets the height at which the\nheader text appears.  By default it is set to half of the header height.\nThis should be approximately centered, but you may alter this to get the\nprecise look you want.}\n\n\\item{fixed_header_text_height_units}{\\code{character(1)}. Determines the units for\nplacing the header text.  Defaults to \\code{\"px\"}. Must be one of\n\\code{c(\"px\", \"pt\", \"\\%\", \"em\")}.}\n\n\\item{fixed_header_background_color}{\\code{character(1)}. Sets the background color for\nthe header row.  This defaults to white and may override the user's CSS\nsettings.  See Avoiding CSS Conflicts.}\n\n\\item{...}{Arguments to pass to other methods.}\n}\n\\description{\nLong tables to be displayed on-screen may benefit by keeping\n  the header fixed in position while scrolling through the body of the\n  table.  This allows the user to maintain visual contact between the\n  column name and the data.\n}\n\\details{\nCSS doesn't make this kind of table natural.  The solution to \n  generate the fixed headers used by \\code{pixiedust} is probably not the \n  best solution in terms of CSS design.  It is, however, the most conducive \n  to generating dynamically on the fly. \n  \n  The fixed header table requires nesting several HTML elements. \n  \\enumerate{\n   \\item a \\code{div} tag is used to control the alignment of the table\n   \\item a \\code{section} tag is used to set up the header row that remains fixed.\n   \\item a \\code{div} that sets the height of the scrollable body\n   \\item the \\code{table} tag establishes the actual table.\n   \\item The \\code{th} tags inside the table are set to full transparency and\n     the content of the headers is duplicated in a \\code{div} within the \n     \\code{th} tag to display the content.\n  }\n  \n  To accomplish these tasks, some CSS is exported with the table and placed\n  in the document immediately before the table.  Read further to understand\n  the conflicts that may arise if you are using custom CSS specifications \n  in your documents.\n}\n\\section{Avoiding CSS Conflicts}{\n \nBecause of all of the shenanigans involved, exporting the CSS with the tables\nmay result in conflicts with your custom CSS. Most importantly, any CSS\nyou have applied to the \\code{th} or \\code{td} tags may be overwritten.\nIf you are using custom CSS, you may want to consider using \n\\code{include_fixed_header_css = FALSE} and then utilizing \n\\code{\\link{fixed_header_css}} to generate CSS you can include in your \nCSS file to provide the fixed headers.  The code generated by \n\\code{fixed_header_css} ought to be placed before your definitions for\n\\code{td} and \\code{th}.  \n\nTo get the same header design in the fixed table, you will want to modify \nthe \\code{.th-pixie-fixed div} definition in the CSS to match your desired\n\\code{th} definition.\n\nThe code produced by \\code{fixed_header_css} will include comments where\nthere is potential for a CSS conflict.\n}\n\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item Set the \\code{fixed_header} element of the \\code{dust} object correctly.\n \\item Set the \\code{include_fixed_header_css} element of the \\code{dust}\n   object correctly.\n \\item Set the \\code{fixed_header_param} element of the \\code{dust} object\n   correctly.\n \\item Cast an error if \\code{x} does not inherit class \\code{dust}\n \\item Cast an error if \\code{scroll_body_height} is not \\code{integerish(1)}\n \\item Cast an error if \\code{scroll_body_height_units} is not \\code{character(1)}\n \\item Cast an error if \\code{scroll_body_background_color} is not \\code{character(1)}\n \\item Cast an error if \\code{scroll_body_background_color} is not a valid color.\n \\item Cast an error if \\code{fixed_header_height} is not \\code{integerish(1)}\n \\item Cast an error if \\code{fixed_header_height_units} is not \\code{character(1)}\n \\item Cast an error if \\code{fixed_header_text_height} is not \\code{numeric(1)}\n \\item Cast an error if \\code{fixed_header_text_height_units} is not \\code{character(1)}\n \\item Cast an error if \\code{fixed_header_background_color} is not \\code{character(1)}\n \\item Cast an error if \\code{fixed_header_background_color} is not a valid color.\n \\item Cast an error if \\code{include_fixed_header_css} is not \\code{logical(1)}\n \\item Cast an error if \\code{fixed_header_class_name} is not \\code{character(1)}\n}\n}\n\n"
  },
  {
    "path": "man/sprinkle_float.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_float.R\n\\name{sprinkle_float}\n\\alias{sprinkle_float}\n\\alias{sprinkle_float.default}\n\\alias{sprinkle_float.dust_list}\n\\title{Change the float Property in a Dust Table}\n\\source{\n\\url{https://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions}\n}\n\\usage{\nsprinkle_float(x, float = getOption(\"pixie_float\", FALSE), ...)\n\n\\method{sprinkle_float}{default}(x, float = getOption(\"pixie_float\", FALSE), ...)\n\n\\method{sprinkle_float}{dust_list}(x, float = getOption(\"pixie_float\", FALSE), ...)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{float}{\\code{logical(1)} indicating if the table should be placed in\na floating environment.}\n\n\\item{...}{Additional arguments to pass to other methods. Currently ignored.}\n}\n\\description{\nAlter the floating behavior of tables rendered in \nLaTeX documents.  Floating tables are moved to a position deemed ideal \nby the typesetter.  Setting \\code{float = FALSE} causes the table to \nbe rendered in the position in which it is generated in the code.\n}\n\\details{\nSee \\url{https://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions}\nfor more about floating environments in LaTeX.\n\nThis property has no effect on non-LaTeX output.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item Change the \\code{float} attribute of the \\code{dust} object.\n \\item Cast an error if \\code{x} is not a \\code{dust} object.\n \\item Cast an error if \\code{float} is not logical or length 1.\n}\n}\n\n\\seealso{\n\\code{\\link{dust}}, \\code{\\link{sprinkle}}\n}\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "man/sprinkle_fn.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_fn.R\n\\name{sprinkle_fn}\n\\alias{sprinkle_fn}\n\\alias{sprinkle_fn.default}\n\\alias{sprinkle_fn.dust_list}\n\\title{Apply a function to a selection of cells}\n\\usage{\nsprinkle_fn(\n  x,\n  rows = NULL,\n  cols = NULL,\n  fn = NULL,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\"),\n  ...\n)\n\n\\method{sprinkle_fn}{default}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  fn = NULL,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\n\\method{sprinkle_fn}{dust_list}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  fn = NULL,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{rows}{Either a numeric vector of rows in the tabular object to be \nmodified or an object of class \\code{call}.  When a \\code{call}, \ngenerated by \\code{quote(expression)}, the expression resolves to \na logical vector the same length as the number of rows in the table.\nSprinkles are applied to where the expression resolves to \\code{TRUE}.}\n\n\\item{cols}{Either a numeric vector of columns in the tabular object to\nbe modified, or a character vector of column names. A mixture of \ncharacter and numeric indices is permissible.}\n\n\\item{fn}{An object of class \\code{call}. The function should act on \nan object \\code{value} (which is an internal column in the \\code{dust}\nobject). It is recommend to wrap the function call in \\code{quote}.\nFor example, \\code{quote(pvalString(value))} or \n\\code{quote(format(value, nsmall = 3))}.}\n\n\\item{part}{A character string denoting which part of the table to modify.}\n\n\\item{fixed}{\\code{logical(1)} indicating if the values in \\code{rows} \nand \\code{cols} should be read as fixed coordinate pairs.  By default, \nsprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \nmeaning that the arguments do not have to share the same length.  \nWhen \\code{fixed = TRUE}, they must share the same length.}\n\n\\item{recycle}{A \\code{character} one that determines how sprinkles are \nmanaged when the sprinkle input doesn't match the length of the region\nto be sprinkled.  By default, recycling is turned off.  Recycling \nmay be performed across rows first (left to right, top to bottom), \nor down columns first (top to bottom, left to right).}\n\n\\item{...}{Additional arguments to pass to other methods. Currently ignored.}\n}\n\\description{\nThe pre-defined sprinkles do not always provide the \n  desired impact on the tables. Applying a function allows for \n  highly customized output without having to pre-process that data \n  frame.\n}\n\\details{\n\\code{dust} objects transform tabular objects so that each cell\n  in the table comprises one row in the data frame of cell attributes.  \n  The function to be applied needs to act on the \\code{value} column of\n  that data frame.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item Correctly reassigns the appropriate elements \\code{fn} column\n   in the table part.\n \\item Casts an error if \\code{x} is not a \\code{dust} object.\n \\item Casts an error if \\code{fn} is not a \\code{call} object.\n \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n   \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\n \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\n   \\code{\"rows\"}, or \\code{\"cols\"}\n}\n}\n\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "man/sprinkle_font.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_font.R\n\\name{sprinkle_font}\n\\alias{sprinkle_font}\n\\alias{sprinkle_font.default}\n\\alias{sprinkle_font.dust_list}\n\\title{Sprinkle the Characteristics of Text in a Cell}\n\\usage{\nsprinkle_font(\n  x,\n  rows = NULL,\n  cols = NULL,\n  bold = NULL,\n  italic = NULL,\n  font_size = NULL,\n  font_size_units = NULL,\n  font_color = NULL,\n  font_family = NULL,\n  ...,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = \"none\"\n)\n\n\\method{sprinkle_font}{default}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  bold = NULL,\n  italic = NULL,\n  font_size = NULL,\n  font_size_units = NULL,\n  font_color = NULL,\n  font_family = NULL,\n  ...,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = \"none\"\n)\n\n\\method{sprinkle_font}{dust_list}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  bold = NULL,\n  italic = NULL,\n  font_size = NULL,\n  font_size_units = NULL,\n  font_color = NULL,\n  font_family = NULL,\n  ...,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = \"none\"\n)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{rows}{Either a numeric vector of rows in the tabular object to be \nmodified or an object of class \\code{call}.  When a \\code{call}, \ngenerated by \\code{quote(expression)}, the expression resolves to \na logical vector the same length as the number of rows in the table.\nSprinkles are applied to where the expression resolves to \\code{TRUE}.}\n\n\\item{cols}{Either a numeric vector of columns in the tabular object to\nbe modified, or a character vector of column names. A mixture of \ncharacter and numeric indices is permissible.}\n\n\\item{bold}{\\code{logical(1)} indicating if the text in the selected cells\nshould be made bold.}\n\n\\item{italic}{\\code{logical(1)} indicating if the text in the selected \ncells should be made italic.}\n\n\\item{font_size}{\\code{numeric(1)} giving the font size.}\n\n\\item{font_size_units}{\\code{character(1)} giving the units of the font \nsize.  May be any of \\code{c(\"px\", \"pt\", \"\\%\", \"em\")}. LaTeX output only\nrecognizes \\code{\"pt\"} and \\code{\"em\"}. For LaTeX output, \\code{\"px\"} is\nquietly changed to \\code{\"pt\"} when printing.}\n\n\\item{font_color}{\\code{character(1)} giving a valid color name for the \ntext.}\n\n\\item{font_family}{\\code{character(1)} giving the font name for the text. \nThis is only recognized in HTML output.}\n\n\\item{...}{Additional arguments to pass to other methods. Currently ignored.}\n\n\\item{part}{A character string denoting which part of the table to modify.}\n\n\\item{fixed}{\\code{logical(1)} indicating if the values in \\code{rows} \nand \\code{cols} should be read as fixed coordinate pairs.  By default, \nsprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \nmeaning that the arguments do not have to share the same length.  \nWhen \\code{fixed = TRUE}, they must share the same length.}\n\n\\item{recycle}{A \\code{character} one that determines how sprinkles are \nmanaged when the sprinkle input doesn't match the length of the region\nto be sprinkled.  By default, recycling is turned off.  Recycling \nmay be performed across rows first (left to right, top to bottom), \nor down columns first (top to bottom, left to right).}\n}\n\\description{\nText can be made to stand out (or fade away) by using font \n  features such as bold and italic text, color, size, or different fonts.\n}\n\\details{\nThe \\code{bold} and \\code{italic} features are recognized by all \n  formats.  \n  \n  Font size features are recognized by HTML and LaTeX. LaTeX only recognizes \n  the font size unit options of \\code{\"pt\"} and \\code{\"em\"}, but will quietly\n  change \\code{\"px\"} to \\code{\"pt\"} when printing.\n  \n  Font color features are recognized by HTML and LaTeX.\n  \n  Font family is only recognized by HTML.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n  \\item Correctly change the \\code{bold} column of the table part for \n    the selected cells.\n  \\item Correctly change the \\code{italic} column of the table part for \n    the selected cells.\n  \\item Correctly change the \\code{font_size} column of the table part for \n    the selected cells.\n  \\item Correctly change the \\code{font_size_units} column of the table part for \n    the selected cells.\n  \\item Correctly chagne the \\code{font_color} column of the table part \n    for the selected cells.\n  \\item Correctly change the \\code{font_family} column of the table part for \n    the selected cells.\n  \\item Cast an error if \\code{x} is not a dust object.\n  \\item Cast an error if \\code{bold} is not \\code{logical(1)}\n  \\item Cast an error if \\code{italic} is not \\code{logical(1)}\n  \\item Cast an error if \\code{font_size} is not \\code{numeric(1)}\n  \\item Cast an error if \\code{font_size_units} is not \\code{character(1)}\n  \\item Cast an error if \\code{font_size_units} is not one of \n    px, pt, em, or %\n  \\item Cast an error if \\code{font_color} is not \\code{character(1)}\n  \\item Cast an error if \\code{font_family} is not \\code{character(1)}\n  \\item Cast an error if \\code{part} is not a subset of \\code{c(\"body\", \n    \"head\", \"foot\", \"interfoot\")}\n \\item Cast an error if \\code{recycle = \"none\"} and \\code{bold}\n   does not have length 1.\n \\item Cast an error if \\code{recycle = \"none\"} and \\code{italic}\n   does not have length 1.\n \\item Cast an error if \\code{recycle = \"none\"} and \\code{font_size}\n   does not have length 1.\n \\item Cast an error if \\code{recycle = \"none\"} and \\code{font_size_units}\n   does not have length 1.\n \\item Cast an error if \\code{recycle = \"none\"} and \\code{font_color}\n   does not have length 1.\n \\item Cast an error if \\code{recycle = \"none\"} and \\code{font_family}\n   does not have length 1.\n}\n\nThe functional behavior of the \\code{fixed} and \\code{recycle} arguments \nis not tested for this function. It is tested and validated in the\ntests for \\code{\\link{index_to_sprinkle}}.\n}\n\n\\seealso{\n\\code{\\link{sprinkle}}\n}\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "man/sprinkle_gradient.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_gradient.R\n\\name{sprinkle_gradient}\n\\alias{sprinkle_gradient}\n\\alias{sprinkle_gradient.default}\n\\alias{sprinkle_gradient.dust_list}\n\\title{Change Color Features by Binning Numeric Values}\n\\usage{\nsprinkle_gradient(\n  x,\n  rows = NULL,\n  cols = NULL,\n  gradient = \"bg\",\n  gradient_colors = getOption(\"pixie_gradient_pal\", NULL),\n  gradient_cut = NULL,\n  gradient_n = 10,\n  gradient_na = \"grey\",\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\n\\method{sprinkle_gradient}{default}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  gradient = \"bg\",\n  gradient_colors = getOption(\"pixie_gradient_pal\", c(\"#132B43\", \"#56B1F7\")),\n  gradient_cut = NULL,\n  gradient_n = 10,\n  gradient_na = \"grey\",\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\n\\method{sprinkle_gradient}{dust_list}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  gradient = \"bg\",\n  gradient_colors = getOption(\"pixie_gradient_pal\", c(\"#132B43\", \"#56B1F7\")),\n  gradient_cut = NULL,\n  gradient_n = 10,\n  gradient_na = \"grey\",\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{rows}{Either a numeric vector of rows in the tabular object to be \nmodified or an object of class \\code{call}.  When a \\code{call}, \ngenerated by \\code{quote(expression)}, the expression resolves to \na logical vector the same length as the number of rows in the table.\nSprinkles are applied to where the expression resolves to \\code{TRUE}.}\n\n\\item{cols}{Either a numeric vector of columns in the tabular object to\nbe modified, or a character vector of column names. A mixture of \ncharacter and numeric indices is permissible.}\n\n\\item{gradient}{\\code{character}. A subset of \\code{c(\"bg\", \"font\", \n\"font_color\", \"border\", \"left_border\", \"top_border\", \"right_border\",\n\"bottom_border\")}.}\n\n\\item{gradient_colors}{\\code{character(2)}. Gives the colors between \nwhich to shared gradients.}\n\n\\item{gradient_cut}{\\code{numeric}. Determines the breaks points for the \ngradient shading. When \\code{NULL} equally spaced quantiles are used, \nthe number of which are determined by \\code{gradient_n}.}\n\n\\item{gradient_n}{\\code{numeric(1)}. Determines the number of shades to use \nbetween the colors in \\code{gradient_colors}}\n\n\\item{gradient_na}{\\code{character(1)} A valid color that sets the color of \n\\code{NA} values when shading a numeric range.}\n\n\\item{part}{A character string denoting which part of the table to modify.}\n\n\\item{fixed}{\\code{logical(1)} indicating if the values in \\code{rows} \nand \\code{cols} should be read as fixed coordinate pairs.  By default, \nsprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \nmeaning that the arguments do not have to share the same length.  \nWhen \\code{fixed = TRUE}, they must share the same length.}\n\n\\item{recycle}{A \\code{character} one that determines how sprinkles are \nmanaged when the sprinkle input doesn't match the length of the region\nto be sprinkled.  By default, recycling is turned off.  Recycling \nmay be performed across rows first (left to right, top to bottom), \nor down columns first (top to bottom, left to right).}\n\n\\item{...}{Additional arguments to pass to other methods. Currently ignored.}\n}\n\\description{\nNumeric values within a range of cells are binned and colors\n  assigned to show gradual increases in the numeric value.\n}\n\\details{\nThis sprinkle is only recognized by HTML and LaTeX.  All of the \n  \\code{height_units} values are recognized by HTML.  For LaTeX, \\code{\"px\"}\n  is converted to \\code{\"pt\"}. \n  \n\\code{\"font\"} and \\code{\"font_color\"} both change the font color.\n\n\\code{\"border\"} is a shortcut to specify all borders.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item Correctly reassigns the appropriate elements of the \\code{bg},\n   \\code{font_color}, \\code{left_border}, \\code{top_border},\n   \\code{right_border}, or \\code{bottom_border} column in the table part.\n \\item Casts an error if \\code{x} is not a \\code{dust} object.\n \\item Casts an error if \\code{gradient} is not a subset of \n   \\code{c(\"bg\", \"font\", \"font_color\", \"border\", \"left_border\",\n           \"right_border\", \"top_border\", \"bottom_border\")}\n \\item Casts an error if \\code{gradient_colors} is not a \\code{character(2)}\n   value.\n \\item Casts an error if any value of \\code{gradient_colors} is not a\n   recognized color value.\n \\item Casts an error if \\code{gradient_cut} is not \\code{numeric}.\n \\item Casts an error if \\code{gradient_n} is not \\code{numeric(1)}.\n \\item Casts an error if \\code{gradient_na} is not \\code{character(1)}.\n \\item Casts an error if \\code{gradient_na} is not a valid color.\n \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n   \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\n \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\n   \\code{\"rows\"}, or \\code{\"cols\"}\n}\n\nThe functional behavior of the \\code{fixed} and \\code{recycle} arguments \nis not tested for this function. It is tested and validated in the\ntests for \\code{\\link{index_to_sprinkle}}.\n}\n\n\\seealso{\n\\code{\\link{sprinkle}}, \n  \\code{\\link{index_to_sprinkle}}\n}\n"
  },
  {
    "path": "man/sprinkle_height.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_height.R\n\\name{sprinkle_height}\n\\alias{sprinkle_height}\n\\alias{sprinkle_height.default}\n\\alias{sprinkle_height.dust_list}\n\\title{Adjust Table Cell Height}\n\\usage{\nsprinkle_height(\n  x,\n  rows = NULL,\n  cols = NULL,\n  height = NULL,\n  height_units = NULL,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\n\\method{sprinkle_height}{default}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  height = NULL,\n  height_units = NULL,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\n\\method{sprinkle_height}{dust_list}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  height = NULL,\n  height_units = NULL,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{rows}{Either a numeric vector of rows in the tabular object to be \nmodified or an object of class \\code{call}.  When a \\code{call}, \ngenerated by \\code{quote(expression)}, the expression resolves to \na logical vector the same length as the number of rows in the table.\nSprinkles are applied to where the expression resolves to \\code{TRUE}.}\n\n\\item{cols}{Either a numeric vector of columns in the tabular object to\nbe modified, or a character vector of column names. A mixture of \ncharacter and numeric indices is permissible.}\n\n\\item{height}{\\code{numeric(1)}. Gives the height of the cell.}\n\n\\item{height_units}{\\code{character(1)}. Gives the units for \\code{height}.\nOne of \\code{c(\"pt\", \"px\", \"cm\", \"in\", \"\\%\")}}\n\n\\item{part}{A character string denoting which part of the table to modify.}\n\n\\item{fixed}{\\code{logical(1)} indicating if the values in \\code{rows} \nand \\code{cols} should be read as fixed coordinate pairs.  By default, \nsprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \nmeaning that the arguments do not have to share the same length.  \nWhen \\code{fixed = TRUE}, they must share the same length.}\n\n\\item{recycle}{A \\code{character} one that determines how sprinkles are \nmanaged when the sprinkle input doesn't match the length of the region\nto be sprinkled.  By default, recycling is turned off.  Recycling \nmay be performed across rows first (left to right, top to bottom), \nor down columns first (top to bottom, left to right).}\n\n\\item{...}{Additional arguments to pass to other methods. Currently ignored.}\n}\n\\description{\nCustomize the height of a cell in a table. This may be done\n  to improve the appearance of cells with long text.\n}\n\\details{\nThis sprinkle is only recognized by HTML and LaTeX.  All of the \n  \\code{height_units} values are recognized by HTML.  For LaTeX, \\code{\"px\"}\n  is converted to \\code{\"pt\"}.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item Correctly reassigns the appropriate elements of \\code{height} \n   and \\code{height_units} columns in the table part.\n \\item Casts an error if \\code{x} is not a \\code{dust} object.\n \\item Casts an error if \\code{height} is not a \\code{numeric(1)}\n \\item Casts an error if \\code{height_units} is not a \\code{character(1)}\n \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n   \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\n \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\n   \\code{\"rows\"}, or \\code{\"cols\"}\n \\item Cast an error if \\code{recycle = \"none\"} and \\code{height}\n   does not have length 1.\n \\item When \\code{recycle = \"none\"}, quietly coerce \\code{height_units}\n   to just the first element given.\n}\n\nThe functional behavior of the \\code{fixed} and \\code{recycle} arguments \nis not tested for this function. It is tested and validated in the\ntests for \\code{\\link{index_to_sprinkle}}.\n}\n\n\\seealso{\n\\code{\\link{sprinkle}}, \n  \\code{\\link{index_to_sprinkle}}\n}\n"
  },
  {
    "path": "man/sprinkle_hhline.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_hhline.R\n\\name{sprinkle_hhline}\n\\alias{sprinkle_hhline}\n\\alias{sprinkle_hhline.default}\n\\alias{sprinkle_hhline.dust_list}\n\\title{Change the hhline Property in a Dust Table}\n\\source{\n\\url{https://www.ctan.org/pkg/hhline?lang=en}\n}\n\\usage{\nsprinkle_hhline(x, hhline = getOption(\"pixie_hhline\", FALSE), ...)\n\n\\method{sprinkle_hhline}{default}(x, hhline = getOption(\"pixie_hhline\", FALSE), ...)\n\n\\method{sprinkle_hhline}{dust_list}(x, hhline = getOption(\"pixie_hhline\", FALSE), ...)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{hhline}{\\code{logical(1)}. When \\code{TRUE}, the LaTeX hhline package\nwill be used for cell borderes.}\n\n\\item{...}{Additional arguments to pass to other methods. Currently ignored.}\n}\n\\description{\nThe \\code{hhline} property controls the appearance of \n  cell borders in LaTeX tables.  There is a known limitation in the \n  LaTeX \\code{colortbl} package where cell borders can be hidden if\n  the cell has a background color.  If using both cell borders and\n  background colors, it is recommended that you use the \\code{hhline}\n  property to make cell borders appear as desired.\n}\n\\details{\nWhen \\code{hhline = TRUE}, borders will be solid; dashed and dotted\n  borders are unsupported by hhline.\n\nThis property has no effect on non-LaTeX output.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item Change the \\code{hhline} attribute of the \\code{dust} object.\n \\item Cast an error if \\code{x} is not a \\code{dust} object.\n \\item Cast an error if \\code{hhline} is not logical and length 1.\n}\n}\n\n\\seealso{\n\\code{\\link{dust}}, \\code{\\link{sprinkle}}\n}\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "man/sprinkle_html_preserve.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_html_preserve.R\n\\name{sprinkle_html_preserve}\n\\alias{sprinkle_html_preserve}\n\\alias{sprinkle_html_preserve.default}\n\\alias{sprinkle_html_preserve.dust_list}\n\\title{Change the HTML Preserve Property in a Dust Table}\n\\usage{\nsprinkle_html_preserve(\n  x,\n  html_preserve = getOption(\"pixie_html_preserve\", TRUE),\n  ...\n)\n\n\\method{sprinkle_html_preserve}{default}(\n  x,\n  html_preserve = getOption(\"pixie_html_preserve\", TRUE),\n  ...\n)\n\n\\method{sprinkle_html_preserve}{dust_list}(\n  x,\n  html_preserve = getOption(\"pixie_html_preserve\", TRUE),\n  ...\n)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{html_preserve}{\\code{logical(1)} indicating if the table is being produced\nin a \\code{htmltools::htmlPreserve} environment.}\n\n\\item{...}{Additional arguments to pass to other methods. Currently ignored.}\n}\n\\description{\nBy default \\code{pixiedust} makes use of \\code{htmltools::htmlPreserve}\n  to prevent certain symbols from rendering in unintended ways based on some \n  not-very-well-understood-by-the-author issues.  This property controls whether\n  the preservation is used or not.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item Change the \\code{html_preserve} attribute of the \\code{dust} object.\n \\item Cast an error if \\code{x} is not a \\code{dust} object.\n \\item Cast an error if \\code{html_preserve} is not logical(1).\n}\n}\n\n\\seealso{\n\\code{\\link{dust}}, \\code{\\link{sprinkle}}, \\code{\\link[htmltools]{htmlPreserve}}\n}\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "man/sprinkle_justify.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_justify.R\n\\name{sprinkle_justify}\n\\alias{sprinkle_justify}\n\\alias{sprinkle_justify.default}\n\\alias{sprinkle_justify.dust_list}\n\\title{Change the Caption in a Dust Table}\n\\usage{\nsprinkle_justify(x, justify = getOption(\"pixie_justify\", \"center\"), ...)\n\n\\method{sprinkle_justify}{default}(x, justify = getOption(\"pixie_justify\", \"center\"), ...)\n\n\\method{sprinkle_justify}{dust_list}(x, justify = getOption(\"pixie_justify\", \"center\"), ...)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{justify}{\\code{character} string giving the justification of the \nentire table on the page. May be any one of \\code{\"center\"},\n\\code{\"left\"}, or \\code{\"right\"}.}\n\n\\item{...}{Additional arguments to pass to other methods. Currently ignored.}\n}\n\\description{\nThe justification of the table determines the horizontal \n  placing of the table on the page.\n}\n\\details{\nFor HTML tables, the values \\code{\"center\"}, \n  \\code{\"left\"},  and \\code{\"right\"} all justify the table as expected.\n  It is important to note, however, that \\code{\"left\"} and \\code{\"right\"} \n  will cause subsequent elements to be rendered next to the table, not \n  below it. To render the table with left alignment without this side \n  effect, use \\code{\"none\"}.\n  \n  In LaTeX output, both \\code{\"right\"} and \\code{\"left\"} justify \n  to the left. This may change in the future if I find a resolution.  Using\n  \\code{\"none\"} also results in left justification.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item Change the \\code{justify} attribute of the \\code{dust} object.\n \\item Cast an error if \\code{x} is not a \\code{dust} object.\n \\item Cast an error if \\code{justify} is not one of \\code{\"center\"}, \n       \\code{\"none\"}, \\code{\"left\"}, or \\code{\"right\"}.\n \\item Ignore capitalization of the \\code{justify} argument.\n}\n}\n\n\\seealso{\n\\code{\\link{dust}}, \\code{\\link{sprinkle}}\n}\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "man/sprinkle_label.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_label.R\n\\name{sprinkle_label}\n\\alias{sprinkle_label}\n\\alias{sprinkle_label.default}\n\\alias{sprinkle_label.dust_list}\n\\title{Change the Border Collapse Property in a Dust Table}\n\\source{\n\\url{https://en.wikibooks.org/wiki/LaTeX/Labels_and_Cross-referencing}\n\n\\url{https://bookdown.org/yihui/bookdown/tables.html}\n}\n\\usage{\nsprinkle_label(x, label = NULL, ...)\n\n\\method{sprinkle_label}{default}(x, label = NULL, ...)\n\n\\method{sprinkle_label}{dust_list}(x, label = NULL, ...)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{label}{\\code{character(1)} or \\code{NULL} for no label.}\n\n\\item{...}{Additional arguments to pass to other methods. Currently ignored.}\n}\n\\description{\nThe \\code{label} property is used to make references to a \n  table.  Labels may be used in LaTeX documents, or in both LaTeX and \n  HTML documents when using \\code{bookdown}.\n}\n\\details{\nFor details about using labels in LaTeX documents, see \n\\url{https://en.wikibooks.org/wiki/LaTeX/Labels_and_Cross-referencing}.\n\nFor details about using labels in \\code{bookdown} documents, see\n\\url{https://bookdown.org/yihui/bookdown/tables.html}\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item Change the \\code{label} attribute of the \\code{dust} object.\n \\item Cast an error if \\code{x} is not a \\code{dust} object.\n \\item Cast an error if \\code{label} is not a \\code{character(1)}.\n}\n}\n\n\\seealso{\n\\code{\\link{dust}}, \\code{\\link{sprinkle}}\n}\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "man/sprinkle_longtable.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_longtable.R\n\\name{sprinkle_longtable}\n\\alias{sprinkle_longtable}\n\\alias{sprinkle_longtable.default}\n\\alias{sprinkle_longtable.dust_list}\n\\title{Change the Longtable Property in a Dust Table}\n\\usage{\nsprinkle_longtable(x, longtable = getOption(\"pixie_longtable\", FALSE), ...)\n\n\\method{sprinkle_longtable}{default}(x, longtable = getOption(\"pixie_longtable\", FALSE), ...)\n\n\\method{sprinkle_longtable}{dust_list}(x, longtable = getOption(\"pixie_longtable\", FALSE), ...)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{longtable}{Either a \\code{logical(1)} or an \\code{numeric(1)} \ninteger-like value.  See Details.}\n\n\\item{...}{Additional arguments to pass to other methods. Currently ignored.}\n}\n\\description{\nThe LaTeX \\code{longtable} package allows for long tables\nto be broken into multiple parts to be displayed on separate pages. \n\\code{pixiedust} will mimic this behavior for other output types.\n}\n\\details{\nWhen \\code{longtable = TRUE}, LaTeX tables will be divided \n  according to the LaTeX document settings.  In other table outputs, the \n  default is to use 25 rows per table.\n  \n  When \\code{longtable} is an integer (or integer-like) value, the table \n  is divided into that many rows per section. This applies to all output.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item Change the \\code{longtable} attribute of the \\code{dust} object.\n \\item Cast an error if \\code{x} is not a \\code{dust} object.\n \\item Cast an error if \\code{longtable} is logical and has length not equal \n   to 1.\n \\item when \\code{longtable} is not logical, cast an error if \n   it is not-integerish and has length not equal to 1.\n}\n}\n\n\\seealso{\n\\code{\\link{dust}}, \\code{\\link{sprinkle}}\n}\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "man/sprinkle_merge.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_merge.R\n\\name{sprinkle_merge}\n\\alias{sprinkle_merge}\n\\alias{sprinkle_merge.default}\n\\alias{sprinkle_merge.dust_list}\n\\title{Sprinkle Table Cells to Merge}\n\\usage{\nsprinkle_merge(\n  x,\n  rows = NULL,\n  cols = NULL,\n  merge = FALSE,\n  merge_rowval = NULL,\n  merge_colval = NULL,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\n\\method{sprinkle_merge}{default}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  merge = FALSE,\n  merge_rowval = NULL,\n  merge_colval = NULL,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\n\\method{sprinkle_merge}{dust_list}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  merge = FALSE,\n  merge_rowval = NULL,\n  merge_colval = NULL,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{rows}{Either a numeric vector of rows in the tabular object to be \nmodified or an object of class \\code{call}.  When a \\code{call}, \ngenerated by \\code{quote(expression)}, the expression resolves to \na logical vector the same length as the number of rows in the table.\nSprinkles are applied to where the expression resolves to \\code{TRUE}.}\n\n\\item{cols}{Either a numeric vector of columns in the tabular object to\nbe modified, or a character vector of column names. A mixture of \ncharacter and numeric indices is permissible.}\n\n\\item{merge}{\\code{logical} Defaults to \\code{FALSE}, prompting no \nmerging action.}\n\n\\item{merge_rowval}{The row position of the cell whose content will be\ndisplayed.  Defaults to the minimum of \\code{rows}.}\n\n\\item{merge_colval}{The column position of the cell whose content will \nbe displayed.  Deafults to the minimum of \\code{cols}.}\n\n\\item{part}{A character string denoting which part of the table to modify.}\n\n\\item{fixed}{\\code{logical(1)} indicating if the values in \\code{rows} \nand \\code{cols} should be read as fixed coordinate pairs.  By default, \nsprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \nmeaning that the arguments do not have to share the same length.  \nWhen \\code{fixed = TRUE}, they must share the same length.}\n\n\\item{recycle}{A \\code{character} one that determines how sprinkles are \nmanaged when the sprinkle input doesn't match the length of the region\nto be sprinkled.  By default, recycling is turned off.  Recycling \nmay be performed across rows first (left to right, top to bottom), \nor down columns first (top to bottom, left to right).}\n\n\\item{...}{Additional arguments to pass to other methods. Currently ignored.}\n}\n\\description{\nMerging cells creates more space for values to be displayed\n  without disrupting the appearance of other cells in the same row or \n  column.  The downside is that the content from only one of the cells\n  in the merge range will be displayed.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item Correctly reassigns the appropriate elements of \\code{merge}, \n   \\code{merge_rowval} and \\code{merge_colval} columns in the table part.\n \\item Casts an error if \\code{x} is not a \\code{dust} object.\n \\item Casts an error if \\code{merge} is not a \\code{logical(1)}\n \\item Casts an error if \\code{merge_rowval} is not a \\code{numeric(1)}\n \\item Casts an error if \\code{merge_colval} is not a \\code{numeric(1)}\n \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n   \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\n \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\n   \\code{\"rows\"}, or \\code{\"cols\"}\n}\n\nThe functional behavior of the \\code{fixed} and \\code{recycle} arguments \nis not tested for this function. It is tested and validated in the\ntests for \\code{\\link{index_to_sprinkle}}.\n}\n\n\\seealso{\n\\code{\\link{sprinkle}}, \n  \\code{\\link{index_to_sprinkle}}\n}\n"
  },
  {
    "path": "man/sprinkle_na_string.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_na_string.R\n\\name{sprinkle_na_string}\n\\alias{sprinkle_na_string}\n\\alias{sprinkle_na_string.default}\n\\alias{sprinkle_na_string.dust_list}\n\\title{Sprinkle Appearance of NA's}\n\\usage{\nsprinkle_na_string(\n  x,\n  rows = NULL,\n  cols = NULL,\n  na_string = getOption(\"pixie_na_string\", NA),\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\n\\method{sprinkle_na_string}{default}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  na_string = getOption(\"pixie_na_string\", NA),\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\n\\method{sprinkle_na_string}{dust_list}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  na_string = getOption(\"pixie_na_string\", NA),\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{rows}{Either a numeric vector of rows in the tabular object to be \nmodified or an object of class \\code{call}.  When a \\code{call}, \ngenerated by \\code{quote(expression)}, the expression resolves to \na logical vector the same length as the number of rows in the table.\nSprinkles are applied to where the expression resolves to \\code{TRUE}.}\n\n\\item{cols}{Either a numeric vector of columns in the tabular object to\nbe modified, or a character vector of column names. A mixture of \ncharacter and numeric indices is permissible.}\n\n\\item{na_string}{\\code{character(1)} A character string giving desired\nreplacement for \\code{NA} values in the selected cells.}\n\n\\item{part}{A character string denoting which part of the table to modify.}\n\n\\item{fixed}{\\code{logical(1)} indicating if the values in \\code{rows} \nand \\code{cols} should be read as fixed coordinate pairs.  By default, \nsprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \nmeaning that the arguments do not have to share the same length.  \nWhen \\code{fixed = TRUE}, they must share the same length.}\n\n\\item{recycle}{A \\code{character} one that determines how sprinkles are \nmanaged when the sprinkle input doesn't match the length of the region\nto be sprinkled.  By default, recycling is turned off.  Recycling \nmay be performed across rows first (left to right, top to bottom), \nor down columns first (top to bottom, left to right).}\n\n\\item{...}{Additional arguments to pass to other methods. Currently ignored.}\n}\n\\description{\nThe appearance of \\code{NA} values in a table may be dependent\n  on the context.  \\code{pixiedust} uses the \\code{na_string} sprinkle\n  to guide the appearance of missing values in the table.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item Correctly reassigns the appropriate elements \\code{na_string} column\n   in the table part.\n \\item Casts an error if \\code{x} is not a \\code{dust} object.\n \\item Casts an error if \\code{bg} is not a \\code{character(1)}\n \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n   \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\n \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\n   \\code{\"rows\"}, or \\code{\"cols\"}\n \\item Cast an error if \\code{recycle = \"none\"} and \\code{na_string}\n   does not have length 1.\n}\n\nThe functional behavior of the \\code{fixed} and \\code{recycle} arguments \nis not tested for this function. It is tested and validated in the\ntests for \\code{\\link{index_to_sprinkle}}.\n}\n\n\\seealso{\n\\code{\\link{sprinkle}}, \n  \\code{\\link{index_to_sprinkle}}\n}\n"
  },
  {
    "path": "man/sprinkle_pad.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_pad.R\n\\name{sprinkle_pad}\n\\alias{sprinkle_pad}\n\\alias{sprinkle_pad.default}\n\\alias{sprinkle_pad.dust_list}\n\\title{Sprinkle the Padding of a Cell}\n\\usage{\nsprinkle_pad(\n  x,\n  rows = NULL,\n  cols = NULL,\n  pad = 0,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\n\\method{sprinkle_pad}{default}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  pad = 0,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\n\\method{sprinkle_pad}{dust_list}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  pad = 0,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{rows}{Either a numeric vector of rows in the tabular object to be \nmodified or an object of class \\code{call}.  When a \\code{call}, \ngenerated by \\code{quote(expression)}, the expression resolves to \na logical vector the same length as the number of rows in the table.\nSprinkles are applied to where the expression resolves to \\code{TRUE}.}\n\n\\item{cols}{Either a numeric vector of columns in the tabular object to\nbe modified, or a character vector of column names. A mixture of \ncharacter and numeric indices is permissible.}\n\n\\item{pad}{\\code{numeric(1)} A character string giving a color for the \nbackground of the chosen cells.}\n\n\\item{part}{A character string denoting which part of the table to modify.}\n\n\\item{fixed}{\\code{logical(1)} indicating if the values in \\code{rows} \nand \\code{cols} should be read as fixed coordinate pairs.  By default, \nsprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \nmeaning that the arguments do not have to share the same length.  \nWhen \\code{fixed = TRUE}, they must share the same length.}\n\n\\item{recycle}{A \\code{character} one that determines how sprinkles are \nmanaged when the sprinkle input doesn't match the length of the region\nto be sprinkled.  By default, recycling is turned off.  Recycling \nmay be performed across rows first (left to right, top to bottom), \nor down columns first (top to bottom, left to right).}\n\n\\item{...}{Additional arguments to pass to other methods. Currently ignored.}\n}\n\\description{\nPadding for HTML tables indicates how many pixels should\nbe placed between the cell's content and the outside border.\n}\n\\details{\nColors may be a dvips color name, or in the rgb(R, G, B), \nrgba(R, G, B, A), #RRGGBB, or #RRGGBBAA formats. \n  \nThis sprinkle is ignored in console and markdown outputs.  HTML output\nwill accept any of the color formats and recognize transparency.  LaTeX\noutput will accept any of the color formats but ignore transparency.\n\nAs long as \\code{pad} is required to be a \\code{numeric(1)}, the \n\\code{recycle} argument is kind of useless. It is included to maintain\nconsistency with the \\code{index_to_sprinkle} function. Future development\nmay permit a character vector of colors.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item Correctly reassigns the appropriate elements \\code{pad} column\n   in the table part.\n \\item Casts an error if \\code{x} is not a \\code{dust} object.\n \\item Casts an error if \\code{pad} is not a \\code{numeric(1)}\n \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n   \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\n \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\n   \\code{\"rows\"}, or \\code{\"cols\"}\n \\item Cast an error if \\code{recycle = \"none\"} and \\code{pad}\n   does not have length 1.\n}\n\nThe functional behavior of the \\code{fixed} and \\code{recycle} arguments \nis not tested for this function. It is tested and validated in the\ntests for \\code{\\link{index_to_sprinkle}}.\n}\n\n\\seealso{\n\\code{\\link{sprinkle}},\n  \\code{\\link{index_to_sprinkle}}\n}\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "man/sprinkle_replace.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_replace.R\n\\name{sprinkle_replace}\n\\alias{sprinkle_replace}\n\\alias{sprinkle_replace.default}\n\\alias{sprinkle_replace.dust_list}\n\\title{Replace Contents of Selected Cells}\n\\usage{\nsprinkle_replace(\n  x,\n  rows = NULL,\n  cols = NULL,\n  replace,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\n\\method{sprinkle_replace}{default}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  replace,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\n\\method{sprinkle_replace}{dust_list}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  replace,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{rows}{Either a numeric vector of rows in the tabular object to be \nmodified or an object of class \\code{call}.  When a \\code{call}, \ngenerated by \\code{quote(expression)}, the expression resolves to \na logical vector the same length as the number of rows in the table.\nSprinkles are applied to where the expression resolves to \\code{TRUE}.}\n\n\\item{cols}{Either a numeric vector of columns in the tabular object to\nbe modified, or a character vector of column names. A mixture of \ncharacter and numeric indices is permissible.}\n\n\\item{replace}{\\code{character} A character vector giving the desired\ncontent for the selected cells.}\n\n\\item{part}{A character string denoting which part of the table to modify.}\n\n\\item{fixed}{\\code{logical(1)} indicating if the values in \\code{rows} \nand \\code{cols} should be read as fixed coordinate pairs.  By default, \nsprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \nmeaning that the arguments do not have to share the same length.  \nWhen \\code{fixed = TRUE}, they must share the same length.}\n\n\\item{recycle}{A \\code{character} one that determines how sprinkles are \nmanaged when the sprinkle input doesn't match the length of the region\nto be sprinkled.  By default, recycling is turned off.  Recycling \nmay be performed across rows first (left to right, top to bottom), \nor down columns first (top to bottom, left to right).}\n\n\\item{...}{Additional arguments to pass to other methods. Currently ignored.}\n}\n\\description{\nAt times it may be necessary to replace the contents of a \ncell with user-supplied values.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item Correctly reassigns the appropriate elements \\code{replace} column\n   in the table part.\n \\item Casts an error if \\code{x} is not a \\code{dust} object.\n \\item Casts an error if \\code{replace} is not a vector\n \\item Casts an warning if the number of indices to replace is not a \n   multiple of \\code{replace} \n \\item Casts an error if \\code{length(replace)} is greater than the \n   number of cells to replace.\n \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n   \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\n \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\n   \\code{\"rows\"}, or \\code{\"cols\"}\n}\n\nThe functional behavior of the \\code{fixed} and \\code{recycle} arguments \nis not tested for this function. It is tested and validated in the\ntests for \\code{\\link{index_to_sprinkle}}.\n}\n\n\\seealso{\n\\code{\\link{sprinkle}}, \n  \\code{\\link{index_to_sprinkle}}\n}\n"
  },
  {
    "path": "man/sprinkle_rotate_degree.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_rotate_degree.R\n\\name{sprinkle_rotate_degree}\n\\alias{sprinkle_rotate_degree}\n\\alias{sprinkle_rotate_degree.default}\n\\alias{sprinkle_rotate_degree.dust_list}\n\\title{Sprinkle Appearance of NA's}\n\\usage{\nsprinkle_rotate_degree(\n  x,\n  rows = NULL,\n  cols = NULL,\n  rotate_degree = NULL,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\n\\method{sprinkle_rotate_degree}{default}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  rotate_degree = NULL,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\n\\method{sprinkle_rotate_degree}{dust_list}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  rotate_degree = NULL,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{rows}{Either a numeric vector of rows in the tabular object to be \nmodified or an object of class \\code{call}.  When a \\code{call}, \ngenerated by \\code{quote(expression)}, the expression resolves to \na logical vector the same length as the number of rows in the table.\nSprinkles are applied to where the expression resolves to \\code{TRUE}.}\n\n\\item{cols}{Either a numeric vector of columns in the tabular object to\nbe modified, or a character vector of column names. A mixture of \ncharacter and numeric indices is permissible.}\n\n\\item{rotate_degree}{\\code{numeric(1)} Indicates how much to rotate the \ncell text in degrees.}\n\n\\item{part}{A character string denoting which part of the table to modify.}\n\n\\item{fixed}{\\code{logical(1)} indicating if the values in \\code{rows} \nand \\code{cols} should be read as fixed coordinate pairs.  By default, \nsprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \nmeaning that the arguments do not have to share the same length.  \nWhen \\code{fixed = TRUE}, they must share the same length.}\n\n\\item{recycle}{A \\code{character} one that determines how sprinkles are \nmanaged when the sprinkle input doesn't match the length of the region\nto be sprinkled.  By default, recycling is turned off.  Recycling \nmay be performed across rows first (left to right, top to bottom), \nor down columns first (top to bottom, left to right).}\n\n\\item{...}{Additional arguments to pass to other methods. Currently ignored.}\n}\n\\description{\nThe content of cells may be rotated when it is desired to save\nspace (such as long table column names), or to draw attention to the \ncells.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item Correctly reassigns the appropriate elements \\code{rotate_degree} column\n   in the table part.\n \\item Casts an error if \\code{x} is not a \\code{dust} object.\n \\item Casts an error if \\code{rotate_degree} is not a \\code{numeric(1)}\n \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n   \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\n \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\n   \\code{\"rows\"}, or \\code{\"cols\"}\n \\item Cast an error if \\code{recycle = \"none\"} and \\code{rotate_degree}\n   does not have length 1.\n}\n\nThe functional behavior of the \\code{fixed} and \\code{recycle} arguments \nis not tested for this function. It is tested and validated in the\ntests for \\code{\\link{index_to_sprinkle}}.\n}\n\n\\seealso{\n\\code{\\link{sprinkle}}, \n  \\code{\\link{index_to_sprinkle}}\n}\n"
  },
  {
    "path": "man/sprinkle_round.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_round.R\n\\name{sprinkle_round}\n\\alias{sprinkle_round}\n\\alias{sprinkle_round.default}\n\\alias{sprinkle_round.dust_list}\n\\title{Sprinkle Appearance of NA's}\n\\usage{\nsprinkle_round(\n  x,\n  rows = NULL,\n  cols = NULL,\n  round = NULL,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\n\\method{sprinkle_round}{default}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  round = NULL,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\n\\method{sprinkle_round}{dust_list}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  round = NULL,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{rows}{Either a numeric vector of rows in the tabular object to be \nmodified or an object of class \\code{call}.  When a \\code{call}, \ngenerated by \\code{quote(expression)}, the expression resolves to \na logical vector the same length as the number of rows in the table.\nSprinkles are applied to where the expression resolves to \\code{TRUE}.}\n\n\\item{cols}{Either a numeric vector of columns in the tabular object to\nbe modified, or a character vector of column names. A mixture of \ncharacter and numeric indices is permissible.}\n\n\\item{round}{\\code{numeric(1)} A value to pass to the \\code{digits}\nargument of \\code{\\link{round}}.}\n\n\\item{part}{A character string denoting which part of the table to modify.}\n\n\\item{fixed}{\\code{logical(1)} indicating if the values in \\code{rows} \nand \\code{cols} should be read as fixed coordinate pairs.  By default, \nsprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \nmeaning that the arguments do not have to share the same length.  \nWhen \\code{fixed = TRUE}, they must share the same length.}\n\n\\item{recycle}{A \\code{character} one that determines how sprinkles are \nmanaged when the sprinkle input doesn't match the length of the region\nto be sprinkled.  By default, recycling is turned off.  Recycling \nmay be performed across rows first (left to right, top to bottom), \nor down columns first (top to bottom, left to right).}\n\n\\item{...}{Additional arguments to pass to other methods. Currently ignored.}\n}\n\\description{\nThe appearance of \\code{NA} values in a table may be dependent\n  on the context.  \\code{pixiedust} uses the \\code{round} sprinkle\n  to guide the appearance of missing values in the table.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item Correctly reassigns the appropriate elements \\code{round} column\n   in the table part.\n \\item Casts an error if \\code{x} is not a \\code{dust} object.\n \\item Casts an error if \\code{round} is not a \\code{numeric(1)}\n \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n   \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\n \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\n   \\code{\"rows\"}, or \\code{\"cols\"}\n \\item Cast an error if \\code{recycle = \"none\"} and \\code{round}\n   does not have length 1.\n}\n\nThe functional behavior of the \\code{fixed} and \\code{recycle} arguments \nis not tested for this function. It is tested and validated in the\ntests for \\code{\\link{index_to_sprinkle}}.\n}\n\n\\seealso{\n\\code{\\link{sprinkle}}, \n  \\code{\\link{index_to_sprinkle}}\n}\n"
  },
  {
    "path": "man/sprinkle_sanitize.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_sanitize.R\n\\name{sprinkle_sanitize}\n\\alias{sprinkle_sanitize}\n\\alias{sprinkle_sanitize.default}\n\\alias{sprinkle_sanitize.dust_list}\n\\title{Sanitize Characters for LaTeX Outputs}\n\\usage{\nsprinkle_sanitize(\n  x,\n  rows = NULL,\n  cols = NULL,\n  sanitize = NULL,\n  sanitize_args = NULL,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\n\\method{sprinkle_sanitize}{default}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  sanitize = NULL,\n  sanitize_args = NULL,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\n\\method{sprinkle_sanitize}{dust_list}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  sanitize = NULL,\n  sanitize_args = NULL,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{rows}{Either a numeric vector of rows in the tabular object to be \nmodified or an object of class \\code{call}.  When a \\code{call}, \ngenerated by \\code{quote(expression)}, the expression resolves to \na logical vector the same length as the number of rows in the table.\nSprinkles are applied to where the expression resolves to \\code{TRUE}.}\n\n\\item{cols}{Either a numeric vector of columns in the tabular object to\nbe modified, or a character vector of column names. A mixture of \ncharacter and numeric indices is permissible.}\n\n\\item{sanitize}{\\code{logical(1)}. Should the code for the cell be sanitized.}\n\n\\item{sanitize_args}{A list of arguments to pass to \n\\code{Hmisc::latexTranslate}}\n\n\\item{part}{A character string denoting which part of the table to modify.}\n\n\\item{fixed}{\\code{logical(1)} indicating if the values in \\code{rows} \nand \\code{cols} should be read as fixed coordinate pairs.  By default, \nsprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \nmeaning that the arguments do not have to share the same length.  \nWhen \\code{fixed = TRUE}, they must share the same length.}\n\n\\item{recycle}{A \\code{character} one that determines how sprinkles are \nmanaged when the sprinkle input doesn't match the length of the region\nto be sprinkled.  By default, recycling is turned off.  Recycling \nmay be performed across rows first (left to right, top to bottom), \nor down columns first (top to bottom, left to right).}\n\n\\item{...}{Additional arguments to pass to other methods. Currently ignored.}\n}\n\\description{\nCertain characters in LaTeX code need to be escaped to \n  prevent errors during processing.  For example, \\code{\\%} is the \n  comment character in LaTeX, and needs to be escaped in \n  order to render correctly.\n}\n\\details{\nThis sprinkle is only recognized by LaTeX output.  See \n  \\code{\\link[Hmisc]{latexTranslate}} for more details.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item Correctly reassigns the appropriate elements of \\code{sanitize} \n   and \\code{sanitize_args} columns in the table part.\n \\item Casts an error if \\code{x} is not a \\code{dust} object.\n \\item Casts an error if \\code{sanitize} is not a \\code{logical(1)}\n \\item Casts an error if \\code{sanitize_args} is not a \\code{list}\n \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n   \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\n \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\n   \\code{\"rows\"}, or \\code{\"cols\"}\n}\n\nThe functional behavior of the \\code{fixed} and \\code{recycle} arguments \nis not tested for this function. It is tested and validated in the\ntests for \\code{\\link{index_to_sprinkle}}.\n}\n\n\\seealso{\n\\code{\\link{sprinkle}}, \n  \\code{\\link{index_to_sprinkle}}\n}\n"
  },
  {
    "path": "man/sprinkle_tabcolsep.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_tabcolsep.R\n\\name{sprinkle_tabcolsep}\n\\alias{sprinkle_tabcolsep}\n\\alias{sprinkle_tabcolsep.default}\n\\alias{sprinkle_tabcolsep.dust_list}\n\\title{Change the tabcolsep Property in a Dust Table}\n\\source{\n\\url{https://www.google.com/webhp?sourceid=chrome-instant&rlz=1C1CHBF_enUS706US706&ion=1&espv=2&ie=UTF-8#q=latex+tabcolsep&*}\n}\n\\usage{\nsprinkle_tabcolsep(x, tabcolsep = getOption(\"pixie_tabcolsep\", 6), ...)\n\n\\method{sprinkle_tabcolsep}{default}(x, tabcolsep = getOption(\"pixie_tabcolsep\", 6), ...)\n\n\\method{sprinkle_tabcolsep}{dust_list}(x, tabcolsep = getOption(\"pixie_tabcolsep\", 6), ...)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{tabcolsep}{\\code{numeric(1)}, integer-like value.}\n\n\\item{...}{Additional arguments to pass to other methods. Currently ignored.}\n}\n\\description{\nThe \\code{tabcolsep} property controls the space between \n  columns in LaTeX output.  By default, it is set to 6 pt.\n}\n\\details{\nReading on the details of \\code{tabcolsep} may be done by \n  searching \"latex tabcolsep\" on the internet.\n\nThis property has no effect on non-LaTeX output.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item Change the \\code{tabcolsep} attribute of the \\code{dust} object.\n \\item Cast an error if \\code{x} is not a \\code{dust} object.\n \\item Cast an error if \\code{tabcolsep} is not integerish and length 1.\n}\n}\n\n\\seealso{\n\\code{\\link{dust}}, \\code{\\link{sprinkle}}\n}\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "man/sprinkle_width.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/sprinkle_width.R\n\\name{sprinkle_width}\n\\alias{sprinkle_width}\n\\alias{sprinkle_width.default}\n\\alias{sprinkle_width.dust_list}\n\\title{Adjust Table Cell Width}\n\\usage{\nsprinkle_width(\n  x,\n  rows = NULL,\n  cols = NULL,\n  width = NULL,\n  width_units = NULL,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\n\\method{sprinkle_width}{default}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  width = NULL,\n  width_units = NULL,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n\n\\method{sprinkle_width}{dust_list}(\n  x,\n  rows = NULL,\n  cols = NULL,\n  width = NULL,\n  width_units = NULL,\n  part = c(\"body\", \"head\", \"foot\", \"interfoot\", \"table\"),\n  fixed = FALSE,\n  recycle = c(\"none\", \"rows\", \"cols\", \"columns\"),\n  ...\n)\n}\n\\arguments{\n\\item{x}{An object of class \\code{dust}}\n\n\\item{rows}{Either a numeric vector of rows in the tabular object to be \nmodified or an object of class \\code{call}.  When a \\code{call}, \ngenerated by \\code{quote(expression)}, the expression resolves to \na logical vector the same length as the number of rows in the table.\nSprinkles are applied to where the expression resolves to \\code{TRUE}.}\n\n\\item{cols}{Either a numeric vector of columns in the tabular object to\nbe modified, or a character vector of column names. A mixture of \ncharacter and numeric indices is permissible.}\n\n\\item{width}{\\code{numeric(1)}. Gives the width of the cell.}\n\n\\item{width_units}{\\code{character(1)}. Gives the units for \\code{width}.\nOne of \\code{c(\"pt\", \"px\", \"cm\", \"in\", \"\\%\")}}\n\n\\item{part}{A character string denoting which part of the table to modify.}\n\n\\item{fixed}{\\code{logical(1)} indicating if the values in \\code{rows} \nand \\code{cols} should be read as fixed coordinate pairs.  By default, \nsprinkles are applied at the intersection of \\code{rows} and \\code{cols}, \nmeaning that the arguments do not have to share the same length.  \nWhen \\code{fixed = TRUE}, they must share the same length.}\n\n\\item{recycle}{A \\code{character} one that determines how sprinkles are \nmanaged when the sprinkle input doesn't match the length of the region\nto be sprinkled.  By default, recycling is turned off.  Recycling \nmay be performed across rows first (left to right, top to bottom), \nor down columns first (top to bottom, left to right).}\n\n\\item{...}{Additional arguments to pass to other methods. Currently ignored.}\n}\n\\description{\nCustomize the width of a cell in a table. This may be done\n  to improve the appearance of cells with long text.\n}\n\\details{\nThis sprinkle is only recognized by HTML and LaTeX.  All of the \n  \\code{width_units} values are recognized by HTML.  For LaTeX, \\code{\"px\"}\n  is converted to \\code{\"pt\"}.\n}\n\\section{Functional Requirements}{\n\n\\enumerate{\n \\item Correctly reassigns the appropriate elements of \\code{width} \n   and \\code{width_units} columns in the table part.\n \\item Casts an error if \\code{x} is not a \\code{dust} object.\n \\item Casts an error if \\code{width} is not \\code{numeric}\n \\item Casts an error if \\code{width_units} is not one of\n   \\code{c(\"px\", \"pt\", \"in\", \"cm\", \"\\%\")}.\n \\item Casts an error if \\code{part} is not one of \\code{\"body\"}, \n   \\code{\"head\"}, \\code{\"foot\"}, or \\code{\"interfoot\"}\n \\item Casts an error if \\code{fixed} is not a \\code{logical(1)}\n \\item Casts an error if \\code{recycle} is not one of \\code{\"none\"},\n   \\code{\"rows\"}, or \\code{\"cols\"}\n \\item Casts an error if \\code{recycle = \"none\"} and \\code{width} does\n   not have length 1.\n \\item Correctly assigns values when \\code{recycle} is not \\code{\"none\"}\n   and multiple values are given.\n \\item Quietly accepts only the first value in \\code{width_units} when\n   \\code{recycle = \"none\"}.\n}\n\nThe functional behavior of the \\code{fixed} and \\code{recycle} arguments \nis not tested for this function. It is tested and validated in the\ntests for \\code{\\link{index_to_sprinkle}}.\n}\n\n\\seealso{\n\\code{\\link{sprinkle}}, \n  \\code{\\link{index_to_sprinkle}}\n}\n"
  },
  {
    "path": "man/str_extract_base.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/str_extract_base.R\n\\name{str_extract_base}\n\\alias{str_extract_base}\n\\alias{str_split_fixed_base}\n\\title{Extract Patterns from Character Strings}\n\\source{\nhttps://stackoverflow.com/a/27274231/1017276\n}\n\\usage{\nstr_extract_base(x, pattern)\n\nstr_split_fixed_base(x, pattern, n)\n}\n\\arguments{\n\\item{x}{\\code{character} vector.}\n\n\\item{pattern}{\\code{character(1)} of the pattern to find in \\code{x}}\n\n\\item{n}{The number of splits.}\n}\n\\description{\nThis is a utility function that follow the pattern of\n  \\code{stringr::str_extract_all}.  It is provided to avoid the \n  dependency on the \\code{stringr} package.\n}\n\\seealso{\n\\code{stringr::str_extract_all}\n}\n"
  },
  {
    "path": "man/tidy_levels_labels.Rd",
    "content": "% Generated by roxygen2: do not edit by hand\n% Please edit documentation in R/tidy_levels_labels.R\n\\name{tidy_levels_labels}\n\\alias{tidy_levels_labels}\n\\title{Term and Level Descriptions for \\code{pixiedust} Tables}\n\\usage{\ntidy_levels_labels(\n  object,\n  descriptors = \"term\",\n  numeric_level = c(\"term\", \"term_plain\", \"label\"),\n  argcheck = NULL\n)\n}\n\\arguments{\n\\item{object}{A model object, ideally with a \\code{model.frame} method.\nIt is unclear at the moment (18 Sept. 2015) what will happen if\nan object is passed that does not have a \\code{model.frame} method.}\n\n\\item{descriptors}{A character vector indicating the descriptors to\nbe used in the table.  Acceptable inputs are \\code{\"term\"}, \n\\code{\"term_plain\"}, \\code{\"label\"}, \\code{\"level\"}, and \n\\code{\"level_detail\"}.  These may be used in any combination and\nany order, with the descriptors appearing in the table from left\nto right in the order given.  The default, \\code{\"term\"}, returns\nonly the term descriptor and is identical to the output provided\nby \\code{broom::tidy} methods.  See Details for a full explanation\nof each option and the Examples for sample output.}\n\n\\item{numeric_level}{A character string that determines which descriptor\nis used for numeric variables in the \\code{\"level_detail\"} descriptor\nwhen a numeric has an interaction with a factor.  Acceptable inputs\nare \\code{\"term\"}, \\code{\"term_plain\"}, and \\code{\"label\"}.}\n\n\\item{argcheck}{An assert collection created by \\code{checkmate::makeAssertCollection}.\nUnder normal circumstances, this is passed from \\code{dust}.  If \\code{NULL},\nas in the case it is run outside of \\code{dust}, a new collection is\ncreated and the assertions are reported within \\code{tidy_levels_labels}.}\n}\n\\description{\nDefault model objects identify rows of results with \n  appropriate term name.  More often than not, the term name is \n  not suitable for formally reported output.  \\code{tidy_levels_labels}\n  performs some basic work to quickly provide more readable \n  descriptors for cases where they can easily be obtained.  These\n  descriptors are retrieved from the data, however, so the \n  utility is determined by the user's habits in providing \n  term labels and meaningful factor levels.  \n  \n  Due to the complexity of the terms that could be used for a model,\n  it isn't practical to attempt to recover human-ready descriptors\n  for every conceivable term.  This would require recovering variable\n  names for any number of functions.  \\code{pixiedust} only \n  goes after the easiest to obtain. Replacements no managed by \n  \\code{tidy_levels_labels} may still be made with the \\code{replace}\n  sprinkle.\n}\n\\details{\nThe user may select up to five columns of descriptors, \n  although doing so would certainly create some ambiguity.  See\n  the Examples for sample output.\n  \\itemize{\n    \\item{\\code{\"term\"} }{The term name used in the R model summary}\n    \\item{\\code{\"term_plain\"} }{The term name used in the formula.\n      For variables that produce multiple term names (such as factors),\n      the plain term name may be duplicated.  For example, a factor that\n      has term names \\code{FctrB} and \\code{FctrC}, indicating rows for \n      levels \\code{B} and \\code{C} of the variable \\code{Fctr}, will \n      have two rows of \\code{\"term_plain\"} of just \\code{Fctr}.}\n    \\item{\\code{\"label\"} }{Provides the label attached to the data using\n      \\code{labelVector::get_label}.  When a term is not associated with a label, \n      the value of \\code{term_plain} is returned instead. Note that, variable names\n      will disassociate with a label if they are used in a function (such\n      as \\code{factor(x)} or \\code{x^2}.}\n    \\item{\\code{\"level\"} }{Indicates the level being compared within a factor \n      (or an interaction involving a factor), otherwise it returns \\code{NA}.\n      It may also be said that this value is the appendix to a factor name.  \n      For the term \\code{FctrB}, this would just be \\code{B}.}\n    \\item{\\code{\"level_detail\"} }{Gives additional information to \\code{level}\n      by including the reference level of the factor.  For the term \\code{FctrB},\n      this would return \\code{\"B vs A\"}.  When an interaction with a numeric\n      variable is present, the \\code{level} for the numeric may be either \n      \\code{term_plain} or \\code{label}, the choice being controlled by the\n      \\code{level_detail} argument.}\n  }\n}\n\\section{Restrictions}{\n\nThe descriptors, other than \\code{\"term\"}, generally don't make sense for data \nframe objects.  The use of \\code{tidy_levels_labels} is not permitted within\nthe \\code{dust} function, but is allowed if you really want it by \n\\code{pixiedust:::tidy_levels_labels}.\n\nOther special cases noted in future uses will be documented here, but in \ngeneral, if it isn't a model object, you probably don't really want to \nuse this.\n}\n\n\\examples{\n#* Descriptors for lm output with no interactions\nmtcars2 <- mtcars\nmtcars2$mpg <- labelVector::set_label(mtcars2$mpg, \"Gas Mileage\")\nmtcars2$qsec <-  labelVector::set_label(mtcars2$qsec, \"Quarter Mile Time\")\nmtcars2$am <-  labelVector::set_label(mtcars2$am, \"Transmission\")\nmtcars2$wt <-  labelVector::set_label(mtcars2$wt, \"Weight\")\nmtcars2$gear <-  labelVector::set_label(mtcars2$gear, \"Gears\")\n\n#* Basic Output for a model with no interactions\n#* Note: numeric_level has no impact as there are no\n#*       interactions involving numeric variables.\n\nfit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars2)\n\npixiedust:::tidy_levels_labels(fit, \n  descriptors = c(\"term\", \"term_plain\", \"label\", \"level\", \"level_detail\"),\n  numeric_level = \"term\") \n  \n#* Assign factors ahead of the model. This allows \n#* the user to determine the levels that display.\n#* Compare the output for 'am' with the output for 'gear'\n\nmtcars2$am <- factor(mtcars2$am, 0:1, c(\"Automatic\", \"Manual\"))\nmtcars2$am <-  labelVector::set_label(mtcars2$am, \"Transmission\") \n    # Label was lost in variable conversion\nfit <- lm(mpg ~ qsec + am + wt + factor(gear), data = mtcars2)\npixiedust:::tidy_levels_labels(fit, \n  descriptors = c(\"term\", \"term_plain\", \"label\", \"level\", \"level_detail\"),\n  numeric_level = \"term\") \n  \n  \n#* Include an interaction between a factor and numeric.\n\nfit <- lm(mpg ~ qsec + am * wt + factor(gear), data = mtcars2)\npixiedust:::tidy_levels_labels(fit, \n  descriptors = c(\"term\", \"term_plain\", \"label\", \"level\", \"level_detail\"),\n  numeric_level = \"term\") \n  \n#* Now observe how 'level' and 'level_detail' change \n#* in the interaction terms as we choose different \n#* values for 'numeric_level'\n\npixiedust:::tidy_levels_labels(fit, \n  descriptors = c(\"term\", \"term_plain\", \"label\", \"level\", \"level_detail\"),\n  numeric_level = \"term_plain\")\n  \npixiedust:::tidy_levels_labels(fit, \n  descriptors = c(\"term\", \"term_plain\", \"label\", \"level\", \"level_detail\"),\n  numeric_level = \"label\")  \n}\n\\author{\nBenjamin Nutter\n}\n"
  },
  {
    "path": "pixiedust.Rproj",
    "content": "Version: 1.0\n\nRestoreWorkspace: Default\nSaveWorkspace: Default\nAlwaysSaveHistory: Default\n\nEnableCodeIndexing: Yes\nUseSpacesForTab: Yes\nNumSpacesForTab: 2\nEncoding: UTF-8\n\nRnwWeave: knitr\nLaTeX: pdfLaTeX\n\nBuildType: Package\nPackageUseDevtools: Yes\nPackageInstallArgs: --no-multiarch --with-keep.source\n"
  },
  {
    "path": "tests/testthat/test-as.data.frame.R",
    "content": "context(\"as.data.frame.dust\")\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"FR 1: Accepts an object of class `dust`\",\n  {\n    skip_on_cran()\n    expect_silent(\n      as.data.frame.dust(dust(mtcars))\n    )\n  }\n)\n\ntest_that(\n  \"FR 1: Accepts an object of class `dust_list`\",\n  {\n    skip_on_cran()\n    expect_silent(\n      split(mtcars, mtcars$am) %>%\n        dust() %>%\n        as.data.frame()\n    )\n  }\n)\n\ntest_that(\n  \"FR 1: Casts an error when passed an object not of class `dust` or `dust_list`\",\n  {\n    skip_on_cran()\n    expect_error(\n      pixiedust:::as.data.frame.dust(mtcars)\n    )\n  }\n)\n\ntest_that(\n  \"FR 1: Casts an error when passed an object not of class `dust` or `dust_list`\",\n  {\n    skip_on_cran()\n    expect_error(\n      pixiedust:::as.data.frame.dust_list(mtcars)\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"FR 2: Accepts a logical indicating if sprinkles should be applied.\",\n  {\n    skip_on_cran()\n    expect_silent(\n      dust(mtcars) %>%\n        as.data.frame(sprinkled = TRUE)\n    )\n  }\n)\n\ntest_that(\n  \"FR 2: Accepts a logical indicating if sprinkles should be applied (dust_list).\",\n  {\n    skip_on_cran()\n    expect_silent(\n      split(mtcars, mtcars$am) %>%\n        dust() %>%\n        as.data.frame(sprinkled = TRUE)\n    )\n  }\n)\n\ntest_that(\n  \"FR 2: Casts error when `sprinkled` is not logical\",\n  {\n    skip_on_cran()\n    expect_error(\n      dust(mtcars) %>%\n        as.data.frame(sprinkled = 1)\n    )\n  }\n)\n\ntest_that(\n  \"FR 2: Casts error when `sprinkled` is not logical (dust_list)\",\n  {\n    skip_on_cran()\n    expect_error(\n      split(mtcars, mtcars$am) %>%\n        dust() %>%\n        as.data.frame(sprinkled = 1)\n    )\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"FR 3: Return a data frame object\",\n  {\n    skip_on_cran()\n    fit <- lm(mpg ~ qsec + factor(am) + wt * factor(gear), data = mtcars)\n    Dust <- dust(fit) %>%\n      sprinkle(cols = 2:4, round = 2) %>%\n      sprinkle(cols = 5, fn = quote(pvalString(value))) %>%\n      sprinkle(cols = 3, font_color = \"#DA70D6\") %>%\n      sprinkle_print_method(\"html\")\n    expect_true(\"data.frame\" %in% class(as.data.frame(Dust)))\n  }\n)\n\ntest_that(\n  \"FR 3: Return a data frame object when unsprinkled\",\n  {\n    skip_on_cran()\n    fit <- lm(mpg ~ qsec + factor(am) + wt * factor(gear), data = mtcars)\n    Dust <- dust(fit) %>%\n      sprinkle(cols = 2:4, round = 2) %>%\n      sprinkle(cols = 5, fn = quote(pvalString(value))) %>%\n      sprinkle(cols = 3, font_color = \"#DA70D6\") %>%\n      sprinkle_print_method(\"html\")\n    expect_true(\"data.frame\" %in% class(as.data.frame(Dust, sprinkled = FALSE)))\n  }\n)\n\n# Functional Requirement 4 ------------------------------------------\n\ntest_that(\n  \"FR 4: Return a list of data frames (dust_list)\",\n  {\n    skip_on_cran()\n    Dust <- split(mtcars, mtcars$am) %>%\n      dust() %>%\n      as.data.frame()\n    \n    dust_class <- vapply(Dust, \n                         function(x) \"data.frame\" %in% class(x),\n                         logical(1))\n    \n    expect_true(all(dust_class))\n  }\n)\n\ntest_that(\n  \"FR 4: Return a list of data frames when unsprinkled (dust_list)\",\n  {\n    skip_on_cran()\n    Dust <- split(mtcars, mtcars$am) %>%\n      dust() %>%\n      as.data.frame(sprinkled = FALSE)\n    \n    dust_class <- vapply(Dust, \n                         function(x) \"data.frame\" %in% class(x),\n                         logical(1))\n    \n    expect_true(all(dust_class))\n  }\n)\n\n"
  },
  {
    "path": "tests/testthat/test-colors.R",
    "content": "context(\"Pixiedust Colors\")\n\nx <- dust(lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars))\n\ntest_that(\n  \"lowercase color\",\n  {\n    expect_silent(sprinkle(x, bg = \"red\"))\n  }\n)\n\ntest_that(\n  \"uppercase color\",\n  {\n    expect_silent(sprinkle(x, bg = \"RED\"))\n  }\n)\n\ntest_that(\n  \"mixed-case color\",\n  {\n    expect_silent(sprinkle(x, bg = \"ReD\"))\n  }\n)\n\ntest_that(\n  \"rgb color\",\n  {\n    expect_silent(sprinkle(x, bg = \"rgb(255,0,0)\"))\n  }\n)\n\ntest_that(\n  \"rgba color\",\n  {\n    expect_silent(sprinkle(x, bg = \"rgba(255,0,0,0)\"))\n  }\n)\n\ntest_that(\n  \"rgba color decimal alpha\",\n  {\n    expect_silent(sprinkle(x, bg = \"rgba(255,0,0,.10)\"))\n  }\n)\n\ntest_that(\n  \"rgba color decimal alpha preceded by 0\",\n  {\n    expect_silent(sprinkle(x, bg = \"rgba(255,0,0,0.10)\"))\n  }\n)\n\ntest_that(\n  \"rgba color 1.0 alpha\",\n  {\n    expect_silent(sprinkle(x, bg = \"rgba(255,0,0,1.0)\"))\n  }\n)\n\ntest_that(\n  \"hexidecimal color\",\n  {\n    expect_silent(sprinkle(x, bg = \"#FF0000\"))\n  }\n)\n\ntest_that(\n  \"hexidecimal color with transparency\",\n  {\n    expect_silent(sprinkle(x, bg = \"#FF0000F0\"))\n  }\n)\n\ntest_that(\n  \"transparent color\",\n  {\n    expect_silent(sprinkle(x, bg = \"transparent\"))\n  }\n)\n"
  },
  {
    "path": "tests/testthat/test-dust.R",
    "content": "context(\"Create a dust object\")\n\nfit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n\ntest_that(\"Create a dust object\",\n{\n  x <- dust(fit)\n  \n  expect_equal(class(x), \"dust\")\n})\n\ntest_that(\"dust object has expected names\",\n{\n  x <- dust(fit)\n  \n  expect_equal(names(x), \n               c(\"head\",            \"body\",        \"interfoot\",   \"foot\", \n                 \"border_collapse\", \"caption\",     \"caption_number\", \"label\",       \n                 \"justify\", \n                 \"float\",           \"longtable\",   \"table_width\", \"tabcolsep\", \n                 \"hhline\",          \"bookdown\",    \"fixed_header\", \"include_fixed_header_css\",\n                 \"fixed_header_param\", \n                 \"html_preserve\",   \"print_method\"))\n})\n\ntest_that(\"dust object body component has correct dimensions\",\n{\n  fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n  x <- dust(fit)\n  \n  Dims <- list(dim(x$head),\n               dim(x$body),\n               dim(x$interfoot),\n               dim(x$foot))\n  \n  expect_equal(Dims, \n               list(c(5, 37), \n                    c(30, 37),\n                    NULL,\n                    NULL))\n})\n\ntest_that(\"dust runs when passed a data frame with tidy_df = FALSE\",\n{\n  expect_silent(dust(mtcars, tidy_df = FALSE))\n})\n\ntest_that(\"dust runs when passed a data frame with tidy_df = TRUE\",\n{\n  # 25 Jun 2018 Changed to expect warning since broom is deprecating data frame\n  #             tidiers\n  if (utils::compareVersion(as.character(packageVersion(\"broom\")), \"0.4.5\") == 1)\n    expect_warning(dust(mtcars, tidy_df = TRUE))\n  else\n    expect_silent(dust(mtcars, tidy_df = TRUE))\n})\n\ntest_that(\"dust with keep_rownames = TRUE adds rownames to object\",\n{\n  x <- dust(mtcars, keep_rownames = TRUE)\n  expect_equal(x$body$value[1:32], rownames(mtcars))\n})\n\ntest_that(\"dust with additional descriptors\",\n{\n  expect_silent(dust(fit, \n                    descriptors = c(\"label\", \"level_detail\")))\n})\n\ntest_that(\"dust with additional descriptors and term_plain numeric_label\",\n{\n  expect_silent(dust(fit,\n                   descriptors = c(\"label\", \"level_detail\"),\n                   numeric_label = \"term_plain\"))\n})\n\ntest_that(\"dust with glance_foot\",\n{\n  expect_silent(dust(fit, glance_foot = TRUE))\n})\n\ntest_that(\"dust with glance_foot and col_pairs a divisor of total_cols\",\n{\n  fit <- lm(mpg ~ qsec + factor(am) + wt * factor(gear), data = mtcars)\n  expect_silent(dust(fit,\n                     descriptors = c(\"label\", \"level_detail\"),\n                     glance_foot = TRUE, \n                     col_pairs = 3))\n})\n\n\ntest_that(\"dust a list\",\n{\n  x <- split(mtcars, list(mtcars$am, mtcars$vs))\n  expect_silent(dust(x))\n})\n\n\ntest_that(\n  \"dust with descriptors\",\n  {\n    expect_silent(\n      dust(fit, descriptors = c(\"term_plain\", \"label\", \"level\"))\n    )\n  }\n)\n"
  },
  {
    "path": "tests/testthat/test-dust.grouped_df.R",
    "content": "context(\"Dust a grouped_df\")\n\ntest_that(\"ungroup a grouped_df\",\n{\n  expect_silent(\n    dust(mtcars %>%\n                 dplyr::group_by(am, vs))\n  )\n})\n\ntest_that(\"split a grouped_df\",\n{\n  expect_silent(\n    dust(mtcars %>%\n           dplyr::group_by(am, vs),\n         ungroup = FALSE)\n  )\n})\n"
  },
  {
    "path": "tests/testthat/test-fixed_header_css.R",
    "content": "context(\"fixed_header_css.R\")\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"If pretty = TRUE, print results to the console\",\n  {\n    expect_output(fixed_header_css())\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"If pretty = FALSE, Return a character string of length 1\",\n  {\n    checkmate::expect_character(fixed_header_css(pretty = FALSE),\n                                len = 1)\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Cast an error if scroll_body_height is not integerish(1)\",\n  {\n    expect_error(fixed_header_css(scroll_body_height = c(100, 200)),\n                 \"Must have length 1\")\n  }\n)\n\ntest_that(\n  \"Cast an error if scroll_body_height is not integerish(1)\",\n  {\n    expect_error(fixed_header_css(scroll_body_height = \"100\"),\n                 \"Must be of type 'integerish'\")\n  }\n)\n\n# Functional Requirement 4 ------------------------------------------\n\ntest_that(\n  \"Cast an error if scroll_body_height_units is not character(1)\",\n  {\n    expect_error(fixed_header_css(scroll_body_height_units = 100),\n                 \"'character'\")\n  }\n)\n\ntest_that(\n  \"Cast an error if scroll_body_height is not character(1)\",\n  {\n    expect_error(fixed_header_css(scroll_body_height_units = c(\"pt\", \"px\")),\n                 \"Must have length 1\")\n  }\n)\n\n# Functional Requirement 5 ------------------------------------------\n\ntest_that(\n  \"Cast an error if scroll_body_background_color is not character(1)\",\n  {\n    expect_error(fixed_header_css(scroll_body_background_color = 100),\n                 \"Must be of type 'character'\")\n  }\n)\n\ntest_that(\n  \"Cast an error if scroll_body_background_color is not character(1)\",\n  {\n    expect_error(fixed_header_css(scroll_body_background_color = c(\"orchid\", \"purple\")),\n                 \"Must have length 1\")\n  }\n)\n\n# Functional Requirement 6 ------------------------------------------\n\ntest_that(\n  \"Cast an error if scroll_body_background_color is not a valid color\",\n  {\n    expect_error(fixed_header_css(scroll_body_background_color = c(\"not a color\")),\n                 \"is not a valid color\")\n  }\n)\n\n# Functional Requirement 7 ------------------------------------------\n\ntest_that(\n  \"Cast an error if fixed_header_height is not integerish(1)\",\n  {\n    expect_error(fixed_header_css(fixed_header_height = c(100, 200)),\n                 \"Must have length 1\")\n  }\n)\n\ntest_that(\n  \"Cast an error if fixed_header_height is not integerish(1)\",\n  {\n    expect_error(fixed_header_css(fixed_header_height = \"100\"))\n  }\n)\n\n# Functional Requirement 8 -----------------------------------------\n\ntest_that(\n  \"Cast an error if fixed_header_height_units is not character(1)\",\n  {\n    expect_error(fixed_header_css(fixed_header_height_units = 100),\n                 \"'character'\")\n  }\n)\n\ntest_that(\n  \"Cast an error if fixed_header_height is not character(1)\",\n  {\n    expect_error(fixed_header_css(fixed_header_height_units = c(\"pt\", \"px\")),\n                 \"Must have length 1\")\n  }\n)\n\n# Functional Requirement 9 -----------------------------------------\n\ntest_that(\n  \"Cast an error if fixed_header_text_height is not integerish(1)\",\n  {\n    expect_error(fixed_header_css(fixed_header_text_height = c(100, 200)),\n                 \"Must have length 1\")\n  }\n)\n\ntest_that(\n  \"Cast an error if fixed_header_text_height is not integerish(1)\",\n  {\n    expect_error(fixed_header_css(fixed_header_text_height = \"100\"))\n  }\n)\n\n# Functional Requirement 10 -----------------------------------------\n\ntest_that(\n  \"Cast an error if fixed_header_text_height_units is not character(1)\",\n  {\n    expect_error(fixed_header_css(fixed_header_text_height_units = 100),\n                 \"Must be of type\")\n  }\n)\n\ntest_that(\n  \"Cast an error if fixed_header_text_height is not character(1)\",\n  {\n    expect_error(fixed_header_css(fixed_header_text_height_units = c(\"pt\", \"px\")),\n                 \"Must have length 1\")\n  }\n)\n\n# Functional Requirement 11 -----------------------------------------\n\ntest_that(\n  \"Cast an error if fixed_header_background_color is not character(1)\",\n  {\n    expect_error(fixed_header_css(fixed_header_background_color = 100),\n                 \"Must be of type 'character'\")\n  }\n)\n\ntest_that(\n  \"Cast an error if fixed_header_background_color is not character(1)\",\n  {\n    expect_error(fixed_header_css(fixed_header_background_color = c(\"orchid\", \"purple\")),\n                 \"Must have length 1\")\n  }\n)\n\n# Functional Requirement 12 -----------------------------------------\n\ntest_that(\n  \"Cast an error if fixed_header_background_color is not a valid color\",\n  {\n    expect_error(fixed_header_css(fixed_header_background_color = c(\"not a color\")),\n                 \"is not a valid color\")\n  }\n)\n\n# Functional Requirement 13 -----------------------------------------\n\ntest_that(\n  \"Cast an error if pretty is not logical(1)\",\n  {\n    expect_error(fixed_header_css(pretty = c(TRUE, FALSE)),\n                 \"Must have length 1\")\n  }\n)\n\ntest_that(\n  \"Cast an error if pretty is not logical(1)\",\n  {\n    expect_error(fixed_header_css(pretty = \"TRUE\"),\n                 \"Must be of type 'logical'\")\n  }\n)\n\n"
  },
  {
    "path": "tests/testthat/test-gaze.R",
    "content": "context(\"gaze.R\")\n\nfit1 <- lm(mpg ~ qsec + wt + factor(gear),\n           data = mtcars)\n\nfit2 <- lm(mpg ~ disp + qsec + wt + factor(gear),\n           data = mtcars)\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Return a data frame object\",\n  {\n    checkmate::expect_data_frame(\n      gaze(fit1, fit2)\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Cast an error if include_glance is not logical(1)\",\n  {\n    expect_error(\n      gaze(fit1, fit2, include_glance = \"yes\")\n    )\n  }\n)\n\ntest_that(\n  \"Cast an error if include_glance is not logical(1)\",\n  {\n    expect_error(\n      gaze(fit1, fit2, include_glance = c(TRUE, FALSE))\n    )\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Cast an error if glance_vars is not a character vector.\",\n  {\n    expect_error(\n      gaze(fit1, fit2, glance_vars = list(1:3, letters))\n    )\n  }\n)\n\n# Functional Requirement 4 ------------------------------------------\n\ntest_that(\n  \"Cast an error if digits is not integerish(1)\",\n  {\n    expect_error(\n      gaze(fit1, fit2, digits = \"two\")\n    )\n  }\n)\n\ntest_that(\n  \"Cast an error if digits is not integerish(1)\",\n  {\n    expect_error(\n      gaze(fit1, fit2, digits = c(2, 3))\n    )\n  }\n)"
  },
  {
    "path": "tests/testthat/test-get_dust_part.R",
    "content": "context(\"get_dust_part\")\n\nfoot <- \n  colMeans(mtcars) %>% \n  matrix(nrow = 1) %>% \n  as.data.frame(stringsAsFactors = FALSE) %>% \n  setNames(names(mtcars))\n\nx <- \n  dust(mtcars) %>% \n  redust(foot, part = \"foot\") %>% \n  redust(foot, part = \"interfoot\")\n  \n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Return, as a data frame, the table head\",\n  expect_equal(\n    get_dust_part(x, \"head\"),\n    names(mtcars) %>% \n      matrix(nrow = 1) %>% \n      as.data.frame(stringsAsFactors = FALSE) %>% \n      setNames(names(mtcars))\n  )\n)\n\ntest_that(\n  \"Return, as a data frame, the table foot\",\n  expect_equal(\n    get_dust_part(x, \"foot\") %>% \n      lapply(as.numeric) %>% \n      as.data.frame(),\n    foot\n  )\n)\n\ntest_that(\n  \"Return, as a data frame, the table interfoot\",\n  expect_equal(\n    get_dust_part(x, \"interfoot\") %>% \n      lapply(as.numeric) %>% \n      as.data.frame(),\n    foot\n  )\n)\n\ntest_that(\n  \"Return, as a data frame, the table body\",\n  expect_equal(\n    {\n      a <- get_dust_part(x, \"body\") %>% \n        lapply(as.numeric) %>% \n        as.data.frame()\n      rownames(a) <- rownames(mtcars)\n      a\n    },\n    mtcars\n  )\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is not a dust object\",\n  {\n    expect_error(\n      get_dust_part(mtcars)\n    )\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Cast an error if part is not one of head, foot, interfoot, or body\",\n  {\n    expect_error(\n      get_dust_part(x, \"not a part\")\n    )\n  }\n)\n\n# Additional Tests --------------------------------------------------\n\ntest_that(\n  \"Return a 0 row data frame if the part is NULL\",\n  {\n    x <- dust(head(mtcars))\n    expect_equal(\n      get_dust_part(x, \"interfoot\"),\n      structure(list(mpg = logical(0), cyl = logical(0), disp = logical(0), \n                     hp = logical(0), drat = logical(0), wt = logical(0), \n                     qsec = logical(0), vs = logical(0), am = logical(0), \n                     gear = logical(0), carb = logical(0)), \n                .Names = c(\"mpg\", \"cyl\", \"disp\", \"hp\", \"drat\", \"wt\", \"qsec\", \n                           \"vs\", \"am\", \"gear\", \"carb\"), \n                row.names = integer(0), \n                class = \"data.frame\")\n    )\n  }\n)\n"
  },
  {
    "path": "tests/testthat/test-glance_foot.R",
    "content": "context(\"glance_foot\")\n\nmtcars2 <- mtcars\nmtcars2 <- \n  labelVector::set_label(\n    mtcars2,\n    mpg = \"Gas Mileage\",\n    qsec = \"Quarter Mile Time\",\n    am = \"Transmission\",\n    wt = \"Weight\",\n    gear = \"Gears\"\n  )\n\nfit <- lm(mpg ~ qsec + factor(am) * wt + factor(gear), data = mtcars2)\n\ntest_that(\"glance_foot by column\",\n{\n  expect_silent(glance_foot(fit, col_pairs = 2, total_cols = 6))\n})\n\ntest_that(\"glance_foot by row\",\n{\n  expect_silent(glance_foot(fit, col_pairs = 2, total_cols = 6, byrow = TRUE))\n})\n\ntest_that(\"glance_foot with subset of stats\",\n{\n  expect_silent(glance_foot(fit, col_pairs = 2, total_cols = 6, byrow = TRUE,\n                          glance_stats = c(\"r.squared\", \"adj.r.squared\",\n                                           \"df\", \"AIC\")))\n})\n\ntest_that(\"glance_foot with invalid stats requested\",\n{\n  expect_warning(glance_foot(fit, col_pairs = 2, total_cols = 6, byrow = TRUE,\n                          glance_stats = c(\"r.squared\", \"adj.r.squared\",\n                                           \"df\", \"AIC-xy\")))\n})\n\ntest_that(\"glance_foot with no valid stats requested\",\n{\n  expect_error(\n    expect_warning(\n      glance_foot(\n        fit, \n        col_pairs = 2, \n        total_cols = 6, \n        byrow = TRUE,\n        glance_stats = c(\"r.squared-x\", \"adj.r.squared-x\",\n                         \"df-x\", \"AIC-xy\")\n      )\n    )\n  )\n})\n\ntest_that(\"glance_foot with too few total_cols\",\n{\n  expect_error(\n    expect_warning(\n      glance_foot(\n        fit, \n        col_pairs = 2, \n        total_cols = 3, \n        byrow = TRUE,\n        glance_stats = c(\"r.squared\", \"adj.r.squared\",\n                         \"df\", \"AIC-xy\")\n      )\n    )\n  )\n})"
  },
  {
    "path": "tests/testthat/test-index_to_sprinkle.R",
    "content": "context(\"index_to_sprinkle.R\")\n\nx <- dust(head(mtcars))\n\n# Tests to cover aspects of index_to_sprinkle note picked up by other tests\n\ntest_that(\n  \"`rows` must be either numeric or a call object\",\n  {\n    expect_error(sprinkle_bg(x, \n                          rows = c(\"1\", \"2\"), \n                          bg = \"blue\"))\n  }\n)\n\n\ntest_that(\n  \"`cols` must be a numeric or character vector\",\n  expect_error(\n    sprinkle_bg(x,\n                cols = c(TRUE, FALSE),\n                bg = \"blue\")\n  )\n)\n\n\ntest_that(\n  \"When `fixed = TRUE`, rows and cols must have the same length\",\n  {\n    expect_error(\n      sprinkle_bg(x,\n                  cols = 1:2,\n                  rows = 1:3,\n                  fixed = TRUE,\n                  bg = \"blue\")\n    )\n  }\n)\n\n\ntest_that(\n  \"Cast an error for invalid rows\",\n  {\n    expect_error(\n      sprinkle_bg(x, rows = 7, bg = \"blue\")\n    )\n  }\n)\n\n\ntest_that(\n  \"Cast an error for invalid columns\",\n  {\n    expect_error(\n      sprinkle_bg(x, rows = 12, bg = \"blue\")\n    )\n  }\n)\n\n\ntest_that(\n  \"recycle = columns is correctly translated\",\n  {\n    expect_silent(\n      sprinkle_bg(x, rows = 1:2, cols = 1:3, \n                  bg = c(\"red\", \"blue\"),\n                  recycle = \"columns\")\n    )\n  }\n)\n\n"
  },
  {
    "path": "tests/testthat/test-is_valid_color.R",
    "content": "context(\"is_valid_color\")\n\n# Functional Requirement --------------------------------------------\n\ntest_that(\n  \"Returns a logical vector correclty identifying valid color formats\",\n  {\n    skip_on_cran()\n    col <- expand.grid(R = seq(0, 255, by = 50),\n                       G = seq(0, 255, by = 50),\n                       B = seq(0, 255, by = 50))\n    col <- sprintf(\"rgb(%s, %s, %s)\",\n                   col$R,\n                   col$G, \n                   col$B)\n    expect_equal(\n      is_valid_color(c(col, \"rgb(255, 255, 255)\")),\n      rep(TRUE, length(col) + 1)\n    )\n  }\n)\n\ntest_that(\n  \"Returns a logical vector correctly identifying valid color formats\",\n  {\n    skip_on_cran()\n    expect_equal(\n      is_valid_color(c(\"rgb(-1, 000, 0)\", \"rgb(5, 15, 256)\", \"rgb(5, 322, 100)\")),\n                     c(FALSE, FALSE, FALSE)\n    )\n  }\n)\n\ntest_that(\n  \"Returns a logical vector correclty identifying valid color formats\",\n  {\n    skip_on_cran()\n    col <- expand.grid(R = seq(0, 255, by = 50),\n                       G = seq(0, 255, by = 50),\n                       B = seq(0, 255, by = 50),\n                       A = seq(0, 1, by = .2))\n    col <- sprintf(\"rgba(%s, %s, %s, %s)\",\n                   col$R,\n                   col$G, \n                   col$B,\n                   col$A)\n    expect_equal(\n      is_valid_color(c(col, \"rgba(255, 255, 255, 0.5)\")),\n      rep(TRUE, length(col) + 1)\n    )\n  }\n)\n\ntest_that(\n  \"Returns a logical vector correctly identifying valid color formats\",\n  {\n    skip_on_cran()\n    expect_equal(\n      is_valid_color(c(\"rgba(-1, 000, 0, 0.5)\", \"rgb(5, 15, 256, 0.5)\", \n                       \"rgb(5, 322, 100, 0.5)\",\n                       \"rgba(000, 000, 255, 1.1)\", \"rgba(256, 100, 15, -0.2)\",\n                       \"rgba(123, 123, 123, 1.00000001)\")),\n      c(FALSE, FALSE, FALSE, FALSE, FALSE, FALSE)\n    )\n  }\n)\n\ntest_that(\n  \"Returns a logical vector correclty identifying valid color formats\",\n  {\n    skip_on_cran()\n    col <- expand.grid(R = sample(c(0:9, LETTERS[1:6]), 4),\n                       R2 = sample(c(0:9, LETTERS[1:6]), 4),\n                       G = sample(c(0:9, LETTERS[1:6]), 4),\n                       G2 = sample(c(0:9, LETTERS[1:6]), 4),\n                       B = sample(c(0:9, LETTERS[1:6]), 4),\n                       B2 = sample(c(0:9, LETTERS[1:6]), 4))\n    col <- sprintf(\"#%s%s%s%s%s%s\",\n                   col$R, col$R2,\n                   col$G, col$G2,\n                   col$B, col$B2)\n    expect_equal(\n      is_valid_color(c(col, \"#000000\", \"#FFFFFF\")),\n      rep(TRUE, length(col) + 2)\n    )\n  }\n)\n\ntest_that(\n  \"Returns a logical vector correctly identifying valid color formats\",\n  {\n    skip_on_cran()\n    expect_equal(\n      is_valid_color(c(\"#00000G\", \"#AAAAZA\", \"#BBBQBB\", \"#CCLCCC\",\n                       \"#DSDDDD\", \"#NEEEEE\")),\n      c(FALSE, FALSE, FALSE, FALSE, FALSE, FALSE)\n    )\n  }\n)\n    \ntest_that(\n  \"Returns a logical vector correclty identifying valid color formats\",\n  {\n    skip_on_cran()\n    col <- expand.grid(R = sample(c(0:9, LETTERS[1:6]), 2),\n                       R2 = sample(c(0:9, LETTERS[1:6]), 2),\n                       G = sample(c(0:9, LETTERS[1:6]), 2),\n                       G2 = sample(c(0:9, LETTERS[1:6]), 2),\n                       B = sample(c(0:9, LETTERS[1:6]), 2),\n                       B2 = sample(c(0:9, LETTERS[1:6]), 2),\n                       A = sample(c(0:9, LETTERS[1:6]), 4),\n                       A2 = sample(c(0:9, LETTERS[1:6], 4)))\n    col <- sprintf(\"#%s%s%s%s%s%s%s%s\",\n                   col$R, col$R2,\n                   col$G, col$G2,\n                   col$B, col$B2,\n                   col$A, col$A2)\n    expect_equal(\n      is_valid_color(c(col, \"#00000000\", \"#FFFFFFFF\")),\n      rep(TRUE, length(col) + 2)\n    )\n  }\n)\n\ntest_that(\n  \"Returns a logical vector correctly identifying valid color formats\",\n  {\n    skip_on_cran()\n    expect_equal(\n      is_valid_color(c(\"#000000AG\", \"#AAAAAAGA\")),\n      c(FALSE, FALSE)\n    )\n  }\n)\n\ntest_that(\n  \"Returns a logical vector correctly identifying valid color formats\",\n  {\n    skip_on_cran()\n    expect_equal(\n      is_valid_color(c(colors(), \"transparent\")),\n      rep(TRUE, length(colors()) + 1)\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Cast an error if color is not a character object\",\n  {\n    skip_on_cran()\n    expect_error(is_valid_color(1:3))\n  }\n)"
  },
  {
    "path": "tests/testthat/test-medley.R",
    "content": "context(\"Medleys\")\n\nfit <- lm(mpg ~ qsec + factor(am) + wt * factor(gear), data = mtcars)\n\ntest_that(\"medley_bw\",\n{\n  expect_silent(\n    dust(fit) %>%\n      medley_bw() %>%\n      sprinkle_print_method(\"html\")\n  )\n\n})\n\ntest_that(\"medley_model\",\n{\n  expect_silent(\n    dust(fit, \n         glance_foot = TRUE) %>%\n    medley_model() %>%\n    sprinkle_print_method(\"html\")\n  )\n})"
  },
  {
    "path": "tests/testthat/test-medley_all_borders.R",
    "content": "context(\"medley_all_borders\")\n\nfit <- lm(mpg ~ qsec + factor(am) + wt * factor(gear), data = mtcars)\n\ntest_that(\"medley_all_borders with defaults\",\n{\n  expect_silent(\n    dust(fit) %>%\n      medley_all_borders()\n  )\n})\n\ntest_that(\"medley_all_borders with horizontal = FALSE\",\n{\n  expect_silent(\n    dust(fit) %>%\n      medley_all_borders(rows = 2, \n                         cols = 3,\n                         horizontal = FALSE)\n  )\n})\n\ntest_that(\"medley_all_borders with vertical = FALSE\",\n{\n  expect_silent(\n    dust(fit) %>%\n      medley_all_borders(rows = 2:4,\n                         cols = 3:5, \n                         vertical = FALSE) %>%\n      sprinkle_print_method(\"html\")\n  )\n})\n\ntest_that(\n  \"medley_all_borders with part = 'table'\",\n  {\n    expect_silent(\n      dust(fit) %>% medley_all_borders(part = \"table\") %>%\n        sprinkle_print_method(\"html\")\n    )\n  }\n)\n            \n  "
  },
  {
    "path": "tests/testthat/test-perform_function.R",
    "content": "context(\"perform_function\")\n\ntest_that(\"Apply a calculation\",\n{\n  fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n  x <- dust(fit) %>% \n    sprinkle(row = 2, cols = 2:3, fn = quote(round(value * -1, 2)))\n  \n  x <- perform_function(x$body)\n  \n  expect_equal(x$value[x$row == 2 & x$col %in% 2:3],\n               c(\"-1.24\", \"-0.38\"))\n})\n\ntest_that(\"Apply a string manipulation\",\n{\n  fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n  x <- dust(fit) %>%\n    sprinkle(cols = 1, fn = quote(gsub(\"factor[(]gear[)]\", \"Gears: \", value)))\n            \n  x <- perform_function(x$body)\n            \n  expect_equal(x$value[x$row %in% 5:6 & x$col == 1],\n               c(\"Gears: 4\", \"Gears: 5\"))\n})"
  },
  {
    "path": "tests/testthat/test-pixie_count.R",
    "content": "context(\"pixie_count\")\n\ntest_that(\"get_pixie_count\",\n{\n  expect_equal(get_pixie_count(), 0)\n})\n\ntest_that(\"set_pixie_count\",\n{\n  set_pixie_count(4)\n  expect_equal(get_pixie_count(), 4)  \n})\n\ntest_that(\"increment_pixie_count\",\n{\n  set_pixie_count(0)\n  increment_pixie_count(1)\n  expect_equal(get_pixie_count(), 1)\n})\n\ntest_that(\"increment_pixie_count, non-1 increment\",\n{\n  set_pixie_count(3)\n  increment_pixie_count(2)\n  expect_equal(get_pixie_count(), 5)\n})"
  },
  {
    "path": "tests/testthat/test-pixieply.R",
    "content": "context(\"pixieply\")\n\ntest_that(\"apply medley to dust_list\",\n{\n  expect_silent(\n    pixieply(\n      dust(mtcars %>%\n             dplyr::group_by(am, vs),\n           ungroup = FALSE),\n      medley_all_borders\n    )\n  )\n})\n\n\ntest_that(\n  \"apply unique captions to dust_list\",\n  {\n    mtcars %>%\n      dplyr::group_by(gear) %>%\n      dust(ungroup = FALSE) %>%\n      pixiemap(FUN = sprinkle,\n               caption = sprintf(\"gear = %s\", sort(unique(mtcars$gear)))) %>%\n      expect_silent()\n  }\n)\n"
  },
  {
    "path": "tests/testthat/test-print.dust-explicit.R",
    "content": "context(\"print.dust-explicit\")\n\ntest_that(\"print.dust for console output\",\n{\n  expect_output(\n    print(dust(mtcars) %>% sprinkle_print_method(\"console\"))\n  )\n})\n\ntest_that(\"print.dust for markdown output\",\n{\n  expect_silent(\n    print(dust(mtcars) %>% sprinkle_print_method(\"markdown\"))\n  )\n})\n\ntest_that(\"print.dust for html output\",\n{\n  expect_silent(\n    print(dust(mtcars) %>% sprinkle_print_method(\"html\"))\n  )\n})\n\ntest_that(\"print.dust for latex output with hhline = FALSE\",\n{\n  expect_silent(\n    print(dust(mtcars) %>% sprinkle_print_method(\"latex\"))\n  )\n})\n\ntest_that(\"print.dust for latex output with hhline = TRUE\",\n{\n  expect_silent(\n    print(dust(mtcars, hhline = TRUE) %>% sprinkle_print_method(\"latex\"))\n  )\n})\n\ntest_that(\"print.dust for unsupported format\",\n{\n  expect_error(\n    print(dust(mtcars) %>% sprinkle_print_method(\"unsupported format\"))\n  )\n})\n\ntest_that(\"print.dust_list\",\n{\n  x <- split(mtcars, list(mtcars$am, mtcars$vs))\n  expect_output(\n    print(dust(x))\n  )\n})\n"
  },
  {
    "path": "tests/testthat/test-print.dust.R",
    "content": "context(\"print.dust\")\r\n\r\ntest_that(\"printing to console succeeds with defaults\",\r\n{\r\n  fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\r\n  x <- dust(fit)\r\n  \r\n  expect_silent(x)\r\n})\r\n\r\ntest_that(\"printing to console succeeds with sprinkles\",\r\n{\r\n  fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\r\n  x <- dust(fit) %>% \r\n    sprinkle(rows = 2:4,\r\n             cols = 2:4,\r\n             bg = \"black\",\r\n             bold = TRUE,\r\n             border_collapse = \"collapse\",\r\n             border = c(\"left\", \"right\"),\r\n             border_thickness = 2,\r\n             border_units = \"px\",\r\n             border_style = \"solid\",\r\n             border_color = \"purple\",\r\n             halign = \"left\",\r\n             height = 7,\r\n             height_units = \"px\",\r\n             fn = quote(value * -1),\r\n             font_color = \"orchid\",\r\n             font_size = 14,\r\n             font_size_units = \"px\",\r\n             italic = TRUE,\r\n             pad = 8,\r\n             round = 3,\r\n             rotate_degree = -45,\r\n             valign = \"bottom\",\r\n             width = 15,\r\n             width_units = \"%\")\r\n  \r\n  expect_silent(x)\r\n})\r\n\r\ntest_that(\"printing to console succeeds with sprinkles\",\r\n{\r\n  fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\r\n  x <- dust(fit) %>% \r\n    sprinkle(rows = 2:4,\r\n             cols = 2:4,\r\n             bg = \"black\",\r\n             bold = TRUE,\r\n             border_collapse = \"collapse\",\r\n             border = c(\"left\", \"right\"),\r\n             border_thickness = 2,\r\n             border_units = \"px\",\r\n             border_style = \"solid\",\r\n             border_color = \"purple\",\r\n             halign = \"left\",\r\n             height = 7,\r\n             height_units = \"px\",\r\n             fn = quote(value * -1),\r\n             font_color = \"orchid\",\r\n             font_size = 14,\r\n             font_size_units = \"px\",\r\n             italic = TRUE,\r\n             pad = 8,\r\n             round = 3,\r\n             rotate_degree = -45,\r\n             valign = \"bottom\",\r\n             width = 15,\r\n             width_units = \"%\") %>% \r\n    sprinkle_print_method(\"markdown\")\r\n          \r\n  expect_silent(x)\r\n})\r\n\r\ntest_that(\"printing to console succeeds with sprinkles\",\r\n{\r\n  fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\r\n  x <- dust(fit) %>% \r\n    sprinkle(rows = 2:4,\r\n             cols = 2:4,\r\n             bg = \"black\",\r\n             bold = TRUE,\r\n             border_collapse = \"inherit\",\r\n             border = c(\"left\", \"right\"),\r\n             border_thickness = 2,\r\n             border_units = \"px\",\r\n             border_style = \"solid\",\r\n             border_color = \"purple\",\r\n             halign = \"left\",\r\n             height = 7,\r\n             height_units = \"px\",\r\n             fn = quote(value * -1),\r\n             font_color = \"orchid\",\r\n             font_size = 14,\r\n             font_size_units = \"px\",\r\n             italic = TRUE,\r\n             pad = 8,\r\n             round = 3,\r\n             rotate_degree = -45,\r\n             valign = \"bottom\",\r\n             width = 15,\r\n             width_units = \"%\") %>% \r\n    sprinkle_print_method(\"html\")\r\n          \r\n  expect_silent(x)\r\n})\r\n"
  },
  {
    "path": "tests/testthat/test-print_dust_html.R",
    "content": "context(\"print_dust_html\")\n\ntest_that(\n  \"print_dust_html with fixed header\",\n  {\n    skip_on_cran()\n    x <- dust(mtcars) %>% \n      sprinkle(fixed_header = TRUE) \n      \n    expect_silent(print_dust_html(x))\n  }\n)\n\ntest_that(\n  \"print_dust_html with interactive = FALSE\",\n  {\n    skip_on_cran()\n    x <- dust(mtcars)\n    \n    expect_silent(print_dust_html(x,\n                                  interactive = FALSE))\n  }\n)\n\ntest_that(\n  \"print_dust_html with interactive = FALSE, asis = FALSE\",\n  {\n    skip_on_cran()\n    x <- dust(mtcars)\n    \n    expect_silent(print_dust_html(x, \n                                  interactive = FALSE, \n                                  asis = FALSE))\n  }\n)\n\n"
  },
  {
    "path": "tests/testthat/test-print_dust_latex.R",
    "content": "context(\"print_dust_latex\")\n\ntest_that(\n  \"print_dust_latex\",\n  {\n    skip_on_cran()\n    fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n    x <- dust(fit) %>% \n      sprinkle(rows = 2:4,\n               cols = 2:4,\n               bg = \"black\",\n               bold = TRUE,\n               border_collapse = \"collapse\",\n               border = c(\"left\", \"right\"),\n               border_thickness = 2,\n               border_units = \"px\",\n               border_style = \"solid\",\n               border_color = \"purple\",\n               halign = \"left\",\n               height = 7,\n               height_units = \"px\",\n               fn = quote(value * -1),\n               font_color = \"orchid\",\n               font_size = 14,\n               font_size_units = \"px\",\n               italic = TRUE,\n               pad = 8,\n               round = 3,\n               rotate_degree = -45,\n               valign = \"bottom\",\n               width = 15,\n               width_units = \"%\") %>%\n      sprinkle_print_method(\"latex\")\n    \n    expect_silent(print_dust_latex(x))\n  })\n\ntest_that(\n  \"print_dust_latex with a label\",\n  {\n    skip_on_cran()\n    fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n    x <- dust(fit,\n              label = \"some label\") %>%\n      sprinkle_print_method(\"latex\")\n    \n    expect_silent(print_dust_latex(x))\n  })\n\ntest_that(\n  \"print_dust_latex with bookdown and no label\",\n  {\n    skip_on_cran()\n    fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n    x <- dust(fit,\n              bookdown = TRUE) %>%\n      sprinkle_print_method(\"latex\")\n    \n    expect_silent(print_dust_latex(x))\n  })\n\ntest_that(\n  \"print_dust_latex with bookdown and a label\",\n  {\n    skip_on_cran()\n    fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n    x <- dust(fit,\n              bookdown = TRUE,\n              label = \"some label\") %>%\n      sprinkle_print_method(\"latex\")\n    \n    expect_silent(print_dust_latex(x))\n  })\n\ntest_that(\n  \"print_dust_latex with longtable\",\n  {\n    skip_on_cran()\n    fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n    x <- dust(fit,\n              longtable = TRUE) %>%\n      sprinkle_print_method(\"latex\")\n    \n    expect_silent(print_dust_latex(x))\n  })\n\ntest_that(\n  \"print_dust_latex with float = FALSE\",\n  {\n    skip_on_cran()\n    fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n    x <- dust(fit,\n              float = FALSE) %>%\n      sprinkle_print_method(\"latex\")\n    \n    expect_silent(print_dust_latex(x))\n  })\n\ntest_that(\n  \"print_dust_latex with HTML colors\",\n  {\n    skip_on_cran()\n    fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n    x <- dust(fit,\n              float = FALSE) %>%\n      sprinkle(bg = \"#FFFFFF\") %>% \n      sprinkle_print_method(\"latex\")\n    \n    expect_silent(print_dust_latex(x))\n  })\n\ntest_that(\n  \"print_dust_latex with rgb color\",\n  {\n    skip_on_cran()\n    fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n    x <- dust(fit,\n              float = FALSE) %>%\n      sprinkle(bg = \"rgb(255,255,255)\") %>% \n      sprinkle_print_method(\"latex\")\n    \n    expect_silent(print_dust_latex(x))\n  })\n\n\ntest_that(\n  \"print_dust_latex with vertical dashed border\",\n  {\n    skip_on_cran()\n    fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n    x <- dust(fit,\n              float = FALSE) %>%\n      sprinkle(cols = 2,\n               border = \"right\",\n               border_style = \"dashed\") %>% \n      sprinkle_print_method(\"latex\")\n    \n    expect_silent(print_dust_latex(x))\n  })\n\ntest_that(\n  \"print_dust_latex with horizontal borders\",\n  {\n    skip_on_cran()\n    fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n    x <- dust(fit,\n              float = FALSE) %>%\n      sprinkle(border = \"bottom\") %>% \n      sprinkle_print_method(\"latex\")\n    \n    expect_silent(print_dust_latex(x))\n  })\n\ntest_that(\n  \"print_dust_latex with horizontal borders\",\n  {\n    skip_on_cran()\n    fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n    x <- dust(fit,\n              float = FALSE) %>%\n      sprinkle(border = \"bottom\",\n               border_style = \"dashed\") %>% \n      sprinkle_print_method(\"latex\")\n    \n    expect_silent(print_dust_latex(x))\n  })\n\ntest_that(\n  \"print_dust_latex sanitization\",\n  {\n    skip_on_cran()\n    fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n    x <- dust(fit,\n              float = FALSE) %>%\n      sprinkle(sanitize = TRUE) %>% \n      sprinkle_print_method(\"latex\")\n    \n    expect_silent(print_dust_latex(x))\n  })"
  },
  {
    "path": "tests/testthat/test-print_dust_latex_hhline.R",
    "content": "context(\"print_dust_latex_hhline\")\n\ntest_that(\n  \"print_dust_latex_hhline\",\n  {\n    skip_on_cran()\n    fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n    x <- dust(fit,\n              hhline = TRUE) %>% \n      sprinkle(rows = 2:4,\n               cols = 2:4,\n               bg = \"black\",\n               bold = TRUE,\n               border_collapse = \"collapse\",\n               border = c(\"left\", \"right\"),\n               border_thickness = 2,\n               border_units = \"px\",\n               border_style = \"solid\",\n               border_color = \"purple\",\n               halign = \"left\",\n               height = 7,\n               height_units = \"px\",\n               fn = quote(value * -1),\n               font_color = \"orchid\",\n               font_size = 14,\n               font_size_units = \"px\",\n               italic = TRUE,\n               pad = 8,\n               round = 3,\n               rotate_degree = -45,\n               valign = \"bottom\",\n               width = 15,\n               width_units = \"%\") %>%\n      sprinkle_print_method(\"latex\")\n    \n    expect_silent(print_dust_latex_hhline(x))\n  })\n\ntest_that(\n  \"print_dust_latex_hhline with a label\",\n  {\n    skip_on_cran()\n    fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n    x <- dust(fit,\n              hhline = TRUE,\n              label = \"some label\") %>%\n      sprinkle_print_method(\"latex\")\n    \n    expect_silent(print_dust_latex_hhline(x))\n  })\n\ntest_that(\n  \"print_dust_latex_hhline with bookdown and no label\",\n  {\n    skip_on_cran()\n    fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n    x <- dust(fit,\n              hhline = TRUE,\n              bookdown = TRUE) %>%\n      sprinkle_print_method(\"latex\")\n    \n    expect_silent(print_dust_latex_hhline(x))\n  })\n\ntest_that(\n  \"print_dust_latex_hhline with bookdown and a label\",\n  {\n    skip_on_cran()\n    fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n    x <- dust(fit,\n              hhline = TRUE,\n              bookdown = TRUE,\n              label = \"some label\") %>%\n      sprinkle_print_method(\"latex\")\n    \n    expect_silent(print_dust_latex_hhline(x))\n  })\n\ntest_that(\n  \"print_dust_latex_hhline with longtable\",\n  {\n    skip_on_cran()\n    fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n    x <- dust(fit,\n              hhline = TRUE,\n              longtable = TRUE) %>%\n      sprinkle_print_method(\"latex\")\n    \n    expect_silent(print_dust_latex_hhline(x))\n  })\n\ntest_that(\n  \"print_dust_latex_hhline with float = FALSE\",\n  {\n    skip_on_cran()\n    fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n    x <- dust(fit,\n              hhline = TRUE,\n              float = FALSE) %>%\n      sprinkle_print_method(\"latex\")\n    \n    expect_silent(print_dust_latex_hhline(x))\n  })\n\ntest_that(\n  \"print_dust_latex with hhline and horizontal borders\",\n  {\n    skip_on_cran()\n    fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n    x <- dust(fit,\n              hhline = TRUE,\n              float = FALSE) %>%\n      sprinkle(border = \"bottom\") %>% \n      sprinkle_print_method(\"latex\")\n    \n    expect_silent(print_dust_latex_hhline(x))\n  })\n\ntest_that(\n  \"print_dust_latex with hhline and horizontal borders\",\n  {\n    skip_on_cran()\n    fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n    x <- dust(fit,\n              hhline = TRUE,\n              float = FALSE) %>%\n      sprinkle(border = \"bottom\",\n               border_style = \"hidden\") %>% \n      sprinkle_print_method(\"latex\")\n    \n    expect_silent(print_dust_latex_hhline(x))\n  })\n\ntest_that(\n  \"print_dust_latex with hhline and horizontal borders\",\n  {\n    skip_on_cran()\n    fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n    x <- dust(fit,\n              hhline = TRUE,\n              float = FALSE) %>%\n      sprinkle(border = \"bottom\",\n               border_style = \"solid\") %>% \n      sprinkle_print_method(\"latex\")\n    \n    expect_silent(print_dust_latex_hhline(x))\n  })\n\ntest_that(\n  \"print_dust_latex with hhline and horizontal borders\",\n  {\n    skip_on_cran()\n    fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n    x <- dust(fit,\n              hhline = TRUE,\n              float = FALSE) %>%\n      sprinkle(border = \"bottom\",\n               border_style = \"double\") %>% \n      sprinkle_print_method(\"latex\")\n    \n    expect_silent(print_dust_latex_hhline(x))\n  })"
  },
  {
    "path": "tests/testthat/test-print_dust_methods.R",
    "content": "context(\"print_dust_methods\")\n\ntest_that(\"print_dust_console\",\n{\n  skip_on_cran()\n  fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n  x <- dust(fit) %>% \n    sprinkle(rows = 2:4,\n             cols = 2:4,\n             bg = \"black\",\n             bold = TRUE,\n             border_collapse = \"collapse\",\n             border = c(\"left\", \"right\"),\n             border_thickness = 2,\n             border_units = \"px\",\n             border_style = \"solid\",\n             border_color = \"purple\",\n             halign = \"left\",\n             height = 7,\n             height_units = \"px\",\n             fn = quote(value * -1),\n             font_color = \"orchid\",\n             font_size = 14,\n             font_size_units = \"px\",\n             italic = TRUE,\n             pad = 8,\n             round = 3,\n             rotate_degree = -45,\n             valign = \"bottom\",\n             width = 15,\n             width_units = \"%\")\n  \n  expect_output(print_dust_console(x), \"\")\n})\n\ntest_that(\"print_dust_html\",\n{\n  skip_on_cran()\n  fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n  x <- dust(fit) %>% \n    sprinkle(rows = 2:4,\n             cols = 2:4,\n             bg = \"black\",\n             bold = TRUE,\n             border_collapse = \"collapse\",\n             border = c(\"left\", \"right\"),\n             border_thickness = 2,\n             border_units = \"px\",\n             border_style = \"solid\",\n             border_color = \"purple\",\n             halign = \"left\",\n             height = 7,\n             height_units = \"px\",\n             fn = quote(value * -1),\n             font_color = \"orchid\",\n             font_size = 14,\n             font_size_units = \"px\",\n             italic = TRUE,\n             pad = 8,\n             round = 3,\n             rotate_degree = -45,\n             valign = \"bottom\",\n             width = 15,\n             width_units = \"%\") %>%\n    sprinkle_print_method(\"html\")\n            \n  expect_silent(print_dust_html(x))\n})\n\ntest_that(\"print_dust_html: correction for multiple cell merge\",\n{\n  skip_on_cran()\n  custom_head <- rbind(names(mtcars), \n                       labelVector::get_label(mtcars,\n                                              names(mtcars))) %>%\n    as.data.frame(stringsAsFactors = FALSE)\n  \n  custom_foot <- rbind(vapply(mtcars, mean, numeric(1)),\n                       vapply(mtcars, sd, numeric(1))) %>%\n    as.data.frame(stringsAsFactors = FALSE)\n  \n  custom_interfoot <- data.frame(\"To Be Continued\", \n                                 \"\", \"\", \"\", \"\", \"\", \"\",\n                                 \"\", \"\", \"\", \"\")\n  suppressWarnings(\n  x <- dust(mtcars) %>%\n     redust(custom_head, part = \"head\") %>%\n     redust(custom_foot, part = \"foot\") %>%\n     redust(custom_interfoot, part = \"interfoot\") %>%\n     sprinkle_table(round = 2, longtable = 4) %>%\n     sprinkle(bg = \"gray\", part = \"head\") %>%\n     sprinkle(bg = \"lightgray\", part = \"foot\") %>%\n     sprinkle(bg = \"lightgray\", part = \"interfoot\") %>%\n     sprinkle(merge = TRUE, halign = \"center\", part = \"interfoot\") %>%\n     sprinkle_print_method(\"html\")\n  )\n\n  expect_silent(print_dust_html(x))\n})\n\ntest_that(\"print_dust_markdown\",\n{\n  skip_on_cran()\n  fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n  x <- dust(fit) %>% \n    sprinkle(rows = 2:4,\n             cols = 2:4,\n             bg = \"black\",\n             bold = TRUE,\n             border_collapse = \"collapse\",\n             border = c(\"left\", \"right\"),\n             border_thickness = 2,\n             border_units = \"px\",\n             border_style = \"solid\",\n             border_color = \"purple\",\n             halign = \"left\",\n             height = 7,\n             height_units = \"px\",\n             fn = quote(value * -1),\n             font_color = \"orchid\",\n             font_size = 14,\n             font_size_units = \"px\",\n             italic = TRUE,\n             pad = 8,\n             round = 3,\n             rotate_degree = -45,\n             valign = \"bottom\",\n             width = 15,\n             width_units = \"%\") %>%\n    sprinkle_print_method(\"markdown\")\n  \n  expect_silent(print_dust_markdown(x))\n})\n\n\ntest_that(\"print_dust_latex\",\n          {\n            skip_on_cran()\n            fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n            x <- dust(fit) %>% \n              sprinkle(rows = 2:4,\n                       cols = 2:4,\n                       bg = \"black\",\n                       bold = TRUE,\n                       border_collapse = \"collapse\",\n                       border = c(\"left\", \"right\"),\n                       border_thickness = 2,\n                       border_units = \"px\",\n                       border_style = \"solid\",\n                       border_color = \"purple\",\n                       halign = \"left\",\n                       height = 7,\n                       height_units = \"px\",\n                       fn = quote(value * -1),\n                       font_color = \"orchid\",\n                       font_size = 14,\n                       font_size_units = \"px\",\n                       italic = TRUE,\n                       pad = 8,\n                       round = 3,\n                       rotate_degree = -45,\n                       valign = \"bottom\",\n                       width = 15,\n                       width_units = \"%\") %>%\n              sprinkle_print_method(\"latex\")\n            \n            expect_silent(print_dust_latex(x))\n          })\n\ntest_that(\n  \"missing values in LaTeX output - sanitization\",\n  {\n    skip_on_cran()\n    DF <- head(mtcars)\n    DF$mpg[c(1, 3, 4)] <- NA\n    \n    expect_silent(\n      dust(DF) %>% \n        sprinkle(sanitize = TRUE) %>% \n        sprinkle_print_method(\"latex\")\n    )\n  }\n)\n\ntest_that(\n  \"print_dust_latex does not output invalid -Inf width or height\", \n  {\n    skip_on_cran()\n    fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n    x <- print_dust_latex(dust(fit))\n    expect_false(grepl(\"-Inf\", x))\n  }\n)\n\ntest_that(\n  \"html tables with bookdown label\",\n  {\n    skip_on_cran()\n    fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)\n    x <- dust(fit,\n              caption = \"Table heading\",\n              label = \"table-ref\",\n              bookdown = TRUE) %>%\n      sprinkle_print_method(\"html\") %>%\n      print(asis = FALSE)\n    expect_match(x, \"#tab:table-ref\")\n  }\n)\n\n"
  },
  {
    "path": "tests/testthat/test-pvalString.R",
    "content": "context(\"pval_string\")\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"pval_string default\",\n  {\n    expect_equal(pval_string(c(1, .9, .5, .111, .101, .0994, .0515, .0486, .001, .0001)),\n                 c('> 0.99', '0.90', '0.50', '0.11', '0.10', '0.099', '0.052', \n                   '0.049', '0.001', '< 0.001'))\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"pval_string exact\",\n  {\n    expect_equal(pval_string(c(1, .9, .5, .111, .101, .0994, .0515, .0486, .001, .0001),\n                            format = \"exact\"),\n                 c('1.000', '0.900', '0.500', '0.111', '0.101', '0.099', '0.052', \n                   '0.049', '0.001', '1.00e-04'))\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"pval_string scientific\",\n  {\n    expect_equal(pval_string(c(1, .9, .5, .111, .101, .0994, .0515, .0486, .001, .0001),\n                            format = \"scientific\"),\n                 c('1.00e+00', '9.00e-01', '5.00e-01', '1.11e-01', '1.01e-01', \n                   '9.94e-02', '5.15e-02', '4.86e-02', '1.00e-03', '1.00e-04'))\n  }\n)\n\n# Functional Requirement 4 ------------------------------------------\n\ntest_that(\n  \"cast an error if p is not numeric on the interval [0, 1]\",\n  {\n    expect_error(pval_string(1.3))\n  }\n)\n\ntest_that(\n  \"Cast an error if p is not numeric on the interval [0, 1]\",\n  {\n    expect_error(pval_string(letters))\n  }\n)\n\n# Functional Requirement 5 ------------------------------------------\n\ntest_that(\n  \"Cast an error if format is not one of default, exact, or scientific\",\n  {\n    expect_error(pval_string(0.3, format = \"not a format\"))\n  }\n)\n\n# Functional Requirement 6 ------------------------------------------\n\ntest_that(\n  \"Cast an error if digits is not integerish(1)\",\n  {\n    expect_error(pval_string(0.3, format = 'exact', digits = \"three\"))\n  }\n)\n\ntest_that(\n  \"Cast an error if digits is not integerish(1)\",\n  {\n    expect_error(pval_string(0.3, format = 'exact', digits = 3:4))\n  }\n)"
  },
  {
    "path": "tests/testthat/test-redust.R",
    "content": "context(\"redust\")\n\ntest_that(\"redust: reject tables with dissimilar column dimension\",\n{\n  x <- dust(mtcars[1:10, ])\n  expect_error(redust(x, mtcars[1:2, 1:9], part = \"head\"),\n               \"The current table has 11 columns\")\n})\n\ntest_that(\"redust: catch mismatched column counts, perhaps from someone adding a table without redust\",\n{\n  x <- dust(mtcars[1:10, ])\n  x$foot <- dust(mtcars[1:2, 1:9])$body\n  expect_error(redust(x, mtcars[1:2, 1:11], part = \"head\"))\n})\n\ntest_that(\"redust: how about a working example\",\n{\n  x <- dust(mtcars[1:10, ])\n  expect_silent(redust(x, mtcars[1:2, ], part = \"head\"))\n})\n\ntest_that(\n  \"redust: dust_list\",\n  {\n    expect_silent(\n      dplyr::group_by(mtcars, am, vs) %>% \n        dust(ungroup = FALSE) %>% \n        redust(mtcars[1:2, ], part = \"head\")\n    )\n  }\n)"
  },
  {
    "path": "tests/testthat/test-roundSafe.R",
    "content": "context(\"roundSafe\")\n\ntest_that(\"roundSafe: skip rounding for characters\",\n{\n  x <- c(1.765, \"hello\", 8.3985, \"world\")\n  expect_equal(roundSafe(x, rep(2, 4)),\n               c(\"1.76\", \"hello\", \"8.4\", \"world\"))\n})\n  "
  },
  {
    "path": "tests/testthat/test-sanitize_latex.R",
    "content": "context(\"sanitize_latex.R\")\n\ntest_that(\n  \"Sanitize basic characters.\",\n  {\n    expect_equal(\n      sanitize_latex(c(\"|\", \"%\", \"#\", \"<=\", \"<\", \">=\", \">\", \"_\", \"\\\\243\", \"&\")),\n      c(\"$|$\", \"\\\\%\", \"\\\\#\", \"$\\\\leq$\", \"$<$\", \"$\\\\geq$\", \"$>$\", \"\\\\_\",\n        \"\\\\pounds\", \"\\\\&\")\n    )\n  }\n)\n\ntest_that(\n  \"Sanitize pb characters.\",\n  {\n    expect_equal(\n      sanitize_latex(c(\"[\", \"(\", \"]\", \")\"), pb = TRUE),\n      c(\"$\\\\left[\", \"$\\\\left(\", \"\\\\right]$\", \"\\\\right)$\")\n    )\n  }\n)\n\ntest_that(\n  \"Sanitize greek characters.\",\n  {\n    expect_equal(\n      sanitize_latex(c(\"alpha\", \"beta\", \"gamma\", \"delta\"), greek = TRUE),\n      c(\"$\\\\alpha$\", \"$\\\\beta$\", \"$\\\\gamma$\", \"$\\\\delta$\")\n    )\n  }\n)\n\ntest_that(\n  \"Sanitize with a caret\",\n  {\n    expect_equal(\n      sanitize_latex(c(\"alpha^theta\"), greek = TRUE),\n      \"$\\\\alpha$$^{$\\\\theta$}$\"\n    )\n  }\n)"
  },
  {
    "path": "tests/testthat/test-sprinkle_align.R",
    "content": "context(\"sprinkle_align\")\n\nx <- dust(head(mtcars))\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of the halign column in the table part.\",\n  {\n    halign <- vector(\"character\", nrow(x$body))\n    halign[x$body$row == 1] <- \"left\"\n    expect_equal(\n      sprinkle_align(x, rows = 1, halign = \"left\")$body$halign,\n      halign\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of the halign column in the table part.\",\n  {\n    halign <- vector(\"character\", nrow(x$body))\n    halign[x$body$row == 2 & x$body$col %in% 4:5] <- \"center\"\n    expect_equal(\n      sprinkle_align(x, rows = 2, cols = 4:5, halign = \"center\")$body$halign,\n      halign\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements bg column in the table part.\",\n  {\n    halign <- vector(\"character\", nrow(x$body))\n    halign[x$body$row == 2 & x$body$col %in% 4:5] <- \"right\"\n    expect_equal(\n      sprinkle_align(x, rows = c(2, 2), cols = 4:5, halign = \"right\",\n                  fixed = TRUE)$body$halign,\n      halign\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of the valign column in the table part.\",\n  {\n    valign <- vector(\"character\", nrow(x$body))\n    valign[x$body$row == 1] <- \"top\"\n    expect_equal(\n      sprinkle_align(x, rows = 1, valign = \"top\")$body$valign,\n      valign\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of the valign column in the table part.\",\n  {\n    valign <- vector(\"character\", nrow(x$body))\n    valign[x$body$row == 2 & x$body$col %in% 4:5] <- \"middle\"\n    expect_equal(\n      sprinkle_align(x, rows = 2, cols = 4:5, valign = \"middle\")$body$valign,\n      valign\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements bg column in the table part.\",\n  {\n    valign <- vector(\"character\", nrow(x$body))\n    valign[x$body$row == 2 & x$body$col %in% 4:5] <- \"bottom\"\n    expect_equal(\n      sprinkle_align(x, rows = c(2, 2), cols = 4:5, valign = \"bottom\",\n                     fixed = TRUE)$body$valign,\n      valign\n    )\n  }\n)\n\ntest_that(\n  \"Correctly skips reassignment when valign = halign = NULL\",\n  {\n    expect_equal(\n      sprinkle_align(x, valign = NULL, halign = NULL),\n      x\n    )\n  }\n)\n\ntest_that(\n  \"Function succeeds when called on a dust_list object\",\n  {\n    expect_silent(\n      dplyr::group_by(mtcars, am, vs) %>% \n        dust(ungroup = FALSE) %>% \n        sprinkle_align(halign = \"left\")\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Casts an error if x is not a dust object.\",\n  {\n    expect_error(sprinkle_align(mtcars))\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Casts an error if halign is not a character\",\n  {\n    expect_error(sprinkle_align(x, halign = c(1:2)))\n  }\n)\n\n# Functional Requirement 4 ------------------------------------------\n\ntest_that(\n  \"Casts an error if part is not one of body, head, foot, or interfoot\",\n  {\n    expect_error(sprinkle_align(x, halign = \"left\", part = \"not_a_part\"))\n  }\n)\n\n# Functional Requirement 5 ------------------------------------------\n\ntest_that(\n  \"Casts an error if fixed is not a logical(1)\",\n  {\n    expect_error(sprinkle_align(x, valign = \"top\", fixed = \"yes\"))\n  }\n)\n\ntest_that(\n  \"Casts an error if fixed is not a logical(1)\",\n  {\n    expect_error(sprinkle_align(x, valign = \"bottom\", fixed = c(TRUE, FALSE)))\n  }\n)\n\n# Functional Requirement 6 ------------------------------------------\n\ntest_that(\n  \"Casts an error if recycle is not one of none, rows, or cols\",\n  {\n    expect_error(sprinkle_align(x, halign = \"right\", recycle = \"not_an_option\"))\n  }\n)\n\n# Functional Requirement 7 ------------------------------------------\n\ntest_that(\n  \"Casts an error if valign is not a character\",\n  {\n    expect_error(sprinkle_align(x, valign = c(1:2)))\n  }\n)\n\n# Functional Requirement 8 ------------------------------------------\n\ntest_that(\n  \"Cast an error if recycle = 'none' and halign does not have length 1.\",\n  {\n    expect_error(\n      sprinkle(sprinkle_align(x, halign = c(\"left\", \"right\")))\n    )\n  }\n)\n\ntest_that(\n  \"Passes if recycle != 'none' and halign does not have length 1.\",\n  {\n    expect_silent(\n      sprinkle_align(x, halign = c(\"left\", \"right\"),\n                              recycle = \"rows\")\n    )\n  }\n)\n\n# Functional Requirement 9 ------------------------------------------\n\ntest_that(\n  \"Cast an error if recycle = 'none' and halign does not have length 1.\",\n  {\n    expect_error(\n      sprinkle(sprinkle_align(x, valign = c(\"bottom\", \"top\")))\n    )\n  }\n)\n\ntest_that(\n  \"Passes if recycle != 'none' and halign does not have length 1.\",\n  {\n    expect_silent(\n      sprinkle_align(x, valign = c(\"bottom\", \"top\"),\n                     recycle = \"rows\")\n    )\n  }\n)\n\n# Functional Requirement 10 -----------------------------------------\n\ntest_that(\n  \"Cast an error if halign is not one of c('left', 'center', 'right')\",\n  {\n    expect_error(\n      sprinkle_align(x, halign = \"something\")\n    )\n  }\n)\n\n# Functional Requirement 11 -----------------------------------------\n\ntest_that(\n  \"Cast an error if valign is not one of c('bottom', 'middle', 'top')\",\n  {\n    expect_error(\n      sprinkle_align(x, valign = \"something\")\n    )\n  }\n)\n"
  },
  {
    "path": "tests/testthat/test-sprinkle_bg.R",
    "content": "context(\"sprinkle_bg\")\n\nx <- dust(head(mtcars))\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Correctly reassigns the appropriate elements bg column in the table part.\",\n  {\n    bg <- rep(\"\", nrow(x$body))\n    bg[x$body$row == 1] <- \"red\"\n    expect_equal(\n      sprinkle_bg(x, rows = 1, bg = \"red\")$body$bg,\n      bg\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements bg column in the table part.\",\n  {\n    bg <- rep(\"\", nrow(x$body))\n    bg[x$body$row == 2 & x$body$col %in% 4:5] <- \"blue\"\n    expect_equal(\n      sprinkle_bg(x, rows = 2, cols = 4:5, bg = \"blue\")$body$bg,\n      bg\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements bg column in the table part.\",\n  {\n    bg <- rep(\"\", nrow(x$body))\n    bg[x$body$row == 2 & x$body$col %in% 4:5] <- \"transparent\"\n    expect_equal(\n      sprinkle_bg(x, rows = c(2, 2), cols = 4:5, bg = \"transparent\",\n                  fixed = TRUE)$body$bg,\n      bg\n    )\n  }\n)\n\ntest_that(\n  \"Function succeeds when called on a dust_list object\",\n  {\n    expect_silent(\n      dplyr::group_by(mtcars, am, vs) %>% \n        dust(ungroup = FALSE) %>% \n        sprinkle_bg(rows = 2, bg = \"transparent\")\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Casts an error if x is not a dust object.\",\n  {\n    expect_error(sprinkle_bg(mtcars))\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Casts an error if bg is not a character(1)\",\n  {\n    expect_error(sprinkle_bg(x, bg = c(\"red\", \"blue\")))\n  }\n)\n\n# Functional Requirement 4 ------------------------------------------\n\ntest_that(\n  \"Casts an error if bg is not a valid color format.\",\n  {\n    expect_error(sprinkle_bg(x, bg = \"rgb(256, 256, 256)\"))\n  }\n)\n\ntest_that(\n  \"Casts an error if bg is not a valid color format.\",\n  {\n    expect_error(sprinkle_bg(x, bg = \"#ZZFFAA0A\"))\n  }\n)\n\n# Functional Requirement 5 ------------------------------------------\n\ntest_that(\n  \"Casts an error if part is not one of body, head, foot, or interfoot\",\n  {\n    expect_error(sprinkle_bg(x, bg = \"red\", part = \"not_a_part\"))\n  }\n)\n\n# Functional Requirement 6 ------------------------------------------\n\ntest_that(\n  \"Casts an error if fixed is not a logical(1)\",\n  {\n    expect_error(sprinkle_bg(x, bg = \"red\", fixed = \"yes\"))\n  }\n)\n\ntest_that(\n  \"Casts an error if fixed is not a logical(1)\",\n  {\n    expect_error(sprinkle_bg(x, bg = \"red\", fixed = c(TRUE, FALSE)))\n  }\n)\n\ntest_that(\n  \"Casts an error if recycle is not one of none, rows, or cols\",\n  {\n    expect_error(sprinkle_bg(x, bg = \"red\", recycle = \"not_an_option\"))\n  }\n)\n\n# Functional Requirement 7 ------------------------------------------\n\ntest_that(\n  \"Casts an error if recycle = 'none' and bg does not have length 1.\",\n  {\n    expect_error(sprinkle_bg(x, bg = c(\"red\", \"blue\"), recycle = \"none\"))\n  }\n)\n\ntest_that(\n  \"Passes when recycle != 'none' and bg does has length > 1.\",\n  {\n    expect_silent(sprinkle_bg(x, bg = c(\"red\", \"blue\"), recycle = \"rows\"))\n  }\n)"
  },
  {
    "path": "tests/testthat/test-sprinkle_bg_pattern.R",
    "content": "context(\"sprinkle_bg_pattern\")\n\nx <- dust(head(mtcars))\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of the `bg` columns \n   in the table part\",\n  {\n    expect_equal(\n      sprinkle_bg_pattern(x = x,\n                          bg_pattern = c('white', 'black'))[[\"body\"]][[\"bg\"]],\n      rep(c(\"white\", \"black\"), length.out = 66)\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of the `bg` columns \n   in the table part\",\n  {\n    expect_equal(\n      sprinkle_bg_pattern(x = x,\n                          rows = 1:2,\n                          bg_pattern = c('white', 'black'))[[\"body\"]][[\"bg\"]],\n      rep(c(\"white\", \"black\", rep(\"\", 4)), length.out = 66)\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of the `bg` columns \n  in the table part\",\n  {\n    expect_equal(\n      sprinkle_bg_pattern(x = x,\n                          bg_pattern = c('white', 'black'),\n                          bg_pattern_by = \"cols\")[[\"body\"]][[\"bg\"]],\n      rep(rep(c(\"white\", \"black\"), length.out = 11),\n          rep(6, 11))\n    )\n  }\n)\n\ntest_that(\n  \"Function succeeds when called on a dust_list object\",\n  {\n    expect_silent(\n      dplyr::group_by(mtcars, am, vs) %>% \n        dust(ungroup = FALSE) %>% \n        sprinkle_bg_pattern(bg_pattern = c(\"white\", \"black\"))\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Casts an error if x is not a dust object\",\n  {\n    expect_error(\n      sprinkle_bg_pattern(mtcars)\n    )\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Casts an error if `bg_pattern` is not a character vector\",\n  {\n    expect_error(\n      sprinkle_bg_pattern(x = x,\n                          bg_pattern = c(TRUE, FALSE))\n    )\n  }\n)\n\n# Functional Requirement 4 ------------------------------------------\n\ntest_that(\n  \"Casts an error if any element of `bg_pattern` is not a valid color\",\n  {\n    expect_error(\n      sprinkle_bg_pattern(x = x,\n                          bg_pattern = c(\"white\", \"blue\", \"not actually a color\"))\n    )\n  }\n)\n\n# Functional Requirement 5 ------------------------------------------\n\ntest_that(\n  \"Casts an error if `bg_pattern_by` is not a subset of [rows, columns]\",\n  {\n    expect_error(\n      sprinkle_bg_pattern(x = x,\n                          bg_pattern_by = \"Column\")\n    )\n  }\n)\n\n# Functional Requirement 6 ------------------------------------------\n\ntest_that(\n  \"Casts an error if `part` is not one of [body, head, foot, interfoot]\",\n  {\n    expect_error(\n      sprinkle_bg_pattern(x = x,\n                          part = \"not a part\")\n    )\n  }\n)\n"
  },
  {
    "path": "tests/testthat/test-sprinkle_bookdown.R",
    "content": "context(\"sprinkle_bookdown\")\n\nx <- dust(mtcars)\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Change the bookdown attribute of the dust object\",\n  {\n    expect_equal(\n      sprinkle_bookdown(x, TRUE)[[\"bookdown\"]],\n      TRUE\n    )\n  }\n)\n\ntest_that(\n  \"Function succeeds when called on a dust_list object\",\n  {\n    expect_silent(\n      dplyr::group_by(mtcars, am, vs) %>% \n        dust(ungroup = FALSE) %>% \n        sprinkle_bookdown(bookdown = TRUE)\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is not a dust object\",\n  {\n    expect_error(\n      sprinkle_bookdown(mtcars)\n    )\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is not a logical object\",\n  {\n    expect_error(\n      sprinkle_bookdown(x, \"FALSE\")\n    )\n  }\n)\n\n# Functional Requirement 4 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x has length greater than 1\",\n  {\n    expect_error(\n      sprinkle_bookdown(x, c(TRUE, FALSE))\n    )\n  }\n)"
  },
  {
    "path": "tests/testthat/test-sprinkle_border.R",
    "content": "context(\"sprinkle_border\")\n\nx <- dust(head(mtcars))\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Correctly reassigns the left_border, right_border, top_border, and \n   bottom_border columns in the table part\",\n  {\n    expect_equal(\n      sprinkle_border(x, border = \"all\", \n                      border_color = \"green\")$body[c(\"bottom_border\", \"left_border\", \"top_border\", \"right_border\")],\n      data.frame(bottom_border = rep(\"1pt solid green\", 66),\n                 left_border = rep(\"1pt solid green\", 66),\n                 top_border = rep(\"1pt solid green\", 66),\n                 right_border = rep(\"1pt solid green\", 66),\n                 stringsAsFactors = FALSE)\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the left_border, right_border, top_border, and \n   bottom_border columns in the table part\",\n  {\n    expect_equal(\n      sprinkle_border(x, border = \"bottom\", color = \"black\")$body$bottom_border,\n      rep(\"1pt solid black\", 66)\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the left_border, right_border, top_border, and \n   bottom_border columns in the table part\",\n  {\n    expect_equal(\n      sprinkle_border(x, border = \"left\", color = \"black\")$body$left_border,\n      rep(\"1pt solid black\", 66)\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the left_border, right_border, top_border, and \n   bottom_border columns in the table part\",\n  {\n    expect_equal(\n      sprinkle_border(x, border = \"top\", color = \"black\")$body$top_border,\n      rep(\"1pt solid black\", 66)\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the left_border, right_border, top_border, and \n   bottom_border columns in the table part\",\n  {\n    expect_equal(\n      sprinkle_border(x, border = \"right\", color = \"black\")$body$right_border,\n      rep(\"1pt solid black\", 66)\n    )\n  }\n)\n\ntest_that(\n  \"Function succeeds when called on a dust_list object\",\n  {\n    expect_silent(\n      mtcars %>% \n        dplyr::group_by(am, vs) %>% \n        dust(ungroup = FALSE) %>% \n        sprinkle_border(border = \"right\", color = \"red\")\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is not a dust object\",\n  {\n    expect_error(sprinkle_border(mtcars,\n                                 border = \"bottom\"))\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Cast an error if any element of border is not one of all, bottom, \n   left, top, or right\",\n  {\n    expect_error(\n      sprinkle_border(x, border = \"middle\")\n    )\n  }\n)\n\n# Functional Requirement 4 ------------------------------------------\n\ntest_that(\n  \"Cast an error if border_color is not a character(1)\",\n  {\n    expect_error(\n      sprinkle_border(x, border_color = 13)\n    )\n  }\n)\n\ntest_that(\n  \"Cast an error if border_color is not a character(1)\",\n  {\n    expect_error(\n      sprinkle_border(x, border_color = c(\"black\", \"red\"))\n    )\n  }\n)\n\n# Functional Requirement 5 ------------------------------------------\n\ntest_that(\n  \"Cast an error if border_color is not a valid color format\",\n  {\n    expect_error(\n      sprinkle_border(x, border_color = \"not_a_color\")\n    )\n  }\n)\n\n# Functional Requirement 6 ------------------------------------------\n\ntest_that(\n  \"Cast an error if border_style is not one of solid, dashed, dotted,\n  double groove, ridge, inset, outset, hidden, none\",\n  {\n    expect_error(\n      sprinkle_border(x, border_style = \"not_a_style\")\n    )\n  }\n)\n\ntest_that(\n  \"Accept solid, dashed, dotted, double, groove, ridge, inset, outset, hidden\n   and none\",\n  {\n    expect_silent(\n      sprinkle_border(x, border_style = \"solid\")\n    )\n  }\n)\n\ntest_that(\n  \"Accept solid, dashed, dotted, double, groove, ridge, inset, outset, hidden\n   and none\",\n  {\n    expect_silent(\n      sprinkle_border(x, border_style = \"dashed\")\n    )\n  }\n)\n\ntest_that(\n  \"Accept solid, dashed, dotted, double, groove, ridge, inset, outset, hidden\n   and none\",\n  {\n    expect_silent(\n      sprinkle_border(x, border_style = \"dotted\")\n    )\n  }\n)\n\n\ntest_that(\n  \"Accept solid, dashed, dotted, double, groove, ridge, inset, outset, hidden\n   and none\",\n  {\n    expect_silent(\n      sprinkle_border(x, border_style = \"double\")\n    )\n  }\n)\n\ntest_that(\n  \"Accept solid, dashed, dotted, double, groove, ridge, inset, outset, hidden\n   and none\",\n  {\n    expect_silent(\n      sprinkle_border(x, border_style = \"groove\")\n    )\n  }\n)\n\ntest_that(\n  \"Accept solid, dashed, dotted, double, groove, ridge, inset, outset, hidden\n   and none\",\n  {\n    expect_silent(\n      sprinkle_border(x, border_style = \"ridge\")\n    )\n  }\n)\n\ntest_that(\n  \"Accept solid, dashed, dotted, double, groove, ridge, inset, outset, hidden\n   and none\",\n  {\n    expect_silent(\n      sprinkle_border(x, border_style = \"inset\")\n    )\n  }\n)\n\ntest_that(\n  \"Accept solid, dashed, dotted, double, groove, ridge, inset, outset, hidden\n   and none\",\n  {\n    expect_silent(\n      sprinkle_border(x, border_style = \"outset\")\n    )\n  }\n)\n\ntest_that(\n  \"Accept solid, dashed, dotted, double, groove, ridge, inset, outset, hidden\n   and none\",\n  {\n    expect_silent(\n      sprinkle_border(x, border_style = \"hidden\")\n    )\n  }\n)\n\ntest_that(\n  \"Accept solid, dashed, dotted, double, groove, ridge, inset, outset, hidden\n   and none\",\n  {\n    expect_silent(\n      sprinkle_border(x, border_style = \"none\")\n    )\n  }\n)\n\n# Functional Requirement 7 ------------------------------------------\n\ntest_that(\n  \"Cast an error if border_thickness is not a numeric(1)\",\n  {\n    expect_error(\n      sprinkle_border(x, border_thickness = \"one\")\n    )\n  }\n)\n\ntest_that(\n  \"Cast an error if border_thickness is not a numeric(1)\",\n  {\n    expect_error(\n      sprinkle_border(x, border_thickness = c(1, 2))\n    )\n  }\n)\n\n# Functional Requirement 8 ------------------------------------------\n\ntest_that(\n  \"Cast an error if border_units is not one of pt or px\",\n  {\n    expect_error(\n      sprinkle_border(x, border_units = \"in\")\n    )\n  }\n)\n\ntest_that(\n  \"border_units accepts pt\",\n  {\n    expect_silent(\n      sprinkle_border(x, border_units = \"pt\")\n    )\n  }\n)\n\ntest_that(\n  \"border_units accepts px\",\n  {\n    expect_silent(\n      sprinkle_border(x, border_units = \"px\")\n    )\n  }\n)\n\n# Functional Requirement 9 - 11 ------------------------------------\n\n# Tested in index_to_sprinkle\n\n# Functional Requirement 12 -----------------------------------------\n\ntest_that(\n  \"Casts an error if recycle = 'none' and border_color does not have length 1.\",\n  {\n    expect_error(sprinkle_border(x, border_color = c(\"red\", \"blue\"), recycle = \"none\"))\n  }\n)\n\ntest_that(\n  \"Passes when recycle != 'none' and border_color does has length > 1.\",\n  {\n    expect_silent(sprinkle_border(x, border_color = c(\"red\", \"blue\"), recycle = \"rows\"))\n  }\n)\n\n# Functional Requirement 13 -----------------------------------------\n\ntest_that(\n  \"Casts an error if recycle = 'none' and border_style does not have length 1.\",\n  {\n    expect_error(sprinkle_border(x, border_style = c(\"dashed\", \"solid\"), recycle = \"none\"))\n  }\n)\n\ntest_that(\n  \"Passes when recycle != 'none' and border_color does has length > 1.\",\n  {\n    expect_silent(sprinkle_border(x, border_style = c(\"dashed\", \"solid\"), recycle = \"rows\"))\n  }\n)\n\n# Functional Requirement 14 -----------------------------------------\n\ntest_that(\n  \"Casts an error if recycle = 'none' and border_thickness does not have length 1.\",\n  {\n    expect_error(sprinkle_border(x, border_thickness = c(1, 3), recycle = \"none\"))\n  }\n)\n\ntest_that(\n  \"Passes when recycle != 'none' and border_thickness does has length > 1.\",\n  {\n    expect_silent(sprinkle_border(x, border_thickness = c(1, 3), recycle = \"rows\"))\n  }\n)\n\n# Functional Requirement 15 -----------------------------------------\n\ntest_that(\n  \"Quietly restrict border_units to just the first element if it has length > 1 and recycle = 'none'\",\n  {\n    expect_silent(sprinkle_border(x, border_units = c(\"px\", \"pt\"), recycle = \"none\"))\n  }\n)\n"
  },
  {
    "path": "tests/testthat/test-sprinkle_border_collapse.R",
    "content": "context(\"sprinkle_border_collapse\")\n\nx <- dust(mtcars)\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Change the border_collapse attribute of the dust object\",\n  {\n    expect_equal(\n      sprinkle_border_collapse(x, \"separate\")[[\"border_collapse\"]],\n      \"separate\"\n    )\n  }\n)\n\ntest_that(\n  \"Function succeeds when called on a dust_list object\",\n  {\n    expect_silent(\n      dplyr::group_by(mtcars, am, vs) %>% \n        dust(ungroup = FALSE) %>% \n        sprinkle_border_collapse(\"separate\")\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is not a dust object\",\n  {\n    expect_error(\n      sprinkle_border_collapse(mtcars)\n    )\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is not one of the acceptable values\",\n  {\n    expect_error(\n      sprinkle_border_collapse(x, border_collapse = \"some value\")\n    )\n  }\n)\n"
  },
  {
    "path": "tests/testthat/test-sprinkle_caption.R",
    "content": "context(\"sprinkle_caption\")\n\nx <- dust(mtcars)\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Change the caption attribute of the dust object\",\n  {\n    expect_equal(\n      sprinkle_caption(x, \"new caption\")[[\"caption\"]],\n      \"new caption\"\n    )\n  }\n)\n\ntest_that(\n  \"Function succeeds when called on a dust_list object\",\n  {\n    expect_silent(\n      dplyr::group_by(mtcars, am, vs) %>% \n        dust(ungroup = FALSE) %>% \n        sprinkle_caption(\"some caption\")\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is not a dust object\",\n  {\n    expect_error(\n      sprinkle_caption(mtcars)\n    )\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is not a character object\",\n  {\n    expect_error(\n      sprinkle_caption(x, 1234)\n    )\n  }\n)\n\n# Functional Requirement 4 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x has length greater than 1\",\n  {\n    expect_error(\n      sprinkle_caption(x, letters[1:2])\n    )\n  }\n)"
  },
  {
    "path": "tests/testthat/test-sprinkle_caption_number.R",
    "content": "context(\"sprinkle_caption_number\")\n\nx <- dust(mtcars)\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Change the caption_number attribute of the dust object\",\n  {\n    expect_equal(\n      sprinkle_caption_number(x, FALSE)[[\"caption_number\"]],\n      FALSE\n    )\n  }\n)\n\ntest_that(\n  \"Function succeeds when called on a dust_list object\",\n  {\n    expect_silent(\n      dplyr::group_by(mtcars, am, vs) %>% \n        dust(ungroup = FALSE) %>% \n        sprinkle_caption_number(FALSE)\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is not a dust object\",\n  {\n    expect_error(\n      sprinkle_caption_number(mtcars)\n    )\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Cast an error if caption_number is not a logical object\",\n  {\n    expect_error(\n      sprinkle_caption_number(x, 1234)\n    )\n  }\n)\n\n# Functional Requirement 4 ------------------------------------------\n\ntest_that(\n  \"Cast an error if caption_number has length greater than 1\",\n  {\n    expect_error(\n      sprinkle_caption_number(x, c(TRUE, FALSE))\n    )\n  }\n)"
  },
  {
    "path": "tests/testthat/test-sprinkle_colnames.R",
    "content": "context(\"sprinkle_colnames\")\n\ntest_that(\"sprinkle_colnames produces output\",\n{\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_silent(sprinkle_colnames(x, \"Term\", \"Estimate\", \"SE\", \"T-stat\", \"Pval\"))\n})\n\ntest_that(\"sprinkle_colnames errors\",\n{\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle_colnames(x, estimate = \"Estimate\", \"SE\"),\n               \"\")\n})\n\ntest_that(\"sprinkle_colnames: unnamed arguments have length 1\",\n{\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle_colnames(x, \"Term\", \"Estimate\", \"SE\", \"Statistic\", c(\"P.value\", \"P\")),\n               \"Arguments to '...' should have length 1\")\n})\n\ntest_that(\"sprinkle_colnames: named argument have lenght 1\",\n{\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle_colnames(x, estimate = c(\"Estimate\", \"est\")),\n               \"Arguments to '...' should have length 1\")\n})\n\ntest_that(\"sprinkle_colnames: named arguments\",\n{\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_silent(sprinkle_colnames(x, estimate = \"Estimate\", std.error = \"Std. Error\"))\n})\n\ntest_that(\"sprinkle_colnames: cast error when named argument doesn't match to table\",\n{\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle_colnames(x, estimate_bad = \"Estimate\", std.error = \"Std. Error\"))\n})"
  },
  {
    "path": "tests/testthat/test-sprinkle_discrete.R",
    "content": "context(\"sprinkle_discrete\")\n\nx <- dust(mtcars)\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Correctly reassigns `bg`\",\n  {\n    expect_equal(\n      sprinkle_discrete(\n        x, \n        cols = \"gear\", \n        discrete = \"bg\", \n        discrete_color = c(\"red\", \"blue\", \"green\"))[[\"body\"]][[\"bg\"]][289:320],\n      c(\"red\", \"blue\", \"green\")[match(mtcars$gear, c(3, 4, 5))]\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns `font_color`\",\n  {\n    expect_equal(\n      sprinkle_discrete(\n        x, \n        cols = \"gear\", \n        discrete = \"font\", \n        discrete_color = c(\"red\", \"blue\", \"green\"))[[\"body\"]][[\"font_color\"]][289:320],\n      c(\"red\", \"blue\", \"green\")[match(mtcars$gear, c(3, 4, 5))]\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns `font_color`\",\n  {\n    expect_equal(\n      sprinkle_discrete(\n        x, \n        cols = \"gear\", \n        discrete = \"font_color\", \n        discrete_color = c(\"red\", \"blue\", \"green\"))[[\"body\"]][[\"font_color\"]][289:320],\n      c(\"red\", \"blue\", \"green\")[match(mtcars$gear, c(3, 4, 5))]\n    )\n  }\n)\n\ntest_that(\n  \"Selects default colors when discrete_color is NULL\",\n  {\n    expect_silent(\n      sprinkle_discrete(x, cols = \"gear\", discrete = \"bg\")\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns `border`\",\n  {\n    expect_equal(\n      sprinkle_discrete(\n        x, \n        cols = \"gear\", \n        discrete = \"border\", \n        discrete_color = c(\"red\", \"blue\", \"green\"))[[\"body\"]][[\"left_border\"]][289:320],\n      sprintf(\"1px solid %s\", c(\"red\", \"blue\", \"green\")[match(mtcars$gear, c(3, 4, 5))])\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns `border`\",\n  {\n    expect_equal(\n      sprinkle_discrete(\n        x, \n        cols = \"gear\", \n        discrete = \"right_border\", \n        discrete_color = c(\"red\", \"blue\", \"green\"))[[\"body\"]][[\"right_border\"]][289:320],\n      sprintf(\"1px solid %s\", c(\"red\", \"blue\", \"green\")[match(mtcars$gear, c(3, 4, 5))])\n    )\n  }\n)\n\ntest_that(\n  \"Function succeeds when called on a dust_list object\",\n  {\n    expect_silent(\n      dplyr::group_by(mtcars, am, vs) %>% \n        dust(ungroup = FALSE) %>% \n        sprinkle_discrete(cols = \"gear\",\n                          discrete = \"bg\",\n                          discrete_color = c(\"red\", \"blue\", \"green\"))\n    )\n  }\n)\n\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is not a dust object\",\n  {\n    expect_error(sprinkle_discrete(x = mtcars,\n                                   cols = \"gear\",\n                                   discrete = \"bg\"))\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Cast an error if discrete is not a subset of bg, border, font, ...\",\n  {\n    expect_error(sprinkle_discrete(x = x,\n                                   cols = \"gear\",\n                                   discrete = \"font_height\"))\n  }\n)\n\n# Functional Requirement 4 ------------------------------------------\n\ntest_that(\n  \"Cast an error if discrete_color is not character\",\n  {\n    expect_error(sprinkle_discrete(x = x,\n                                   cols = \"gear\",\n                                   discrete_colors = 1:3))\n  }\n)\n\n# Functional Requirement 5 ------------------------------------------\ntest_that(\n  \"Cast an error if discrete_color is not a recognized color\",\n  {\n    expect_error(sprinkle_discrete(x = x,\n                                   cols = \"gear\",\n                                   discrete_colors = c(\"my own red\",\n                                                       \"my own blue\",\n                                                       \"my own green\")))\n  }\n)\n\ntest_that(\n  \"Cast an error if discrete_color has too few values\",\n  {\n    expect_error(sprinkle_discrete(x = x,\n                                   cols = \"gear\",\n                                   discrete_colors = c('red', 'blue')))\n  }\n)\n\n# Functional Requirement 6 ------------------------------------------\n\ntest_that(\n  \"Cast an error if part is not one of body, head, foot, interfoot\",\n  {\n    expect_error(\n      sprinkle_discrete(x = x,\n                        cols = \"gear\",\n                        part = \"not a part\")\n    )\n  }\n)\n\n# Functional Requirement 7 ------------------------------------------\n\ntest_that(\n  \"Cast an error if fixed is not logical(1)\",\n  expect_error(\n    sprinkle_discrete(x = x,\n                      cols = \"gear\",\n                      fixed = \"FALSE\")\n  )\n)\n\ntest_that(\n  \"Cast an error if fixed is not logical(1)\",\n  expect_error(\n    sprinkle_discrete(x = x,\n                      cols = \"gear\",\n                      fixed = c(TRUE, FALSE))\n  )\n)\n\n# Functional Requirement 8 ------------------------------------------\n\ntest_that(\n  \"Cast an error if recycle is not one of none, rows, cols\",\n  {\n    expect_error(\n      sprinkle_discrete(x = x,\n                        cols = \"gear\",\n                        recycle = \"not a value\")\n    )\n  }\n)\n"
  },
  {
    "path": "tests/testthat/test-sprinkle_dust_list.R",
    "content": "context(\"sprinkling dust_list\")\n\ndlist <- dust(mtcars %>%\n                dplyr::group_by(am, vs),\n              ungroup = FALSE)\n\ntest_that(\"sprinkle_table on a dust_list\",\n{\n  expect_silent(\n    sprinkle_table(dlist, longtable = TRUE)\n  )\n})\n\ntest_that(\"sprinkle_print_method on a dust_list\",\n{\n  expect_silent(\n    sprinkle_print_method(dlist, \"html\")\n  )\n})\n\ntest_that(\"sprinkle_colnames on a dust_list\",\n{\n  expect_silent(\n    sprinkle_colnames(dlist, mpg = \"MPG\", cyl = \"CYL\")\n  )\n})\n\ntest_that(\"sprinkle a dust_list\",\n{\n  expect_silent(\n    sprinkle(dlist, \n             rows = 3, \n             cols = 2,\n             italic = TRUE)\n  )\n})\n\ntest_that(\"convert dust_list to list of data.frames\",\n{\n  expect_silent(\n    as.data.frame(dlist)\n  )\n})"
  },
  {
    "path": "tests/testthat/test-sprinkle_fixed_header.R",
    "content": "context(\"sprinkle_fixed_header.R\")\n\nx <- dust(head(mtcars))\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Set the fixed_header element of the dust object correctly\",\n  expect_equal(\n    sprinkle_fixed_header(x, fixed_header = FALSE)$fixed_header,\n    FALSE\n  )\n)\n\ntest_that(\n  \"Set the fixed_header element of the dust object correctly\",\n  expect_equal(\n    sprinkle_fixed_header(x, fixed_header = TRUE)$fixed_header,\n    TRUE\n  )\n)\n\ntest_that(\n  \"Works with dust_list object\",\n  {\n    test_df <- rbind(mtcars, mtcars, mtcars)\n    test_df <- dplyr::group_by(test_df, am)\n    expect_silent(\n      dust(test_df, ungroup = FALSE) %>% \n        sprinkle_fixed_header(scroll_body_height = 100) %>% \n        sprinkle_print_method(\"html\")\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Set the include_fixed_header_css element of the dust object correctly\",\n  expect_equal(\n    sprinkle_fixed_header(x, include_fixed_header_css = FALSE)$include_fixed_header_css,\n    FALSE\n  )\n)\n\ntest_that(\n  \"Set the include_fixed_header_css element of the dust object correctly\",\n  expect_equal(\n    sprinkle_fixed_header(x, include_fixed_header_css = TRUE)$include_fixed_header_css,\n    TRUE\n  )\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Set the fixed_header_param element of the dust object correctly\",\n  expect_equal(\n    sprinkle_fixed_header(x, \n                          fixed_header_class_name = \"new-pixie\",\n                          scroll_body_height = 400,\n                          scroll_body_height_units = \"pt\",\n                          scroll_body_background_color = \"orchid\",\n                          fixed_header_height = 30,\n                          fixed_header_height_units = \"pt\",\n                          fixed_header_text_height = 30,\n                          fixed_header_text_height_units = \"pt\",\n                          fixed_header_background_color = \"pink\")$fixed_header_param,\n    list(fixed_header_class_name = \"new-pixie\",\n         scroll_body_height = 400,\n         scroll_body_height_units = \"pt\",\n         scroll_body_background_color = \"orchid\",\n         fixed_header_height = 30,\n         fixed_header_height_units = \"pt\",\n         fixed_header_text_height = 30,\n         fixed_header_text_height_units = \"pt\",\n         fixed_header_background_color = \"pink\")\n  )\n)\n\n# Functional Requirement 4 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x does not inherit class dust\",\n  {\n    expect_error(sprinkle_fixed_header(mtcars),\n                 \"class 'dust'\")\n  }\n)\n\n# Functional Requirement 5 ------------------------------------------\n\ntest_that(\n  \"Cast an error if scroll_body_height is not integerish(1)\",\n  {\n    expect_error(sprinkle_fixed_header(x,\n                                       scroll_body_height = c(100, 200)),\n                 \"Must have length 1\")\n  }\n)\n\ntest_that(\n  \"Cast an error if scroll_body_height is not integerish(1)\",\n  {\n    expect_error(sprinkle_fixed_header(x,\n                                       scroll_body_height = \"100\"),\n                 \"'integerish'\")\n  }\n)\n\n# Functional Requirement 6 ------------------------------------------\n\ntest_that(\n  \"Cast an error if scroll_body_height_units is not character(1)\",\n  {\n    expect_error(sprinkle_fixed_header(x,\n                                       scroll_body_height_units = 100),\n                 \"'character'\")\n  }\n)\n\ntest_that(\n  \"Cast an error if scroll_body_height is not character(1)\",\n  {\n    expect_error(sprinkle_fixed_header(x,\n                                       scroll_body_height_units = c(\"pt\", \"px\")),\n                 \"Must have length 1\")\n  }\n)\n\n# Functional Requirement 7 ------------------------------------------\n\ntest_that(\n  \"Cast an error if scroll_body_background_color is not character(1)\",\n  {\n    expect_error(sprinkle_fixed_header(x,\n                                       scroll_body_background_color = 100),\n                 \"'character'\")\n  }\n)\n\ntest_that(\n  \"Cast an error if scroll_body_background_color is not character(1)\",\n  {\n    expect_error(sprinkle_fixed_header(x,\n                                       scroll_body_background_color = c(\"orchid\", \"purple\")),\n                 \"Must have length 1\")\n  }\n)\n\n# Functional Requirement 8 ------------------------------------------\n\ntest_that(\n  \"Cast an error if scroll_body_background_color is not a valid color\",\n  {\n    expect_error(sprinkle_fixed_header(x,\n                                       scroll_body_background_color = c(\"not a color\")),\n                 \"is not a valid color\")\n  }\n)\n\n# Functional Requirement 9 ------------------------------------------\n\ntest_that(\n  \"Cast an error if fixed_header_height is not integerish(1)\",\n  {\n    expect_error(sprinkle_fixed_header(x,\n                                       fixed_header_height = c(100, 200)),\n                 \"Must have length 1\")\n  }\n)\n\ntest_that(\n  \"Cast an error if fixed_header_height is not integerish(1)\",\n  {\n    expect_error(sprinkle_fixed_header(x,\n                                       fixed_header_height = \"100\"))\n  }\n)\n\n# Functional Requirement 10 -----------------------------------------\n\ntest_that(\n  \"Cast an error if fixed_header_height_units is not character(1)\",\n  {\n    expect_error(sprinkle_fixed_header(x,\n                                       fixed_header_height_units = 100),\n                 \"'character'\")\n  }\n)\n\ntest_that(\n  \"Cast an error if fixed_header_height is not character(1)\",\n  {\n    expect_error(sprinkle_fixed_header(x,\n                                       fixed_header_height_units = c(\"pt\", \"px\")),\n                 \"Must have length 1\")\n  }\n)\n\n# Functional Requirement 11 -----------------------------------------\n\ntest_that(\n  \"Cast an error if fixed_header_text_height is not integerish(1)\",\n  {\n    expect_error(sprinkle_fixed_header(x,\n                                       fixed_header_text_height = c(100, 200)),\n                 \"Must have length 1\")\n  }\n)\n\ntest_that(\n  \"Cast an error if fixed_header_text_height is not integerish(1)\",\n  {\n    expect_error(sprinkle_fixed_header(x,\n                                       fixed_header_text_height = \"100\"))\n  }\n)\n\n# Functional Requirement 12 -----------------------------------------\n\ntest_that(\n  \"Cast an error if fixed_header_text_height_units is not character(1)\",\n  {\n    expect_error(sprinkle_fixed_header(x,\n                                       fixed_header_text_height_units = 100),\n                 \"Must be of type\")\n  }\n)\n\ntest_that(\n  \"Cast an error if fixed_header_text_height is not character(1)\",\n  {\n    expect_error(sprinkle_fixed_header(x,\n                                       fixed_header_text_height_units = c(\"pt\", \"px\")),\n                 \"Must have length 1\")\n  }\n)\n\n# Functional Requirement 13 -----------------------------------------\n\ntest_that(\n  \"Cast an error if fixed_header_background_color is not character(1)\",\n  {\n    expect_error(sprinkle_fixed_header(x,\n                                       fixed_header_background_color = 100),\n                 \"'character'\")\n  }\n)\n\ntest_that(\n  \"Cast an error if fixed_header_background_color is not character(1)\",\n  {\n    expect_error(sprinkle_fixed_header(x,\n                                       fixed_header_background_color = c(\"orchid\", \"purple\")),\n                 \"Must have length 1\")\n  }\n)\n\n# Functional Requirement 14 -----------------------------------------\n\ntest_that(\n  \"Cast an error if fixed_header_background_color is not a valid color\",\n  {\n    expect_error(sprinkle_fixed_header(x,\n                                       fixed_header_background_color = c(\"not a color\")),\n                 \"is not a valid color\")\n  }\n)\n\n# Functional Requirement 15 -----------------------------------------\n\ntest_that(\n  \"Cast an error if include_fixed_header_css is not logical(1)\",\n  {\n    expect_error(sprinkle_fixed_header(x,\n                                       include_fixed_header_css = c(TRUE, FALSE)),\n                 \"Must have length 1\")\n  }\n)\n\ntest_that(\n  \"Cast an error if include_fixed_header_css is not logical(1)\",\n  {\n    expect_error(sprinkle_fixed_header(x,\n                                       include_fixed_header_css = \"TRUE\"),\n                 \"'logical'\")\n  }\n)\n\n# Functional Requirement 16 -----------------------------------------\n\ntest_that(\n  \"Cast an error if fixed_header_class_name is not character(1)\",\n  {\n    expect_error(sprinkle_fixed_header(x,\n                                       fixed_header_class_name = 100),\n                 \"'character'\")\n  }\n)\n\ntest_that(\n  \"Cast an error if fixed_header_class_name is not character(1)\",\n  {\n    expect_error(sprinkle_fixed_header(x,\n                                       fixed_header_class_name = c(\"orchid\", \"purple\")),\n                 \"Must have length 1\")\n  }\n)\n\n# Functional Requirement 16 -----------------------------------------\n\ntest_that(\n  \"Cast an error if fixed_header is not logical(1)\",\n  {\n    expect_error(sprinkle_fixed_header(x,\n                                       fixed_header = c(TRUE, FALSE)),\n                 \"Must have length 1\")\n  }\n)\n\ntest_that(\n  \"Cast an error if fixed_header is not logical(1)\",\n  {\n    expect_error(sprinkle_fixed_header(x,\n                                       fixed_header = \"TRUE\"),\n                 \"'logical'\")\n  }\n)\n"
  },
  {
    "path": "tests/testthat/test-sprinkle_float.R",
    "content": "context(\"sprinkle_float\")\n\nx <- dust(mtcars)\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Change the float attribute of the dust object\",\n  {\n    expect_equal(\n      sprinkle_float(x, TRUE)[[\"float\"]],\n      TRUE\n    )\n  }\n)\n\ntest_that(\n  \"Function succeeds when called on a dust_list object\",\n  {\n    expect_silent(\n      dplyr::group_by(mtcars, am, vs) %>% \n        dust(ungroup = FALSE) %>% \n        sprinkle_float(float = TRUE)\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is not a dust object\",\n  {\n    expect_error(\n      sprinkle_float(mtcars)\n    )\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is a logical object with length not equal to 1\",\n  {\n    expect_error(\n      sprinkle_float(x, c(FALSE, TRUE))\n    )\n  }\n)\n\ntest_that(\n  \"Cast an error if x is not a logical object\",\n  {\n    expect_error(\n      sprinkle_float(x, \"TRUE\")\n    )\n  }\n)\n"
  },
  {
    "path": "tests/testthat/test-sprinkle_fn.R",
    "content": "context(\"sprinkle_fn\")\r\n\r\nx <- dust(head(mtcars))\r\n\r\n# Functional Requirement 1 ------------------------------------------\r\n\r\ntest_that(\r\n  \"Correctly reassigns the appropriate elements of the fn column in the table part.\",\r\n  {\r\n    expect_equal(\r\n      sprinkle_fn(x, rows = 1, fn = quote(identity(value)))$body$fn,\r\n      rep(c(\"identity(value)\", rep(NA, 5)), 11)\r\n    )\r\n  }\r\n)\r\n\r\ntest_that(\r\n  \"Correctly reassigns the appropriate elements bg column in the table part.\",\r\n  {\r\n    fn <- rep(NA, nrow(x$body))\r\n    fn[x$body$row == 2 & x$body$col %in% 4:5] <- \"identity(value)\"\r\n    expect_equal(\r\n      sprinkle_fn(x, rows = 2, cols = 4:5, fn = quote(identity(value)))$body$fn,\r\n      fn\r\n    )\r\n  }\r\n)\r\n\r\ntest_that(\r\n  \"Correctly reassigns the appropriate elements of replace column in the table part.\",\r\n  {\r\n    fn <- rep(NA, nrow(x$body))\r\n    fn[x$body$row == 2 & x$body$col %in% 4:5] <- \"pvalString(value)\"\r\n    expect_equal(\r\n      sprinkle_fn(x, rows = c(2, 2), cols = 4:5, fn = quote(pvalString(value)),\r\n                  fixed = TRUE)$body$fn,\r\n      fn\r\n    )\r\n  }\r\n)\r\n\r\ntest_that(\r\n  \"Function succeeds when called on a dust_list object\",\r\n  {\r\n    expect_silent(\r\n      dplyr::group_by(mtcars, am, vs) %>% \r\n        dust(ungroup = FALSE) %>% \r\n        sprinkle_fn(cols = \"mpg\", fn = quote(median(value)))\r\n    )\r\n  }\r\n)\r\n\r\n# Functional Requirement 2 ------------------------------------------\r\n\r\ntest_that(\r\n  \"Casts an error if x is not a dust object.\",\r\n  {\r\n    expect_error(sprinkle_fn(mtcars))\r\n  }\r\n)\r\n\r\n# Functional Requirement 3 ------------------------------------------\r\n\r\ntest_that(\r\n  \"Casts an error if bg is not a call object\",\r\n  {\r\n    expect_error(sprinkle_fn(x, fn = mtcars))\r\n  }\r\n)\r\n\r\n# Functional Requirement 4 ------------------------------------------\r\n\r\ntest_that(\r\n  \"Casts an error if part is not one of body, head, foot, or interfoot\",\r\n  {\r\n    expect_error(sprinkle_fn(x, fn = NULL, part = \"not_a_part\"))\r\n  }\r\n)\r\n\r\n# Functional Requirement 5 ------------------------------------------\r\n\r\ntest_that(\r\n  \"Casts an error if fixed is not a logical(1)\",\r\n  {\r\n    expect_error(sprinkle_fn(x, fn = quote(identity(value)), fixed = \"yes\"))\r\n  }\r\n)\r\n\r\ntest_that(\r\n  \"Casts an error if fixed is not a logical(1)\",\r\n  {\r\n    expect_error(sprinkle_fn(x, fn = quote(identity(value)), \r\n                             fixed = c(TRUE, FALSE)))\r\n  }\r\n)\r\n\r\n# Functional Requirement 6 ------------------------------------------\r\n\r\ntest_that(\r\n  \"Casts an error if recycle is not one of none, rows, or cols\",\r\n  {\r\n    expect_error(sprinkle_fn(x, fn = quote(identity(value)), recycle = \"not_an_option\"))\r\n  }\r\n)"
  },
  {
    "path": "tests/testthat/test-sprinkle_font.R",
    "content": "context(\"sprinkle_font\")\n\nx <- dust(head(mtcars))\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Correctly change the bold column of the table part for the selected cells\",\n  {\n    expect_equal(\n      sprinkle_font(x = x,\n                    bold = TRUE)[[\"body\"]][[\"bold\"]],\n      rep(TRUE, 66)\n    )\n  }\n)\n\ntest_that(\n  \"Succeeds when called on a dust_list object\",\n  {\n    expect_silent(\n      mtcars %>% \n        dplyr::group_by(vs, am) %>% \n        dust(ungroup = FALSE) %>% \n        sprinkle_font(cols = \"mpg\", \n                      bold = TRUE)\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Correctly change the italic column of the table part for the selected cells\",\n  {\n    expect_equal(\n      sprinkle_font(x = x,\n                    italic = TRUE)[[\"body\"]][[\"italic\"]],\n      rep(TRUE, 66)\n    )\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Correctly change the font_size column of the table part for the selected cells\",\n  {\n    expect_equal(\n      sprinkle_font(x = x,\n                    font_size = 10)[[\"body\"]][[\"font_size\"]],\n      rep(\"10\", 66)\n    )\n  }\n)\n\n# Functional Requirement 4 ------------------------------------------\n\ntest_that(\n  \"Correctly change the font_size_units column of the table part for the selected cells\",\n  {\n    expect_equal(\n      sprinkle_font(x = x,\n                    font_size_units = \"em\")[[\"body\"]][[\"font_size_units\"]],\n      rep(\"em\", 66)\n    )\n  }\n)\n\n# Functional Requirement 5 ------------------------------------------\n\ntest_that(\n  \"Correctly change the font_color column of the table part for the selected cells\",\n  {\n    expect_equal(\n      sprinkle_font(x = x,\n                    font_color = \"blue\")[[\"body\"]][[\"font_color\"]],\n      rep(\"blue\", 66)\n    )\n  }\n)\n\n# Functional Requirement 6 ------------------------------------------\n\ntest_that(\n  \"Correctly change the font_family column of the table part for the selected cells\",\n  {\n    expect_equal(\n      sprinkle_font(x = x,\n                    font_family = \"Courier New\")[[\"body\"]][[\"font_family\"]],\n      rep(\"Courier New\", 66)\n    )\n  }\n)\n\n# Functional Requirement 7 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is not a dust object\",\n  {\n    expect_error(\n      sprinkle_font(x = mtcars)\n    )\n  }\n)\n\n# Functional Requirement 8 ------------------------------------------\n\ntest_that(\n  \"Cast an error if bold is not logical(1)\",\n  {\n    expect_error(\n      sprinkle_font(x = x,\n                    bold = \"TRUE\")\n    )\n  }\n)\n\ntest_that(\n  \"Cast an error if bold is not logical(1)\",\n  {\n    expect_error(\n      sprinkle_font(x = x,\n                    bold = c(TRUE, FALSE))\n    )\n  }\n)\n\n# Functional Requirement 9 ------------------------------------------\n\ntest_that(\n  \"Cast an error if italic is not logical(1)\",\n  {\n    expect_error(\n      sprinkle_font(x = x,\n                    italic = \"TRUE\")\n    )\n  }\n)\n\ntest_that(\n  \"Cast an error if italic is not logical(1)\",\n  {\n    expect_error(\n      sprinkle_font(x = x,\n                    italic = c(TRUE, FALSE))\n    )\n  }\n)\n\n# Functional Requirement 10 -----------------------------------------\n\ntest_that(\n  \"Cast an error if font_size is not numeric(1)\",\n  {\n    expect_error(\n      sprinkle_font(x = x,\n                    font_size = \"3\")\n    )\n  }\n)\n\ntest_that(\n  \"Cast an error if font_size_units is not numeric(1)\",\n  {\n    expect_error(\n      sprinkle_font(x = x,\n                    font_size = c(3, 4))\n    )\n  }\n)\n\n# Functional Requirement 11 -----------------------------------------\n\ntest_that(\n  \"Cast an error if font_size_units is not character(1)\",\n  {\n    expect_error(\n      sprinkle_font(x = x,\n                    font_size_units = TRUE)\n    )\n  }\n)\n\ntest_that(\n  \"Cast an error if font_size_units is not character(1)\",\n  {\n    expect_error(\n      sprinkle_font(x = x,\n                    font_size_units = c(\"px\", \"pt\"))\n    )\n  }\n)\n\n# Functional Requirement 12 -----------------------------------------\n\ntest_that(\n  \"Cast an error if font_size_units is not one of px, pt, em, %\",\n  {\n    expect_error(\n      sprinkle_font(x = x,\n                    font_size_units = \"in\")\n    )\n  }\n)\n\n# Functional Requirement 13 -----------------------------------------\n\ntest_that(\n  \"Cast an error if font_color is not character(1)\",\n  {\n    expect_error(\n      sprinkle_font(x = x,\n                    font_color = TRUE)\n    )\n  }\n)\n\ntest_that(\n  \"Cast an error if font_color is not character(1)\",\n  {\n    expect_error(\n      sprinkle_font(x = x,\n                    font_color = c(\"red\", \"blue\"))\n    )\n  }\n)\n\n# Functional Requirement 14 -----------------------------------------\n\ntest_that(\n  \"Cast an error if any value in font_color is not a valid color\",\n  {\n    expect_error(\n      sprinkle_font(x = x,\n                    font_color = \"not a color\")\n    )\n  }\n)\n\n# Functional Requirement 15 -----------------------------------------\n\ntest_that(\n  \"Cast an error if font_family is not character(1)\",\n  {\n    expect_error(\n      sprinkle_font(x = x,\n                    font_family = TRUE)\n    )\n  }\n)\n\ntest_that(\n  \"Cast an error if font_family is not character(1)\",\n  {\n    expect_error(\n      sprinkle_font(x = x,\n                    font_family = c(\"red\", \"blue\"))\n    )\n  }\n)\n\n# Functional Requirement 16 -----------------------------------------\n\ntest_that(\n  \"Cast an error if part is not one of body, head, foot, interfoot\",\n  {\n    expect_error(\n      sprinkle_font(x = x,\n                    part = \"not a part\")\n    )\n  }\n)\n\n# Functional Requirement 17 -----------------------------------------\n\ntest_that(\n  \"Casts an error if recycle = 'none' and bold does not have length 1.\",\n  {\n    expect_error(sprinkle_font(x, bold = c(TRUE, FALSE), recycle = \"none\"))\n  }\n)\n\ntest_that(\n  \"Passes when recycle != 'none' and bold does has length > 1.\",\n  {\n    expect_silent(sprinkle_font(x, bold = c(TRUE, FALSE), recycle = \"rows\"))\n  }\n)\n\n# Functional Requirement 18 -----------------------------------------\n\ntest_that(\n  \"Casts an error if recycle = 'none' and italic does not have length 1.\",\n  {\n    expect_error(sprinkle_font(x, italic = c(TRUE, FALSE), recycle = \"none\"))\n  }\n)\n\ntest_that(\n  \"Passes when recycle != 'none' and italic does has length > 1.\",\n  {\n    expect_silent(sprinkle_font(x, italic = c(TRUE, FALSE), recycle = \"rows\"))\n  }\n)\n\n# Functional Requirement 19 -----------------------------------------\n\ntest_that(\n  \"Casts an error if recycle = 'none' and font_size does not have length 1.\",\n  {\n    expect_error(sprinkle_font(x, font_size = c(10, 12), recycle = \"none\"))\n  }\n)\n\ntest_that(\n  \"Passes when recycle != 'none' and font_size does has length > 1.\",\n  {\n    expect_silent(sprinkle_font(x, font_size = c(10, 12), recycle = \"rows\"))\n  }\n)\n\n# Functional Requirement 20 -----------------------------------------\n\ntest_that(\n  \"Casts an error if recycle = 'none' and font_size_units does not have length 1.\",\n  {\n    expect_error(sprinkle_font(x, font_size_units = c(\"px\", \"pt\"), recycle = \"none\"))\n  }\n)\n\ntest_that(\n  \"Passes when recycle != 'none' and font_size_units does has length > 1.\",\n  {\n    expect_silent(sprinkle_font(x, font_size_units = c(\"px\", \"pt\"), recycle = \"rows\"))\n  }\n)\n\n# Functional Requirement 21 -----------------------------------------\n\ntest_that(\n  \"Casts an error if recycle = 'none' and font_color does not have length 1.\",\n  {\n    expect_error(sprinkle_font(x, font_color = c(\"red\", \"blue\"), recycle = \"none\"))\n  }\n)\n\ntest_that(\n  \"Passes when recycle != 'none' and font_color does has length > 1.\",\n  {\n    expect_silent(sprinkle_font(x, font_color = c(\"red\", \"blue\"), recycle = \"rows\"))\n  }\n)\n\n# Functional Requirement 22 -----------------------------------------\n\ntest_that(\n  \"Casts an error if recycle = 'none' and font_family does not have length 1.\",\n  {\n    expect_error(sprinkle_font(x, font_family = c(\"Roman\", \"Arial\"), recycle = \"none\"))\n  }\n)\n\ntest_that(\n  \"Passes when recycle != 'none' and font_family does has length > 1.\",\n  {\n    expect_silent(sprinkle_font(x, font_family = c(\"Roman\", \"Arial\"), recycle = \"rows\"))\n  }\n)\n"
  },
  {
    "path": "tests/testthat/test-sprinkle_gradient.R",
    "content": "context(\"sprinkle_gradient\")\n\nx <- dust(mtcars)\n\ncolor_range <- \n  scales::gradient_n_pal(c(\"#132B43\", \"#56B1F7\"))(seq(0, 1, \n                                                      length.out = 10))\ncolor_index <- \n  as.numeric(cut(mtcars$mpg,\n                 breaks = quantile(mtcars$mpg, \n                                   probs = seq(0, 1, length.out = 10),\n                                   na.rm = TRUE),\n                 include.lowest = TRUE))\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of the bg column\",\n  {\n    expect_equal(\n      sprinkle_gradient(\n        x, \n        cols = \"mpg\", \n        gradient = \"bg\")[[\"body\"]][[\"bg\"]][1:32],\n      \n      color_range[color_index]\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of the border columns\",\n  {\n    expect_equal(\n      sprinkle_gradient(\n        x,\n        cols = \"mpg\",\n        gradient = \"border\")[[\"body\"]][[\"bottom_border\"]][1:32],\n      sprintf(\"1px solid %s\", color_range[color_index])\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of the border columns\",\n  {\n    expect_equal(\n      sprinkle_gradient(\n        x,\n        cols = \"mpg\",\n        gradient = \"border\")[[\"body\"]][[\"left_border\"]][1:32],\n      sprintf(\"1px solid %s\", color_range[color_index])\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of the border columns\",\n  {\n    expect_equal(\n      sprinkle_gradient(\n        x,\n        cols = \"mpg\",\n        gradient = \"border\")[[\"body\"]][[\"top_border\"]][1:32],\n      sprintf(\"1px solid %s\", color_range[color_index])\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of the border columns\",\n  {\n    expect_equal(\n      sprinkle_gradient(\n        x,\n        cols = \"mpg\",\n        gradient = \"border\")[[\"body\"]][[\"right_border\"]][1:32],\n      sprintf(\"1px solid %s\", color_range[color_index])\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of the border columns\",\n  {\n    expect_equal(\n      sprinkle_gradient(\n        x,\n        cols = \"mpg\",\n        gradient = \"bottom_border\")[[\"body\"]][[\"bottom_border\"]][1:32],\n      sprintf(\"1px solid %s\", color_range[color_index])\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of the border columns\",\n  {\n    expect_equal(\n      sprinkle_gradient(\n        x,\n        cols = \"mpg\",\n        gradient = \"left_border\")[[\"body\"]][[\"left_border\"]][1:32],\n      sprintf(\"1px solid %s\", color_range[color_index])\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of the border columns\",\n  {\n    expect_equal(\n      sprinkle_gradient(\n        x,\n        cols = \"mpg\",\n        gradient = \"top_border\")[[\"body\"]][[\"top_border\"]][1:32],\n      sprintf(\"1px solid %s\", color_range[color_index])\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of the border columns\",\n  {\n    expect_equal(\n      sprinkle_gradient(\n        x,\n        cols = \"mpg\",\n        gradient = \"right_border\")[[\"body\"]][[\"right_border\"]][1:32],\n      sprintf(\"1px solid %s\", color_range[color_index])\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of the border columns\",\n  {\n    expect_equal(\n      sprinkle_gradient(\n        x,\n        cols = \"mpg\",\n        gradient = \"font\")[[\"body\"]][[\"font_color\"]][1:32],\n      color_range[color_index]\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of the border columns\",\n  {\n    expect_equal(\n      sprinkle_gradient(\n        x,\n        cols = \"mpg\",\n        gradient = \"font_color\")[[\"body\"]][[\"font_color\"]][1:32],\n      color_range[color_index]\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of the border columns\",\n  {\n    expect_equal(\n      sprinkle_gradient(\n        x,\n        cols = \"mpg\",\n        gradient = \"font\",\n        gradient_colors = NULL)[[\"body\"]][[\"font_color\"]][1:32],\n      color_range[color_index]\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the default color for gradient_na = NULL\",\n  {\n    expect_equal(\n      {X <- mtcars\n       X$mpg[1] <- NA\n       sprinkle_gradient(dust(X), cols = \"mpg\", gradient = \"bg\", \n                       gradient_na = NULL)[[\"body\"]][[\"bg\"]][1]},\n      \"grey\"\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the color for custom cut vector\",\n  {\n    expect_equal(\n      sprinkle_gradient(x, cols = \"mpg\", \n                        gradient_cut = quantile(mtcars$mpg, \n                                                probs = seq(0, 1, length.out = 10),\n                                                na.rm = TRUE))[[\"body\"]][[\"bg\"]][1:32],\n      color_range[color_index]\n    )\n  }\n)\n\ntest_that(\n  \"sprinkle_gradient succeeds on dust_list\",\n  {\n    expect_silent(\n      mtcars %>% \n        dplyr::group_by(am) %>% \n        dust(ungroup = FALSE) %>% \n        sprinkle_gradient(gradient = \"bg\", gradient_n = 5)\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Casts an error if x is not a dust object\",\n  {\n    expect_error(\n      sprinkle_gradient(mtcars)\n    )\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Cast an error if gradient is not a subset of ...\",\n  {\n    expect_error(\n      sprinkle_gradient(x, gradient = \"not an option\"),\n      \"Must be a subset of\"\n    )\n  }\n)\n\n# Functional Requirement 4 ------------------------------------------\n\ntest_that(\n  \"Cast an error if gradient_colors is not a character(2)\",\n  {\n    expect_error(\n      sprinkle_gradient(x, gradient_colors = 1:2),\n      \"Must be of type 'character'\"\n    )\n  }\n)\n\ntest_that(\n  \"Cast an error if gradient_colors is not a character(2)\",\n  {\n    expect_error(\n      sprinkle_gradient(x, gradient_colors = \"black\"),\n      \"Must have length 2\"\n    )\n  }\n)\n\n# Functional Requirement 5 ------------------------------------------\n\ntest_that(\n  \"Cast an error if gradient_colors is not a recognized color value\",\n  {\n    expect_error(\n      sprinkle_gradient(x, gradient_colors = c(\"rgb(-3,520,17)\",\n                                               \"some other color\")),\n      \"are not valid colors\"\n    )\n  }\n)\n\n# Functional Requirement 6 ------------------------------------------\n\ntest_that(\n  \"Cast an error if gradient_cut is not numeric\",\n  {\n    expect_error(\n      sprinkle_gradient(x, cols = \"mpg\", gradient_cut = \"10\"),\n      \"Must be of type 'numeric'\"\n    )\n  }\n)\n\n# Functional Requirement 7 ------------------------------------------\n\ntest_that(\n  \"Cast an error if gradient_n is not numeric(1)\",\n  {\n    expect_error(\n      sprinkle_gradient(x, gradient_n = c(5, 10)),\n      \"Must have length 1\"\n    )\n  }\n)\n\ntest_that(\n  \"Cast an error if gradient_n is not numeric(1)\",\n  {\n    expect_error(\n      sprinkle_gradient(x, gradient_n = \"10\"),\n      \"Must be of type 'numeric'\"\n    )\n  }\n)\n\n# Functional Requirement 8 ------------------------------------------\n\ntest_that(\n  \"Cast an error if gradient_na is not character(1)\",\n  {\n    expect_error(\n      sprinkle_gradient(x, gradient_na = 7),\n      \"Must be of type 'character'\"\n    )\n  }\n)\n\ntest_that(\n  \"Cast an error if gradient_na is not character(1)\",\n  {\n    expect_error(\n      sprinkle_gradient(x, gradient_na = c(\"red\", \"blue\")),\n      \"Must have length 1\"\n    )\n  }\n)\n\n# Functional Requirement 9 ------------------------------------------\n\ntest_that(\n  \"Cast an error if gradient_na is not a valid color\",\n  {\n    expect_error(\n      sprinkle_gradient(x, gradient_na = \"some other color\")\n    )\n  }\n)\n\n# Functional Requirement 10 -----------------------------------------\n\ntest_that(\n  \"Cast an error if part is not one of body, head, foot, interfoot\",\n  {\n    expect_error(\n      sprinkle_gradient(x = x,\n                        cols = \"gear\",\n                        part = \"not a part\")\n    )\n  }\n)\n\n# Functional Requirement 11 ------------------------------------------\n\ntest_that(\n  \"Cast an error if fixed is not logical(1)\",\n  expect_error(\n    sprinkle_gradient(x = x,\n                      cols = \"gear\",\n                      fixed = \"FALSE\")\n  )\n)\n\ntest_that(\n  \"Cast an error if fixed is not logical(1)\",\n  expect_error(\n    sprinkle_gradient(x = x,\n                      cols = \"gear\",\n                      fixed = c(TRUE, FALSE))\n  )\n)\n\n# Functional Requirement 12 ------------------------------------------\n\ntest_that(\n  \"Cast an error if recycle is not one of none, rows, cols\",\n  {\n    expect_error(\n      sprinkle_gradient(x = x,\n                        cols = \"gear\",\n                        recycle = \"not a value\")\n    )\n  }\n)\n"
  },
  {
    "path": "tests/testthat/test-sprinkle_height.R",
    "content": "context(\"sprinkle_height\")\n\nx <- dust(head(mtcars))\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of height and\n   height_units columns in the table part\",\n  {\n    expect_equal(\n      sprinkle_height(x, cols = 2, height = 20)[[\"body\"]][[\"height\"]],\n      rep(c(\"\", \"20\", \"\"), times = c(6, 6, 6*9))\n    )\n  }  \n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of height and\n   height_units columns in the table part\",\n  {\n    expect_equal(\n      sprinkle_height(x, cols = 2, height_units = \"%\")[[\"body\"]][[\"height_units\"]],\n      rep(c(\"\", \"%\", \"\"), times = c(6, 6, 6*9))\n    )\n  }  \n)\n\ntest_that(\n  \"Function succeeds when called on a dust_list object\",\n  {\n    expect_silent(\n      dplyr::group_by(mtcars, am, vs) %>% \n        dust(ungroup = FALSE) %>% \n        sprinkle_height(height = 10)\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is not a dust object\",\n  {\n    expect_error(sprinkle_height(mtcars))\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Cast an error if height is not a numeric(1)\",\n  {\n    expect_error(sprinkle_height(x, height = \"20\"))\n  }\n)\n\ntest_that(\n  \"Cast an error if height is not a numeric(1)\",\n  {\n    expect_error(sprinkle_height(x, height = c(20, 40)))\n  }\n)\n\n# Functional Requirement 4 ------------------------------------------\n\ntest_that(\n  \"Cast an error if height_units is not a character(1)\",\n  {\n    expect_error(sprinkle_height(x, height_units = 20))\n  }\n)\n\ntest_that(\n  \"Cast an error if height_units is not a character(1)\",\n  {\n    expect_error(sprinkle_height(x, height = c(\"px\", \"pt\")))\n  }\n)\n\n# Functional Requirement 5 ------------------------------------------\n\ntest_that(\n  \"Casts an error if part is not one of body, head, foot, or interfoot\",\n  {\n    expect_error(\n      sprinkle_height(x, height = 20, part = \"not a part\")\n    )\n  }\n)\n\n# Functional Requirement 6 ------------------------------------------\n\ntest_that(\n  \"Casts an error if fixed is not logical(1)\",\n  {\n    expect_error(sprinkle_height(x, height = 20, fixed = \"FALSE\"))\n  }\n)\n\ntest_that(\n  \"Casts an error if fixed is not logical(1)\",\n  {\n    expect_error(sprinkle_height(x, height = 20, fixed = c(TRUE, FALSE)))\n  }\n)\n\n# Functional Requirement 7 ------------------------------------------\n\ntest_that(\n  \"Casts an error if recycle is not one of none, rows, or cols\",\n  {\n    expect_error(sprinkle_height(x, recycle = \"not an option\"))\n  }\n)\n\n# Functional Requirement 8 ------------------------------------------\n\ntest_that(\n  \"Casts an error if recycle = 'none' and height does not have length 1.\",\n  {\n    expect_error(sprinkle_height(x, height = c(10, 15), recycle = \"none\"))\n  }\n)\n\ntest_that(\n  \"Passes when recycle != 'none' and height has length > 1.\",\n  {\n    expect_silent(sprinkle_height(x, height = c(10, 15), recycle = \"rows\"))\n  }\n)\n\n# Functional Requirement 9 ------------------------------------------\n\ntest_that(\n  \"When recycle = 'none', quietly coerce height_units to just the first element given.\",\n  {\n    expect_silent(sprinkle_height(x, height_units = c(\"px\", \"pt\")))\n  }\n)"
  },
  {
    "path": "tests/testthat/test-sprinkle_hhline.R",
    "content": "context(\"sprinkle_hhline\")\n\nx <- dust(mtcars)\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Change the hhline attribute of the dust object\",\n  {\n    expect_equal(\n      sprinkle_hhline(x, TRUE)[[\"hhline\"]],\n      TRUE\n    )\n  }\n)\n\ntest_that(\n  \"Succeeds when called on a dust_list object\",\n  {\n    expect_silent(\n      dplyr::group_by(mtcars, am, vs) %>% \n        dust(ungroup = FALSE) %>% \n        sprinkle_hhline(hhline = FALSE)\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is not a dust object\",\n  {\n    expect_error(\n      sprinkle_hhline(mtcars)\n    )\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is a logical object with length not equal to 1\",\n  {\n    expect_error(\n      sprinkle_hhline(x, c(TRUE, FALSE))\n    )\n  }\n)\n\ntest_that(\n  \"Cast an error if x is not a logical object\",\n  {\n    expect_error(\n      sprinkle_hhline(x, \"TRUE\")\n    )\n  }\n)\n"
  },
  {
    "path": "tests/testthat/test-sprinkle_html_preserve.R",
    "content": "context(\"sprinkle_html_preserve\")\n\nx <- dust(mtcars)\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Change the html_preserve attribute of the dust object\",\n  {\n    expect_equal(\n      sprinkle_html_preserve(x, TRUE)[[\"html_preserve\"]],\n      TRUE\n    )\n  }\n)\n\ntest_that(\n  \"Change the html_preserve attribute of the dust object\",\n  {\n    expect_equal(\n      sprinkle_html_preserve(x, FALSE)[[\"html_preserve\"]],\n      FALSE\n    )\n  }\n)\n\ntest_that(\n  \"Function succeeds when called on a dust_list object\",\n  {\n    expect_silent(\n      dplyr::group_by(mtcars, am, vs) %>% \n        dust(ungroup = FALSE) %>% \n        sprinkle_html_preserve(html_preserve = TRUE)\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is not a dust object\",\n  {\n    expect_error(\n      sprinkle_html_preserve(mtcars)\n    )\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is not a logical object\",\n  {\n    expect_error(\n      sprinkle_html_preserve(x, \"FALSE\")\n    )\n  }\n)\n\ntest_that(\n  \"Cast an error if html_preserve is not logical(1)\",\n  {\n    expect_error(\n      sprinkle_html_preserve(x, c(TRUE, FALSE))\n    )\n  }\n)\n"
  },
  {
    "path": "tests/testthat/test-sprinkle_justify.R",
    "content": "context(\"sprinkle_justify\")\n\nx <- dust(mtcars)\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Change the justify attribute of the dust object: left\",\n  {\n    expect_equal(\n      sprinkle_justify(x, \"left\")[[\"justify\"]],\n      \"left\"\n    )\n  }\n)\n\ntest_that(\n  \"Change the justify attribute of the dust object: center\",\n  {\n    expect_equal(\n      sprinkle_justify(x, \"center\")[[\"justify\"]],\n      \"center\"\n    )\n  }\n)\n\ntest_that(\n  \"Change the justify attribute of the dust object: right\",\n  {\n    expect_equal(\n      sprinkle_justify(x, \"right\")[[\"justify\"]],\n      \"right\"\n    )\n  }\n)\n\ntest_that(\n  \"Function succeeds when called on a dust_list object\",\n  {\n    expect_silent(\n      dplyr::group_by(mtcars, am, vs) %>% \n        dust(ungroup = FALSE) %>% \n        sprinkle_justify(justify = \"left\")\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is not a dust object\",\n  {\n    expect_error(\n      sprinkle_justify(mtcars)\n    )\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Cast an error if justify is not one of center, left, or right\",\n  {\n    expect_error(\n      sprinkle_justify(x, \"lft misspelled\")\n    )\n  }\n)\n\n# Functional Requirement 4 ------------------------------------------\n\ntest_that(\n  \"Ignore capitalization of the justify argument\",\n  {\n    expect_silent(\n      sprinkle_justify(x, \"Left\")\n    )\n  }\n)\n\ntest_that(\n  \"Ignore capitalization of the justify argument\",\n  {\n    expect_silent(\n      sprinkle_justify(x, \"LeFt\")\n    )\n  }\n)\n\ntest_that(\n  \"Ignore capitalization of the justify argument\",\n  {\n    expect_silent(\n      sprinkle_justify(x, \"R\")\n    )\n  }\n)\n"
  },
  {
    "path": "tests/testthat/test-sprinkle_label.R",
    "content": "context(\"sprinkle_label\")\n\nx <- dust(mtcars)\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Change the label attribute of the dust object\",\n  {\n    expect_equal(\n      sprinkle_label(x, \"separate\")[[\"label\"]],\n      \"separate\"\n    )\n  }\n)\n\ntest_that(\n  \"Function succeeds when called on a dust_list object\",\n  {\n    expect_warning(\n      dplyr::group_by(mtcars, am, vs) %>% \n        dust(ungroup = FALSE) %>% \n        sprinkle_label(label = \"label\")\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is not a dust object\",\n  {\n    expect_error(\n      sprinkle_label(mtcars)\n    )\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is not a character(1)\",\n  {\n    expect_error(\n      sprinkle_label(x, label = character(0))\n    )\n  }\n)\n\ntest_that(\n  \"Cast an error if x is not a character(1)\",\n  {\n    expect_error(\n      sprinkle_label(x, label = letters[1:2])\n    )\n  }\n)\n\ntest_that(\n  \"Cast an error if x is not a character(1)\",\n  {\n    expect_error(\n      sprinkle_label(x, label = 1)\n    )\n  }\n)"
  },
  {
    "path": "tests/testthat/test-sprinkle_longtable.R",
    "content": "context(\"sprinkle_longtable\")\n\nx <- dust(mtcars)\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Change the longtable attribute of the dust object\",\n  {\n    expect_equal(\n      sprinkle_longtable(x, TRUE)[[\"longtable\"]],\n      TRUE\n    )\n  }\n)\n\n\ntest_that(\n  \"Change the longtable attribute of the dust object\",\n  {\n    expect_equal(\n      sprinkle_longtable(x, 15)[[\"longtable\"]],\n      15\n    )\n  }\n)\n\ntest_that(\n  \"Function succeeds when called on a dust_list object\",\n  {\n    expect_silent(\n      dplyr::group_by(mtcars, am, vs) %>% \n        dust(ungroup = FALSE) %>% \n        sprinkle_longtable(longtable = TRUE)\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is not a dust object\",\n  {\n    expect_error(\n      sprinkle_longtable(mtcars)\n    )\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is a logical object with length not equal to 1\",\n  {\n    expect_error(\n      sprinkle_longtable(x, c(FALSE, TRUE))\n    )\n  }\n)\n\ntest_that(\n  \"Cast an error if x is a logical object with length not equal to 1\",\n  {\n    expect_error(\n      sprinkle_longtable(x, logical(0))\n    )\n  }\n)\n\n# Functional Requirement 4 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is not integerish or has length not equal to 1\",\n  {\n    expect_error(\n      sprinkle_longtable(x, c(10, 15))\n    )\n  }\n)\n\ntest_that(\n  \"Cast an error if x is not integerish or has length not equal to 1\",\n  {\n    expect_error(\n      sprinkle_longtable(x, numeric(0))\n    )\n  }\n)"
  },
  {
    "path": "tests/testthat/test-sprinkle_merge.R",
    "content": "context(\"sprinkle_merge\")\n\nx <- dust(head(mtcars))\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of merge, merge_rowval and \n   merge_colval columns in the table part.\",\n  {\n    merge <- vector(\"logical\", nrow(x$body))\n    merge[c(1, 2, 7, 8)] <- TRUE\n    expect_equal(\n      sprinkle_merge(x, rows = 1:2, cols = 1:2, merge = TRUE)$body$merge,\n      merge\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of merge, merge_rowval and \n   merge_colval columns in the table part.\",\n  {\n    expect_equal(\n      sprinkle_merge(x, rows = 1:2, cols = 1:2, merge = TRUE,\n                     merge_rowval = 2)$body$merge_rowval[c(1, 2, 7, 8)],\n      c(1, 2, 1, 2)\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of merge, merge_rowval and \n   merge_colval columns in the table part.\",\n  {\n    expect_equal(\n      sprinkle_merge(x, rows = 1:2, cols = 1:2, merge = TRUE,\n                     merge_rowval = 2,\n                     merge_colval = 2)$body$merge_colval[c(1, 2, 7, 8)],\n      c(1, 1, 2, 2)\n    )\n  }\n)\n\ntest_that(\n  \"Works with a dust_list object\",\n  {\n    expect_silent(\n      dplyr::group_by(mtcars, am, vs) %>% \n        dust(ungroup = FALSE) %>% \n        sprinkle_merge(rows = 1, cols = 1:2, merge = TRUE)\n    )\n  }\n)\n\n\ntest_that(\n  \"Correctly skips merging when merge = FALSE\",\n  {\n    expect_equal(\n      sprinkle_merge(x, rows = 1:2, cols = 1:2, merge = FALSE),\n      x\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Casts an error if x is not a dust object.\",\n  {\n    expect_error(sprinkle_merge(mtcars))\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Casts an error if merge is not a logical(1)\",\n  {\n    expect_error(sprinkle_merge(x, merge = c(TRUE, FALSE)))\n  }\n)\n\ntest_that(\n  \"Casts an error if merge is not a logical(1)\",\n  {\n    expect_error(sprinkle_merge(x, merge = c(\"TRUE\")))\n  }\n)\n\n# Functional Requirement 4 ------------------------------------------\n\ntest_that(\n  \"Casts an error if merge_rowval is not a numeric(1)\",\n  {\n    expect_error(suppressMessages(sprinkle_merge(x, merge_rowval = 1:2)))\n  }\n)\n\ntest_that(\n  \"Casts an error if merge is not a logical(1)\",\n  {\n    expect_error(suppressMessages(sprinkle_merge(x, merge_rowval = \"one\")))\n  }\n)\n\n# Functional Requirement 5 ------------------------------------------\n\ntest_that(\n  \"Casts an error if merge_colval is not a numeric(1)\",\n  {\n    expect_error(suppressMessages(sprinkle_merge(x, merge_colval = 1:2)))\n  }\n)\n\ntest_that(\n  \"Casts an error if merge is not a logical(1)\",\n  {\n    expect_error(suppressMessages(sprinkle_merge(x, merge_colval = \"one\")))\n  }\n)\n\n\n# Functional Requirement 6 ------------------------------------------\n\ntest_that(\n  \"Casts an error if part is not one of body, head, foot, or interfoot\",\n  {\n    expect_error(sprinkle_align(x, halign = \"left\", part = \"not_a_part\"))\n  }\n)\n\n# Functional Requirement 7 ------------------------------------------\n\ntest_that(\n  \"Casts an error if fixed is not a logical(1)\",\n  {\n    expect_error(sprinkle_align(x, valign = \"top\", fixed = \"yes\"))\n  }\n)\n\ntest_that(\n  \"Casts an error if fixed is not a logical(1)\",\n  {\n    expect_error(sprinkle_align(x, valign = \"bottom\", fixed = c(TRUE, FALSE)))\n  }\n)\n\ntest_that(\n  \"Casts an error if recycle is not one of none, rows, or cols\",\n  {\n    expect_error(sprinkle_align(x, halign = \"right\", recycle = \"not_an_option\"))\n  }\n)"
  },
  {
    "path": "tests/testthat/test-sprinkle_na_string.R",
    "content": "context(\"sprinkle_na_string\")\n\nx <- dust(head(mtcars))\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of the na_string column in the table part.\",\n  {\n    na_string <- rep(NA, nrow(x$body))\n    na_string[x$body$row == 1] <- \"red\"\n    expect_equal(\n      sprinkle_na_string(x, rows = 1, na_string = \"red\")$body$na_string,\n      na_string\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements bg column in the table part.\",\n  {\n    na_string <- rep(NA, nrow(x$body))\n    na_string[x$body$row == 2 & x$body$col %in% 4:5] <- \"blue\"\n    expect_equal(\n      sprinkle_na_string(x, rows = 2, cols = 4:5, na_string = \"blue\")$body$na_string,\n      na_string\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements bg column in the table part.\",\n  {\n    na_string <- rep(NA, nrow(x$body))\n    na_string[x$body$row == 2 & x$body$col %in% 4:5] <- \"transparent\"\n    expect_equal(\n      sprinkle_na_string(x, rows = c(2, 2), cols = 4:5, na_string = \"transparent\",\n                  fixed = TRUE)$body$na_string,\n      na_string\n    )\n  }\n)\n\ntest_that(\n  \"Succeeds when called on a dust_list object\",\n  {\n    expect_silent(\n      dplyr::group_by(mtcars, am, vs) %>% \n        dust(ungroup = FALSE) %>% \n        sprinkle_na_string(na_string = \"transparent\")\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Casts an error if x is not a dust object.\",\n  {\n    expect_error(sprinkle_na_string(mtcars))\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Casts an error if bg is not a character(1)\",\n  {\n    expect_error(sprinkle_na_string(x, na_string = c(\"red\", \"blue\")))\n  }\n)\n\n# Functional Requirement 4 ------------------------------------------\n\ntest_that(\n  \"Casts an error if part is not one of body, head, foot, or interfoot\",\n  {\n    expect_error(sprinkle_na_string(x, na_string = \"red\", part = \"not_a_part\"))\n  }\n)\n\n# Functional Requirement 5 ------------------------------------------\n\ntest_that(\n  \"Casts an error if fixed is not a logical(1)\",\n  {\n    expect_error(sprinkle_na_string(x, na_string = \"red\", fixed = \"yes\"))\n  }\n)\n\ntest_that(\n  \"Casts an error if fixed is not a logical(1)\",\n  {\n    expect_error(sprinkle_na_string(x, na_string = \"red\", fixed = c(TRUE, FALSE)))\n  }\n)\n\ntest_that(\n  \"Casts an error if recycle is not one of none, rows, or cols\",\n  {\n    expect_error(sprinkle_na_string(x, na_string = \"red\", recycle = \"not_an_option\"))\n  }\n)\n\n# Functional Requirement 6 -----------------------------------------\n\ntest_that(\n  \"Casts an error if recycle = 'none' and na_string does not have length 1.\",\n  {\n    expect_error(sprinkle_na_string(x, na_string = c(\"Roman\", \"Arial\"), recycle = \"none\"))\n  }\n)\n\ntest_that(\n  \"Passes when recycle != 'none' and na_string does has length > 1.\",\n  {\n    expect_silent(sprinkle_na_string(x, na_string = c(\"Roman\", \"Arial\"), recycle = \"rows\"))\n  }\n)"
  },
  {
    "path": "tests/testthat/test-sprinkle_pad.R",
    "content": "context(\"sprinkle_pad\")\n\nx <- dust(head(mtcars))\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Correctly reassigns the appropriate elements pad column in the table part.\",\n  {\n    pad <- rep(\"\", nrow(x$body))\n    pad[x$body$row == 1] <- \"3\"\n    expect_equal(\n      sprinkle_pad(x, rows = 1, pad = 3)$body$pad,\n      pad\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements pad column in the table part.\",\n  {\n    pad <- rep(\"\", nrow(x$body))\n    pad[x$body$row == 2 & x$body$col %in% 4:5] <- 2\n    expect_equal(\n      sprinkle_pad(x, rows = 2, cols = 4:5, pad = 2)$body$pad,\n      pad\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements pad column in the table part.\",\n  {\n    pad <- rep(\"\", nrow(x$body))\n    pad[x$body$row == 2 & x$body$col %in% 4:5] <- 10\n    expect_equal(\n      sprinkle_pad(x, rows = c(2, 2), cols = 4:5, pad = 10,\n                  fixed = TRUE)$body$pad,\n      pad\n    )\n  }\n)\n\ntest_that(\n  \"Function succeeds when called on a dust_list object\",\n  {\n    expect_silent(\n      dplyr::group_by(mtcars, am, vs) %>% \n        dust(ungroup = FALSE) %>% \n        sprinkle_pad(pad = 5)\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Casts an error if x is not a dust object.\",\n  {\n    expect_error(sprinkle_pad(mtcars, pad = 3))\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Casts an error if pad is not a numeric(1)\",\n  {\n    expect_error(sprinkle_pad(x, pad = 1:2))\n  }\n)\n\n# Functional Requirement 4 ------------------------------------------\n\ntest_that(\n  \"Casts an error if part is not one of body, head, foot, or interfoot\",\n  {\n    expect_error(sprinkle_pad(x, pad = 2, part = \"not_a_part\"))\n  }\n)\n\n# Functional Requirement 5 ------------------------------------------\n\ntest_that(\n  \"Casts an error if fixed is not a logical(1)\",\n  {\n    expect_error(sprinkle_pad(x, pad = 3, fixed = \"yes\"))\n  }\n)\n\ntest_that(\n  \"Casts an error if fixed is not a logical(1)\",\n  {\n    expect_error(sprinkle_pad(x, pad = 3, fixed = c(TRUE, FALSE)))\n  }\n)\n\n# Functional Requirement 6 ------------------------------------------\n\ntest_that(\n  \"Casts an error if recycle is not one of none, rows, or cols\",\n  {\n    expect_error(sprinkle_pad(x, pad = 2, recycle = \"not_an_option\"))\n  }\n)\n\n# Functional Requirement 7 -----------------------------------------\n\ntest_that(\n  \"Casts an error if recycle = 'none' and pad does not have length 1.\",\n  {\n    expect_error(sprinkle_pad(x, pad = 1:3, recycle = \"none\"))\n  }\n)\n\ntest_that(\n  \"Passes when recycle != 'none' and pad does has length > 1.\",\n  {\n    expect_silent(sprinkle_pad(x, pad = 1:3, recycle = \"rows\"))\n  }\n)"
  },
  {
    "path": "tests/testthat/test-sprinkle_replace.R",
    "content": "context(\"sprinkle_replace\")\n\nx <- dust(head(mtcars))\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of the replace column in the table part.\",\n  {\n    replace <- rep(NA, nrow(x$body))\n    replace[x$body$row == 1] <- \"red\"\n    expect_equal(\n      sprinkle_replace(x, rows = 1, replace = \"red\")$body$replace,\n      replace\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements bg column in the table part.\",\n  {\n    replace <- rep(NA, nrow(x$body))\n    replace[x$body$row == 2 & x$body$col %in% 4:5] <- \"blue\"\n    expect_equal(\n      sprinkle_replace(x, rows = 2, cols = 4:5, replace = \"blue\")$body$replace,\n      replace\n    )\n  }\n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of replace column in the table part.\",\n  {\n    replace <- rep(NA, nrow(x$body))\n    replace[x$body$row == 2 & x$body$col %in% 4:5] <- \"transparent\"\n    expect_equal(\n      sprinkle_replace(x, rows = c(2, 2), cols = 4:5, replace = \"transparent\",\n                  fixed = TRUE)$body$replace,\n      replace\n    )\n  }\n)\n\ntest_that(\n  \"Function succeeds when called on a dust_list object\",\n  {\n    expect_silent(\n      dplyr::group_by(mtcars, am, vs) %>% \n        dust(ungroup = FALSE) %>% \n        sprinkle_replace(rows = 1, cols = 1, replace = \"abc\")\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Casts an error if x is not a dust object.\",\n  {\n    expect_error(sprinkle_replace(mtcars))\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Casts an error if bg is not an atomic vector\",\n  {\n    expect_error(sprinkle_replace(x, replace = mtcars))\n  }\n)\n\n# Functional Requirement 4 ------------------------------------------\n\ntest_that(\n  \"Casts an error if part is not one of body, head, foot, or interfoot\",\n  {\n    expect_error(sprinkle_replace(x, replace = \"red\", part = \"not_a_part\"))\n  }\n)\n\n# Functional Requirement 5 ------------------------------------------\n\ntest_that(\n  \"Casts an warning if the number of indices to replace is not a \n   multiple of `replace`` \",\n  {\n    expect_warning(\n      sprinkle_replace(x, rows = 1, cols = 1:4,\n                       replace = 1:3)\n    )\n  }\n)\n\n# Functional Requirement 6 ------------------------------------------\n\ntest_that(\n  \"Casts an error if `length(replace)` is greater than the \n    number of cells to replace.\",\n  {\n    expect_error(\n      sprinkle_replace(x = x,\n                       rows = 1,\n                       replace = rep(\"blue\", 12))\n    )\n  }\n)\n# Functional Requirement 7 ------------------------------------------\n\ntest_that(\n  \"Casts an error if fixed is not a logical(1)\",\n  {\n    expect_error(sprinkle_replace(x, replace = \"red\", fixed = \"yes\"))\n  }\n)\n\ntest_that(\n  \"Casts an error if fixed is not a logical(1)\",\n  {\n    expect_error(sprinkle_replace(x, replace = \"red\", fixed = c(TRUE, FALSE)))\n  }\n)\n\ntest_that(\n  \"Casts an error if recycle is not one of none, rows, or cols\",\n  {\n    expect_error(sprinkle_replace(x, replace = \"red\", recycle = \"not_an_option\"))\n  }\n)"
  },
  {
    "path": "tests/testthat/test-sprinkle_rotate_degree.R",
    "content": "context(\"sprinkle_rotate_degree\")\n\nx <- dust(head(mtcars))\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of rotate_degree\n   columns in the table part\",\n  {\n    expect_equal(\n      sprinkle_rotate_degree(x, cols = 2, rotate_degree = 3)[[\"body\"]][[\"rotate_degree\"]],\n      rep(c(\"\", 3, \"\"), times = c(6, 6, 6*9))\n    )\n  }  \n)\n\ntest_that(\n  \"Succeeds when called on a dust_list object\",\n  {\n    expect_silent(\n      dplyr::group_by(mtcars, am, vs) %>% \n        dust(ungroup = FALSE) %>% \n        sprinkle_rotate_degree(rotate_degree = 90)\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is not a dust object\",\n  {\n    expect_error(sprinkle_rotate_degree(mtcars))\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Cast an error if rotate_degree is not a numeric(1)\",\n  {\n    expect_error(sprinkle_rotate_degree(x, rotate_degree = \"3\"))\n  }\n)\n\ntest_that(\n  \"Cast an error if rotate_degree is not a numeric(1)\",\n  {\n    expect_error(sprinkle_rotate_degree(x, rotate_degree = c(2, 3)))\n  }\n)\n\n# Functional Requirement 4 ------------------------------------------\n\ntest_that(\n  \"Casts an error if part is not one of body, head, foot, or interfoot\",\n  {\n    expect_error(\n      sprinkle_rotate_degree(x, rotate_degree = 20, part = \"not a part\")\n    )\n  }\n)\n\n# Functional Requirement 6 ------------------------------------------\n\ntest_that(\n  \"Casts an error if fixed is not logical(1)\",\n  {\n    expect_error(sprinkle_rotate_degree(x, rotate_degree = 20, fixed = \"FALSE\"))\n  }\n)\n\ntest_that(\n  \"Casts an error if fixed is not logical(1)\",\n  {\n    expect_error(sprinkle_rotate_degree(x, rotate_degree = 20, fixed = c(TRUE, FALSE)))\n  }\n)\n\n# Functional Requirement 7 ------------------------------------------\n\ntest_that(\n  \"Casts an error if recycle is not one of none, rows, or cols\",\n  {\n    expect_error(sprinkle_rotate_degree(x, recycle = \"not an option\"))\n  }\n)\n\n# Functional Requirement 8 -----------------------------------------\n\ntest_that(\n  \"Casts an error if recycle = 'none' and rotate_degree does not have length 1.\",\n  {\n    expect_error(sprinkle_rotate_degree(x, rotate_degree = 1:3, recycle = \"none\"))\n  }\n)\n\ntest_that(\n  \"Passes when recycle != 'none' and rotate_degree does has length > 1.\",\n  {\n    expect_silent(sprinkle_rotate_degree(x, rotate_degree = 1:3, recycle = \"rows\"))\n  }\n)"
  },
  {
    "path": "tests/testthat/test-sprinkle_round.R",
    "content": "context(\"sprinkle_round\")\n\nx <- dust(head(mtcars))\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of round\n   columns in the table part\",\n  {\n    expect_equal(\n      sprinkle_round(x, cols = 2, round = 3)[[\"body\"]][[\"round\"]],\n      rep(c(\"\", 3, \"\"), times = c(6, 6, 6*9))\n    )\n  }  \n)\n\ntest_that(\n  \"Succeeds when called on a dust_list object\",\n  {\n    expect_silent(\n      dplyr::group_by(mtcars, am, vs) %>% \n        dust(ungroup = FALSE) %>% \n        sprinkle_round(round = 2)\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is not a dust object\",\n  {\n    expect_error(sprinkle_round(mtcars))\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Cast an error if round is not a numeric(1)\",\n  {\n    expect_error(sprinkle_round(x, round = \"3\"))\n  }\n)\n\ntest_that(\n  \"Cast an error if round is not a numeric(1)\",\n  {\n    expect_error(sprinkle_round(x, round = c(2, 3)))\n  }\n)\n\n# Functional Requirement 4 ------------------------------------------\n\ntest_that(\n  \"Casts an error if part is not one of body, head, foot, or interfoot\",\n  {\n    expect_error(\n      sprinkle_round(x, round = 20, part = \"not a part\")\n    )\n  }\n)\n\n# Functional Requirement 6 ------------------------------------------\n\ntest_that(\n  \"Casts an error if fixed is not logical(1)\",\n  {\n    expect_error(sprinkle_round(x, round = 20, fixed = \"FALSE\"))\n  }\n)\n\ntest_that(\n  \"Casts an error if fixed is not logical(1)\",\n  {\n    expect_error(sprinkle_round(x, round = 20, fixed = c(TRUE, FALSE)))\n  }\n)\n\n# Functional Requirement 7 ------------------------------------------\n\ntest_that(\n  \"Casts an error if recycle is not one of none, rows, or cols\",\n  {\n    expect_error(sprinkle_round(x, recycle = \"not an option\"))\n  }\n)\n\n# Functional Requirement 8 -----------------------------------------\n\ntest_that(\n  \"Casts an error if recycle = 'none' and round does not have length 1.\",\n  {\n    expect_error(sprinkle_round(x, round = 1:2, recycle = \"none\"))\n  }\n)\n\ntest_that(\n  \"Passes when recycle != 'none' and round does has length > 1.\",\n  {\n    expect_silent(sprinkle_round(x, round = 1:3, recycle = \"rows\"))\n  }\n)"
  },
  {
    "path": "tests/testthat/test-sprinkle_sanitize.R",
    "content": "context(\"sprinkle_sanitize\")\n\nx <- dust(head(mtcars))\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of sanitize and\n  sanitize_args columns in the table part\",\n  {\n    expect_equal(\n      sprinkle_sanitize(x, cols = 2, sanitize = TRUE)[[\"body\"]][[\"sanitize\"]],\n      rep(c(FALSE, TRUE, FALSE), times = c(6, 6, 6*9))\n    )\n  }  \n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of sanitize and\n  sanitize_units columns in the table part\",\n  {\n    expect_equal(\n      sprinkle_sanitize(x, cols = 2, sanitize_args = list(greek = TRUE))[[\"body\"]][[\"sanitize_args\"]],\n      rep(c(\"\", \n            deparse(list(greek = TRUE)), \n            \"\"), \n          times = c(6, 6, 6*9))\n    )\n  }  \n)\n\ntest_that(\n  \"Function succeeds when called on a dust_list object\",\n  {\n    expect_silent(\n      dplyr::group_by(mtcars, am, vs) %>% \n        dust(ungroup = FALSE) %>% \n        sprinkle_sanitize(sanitize = TRUE)\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is not a dust object\",\n  {\n    expect_error(sprinkle_sanitize(mtcars))\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Cast an error if sanitize is not a logical(1)\",\n  {\n    expect_error(sprinkle_sanitize(x, sanitize = \"TRUE\"))\n  }\n)\n\ntest_that(\n  \"Cast an error if sanitize is not a logical(1)\",\n  {\n    expect_error(sprinkle_sanitize(x, sanitize = c(TRUE, FALSE)))\n  }\n)\n\n# Functional Requirement 4 ------------------------------------------\n\ntest_that(\n  \"Cast an error if sanitize_args is not a list\",\n  {\n    expect_error(sprinkle_sanitize(x, sanitize_args = 20))\n  }\n)\n\n# Functional Requirement 5 ------------------------------------------\n\ntest_that(\n  \"Casts an error if part is not one of body, head, foot, or interfoot\",\n  {\n    expect_error(\n      sprinkle_sanitize(x, sanitize = 20, part = \"not a part\")\n    )\n  }\n)\n\n# Functional Requirement 6 ------------------------------------------\n\ntest_that(\n  \"Casts an error if fixed is not logical(1)\",\n  {\n    expect_error(sprinkle_sanitize(x, sanitize = 20, fixed = \"FALSE\"))\n  }\n)\n\ntest_that(\n  \"Casts an error if fixed is not logical(1)\",\n  {\n    expect_error(sprinkle_sanitize(x, sanitize = 20, fixed = c(TRUE, FALSE)))\n  }\n)\n\n# Functional Requirement 7 ------------------------------------------\n\ntest_that(\n  \"Casts an error if recycle is not one of none, rows, or cols\",\n  {\n    expect_error(sprinkle_sanitize(x, recycle = \"not an option\"))\n  }\n)"
  },
  {
    "path": "tests/testthat/test-sprinkle_tabcolsep.R",
    "content": "context(\"sprinkle_tabcolsep\")\n\nx <- dust(mtcars)\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Change the tabcolsep attribute of the dust object\",\n  {\n    expect_equal(\n      sprinkle_tabcolsep(x, 4)[[\"tabcolsep\"]],\n      4\n    )\n  }\n)\n\ntest_that(\n  \"Function succeeds when called on a dust_list object\",\n  {\n    expect_silent(\n      dplyr::group_by(mtcars, am, vs) %>% \n        dust(ungroup = FALSE) %>% \n        sprinkle_tabcolsep(tabcolsep = 3)\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is not a dust object\",\n  {\n    expect_error(\n      sprinkle_tabcolsep(mtcars)\n    )\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is a logical object with length not equal to 1\",\n  {\n    expect_error(\n      sprinkle_tabcolsep(x, 1:2)\n    )\n  }\n)\n\ntest_that(\n  \"Cast an error if x is not a logical object\",\n  {\n    expect_error(\n      sprinkle_tabcolsep(x, \"TRUE\")\n    )\n  }\n)\n"
  },
  {
    "path": "tests/testthat/test-sprinkle_table.R",
    "content": "context(\"sprinkle_table\")\n\ntest_that(\"sprinkle_table: apply a sprinkle to all parts\",\n{\n  x <- dust(mtcars)\n  expect_silent(sprinkle_table(x, round = 2))\n})\n\ntest_that(\"sprinkle_table: no valid part names\",\n{\n  x <- dust(mtcars)\n  expect_error(sprinkle_table(x, round = 2, part = \"that part yonder\"))\n})"
  },
  {
    "path": "tests/testthat/test-sprinkle_width.R",
    "content": "context(\"sprinkle_width\")\n\nx <- dust(head(mtcars))\n\n# Functional Requirement 1 ------------------------------------------\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of width and\n   width_units columns in the table part\",\n  {\n    expect_equal(\n      sprinkle_width(x, cols = 2, width = 20)[[\"body\"]][[\"width\"]],\n      rep(c(\"\", \"20\", \"\"), times = c(6, 6, 6*9))\n    )\n  }  \n)\n\ntest_that(\n  \"Correctly reassigns the appropriate elements of width and\n   width_units columns in the table part\",\n  {\n    expect_equal(\n      sprinkle_width(x, cols = 2, width_units = \"%\")[[\"body\"]][[\"width_units\"]],\n      rep(c(\"\", \"%\", \"\"), times = c(6, 6, 6*9))\n    )\n  }  \n)\n\ntest_that(\n  \"Function succeeds when called on a dust_list object\",\n  {\n    expect_silent(\n      mtcars %>% \n        dplyr::group_by(am, vs) %>% \n        dust(ungroup = FALSE) %>% \n        sprinkle_width(cols = \"mpg\", \n                       width = 150,\n                       width_units = \"pt\")\n    )\n  }\n)\n\n# Functional Requirement 2 ------------------------------------------\n\ntest_that(\n  \"Cast an error if x is not a dust object\",\n  {\n    expect_error(sprinkle_width(mtcars))\n  }\n)\n\n# Functional Requirement 3 ------------------------------------------\n\ntest_that(\n  \"Cast an error if width is not a numeric(1)\",\n  {\n    expect_error(sprinkle_width(x, width = \"20\"))\n  }\n)\n\ntest_that(\n  \"Cast an error if width is not a numeric(1)\",\n  {\n    expect_error(sprinkle_width(x, width = c(20, 40)))\n  }\n)\n\n# Functional Requirement 4 ------------------------------------------\n\ntest_that(\n  \"Cast an error if width_units is not a character(1)\",\n  {\n    expect_error(sprinkle_width(x, width_units = 20))\n  }\n)\n\ntest_that(\n  \"Cast an error if width_units is not a character(1)\",\n  {\n    expect_error(sprinkle_width(x, width = c(\"px\", \"pt\")))\n  }\n)\n\n# Functional Requirement 5 ------------------------------------------\n\ntest_that(\n  \"Casts an error if part is not one of body, head, foot, or interfoot\",\n  {\n    expect_error(\n      sprinkle_width(x, width = 20, part = \"not a part\")\n    )\n  }\n)\n\n# Functional Requirement 6 ------------------------------------------\n\ntest_that(\n  \"Casts an error if fixed is not logical(1)\",\n  {\n    expect_error(sprinkle_width(x, width = 20, fixed = \"FALSE\"))\n  }\n)\n\ntest_that(\n  \"Casts an error if fixed is not logical(1)\",\n  {\n    expect_error(sprinkle_width(x, width = 20, fixed = c(TRUE, FALSE)))\n  }\n)\n\n# Functional Requirement 7 ------------------------------------------\n\ntest_that(\n  \"Casts an error if recycle is not one of none, rows, or cols\",\n  {\n    expect_error(sprinkle_width(x, recycle = \"not an option\"))\n  }\n)\n\n# Functional Requirement 8 ------------------------------------------\n\ntest_that(\n  \"Casts an error if recycle = 'none' and width does not have length 1\",\n  {\n    expect_error(sprinkle_width(x, recycle = \"none\", width = 1:2))\n  }\n)\n\n# Functional Requirement 9 ------------------------------------------\n\ntest_that(\n  \"Correctly assigns values when recycle is not 'none' and multiple values are given.\",\n  {\n    expect_equal(\n      sprinkle_width(x, \n                     cols = 1:2,\n                     width = c(1, 3),\n                     recycle = \"rows\")[[\"body\"]][[\"width\"]][1:12],\n      rep(c(\"1\", \"3\"), each = 6)\n    )\n  }\n)\n\ntest_that(\n  \"Correctly assigns values when recycle is not 'none' and multiple values are given.\",\n  {\n    expect_equal(\n      sprinkle_width(x, \n                     cols = 1:2,\n                     width = c(1, 3),\n                     recycle = \"cols\")[[\"body\"]][[\"width\"]][1:12],\n      rep(c(\"1\", \"3\"), times = 6)\n    )\n  }\n)\n\n# Functional Requirement 10 -----------------------------------------\n\ntest_that(\n  \"Quietly accepts only the first value in width_units when recycle = 'none'.\",\n  {\n    expect_equal(\n      sprinkle_width(x,\n                     cols = 1:2,\n                     width = 2,\n                     width_units = c(\"in\", \"pt\"),\n                     recycle = \"none\")[[\"body\"]][[\"width_units\"]][1:12],\n      rep(\"in\", 12)\n    )\n  }\n)"
  },
  {
    "path": "tests/testthat/test-sprinkles.R",
    "content": "context(\"sprinkles\")\n\nx <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n\ntest_that(\n  \"Cast an error if no sprinkles are given\",\n  {\n    skip_on_cran()\n    expect_error(sprinkle(x),\n                 \"At least one sprinkle\")\n  }\n)\n\ntest_that(\n  \"Cast an error if unnamed sprinkles are given\",\n  {\n    skip_on_cran()\n    expect_error(sprinkle(x, rows = 1, cols = 1, \"green\"),\n                 \"Arguments to ... must be named\")\n  }\n)\n\ntest_that(\n  \"Cast an error if a non-existent sprinkle is given\",\n  {\n    skip_on_cran()\n    expect_error(sprinkle(x, not_a_sprinkle = \"abc\"),\n                 \"could not be matched\")\n  }\n)\n\ntest_that(\"sprinkles: bg\",\n{\n  skip_on_cran()\n  expect_equal(sprinkle(x, rows = 1, cols = 1, bg = \"orchid\")$body$bg[1],\n               \"orchid\")\n})\n\n\ntest_that(\"sprinkles: bg_pattern\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_equal(sprinkle(x, rows = 1, cols = 1, \n                        bg_pattern = c(\"orchid\", \"aquamarine\"))$body$bg[1:2],\n               c(\"orchid\", \"\"))\n})\n\n# test_that(\"sprinkles: bg_pattern_by\",\n# {\n#   x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n#   expect_equal(sprinkle(x, rows=1, cols=1, bg_pattern_by = \"columns\")$bg_pattern_by,\n#                \"columns\")\n# })\n\ntest_that(\"sprinkles: bg_pattern_by gives error when invalid option is given\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle(x, rows = 1, cols = 1, bg_pattern_by = \"diagonal\"),\n               \"\")\n})\n\ntest_that(\"sprinkles: bold\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_equal(sprinkle(x, rows = 1, cols = 1, bold = TRUE)$body$bold[1],\n               TRUE)\n})\n\ntest_that(\"sprinkles: bold errors\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle(x, rows = 1, cols = 1, bold = c(1, 2)),\n               \"\")\n})\n\ntest_that(\"sprinkles: border_collapse\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_equal(sprinkle(x, rows=1, cols = 1, \n                        border_collapse = \"separate\")$border_collapse,\n               \"separate\")\n})\n\ntest_that(\"sprinkles: border_collapse errors\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle(x, rows = 1, cols = 1, border_collapse = c(1, 0)),\n               \"\")\n})\n\ntest_that(\"sprinkles: border\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_equal(sprinkle(x, rows = 1, cols = 1, \n                        border = c(\"left\", \"right\"))$body$left_border[1],\n               \"1pt solid black\")\n})\n\ntest_that(\"sprinkles: border errors\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle(x, rows = 1, cols = 1, border = \"everything\"),\n               \"\")\n})\n\ntest_that(\"sprinkles: border_thickness\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_equal(sprinkle(x, rows = 1, cols = 1, \n                        border_thickness = 2)$body$top_border[1],\n               \"2pt solid black\")\n})\n\ntest_that(\"sprinkles: border_thickness errors\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle(x, rows = 1, cols = 1, border_thickness = c(1, 2)),\n               \"\")\n})\n\ntest_that(\"sprinkles: border_units\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_equal(sprinkle(x, rows = 1, cols = 1, \n                        border_units = \"px\")$body$top_border[1],\n               \"1px solid black\")\n})\n\ntest_that(\"sprinkles: border_units errors\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle(x, rows = 1, cols = 1, border_units = c(\"inches\")),\n               \"\")\n})\n\ntest_that(\"sprinkles: border_style\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_equal(sprinkle(x, rows = 1, cols = 1, \n                        border_style = \"dashed\")$body$top_border[1],\n               \"1pt dashed black\")\n})\n\ntest_that(\"sprinkles: border_style errors\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle(x, rows = 1, cols = 1, border_style = c(\"halo\")),\n               \"\")\n})\n\ntest_that(\"sprinkles: border_color\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_equal(sprinkle(x, rows = 1, cols = 1, \n                        border_color = \"Black\")$body$top_border[1],\n               \"1pt solid Black\")\n})\n\ntest_that(\"sprinkles: border_color errors\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle(x, rows = 1, cols = 1, border_color = 1),\n               \"\")\n})\n\ntest_that(\"sprinkles: halign\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_equal(sprinkle(x, rows = 1, cols = 1, \n                        halign = \"left\")$body$halign[1],\n               \"left\")\n})\n\ntest_that(\"sprinkles: halign errors\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle(x, rows = 1, cols = 1, halign = c(\"left\", \"right\")),\n               \"\")\n})\n               \ntest_that(\"sprinkles: height\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_equal(sprinkle(x, rows = 1, cols = 1, height = 12)$body$height[1],\n               \"12\")\n})\n\ntest_that(\"sprinkles: height errors\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle(x, rows = 1, cols = 1, height = c(12, \"text\")),\n               \"\")\n})\n\ntest_that(\"sprinkles: height_units\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_equal(sprinkle(x, rows = 1, cols = 1, \n                        height_units = \"px\")$body$height_units[1],\n               \"px\")\n})\n\ntest_that(\"sprinkles: height_units errors\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle(x, rows = 1, cols = 1, height_units = \"em\"),\n               \"\")\n})\n\ntest_that(\"sprinkles: fn\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_equal(sprinkle(x, rows = 1, cols = 1, \n                        fn = quote(pvalString(value)))$body$fn[1],\n               \"pvalString(value)\")\n})\n\ntest_that(\"sprinkles: font_color\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_equal(sprinkle(x, rows = 1, cols = 1, \n                        font_color = \"orchid\")$body$font_color[1],\n               \"orchid\")\n})\n           \ntest_that(\"sprinkles: font_color error\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle(x, rows = 1, cols = 1, font_color = c(\"orchid\", \"aquamarine\")),\n               \"\")\n})\n\ntest_that(\"sprinkles: font_size\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_equal(sprinkle(x, rows = 1, cols = 1, \n                        font_size = 12)$body$font_size[1],\n               \"12\")\n})\n\ntest_that(\"sprinkles: font_size errors\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle(x, rows = 1, cols = 1, font_size = c(\"1\", \"x\")),\n               \"\")\n})\n\ntest_that(\"sprinkles: font_size_units\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_equal(sprinkle(x, rows = 1, cols = 1, \n                        font_size_units = \"em\")$body$font_size_units[1],\n               \"em\")\n})\n\ntest_that(\"sprinkles: font_size_unit errors\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle(x, rows = 1, cols = 1, font_size_units = c(\"inches\")),\n               \"\")\n})\n\ntest_that(\"sprinkles: italic\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_equal(sprinkle(x, rows = 1, cols = 1, \n                        italic = TRUE)$body$italic[1],\n               TRUE)\n})\n\ntest_that(\"sprinkles: italic errors\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle(x, rows = 1, cols = 1, italic = c(1, 2)),\n               \"\")\n})\n\ntest_that(\"sprinkles: longtable accepts TRUE\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_equal(sprinkle(x, longtable = TRUE)$longtable,\n               TRUE)\n})\n\ntest_that(\"sprinkles: longtable accepts FALSE\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_equal(sprinkle(x, longtable = FALSE)$longtable,\n               FALSE)\n})\n\ntest_that(\"sprinkles: longtable accepts a number\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_equal(sprinkle(x, longtable = 10)$longtable,\n               10)\n})\n\ntest_that(\"sprinkles: longtable- character resolve to FALSE\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle(x, longtable = \"character\"))\n})\n\ntest_that(\"sprinkles: merge\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_silent(sprinkle(x, rows = 3:4, cols = 1:2, merge = TRUE,\n                       merge_rowval = 4, merge_colval = 2))\n})\n\ntest_that(\"sprinkles: merge is not logical\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle(x, rows = 3:4, cols = 1:2, merge = \"yes please\",\n                       merge_rowval = 4, merge_colval = 2),\n               \"\")\n})\n\ntest_that(\"sprinkles: merge_rowval without merge casts message\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_message(sprinkle(x, rows = 3:4, cols = 1:2,\n                       merge_rowval = 4),\n               \"\")\n})\n\ntest_that(\"sprinkles: merge_colval without merge casts message\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_message(sprinkle(x, rows = 3:4, cols = 1:2,\n                       merge_colval = 4),\n               \"\")\n})\n\ntest_that(\"sprinkles: na_string\",\n{\n  skip_on_cran()\n  x <- dust(aov(mpg ~ factor(am) + factor(gear), data = mtcars))\n  expect_equal(sprinkle(x, na_string = \"\")$body$na_string,\n               rep(\"\", 18))\n})\n\ntest_that(\"sprinkles: na_string not character\",\n{\n  skip_on_cran()\n  x <- dust(aov(mpg ~ factor(am) + factor(gear), data = mtcars))\n  expect_error(sprinkle(x, na_string = 1),\n               \"\")\n}) \n\ntest_that(\"sprinkles: pad\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_equal(sprinkle(x, rows = 1, cols = 1, pad = 5)$body$pad[1],\n               \"5\")\n})\n\ntest_that(\"sprinkles: pad errors\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle(x, rows = 1, cols = 1, pad = c(1, \"text\")),\n               \"\")\n})\n\ntest_that(\"sprinkles: replace\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_equal(sprinkle(x, rows = 1, cols = 1, replace = \"Intercept\")$body$replace[1],\n              \"Intercept\")\n})\n\ntest_that(\"sprinkles: replace errors\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle(x, rows = 1, cols = 1, \n                        replace = c(\"Intercept\", \"1/4 Mile Time\")),\n               \"\")\n})\n\ntest_that(\"sprinkles: round\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_equal(sprinkle(x, rows = 1, cols = 1, round = 5)$body$round[1],\n               \"5\")\n})\n\ntest_that(\"sprinkles: round errors\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle(x, rows = 1, cols = 1, round = c(1, \"text\")),\n               \"\")\n})\n\ntest_that(\"sprinkles: rotate_degree\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_equal(sprinkle(x, rows = 1, cols = 1, \n                        rotate_degree = 5)$body$rotate_degree[1],\n               \"5\")\n})\n\ntest_that(\"sprinkles: rotate_degree errors\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle(x, rows = 1, cols = 1, rotate_degree = c(1, \"text\")),\n               \"\")\n})\n\ntest_that(\"sprinkles: valign\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_equal(sprinkle(x, rows = 1, cols = 1, valign = \"middle\")$body$valign[1],\n               \"middle\")\n          })\n\ntest_that(\"sprinkles: valign errors\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle(x, rows = 1, cols = 1, valign = \"above\"),\n               \"\")\n})\n\ntest_that(\"sprinkles: width\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_equal(sprinkle(x, rows = 1, cols = 1, width = 12)$body$width[1],\n               \"12\")\n})\n\ntest_that(\"sprinkles: width errors\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle(x, rows = 1, cols = 1, width = c(12, \"text\")),\n               \"\")\n})\n\ntest_that(\"sprinkles: width_units\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_equal(sprinkle(x, rows = 1, cols = 1, \n                        width_units = \"px\")$body$width_units[1],\n               \"px\")\n})\n\ntest_that(\"sprinkles: width_units errors\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle(x, rows = 1, cols = 1, width_units = \"em\"),\n               \"\")\n})\n\ntest_that(\"sprinkles: no sprinkles given\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data=mtcars))\n  expect_error(sprinkle(x, rows = 1, cols = 1),\n               \"\")\n})\n\ntest_that(\"sprinkles: single unnamed sprinkle\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle(x, rows = 1, cols = 1, \"green\"),\n               \"\")\n})\n\ntest_that(\"sprinkles: multiple unnamed sprinkles\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle(x, rows = 1, cols = 1, \"green\", \"dotted\"),\n               \"\")\n})\n\ntest_that(\"sprinkles: mixture of named and unnamed sprinkles\",\n{\n  skip_on_cran()\n  x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars))\n  expect_error(sprinkle(x, rows = 1, cols = 1, border_color = \"green\", \"dotted\"),\n               \"\")\n})\n\n\ntest_that(\n  \"sprinkles: fixed argument\",\n  {\n    skip_on_cran()\n    x <- dust(lm(mpg ~ qsec + factor(am) + wt, data = mtcars)) %>%\n      sprinkle(cols = c(1, 2, 3),\n               rows = c(1, 2, 3),\n               bg = \"green\",\n               fixed = TRUE) \n    expect_output(print(x))\n  }\n)\n\n\ntest_that(\n  \"sprinkles: longtable\",\n  {\n    skip_on_cran()\n    expect_silent(\n      dust(mtcars) %>%\n        sprinkle(longtable = 10)\n    )\n  }\n)\n          \n  "
  },
  {
    "path": "tests/testthat/test-tidy_label_level.R",
    "content": "context(\"tidy_labels_levels\")\n\n\nmtcars2 <- mtcars\nmtcars2 <- \n  labelVector::set_label(\n    mtcars2,\n    mpg = \"Gas Mileage\",\n    qsec = \"Quarter Mile Time\",\n    am = \"Transmission\",\n    wt = \"Weight\",\n    gear = \"Gears\"\n  )\n\n#* Basic Output for a model with no interactions\n#* Note: numeric_level has no impact as there are no\n#*       interactions involving numeric variables.\n\nfit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars2)\n\ntest_that(\"output for a model with no interactions\",\n{\n  expect_silent(tidy_levels_labels(fit, \n                                 descriptors = c(\"term\", \"term_plain\", \"label\", \n                                                 \"level\", \"level_detail\"),\n                                 numeric_level = \"term\"))\n})\n \n#* Assign factors ahead of the model. This allows \n#* the user to determine the levels that display.\n#* Compare the output for 'am' with the output for 'gear'\n\nmtcars2$am <- factor(mtcars2$am, 0:1, c(\"Automatic\", \"Manual\"))\nmtcars2$am <- labelVector::set_label(mtcars2$am, \"Transmission\") # Label was lost in variable conversion\nfit <- lm(mpg ~ qsec + am + wt + factor(gear), data = mtcars2)\n\ntest_that(\"factor labels from data are preserved\",\n{\n  expect_equal(tidy_levels_labels(fit, \n                                 descriptors = c(\"term\", \"term_plain\", \"label\", \n                                                 \"level\", \"level_detail\"),\n                                 numeric_level = \"term\")$level[3],\n               \"Manual\")\n})\n \n \n#* Include an interaction between a factor and numeric.\n\nfit <- lm(mpg ~ qsec + am * wt + factor(gear), data = mtcars2)\n\n\ntest_that(\"use an interaction\",\n{\n  expect_silent(tidy_levels_labels(fit, \n                                 descriptors = c(\"term\", \"term_plain\", \"label\", \n                                                 \"level\", \"level_detail\"),\n                                 numeric_level = \"term\"))\n})\n \n#* Now observe how 'level' and 'level_detail' change \n#* in the interaction terms as we choose different \n#* values for 'numeric_level'\n\ntest_that(\"use an interaction with term_plain\",\n{\n  expect_silent(tidy_levels_labels(fit, \n                                 descriptors = c(\"term\", \"term_plain\", \"label\", \n                                                 \"level\", \"level_detail\"),\n                                 numeric_level = \"term_plain\"))\n})\n   \ntest_that(\"use an interaction with label\",\n{\n  expect_silent(tidy_levels_labels(fit, \n                                 descriptors = c(\"term\", \"term_plain\", \"label\", \n                                                 \"level\", \"level_detail\"),\n                                 numeric_level = \"label\"))\n})\n\ntest_that(\"tidy_labels_levels with bad descriptor list\",\n{\n  expect_error(tidy_levels_labels(fit,\n                                 descriptors = c(\"term_boring\"),\n                                 numeric_level = \"term\"))\n})\n\ntest_that(\"tidy_labels_levels with bad numeric_level\",\n{\n  expect_error(tidy_levels_labels(fit,\n                                 descriptors = c(\"term\"),\n                                 numeric_level = \"term_boring\"))\n})"
  },
  {
    "path": "tests/testthat.R",
    "content": "library(\"testthat\")\nlibrary(\"pixiedust\")\n\ntest_check(\"pixiedust\")"
  },
  {
    "path": "vignettes/advancedMagic.Rmd",
    "content": "---\ntitle: \"Advanced Magic with `pixiedust`\"\nauthor: \"Benjamin Nutter\"\ndate: \"`r Sys.Date()`\"\noutput:\n  rmarkdown::html_vignette:\n    fig_caption: no\n    number_section: yes\n    toc: yes\n    css: no_css.css\nvignette: >\n  %\\VignetteEngine{knitr::rmarkdown}\n  %\\VignetteIndexEntry{Advanced Magic with pixiedust}\n  \\usepackage[utf8]{inputenc}\n---\n\nIn addition to the basic cell-specific customizations covered in the \"pixiedust\" vignette (`vignette(\"pixiedust\")`), `pixiedust` also supports some more advanced features for displaying tabular output.  Specifically, you can add multi-row headers and footers; display your tables in multiple divisions; and create cells that span multiple columns and/or rows.\n\nThe presentation of this vignette will be a hybrid of tutorial and testing environment.  Due to the way that `pixiedust` generates output, it cannot be directly evaluated for accuracy (this may change some day, but not right now) and so the best way to see if it is doing what is expected is to generate the output.  The primary tutorial aspect of this vignette will be covered in the HTML portions, with the Markdown and Console output being provided mostly to verify that the output is as expected.\n\nFor parts of this vignette, we will work with the `mtcars` data frame.  But first we make some additions to the data.  For simplicity, we will only use the first ten rows of the data frame.  Additionally, we will add labels to the variables using the `set_label` function from the `labelVector` package.\n\n```{r}\nlibrary(dplyr)\nlibrary(pixiedust)\n\nmtcars2 <- mtcars[1:10, ]\nmtcars2 <- \n  labelVector::set_label(\n    mtcars2,\n    mpg = \"Gas Mileage\",\n    cyl = \"Cylinders\",\n    disp = \"Displacement\",\n    hp = \"Horse Power\",\n    drat = \"Rear Axle Ratio\",\n    wt = \"Weight\",\n    qsec = \"1/4 mile time\",\n    vs = \"V/S\",\n    am = \"Transmission\",\n    gear = \"Forward Gears\",\n    carb = \"Carburetors\")\n```\n\nIn other portions of the vignette, we will use a linear model based on the full `mtcars` data set.  We will assign the same variable labels shown above.  We will also create a couple of factor variables to show how factors can be displayed.\n\n```{r, echo=FALSE}\nmtcars <- mutate(mtcars,\n                 am = factor(am, 0:1, c(\"Automatic\", \"Manual\")),\n                 cyl = factor(cyl),\n                 gear = factor(gear))\n\nmtcars <-\n  labelVector::set_label(\n    mtcars,\n    mpg = \"Gas Mileage\",\n    cyl = \"Cylinders\",\n    disp = \"Displacement\",\n    hp = \"Horse Power\",\n    drat = \"Rear Axle Ratio\",\n    wt = \"Weight\",\n    qsec = \"1/4 mile time\",\n    vs = \"V/S\",\n    am = \"Transmission\",\n    gear = \"Forward Gears\",\n    carb = \"Carburetors\")\n\nfit <- lm(mpg ~ am + wt + qsec + gear, data = mtcars)\n```\n\n\n\n# HTML Output\n\n## Multirow Headers and Footers\n\nTo illustrate the multirow headers and footers, we will generate a header that has both the column name and the label.  The footer will summarise the values in each column by mean and standard deviation.\n\n```{r}\ncustom_head <- rbind(names(mtcars2), \n                     labelVector::get_label(mtcars2,\n                                            names(mtcars2))) %>%\n  as.data.frame(stringsAsFactors = FALSE)\n\ncustom_foot <- rbind(vapply(mtcars2, mean, numeric(1)),\n                     vapply(mtcars2, sd, numeric(1))) %>%\n  as.data.frame(stringsAsFactors = FALSE)\n```\n\nNow we need only create a `dust` object and add our custom header and footer.  To replace components of the `dust` object, we \"`redust`\" the component.  We'll also shade the head and foot in different shades of gray to make them stand out.\n\n```{r}\ndust(mtcars2) %>%\n  redust(custom_head, part = \"head\") %>%\n  redust(custom_foot, part = \"foot\") %>%\n  sprinkle_table(round = 2) %>%\n  sprinkle(bg = \"gray\", part = \"head\") %>%\n  sprinkle(bg = \"lightgray\", part = \"foot\") %>%\n  sprinkle_print_method(\"html\")\n```\n\n\n## Longtable Feature\n\nThe longtable feature is named for the LaTeX package `longtable`, which will automatically break a table into multiple divisions, each of which is displayed on a separate page.  We can use the long table sprinkle to break a table into divisions of any size we like.  In this example, we'll use divisions of four rows each.  We will use the same header and footer as the previous example, and we'll also make use of the _interfoot_, which is the footer placed at the bottom of each intermediate table, while the footer is placed only at the bottom of the last table.  We'll make use of the multi-cell feature for the interfoot here, although we won't really discuss it until the next section.\n\nThe code for this table is nearly identical to the previous example.  We just add a `redust` call for the interfoot and add a `longtable` argument to `sprinkle_table`.\n\n```{r}\ncustom_interfoot <- data.frame(\"To Be Continued\", \n                               \"\", \"\", \"\", \"\", \"\", \"\",\n                               \"\", \"\", \"\", \"\")\n\n(x <- dust(mtcars2) %>%\n  redust(custom_head, part = \"head\") %>%\n  redust(custom_foot, part = \"foot\") %>%\n  redust(custom_interfoot, part = \"interfoot\") %>%\n  sprinkle_table(round = 2, longtable = 4) %>%\n  sprinkle(bg = \"gray\", part = \"head\") %>%\n  sprinkle(bg = \"lightgray\", part = \"foot\") %>%\n  sprinkle(bg = \"lightgray\", part = \"interfoot\") %>%\n  sprinkle_print_method(\"html\"))\n```\n\n## Multi-cell Representations\n\nThe table above doesn't look quite right, however, because the \"To Be Continued\" appears in one cell when it might look better spread out on a single line.  We can use the `merge` sprinkle to merge all of the cells in the `interfoot` in order to make it appear more fluid.\n\n```{r}\nx %>%\n  sprinkle(merge = TRUE, halign = \"center\", part = \"interfoot\")\n```\n\nThe `merge` sprinkle may be used to join any number of conjoined cells. The following example is for illustration only, and probably wouldn't be put to use in any meaningful application.  What we will do is merge nine cells and display the value of the center cell.  Take notice of where the value `160` appears in the table below compared to the table above.\n\n```{r}\nx %>%\n  sprinkle(merge = TRUE, halign = \"center\", part = \"interfoot\") %>%\n  sprinkle(rows = 1:3, cols = 2:4,\n           merge = TRUE, merge_rowval = 2, merge_colval = 3,\n           halign = \"center\")\n```\n\n## Model Summaries with Fit Statistics\n\n`pixiedust` offers a few options to help simplify the preparation of model output for tabular display.  If you choose to use the `label` functions from the `labelVector` package, these labels can be accessed for the table.  Additionally, the levels of factor variables may be printed in a more human-readable format. (note that the `label` functions from the `Hmisc` package may also be used)\n\n```{r}\nfit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), \n          data = mtcars)\n\ndust(fit, descriptors = c(\"label\", \"level\")) %>%\n  sprinkle(cols = 3:5, round = 2) %>%\n  sprinkle(cols = 6, fn = quote(pvalString(value))) %>%\n  sprinkle_print_method(\"html\")\n```\n\nOr, if we wish to see the reference value of the factors, we can request the `\"level_detail\"` descriptor.\n\n```{r}\ndust(fit, descriptors = c(\"label\", \"level_detail\")) %>%\n  sprinkle(cols = 3:5, round = 2) %>%\n  sprinkle(cols = 6, fn = quote(pvalString(value))) %>%\n  sprinkle_print_method(\"html\")\n```\n\nOne word of caution: The labels are pulled from the data obtained by `model.frame`, and if you apply a function to a term in your formula, you might lose the label.  Consider the example below, where we include the `vs` variable, but convert it from a numeric to a factor. If retaining the label is important to you, making your conversions prior to assigning the labels will be a good habit.  Don't fret too much, however, as you can always replace a cell's content with the `replace` sprinkle.\n\n```{r}\nfit <- lm(mpg ~ qsec + am + wt + gear + factor(vs), \n          data = mtcars)\n\ndust(fit, descriptors = c(\"label\", \"level_detail\")) %>%\n  sprinkle(cols = 3:5, round = 2) %>%\n  sprinkle(cols = 6, fn = quote(pvalString(value))) %>%\n  sprinkle_print_method(\"html\")\n```\n\nIn addition to providing better labeling of terms and factor levels, `pixiedust` allows you to add model fit statistics in a similar manner that the `stargazer` package does.  Under the default settings, we can build these statistics in the following manner:\n\n```{r}\nfit <- lm(mpg ~ qsec + am + wt + gear, \n          data = mtcars)\n\ndust(fit, descriptors = c(\"label\", \"level_detail\"),\n     glance_foot = TRUE) %>%\n  sprinkle(cols = 3:5, round = 2) %>%\n  sprinkle(cols = 6, fn = quote(pvalString(value))) %>%\n  sprinkle(rows = 1, border = \"top\") %>%\n  sprinkle(cols = c(2, 6), round = 2, na_string = \"\",\n           part = \"foot\") %>%\n  sprinkle(rows = 1, border = \"top\", part = \"foot\") %>%\n  sprinkle_print_method(\"html\")\n```\n\nAt times, we may find the volume of these fit statistics overwhelming and may want to display only a subset of them.  This can be done with the use of the `glance_stats` argument in `dust`.  In addition to selecting the statistics to display, the order in which they are displayed may also be controlled.\n\n```{r}\nfit <- lm(mpg ~ qsec + am + wt + gear, \n          data = mtcars)\n\ndust(fit, descriptors = c(\"label\", \"level_detail\"),\n     glance_foot = TRUE,\n     glance_stats = c(\"AIC\", \"adj.r.squared\", \"BIC\", \"df\"),\n     byrow = TRUE) %>%\n  sprinkle(cols = 3:5, round = 2) %>%\n  sprinkle(cols = 6, fn = quote(pvalString(value))) %>%\n  sprinkle(rows = 1, border = \"top\") %>%\n  sprinkle(cols = c(2, 6), round = 2, na_string = \"\",\n           part = \"foot\") %>%\n  sprinkle(rows = 1, border = \"top\", part = \"foot\") %>%\n  sprinkle_print_method(\"html\")\n```\n\n# Console Output\n\nThe console output isn't as sophisticated as the HTML output, and so not all of the sprinkles applied to the HTML table will show up in the console.  Background shading in particular doesn't appear in the console. Multirow headers and footers still work, however.\n\n## Multirow Headers and Footers\n\nTo illustrate the multirow headers and footers, we will generate a header that has both the column name and the label.  The footer will summarise the values in each column by mean and standard deviation.\n\n```{r}\ncustom_head <- rbind(names(mtcars2), \n                     labelVector::get_label(mtcars2,\n                                            names(mtcars2))) %>%\n  as.data.frame(stringsAsFactors = FALSE)\n\ncustom_foot <- rbind(vapply(mtcars2, mean, numeric(1)),\n                     vapply(mtcars2, sd, numeric(1))) %>%\n  as.data.frame(stringsAsFactors = FALSE)\n```\n\nNow we need only create a `dust` object and add our custom header and footer.  To replace components of the `dust` object, we \"`redust`\" the component.  We'll also shade the head and foot in different shades of gray to make them stand out.\n\n```{r}\ndust(mtcars2) %>%\n  redust(custom_head, part = \"head\") %>%\n  redust(custom_foot, part = \"foot\") %>%\n  sprinkle_table(round = 2) %>%\n  sprinkle(bg = \"gray\", part = \"head\") %>%\n  sprinkle(bg = \"lightgray\", part = \"foot\") %>%\n  sprinkle_print_method(\"console\")\n```\n\n\n## Longtable Feature\n\nThe longtable feature is named for the LaTeX package `longtable`, which will automatically break a table into multiple divisions, each of which is displayed on a separate page.  We can use the long table sprinkle to break a table into divisions of any size we like.  In this example, we'll use divisions of four rows each.  We will use the same header and footer as the previous example, and we'll also make use of the _interfoot_, which is the footer placed at the bottom of each intermediate table, while the footer is placed only at the bottom of the last table.  We'll make use of the multi-cell feature for the interfoot here, although we won't really discuss it until the next section.\n\nThe code for this table is nearly identical to the previous example.  We just add a `redust` call for the interfoot and add a `longtable` argument to `sprinkle_table`.\n\n```{r}\ncustom_interfoot <- data.frame(\"To Be Continued\", \n                               \"\", \"\", \"\", \"\", \"\", \"\",\n                               \"\", \"\", \"\", \"\")\n\n(x <- dust(mtcars2) %>%\n  redust(custom_head, part = \"head\") %>%\n  redust(custom_foot, part = \"foot\") %>%\n  redust(custom_interfoot, part = \"interfoot\") %>%\n  sprinkle_table(round = 2, longtable = 4) %>%\n  sprinkle(bg = \"gray\", part = \"head\") %>%\n  sprinkle(bg = \"lightgray\", part = \"foot\") %>%\n  sprinkle(bg = \"lightgray\", part = \"interfoot\") %>%\n  sprinkle_print_method(\"console\"))\n```\n\n## Multi-cell Representations\n\nThe table above doesn't look quite right, however, because the \"To Be Continued\" appears in one cell when it might look better spread out on a single line.  With the HTML output, we could use the `merge` sprinkle to merge all of the cells in the `interfoot` in order to make it appear more fluid.  However, this feature isn't supported by the console, so the best we can get is the text in one cell.\n\n```{r}\nx %>%\n  sprinkle(merge = TRUE, halign = \"center\", part = \"interfoot\")\n```\n\nThe `merge` sprinkle may be used to join any number of conjoined cells. The following example is for illustration only, and probably wouldn't be put to use in any meaningful application.  What we will do is merge nine cells and display the value of the center cell.  Take notice of where the value `160` appears in the table below compared to the table above.  In the case of markdown output, the cells aren't actually merged, but the values of the non-displayed cells are set to `\"\"`.\n\n```{r}\nx %>%\n  sprinkle(merge = TRUE, halign = \"center\", part = \"interfoot\") %>%\n  sprinkle(rows = 1:3, cols = 2:4,\n           merge = TRUE, merge_rowval = 2, merge_colval = 3,\n           halign = \"center\")\n```\n\n## Model Summaries with Fit Statistics\n\n`pixiedust` offers a few options to help simplify the preparation of model output for tabular display.  If you choose to use the `label` functions from the `labelVector` package, these labels can be accessed for the table.  Additionally, the levels of factor variables may be printed in a more human-readable format. (note that the `label` functions from the `Hmisc` package may also be used)\n\n```{r}\nfit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), \n          data = mtcars)\n\ndust(fit, descriptors = c(\"label\", \"level\")) %>%\n  sprinkle(cols = 3:5, round = 2) %>%\n  sprinkle(cols = 6, fn = quote(pvalString(value))) %>%\n  sprinkle_print_method(\"console\")\n```\n\nOr, if we wish to see the reference value of the factors, we can request the `\"level_detail\"` descriptor.\n\n```{r}\ndust(fit, descriptors = c(\"label\", \"level_detail\")) %>%\n  sprinkle(cols = 3:5, round = 2) %>%\n  sprinkle(cols = 6, fn = quote(pvalString(value))) %>%\n  sprinkle_print_method(\"console\")\n```\n\nOne word of caution: The labels are pulled from the data obtained by `model.frame`, and if you apply a function to a term in your formula, you might lose the label.  Consider the example below, where we include the `vs` variable, but convert it from a numeric to a factor. If retaining the label is important to you, making your conversions prior to assigning the labels will be a good habit.  Don't fret too much, however, as you can always replace a cell's content with the `replace` sprinkle.\n\n```{r}\nfit <- lm(mpg ~ qsec + am + wt + gear + factor(vs), \n          data = mtcars)\n\ndust(fit, descriptors = c(\"label\", \"level_detail\")) %>%\n  sprinkle(cols = 3:5, round = 2) %>%\n  sprinkle(cols = 6, fn = quote(pvalString(value))) %>%\n  sprinkle_print_method(\"console\")\n```\n\nIn addition to providing better labeling of terms and factor levels, `pixiedust` allows you to add model fit statistics in a similar manner that the `stargazer` package does.  Under the default settings, we can build these statistics in the following manner:\n\n```{r}\nfit <- lm(mpg ~ qsec + am + wt + gear, \n          data = mtcars)\n\ndust(fit, descriptors = c(\"label\", \"level_detail\"),\n     glance_foot = TRUE) %>%\n  sprinkle(cols = 3:5, round = 2) %>%\n  sprinkle(cols = 6, fn = quote(pvalString(value))) %>%\n  sprinkle(rows = 1, border = \"top\") %>%\n  sprinkle(cols = c(2, 6), round = 2, na_string = \"\",\n           part = \"foot\") %>%\n  sprinkle(rows = 1, border = \"top\", part = \"foot\") %>%\n  sprinkle_print_method(\"console\")\n```\n\nAt times, we may find the volume of these fit statistics overwhelming and may want to display only a subset of them.  This can be done with the use of the `glance_stats` argument in `dust`.  In addition to selecting the statistics to display, the order in which they are displayed may also be controlled.\n\n```{r}\nfit <- lm(mpg ~ qsec + am + wt + gear, \n          data = mtcars)\n\ndust(fit, descriptors = c(\"label\", \"level_detail\"),\n     glance_foot = TRUE,\n     glance_stats = c(\"AIC\", \"adj.r.squared\", \"BIC\", \"df\"),\n     byrow = TRUE) %>%\n  sprinkle(cols = 3:5, round = 2) %>%\n  sprinkle(cols = 6, fn = quote(pvalString(value))) %>%\n  sprinkle(rows = 1, border = \"top\") %>%\n  sprinkle(cols = c(2, 6), round = 2, na_string = \"\",\n           part = \"foot\") %>%\n  sprinkle(rows = 1, border = \"top\", part = \"foot\") %>%\n  sprinkle_print_method(\"console\")\n```\n\n# Markdown Output\n\nMarkdown output will support some of the features of `pixiedust` a little better, but they are still pretty limited.  Background colors are not supported.  Headers will appear in bold text.  To distinguish the footers, we'll print them in italics.\n\n## Multirow Headers and Footers\n\nTo illustrate the multirow headers and footers, we will generate a header that has both the column name and the label.  The footer will summarise the values in each column by mean and standard deviation.\n\n```{r}\ncustom_head <- rbind(names(mtcars2), \n                     labelVector::get_label(mtcars2,\n                                            names(mtcars2))) %>%\n  as.data.frame(stringsAsFactors = FALSE)\n\ncustom_foot <- rbind(vapply(mtcars2, mean, numeric(1)),\n                     vapply(mtcars2, sd, numeric(1))) %>%\n  as.data.frame(stringsAsFactors = FALSE)\n```\n\nNow we need only create a `dust` object and add our custom header and footer.  To replace components of the `dust` object, we \"`redust`\" the component.  We'll also shade the head and foot in different shades of gray to make them stand out.\n\n```{r}\ndust(mtcars2) %>%\n  redust(custom_head, part = \"head\") %>%\n  redust(custom_foot, part = \"foot\") %>%\n  sprinkle_table(round = 2) %>%\n  sprinkle(bg = \"gray\", part = \"head\") %>%\n  sprinkle(bg = \"lightgray\", part = \"foot\") %>%\n  sprinkle_print_method(\"markdown\")\n```\n\n\n## Longtable Feature\n\nThe longtable feature is named for the LaTeX package `longtable`, which will automatically break a table into multiple divisions, each of which is displayed on a separate page.  We can use the long table sprinkle to break a table into divisions of any size we like.  In this example, we'll use divisions of four rows each.  We will use the same header and footer as the previous example, and we'll also make use of the _interfoot_, which is the footer placed at the bottom of each intermediate table, while the footer is placed only at the bottom of the last table.  We'll make use of the multi-cell feature for the interfoot here, although we won't really discuss it until the next section.\n\nThe code for this table is nearly identical to the previous example.  We just add a `redust` call for the interfoot and add a `longtable` argument to `sprinkle_table`.\n\n```{r}\ncustom_interfoot <- data.frame(\"To Be Continued\", \n                               \"\", \"\", \"\", \"\", \"\", \"\",\n                               \"\", \"\", \"\", \"\")\n\n(x <- dust(mtcars2) %>%\n  redust(custom_head, part = \"head\") %>%\n  redust(custom_foot, part = \"foot\") %>%\n  redust(custom_interfoot, part = \"interfoot\") %>%\n  sprinkle_table(round = 2, longtable = 4) %>%\n  sprinkle(bg = \"gray\", part = \"head\") %>%\n  sprinkle(bg = \"lightgray\", part = \"foot\") %>%\n  sprinkle(bg = \"lightgray\", part = \"interfoot\") %>%\n  sprinkle_print_method(\"markdown\"))\n```\n\n## Multi-cell Representations\n\nThe table above doesn't look quite right, however, because the \"To Be Continued\" appears in one cell when it might look better spread out on a single line.  With the HTML output, we could use the `merge` sprinkle to merge all of the cells in the `interfoot` in order to make it appear more fluid.  However, this feature isn't supported by markdown, so the best we can get is the text in one cell.\n\n```{r}\nx %>%\n  sprinkle(merge = TRUE, halign = \"center\", part = \"interfoot\")\n```\n\nThe `merge` sprinkle may be used to join any number of conjoined cells. The following example is for illustration only, and probably wouldn't be put to use in any meaningful application.  What we will do is merge nine cells and display the value of the center cell.  Take notice of where the value `160` appears in the table below compared to the table above.  In the case of markdown output, the cells aren't actually merged, but the values of the non-displayed cells are set to `\"\"`.\n\n```{r}\nx %>%\n  sprinkle(merge = TRUE, halign = \"center\", part = \"interfoot\") %>%\n  sprinkle(rows = 1:3, cols = 2:4,\n           merge = TRUE, merge_rowval = 2, merge_colval = 3,\n           halign = \"center\")\n```\n\n## Model Summaries with Fit Statistics\n\n`pixiedust` offers a few options to help simplify the preparation of model output for tabular display.  If you choose to use the `label` functions from the `labelVector` package, these labels can be accessed for the table.  Additionally, the levels of factor variables may be printed in a more human-readable format. (note that the `label` functions from the `Hmisc` package may also be used)\n\n```{r}\nfit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), \n          data = mtcars)\n\ndust(fit, descriptors = c(\"label\", \"level\")) %>%\n  sprinkle(cols = 3:5, round = 2) %>%\n  sprinkle(cols = 6, fn = quote(pvalString(value))) %>%\n  sprinkle_print_method(\"markdown\")\n```\n\nOr, if we wish to see the reference value of the factors, we can request the `\"level_detail\"` descriptor.\n\n```{r}\ndust(fit, descriptors = c(\"label\", \"level_detail\")) %>%\n  sprinkle(cols = 3:5, round = 2) %>%\n  sprinkle(cols = 6, fn = quote(pvalString(value))) %>%\n  sprinkle_print_method(\"markdown\")\n```\n\nOne word of caution: The labels are pulled from the data obtained by `model.frame`, and if you apply a function to a term in your formula, you might lose the label.  Consider the example below, where we include the `vs` variable, but convert it from a numeric to a factor. If retaining the label is important to you, making your conversions prior to assigning the labels will be a good habit.  Don't fret too much, however, as you can always replace a cell's content with the `replace` sprinkle.\n\n```{r}\nfit <- lm(mpg ~ qsec + am + wt + gear + factor(vs), \n          data = mtcars)\n\ndust(fit, descriptors = c(\"label\", \"level_detail\")) %>%\n  sprinkle(cols = 3:5, round = 2) %>%\n  sprinkle(cols = 6, fn = quote(pvalString(value))) %>%\n  sprinkle_print_method(\"markdown\")\n```\n\nIn addition to providing better labeling of terms and factor levels, `pixiedust` allows you to add model fit statistics in a similar manner that the `stargazer` package does.  Under the default settings, we can build these statistics in the following manner:\n\n```{r}\nfit <- lm(mpg ~ qsec + am + wt + gear, \n          data = mtcars)\n\ndust(fit, descriptors = c(\"label\", \"level_detail\"),\n     glance_foot = TRUE) %>%\n  sprinkle(cols = 3:5, round = 2) %>%\n  sprinkle(cols = 6, fn = quote(pvalString(value))) %>%\n  sprinkle(rows = 1, border = \"top\") %>%\n  sprinkle(cols = c(2, 6), round = 2, na_string = \"\",\n           part = \"foot\") %>%\n  sprinkle(rows = 1, border = \"top\", part = \"foot\") %>%\n  sprinkle_print_method(\"markdown\")\n```\n\nAt times, we may find the volume of these fit statistics overwhelming and may want to display only a subset of them.  This can be done with the use of the `glance_stats` argument in `dust`.  In addition to selecting the statistics to display, the order in which they are displayed may also be controlled.\n\n```{r}\nfit <- lm(mpg ~ qsec + am + wt + gear, \n          data = mtcars)\n\ndust(fit, descriptors = c(\"label\", \"level_detail\"),\n     glance_foot = TRUE,\n     glance_stats = c(\"AIC\", \"adj.r.squared\", \"BIC\", \"df\"),\n     byrow = TRUE) %>%\n  sprinkle(cols = 3:5, round = 2) %>%\n  sprinkle(cols = 6, fn = quote(pvalString(value))) %>%\n  sprinkle(rows = 1, border = \"top\") %>%\n  sprinkle(cols = c(2, 6), round = 2, na_string = \"\",\n           part = \"foot\") %>%\n  sprinkle(rows = 1, border = \"top\", part = \"foot\") %>%\n  sprinkle_print_method(\"markdown\")\n```"
  },
  {
    "path": "vignettes/no_css.css",
    "content": "/* This is a copy of the html_vignette css file from \n     https://github.com/rstudio/rmarkdown/blob/master/inst/rmarkdown/templates/html_vignette/resources/vignette.css\n     but the table CSS has been removed */\nbody {\n  background-color: #fff;\n  margin: 1em auto;\n  max-width: 700px;\n  overflow: visible;\n  padding-left: 2em;\n  padding-right: 2em;\n  font-family: \"Open Sans\", \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n  font-size: 14px;\n  line-height: 1.35;\n}\n\n#header {\n  text-align: center;\n}\n\n#TOC {\n  clear: both;\n  margin: 0 0 10px 10px;\n  padding: 4px;\n  width: 400px;\n  border: 1px solid #CCCCCC;\n  border-radius: 5px;\n\n  background-color: #f6f6f6;\n  font-size: 13px;\n  line-height: 1.3;\n}\n  #TOC .toctitle {\n    font-weight: bold;\n    font-size: 15px;\n    margin-left: 5px;\n  }\n\n  #TOC ul {\n    padding-left: 40px;\n    margin-left: -1.5em;\n    margin-top: 5px;\n    margin-bottom: 5px;\n  }\n  #TOC ul ul {\n    margin-left: -2em;\n  }\n  #TOC li {\n    line-height: 16px;\n  }\n\np {\n  margin: 0.5em 0;\n}\n\nblockquote {\n  background-color: #f6f6f6;\n  padding: 0.25em 0.75em;\n}\n\nhr {\n  border-style: solid;\n  border: none;\n  border-top: 1px solid #777;\n  margin: 28px 0;\n}\n\ndl {\n  margin-left: 0;\n}\n  dl dd {\n    margin-bottom: 13px;\n    margin-left: 13px;\n  }\n  dl dt {\n    font-weight: bold;\n  }\n\nul {\n  margin-top: 0;\n}\n  ul li {\n    list-style: circle outside;\n  }\n  ul ul {\n    margin-bottom: 0;\n  }\n\npre, code {\n  background-color: #f7f7f7;\n  border-radius: 3px;\n  color: #333;\n  white-space: pre-wrap;    /* Wrap long lines */\n}\npre {\n  border-radius: 3px;\n  margin: 5px 0px 10px 0px;\n  padding: 10px;\n}\npre:not([class]) {\n  background-color: #f7f7f7;\n}\n\ncode {\n  font-family: Consolas, Monaco, 'Courier New', monospace;\n  font-size: 85%;\n}\np > code, li > code {\n  padding: 2px 0px;\n}\n\ndiv.figure {\n  text-align: center;\n}\nimg {\n  background-color: #FFFFFF;\n  padding: 2px;\n  border: 1px solid #DDDDDD;\n  border-radius: 3px;\n  border: 1px solid #CCCCCC;\n  margin: 0 5px;\n}\n\nh1 {\n  margin-top: 0;\n  font-size: 35px;\n  line-height: 40px;\n}\n\nh2 {\n  border-bottom: 4px solid #f7f7f7;\n  padding-top: 10px;\n  padding-bottom: 2px;\n  font-size: 145%;\n}\n\nh3 {\n  border-bottom: 2px solid #f7f7f7;\n  padding-top: 10px;\n  font-size: 120%;\n}\n\nh4 {\n  border-bottom: 1px solid #f7f7f7;\n  margin-left: 8px;\n  font-size: 105%;\n}\n\nh5, h6 {\n  border-bottom: 1px solid #ccc;\n  font-size: 105%;\n}\n\na {\n  color: #0033dd;\n  text-decoration: none;\n}\n  a:hover {\n    color: #6666ff; }\n  a:visited {\n    color: #800080; }\n  a:visited:hover {\n    color: #BB00BB; }\n  a[href^=\"http:\"] {\n    text-decoration: underline; }\n  a[href^=\"https:\"] {\n    text-decoration: underline; }\n\n/* Class described in https://benjeffrey.com/posts/pandoc-syntax-highlighting-css\n   Colours from https://gist.github.com/robsimmons/1172277 */\n\ncode > span.kw { color: #555; font-weight: bold; } /* Keyword */\ncode > span.dt { color: #902000; } /* DataType */\ncode > span.dv { color: #40a070; } /* DecVal (decimal values) */\ncode > span.bn { color: #d14; } /* BaseN */\ncode > span.fl { color: #d14; } /* Float */\ncode > span.ch { color: #d14; } /* Char */\ncode > span.st { color: #d14; } /* String */\ncode > span.co { color: #888888; font-style: italic; } /* Comment */\ncode > span.ot { color: #007020; } /* OtherToken */\ncode > span.al { color: #ff0000; font-weight: bold; } /* AlertToken */\ncode > span.fu { color: #900; font-weight: bold; } /* Function calls */ \ncode > span.er { color: #a61717; background-color: #e3d2d2; } /* ErrorTok */"
  },
  {
    "path": "vignettes/pixiedust.Rmd",
    "content": "---\ntitle: \"Creating Magic with `pixiedust` \"\nauthor: \"Benjamin Nutter\"\ndate: \"`r Sys.Date()`\"\noutput:\n  rmarkdown::html_vignette:\n    fig_caption: no\n    number_section: yes\n    toc: yes\n    css: no_css.css\nvignette: >\n  %\\VignetteEngine{knitr::rmarkdown}\n  %\\VignetteIndexEntry{Creating Magic with pixiedust}\n  \\usepackage[utf8]{inputenc}\n---\n\nWhen David Robinson produced the `broom` package [1], he described it as an attempt to \"[bridge]  the gap from untidy outputs of predictions and estimations to create tidy data that is easy to manipulate with standard tools.\"  While `broom`'s vision was to use model outputs as data, his work had a happy side-effect of producing tabular output that was very near what many researchers wish to present as results.  While the `broom` package assumes you want the model output for further analysis, the `pixiedust` package diverts from this assumption and provides you with the tools to customize that output into a fine looking table suitable for reports.\n\nTo illustrate the functionality of `pixiedust`, we will make use of a linear regression model based on the `mtcars` dataset.  The model is defined:\n\n```{r}\nfit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), \n          data = mtcars)\n```\n\nIn base R, the model summary can be presented using the `summary` command, and produces output that is quasi tabular.  While this summary contains many details of interest to the statistician, many of them are foreign to non-statistical audiences, and may intimidate some readers rather than inviting further reflection.\n\n```{r}\nsummary(fit)\n```\n\nWhen `broom` was released, many undoubtedly recognized the potential to use the tidy output as executive summaries of the analyses.  Surely, the output below is much more consumable for the lay audience than the output above.\n\n```{r}\nbroom::tidy(fit)\n```\n\nThanks to `broom`, the hardest part of generating the tabular output is already accomplished.  However, there are still a few details to be dealt with, even with the tidy output.  For instance, the numeric values have too many decimal places; the column names could be spruced up a little; and we may want to direct readers' attention to certain parts of the table that are of particular interest.  Adding `pixiedust` makes these customizations easier and uses the familiar strategy of `ggplot2` where each new customization is added on top of the others.\n\nThe process of building these tables involves an initial dusting with the `dust` function, and then the addition of \"sprinkles\" to fine tune rows, columns, or even individual cells.  The initial dusting creates a presentation very similar to the `broom` output.  \n\n```{r}\nlibrary(pixiedust)\ndust(fit)\n```\n\nRealistically, the `dust` output is very similar to the `broom` output.  Some differences are that the `broom` output retains the class of the variables.  `term` is a character vector, the other vectors are numeric.  When this output is `dust`ed, however, these are all turned into character values (but with a reference to its original class).  Don't panic, though.  This isn't a disadvantage, it's the key feature of `pixiedust`.  `dust` converts the `broom` output into a table where each cell in the table is represented by a row (Take a look at `dust(fit)$body` to see what I mean).  This is the process by which we get control over every last detail of the table.  By the time we're done, we'll easily produce tables that look like this:\n\n```{r, echo=FALSE}\ndust(fit) %>%\n  sprinkle(cols = c(\"estimate\", \"std.error\", \"statistic\"),\n           round = 3) %>% \n  sprinkle(cols = \"p.value\", fn = quote(pvalString(value))) %>% \n  sprinkle_colnames(\"Term\", \"Coefficient\", \"SE\", \"T-statistic\", \"P-value\") %>% \n  sprinkle(bg_pattern = c(\"orchid\", \"plum\")) %>% \n  sprinkle_print_method(\"html\")\n```\n\nOkay, maybe not those exact colors.  But you have to admit, they are very pixie like colors, are they not?\n\n# Formatting Cell Values\nAs we noted earlier, the default output of `dust` has far too many decimal places.  In most cases, the decimal places returned probably exceed the accuracy of the values in the data.  We can sprinkle the values with `round` or any other function to suit our needs.  First, let's take a look at the `round` sprinkle.\n\n```{r}\ndust(fit) %>% \n  sprinkle(cols = c(\"estimate\", \"std.error\", \"statistic\"), round = 2)\n```\n\nThat already makes a big difference.  We could have rounded the p-values as well, but we'll do something different with those.  We'll use another function to format the p-values into strings.  In the following code, we'll pass a function call to the `fn` argument of `sprinkle`. There are two important aspects of this call to be aware of\n\n1. The function is wrapped in `quote`.  `sprinkles` uses standard evaluation, and passing a function wrapped in `quote` allows us to delay its execution.\n2. The function `pvalString` is acting on `value`.  The elements of the `dust` object are stored in a manner where each cell in the table is a row in a data frame, with the contents of the cell being stored as `value`.  (Try running `dust(fit)$body` to explore the anatomy of the `dust` object).  Any function you pass in the `fn` argument needs to act on `value`.\n\n```{r}\ndust(fit) %>% \n  sprinkle(cols = c(\"estimate\", \"std.error\", \"statistic\"),\n           round = 3) %>% \n  sprinkle(cols = \"p.value\", fn = quote(pvalString(value))) \n```\n\n\n\n# Columns Names\n\nAfter formatting the cell values, the next thing we will likely want to change about our table is the column names.  The names returned by `broom` are deliberately generic.  In a conference call in July of 2015, a listener asked Robinson if using the column name `statisic` made sense for so many model types, since some were `F` statistics, some were `t` and still others were `z`.  Robinson answered that `broom'`s focus was not on the convenience of the reader, but on the convenience of the analyst being able to quickly and easily combine the output of several models.  Having a generic name made it easier for the analyst.  \n\nFor the reader, the table's column names can be modified using the `sprinkle_colnames` function in `pixiedust`.  The function only has a `...` argument, and may accept either named or unnamed arguments.  If the arguments are named, the name matches one of the column names in the `broom` output, and the argument value represents the name we wish to appear in print.\n\n```{r}\ndust(fit) %>% \n  sprinkle(cols = c(\"estimate\", \"std.error\", \"statistic\"),\n           round = 3) %>% \n  sprinkle(cols = \"p.value\", fn = quote(pvalString(value))) %>% \n  sprinkle_colnames(term = \"Term\", p.value = \"P-value\")\n```\n\nNaming the arguments has advantages for reproducibility, as `pixiedust` will correctly assign the column names regardless of order.\n\n```{r}\ndust(fit) %>% \n  sprinkle(cols = c(\"estimate\", \"std.error\", \"statistic\"),\n           round = 3) %>% \n  sprinkle(cols = \"p.value\", fn = quote(pvalString(value))) %>% \n  sprinkle_colnames(term = \"Term\", p.value = \"P-value\", \n                    std.error = \"SE\", statistic = \"T-statistic\",\n                    estimate = \"Coefficient\")\n```\n\nIf all of the columns are to be renamed, we may forego naming the arguments _so long as we are careful to provide the new names in the same order they appear in the table_ (from left to right).  If the new names are provided in the wrong order, they will be applied to the table incorrectly.  Thus, it is recommended to name the arguments.  \n\n```{r}\ndust(fit) %>% \n  sprinkle(cols = c(\"estimate\", \"std.error\", \"statistic\"),\n           round = 3) %>% \n  sprinkle(cols = \"p.value\", fn = quote(pvalString(value))) %>% \n  sprinkle_colnames(\"Term\", \"Coefficient\", \"SE\", \"T-statistic\", \"P-value\")\n```\n\nIn the case that you provide a different number of arguments than there are columns in the table, an error is returned stating such.\n\n```{r, error = TRUE}\ndust(fit) %>% \n  sprinkle(cols = c(\"estimate\", \"std.error\", \"statistic\"),\n           round = 3) %>% \n  sprinkle(cols = \"p.value\", fn = quote(pvalString(value))) %>% \n  sprinkle_colnames(\"Term\", \"Coefficient\", \"SE\", \"T-statistic\", \"P-value\", \"Extra Column Name\")\n```\n\n# Replacing Values in the Table\n\nThere may be times you wish to use different values in the table than what are provided by the `broom` output.  Some examples may be using different standard errors from a ridge regression, or perhaps you prefer to display the variance inflation factors instead of the p-value.  Values can be replaced using the `replace` sprinkle.  In this example, we'll replace the `term` column with names that are a bit more friendly to the reader.\n\n```{r}\ndust(fit) %>% \n  sprinkle(cols = \"term\", \n           replace = c(\"Intercept\", \"Quarter Mile Time\", \"Automatic vs. Manual\",\n                       \"Weight\", \"Gears: 4 vs. 3\", \"Gears: 5 vs 3\")) %>%\n  sprinkle(cols = c(\"estimate\", \"std.error\", \"statistic\"),\n           round = 3) %>% \n  sprinkle(cols = \"p.value\", fn = quote(pvalString(value))) %>% \n  sprinkle_colnames(\"Term\", \"Coefficient\", \"SE\", \"T-statistic\", \"P-value\")\n```\n\nValues are always replaced down the column before across the row.  To illustrate, let's replace the cells in rows 2 - 3 and columns 3 - 4 with the values 100, 200, 300, and 400.  If we want the values to read in sequential order from left to right before going to the next line, we make the replacement call (we will also italicize these cells to make them easier to find)\n\n```{r}\ndust(fit) %>% \n  sprinkle(rows = 2:3, cols = 3:4, \n           replace = c(100, 300, 200, 400),\n           italic = TRUE) %>%\n  sprinkle(cols = c(\"estimate\", \"std.error\", \"statistic\"),\n           round = 3) %>% \n  sprinkle(cols = \"p.value\", fn = quote(pvalString(value))) %>% \n  sprinkle_colnames(\"Term\", \"Coefficient\", \"SE\", \"T-statistic\", \"P-value\")\n```\n\n# Borders and Padding\nFor the duration of the vignette, we will use `basetable` as the basis of additional customizations where `basetable` is defined below. We are also moving out of the capabilities of the console, so we will switch over to HTML printing.\n\n```{r}\nbasetable <- dust(fit) %>% \n  sprinkle(cols = c(\"estimate\", \"std.error\", \"statistic\"),\n           round = 3) %>% \n  sprinkle(cols = \"p.value\", fn = quote(pvalString(value))) %>% \n  sprinkle_colnames(term = \"Term\", estimate = \"Coefficient\", \n                    std.error = \"SE\", statistic = \"T-statistic\", \n                    p.value = \"P-value\") %>% \n  sprinkle_print_method(\"html\")\n```\n\nFor no good reason, let's also focus on drawing attention to the statistically significant results.  Using borders, we could accomplish this by drawing a border around each of those rows.  There are five sprinkles related to borders.\n\n1. `border` controls on which sides of the cells the borders are drawn.\n2. `border_thickness` controls how thick the borders are.\n3. `border_units` controls the units of measure on the thickness.\n4. `border_style` controls the border style (solid or dashed, etc).\n5. `border_color` controls the color of the border.\n\nAll of these sprinkles have default values they can take, so unless we need to customize more than one sprinkle, we need only specify one of the five in order to get all of them to take effect.\n\n```{r}\nbasetable %>% \n  sprinkle(rows = c(2, 4), border_color = \"orchid\")\n```\n\nIf we want to eliminate the borders between cells, we have to do a little more work.\n\n```{r}\nbasetable %>% \n  sprinkle(rows = c(2, 4), cols = 1, \n           border = c(\"left\", \"top\", \"bottom\"),\n           border_color = \"orchid\") %>% \n  sprinkle(rows = c(2, 4), cols = 5,\n           border = c(\"right\", \"top\", \"bottom\"),\n           border_color = \"orchid\") %>%\n  sprinkle(rows = c(2, 4), cols = 2:4,\n           border = c(\"top\", \"bottom\"),\n           border_color = \"orchid\")\n```\n\nWe can further separate these rows by adding more padding to the cells.  In this example, for simplicity, we'll allow the lines between cells.\n\n```{r}\nbasetable %>% \n  sprinkle(rows = c(2, 4), border_color = \"orchid\",\n           pad = 15)\n```\n\n# Bold and Italic Text\nA more conventional way to draw attention to these rows would be to print them in bold text.\n\n```{r}\nbasetable %>% \n  sprinkle(rows = c(2, 4), bold = TRUE)\n```\n\nThe text could also be italicized either separately or concurrently.  He we show the italics printed concurrently.\n\n```{r}\nbasetable %>% \n  sprinkle(rows = c(2, 4), bold = TRUE, italic=TRUE)\n```\n\n# Backgrounds\n\nBackgrounds are added using the `bg` sprinkle, which accepts X11 colors, hexidecimal colors, rgb colors, and for HTML rgba colors (the a specifies the transparency). To put in a background in the rows showing statistical significance, we need only specify the color.\n\n```{r}\nbasetable %>% \n  sprinkle(rows = c(2, 4), bg = \"orchid\")\n```\n\nIf we decide that color is a little bit strong, we can lighten it up a little with the transparency.  We have to look up the rgb specification for the orchid color (there are lots of web resources for this; X11 Color Names on Wikipedia is a good place to start).\n\n```{r}\nbasetable %>% \n  sprinkle(rows = c(2, 4), bg = \"rgba(218,112,214,.5)\")\n```\n\nIf we aren't interested in coloring just those two rows, we can apply color to the entire table with the `bg_pattern` sprinkle.  This sprinkle accepts as many colors as you want to cycle through.\n\n```{r}\nbasetable %>% \n  sprinkle(bg_pattern = c(\"orchid\", \"plum\"))\n```\n\n# Font Sizes and Colors\n\nFont sizes and colors are modified with the `font_size` and `font_color` sprinkles.  We'll employ these simultaneously to highlight our significant rows.\n\n```{r}\nbasetable %>% \n  sprinkle(rows = c(2, 4), \n           font_color = \"orchid\",\n           font_size = 24,\n           font_size_units = \"pt\")\n```\n\n(Woah!  That was a bit too much.)\n\n# Dimensions and Alignment\n\nIn addition to the sprinkles already discussed, we can also use sprinkles to change the height, width, and alignment of cells.  For illustration, we're going to use the first three rows of columns 2-4 to show a grid of all the combinations of alignments.  This requires that each cell be modified individually, so bear with me...the code is a bit long.\n\n```{r}\nbasetable %>% \n  sprinkle(rows = 1, cols = 2, halign = \"left\", valign = \"top\", height = 50, width = 50) %>% \n  sprinkle(rows = 1, cols = 3, halign = \"center\", valign = \"top\", height = 50, width = 50) %>% \n  sprinkle(rows = 1, cols = 4, halign = \"right\", valign = \"top\", height = 50, width = 50) %>% \n  sprinkle(rows = 2, cols = 2, halign = \"left\", valign = \"middle\", height = 50, width = 50) %>% \n  sprinkle(rows = 2, cols = 3, halign = \"center\", valign = \"middle\", height = 50, width = 50) %>% \n  sprinkle(rows = 2, cols = 4, halign = \"right\", valign = \"middle\", height = 50, width = 50) %>% \n  sprinkle(rows = 3, cols = 2, halign = \"left\", valign = \"bottom\", height = 50, width = 50) %>% \n  sprinkle(rows = 3, cols = 3, halign = \"center\", valign = \"bottom\", height = 50, width = 50) %>% \n  sprinkle(rows = 3, cols = 4, halign = \"right\", valign = \"bottom\", height = 50, width = 50)\n```\n# Rotating Text\n\nThere is a sprinkle available to rotate the text in a cell. I don't recommend using it.  Rotated text is harder to read, and communicating concepts is the whole point of the table.  However, sometimes it might be necessary.  For our example, we'll use the first few rows of the `mtcars` data set.\n\nNotice here that when I apply the rotation, I added an argument to `sprinkle` in which I denoted that the rotation should apply to the head of the table.  The head and body of the table are stored separately in the `dust` object and all of the sprinkles may be applied to either part of the table.  \n\n```{r}\ndust(Formaldehyde) %>%\n  sprinkle(cols = c(\"mpg\", \"disp\", \"drat\", \"qsec\"),\n           round = 2) %>%\n  sprinkle(rows = 1,\n           rotate_degree = -90,\n           height = 60,\n           part = \"head\") %>%\n  sprinkle_print_method(\"html\")\n```\n\n# References\n\n1. Robinson, David. \"`broom`: An R Package for Converting Statistical Analysis Objects Into Tidy Data Frames,\" Cornell University Library, https://arxiv.org/pdf/1412.3565v2.pdf."
  },
  {
    "path": "vignettes/sprinkles.Rmd",
    "content": "---\ntitle: \"Sprinkles\"\nauthor: \"Benjamin Nutter\"\ndate: \"`r Sys.Date()`\"\noutput:\n  rmarkdown::html_vignette:\n    fig_caption: no\n    number_section: yes\n    toc: yes\n    css: no_css.css\nvignette: >\n  %\\VignetteEngine{knitr::rmarkdown}\n  %\\VignetteIndexEntry{Sprinkles}\n  \\usepackage[utf8]{inputenc}\n---\n\n```{r, echo = FALSE, warning = FALSE, message = FALSE}\nlibrary(dplyr)\n```\n\nSprinkles are used to modify the appearance of a table. The table below shows each sprinkle and for which output formats it is available. \n\nDetails regarding the use of each sprinkle are in Table 2. \n\n\n```{r, echo=FALSE}\nSprinkles <- read.csv(system.file(\"sprinkles.csv\", package = \"pixiedust\"),\n                        stringsAsFactors=FALSE)\nSprinkles[,-1] <- lapply(Sprinkles[-1], trimws)\n```\n\n```{r, echo=FALSE}\nlibrary(pixiedust)\nred <- \"#A50026\"\nlightgreen <- \"#A6DBA0\"\ngreen <- \"#006837\"\nyellow <- \"#FFFFBF\"\n\nrow_bg <- which(1:nrow(Sprinkles) %% 2 == 0)\n\ndust(Sprinkles[, -2],\n     caption = \"Sprinkles and their output formats\") %>%\n  sprinkle(cols = 2:5,\n           fn = quote(ifelse(value == \"x\", \t\"&#10003;\", \"\"))) %>%\n  sprinkle(bg_pattern_by = \"rows\",\n           border = \"all\",\n           border_color = \"#DCDCDC\") %>%\n  sprinkle(rows = row_bg,\n           border_color = \"#FFFFFF\") %>%\n  sprinkle_table(pad = 3) \n\n```\n\n\n```{r, echo = FALSE}\nSprinkleDocs <- \n  read.csv(system.file(\"sprinkle_documentation.csv\", package = \"pixiedust\"),\n                        stringsAsFactors=FALSE,\n           na = \"\")\n\nSprinkleDocs[[\"sprinkle_name\"]] <- SprinkleDocs[[\"sprinkle\"]]\n\nfor(i in seq_along(SprinkleDocs[[\"sprinkle\"]]))\n{\n  if (is.na(SprinkleDocs[[\"sprinkle_name\"]][i])) \n    SprinkleDocs[[\"sprinkle_name\"]][i] <- SprinkleDocs[[\"sprinkle_name\"]][i-1]\n}\n\nSprinkleDocs <- \n  mutate(SprinkleDocs,\n         bg_index = as.numeric(factor(sprinkle_name,\n                                         unique(sprinkle_name))) %% 2)\n\nrows_bg <- which(SprinkleDocs$bg_index == 0)\n\nrows_top_border <- which(!is.na(SprinkleDocs$sprinkle))\n\ndust(SprinkleDocs[, 1:3],\n     caption = \"Sprinkle Usage\") %>%\n  sprinkle(border = \"all\",\n           border_color = \"#DCDCDC\",\n           na_string = \"\") %>%\n  sprinkle(rows = rows_bg,\n           bg = \"#DDDDDD\",\n           border = \"all\",\n           border_color = \"#FFFFFF\") %>%\n  sprinkle(rows = rows_top_border,\n           border = \"top\", \n           border_color = \"black\",\n           border_thickness = 2) \n```\n"
  },
  {
    "path": "xtable_vs_pixiedust.Rmd",
    "content": "---\ntitle: \"`xtable` vs `pixiedust`: Speed Comparison\"\nauthor: \"Benjamin Nutter\"\ndate: \"`r Sys.Date()`\"\noutput:\n  rmarkdown::html_vignette:\n    fig_caption: no\n    number_section: yes\n    toc: yes\nvignette: >\n  %\\VignetteEngine{knitr::rmarkdown}\n  %\\VignetteIndexEntry{xtable vs pixiedust: Speed Comparison}\n  \\usepackage[utf8]{inputenc}\n---\n\nThe process for comparing the speed of `xtable` and `pixiedust` will be a random sample of `r format(1e4, big.mark = \",\")` rows from the `mtcars` dataset, with replacement.  A table with this many rows is certainly at the fringe of the size of tables people my try to produce using either package and is large enough to give us some idea of how the two packages differ in terms of speed.\n\n```{r, warning = FALSE, message = FALSE}\nlibrary(dplyr)\nlibrary(ggplot2)\nlibrary(microbenchmark)\nlibrary(stargazer)\nlibrary(xtable)\nset.seed(100)\nLargeTable <- mtcars[sample(1:nrow(mtcars), 1000, replace = TRUE), ]\n```\n\nThe `xtable` times are calculated as follows:\n\n```{r, results = 'hide'}\nXtable <- microbenchmark(xtable = print.xtable(xtable(LargeTable, type = \"html\"), type = \"html\",\n                                      print.results = FALSE),\n                         times = 10, unit = \"ms\")\n```\n\nThe `stargazer` times are calculated in a similar manner.\n\n```{r, results = 'hide'}\nStargazer <- microbenchmark(stargazer = {x <- capture.output(stargazer(LargeTable, \n                                                          type = \"html\", summary = FALSE))},\n                            times = 10, unit = \"ms\")\n```\n\nThe `pixiedust` times are calculated below.  We apply the default background pattern just to add a little more complexity to the table.  This should elaborate if adding more sprinkles adds to the processing time.  Further investigation will be needed to determine if the time is added in the `sprinkle` function, or in the printing.\n\n```{r, results='hide'}\nlibs <- list.files(\"F:/pixiedust_library\", full.names = TRUE)\nlib_versions <- gsub(\"(pixiedust-|[.]tar[.]gz)\", \"\", basename(libs))\n\nfor (i in seq_along(libs)){\n  library(pixiedust, \n          lib.loc=file.path(\"F:/pixiedust_library\", lib_versions[i]))\n  \n  Pixie <- microbenchmark({dust(LargeTable) %>% \n                             sprinkle_print_method(\"html\") %>%\n                             sprinkle(bg_pattern_by = \"rows\")},\n                            times = 10, unit = \"ms\")\n  Pixie$expr <- paste0(\"pixiedust \", lib_versions[i])\n\n  \n  assign(paste0(\"Pixie_\", lib_versions[i]), Pixie)\n  \n  detach(\"package:pixiedust\", unload=TRUE)\n}\nrm(list = c(\"Pixie\", \"lib_versions\", \"libs\", \"LargeTable\", \"i\", \"x\"))\n```\n\n```{r, fig.height = 6, fig.width = 8}\nCompare <- bind_rows(mget(x = ls()))\n\nggplot(Compare,\n       aes(x = expr, y = time)) + \n  geom_boxplot() + \n  theme(axis.text.x = element_text(angle = 90, hjust = 1))\n\nMedian <- Compare %>%\n  group_by(expr) %>%\n  summarise(median_time = median(time)) %>%\n  mutate(relative_time = median_time / min(median_time)) %>%\n  print()\n```\n\n"
  }
]