Learn R Programming

FSA (version 0.8.11)

kCounts: Specific utilities for use in a knitr document.

Description

Specific utilities for pretty printing various items in a knitr document.

Usage

kCounts(value, capitalize = FALSE)
kPvalue(value, digits = 4, include.p = TRUE, latex = TRUE)
purl2(file, out.dir = NULL, newname = NULL, topnotes = NULL, moreItems = NULL, blanks = c("extra", "all", "none"), delHeader = NULL, timestamp = TRUE, ...)
reproInfo(out = c("r", "markdown", "latex"), rqrdPkgs = NULL, elapsed = NULL, width = 0.95 * getOption("width"), addTOC = TRUE, newpage = FALSE, links = NULL, closeGraphics = TRUE)

Arguments

value
A single numeric count or p-value.
capitalize
A logical that indicates if the returned words should be capitalized or not (the default).
digits
Number of decimal places to round the values to.
include.p
A logical that indicates whether the result should be a character string with “p=” appended to the numerical result.
latex
A logical that indicates whether the resultant p-value string should be contained within dollar signs to form a latex formula.
file
A string that contains the root name of the .RNW file. This will also be the name of the resultant purled file with .R appended.
out.dir
A string that indicates the directory structure in which the purled file should be located. This should not have a forward slash at the end.
newname
A string for the output filename (without the extension) from purl2.
topnotes
A character vector of lines to be added to the top of the output file. Each value in the vector will be placed on a single line at the top of the output file.
moreItems
A string that contains additional words that when found in the purled file will result in the entire line with those words to be deleted.
blanks
A string that indicates if blank lines should be removed. If blanks="all" then all blank lines will be removed. If blanks="extra" then only “extra” blanks lines will be removed (i.e., one blank line will be left where there was originally more than one blank line).
delHeader
A single character that denotes the top and bottom of a block of lines that should be deleted from the script created by purl2.
timestamp
A logical that indicates whether a timestamp comment should be appended to the bottom of the script created by purl2.
out
A string that indicates the type of output from reproInfo -- Markdown, LaTeX, or simple R code.
rqrdPkgs
A string vector that contains packages that are required for the vignette and for which all dependencies should be found.
elapsed
A numeric, usually from proc.time, that is the time required to run the vignette. If NULL then this output will not be used. See the note below.
width
A numeric that indicates the width to use for wrapping the reproducibility information when out="r".
addTOC
A logical that indicates whether or not a table of contents entry for the reproducibity section should be added to the LaTeX output. Used only if Rout="latex"
newpage
A logical that indicates whether or not the reproduciility information should begin on a new page. Used only if Rout="latex"
links
A named character vector that will add a links bullet to the reproducibility information. The names will be shown and the values are the links. Used only if Rout="markdown.
closeGraphics
A logical that indicates whether the graphics device should be closed or not.
...
Additional arguments for the original purl.

Value

  • kCounts returns a numeric value if the count is less than zero or greater than ten and returns a character string of the number ‘name’. See the examples.
  • kPvalue returns a character string of the supplied p-value rounded to the requested number of digits or a character string that indicates what the p-value is less than the value with a ‘5’ in the digits+1 place. See the examples.
  • purl2 is a modification of purl from knitr that creates a file with the same name as file but with lines removed that contain certain words (those found in ItemsToRemove and moreItems).
  • reproInfo returns Markdown, LaTeX, or R code that prints “reproducibility information” at the bottom of the knitted document.

Details

  • kCounts is used to convert numeric numbers to ‘word’ numbers in a sentence.
  • kPvalue is used to print ‘pretty’ p-values.
  • purl2 is used to create a modified (see below) Stangled or purled script.
  • reproInfo is used to print ‘reproducibility information’ for the document.

See Also

See formatC for functionality similar to kPvalue. See purl and knit in knitr for functionality similar to purl2.

Examples

Run this code
kCounts(7)
kCounts(17)
kCounts(0)
kCounts(-6)
kCounts(3,capitalize=TRUE)

kPvalue(0.123456789)
kPvalue(0.000123456)
kPvalue(0.000012345)
kPvalue(0.000012345,include.p=FALSE)
kPvalue(0.000012345,include.p=FALSE,latex=FALSE)

Run the code above in your browser using DataLab