# simple example
v=1:100/10 +.0111
vr=signif(v,digits=2)
# print.unf shows in standard format, including version and digits
print(unf(v))
# as.character will return base64 section only for comparisons
as.character(unf(v))
# this is false, since computed base64 values UNF's differ
unf2base64(unf(v))==unf2base64(unf(vr))
# this is true, since computed UNF's base64 values are the same at 2 significant digits
unf2base64(unf(v, digits=2))==unf2base64(unf(vr))
# WARNING: this is false, since UNF's values are the same, but
# number of calculated digits differ , probably not the comparison
# you intend
identical(unf(v,digits=2),unf(vr))
# compute a fingerprint of longley at 10 significant digits of accuracy for numeric values
# this fingerprint can be stored and verified when reading the dataset
# later
data(longley)
mf10<-unf(longley,ndigits=10);
# this produces the same results as using signifz(), but not signif()
mf11<-unf(signifz(longley,digits=10))
unf2base64(mf11)==unf2base64(mf10)
#printable representation, prints seven UNF's, one for each vector
print(mf10)
# summarizes the base64 portion of the unf for each vector into a
# single base64 UNF representing entire dataset
summary(mf10)
#self test
unfTest=get("unfTest",envir=environment(unf))
if (!unfTest(silent=FALSE)) {
stop("failed self tests")
}
Run the code above in your browser using DataLab