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

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

[复制链接]
发表于 2012-2-16 22:08:09 | 显示全部楼层 |阅读模式
model.frame(stats)
model.frame()所属R语言包:stats

                                        Extracting the Model Frame from a Formula or Fit
                                         从公式或适合提取模型框架

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

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

model.frame (a generic function) and its methods return a data.frame with the variables needed to use formula and any ... arguments.
model.frame(通用功能)和它的方法返回一个data.frame任何formula参数需要使用的变量...。


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


model.frame(formula, ...)

## Default S3 method:[默认方法]
model.frame(formula, data = NULL,
           subset = NULL, na.action = na.fail,
           drop.unused.levels = FALSE, xlev = NULL, ...)

## S3 method for class 'aovlist'
model.frame(formula, data = NULL, ...)

## S3 method for class 'glm'
model.frame(formula, ...)

## S3 method for class 'lm'
model.frame(formula, ...)

get_all_vars(formula, data, ...)



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

参数:formula
a model formula or terms object or an R object.
模型formula或terms对象或一个R对象。


参数:data
a data.frame, list or environment (or object coercible by as.data.frame to a data.frame), containing the variables in formula.  Neither a matrix nor an array will be accepted.
数据框,列表或环境(或对象强制转换as.data.frame数据框),包含在formula的变量。既不是一个矩阵,也不是一个数组将被接受。


参数:subset
a specification of the rows to be used: defaults to all rows. This can be any valid indexing vector (see [.data.frame) for the rows of data or if that is not supplied, a data frame made up of the variables used in formula.
一个要使用的行规格:默认为所有行。这可以是任何有效的索引向量(看到[.data.frame)data或如果是不提供的,数据框使用的变量在formula行。


参数:na.action
how NAs are treated.  The default is first, any na.action attribute of data, second a na.action setting of options, and third na.fail if that is unset.  The "factory-fresh" default is na.omit.  Another possible value is NULL.
如何NA的处理。默认是第一,任何na.action属性data,第二个是na.action设置options,第三na.fail如果没有设置。工厂新鲜的默认是na.omit。另一种可能的值是NULL。


参数:drop.unused.levels
should factors have unused levels dropped? Defaults to FALSE.
因素应该有未使用的水平下降? FALSE默认。


参数:xlev
a named list of character vectors giving the full set of levels to be assumed for each factor.
指定一个字符,假设每个因子的水平的全套向量。


参数:...
further arguments such as data, na.action, subset.  Any additional arguments such as offset and weights which reach the default method are used to create further columns in the model frame, with parenthesised names such as "(offset)".
进一步的参数,如data,na.action,subset。任何额外的参数,如offset和weights达到默认的方法,用于创建模型框架的进一步列,如"(offset)"parenthesised名。


Details

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

Exactly what happens depends on the class and attributes of the object formula.  If this is an object of fitted-model class such as "lm", the method will either return the saved model frame used when fitting the model (if any, often selected by argument model = TRUE) or pass the call used when fitting on to the default method.  The default method itself can cope with rather standard model objects such as those of class "lqs" from package MASS if no other arguments are supplied.
正是这样的依赖对象formula类和属性。如果这是一个拟合模型,如类的对象"lm",该方法将返回保存的模型框架,用来拟合模型(如有的话,往往通过参数选择时model = TRUE)或通过电话装修默认的方法时使用。默认的方法本身就可以应付,而标准模型中的对象,如类"lqs"包MASS如果没有其他的参数提供。

The rest of this section applies only to the default method.
本节的其余部分仅适用于默认的方法。

If either formula or data is already a model frame (a data frame with a "terms" attribute) and the other is missing, the model frame is returned.  Unless formula is a terms object, as.formula and then terms is called on it.  (If you wish to use the keep.order argument of terms.formula, pass a terms object rather than a formula.)
如果任formula或data已经是一个模型框架("terms"属性的数据框)和其他失踪,模型框架返回。除非formula是一个对象,as.formula然后terms它称为。 (如果你想使用keep.orderterms.formula参数,通过计算对象比公式。)

Row names for the model frame are taken from the data argument if present, then from the names of the response in the formula (or rownames if it is a matrix), if there is one.
模型框架的行名取自data参数,如果存在的话,那么从响应公式中的名称(或rownames如果它是一个矩阵),如果有一个。

All the variables in formula, subset and in ... are looked for first in data and then in the environment of formula (see the help for formula() for further details) and collected into a data frame.  Then the subset expression is evaluated, and it is used as a row index to the data frame.  Then the na.action function is applied to the data frame (and may well add attributes).  The levels of any factors in the data frame are adjusted according to the drop.unused.levels and xlev arguments: if xlev specifies a factor and a character variable is found, it is converted to a factor (as from R 2.10.0).
所有的变量在formula,subset和...先看着data然后在环境formula(帮助formula()详情)和收集到的数据框。然后subset表达式评估,它是作为行索引到的数据框。然后na.action函数应用到的数据框(可能添加属性)。在数据框的任何因素水平根据drop.unused.levels和xlev参数:xlev如果指定一个因素,发现一个字符变量,它被转换为一个因素(调整从R 2.10.0)。

Unless na.action = NULL, time-series attributes will be removed from the variables found (since they will be wrong if NAs are removed).
除非na.action = NULL,时间序列的属性将被删除(如果NAS被删除,因为他们将是错误的)变量。

Note that all the variables in the formula are included in the data frame, even those preceded by -.
请注意,公式中的所有变量包含在数据框,甚至-前面那些。

Only variables whose type is raw, logical, integer, real, complex or character can be included in a model frame: this includes classed variables such as factors (whose underlying type is integer), but excludes lists.
唯一的变量,其类型是原材料,逻辑,整数,真实的,复杂的或字符,可以包含在一个模型框架:包括归类等因素(其基本类型是整数)的变量,但不包括列表。

get_all_vars returns a data.frame containing the variables used in formula plus those specified .... Unlike model.frame.default, it returns the input variables and not those resulting from function calls in formula.
get_all_vars返回data.frame包含formula使用的变量,加上那些指定的...的。不像model.frame.default,它返回的输入变量,而不是那些导致formula函数调用。


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

A data.frame containing the variables used in formula plus those specified in ....  It will have additional attributes, including "terms" for an object of class "terms" derived from formula, and possibly "na.action" giving information on the handling of NAs (which will not be present if no special handling was done, e.g. by na.pass).
一个data.frame包含formula使用的变量加上...指定。这将有额外的属性,包括"terms"类"terms"formula派生,可能"na.action"给NA的处理的信息(对象不会存在,如果没有做特殊处理,例如na.pass)。


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

Data for models. Chapter 3 of Statistical Models in S eds J. M. Chambers and T. J. Hastie, Wadsworth & Brooks/Cole.

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

model.matrix for the "design matrix", formula for formulas  and expand.model.frame for model.frame manipulation.
model.matrix“设计矩阵,formula和expand.model.framemodel.frame操纵公式。


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


data.class(model.frame(dist ~ speed, data = cars))

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-1-23 09:26 , Processed in 0.029843 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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