| 1 |
\name{Table} |
| 2 |
\alias{Table} |
| 3 |
\alias{Table,atomic-method} |
| 4 |
\alias{Table,factor-method} |
| 5 |
\alias{Table,item.vector-method} |
| 6 |
\title{One-Dimensional Table of Frequences and/or Percentages} |
| 7 |
\description{ |
| 8 |
\code{Table} is a generic function that |
| 9 |
produces a table of counts or weighted counts |
| 10 |
and/or the corresponding percentages of an atomic vector, |
| 11 |
factor or \code{"item.vector"} object. |
| 12 |
This function is intended for use with |
| 13 |
\code{\link{Aggregate}} or \code{\link{genTable}}. |
| 14 |
The \code{"item.vector"} method is the workhorse |
| 15 |
of \code{\link{codebook}}. |
| 16 |
} |
| 17 |
\usage{ |
| 18 |
\S4method{Table}{atomic}(x,weights=NULL,counts=TRUE,percentage=FALSE,\dots) |
| 19 |
\S4method{Table}{factor}(x,weights=NULL,counts=TRUE,percentage=FALSE,\dots) |
| 20 |
\S4method{Table}{item.vector}(x,weights=NULL,counts=TRUE,percentage=(style=="codebook"), |
| 21 |
style=c("table","codebook","nolabels"), |
| 22 |
include.missings=(style=="codebook"), |
| 23 |
missing.marker=if(style=="codebook") "M" else "*",\dots) |
| 24 |
} |
| 25 |
\arguments{ |
| 26 |
\item{x}{an atomic vector, factor or \code{"item.vector"} object} |
| 27 |
\item{counts}{logical value, should the table contain counts?} |
| 28 |
\item{percentage}{logical value, should the table contain percentages? |
| 29 |
Either the \code{counts} or the \code{percentage} arguments or both |
| 30 |
should be \code{TRUE}. } |
| 31 |
\item{style}{character string, the style of the names or rownames of the table.} |
| 32 |
\item{weights}{a numeric vector of weights of the same length as \code{x}.} |
| 33 |
\item{include.missings}{a logical value; should missing values included into the table?} |
| 34 |
\item{missing.marker}{a character string, used to mark missing values |
| 35 |
in the table (row)names.} |
| 36 |
\item{\dots}{other, currently ignored arguments.} |
| 37 |
} |
| 38 |
\value{ |
| 39 |
The atomic vector and factor methods return either a vector |
| 40 |
of counts or vector of percentages or a matrix of counts and percentages. |
| 41 |
The same applies to the \code{"item.vector"} vector method unless |
| 42 |
\code{include.missing=TRUE} and \code{percentage=TRUE}, |
| 43 |
in which case total percentages and percentages of valid values |
| 44 |
are given. |
| 45 |
} |
| 46 |
\examples{ |
| 47 |
with(as.data.frame(UCBAdmissions),Table(Admit,Freq)) |
| 48 |
Aggregate(Table(Admit,Freq)~.,data=UCBAdmissions) |
| 49 |
|
| 50 |
A <- sample(c(1:5,9),size=100,replace=TRUE) |
| 51 |
labels(A) <- c(a=1,b=2,c=3,d=4,e=5,dk=9) |
| 52 |
missing.values(A) <- 9 |
| 53 |
Table(A,percentage=TRUE) |
| 54 |
} |
| 55 |
\keyword{univar} |