xtable.fdt {fdth} | R Documentation |
LaTeX table of the frequency distribution table
Description
This function returns a LaTeX table of the fdt
, fdt.multiple
and fdt_cat.multiple
objects of the xtable
class.
Usage
## S3 method for class 'fdt'
xtable(x,
caption = NULL,
label = NULL,
align = NULL,
digits = NULL,
display = NULL,
auto = FALSE,
...)
## S3 method for class 'fdt.multiple'
xtable(x,
caption = NULL,
label = NULL,
align = NULL,
digits = NULL,
display = NULL,
...)
## S3 method for class 'fdt_cat.multiple'
xtable(x,
caption = NULL,
label = NULL,
align = NULL,
digits = NULL,
display = NULL,
...)
Arguments
x |
A |
caption |
Character vector of length 1 or 2 containing the table's caption or title. See |
label |
Character vector of length 1 containing the LaTeX label or HTML anchor. See |
align |
Character vector of length equal to the number of columns of the resulting table, indicating the alignment of the corresponding columns. See |
digits |
Numeric vector of length equal to one (in which case it will be replicated as necessary) or to the number of columns of the resulting table or matrix of the same size as the resulting table, indicating the number of digits to display in the corresponding columns. See |
display |
Character vector of length equal to the number of columns of the resulting table, indicating the format for the corresponding columns. See |
auto |
Logical, indicating whether to apply automatic format when no value is passed to |
... |
Additional arguments. |
Details
The functions latex.fdt
was deprecated. We understand over the years that creating a method for the generic xtable
function would be inevitable, given the advancement of the xtable package and its support by the academic community.
Then, the fdt
, fdt.multiple
and fdt_cat.multiple
methods were created for the generic xtable
function. For object of the fdt_cat
class, no methods were created, as they inherit the data.frame
class, and therefore, the xtable
functions can be used directly for such objects.
Objects of the fdt.multiple
and fdt_cat.multiple
class, when using the xtable
function, will have the xtableList
class. Although it may seem confusing, the xtableList
function in the xtable package has no generic function and therefore it was not possible to create a method of type xtableList.fdt.multiple
. Therefore, a method of the xtable.fdt.multiple
class was created, but the function xtableList
is being used internally.
More examples than those provided in the manual can be seen in the vignette.
It is possible to select what columns of the table (a data.frame
) will be shown, as well as the pattern of the first column. The columns are:
-
‘Class limits’
-
‘f’ - Absolute frequency
-
‘rf’ - Relative frequency
-
‘rf(%)’ - Relative frequency, %
-
‘cf’ - Cumulative frequency
-
‘cf(%)’ - Cumulative frequency, %
Value
An object of the class xtable.fdt
, xtable.fdt.multiple
and xtable.fdt_cat.multiple
.
Author(s)
Faria, J. C.
Allaman, I. B
Jelihovschi, E. G.
See Also
Examples
library(fdth)
library(xtable)
# +++++ Quantitative data
## Example 1: The simplest possible
t1 <- fdt(rnorm(n=1e3,
mean=10,
sd=2))
t1x <- xtable(t1)
t1x
## Example 2
print(t1x,
include.rownames=FALSE)
## Example 3
newclass <- gsub("[\\[\\)]",
"",
t1x[,1],
perl=TRUE)
t3x <- t1x
t3x[,1] <- newclass
print(t3x,
include.rownames=FALSE,
sanitize.text.function = function(x)gsub(",",
"\\dashv",
x,
perl = TRUE))
## Not run:
## Example 4
clim <- t1$table[1]
clim1 <- sapply(clim,
as.character)
right <- t1$breaks[4]
pattern <- "
clim2 <- make.fdt.format.classes(clim1,
right,
pattern)
clim3 <- sapply(clim2,
function(x) paste0("$",
x,
"$"))
t4x <- t1x
t4x[,1] <- clim3
print(t4x,
include.rownames=FALSE)
## End(Not run)
## Example 5
t5 <- fdt(iris,
by="Species")
attr(t5, "subheadings") <- paste0("Variable = ",
names(t5))
xtable(t5)
# +++++ Qualitative data
## Example 6
t6 <- fdt_cat(sample(LETTERS[1:3],
replace=TRUE,
size=30))
t6x <- xtable(t6)
t6x
t61 <- fdt_cat(data.frame(c1=sample(LETTERS[1:3],
replace=TRUE,
size=10),
c2=sample(letters[4:5],
replace=TRUE,
size=10),
stringsAsFactors=TRUE))
attr(t61, "subheadings") <- paste0("Variable = ",
names(t61))
t61x <- xtable(t61)
t61x