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

R语言 zoo包 merge.zoo()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-10-2 07:52:44 | 显示全部楼层 |阅读模式
merge.zoo(zoo)
merge.zoo()所属R语言包:zoo

                                        Merge Two or More zoo Objects
                                         合并两个或多个动物园对象

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

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

Merge two zoo objects by common indexes (times), or do other versions of database join operations.
将合并两个动物园对象的常用指标(次),或其他版本的数据库的连接操作。


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


## S3 method for class 'zoo'
merge(..., all = TRUE, fill = NA, suffixes = NULL,
  check.names = FALSE, retclass = c("zoo", "list", "data.frame"),
  drop = TRUE)



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

参数:...
two or more objects, usually of class "zoo".
两个或多个对象,通常类"zoo"。


参数:all
logical vector having the same length as the number of "zoo" objects to be merged (otherwise expanded).
逻辑向量具有相同的长度作为"zoo"以被合并(否则扩大)的对象的数目。


参数:fill
an element for filling gaps in merged "zoo" objects (if any).
填补空白在合并"zoo"对象(如果有的话)的元素。


参数:suffixes
character vector of the same length as the number of "zoo" objects specifying the suffixes to be used for making the merged column names unique.
"zoo"对象指定要用于使合并的列名的独特的后缀的数目相同的长度的字符向量。


参数:check.names
See link{read.table}.
见link{read.table}。


参数:retclass
character that specifies the class of the returned result. It can be "zoo" (the default), "list" or NULL. For  details see below.
字符所指定的类,返回的结果。它可以是"zoo"(默认值),"list"或NULL。有关详细信息,请参阅下文。


参数:drop
logical. If a "zoo" object without observations is merged with a one-dimensional "zoo" object (vector or 1-column matrix), should the result be a vector (drop = TRUE) or a 1-column matrix (drop = FALSE)? The former is the default in the Merge method, the latter in the cbind method.
逻辑。如果"zoo"对象没有观测的一个一维的"zoo"对象(矢量或1列的矩阵)合并,结果应该是一个矢量(drop = TRUE)或1列矩阵(drop = FALSE)?前者是默认情况下,在Merge方法,后者在cbind方法。


Details

详细信息----------Details----------

The merge method for "zoo" objects combines the columns of several objects along the union of the dates  for all = TRUE, the default, or the intersection of their dates for all = FALSE filling up the created gaps (if any) with the fill pattern.
merge"zoo"对象的方法相结合的几个对象以及工会的日期为all = TRUE列,默认情况下,或在路口的日期all = FALSE填补了创建的空白(如果任何fill模式)。

The first argument must be a zoo object.   If any of the remaining arguments are plain vectors or matrices with the same length or number of rows as the first argument then such arguments are coerced to "zoo" using as.zoo.  If they are plain but have length 1 then they are merged after all non-scalars such that their column is filled with the value of the scalar.
第一个参数必须是一个zoo对象。如果任何其余的参数是纯向量或矩阵行的第一个参数具有相同的长度或数量,则该参数被强制为"zoo"使用as.zoo。如果他们是纯的,但有长度为1,然后将它们合并后,所有的非标量,使得它们的列填充的值的标量。

all can be a vector of the same length as the number of "zoo" objects to merged (if not, it is expanded): All indexes (times) of the objects corresponding to TRUE are included, for those corresponding to FALSE only the indexes present in all objects are included.  This allows intersection, union and left and right joins  to be expressed.
all可以是一个矢量"zoo"对象合并的(如果不是,它被扩展)的数目相同的长度为:所有的索引(倍)的相对应的对象到TRUE包括,对应FALSE中的所有对象的索引中包含。这使得交集,并集和左,右联接来表达。

If retclass is "zoo" (the default) a single merged "zoo" object is returned. If it is set to "list" a list of "zoo" objects is returned. If retclass = NULL then instead of returning a value it updates each argument (if it is a variable rather than an expression) in place so as to extend or reduce it to use the common index vector.
retclass如果是"zoo"(默认值)一个单一的合并"zoo"对象返回。如果它被设置为"list"的列表"zoo"对象被返回。如果retclass = NULL然后返回一个值,而不是它的每个参数更新(如果它是一个变量,而不是一个表达式)代替,以延长或缩短它使用普通的索引向量。

The indexes of different "zoo" objects can be of different classes and are coerced to one class in the resulting object (with a warning).
不同的"zoo"对象的索引可以是不同阶级和被强制为一个类所产生的对象(警告)。

