subtable: data.frame reduction

Description Usage Arguments Details Value Author(s) Examples

View source: R/subtable.R

Description

Reduces a data.frame into a frequency table with prespecified entries. Uses a modified version of the count function which also accepts weights. Zero-entries can be included or excluded and the variables can be coerced into factors if necessary.

Usage

1
2
subtable(data, cols, freqvar = "Freq", 
		keep.zero = FALSE, allfactor = FALSE, return.type = class(data))

Arguments

data

The data.frame to reduce.

cols

An ordered integer vector containing the indices of the colums to keep.

freqvar

Optional name of a frequency variable in V.

keep.zero

A logical indicating whether to include zero-cases in the output.

allfactor

A logical indicating whether to convert all variables into factor variables. Integer variables will be applied a fitting (non-lexicographic) level order.

return.type

The function is able to convert the output to a data.frame or table. The default is to use the same type as the input had.

Details

This function uses count as a workhorse and offers additional arguments keep.zero and allfactor. Both raw datasets, datasets with a frequency variable and tables can be handled.

Value

A data.frame including a "Freq" variable.

Author(s)

Alexander Pilhoefer
Department for Computer Oriented Statistics and Data Analysis
University of Augsburg
Germany

Examples

1
2
3
4
5
6
require(MASS)
hs2 = subtable(housing,c(3,1))
summary(hs2)

A <- arsim(33333,c(11,11,11,11),3)
subtable(A, c(1,4))

extracat documentation built on July 17, 2018, 5:05 p.m.

Related to subtable in extracat...