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

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

[复制链接]
发表于 2012-2-17 10:05:14 | 显示全部楼层 |阅读模式
data.frame(base)
data.frame()所属R语言包:base

                                        Data Frames
                                         数据框

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

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

This function creates data frames, tightly coupled collections of variables which share many of the properties of matrices and of lists, used as the fundamental data structure by most of R's modeling software.
这个函数创建的数据框,有着许多的属性,矩阵和列表的变量紧密耦合的集合,大多数R的建模软件的使用作为基本数据结构。


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


data.frame(..., row.names = NULL, check.rows = FALSE,
           check.names = TRUE,
           stringsAsFactors = default.stringsAsFactors())

default.stringsAsFactors()



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

参数:...
these arguments are of either the form value or tag = value.  Component names are created based on the tag (if present) or the deparsed argument itself.
这些论点形式value或tag = value。组件名称创建的基础上的标签(如果存在)的deparsed参数本身。


参数:row.names
NULL or a single integer or character string specifying a column to be used as row names, or a character or integer vector giving the row names for the data frame.
NULL或一个整数或字符串,指定要作为行的名称,或一个字符或整数向量,使数据框行名称中使用的列。


参数:check.rows
if TRUE then the rows are checked for consistency of length and names.
如果TRUE然后行的长度和名称的一致性检查。


参数:check.names
logical.  If TRUE then the names of the variables in the data frame are checked to ensure that they are syntactically valid variable names and are not duplicated. If necessary they are adjusted (by make.names) so that they are.
逻辑。如果TRUE然后检查数据框中的变量的名称,以确保它们是语法有效的变量名不重复。如果有必要调整它们(make.names),使它们。


参数:stringsAsFactors
logical: should character vectors be converted to factors?  The "factory-fresh" default is TRUE, but this can be changed by setting options(stringsAsFactors       = FALSE).
逻辑:特征向量转换的因素? “工厂新鲜的默认是TRUE,但是这可以通过设置options(stringsAsFactors       = FALSE)改变。


Details

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

A data frame is a list of variables of the same number of rows with unique row names, given class "data.frame".  If no variables are included, the row names determine the number of rows.
一个数据框是一个具有独特的行名行号,给定类的"data.frame"的变量列表。如果没有变量,则该行的名称确定的行数。

The column names should be non-empty, and attempts to use empty names will have unsupported results.  Duplicate column names are allowed, but you need to use check.names = FALSE for data.frame to generate such a data frame.  However, not all operations on data frames will preserve duplicated column names: for example matrix-like subsetting will force column names in the result to be unique.
列名应为非空,并尝试使用空的名字,将有不支持的结果。重复的列名是允许的,但你需要使用check.names = FALSEdata.frame产生这样一个数据框。然而,并非所有的数据框的操作将保留重复的列名:例如矩阵子集,将迫使结果中的列名必须是唯一的。

data.frame converts each of its arguments to a data frame by calling as.data.frame(optional=TRUE).  As that is a generic function, methods can be written to change the behaviour of arguments according to their classes: R comes with many such methods. Character variables passed to data.frame are converted to factor columns unless protected by I or argument stringsAsFactors is false.  If a list or data frame or matrix is passed to data.frame it is as if each component or column had been passed as a separate argument (except for matrices of class "model.matrix" and those protected by I).
data.frame转换其每一个数据框的参数调用as.data.frame(optional=TRUE)。因为这是一个通用的功能,方法可以写入更改参数,根据他们班的行为:R与很多这样的方法。字符变量传递data.frame的,转换因子列除非I或参数stringsAsFactors是假的保护。如果列表或数据框或矩阵传递给data.frame“这是因为如果每个组件或列已作为一个单独的参数传递(除"model.matrix"和I保护那些类矩阵)。

Objects passed to data.frame should have the same number of rows, but atomic vectors, factors and character vectors protected by I will be recycled a whole number of times if necessary (including as elements of list arguments).
对象传递到data.frame应该有相同的行数,但原子的向量,保护因素和特征向量I将回收的次数的整数,如果必要的(包括元素的列表参数)。

