Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

xtable.fdt

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

xtable.fdt(x,
           caption = NULL,
           label = NULL,
           align = NULL,
           digits = NULL,
           display = NULL,
           auto = FALSE,
           ...) 

xtable.fdt.multiple(x,
                    caption = NULL,
                    label = NULL,
                    align = NULL,
                    digits = NULL,
                    display = NULL,
                    ...) 

xtable.fdt_cat.multiple(x,
                        caption = NULL,
                        label = NULL,
                        align = NULL,
                        digits = NULL,
                        display = NULL,
                        ...)

Arguments

x

A fdt or fdt.multiple class object.

caption

Character vector of length 1 or 2 containing the table's caption or title. See xtable function to more details.

label

Character vector of length 1 containing the LaTeX label or HTML anchor. See xtable function to more details.

align

Character vector of length equal to the number of columns of the resulting table, indicating the alignment of the corresponding columns. See xtable function to more details.

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 xtable function to more details.

display

Character vector of length equal to the number of columns of the resulting table, indicating the format for the corresponding columns. See xtable function to more details.

auto

Logical, indicating whether to apply automatic format when no value is passed to align, digits, or display

...

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:

  1. Class limits

  2. f - Absolute frequency

  3. rf - Relative frequency

  4. rf(%) - Relative frequency, %

  5. cf - Cumulative frequency

  6. cf(%) - Cumulative frequency, %

Value

An object of the class xtable.fdt and xtable.fdt.multiple.

Author(s)

José Cláudio Faria
Enio G. Jelihovschi
Ivan B. Allaman

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

fdth

Frequency Distribution Tables, Histograms and Polygons

v1.2-5
GPL (>= 2)
Authors
Jos<e9> Cl<e1>udio Faria, Enio G. Jelihovschi and Ivan B. Allaman
Initial release
2020-04-17

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.