The R Project SVN R

Rev

Rev 74519 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 74519 Rev 74546
Line 84... Line 84...
84
 
84
 
85
  For other interfaces to the underlying serialization format, see
85
  For other interfaces to the underlying serialization format, see
86
  \code{\link{unserialize}} and \code{\link{readRDS}}.
86
  \code{\link{unserialize}} and \code{\link{readRDS}}.
87
}
87
}
88
\examples{
88
\examples{
89
## save all data
-
 
90
\dontshow{oldwd <- setwd(tempdir())}
89
\dontshow{oldwd <- setwd(tempdir())}
-
 
90
 
-
 
91
## save all data
91
xx <- pi # to ensure there is some data
92
xx <- pi # to ensure there is some data
92
save(list = ls(all = TRUE), file= "all.rda")
93
save(list = ls(all = TRUE), file= "all.rda")
93
rm(xx)
94
rm(xx)
94
 
95
 
95
## restore the saved values to the current environment
96
## restore the saved values to the current environment
Line 107... Line 108...
107
rm(xx)
108
rm(xx)
108
attach("all.rda") # safer and will warn about masked objects w/ same name in .GlobalEnv
109
attach("all.rda") # safer and will warn about masked objects w/ same name in .GlobalEnv
109
ls(pos = 2)
110
ls(pos = 2)
110
##  also typically need to cleanup the search path:
111
##  also typically need to cleanup the search path:
111
detach("file:all.rda")
112
detach("file:all.rda")
-
 
113
 
-
 
114
## clean up (the example):
112
unlink("all.rda")
115
unlink("all.rda")
113
\dontshow{setwd(oldwd)}
116
\dontshow{setwd(oldwd)}
-
 
117
 
114
\dontrun{
118
\dontrun{
115
con <- url("http://some.where.net/R/data/example.rda")
119
con <- url("http://some.where.net/R/data/example.rda")
116
## print the value to see what objects were created.
120
## print the value to see what objects were created.
117
print(load(con))
121
print(load(con))
118
close(con) # url() always opens the connection
122
close(con) # url() always opens the connection