找回密码
 注册
查看: 3676|回复: 0

R语言:save()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-2-16 20:15:57 | 显示全部楼层 |阅读模式
save(base)
save()所属R语言包:base

                                        Save R Objects
                                         保存R对象

                                         译者:生物统计家园网 机器人LoveR

描述----------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 data in some cases).
saveR对象的外部表现形式写入到指定的文件。在日后的文件对象可以读取从使用功能load(data在某些情况下)。

save.image() is just a short-cut for "save my current workspace", i.e., save(list = ls(all=TRUE), file = ".RData").  It is also what happens with q("yes").
save.image()仅仅是一个捷径,为“救我目前的工作区,即save(list = ls(all=TRUE), file = ".RData")。它也是用q("yes")发生什么。


用法----------Usage----------


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

save.image(file = ".RData", version = NULL, ascii = FALSE,
           compress = !ascii, safe = TRUE)



参数----------Arguments----------

参数:...
the names of the objects to be saved (as symbols or character strings).
要保存的对象的名称(如符号或字符串)。


参数:list
A character vector containing the names of objects to be saved.
一个特征向量,包含要保存的对象名称。


参数:file
a (writable binary-mode) connection or the name of the file where the data will be saved (when tilde expansion is done).  Must be a file name for version = 1.
(写入二进制模式)连接或其中的数据将被保存(波浪线扩建完成时)的文件名。必须是一个文件名version = 1。


参数:ascii
if TRUE, an ASCII representation of the data is written.  The default value of ascii is FALSE which leads to a binary file being written.
如果TRUE,写入数据的ASCII表示。默认值ascii是FALSE从而导致被写入到一个二进制文件。


参数:version
the workspace format version to use.  NULL specifies the current default format.  The version used from R 0.99.0 to R 1.3.1 was version 1.  The default format as from R 1.4.0 is version 2.
使用工作区的格式版本。 NULL指定当前默认的格式。从R 0.99.0使用的R 1.3.1版本是版本1。从R 1.4.0的默认格式是版本2。


参数:envir
environment to search for objects to be saved.
环境,以搜寻要保存的对象。


参数:compress
logical or character string specifying whether saving to a named file is to use compression.  TRUE corresponds to gzip compression, and (from R 2.10.0) character strings "gzip", "bzip2" or "xz" specify the type of compression.  Ignored when file is a connection and for workspace format version 1.  
逻辑或字符串指定保存到指定的文件是否是使用压缩。 TRUEgzip压缩,(从R 2.10.0)字符串"gzip","bzip2"或"xz"指定的压缩类型。忽略file是连接和工作区的格式版本1。


参数:compression_level
integer: the level of compression to be used.  Defaults to 6 for gzip compression and to 9 for bzip2 or xz compression.
整数:要使用的压缩级别。默认6gzip压缩9bzip2或xz压缩。


参数:eval.promises
logical: should objects which are promises be forced before saving?
逻辑:这是承诺的对象应该被保存前被迫?


参数:precheck
logical: should the existence of the objects be checked before starting to save (and in particular before opening the file/connection)?  Does not apply to version 1 saves.
逻辑:应开始之前保存(和特别是在打开文件/连接之前)检查对象存在吗?并不适用于第1版保存。


参数:safe
logical.  If TRUE, a temporary file is used for creating the saved workspace.  The temporary file is renamed to file if the save succeeds.  This preserves an existing workspace file if the save fails, but at the cost of using extra disk space during the save.
逻辑。如果TRUE,一个临时文件用于创建保存的工作区。临时文件更名为file如果保存成功。这将保留现有的工作区file如果保存失败,但在使用额外的磁盘空间的成本在保存过程中。


Details

详情----------Details----------

The names of the objects specified either as symbols (or character strings) in ... or as a character vector in list are used to look up the objects from environment envir.  By default promises are evaluated, but if eval.promises = FALSE promises are saved (together with their evaluation environments). (Promises embedded in objects are always saved unevaluated.)
对象的名称指定为符号(或字符串)在...或作为一个特征向量list是用来寻找对象,从环境envir。默认情况下,承诺评估,但如果eval.promises = FALSE承诺保存(连同他们的评价环境)。 (承诺嵌入对象中总是保存不计算。)

