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("StatDataML-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('StatDataML') Loading required package: XML > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "readSDML" > > ### * readSDML > > flush(stderr()); flush(stdout()) > > ### Name: readSDML > ### Title: Read StatDataML Files > ### Aliases: readSDML > ### Keywords: file > > ### ** Examples > > library(XML) > > # write/read vector with names > a <- 1:15 > names(a) <- paste("n", 1:15, sep="") > writeSDML(a, "testvec.xml") > b <- readSDML("testvec.xml") > cat(" a is equal b :", all.equal(a,b), "\n") a is equal b : TRUE > > # write/read a matrix > A <- matrix(1:16, ncol=4) > rownames(A) <- paste("row", 1:4, sep="") > colnames(A) <- paste("col", 1:4, sep="") > writeSDML(A, "testmat.sdml") > B <- readSDML("testmat.sdml") > cat(" A is equal B :", all.equal(A,B), "\n") A is equal B : TRUE > > # write/read a data.frame > data(iris) > writeSDML(iris, "iris.sdml") > irisSDML <- readSDML("iris.sdml") > cat(" iris is equal irisSDML: ", all.equal(iris,irisSDML), "\n") iris is equal irisSDML: TRUE > > # write/read a ts object > data(airmiles) > writeSDML(airmiles, "air.sdml") > airSDML <- readSDML("air.sdml") > cat(" airmiles is equal airSDML: ", all.equal(airmiles,airSDML), "\n") airmiles is equal airSDML: TRUE > > # write/read the islands data > data(islands) > writeSDML(islands, "islands.sdml") > islandsSDML <- readSDML("islands.sdml") > cat(" islands is equal islandsSDML: ", all.equal(islands,islandsSDML), "\n") islands is equal islandsSDML: TRUE > > > > > cleanEx(); ..nameEx <- "writeSDML" > > ### * writeSDML > > flush(stderr()); flush(stdout()) > > ### Name: writeSDML > ### Title: Write Data in StatDataML Format > ### Aliases: writeSDML > ### Keywords: file > > ### ** Examples > > A <- matrix(1:16, ncol=4) > rownames(A) <- paste("row", 1:4, sep="") > colnames(A) <- paste("col", 1:4, sep="") > writeSDML(A, "testmat.sdml") > > I <- letters[1:16] > attr(A, "info") <- I > writeSDML(A, "testmat2.sdml", textdata = FALSE) > > > > ### *