trackObjs-package(trackObjs)
trackObjs-package()所属R语言包:trackObjs
Overview of trackObjs package
trackObjs包概述
译者:生物统计家园网 机器人LoveR
描述----------Description----------
The trackObjs package sets up a link between R objects in memory and files on disk so that objects are automatically resaved to files when they are changed. R objects in files are read in on demand and do not consume memory prior to being referenced. The trackObjs package also tracks times when objects are created and modified, and caches some basic characteristics of objects to allow for fast summaries of objects.
trackObjs包R对象在内存和文件在磁盘上,这样的对象会自动重新保存到文件时,改变之间的联系。 R对象文件中读入的需求,不消耗内存之前被引用。 trackObjs包跟踪当对象被创建和修改的时间,并缓存对象的一些基本特征,以便快速汇总的对象。
Each object is stored in a separate RData file using the standard format as used by save(), so that objects can be manually picked out of or added to the trackObjs database if needed.
每个对象被存储在一个单独的RDATA使用如所使用的标准格式的文件对象save(),以便可以手动拾取满分或添加的trackObjs数据库中,如果需要的话。
Tracking works by replacing a tracked variable by an 'activeBinding', which when accessed looks up information in an associated 'tracking environment' and reads or writes the corresponding RData file and/or gets or assigns the variable in the tracking environment.
访问时,跟踪跟踪的变量替换由“activeBinding”的作品,查找信息相关联的跟踪环境和读取或写入相应的的RDATA文件和/或获取或分配的跟踪环境中的变量。
Details
详细信息----------Details----------
There are three main reasons to use the trackObjs package:
使用trackObjs包有三个主要的原因:
conveniently handle many moderately-large objects that would collectively exhaust memory or be inconvenient to manage in files by manually using save() and load()
在,集体耗尽内存或不便管理的文件中手动使用save()和load()方便地处理许多中等大小的物体
keep track of creation and modification times on objects
跟踪对象的创建和修改时间
get fast summaries of basic characteristics of objects - class, size, dimension, etc. </ul>
得到基本特征的快速汇总的对象 - 类,大小,尺寸等</ ul>
There is an option to control whether tracked objects are cached in memory as well as being stored on disk. By default, objects are not cached. To save time when working with collections of objects that will all fit in memory, turn on caching with track.options(cache=TRUE), or start tracking with track.start(..., cache=TRUE).
有一个选项来控制是否跟踪对象缓存在内存以及存储在磁盘上。默认情况下,对象是不被缓存。工作时,为了节省时间,将所有适合在内存中的对象的集合,打开缓存track.options(cache=TRUE)或开始跟踪track.start(..., cache=TRUE)。
Here is a brief example of tracking some variables in the global environment:
在全球环境中跟踪一些变量下面是一个简单的例子:
<pre> > library(trackObjs) > track.start("tmp1") > x <- 123 # Not yet tracked > track(x) # Variable 'x' is now tracked > track(y <- matrix(1:6, ncol=2)) # 'y' is assigned & tracked > z1 <- list("a", "b", "c") > z2 <- Sys.time() > track(list=c("z1", "z2")) # Track a bunch of variables > track.summary(size=F) # See a summary of tracked vars class mode extent length modified TA TW x numeric numeric [1] 1 2007-09-07 08:50:58 0 1 y matrix numeric [3x2] 6 2007-09-07 08:50:58 0 1 z1 list list [[3]] 3 2007-09-07 08:50:58 0 1 z2 POSIXt,POSIXct numeric [1] 1 2007-09-07 08:50:58 0 1 > # (TA="total accesses", TW="total writes") > ls(all=TRUE) [1] "x" "y" "z1" "z2" > track.stop() # Stop tracking > ls(all=TRUE) character(0) > > # Restart using the tracking dir -- the variables reappear > track.start("tmp1") # Start using the tracking dir again > ls(all=TRUE) [1] "x" "y" "z1" "z2" > track.summary(size=F) class mode extent length modified TA TW x numeric numeric [1] 1 2007-09-07 08:50:58 0 1 y matrix numeric [3x2] 6 2007-09-07 08:50:58 0 1 z1 list list [[3]] 3 2007-09-07 08:50:58 0 1 z2 POSIXt,POSIXct numeric [1] 1 2007-09-07 08:50:58 0 1 > track.stop() > > # the files in the tracking directory: > list.files("tmp1", all=TRUE) [1] "." ".." [3] "filemap.txt" ".trackingSummary.rda" [5] "x.rda" "y.rda" [7] "z1.rda" "z2.rda" > </pre>
的<PRE>>库(trackObjs)> track.start(TMP1“)> X < - 123#尚未追踪>跟踪(X)#变量中的”x“现在跟踪轨道(Y < - 矩阵(1:6,NCOL = 2))#y的分配与跟踪> Z1 < - 列表(的“a”中,“b”,“c”的)> z2的< - 系统。时间()>轨道(名单= C(“Z1”,“Z2”))#追踪一组变量的> track.summary(大小= F)#查看摘要追踪的的瓦尔类模式范围长度修改TA TW x数字数字[1] 2007-09-07 08:50:58 0 1 y矩阵数字为3x2] 2007-09-07 08:50:58 0 1 Z1名单列表[[3]] 2007-09 -07八时五十分58秒0 1 Z2 POSIXt,POSIXct数字[1] 1 2007-09-07 8点50分58秒0 1#(TA =总访问“,TW =”总写入“)> LS(= TRUE)[1]“X”,“Y”,“Z1”,“Z2”track.stop()#停止跟踪> LS(所有= TRUE)字符(0)>>#重新启动使用跟踪目录 - 重现> track.start(TMP1“)的变量#开始再次使用的跟踪目录>的ls(所有= TRUE)[1]”ד的”y“,”Z1“,”z2的“> track.summary(大小= F修改TA TW)类模式范围长度x数字数字[1] 1 0 1 2007-09-07 08:50:58 y矩阵数字为3x2] 6 2007-09-07 08:50: 58 0 1 Z1名单列表[[3]] 2007-09-07 08:50:58 0 1 Z2 POSIXt,POSIXct数字[1] 1 2007-09-07 08:50:58 0 1> track.stop ()>>#跟踪目录中的文件:list.files(“TMP1”,所有= TRUE)[1]“。” “..” [3]“filemap.txt”“。trackingSummary.rda”[5]“x.rda”的“y.rda”[7]的“z1.rda”的“z2.rda”> </ pre>
There are several points to note:
有几点要注意:
The global environment is the default environment for tracking – it is possible to track variables in other environments, but that environment must be supplied as an argument to the track functions.
全球环境是默认的环境跟踪 - 它可以跟踪在其他环境中的变量,但该环境必须提供作为参数的跟踪功能。
Vars must be explicitly track()ed - newly created objects are not tracked. (This is not a "feature", but there is currently no way of automatically tracking newly created objects – this is on the wishlist.) Thus, it is possible for variables in a tracked environment to either tracked or untracked.
的瓦尔必须是明确track()版 - 新创建的对象不跟踪。 (这是一个“功能”,但目前还没有办法自动跟踪新创建的对象 - 这是对的心愿。),因此,它有可能在跟踪环境变量跟踪或不露痕迹的。
When tracking is stopped, all tracked variables are saved on disk and will be no longer accessible until tracking is started again.
停止跟踪时,所有跟踪的变量保存在磁盘上,将不再跟踪访问,直到再次启动。
The objects are stored each in their own file in the tracking dir, in the format used by save()/load() (RData files). </ul>
对象存储在自己的跟踪目录中的文件,的格式使用save()/load()(RDATA文件)。 </ ul>
列表的基本功能和通用的调用方式----------List of basic functions and common calling patterns----------
Six functions cover the majority of common usage of the trackObjs package:
六大功能涵盖了大部分常见的用法的trackObjs包:
track.start(dir=...): start tracking the global environment, with files saved in dir
track.start(dir=...):开始追踪全球环境,与保存在dir的文件
track.stop(): stop tracking (any unsaved tracked variables are saved to disk and all tracked variables become unavailable until tracking starts again)
track.stop():停止跟踪(任何未保存的跟踪变量保存到磁盘上,成为不可用,直到再次启动跟踪所有跟踪的变量)
track(x): start tracking x - x in the global environment is replaced by an active binding and x is saved in its corresponding file in the tracking directory and, if caching is on, in the tracking environment
track(x):开始跟踪x - x在全球环境中被替换为一个动态绑定和x保存在其相应的跟踪目录中的文件,如果缓存是上,在跟踪的环境
track(x <- value): start tracking x
track(x <- value):开始跟踪x
track(list=c('x', 'y')): start tracking specified variables
track(list=c('x', 'y')):开始跟踪指定的变量
track(all=TRUE): start tracking all untracked variables in the global environment
track(all=TRUE):开始跟踪不露痕迹的在全球环境中的变量
untrack(x): stop tracking variable x - the R object x is put back as an ordinary object in the global environment
untrack(x):停止跟踪变量x - R对象x被放回到一个普通的对象,在全球环境
untrack(all=TRUE): stop tracking all variables in the global environment (but tracking is still set up)
untrack(all=TRUE):停止跟踪的全球环境中的所有变量(但仍然成立跟踪)
untrack(list=...): stop tracking specified variables
untrack(list=...):停止跟踪指定的变量
track.summary(): print a summary of the basic characteristics of tracked variables: name, class, extent, and creation, modification and access times.
track.summary():打印一个总结的跟踪变量的基本特征:名称,类别,程度,创建,修改和访问时间。
track.remove(x): completely remove all traces of x from the global environment, tracking environment and tracking directory. Note that if variable x in the global environment is tracked, remove(x) will make x an "orphaned" variable: remove(x) will just remove the active binding from the global environment, and leave x in the tracked environment and on file, and x will reappear after restarting tracking. </ul>
track.remove(x):完全x从全球环境,跟踪环境和跟踪目录中删除所有的痕迹。需要注意的是,如果变量x在全球环境中的跟踪,remove(x)做x“孤立”变量:remove(x)只是删除了积极约束力的全球环境,和离开x在履带环境和文件,和x会再次出现重新启动后的跟踪。 </ ul>
功能和通用的调用方式的完整列表----------Complete list of functions and common calling patterns----------
The trackObjs package provides many additional functions for controlling how tracking is performed (e.g., whether or not tracked variables are cached in memory), examining the state of tracking (show which variables are tracked, untracked, orphaned, masked, etc.) and repairing tracking environments and databases that have become inconsistent or incomplete (this may result from resource limitiations, e.g., being unable to write a save file due to lack of disk space, or from manual tinkering, e.g., dropping a new save file into a tracking directory.)
trackObjs包提供了许多额外的功能,用于控制如何跟踪(例如,是否跟踪变量在内存中缓存),检查跟踪的状态(显示哪些变量进行跟踪,不露痕迹的,孤立的,屏蔽等。)和跟踪环境和数据库修复,已成为不一致或不完整的(这可能会导致从的资源limitiations,例如,不能写一个保存文件由于缺乏的磁盘空间,或从手动修修补补,例如,删除一个新的保存文件跟踪目录。)
The functions that can be used to set up and take down tracking are:
可以用来建立,并采取了跟踪的功能是:
track.start(dir=...): start tracking, using the supplied directory
track.start(dir=...):开始跟踪,使用所提供的目录
track.stop(): stop tracking (any unsaved tracked variables are saved to disk and all tracked variables become unavailable until tracking starts again)
track.stop():停止跟踪(任何未保存的跟踪变量保存到磁盘上,成为不可用,直到再次启动跟踪所有跟踪的变量)
track.dir(): return the path of the tracking directory </ul>
track.dir():返回路径的跟踪目录</ ul>
Functions for tracking and stopping tracking variables:
跟踪和停止跟踪变量的函数:
track(x) track(var <- value) track(list=...) track(all=TRUE): start tracking variable(s)
track(x)track(var <- value)track(list=...)track(all=TRUE):开始跟踪变量(S)
track.load(file=...): load some objects from a RData file into the tracked environment
track.load(file=...): load some objects from a RData file into the tracked environment
untrack(x, keep.in.db=FALSE) untrack(list=...) untrack(all=TRUE): stop tracking variable(s) - value is left in place, and optionally, it is also left in the the database </ul>
untrack(x, keep.in.db=FALSE)untrack(list=...)untrack(all=TRUE):一站式的跟踪变量(S) - 价值留在原地,并选择性地,它也留在了数据库</ ul>
Functions for getting status of tracking and summaries of variables:
获得状态变量的跟踪和总结的功能:
track.summary(): return a data frame containing a summary of the basic characteristics of tracked variables: name, class, extent, and creation, modification and access times.
track.summary():返回一个数据框包含的跟踪变量的基本特征的总结:名称,类别,程度,以及创建,修改和访问时间。
track.status(): return a data frame containing information about the tracking status of variables: whether they are saved to disk or not, etc.
track.status():返回一个数据框包含的跟踪变量状态的信息:他们是否被保存到磁盘或等
env.is.tracked(): tell whether an environment is currently tracked </ul>
env.is.tracked():判断目前的环境跟踪</ ul>
The remaining functions allow the user to more closely manage variable tracking, but are less likely to be of use to new users.
其余的功能使用户能够更密切地管理变量跟踪,但不太可能使用新的用户。
Functions for getting status of tracking and summaries of variables:
获得状态变量的跟踪和总结的功能:
tracked(): return the names of tracked variables
tracked():返回的跟踪变量的名称
untracked(): return the names of untracked variables
untracked():返回的不露痕迹的变量名称
untrackable(): return the names of variables that cannot be tracked
untrackable():返回的名称不能被跟踪的变量
track.unsaved(): return the names of variables whose copy on file is out-of-date
track.unsaved():返回变量的名字,他们的拷贝文件的最新
track.orphaned(): return the names of once-tracked variables that have lost their active binding (should not happen)
track.orphaned():返回已失去活性结合(一次跟踪变量的名字应该不会发生)
track.masked(): return the names of once-tracked variables whose active binding has been overwritten by an ordinary variable (should not happen) </ul>
track.masked():返回的名字一次跟踪变量,其活性位已被覆盖,由一个普通的变量(应该不会发生)</ ul>
Functions for managing tracking and tracked variables:
管理跟踪和追踪变量的函数:
track.options(): examine and set options to control tracking
track.options():检查和设置选项来控制跟踪
track.remove(): completely remove all traces of a tracked variable
track.remove():彻底清除所有痕迹跟踪的变量
track.save(): write unsaved variables to disk
track.save():未保存的变量写入到磁盘
track.flush(): write unsaved variables to disk, and remove from memory
track.flush():未保存的变量写入到磁盘,并从内存中删除
track.forget(): delete cached versions without saving to file (file version will be retrieved next time the variable is accessed)
track.forget():删除缓存的版本,而不会保存到文件(文件版本将被检索下次访问该变量的时候)
track.restart(): reload variable values from disk (can forget all cached vars, remove no-longer existing tracked vars)
track.restart():重装变量的值从磁盘(可以忘记所有的缓存瓦尔,删除没有已跟踪瓦尔“)
track.load(): load variables from a saved RData file into the tracking session </ul>
track.load():负载变量从已保存的的RDATA文件到跟踪会话</ ul>
Functions for recovering from errors:
从错误中恢复的功能:
track.rebuild(): rebuild tracking information from objects in memory or on disk
track.rebuild():重建跟踪对象在内存或磁盘上的信息
track.flush: write unsaved variables to disk, and remove from memory </ul>
track.flush:未保存的变量写入到磁盘,并从内存中删除</ ul>
Design and internals of tracking:
设计和内部跟踪:
track.design </ul>
track.design</ ul>
(作者)----------Author(s)----------
Tony Plate <tplate@acm.org>
参考文献----------References----------
Roger D. Peng. Interacting with data using the filehash package. R News, 6(4):19-24, October 2006. http://cran.r-project.org/doc/Rnews and http://sandybox.typepad.com/software
David E. Brahm. Delayed data packages. R News, 2(3):11-12, December 2002. http://cran.r-project.org/doc/Rnews
参见----------See Also----------
Design of the trackObjs package.
trackObjs包的设计。
Potential future features of the trackObjs package.
trackObjs包的潜在的未来的功能。
Documentation for save and load (in 'base' package).
save和load(碱基包文件)。
Documentation for makeActiveBinding and related functions (in 'base' package).
makeActiveBinding和相关的功能(在碱基包)的文件。
Inspriation from the packages g.data and filehash.
Inspriation的包g.data和filehash。
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|