All R platforms use the XDR (bigendian) representation of C ints and doubles in binary save-d files, and these are portable across all R platforms.  (ASCII saves used to be useful for moving data between platforms but are now mainly of historical interest.  They can be more compact than binary saves where compression is not used, but are almost always slower to both read and write: binary saves compress much better than ASCII ones.)
所有R平台上使用的C整数的XDR的(Bigendian)表示,双打二进制保存-D文件中,而这些都是在所有R平台上移植。 (ASCII码保存用于移动平台之间的数据有用,但主要是对历史的兴趣,现在他们可以比二进制更紧凑,节省了在不使用压缩,但几乎总是慢的读写:二进制保存压缩好得多非ASCII的。)

Default values for the ascii, compress, safe and version arguments can be modified with the "save.defaults" option (used both by save and save.image), see also the "Examples" section.  If a "save.image.defaults" option is set it is used in preference to "save.defaults" for function save.image (which allows this to have different defaults).
默认值ascii,compress,safe和version参数可以修改"save.defaults"选项(都save和 save.image),亦见“的例子”一节。如果"save.image.defaults"选项设置优先使用"save.defaults"功能save.image(允许有不同的默认值)。

A connection that is not already open will be opened in mode "wb".
一个尚未打开的连接将被打开模式"wb"。


压缩----------Compression----------

Large files can be reduced considerably in size by compression.  A particular 46MB dataset was saved as 35MB without compression in 2 seconds, 22MB with gzip compression in 8 secs, 19MB with bzip2 compression in 13 secs and 9.4MB with xz compression in 40 secs.  The load times were 1.3, 2.8, 5.5 and 5.7 seconds respectively.  These results are indicative, but the relative performances do depend on the actual file and xz did unusually well here.
可以减少大文件大小大大压缩。 35MB不压缩在2秒的数据集保存为一个特定的46MB,22MB用gzipbzip2xz压缩在40秒13秒和9.4MB压缩压缩在8秒,19MB的。加载时间分别为1.3,2.8,5.5和5.7秒。这些结果是指示性的,但相对表现不依赖于实际的文件和xz没有异常以及这里。

It is possible to compress later (with gzip, bzip2 or xz) a file saved with compress = FALSE: the effect is the same as saving with compression.  Also, a saved file can be uncompressed and re-compressed under a different compression scheme (and see resaveRdaFiles for a way to do so from within R).
它有可能压缩后(gzip,bzip2或xz)用保存文件compress = FALSE:效果是相同的压缩节省。此外,保存的文件可以压缩和重新压缩不同的压缩方案下(见resaveRdaFiles办法做到在R)。


警告----------Warnings----------

The ... arguments only give the names of the objects to be saved: they are searched for in the environment given by the envir argument, and the actual objects given as arguments need not be those found.
...参数只给要保存的对象的名称:搜索envir参数的环境,并给予实际对象作为参数需要不会是那些发现。

Saved R objects are binary files, even those saved with ascii = TRUE, so ensure that they are transferred without conversion of end of line markers and of 8-bit characters.  The lines are delimited by LF on all platforms.
保存的R对象是二进制文件,甚至那些保存ascii = TRUE,以便确保它们没有行标记结束的8位字符的转换和转移。线LF所有平台上的分隔。

Although the default version has not changed since R 1.4.0, this does not mean that saved files are necessarily backwards compatible. You will be able to load a saved image into an earlier version of R unless use is made of later additions (for example, raw vectors or external pointers).
虽然由于R 1.4.0改变默认的版本还没有,这并不意味着,保存的文件必然是向后兼容的。除非使用后增加(例如,原始向量或外部指针),您将能够保存的图像加载到研发的早期版本。


注意----------Note----------

The most common reason for failure is lack of write permission in the current directory.  For save.image and for saving at the end of a session this will shown by messages like
失败的最常见的原因是在当前目录的写权限不足。 save.image,并在会议结束节约这将显示这样的信息


参见----------See Also----------

dput, dump, load, data.
dput,dump,load,data。

For other interfaces to the underlying serialization format, see serialize and saveRDS.
对于其他接口底层的序列化格式,请参阅serialize和saveRDS。


举例----------Examples----------


x <- stats::runif(20)
y <- list(a = 1, b = TRUE, c = "oops")
save(x, y, file = "xy.RData")
save.image()
unlink("xy.RData")
unlink(".RData")

# set save defaults using option:[设置保存默认使用选项:]
options(save.defaults=list(ascii=TRUE, safe=FALSE))
save.image()
unlink(".RData")

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-5-6 16:50 , Processed in 0.030441 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表