R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. Warning: UNFllong's may lose precision when converted to UNFldoubles UNFldouble mantissa 53 sizeof UNFllong unsigned int 8 > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("UNF-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('UNF') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "unf" > > ### * unf > > flush(stderr()); flush(stdout()) > > ### Name: unf > ### Title: universal numeric fingerprint > ### Aliases: unf as.unf as.character.unf unf2base64 > ### Keywords: misc debugging > > ### ** Examples > > > # 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)) [1] "UNF:3:10:rOk2V32CW294EW6fP6ik1Q==" > > # as.character will return base64 section only for comparisons > as.character(unf(v)) [1] "UNF:3:10:rOk2V32CW294EW6fP6ik1Q==" > > # this is false, since computed base64 values UNF's differ > as.character(unf(v))==as.character(unf(vr)) [1] FALSE > > # this is true, since computed UNF's base64 values are the same at 2 significant digits > as.character(unf(v, digits=2))==as.character(unf(vr)) [1] FALSE > > # 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)) [1] FALSE > > # compute a fingerprint of longley at 10 significant digits of accuracy > # this fingerprint can be stored and verified when reading the dataset > # later > data(longley) > mf10<-unf(longley,digits=10); > > #printable representation, prints seven UNF's, one for each vector > print(mf10) [1] "UNF:3:10:30ObC1h8QA1WhSE0FWmYhA==" "UNF:3:10:FyY+kxfdF13JoTH0ascNjQ==" [3] "UNF:3:10:lRU/Y4WYUNjNy5MZ4F09aA==" "UNF:3:10:ULOA0HC94ULNFvbrGkG0cA==" [5] "UNF:3:10:jINPpf9fC5HmM1c6m5E2Eg==" "UNF:3:10:gm1lOzG/ziBKGGvy6TCVRg==" [7] "UNF:3:10:TnSDq3rRD8MHSCQZNUHB9w==" > > # summarizes the base64 portion of the unf for each vector into a > # single base64 UNF representing entire dataset > summary(mf10) [1] "UNF:3:32:9WjBbKMpKv3dibqeLoCTkg==" > > > > > ### *