Rtdf: Print and/or store 'table' object as 'data.frame'.

View source: R/Rtdf.R

RtdfR Documentation

Print and/or store table object as data.frame.

Description

This is a simple convenience wrapper function to print and/or store objects returned in table class as either a matrix, dataframe or list, which allows for more versatility in the printing methods for tabulations (e.g., presenting tabulations "long-ways", as opposed to the default short, and therefore potentially wide, method for the table class). Currently only implemented for one object interpretable as a factor, since stats::ftable() exists for multi-object tabulation

Usage

R.tdf(x, names = c(deparse(substitute(x)), "Freq"), cls = "df")

Arguments

x

an object suitable for tabulating discrete counts (i.e., interpretable as a factor). See documentation for base::table.

names

Character vector containing the labels to be used for colnames when cls is either data.frame or matrix. Currently, the default is the deparsed object tag.

cls

Character string ("df") indicating the output class. Can be one of "data.frame"/"df" (default), "matrix"/"mat", or "list"/"ls"

Details

See ?base::table.

Value

Returns an object in the class indicated for cls containing the frequency tabulation of discrete values in x.

Author(s)

Rachel M. Smith

See Also

base::table, stats::ftable for multi-object tabulation.


EccRiley/Riley documentation built on Feb. 15, 2024, 9:29 a.m.