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

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

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

                                        Combine R Objects by Rows or Columns
                                         结合R对象的行或列

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

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

Take a sequence of vector, matrix or data frames arguments and combine by columns or rows, respectively.  These are generic functions with methods for other R classes.
采取的向量,矩阵或数据框参数的顺序和组合,分别列或行。这些都是与其他R类方法的通用功能。


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


cbind(..., deparse.level = 1)
rbind(..., deparse.level = 1)



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

参数:...
vectors or matrices.  These can be given as named arguments.  Other R objects will be coerced as appropriate: see sections "Details" and "Value".  (For the "data.frame" method of cbind these can be further arguments to data.frame such as stringsAsFactors.)
向量或矩阵。这些都可以作为命名参数。其他研究对象,将酌情裹挟:看到部分“详细资料”和“价值”。 ("data.frame"方法对于cbind这些都可以data.framestringsAsFactors的进一步论据。)


参数:deparse.level
integer controlling the construction of labels in the case of non-matrix-like arguments (for the default method):<br> deparse.level = 0 constructs no labels; the default, deparse.level = 1 or 2 constructs labels from the argument names, see the "Value" section below.
整数控制标签在非矩阵类似的参数(默认方法)的情况下建设:参考deparse.level = 0构造无标签;默认情况下,deparse.level = 1 or 2构造参数名的标签,看到下面的“价值”一节。


Details

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

The functions cbind and rbind are S3 generic, with methods for data frames.  The data frame method will be used if at least one argument is a data frame and the rest are vectors or matrices.  There can be other methods; in particular, there is one for time series objects.  See the section on "Dispatch" for how the method to be used is selected.
职能cbind和rbind是S3的通用数据框的方法。如果至少有一个参数是一个数据框,其余的是向量或矩阵的数据框的方法将被用于。可以有其他方法,特别是有一个时间序列对象。如何选择要使用的方法是调度。

In the default method, all the vectors/matrices must be atomic (see vector) or lists.  Expressions are not allowed. Language objects (such as formulae and calls) and pairlists will be coerced to lists: other objects (such as names and external pointers) will be included as elements in a list result.  Any classes the inputs might have are discarded (in particular, factors are replaced by their internal codes).
在默认的方法,所有的向量/矩阵必须是原子(见vector)或列表。表达式是不允许的。语言中的对象(如公式,并呼吁)和pairlists的将被裹挟到列表:其他对象(如姓名和外部指针)将被列入列表结果中的元素。被丢弃的投入可能有任何类(因素,特别是通过其内部的代码替换)。

If there are several matrix arguments, they must all have the same number of columns (or rows) and this will be the number of columns (or rows) of the result.  If all the arguments are vectors, the number of columns (rows) in the result is equal to the length of the longest vector.  Values in shorter arguments are recycled to achieve this length (with a warning if they are recycled only fractionally).
如果有多个矩阵参数,他们都必须有相同数量的列(或行),这将是对结果的列(或行)的数目。如果所有参数向量,结果中的列(行)的数量是相等的长度最长的向量。在较短的参数值回收要达到这个长度(warning如果他们仅小幅回收)。

When the arguments consist of a mix of matrices and vectors the number of columns (rows) of the result is determined by the number of columns (rows) of the matrix arguments.  Any vectors have their values recycled or subsetted to achieve this length.
当混合矩阵和向量的参数包括结果的列(行)的数量确定的列数的矩阵参数(行)。任何向量都有其价值回收或子集来实现这个长度。

For cbind (rbind), vectors of zero length (including NULL) are ignored unless the result would have zero rows (columns), for S compatibility. (Zero-extent matrices do not occur in S3 and are not ignored in R.)
cbind(rbind),长度为零的向量(包括NULL)被忽略,除非其结果将有为零的行(列)的兼容性。 (零程度矩阵不发生在S3中,河中不忽略)


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

For the default method, a matrix combining the ... arguments column-wise or row-wise.  (Exception: if there are no inputs or all the inputs are NULL, the value is NULL.)
默认的方法,结合矩阵...参数列明智的或明智的行。 (例外:如果没有输入或输入NULL值NULL)

The type of a matrix result determined from the highest type of any of the inputs in the hierarchy raw < logical < integer < real < complex < character < list .
决定从最高层次结构中的原料<逻辑<整数<真正<复杂的<字符<列表输入任何类型的矩阵结果的类型。

For cbind (rbind) the column (row) names are taken from the colnames (rownames) of the arguments if these are matrix-like.  Otherwise from the names of the arguments or where those are not supplied and deparse.level > 0, by deparsing the expressions given, for deparse.level = 1 only if that gives a sensible name (a "symbol", see is.symbol).
cbind(rbind)列(行)的名字取自colnames(rownames)的论点,如果这些矩阵状。否则从这些参数或名称不提供deparse.level > 0,由deparsing表达式deparse.level = 1只要给出一个合理的名称(一个符号,看到的,<X >)。

