Description Usage Arguments Value Methods (by class) Examples
Creates formatted HTML tables of in a flexible, convenient way.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | fable(x, ...)
## S3 method for class 'data.frame'
fable(x, value, facets, ..., render, lab,
expand.along = c("rows", "columns"), drop = c("both", "rows",
"columns", "none"), collapse.cells = TRUE, row.names = T)
## S3 method for class 'formula'
fable(x, data, ..., render, lab,
expand.along = c("rows", "columns"), drop = c("both", "rows",
"columns", "none"), collapse.cells = TRUE)
## S3 method for class 'numeric'
fable(x, rowvars, colvars, ..., render, lab,
expand.along = c("rows", "columns"), drop = c("both", "rows",
"columns", "none"), collapse.cells = TRUE)
## S3 method for class 'ftable'
fable(x, text = matrix(as.character(x), nrow(x)), ...,
lab, drop = c("both", "rows", "columns", "none"),
collapse.cells = TRUE)
|
x |
An object. |
... |
Additional arguments passed to |
value |
A column name or position. |
facets |
A two-sided formula of the form |
render |
A function to render the contents of each cell to character data. |
lab |
Specify the contents of an extra table cell spanning over all column labels. |
expand.along |
Specify the direction to expand the table when render returns a (named) vector. |
drop |
If |
collapse.cells |
If |
row.names |
If |
data |
A data.frame. |
rowvars |
A list of row variables for splitting the data. |
colvars |
A list of column variables for splitting the data. |
text |
A character matrix containing the textual content of each table cell. |
A character
which contains an HTML table fragment. It has
additional class attributes that cause it to be displayed in a browser in an
interactive context, and rendered as HTML in a knitr
context.
data.frame
: The data.frame
method.
formula
: The formula
method.
numeric
: The numeric
method.
ftable
: The ftable
method.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | # mtcars examples
fable(mtcars)
fable(mtcars, mpg, facets=(gear ~ cyl), lab="Cylinders")
fable(mpg ~ gear | cyl, data=mtcars, lab="Cylinders")
fable(rownames(mtcars) ~ gear | cyl, data=mtcars,
render=paste, collapse="<br/>", lab="Cylinders")
# OrchardSprays examples
fable(head(OrchardSprays, 12))
fable(head(OrchardSprays, 12), row.names=FALSE)
fable(treatment ~ rowpos | colpos, data=OrchardSprays, lab="colpos")
fable(paste(treatment, decrease, sep="<br/>") ~ rowpos | colpos, data=OrchardSprays, lab="colpos")
rndr.meansd <- function(x) formatC(c(Mean=mean(x), SD=sd(x)), digits=3)
fable(decrease ~ treatment, data=OrchardSprays, render=rndr.meansd, expand.along="rows")
fable(decrease ~ treatment, data=OrchardSprays, render=rndr.meansd, expand.along="columns")
# ToothGrowth examples
fable(len ~ dose | supp, data=ToothGrowth, lab="Mean (SD)",
render=function(x) sprintf("%0.3g (%0.3g)", mean(x), sd(x)))
fable(len ~ dose | supp, data=ToothGrowth, lab="Supplement Type",
render=rndr.meansd)
fable(len ~ dose | supp, data=ToothGrowth, lab="Supplement Type",
render=rndr.meansd, expand.along="columns")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.