var: Variance of frequency distribution table (numerical variable)

View source: R/var.R

varR Documentation

Variance of frequency distribution table (numerical variable)

Description

S3 methods for the variance of a fdt.
Useful to estimate the variance (when the real data vector is not known) from a previous fdt.

Usage

## S3 generic
var(x, ...)

## S3 methods: numerical
## Default S3 method:
var(x, ...)

## S3 method for class 'fdt'
var(x, ...)

## S3 method for class 'fdt.multiple'
var(x, ...)

Arguments

x

a fdt (simple or multiple) object.

...

required to be generic.

Details

var.fdt calculates the value of the variance based on a known formula. var.fdt.multiple calls var.fdt for each variable, that is, each column of the data.frame.

Value

var.fdt returns a numeric vector containing the value of the variance of the fdt. var.fdt.multiple returns a list, where each element is a numeric vector containing the value of the variance of the fdt for each variable.

Author(s)

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

See Also

sd.fdt, mean.fdt.

Examples

library(fdth)

mdf <- data.frame(x=rnorm(1e2,
                          20,
                          2),
                  y=rnorm(1e2,
                          30,
                          3),
                  z=rnorm(1e2,
                          40,
                          4))

head(mdf)

# From a data.frame
apply(mdf,
      2,
      var)

# From a fdt object
var(fdt(mdf))

unlist(var(fdt(mdf)))

fdth documentation built on May 12, 2026, 1:08 a.m.