设为首页收藏本站获取积分奖励

R语言中文网

 找回密码
 立即注册
查看: 1061|回复: 0

R语言因素addNA()函数-中英文对照帮助文档

[复制链接]
发表于 2020-8-20 22:38:41 | 显示全部楼层 |阅读模式
        R语言因素addNA()函数-中英文对照帮助文档

                                         By MicroRbt Martinez PhD

R语言函数名:addNA()
R语言函数功能:因素
来自资源库:基础库(R语言自带)
addNA()函数所属R语言包:所在R包具体名称、包功能的中英文双语描述见正文后面'--所在R语言包信息--'部分。

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

The function factor is used to encode a vector as a factor (the terms category and enumerated type are also used for factors). If argument ordered is TRUE, the factor levels are assumed to be ordered. For compatibility with S there is also a function ordered.
函数factor用于将向量编码为因子(术语category和enumerated type也用于因子)。如果参数ordered为TRUE,则假定因子级别是有序的。为了与S兼容,还有一个功能ordered。

is.factor, is.ordered, as.factor and as.ordered are the membership and coercion functions for these classes.
is.factor,is.ordered,as.factor和as.ordered是这些类的成员身份和强制功能。


使用方法-----Usage-----

factor(x = character(), levels, labels = levels,
exclude = NA, ordered = is.ordered(x), nmax = NA)
ordered(x, ...)
is.factor(x)
is.ordered(x)
as.factor(x)
as.ordered(x)
addNA(x, ifany = FALSE)

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

参数x介绍: a vector of data, usually taking a small number of distinct values.
数据向量,通常采用少量不同的值。

参数levels介绍: an optional vector of the unique values (as character strings) that x might have taken. The default is the unique set of values taken by as.character(x), sorted into increasing order of <code>x</code>. Note that this set can be specified as smaller than sort(unique(x)).
x可能已采用的唯一值的可选向量(作为字符串)。默认值是as.character(x)唯一的一组值,按升序of <code>x </ code>排序。请注意,可以将此集合指定为小于sort(unique(x))。

参数labels介绍: either an optional character vector of labels for the levels (in the same order as levels after removing those in exclude), or a character string of length 1. Duplicated values in labels can be used to map different values of x to the same factor level.
either级别的标签的可选字符向量(删除了exclude中的标签后,顺序与levels相同),or长度为1的字符串。labels中的重复值可用于将不同的x值映射到相同的水平。

参数exclude介绍: a vector of values to be excluded when forming the set of levels. This may be factor with the same level set as x or should be a character.
构成一组水平时要排除的值的向量。这可能是与x设置的水平相同的因子,或者应该是character。

参数ordered介绍: logical flag to determine if the levels should be regarded as ordered (in the order given).
逻辑标志,用于确定是否应将这些级别视为已排序(按给定的顺序)。

参数nmax介绍: an upper bound on the number of levels; see Details .
级别数的上限;请参阅Details。

参数...介绍: (in ordered(.)): any of the above, apart from ordered itself.
(在ordered(.)中):除ordered本身以外的任何上述内容。

参数ifany介绍: only add an NA level if it is used, i.e. if any(is.na(x)).
仅在使用NA级别时(即any(is.na(x)))添加。


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

The type of the vector x is not restricted; it only must have an as.character method and be sortable (by order).
向量x的类型不受限制;它仅必须具有as.character方法并且可以排序(通过order)。

Ordered factors differ from factors only in their class, but methods and the model-fitting functions treat the two classes quite differently.
有序因子仅在其类中不同于因子,但是方法和模型拟合函数对这两个类的处理却大不相同。

The encoding of the vector happens as follows. First all the values in exclude are removed from levels. If x equals levels[j], then the i-th element of the result is j. If no match is found for x in levels (which will happen for excluded values) then the i-th element of the result is set to NA.
向量的编码如下。首先,从levels中删除exclude中的所有值。如果x等于levels[j],则结果的第i个元素为j。如果在levels中找不到与x匹配的项(排除值将发生),则结果的第i个元素将设置为NA。

Normally the levels used as an attribute of the result are the reduced set of levels after removing those in exclude, but this can be altered by supplying labels. This should either be a set of new labels for the levels, or a character string, in which case the levels are that character string with a sequence number appended.
通常,将levels用作结果的属性是在exclude中删除了那些之后减少的一组水平,但是可以通过提供labels来更改。这应该是一组新的级别标签,也可以是一个字符串,在这种情况下,级别是附加了序列号的字符串。

factor(x, exc
-----未完,待续-----,↓↓↓展开剩余72%↓↓↓
购买主题 前行需要您的支持,请赞助作者 【15 金钱】 就能浏览全部100%内容啦!(本贴一次赞助、永久可读)
回复

使用道具 举报

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

本版积分规则

手机版|小黑屋|Archiver|R语言中文网    

GMT+8, 2024-5-21 04:52 , Processed in 0.025754 second(s), 21 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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