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

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.

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.

Author

Steve Dutky sdutky@terpalum.umd.edu

See also

Examples

   b <- "I would rather have a bottle in front of me than frontal lobotomy\n"
 stopifnot(cksum(b) == 1342168430)
 (bv <- strsplit(b, " ")[[1]])
#>  [1] "I"          "would"      "rather"     "have"       "a"         
#>  [6] "bottle"     "in"         "front"      "of"         "me"        
#> [11] "than"       "frontal"    "lobotomy\n"
 cksum(bv) # now a vector of length 13
#>  [1] 3794341002  351271217 2629646443 3986024602 1220704766 2750897933
#>  [7] 3122994064 3007351831  884913104 1172616461 3405771722 2111744547
#> [13] 1881082391