cksum.RdReturn a cyclic redundancy checksum for each element in the argument.
cksum(a)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).
numeric vector of the same length as a.
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.
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