If row names are not supplied in the call to data.frame, the row names are taken from the first component that has suitable names, for example a named vector or a matrix with rownames or a data frame. (If that component is subsequently recycled, the names are discarded with a warning.)  If row.names was supplied as NULL or no suitable component was found the row names are the integer sequence starting at one (and such row names are considered to be "automatic", and not preserved by as.matrix).
如果在调用data.frame不提供行名,行名取自第一部分,有合适的名称,例如一个名为向量或矩阵与rownames或一个数据框,。 (如果该组件随后回收的名字被丢弃。警告)如果row.names是NULL提供或没有合适的组件被发现的行名是在一开始的整数序列(等列名被认为是自动,as.matrix),而不是保留。

If row names are supplied of length one and the data frame has a single row, the row.names is taken to specify the row names and not a column (by name or number).
如果行名称长度为一提供的数据框有一个单列,row.names采取指定的列名和列(名称或号码)。

Names are removed from vector inputs not protected by I.
从I保护向量输入的名称。

default.stringsAsFactors is a utility that takes getOption("stringsAsFactors") and ensures the result is TRUE or FALSE (or throws an error if the value is not NULL).
default.stringsAsFactors是一个实用程序需要getOption("stringsAsFactors"),并确保其结果是TRUE或FALSE(或抛出一个错误,如果该值不是NULL)。


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

A data frame, a matrix-like structure whose columns may be of differing types (numeric, logical, factor and character and so on).
一个数据框,矩阵结构,其列,可能是不同的类型(数字,逻辑,因素和性格等)。

How the names of the data frame are created is complex, and the rest of this paragraph is only the basic story.  If the arguments are all named and simple objects (not lists, matrices of data frames) then the argument names give the column names.  For an unnamed simple argument, a deparsed version of the argument is used as the name (with an enclosing I(...) removed).  For a named matrix/list/data frame argument with more than one named column, the names of the columns are the name of the argument followed by a dot and the column name inside the argument: if the argument is unnamed, the argument's column names are used.  For a named or unnamed matrix/list/data frame argument that contains a single column, the column name in the result is the column name in the argument.  Finally, the names are adjusted to be unique and syntactically valid unless check.names = FALSE.
如何创建的数据框的名称是复杂的,本段其余部分是唯一的基本故事。如果参数都命名和简单对象(不列出,数据框的矩阵),然后参数名列名。一位不愿透露姓名的简单参数,一个参数deparsed版本使用的名称(一个封闭I(...)删除)。对于1命名多于一个名为列矩阵/列表/数据框的参数,列的名称是1点和参数内列名参数的名称:如果参数是无名,该参数的列名被使用。结果中的列名是一个有名或无名的矩阵/列表/数据框的参数,包含单个列,在参数的列名。最后,名称调整是唯一的和语法有效,除非check.names = FALSE。


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

In versions of R prior to 2.4.0 row.names had to be character: to ensure compatibility with such versions of R, supply a character vector as the row.names argument.
研发到2.4.0之前的版本row.names必须是字符,以确保与R版本的兼容性,提供row.names参数字符向量。


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

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

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

I, plot.data.frame, print.data.frame, row.names, names (for the column names), [.data.frame for subsetting methods, Math.data.frame etc, about Group methods for data.frames; read.table, make.names.
I,plot.data.frame,print.data.frame,row.names,names(列名),[.data.frame子集的方法,Math.data.frame等有关data.frame的组方法;read.table,make.names。


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


L3 <- LETTERS[1:3]
(d <- data.frame(cbind(x=1, y=1:10), fac=sample(L3, 10, replace=TRUE)))

## The same with automatic column names:[#一样的自动列名:]
data.frame(cbind(  1,   1:10),     sample(L3, 10, replace=TRUE))

is.data.frame(d)

## do not convert to factor, using I() :[不转换因子,使用():]
(dd <- cbind(d, char = I(letters[1:10])))
rbind(class=sapply(dd, class), mode=sapply(dd, mode))

stopifnot(1:10 == row.names(d))# {coercion}[{胁迫}]

(d0  &lt;- d[, FALSE]) # NULL data frame with 10 rows[10行的NULL数据框]
(d.0 &lt;- d[FALSE, ]) # &lt;0 rows&gt; data frame  (3 cols)[<行>数据框(3 COLS)]
(d00 &lt;- d0[FALSE,])  # NULL data frame with 0 rows[NULL数据框0行]

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-1-22 23:44 , Processed in 0.034697 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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