The default cbind method is essentially the default merge method, but does not support the retclass argument. The rbind method combines the dates of the "zoo" objects (duplicate dates are not allowed) and combines the rows of the objects. Furthermore, the c method is identical to the rbind method.
默认cbind方法在本质上是默认merge方法,但不支持retclass参数。 rbind方法相结合的日期"zoo"对象(日期不得重复),并结合该行的对象。此外,c方法rbind方法是相同的。


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

An object of class "zoo" if retclass="zoo", an object of class "list" if retclass="list" or modified arguments as explained above if retclass=NULL.   If the result is an object of class "zoo" then its frequency is the common frequency of its zoo arguments, if they have a common frequency.
类的一个对象"zoo"如果retclass="zoo"“类的一个对象"list"如果retclass="list"或修改参数,如上文所述,如果retclass=NULL。如果结果是类的一个对象"zoo"那么它的频率是普通的频率其动物园参数的,如果他们有一个共同的频率。


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

zoo
zoo


实例----------Examples----------


## simple merging[#简单合并]
x.date <- as.Date(paste(2003, 02, c(1, 3, 7, 9, 14), sep = "-"))
x <- zoo(rnorm(5), x.date)

y1 <- zoo(matrix(1:10, ncol = 2), 1:5)
y2 <- zoo(matrix(rnorm(10), ncol = 2), 3:7)

## using arguments `fill' and `suffixes'[#参数的补和后缀]
merge(y1, y2, all = FALSE)
merge(y1, y2, all = FALSE, suffixes = c("a", "b"))
merge(y1, y2, all = TRUE)
merge(y1, y2, all = TRUE, fill = 0)

## if different index classes are merged, as in[#如果不同的指数类合并,如]
## the next merge example then ## a warning is issued and [#然后在未来的合并例子##警告,发行及]
### the indexes are coerced.[##的索引会被强制转换。]
## It is up to the user to ensure that the result makes sense.[#它是给用户,以确保结果是有道理的。]
merge(x, y1, y2, all = TRUE)

## extend an irregular series to a regular one:[#一个不规则的系列扩展到正规的:]
# create a constant series[创建一个常数系列]
z <- zoo(1, seq(4)[-2])
# create a 0 dimensional zoo series[创建一个0维动物园系列]
z0 <- zoo(, 1:4)
# do the extension[做扩展]
merge(z, z0)
# same but with zero fill[相同的,但与零填充]
merge(z, z0, fill = 0)

merge(z, coredata(z),  1)


## merge multiple series represented in a long form data frame [#在很长的表单数据框合并多个系列代表]
## into a multivariate zoo series and plot, one series for each site.[#多元动物园系列和图,为每个站点的一个系列。]
## Additional examples can be found here:[#例子可以在这里找到:]
## https://stat.ethz.ch/pipermail/r-help/2009-February/187094.html[#https://stat.ethz.ch/pipermail/r-help/2009-February/187094.html]
## https://stat.ethz.ch/pipermail/r-help/2009-February/187096.html[#https://stat.ethz.ch/pipermail/r-help/2009-February/187096.html]
##[#]
m &lt;- 5 # no of years[没有年]
n &lt;- 6 # no of sites[没有网站]
sites <- LETTERS[1:n]
set.seed(1)
DF <- data.frame(site = sites, year = 2000 + 1:m, data = rnorm(m*n))
tozoo <- function(x) zoo(x$data, x$year)
Data <- do.call(merge, lapply(split(DF, DF$site), tozoo))
plot(Data, screen = 1, col = 1:n, pch = 1:n, type = "o", xlab = "")
legend("bottomleft", legend = sites, lty = 1, pch = 1:n, col = 1:n)

## for each index value in x merge it with the closest index value in y[#x中的每个索引值合并它与最接近的索引值在y]
## but retaining x's times.[#但是保持x的时间。]
x<-zoo(1:3,as.Date(c("1992-12-13", "1997-05-12", "1997-07-13")))
y<-zoo(1:5,as.Date(c("1992-12-15", "1992-12-16", "1997-05-10","1997-05-19", "1997-07-13")))
f <- function(u) which.min(abs(as.numeric(index(y)) - as.numeric(u)))
ix <- sapply(index(x), f)
cbind(x, y = coredata(y)[ix])

## this merges each element of x with the closest time point in y at or[这个合并在最近的时间点y在x的每个元素]
## after x's time point (whereas in previous example it could be before[#x的时间点后(而在前面的例子中,它也可以用在]
## or after)[#或后)]
window(na.locf(merge(x, y), fromLast = TRUE), index(x))



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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-23 23:39 , Processed in 0.021705 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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