UserFunction-class(Streamer)
UserFunction-class()所属R语言包:Streamer
Class "UserFunction"
类“UserFunction”
译者:生物统计家园网 机器人LoveR
描述----------Description----------
The UserFunction class is provided as a convenience class enabling users to quickly create Consumer-classes that can be added to a stream without having to go into more complex details about the implementation of the classes hierarchy provided by the Streamer-package.
类UserFunction提供一个方便的类,使用户能够快速创建Consumer可以添加到一个流,而无需进入所提供的类层次实施更复杂的细节类Streamer包。
The users pass in a function fun to the constructor of the UserFunction-class to manipulate the records returned by the class intended to be connected upstream. The constructor returns an instance of the UserFunction-class with a with a yield method that the user can directly invoke.
用户通过在功能funUserFunction级操纵拟上游连接的类返回的记录,构造的。该构造函数返回一个UserFunction方法,用户可以直接调用yield类的一个实例。
用法----------Usage----------
UserFunction(fun, ..., yieldSize=1e6, verbose=FALSE)
参数----------Arguments----------
参数:fun
User defined function that operates on records yielded by the class connected upstream.
用户自定义功能,经营上取得了上游连接的类的记录。
参数:...
Additional arguments, passed to the $new method of this class. Currently ignored.
额外的参数传递$new这个类的方法。目前被忽略。
参数:yieldSize
A integer(1) indicating the number of records to yield.
一个integer(1)指示产生的记录数量。
参数:verbose
logical(1) indicating whether class methods should report to the user.
logical(1)类的方法是否应该报告给用户。
构造----------Constructors----------
Use UserFunction to construct instances of this class.
使用UserFunction建设这个类的实例。
领域----------Fields----------
.fun: A user suppliedfunction that operates on records
.fun:用户提供的function操作记录
方法----------Methods----------
initialize(...): Initializes the fields of the
initialize(...):初始化的字段
yield(): Applies the function fun to the records retrieved from the class connected upstream to the UserFunction
yield():适用于功能fun从上游连接的类检索的记录UserFunction
作者(S)----------Author(s)----------
Nishant Gopalakrishnan <a href="ngopalak@fhcrc.org">ngopalak@fhcrc.org</a>
参见----------See Also----------
stream
stream
举例----------Examples----------
f <- system.file("extdata", "s_1_sequence.txt", package="Streamer")
b <- RawInput(f, 100L, reader=rawReaderFactory(1e4))
### Create a user defined function to convert raw bytes to character[#创建一个用户定义的函数将原始字节转换为字符]
myFun <- function(x) {
sapply(x, rawToChar)
}
#### Pass the function to the UserFunction constructor[###传递函数的UserFunction构造,]
d <- UserFunction(fun=myFun)
#### Create a stream[###创建一个流]
s <- stream(b, d)
yield(s)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|