ucounts: How many times does each term in x appear?

Description Usage Arguments Value Author(s) Examples

Description

table does a similar job, but does not provide the option of return.unique=FALSE

Usage

1
ucounts(x, return.unique = TRUE, issorted = FALSE, sort = TRUE)

Arguments

x

a character vector

return.unique

logical: if TRUE, the numeric counts of the unique elements in x are returned (the names indicate the elements in x). The order of the returned elements is the same order that unique(x) returns. If FALSE, then return the numeric counts of each element in x. Useful if you then want to work out which elements have count > 1 and quickly view those elements. The order remains the same as x.

issorted

logical: to improve the speed of this code, the algorithm first sorts the data. If it's already sorted, then save time by setting issorted=FALSE.

sort

logical: whether to sort the result vector from highest counts to lowest?

Value

a vector of counts, named by the elements of x

Author(s)

Mark Cowley, 11 May 2006

Examples

1
2
3
4
5
6
7
8
9
ucounts(c("a", "a", "b", "c", "c"), TRUE)
# a b c
# 2 1 2
ucounts(c("a", "a", "b", "c", "c"), FALSE)
# a a b c c
# 2 2 1 2 2
ucounts(c("a", "a", "b", "c", "c"), FALSE) > 1
#	a	  a		b	  c		c
# TRUE  TRUE FALSE  TRUE	 TRUE

drmjc/mjcbase documentation built on May 15, 2019, 2:27 p.m.