The R Project SVN R

Rev

Rev 22997 | Rev 48967 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 22997 Rev 28012
Line 1... Line 1...
1
\name{tabulate}
1
\name{tabulate}
2
\title{Tabulation for Vectors}
2
\title{Tabulation for Vectors}
-
 
3
\description{
-
 
4
  \code{tabulate} takes the integer-valued vector \code{bin} and counts
-
 
5
  the number of times each integer occurs in it. 
-
 
6
}
3
\usage{
7
\usage{
4
tabulate(bin, nbins = max(1, bin))
8
tabulate(bin, nbins = max(1, bin))
5
}
9
}
6
\alias{tabulate}
10
\alias{tabulate}
7
\arguments{
11
\arguments{
8
    \item{bin}{a vector of integers, or a factor.}
12
    \item{bin}{a numeric vector (of positive integers), or a factor.}
9
    \item{nbins}{the number of bins to be used.}
13
    \item{nbins}{the number of bins to be used.}
10
}
14
}
11
\description{
-
 
12
\code{tabulate} takes the integer valued vector \code{bin} and counts
-
 
13
the number of times each integer occurs in it.  \code{tabulate} is
-
 
14
used as the basis of the \code{table} function.
-
 
15
}
-
 
16
\details{
15
\details{
-
 
16
   \code{tabulate} is used as the basis of the \code{\link{table}} function.
-
 
17
  
17
  If \code{bin} is a factor, its internal integer representation
18
  If \code{bin} is a factor, its internal integer representation
18
  is tabulated.
19
  is tabulated.
-
 
20
  
19
  If the elements of \code{bin} are not integers, they are rounded
21
  If the elements of \code{bin} are numeric but not integers,
20
  to the nearest integer.  Elements outside the range \code{1,\dots,
22
  they are truncated to the nearest integer.
-
 
23
}
-
 
24
\value{
21
    nbin} are (silently) ignored in the tabulation.
25
  An integer vector (without names).  There is a bin for each of the
-
 
26
  values \code{1, \dots, nbins}; values outside that range are (silently)
-
 
27
  ignored.
22
}
28
}
23
\seealso{
29
\seealso{
24
\code{\link{factor}}, \code{\link{table}}.
30
  \code{\link{table}}, \code{\link{factor}}.
25
}
31
}
26
\examples{
32
\examples{
27
tabulate(c(2,3,5))
33
tabulate(c(2,3,5))
28
tabulate(c(2,3,3,5), nb = 10)
34
tabulate(c(2,3,3,5), nbins = 10)
-
 
35
tabulate(c(-2,0,2,3,3,5))  # -2 and 0 are ignored
29
tabulate(c(-2,0,2,3,3,5), nb = 3)
36
tabulate(c(-2,0,2,3,3,5), nbins = 3)
30
tabulate(factor(letters[1:10]))
37
tabulate(factor(letters[1:10]))
31
}
38
}
32
\keyword{arith}
39
\keyword{arith}