cache(Biobase)
cache()所属R语言包:Biobase
Evaluate an expression if its value is not already cached.
评价一个表达式,如果它的价值是不是已经缓存。
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Cache the evaluation of an expression in the file system.
缓存在文件系统中的表达评价。
用法----------Usage----------
cache(expr, dir=".", prefix="tmp_R_cache_", name)
参数----------Arguments----------
参数:expr
An expression of the form LHS <- RHS, Where LHS is a variable name, RHS is any valid expression, and <- must be used (= will not work).
LHS <- RHS表达的形式,LHS是一个变量名,RHS是任何有效的表达式,<-(=将无法正常工作,必须使用)。
参数:dir
A string specifying the directory into which cache files should be written (also where to go searching for an appropriate cache file).
一个字符串,指定应写入到其中的缓存文件的目录(也去哪里寻找一个合适的缓存文件)。
参数:prefix
A string giving the prefix to use when naming and searching for cache files. The default is "tmp_R_cache_"
字符串,命名和搜索缓存文件时使用的前缀。默认是"tmp_R_cache_"
参数:name
Unused. This argument is present as a compatibility layer for the deprecated calling convention.
未使用。这种说法是作为一个过时的调用约定兼容层。
Details
详情----------Details----------
This function can be useful during the development of computationally intensive workflows, for example in vignettes or scripts. The function uses a cache file in dir which defaults to the current working directory whose name is obtained by paste(prefix, name, ".RData", sep="").
此功能可以在计算密集型工作流程的发展是有益的,例如在护身符或脚本。该函数使用一个缓存文件在dir默认为当前工作目录,其名称由paste(prefix, name, ".RData", sep="")获得。
When cache is called and the cache file exists, it is loaded and the object whose name is given on the left of <- in expr is returned. In this case, expr is not evaluted.
当cache被称为缓存文件存在,它加载的对象,其名称<-expr返回左侧。在这种情况下,expr不evaluted。
When cache is called and the cache file does not exist, expr is evaluted, its value is saved into a cache file, and then its value is returned.
当cache被称为缓存文件不存在,exprevaluted,其价值将被保存到缓存文件,然后返回它的值。
The expr argument must be of the form of someVar <- {expressions}. That is, the left hand side must be a single symbol name and the next syntactic token must be <-.
expr参数必须是的someVar <- {expressions}的形式。也就是说,左边必须是一个符号名称,并在未来的句法令牌必须是<-。
To flush the cache and force recomputation, simply remove the cache files. You can use file.remove to do this.
刷新缓存和力量的重新计算,只需删除缓存文件。你可以使用file.remove做到这一点。
值----------Value----------
The (cached) value of expr.
expr(缓存)值。
注意----------Note----------
The first version of this function had a slightly different interface which is now deprecated (but still functional). The old version has arguments name and expr and the intended usage is: foo <- cache("foo", expr).
这个函数的第一个版本,有一个稍微不同的接口,现在已经过时(但仍然功能)。旧版本的参数name和expr和使用目的是:foo <- cache("foo", expr)。
作者(S)----------Author(s)----------
Wolfgang Huber, <a href="mailto:huber@ebi.ac.uk">huber@ebi.ac.uk</a>
Seth Falcon, <a href="mailto:sfalcon@fhcrc.org">sfalcon@fhcrc.org</a>
举例----------Examples----------
bigCalc <- function() runif(10)
cache(myComplicatedObject <- bigCalc())
aCopy <- myComplicatedObject
remove(myComplicatedObject)
cache(myComplicatedObject <- bigCalc())
stopifnot(all.equal(myComplicatedObject, aCopy))
allCacheFiles <-
list.files(".", pattern="^tmp_R_cache_.*\\.RData$", full.name=TRUE)
file.remove(allCacheFiles)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|