if (FALSE) {
ddp <- tempfile("newdir") # Where to put the files
g.data.attach(ddp) # Warns that this is a new directory
assign("m1", matrix(1, 5000, 1000), 2)
assign("m2", matrix(2, 5000, 1000), 2)
g.data.save() # Writes the files
detach(2)
g.data.attach(ddp) # No warning, because directory exists
ls(2)
system.time(print(dim(m1))) # Takes time to load up
system.time(print(dim(m1))) # Second time is faster!
find("m1") # m1 still lives in pos=2, is now real
assign("m3", m1*10, 2)
g.data.save() # Or just g.data.save(obj="m3")
detach(2)
mym2 <- g.data.get("m2", ddp) # Get one objects without attaching
unlink(ddp, recursive=TRUE) # Clean up this example
}
if (FALSE) {
ddp <- tempfile("newdir") # New example
y <- list(m1=1:1000, m2=2:1001)
attach(y) # Attach an existing list or dataframe
g.data.save(ddp)
detach(2)
unlink(ddp, recursive=TRUE) # Clean up this example
}
Run the code above in your browser using DataLab