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. > ### *
> ### > 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("g.data-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('g.data') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "g.data.save" > > ### * g.data.save > > flush(stderr()); flush(stdout()) > > ### Name: g.data.save > ### Title: Create and Maintain Delayed-Data Packages > ### Aliases: g.data.attach g.data.get g.data.put g.data.load g.data.save > ### Keywords: data > > ### ** Examples > > ## Not run: > ##D ddp <- tempfile("newdir") # Where to put the files > ##D g.data.attach(ddp) # Warns that this is a new directory > ##D assign("x1", matrix(1, 1000, 1000), 2) > ##D assign("x2", matrix(2, 1000, 1000), 2) > ##D g.data.save() # Writes the files > ##D detach(2) > ##D > ##D g.data.attach(ddp) # No warning, because directory exists > ##D ls(2) > ##D system.time(print(dim(x1))) # Takes time to load up > ##D system.time(print(dim(x1))) # Second time is faster! > ##D find("x1") # x1 still lives in pos=2, is now real > ##D assign("x3", x2*10, 2) > ##D g.data.save() # Or just g.data.save(obj="x3") > ##D detach(2) > ##D > ##D myx2 <- g.data.get("x2", ddp) # Get one objects without attaching > ##D unlink(ddp, recursive=TRUE) # Clean up this example > ## End(Not run) > > ## Not run: > ##D ddp <- tempfile("newdir") # New example > ##D y <- list(x1=1:1000, x2=2:1001) > ##D attach(y) # Attach an existing list or dataframe > ##D g.data.save(ddp) > ##D detach(2) > ##D unlink(ddp, recursive=TRUE) # Clean up this example > ## End(Not run) > > > > ### *