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

R语言:detach()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-2-16 19:21:37 | 显示全部楼层 |阅读模式
detach(base)
detach()所属R语言包:base

                                        Detach Objects from the Search Path
                                         从搜索路径中分离对象

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

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

Detach a database, i.e., remove it from the search() path of available R objects.  Usually this is either a data.frame which has been attached or a package which was attached by library.
分离,即一个数据库,从它的search()可用R对象的路径。这通常是已data.frameed或一个附加包attachlibrary。


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


detach(name, pos = 2, unload = FALSE, character.only = FALSE,
       force = FALSE)



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

参数:name
The object to detach.  Defaults to search()[pos]. This can be an unquoted name or a character string but not a character vector.  If a number is supplied this is taken as pos.  
分离的对象。 search()[pos]默认。这可以是一个非上市的名称或一个字符串而不是一个字符向量。如果提供的数字,这是为pos。


参数:pos
Index position in search() of the database to detach.  When name is a number, pos = name is used.  
search()分离数据库的索引位置。当name是一个数字,pos = name使用。


参数:unload
A logical value indicating whether or not to attempt to unload the namespace when a package is being detached.  If the package has a namespace and unload is TRUE, then detach will attempt to unload the namespace via unloadNamespace: if the namespace is imported by another namespace or unload is FALSE, no unloading will occur.  
一个逻辑值,指示是否尝试卸载命名空间,当一个包被分离。如果包有一个命名空间和unload是TRUE,则detach会尝试卸载通过的命名空间unloadNamespace:如果另一个命名空间命名空间是由进口或<X >是unload,没有卸载,会发生。


参数:character.only
a logical indicating whether name can be assumed to be character strings.
逻辑是否name可以假定为字符串。


参数:force
logical: should a package be detached even though other attached packages depend on it?
逻辑:即使其他附着物包依赖于它的包分离?


Details

详情----------Details----------

This is most commonly used with a single number argument referring to a position on the search list, and can also be used with a unquoted or quoted name of an item on the search list such as package:tools.
这是最常用的单数指的是在搜索列表中的位置的说法,也可用于非上市或报价的搜索列表,如package:tools一个项目的名称。

If a package has a namespace, detaching it does not by default unload the namespace (and may not even with unload=TRUE), and detaching will not in general unload any dynamically loaded compiled code (DLLs).  Further, registered S3 methods from the namespace will not be removed.  If you use library on a package whose namespace is loaded, it attaches the exports of the already loaded namespace.  So detaching and re-attaching a package may not refresh some or all components of the package, and is inadvisable.
如果一个包有一个命名空间,分离它不默认情况下,卸载命名空间(不得即使unload=TRUE),分离一般不卸载任何动态加载编译后的代码(DLL)中。此外,注册S3的命名空间的方法不会被删除。如果你使用library加载包的命名空间,它十分重视出口已加载的命名空间。因此,分离和重新附加一个包可能不刷新的部分或全部组件的包,是不可取的。


值----------Value----------

The return value is invisible.  It is NULL when a package is detached, otherwise the environment which was returned by attach when the object was attached (incorporating any changes since it was attached).
返回值是无形的。它是NULL包时,分离,否则的环境,这是由attach返回连接对象时(包含任何的变化,因为它是连接)。


注意----------Note----------

You cannot detach either the workspace (position 1) nor the base package (the last item in the search list), and attempting to do so will throw an error.
你不能分离的工作区(位置1),也不base包(在搜索列表中的最后一个项目),并试图这样做,会抛出一个错误。

Unloading some namespaces has undesirable side effects: e.g. unloading grid closes all graphics devices, and on most systems tcltk cannot be reloaded once it has been unloaded and may crash R if this is attempted.
卸载一些命名空间有不良副作用的影响:如卸“grid关闭所有的图形设备,在大多数系统上tcltk不能重装一旦被卸载,可能会崩溃R如果这是尝试。


参考文献----------References----------

The New S Language. Wadsworth &amp; Brooks/Cole.

参见----------See Also----------

attach, library, search, objects, unloadNamespace, library.dynam.unload .
attach,library,search,objects,unloadNamespace,library.dynam.unload。


举例----------Examples----------


require(splines) # package[包]
detach(package:splines)
## or also[#]
library(splines)
pkg <- "package:splines"

detach(pkg, character.only = TRUE)

## careful: do not do this unless 'splines' is not already attached.[#注意:不这样做,除非“样条”尚未连接。]
library(splines)
detach(2) # 'pos' used for 'name'[POS为名]

## an example of the name argument to attach[#附加一个名称参数的例子]
## and of detaching a database named by a character vector[#和分离由特征向量命名数据库]
attach_and_detach <- function(db, pos=2)
{
   name <- deparse(substitute(db))
   attach(db, pos=pos, name=name)
   print(search()[pos])
   detach(name, character.only = TRUE)
}
attach_and_detach(women, pos=3)

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-1-24 13:13 , Processed in 0.027249 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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