Learn R Programming

FSA (version 0.8.6)

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
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"

Value

    • kCountsreturns a numeric value if the count is less than zero or greater than ten and returns a character string of the numbername. See the examples.
    • kPvaluereturns 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 a5in thedigits+1 place. See the examples.
    • purl2is a modification ofpurlfromknitrthat creates a file with the same name asfilebut with lines removed that contain certain words (those found inItemsToRemoveandmoreItems).
    • reproInforeturns Markdown, LaTeX, or R code that printsreproducibility informationat the bottom of the knitted document.

item

  • newpage
  • links
  • closeGraphics
  • ...

R

  • out="latex"
  • out="markdown

code

purl

Details

  • kCountsis used to convert numeric numbers towordnumbers in a sentence.
  • kPvalueis used to printprettyp-values.
  • purl2is used to create a modified (see below) Stangled or purled script.
  • reproInfois used to printreproducibility informationfor 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