summary: Summary methods for fdt objects

summary.fdtR Documentation

Summary methods for fdt objects

Description

S3 methods to return a data.frame (the frequency distribution table - ‘⁠fdt⁠’) for fdt.default, fdt.multiple, fdt_cat.default and fdt_cat.multiple objects.

Usage

## S3 methods
## S3 method for class 'fdt.default'
summary(object,
        columns=1:6,
        round=2,
        format.classes=FALSE,
        pattern="%09.3e",
        row.names=FALSE,
        right=TRUE, ...)

## S3 method for class 'fdt.multiple'
summary(object,
        columns=1:6,
        round=2,
        format.classes=FALSE,
        pattern="%09.3e",
        row.names=FALSE,
        right=TRUE, ...)

## S3 method for class 'fdt_cat.default'
summary(object,
        columns=1:6,
        round=2,
        row.names=FALSE,
        right=TRUE, ...)

## S3 method for class 'fdt_cat.multiple'
summary(object,
        columns=1:6,
        round=2,
        row.names=FALSE,
        right=TRUE, ...)

Arguments

object

a fdt or fdt_cat object.

columns

a vector of integers to select columns of the data.frame table.

round

rounds ‘⁠fdt⁠’ columns to the specified number of decimal places (default 2).

format.classes

logical, if TRUE the first column of the data.frame table will be formated using regular expression. The default is “%09.3e”.

pattern

same as fmt in sprintf.

row.names

logical (or character vector), indicating whether (or what) row names should be printed. The default is FALSE.

right

logical, indicating whether or not strings should be right-aligned. The default is right-alignment.

...

optional further arguments (require by generic).

Details

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, %

The available parameters offer an easy and powerful way to format the ‘⁠fdt⁠’ for publications and other purposes.

Value

A single data.frame for fdt.default or multiple data.frames for fdt.multiple.

Author(s)

Faria, J. C.
Allaman, I. B
Jelihovschi, E. G.

Examples

library (fdth)

#======================
# Vectors: univariated
#======================
set.seed(1)

x <- rnorm(n=1e3,
           mean=5,
           sd=1)

ft <- fdt(x)

str(ft)

ft

summary(ft)  # the same

summary(ft,
        format=TRUE)      # It can not be what you want to publications!

summary(ft,
        format=TRUE,
        pattern='%.2f')   # Huumm ..., good, but ... Can it be better?

summary(ft,
        col=c(1:2, 4, 6),
        format=TRUE,
        pattern='%.2f')   # Yes, it can!

range(x)                  # To know x

summary(fdt(x,
            start=1,
            end=9,
            h=1),
        col=c(1:2, 4, 6),
        format=TRUE,
        pattern='%d')     # Is it nice now?

ft[['table']]                        # Stores the feq. dist. table (fdt)
ft[['breaks']]                       # Stores the breaks of fdt
ft[['breaks']]['start']              # Stores the left value of the first class
ft[['breaks']]['end']                # Stores the right value of the last class
ft[['breaks']]['h']                  # Stores the class interval
as.logical(ft[['breaks']]['right'])  # Stores the right option

#=============================================
# Data.frames: multivariated with categorical
#=============================================
mdf <- data.frame(X1=rep(LETTERS[1:4], 25),
                  X2=as.factor(rep(1:10, 10)),
                  Y1=c(NA, NA, rnorm(96, 10, 1), NA, NA),
                  Y2=rnorm(100, 60, 4),
                  Y3=rnorm(100, 50, 4),
                  Y4=rnorm(100, 40, 4),
                  stringsAsFactors=TRUE)
                  
ft_c <- fdt_cat(mdf)

summary(ft_c)

ft <- fdt(mdf,
          na.rm=TRUE)

str(ft)

summary(ft)  # the same

summary(ft,
        format=TRUE)

summary(ft,
        format=TRUE,
        pattern='%05.2f')  # regular expression

summary(ft,
        col=c(1:2, 4, 6),
        format=TRUE,
        pattern='%05.2f')

print(ft,
      col=c(1:2, 4, 6))

print(ft,
      col=c(1:2, 4, 6),
      format=TRUE,
      pattern='%05.2f')

levels(mdf$X1)

summary(fdt(mdf,
            k=5,
            by='X1',
            na.rm=TRUE))

levels(mdf$X2)

summary(fdt(mdf, 
            breaks='FD',
            by='X2',
            na.rm=TRUE),
        round=3)

summary(fdt(mdf,
            k=5,
            by='X2',
            na.rm=TRUE),
        format=TRUE,
        round=3)

summary(fdt(iris,
            k=5),
        format=TRUE,
        patter='%04.2f')

levels(iris$Species)

summary(fdt(iris, 
            k=5, 
            by='Species'), 
        format=TRUE, 
        patter='%04.2f')

#=========================
# Matrices: multivariated
#=========================
summary(fdt(state.x77),
        col=c(1:2, 4, 6),
        format=TRUE)

summary(fdt(volcano,
            right=TRUE),
        col=c(1:2, 4, 6),
        round=3,
        format=TRUE,
        pattern='%05.1f')

jcfaria/fdth documentation built on Nov. 24, 2023, 4:16 a.m.