.RData
、.Rda
和.Rds
文件之间的主要区别是什么?
发布于 2014-01-27 06:53:18
Rda只是RData的缩写。您可以只保存()、加载()、附加()等,就像使用RData一样。
Rds存储单个R对象。然而,除了这个简单的解释之外,还有一些与“标准”存储的区别。也许这个R-manual Link to readRDS() function已经充分地阐明了这些区别。
所以,回答你的问题:
保存的区别不在于压缩,而在于序列化(参见手册页中所示的this page)
()。
发布于 2014-01-27 07:21:21
除了@KenM的答案之外,另一个重要的区别是,在加载保存的对象时,您可以分配Rds
文件的内容。Rda
并非如此
> x <- 1:5
> save(x, file="x.Rda")
> saveRDS(x, file="x.Rds")
> rm(x)
## ASSIGN USING readRDS
> new_x1 <- readRDS("x.Rds")
> new_x1
[1] 1 2 3 4 5
## 'ASSIGN' USING load -- note the result
> new_x2 <- load("x.Rda")
loading in to <environment: R_GlobalEnv>
> new_x2
[1] "x"
# NOTE: `load()` simply returns the name of the objects loaded. Not the values.
> x
[1] 1 2 3 4 5
https://stackoverflow.com/questions/21370132
复制相似问题