Thursday, 2 July 2015

R : save : save R objects

“save” function writes external representation of objects to a file.  You can read the objects back using “load”, “attach”, “data” functions.

Syntax
save(..., list = character(),
     file = stop("'file' must be specified"),
     ascii = FALSE, version = NULL, envir = parent.frame(),
     compress = isTRUE(!ascii), compression_level,
     eval.promises = TRUE, precheck = TRUE)

If you install “R”, open R console and type ?"save"  to get help for the function save.

> x <- 1:50
> y <- list(a = 1, b = TRUE, c = "oops")
> save(x, y, file = "xy.RData")
> 
> x<-10
> y<-20
> 
> x
[1] 10
> y
[1] 20
> 
> data <- load("xy.RData")
> data
[1] "x" "y"
> 
> x
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
> y
$a
[1] 1

$b
[1] TRUE

$c
[1] "oops"




Prevoius                                                 Next                                                 Home

No comments:

Post a Comment