exists(base)
exists()所属R语言包:base
Is an Object Defined?
是一个对象定义吗?
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Look for an R object of the given name.
寻找一个给定名称的R对象。
用法----------Usage----------
exists(x, where = -1, envir = , frame, mode = "any",
inherits = TRUE)
参数----------Arguments----------
参数:x
a variable name (given as a character string).
一个变量的名称(字符串)。
参数:where
where to look for the object (see the details section); if omitted, the function will search as if the name of the object appeared unquoted in an expression.
到哪里寻找对象(见细节部分);如果省略,函数将搜索对象的名称,如果出现在一个表达式中加引号。
参数:envir
an alternative way to specify an environment to look in, but it is usually simpler to just use the where argument.
另一种方式指定的环境看,但它通常是简单,只需使用where参数。
参数:frame
a frame in the calling list. Equivalent to giving where as sys.frame(frame).
在调用列表框。相当于给wheresys.frame(frame)。
参数:mode
the mode or type of object sought: see the "Details" section.
模式或类型的对象要求:见“详细资料”部分。
参数:inherits
should the enclosing frames of the environment be searched?
环境封闭的框架应被搜查?
Details
详情----------Details----------
The where argument can specify the environment in which to look for the object in any of several ways: as an integer (the position in the search list); as the character string name of an element in the search list; or as an environment (including using sys.frame to access the currently active function calls). The envir argument is an alternative way to specify an environment, but is primarily there for back compatibility.
可以指定where参数的环境中寻找在以下几个方面的任何对象:作为一个整数(在search列表的位置);元素的字符串名称搜索列表;或environment(包括使用sys.frame访问当前活动的函数调用)。论据是envir另一种方式来指定一个环境,但主要是为后面的兼容性有。
This function looks to see if the name x has a value bound to it in the specified environment. If inherits is TRUE and a value is not found for x in the specified environment, the enclosing frames of the environment are searched until the name x is encountered. See environment and the "R Language Definition" manual for details about the structure of environments and their enclosures.
这个功能看起来看到的名字x有一个值绑定在指定的环境。 inherits如果是TRUE和x在指定的环境,环境封闭的帧搜索,直到名称x遇到一个值。看到environment“和”R语言定义有关的环境和他们的外壳结构的详细信息手册。
Warning: inherits = TRUE is the default behaviour for R but not for S.
警告:inherits = TRUE默认行为是为R,但不为S
If mode is specified then only objects of that type are sought. The mode may specify one of the collections "numeric" and "function" (see mode): any member of the collection will suffice. (This is true even if a member of a collection is specified, so for example mode="special" will seek any type of function.)
如果mode被指定,那么只有该类型的对象要求。 mode可以指定集合"numeric"和"function"(见mode):集合的任何成员就足够了。 (这是真实的,即使是一个集合的成员被指定,例如mode="special"将寻求任何类型的功能。)
值----------Value----------
Logical, true if and only if an object of the correct name and mode is found.
逻辑,真当且仅当找到正确的名称和模式的对象。
参考文献----------References----------
The New S Language. Wadsworth & Brooks/Cole.
参见----------See Also----------
get. For quite a different kind of “existence” checking, namely if function arguments were specified, missing.
get。对于相当多的不同种类的“存在”的检查,即如果函数的参数被指定,missing。
举例----------Examples----------
## Define a substitute function if necessary:[#定义一个替代的功能,如果有必要:]
if(!exists("some.fun", mode="function"))
some.fun <- function(x) { cat("some.fun(x)\n"); x }
search()
exists("ls", 2) # true even though ls is in pos=3[真正LS即使是在POS = 3]
exists("ls", 2, inherits = FALSE) # false[假]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|