For cbind row names are taken from the first argument with appropriate names: rownames for a matrix, or names for a vector of length the number of rows of the result.
cbind行名取自适当的名称的第一个参数:为的矩阵rownames,或长度结果的行数向量的名称。

For rbind column names are taken from the first argument with appropriate names: colnames for a matrix, or names for a vector of length the number of columns of the result.
rbind列名取自适当的名称的第一个参数:矩阵colnames,结果列的数目或名称长度的向量。


数据框的方法----------Data frame methods----------

The cbind data frame method is just a wrapper for data.frame(..., check.names = FALSE).  This means that it will split matrix columns in data frame arguments, and convert character columns to factors unless stringsAsFactors = FALSE is specified.
cbind数据框的方法仅仅是一个data.frame(..., check.names = FALSE)的包装。这意味着,在数据框的参数,它会分裂矩阵的列,除非stringsAsFactors = FALSE指定字符列转换因素。

The rbind data frame method first drops all zero-column and zero-row arguments.  (If that leaves none, it returns the first argument with columns otherwise a zero-column zero-row data frame.) It then takes the classes of the columns from the first data frame, and matches columns by name (rather than by position).  Factors have their levels expanded as necessary (in the order of the levels of the levelsets of the factors encountered) and the result is an ordered factor if and only if all the components were ordered factors.  (The last point differs from S-PLUS.)  Old-style categories (integer vectors with levels) are promoted to factors.
rbind数据框的方法,首次降到零列零排参数。 (如果说离开没有,它返回的列,否则一个零列零行的数据框的第一个参数。),然后从第一个数据框的列类,和匹配列名称(而不是位置) 。因素,有必要扩大自己的水平(秩序的遇到因素levelsets的水平),结果是一个有序的因素,当且仅当所有的组件被勒令因素。 (最后一点不同,S-PLUS)。旧风格的类别(整数向量与水平)促进因素。


派遣----------Dispatch----------

The method dispatching is not done via UseMethod(), but by C-internal dispatching. Therefore there is no need for, e.g., rbind.default.
不这样做,通过UseMethod(),但由C-内部调度方法调度。因此,有没有需要,例如,rbind.default。

The dispatch algorithm is described in the source file (".../src/main/bind.c") as
调度算法中描述的源文件(.../src/main/bind.c)

For each argument we get the list of possible class memberships from the class attribute.
对于每个参数,我们得到可能的类成员的名单,从阶级属性。

We inspect each class in turn to see if there is an applicable method.
我们检查每个类依次是看是否有适用的方法。

If we find an applicable method we make sure that it is identical to any method determined for prior arguments. If it is identical, we proceed, otherwise we immediately drop through to the default code.
如果我们找到一个适用的方法,我们要确保这是事先论证确定的任何方法相同。如果是相同的,我们继续,否则,我们立即下降到默认的代码。

If you want to combine other objects with data frames, it may be necessary to coerce them to data frames first.  (Note that this algorithm can result in calling the data frame method if all the arguments are either data frames or vectors, and this will result in the coercion of character vectors to factors.)
如果你想与数据框相结合的其他对象,它可能是必要的,强迫他们第一个数据框。 (请注意,该算法能导致在调用数据框的方法,如果所有的参数数据框或向量,这将导致在胁迫因素的特征向量。)


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

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

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

c to combine vectors (and lists) as vectors, data.frame to combine vectors and matrices as a data frame.
c作为向量相结合的向量(名单),data.frame结合向量和矩阵作为一个数据框。


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


m &lt;- cbind(1, 1:7) # the '1' (= shorter vector) is recycled[1(=短向量)被回收]
m
m &lt;- cbind(m, 8:14)[, c(1, 3, 2)] # insert a column[插入一列]
m
cbind(1:7, diag(3))# vector is subset -&gt; warning[向量的子集 - >警告]

cbind(0, rbind(1, 1:3))
cbind(I=0, X=rbind(a=1, b=1:3))  # use some names[使用一些名字]
xx <- data.frame(I=rep(0,2))
cbind(xx, X=rbind(a=1, b=1:3))   # named differently[不同的名称]

cbind(0, matrix(1, nrow=0, ncol=4))#&gt; Warning (making sense)[>警告(决策意识)]
dim(cbind(0, matrix(1, nrow=2, ncol=0)))#-&gt; 2 x 1[ - > 2×1]

## deparse.level[#deparse.level]
dd <- 10
rbind(1:4, c=2, "a++" = 10, dd, deparse.level=0)# middle 2 rownames[中间2 rownames]
rbind(1:4, c=2, "a++" = 10, dd, deparse.level=1)# 3 rownames (default)[3 rownames(默认)]
rbind(1:4, c=2, "a++" = 10, dd, deparse.level=2)# 4 rownames[4 rownames]

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-1-23 02:02 , Processed in 0.034490 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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