| factor256 {factor256} | R Documentation |
Factors of fewer than 256 elements
Description
Whereas base R's factors are based on 32-bit integer vectors,
factor256 uses 8-bit raw vectors to minimize its memory footprint.
Usage
factor256(x, levels = NULL)
recompose256(f)
relevel256(x, levels)
## S3 method for class 'factor256'
levels(x)
is.factor256(x)
isntSorted256(x, strictly = FALSE)
as_factor(x)
factor256_in(x, tbl)
factor256_notin(x, tbl)
factor256_ein(x, tbl)
factor256_enotin(x, tbl)
tabulate256(f)
rank256(x)
order256(x)
unique256(x)
tabulate256_levels(x, nmax = NULL, dotInterval = 65535L)
Arguments
x |
An atomic vector with fewer than 256 unique elements. |
levels |
An optional character vector of or representing the unique values of |
f |
A raw vector of class |
strictly |
If |
tbl |
The table of values to lookup in |
nmax, dotInterval |
( |
Value
factor256 is a class based on raw vectors.
Values in x absent from levels are mapped to 00.
In the following list, o is the result.
factor256A raw vector of class
factor256.recompose256is the inverse operation.
factor256_e?(not)?inA logical vector the same length of
f,o[i] = TRUEiff[i]is among the values oftblwhen converted tofactor256._notinis the negation. Thefactor256_evariants will error if none of the values oftblare present inf.tabulate256Takes a raw vector and counts the number of times each element occurs within it. It is always length-256; if an element is absent it will have value zero in the output.
tabulate256_levelsSimilar to
tabulate256but with optional argumentsnmax,dotInterval.as_factorConverts from
factor256tofactor.order256Same as
orderbut supports raw vectors.order256(x)rank256Same as
rankwithties.method = "first"but supports raw vectors.unique256Unique elements of.
Examples
f10 <- factor256(1:10)
fletters <- factor256(rep(letters, 1:26))
head(factor256_in(fletters, "g"))
head(tabulate256(fletters))
head(recompose256(fletters))
gletters <- factor256(rep(letters, 1:26), levels = letters[1:25])
tail(tabulate256(gletters))
tabulate256_levels(gletters, nmax = 5L, dotInterval = 1L)