第五天,复杂了复杂了。。。
Day 5. 数据结构.png关于数据结构,要学要练的还有很多,比如这个save函数,为什么报错呢?因为变量X没有在test.RData中先赋值?
save(X,file="test.RData")
Error in save(X, file = "test.RData") : object ‘X’ not found
正确的用法是:
x <- stats::runif(20)
y <- list(a = 1, b = TRUE, c = "oops")
save(x, y, file = "xy.RData") # creating "xy.RData" in current working directory, 保存其中部分变量
save.image() # creating ".RData" in current working directory, 保存当前所有变量
Save R Objects
Description
save
writes an external representation of R objects to the specified file. The objects can be read back from the file at a later date by using the function load or attach (or data in some cases).
save.image()
is just a short-cut for ‘save my current workspace’, i.e.,save(list = ls(all.names = TRUE), file = ".RData", envir = .GlobalEnv)
. It is also what happens with q ("yes")`.
网友评论