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

R语言 xts包 to.period()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-10-2 07:28:23 | 显示全部楼层 |阅读模式
to.period(xts)
to.period()所属R语言包:xts

                                         Convert time series data to an OHLC series
                                         转换的OHLC系列的时间序列数据

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

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

Convert an OHLC or univariate object to a specified periodicity lower than the given data object. For example, convert a daily series to a monthly series, or a monthly series to a yearly one, or a one minute series to an hourly series.
转换为OHLC或单变量的对象到一个指定的周期性低于给定的数据对象。例如,每天每月系列串联,或每年每月系列,或一分钟每小时系列串联转换。

The result will contain the open and close for the given period, as well as the maximum and minimum over the new period, reflected in the new high and low, respectively.
结果将包含给定的时间内打开和关闭,以及最大和最小的在新的时期,反映在新的高点和低点分别。

If volume for a period was available, the new volume will also be calculated.
如果成交量一段时间,新的体积也将被计算。


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


to.minutes(x,k,name,...)
to.minutes3(x,name,...)
to.minutes5(x,name,...)
to.minutes10(x,name,...)
to.minutes15(x,name,...)
to.minutes30(x,name,...)
to.hourly(x,name,...)
to.daily(x,drop.time=TRUE,name,...)

to.weekly(x,drop.time=TRUE,name,...)
to.monthly(x,indexAt='yearmon',drop.time=FALSE,name,...)
to.quarterly(x,indexAt='yearqtr',drop.time=FALSE,name,...)
to.yearly(x,drop.time=TRUE,name,...)

to.period(x,
          period = 'months',
          k = 1,
          indexAt,
          name=NULL,
          OHLC = TRUE,
          ...)



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

参数:x
a univariate or OHLC type time-series object   
单变量或OHLC型时间序列对象


参数:period
period to convert to. See details.  
期间转换为。查看详细信息。


参数:indexAt
convert final index to new class or date. See details  
最终指数转换到新的类或日期。查看详细资料


参数:drop.time
remove time component of POSIX datestamp (if any)  
删除POSIX邮戳时间部分(如果有的话)


参数:k
number of sub periods to aggregate on (only for minutes and seconds)  
子期总数量(只,分和秒)


参数:name
override column names  
覆盖的列名


参数:OHLC
should an OHLC object be returned? (only OHLC=TRUE currently supported)  
OHLC对象回来了吗? (只有OHLC=TRUE目前支持)


参数:...
additional arguments  
额外的参数


Details

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

Essentially an easy and reliable way to convert one periodicity of data into any new periodicity. It is important to note that all dates will be aligned to the end of each period by default - with the exception of to.monthly and to.quarterly, which index by "yearmon" and "yearqtr" from the zoo package, respectively.
本质上是一个简单和可靠的方式转换成一个周期性的数据到任何新的周期性。重要的是要注意,默认情况下,所有的日期将对准在每个周期结束 - 除to.monthly和to.quarterly“指数”yearmon“和”yearqtr“的zoo包。

Valid period character strings include: "seconds",  "minutes", "hours", "days", "weeks", "months", "quarters", and "years". These are calculated internally via endpoints. See that function's help page for further details.
有效期字符串包括:"seconds","minutes","hours","days","weeks","months","quarters"和 "years"。这些都是通过内部计算endpoints。进一步详情,请参阅该功能的帮助页面。

To adjust the final indexing style, it is possible to set indexAt to one of the following: "yearmon", "yearqtr", "firstof", "lastof", "startof", or "endof".  The final index will then be yearmon, yearqtr, the first time of the period, the last time of the period, the starting time in the data for that period, or the ending time in the data for that period, respectively.
调整最后的索引样式,能够设置indexAt以下操作之一:yearmon,yearqtr,firstof,lastof,STARTOF,或 ; endof“。的最后索引,然后是yearmon,yearqtr“期间的第一次,也是最后一次的时期,在这期间的数据的起始时间或结束时间的数据这期间,分别。

It is also possible to pass a single time series, such as a univariate exchange rate, and return an OHLC object of lower frequency - e.g. the weekly OHLC of the daily series.
另外,也可以通过一个单一的时间系列,如单变量交换速率,并返回一个较低的频率的OHLC目的 - 例如每周OHLC每天的系列。

Setting drop.time to TRUE (the default) will convert a series that includes a time component into one with just a date index, as the time index is often of little value in lower frequency series.
设置drop.timeTRUE(默认值)将转换成一个系列,包括时间组件只是一个日期索引,随着时间的指数往往是没有什么价值较低的频率系列。

It is not possible to convert a series from a lower periodicity to a higher periodicity - e.g. weekly to daily or daily to 5 minute bars, as that would require magic.
这是不可能的一个系列转换从低级到一个更高的周期性的周期性 - 比如每周每天每天到5分钟的条形,因为这将需要魔法。


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

An object of the original type, with new periodicity.
对象的原始类型,用新的周期性。


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

In order for this function to  work properly on OHLC data, it is necessary that the Open, High, Low and Close columns be names as such; including the first letter capitalized and the full spelling found.  Internally a call is made to reorder the data into the correct column order, and then a verification step to make sure that this ordering and naming has succeeded. All other data formats must be aggregated with functions such as aggregate and period.apply.
在此功能上正常工作OHLC数据,这是必要的开盘价,最高价,最低价和收盘价列名等,包括首字母大写,找到的完整拼写。内部呼叫到正确的列顺序重新排序的数据,然后验证步骤,以确保这个顺序命名已成功。所有其他的数据格式,必须综合计算功能,如aggregate和period.apply。

This method should work on almost all time-series-like objects. Including "timeSeries", "zoo", "ts", "its", and "irts". It is even likely to work well for other data structures - including "data.frames" and "matrix" objects.
此方法应该适用于几乎所有的时间序列对象。包括“时间序列”,“动物园”,TS,,和IRTS。它甚至有可能工作以及其他数据结构 - 包括“data.frames”和“矩阵”的对象。

Internally a call to as.xts converts the original x into the universal xts format, and then re-converts back to the original type.
内部呼叫as.xts转换为原始的x到普遍xts格式,然后再转换回原始类型。

A special note with respect to "ts" objects. As these are strictly regular they may include NA values.  These are stripped for aggregation purposes, though replaced before returning. This inevitably leads to many, many additional "NA" values in the data. It is more beneficial to consider using an "xts" object originally, or converting to one in the function call by means of as.xts.
特别要TS对象。由于这些是严格的规则,他们可能包括NA值。这些被剥离的聚集,虽然替换,然后返回。这不可避免地导致了很多很多额外的“NA”数据中的值。 XTS的对象最初考虑使用,或转换为一个在函数调用的as.xts这是更有利的。


(作者)----------Author(s)----------


Jeffrey A. Ryan



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


data(sample_matrix)

samplexts <- as.xts(sample_matrix)

to.monthly(samplexts)
to.monthly(sample_matrix)

str(to.monthly(samplexts))
str(to.monthly(sample_matrix))

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-24 06:38 , Processed in 0.023188 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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