cksum: Compute Check Sum

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/bitops.R

Description

Return a cyclic redundancy checksum for each element in the argument.

Usage

1
cksum(a)

Arguments

a

coerced to character vector

Details

NA's appearing in the argument are returned as NA's.

The default calculation is identical to that given in pseudo-code in the ACM article (in the References).

Value

numeric vector of the same length as a.

Author(s)

Steve Dutky sdutky@terpalum.umd.edu

References

Fashioned from cksum(1) UNIX command line utility, i.e., man cksum.

Dilip V. Sarwate (1988) Computation of Cyclic Redundancy Checks Via Table Lookup, Communications of the ACM 31, 8, 1008–1013.

See Also

bitShiftL, bitAnd, etc.

Examples

1
2
3
4
   b <- "I would rather have a bottle in front of me than frontal lobotomy\n"
 stopifnot(cksum(b) == 1342168430)
 (bv <- strsplit(b, " ")[[1]])
 cksum(bv) # now a vector of length 13

bitops documentation built on April 24, 2021, 5:07 p.m.