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

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

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

                                        Uncompress data and return it as a string vector
                                         解压缩数据并返回它作为一个字符串向量

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

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

This function is a wrapper for uncompress() and rawToLines(). First it uncompresses the raw binary vector passed as the first argument, then it splits it according to line breaks (LF [Unix] or CR/LF [Windows] style), and returns a string vector with one line per entry. If there is a blank line at the end of the file, it is included. Optionally, you can skip a number of lines from the start of the file by passing an integer as the second argument. You can also, optionally, limit the number of lines that will be returned by passing an integer as the third argument.
这个函数是一个与uncompress()和rawToLines()的包装。首先,它解压缩的原始二进制向量作为第一个参数传递,然后将它根据换行符(LF [转载]或CR / LF [视窗]风格),并返回一个字符串,向量,每个条目一行。如果有一个空行的文件的结尾处,它被包含。或者,您可以跳过的行数从一开始的文件作为第二个参数传递一个整数。 (可选),也可以作为第三个参数传递一个整数,将返回的行数限制。


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


uncompressToLines(data, start_line = 0, max_line_count = 999999999)



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

参数:data
The raw compressed binary data.
原始的二进制数据。


参数:start_line
The index of the first line to return. Defaults to 0. In effect, processing of the data begins after skipping this many lines from the start. If it is greater than the number of lines in the file, an error will be returned.
返回的第一行的索引。默认为0。实际上,处理的数据后开始行从一开始就跳过这许多。如果它是大于在该文件中的行的数目,一个错误将被返回。


参数:max_line_count
If more than this many lines would be returned, the rest are ignored. Otherwise it has no effect. The default is 999999999.</table>
如果超过此线将被返回,其余的被忽略。否则,它没有任何效果。默认值是999999999。</ TABLE>


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


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

## Example 1 - uncompress a file, then split it into strings by line.[例1  - 解压缩文件,然后把它分解成字符串行。]
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)
text_lines <- uncompressToLines(data)
print(text_lines)

## Example 2 - the same, except does the conversion 1000 lines at a time.[#例2  - 一样的,除了1000行一次转换。]
##             Note that this will uncompress all the data for each call![#请注意,这将解压每次调用的所有数据!]
##             Example 3 is a much better way to do it.[例3#是一个更好的方法来做到这一点。]
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)
start <- 0
while( 1 ) {
        text_lines <- uncompressToLines(data, start, 1000)
        if( length(text_lines) == 0 )
                break;
        print(text_lines);
        if( length(text_lines) < 1000 )
                break;
        start <- start + 1000
}

## Example 3 - Smarter version of Example 2[例3  - 智慧版本的例2]
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)
data <- uncompress(data);
start <- 0
while( 1 ) {
        text_lines <- rawToLines(data, start, 1000)
        if( length(text_lines) == 0 )
                break;
        print(text_lines);
        if( length(text_lines) < 1000 )
                break;
        start <- start + 1000
}


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

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


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

使用道具 举报

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

本版积分规则

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

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

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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