Learn R Programming

fdth (version 1.2-1)

make.fdt: Frequency distribution table for continuous and categorical variables

Description

Makes a full fdt from a minimal set of information. Useful to reproduce (when the real data vector is not known) a previous fdt.

Usage

make.fdt(f, start, end, right=FALSE)
make.fdt_cat(f, categories=NULL, sort=TRUE, decreasing=TRUE)

Arguments

f
A numeric vector object of frequency.
start
The left value of the interval of the first class.
end
The last value of the interval of the last class.
right
Intervals right open (default = FALSE).
categories
...
sort
...
decreasing
...

Value

The function make.fdt returns a list with the slots:
table
A data.frame storing the fdt.
breaks
A vector of length 4 storing start, end, h and right of the fdt generated by this method.
The function make.fdt_cat returns a list whith the slots:
Category
The levels of the categorical variable.
f
Absolute frequency, numeric
rf
Relative frequency, numeric
rf(%)
Relative frequency in percentages, numeric
cf
Cumulative frequency; numeric
cf(%)
Cumulative frequency in percentages, numeric

Details

Given the starting and ending values of the continuous variable table or the levels of the categorical variable plus the number of intervals and the absolute frequency values the functions make.fdt and make.fdt_cat reconstruct whole fdt or fdt_cat table.

See Also

table and cut provided by base package.

Examples

Run this code
## Numeric
## Making one reference fdt
set.seed(33)
x <- rnorm(1e3, 
           20, 
           2)

(tb.r <- fdt(x))

## Making a brand new
(tb.n  <- make.fdt(f=tb.r$table$f,
                   start=13.711,
                   end=27.229))   # Huumm ..., good, but ... Can it be better? 

summary(tb.n,
        format=TRUE,
        pattern='%.3f')           # Is it nice now?


## Categorical
x <- sample(letters[1:5], 
            1e3, 
            rep=TRUE)

## Making one reference fdt
(tb.r <- fdt_cat(x))

## Making a brand new
(tb.n <- make.fdt_cat(f=tb.r$f,
                      categ=tb.r$Category))

Run the code above in your browser using DataLab