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

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

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

                                        The (Storage) Mode of an Object
                                         对象(存储)模式

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

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

Get or set the type or storage mode of an object.
获取或设置对象的类型或存储模式。


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


mode(x)
mode(x) <- value
storage.mode(x)
storage.mode(x) <- value



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

参数:x
any R object.
任何R对象。


参数:value
a character string giving the desired mode or "storage mode" (type) of the object.
一个字符串,提供所需的模式或“存储模式”(类型)的对象。


Details

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

Both mode and storage.mode return a character string giving the (storage) mode of the object — often the same — both relying on the output of typeof(x), see the example below.
既mode和storage.mode返回一个字符串对象(存储)模式 - 往往是相同的 - 无论对依靠typeof(x),看到下面的例子中的输出。

mode(x) <- "newmode" changes the mode of object x to newmode.  This is only supported if there is an appropriate as.newmode function, for example "logical", "integer", "double", "complex", "raw", "character", "list", "expression", "name", "symbol" and "function".  Attributes are preserved (but see below).
mode(x) <- "newmode"改变的对象mode xnewmode。这是唯一支持,如果有一个合适的as.newmode功能,例如,"logical","integer","double","complex","raw","character","list","expression","name","symbol"和"function"。属性会被保留(但请参阅下文)。

storage.mode(x) <- "newmode" is a more efficient primitive version of mode<-, which works for "newmode" which is one of the internal types (see typeof), but not for "single".  Attributes are preserved.
storage.mode(x) <- "newmode"mode<-,是一种更有效的原始版本"newmode"这是一个内部类型(见typeof),但不"single" 。属性会被保留。

As storage mode "single" is only a pseudo-mode in R, it will not be reported by mode or storage.mode: use attr(object, "Csingle") to examine this.  However, mode<- can be used to set the mode to "single", which sets the real mode to "double" and the "Csingle" attribute to TRUE.  Setting any other mode will remove this attribute.
"single"只有在R伪模式作为存储模式,它不会被mode或storage.mode用attr(object, "Csingle")检查报告。然而,mode<-可以用来将模式设置为"single",设置实模式"double"和"Csingle"属性TRUE。设置任何其他的模式,将删除此属性。

Note (in the examples below) that some calls have mode "(" which is S compatible.
注(在下面的例子),一些callS模式"("这是S兼容。


模式名称----------Mode names----------

Modes have the same set of names as types (see typeof) except that
模式有相同类型的名称,除了集(见typeof)

types "integer" and "double" are returned as "numeric".
类型"integer"和"double""numeric"的返回。

types "special" and "builtin" are returned as "function".
类型"special"和"builtin""function"的返回。

type "symbol" is called mode "name".
类型"symbol"被称为模式"name"。

type "language" is returned as "(" or "call".
返回类型"language""("或"call"。


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

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

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

typeof for the R-internal "mode", attributes.
typeofR  - 内部模式,attributes。


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


require(stats)

sapply(options(),mode)

cex3 <- c("NULL","1","1:1","1i","list(1)","data.frame(x=1)",
  "pairlist(pi)", "c", "lm", "formals(lm)[[1]]",  "formals(lm)[[2]]",
  "y~x","expression((1))[[1]]", "(y~x)[[1]]",
  "expression(x <- pi)[[1]][[1]]")
lex3 <- sapply(cex3, function(x) eval(parse(text=x)))
mex3 <- t(sapply(lex3,
                 function(x) c(typeof(x), storage.mode(x), mode(x))))
dimnames(mex3) <- list(cex3, c("typeof(.)","storage.mode(.)","mode(.)"))
mex3

## This also makes a local copy of 'pi':[#这也使得“PI”的本地副本:]
storage.mode(pi) <- "complex"
storage.mode(pi)
rm(pi)

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


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

使用道具 举报

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

本版积分规则

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

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

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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