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

R语言 uncompress包 uncompress()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-10-1 13:19:37 | 显示全部楼层 |阅读模式
uncompress(uncompress)
uncompress()所属R语言包:uncompress

                                        Uncompress .Z file data
                                         Z文件解压缩。数据

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

描述----------Description----------

Uncompresses data compressed with the "compress" utility. Data pass in and returned are both raw binary strings. Invalid compressed data results in an error being returned.
解压缩数据压缩的“压缩”程序。数据传递和返回都是原始的二进制字符串。无效的压缩数据会导致错误被退回。


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


uncompress(data)



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

参数:data
The raw binary data to decompress.</table>
原始二进制数据进行解压缩。</ TABLE>


实例----------Examples----------


library("uncompress")
## Not run: [#不运行:]

## Example 1 - extracting text data from a .Z file.[#示例1  - 从Z文件中提取文本数据。]
handle <- file("file.Z", "rb")
# The size here is arbitrary, it should be large enough for most files,[这里的大小是任意的,它应该足够大,对于大多数文件,]
#  adjust as necessary.[调整是必要的。]
data <- readBin(handle, "raw", 99999999)
close(handle)
uncomp_data <- uncompress(data)
# At this point you might want to check if uncomp_data is NULL in case the[在这一点上,你可能要检查的情况下,如果uncomp_data是NULL]
#  file is corrupt.[文件已损坏。]
# This is assuming it's Unix-style text (i.e. \n separates lines).[这是假设它的Unix风格的文本(即\ n分隔行)。]
# If it's Windows-style text you may need to use "\r\n".[如果是Windows风格的文字,你可能需要使用“\ r \ n”。]
lines <- strsplit(rawToChar(uncomp_data), "\n")
print(lines)

## Example 2 - extracting text data from a .Z file at an HTTP host.[#2  - 在一个HTTP主机从Z文件中提取文本数据。]
handle <- url("http://host/path/file.Z", "rb")
# The size here is arbitrary, it should be large enough for most files,[这里的大小是任意的,它应该足够大,对于大多数文件,]
#  adjust as necessary.[调整是必要的。]
data <- readBin(handle, "raw", 99999999)
close(handle)
uncomp_data <- uncompress(data)
# At this point you might want to check if uncomp_data is NULL in case the[在这一点上,你可能要检查的情况下,如果uncomp_data是NULL]
#  file is corrupt.[文件已损坏。]
# This is assuming it's Unix-style text (i.e. \n separates lines).[这是假设它的Unix风格的文本(即\ n分隔行)。]
# If it's Windows-style text you may need to use "\r\n".[如果是Windows风格的文字,你可能需要使用“\ r \ n”。]
lines <- strsplit(rawToChar(uncomp_data), "\n")
print(lines)

## Example 3 - downloading a .Z file, then uncompressing it.[#3  - 。Z文件下载,然后解压缩。]
# Mode is important, in Windows if you don't use binary mode the compressed[模式是很重要的,在Windows中,如果你没有使用二进制模式下压缩]
#  data will be corrupted.[数据将被破坏。]
download.file("http://host/path/file.Z", "file.Z", mode="wb")
handle <- file("file.Z", "rb")
# The size here is arbitrary, it should be large enough for most files,[这里的大小是任意的,它应该足够大,对于大多数文件,]
#  adjust as necessary.[调整是必要的。]
data <- readBin(handle, "raw", 99999999)
close(handle)
uncomp_data <- uncompress(data)
# At this point you might want to check if uncomp_data is NULL in case the[在这一点上,你可能要检查的情况下,如果uncomp_data是NULL]
#  file is corrupt.[文件已损坏。]
# This is assuming it's Unix-style text (i.e. \n separates lines).[这是假设它的Unix风格的文本(即\ n分隔行)。]
# If it's Windows-style text you may need to use "\r\n".[如果是Windows风格的文字,你可能需要使用“\ r \ n”。]
lines <- strsplit(rawToChar(uncomp_data), "\n")
print(lines)

## Example 4 - downloading a .Z file, writing the uncompressed data to a[例4  - 下载。Z文件,未压缩数据写入到]
##  local file.[#本地文件。]
handle <- url("http://host/path/file.Z", "rb")
# The size here is arbitrary, it should be large enough for most files,[这里的大小是任意的,它应该足够大,对于大多数文件,]
#  adjust as necessary.[调整是必要的。]
data <- readBin(handle, "raw", 99999999)
close(handle)
uncomp_data <- uncompress(data)
handle <- file("file", "wb")
writeBin(uncomp_data, handle)
close(handle)


## End(Not run)[#(不执行)]

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-28 13:31 , Processed in 0.021974 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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