timeDate-class(timeDate)
timeDate-class()所属R语言包:timeDate
Class "timeDate"
类“TIMEDATE”
译者:生物统计家园网 机器人LoveR
描述----------Description----------
The class 'timeDate' represents date and time objects.
类“TIMEDATE”的代表日期和时间对象。
Details
详细信息----------Details----------
For the management of chronological objects under R three concepts are available: The first is the implementation of date and time in R's chron package neglecting locals, time zones and day light saving times. This approach is in most cases appropriate for economic time series. The second approach, available in R's base package implements the POSIX standard to date and time objects, named "POSIXt".
对于在R按时间顺序对象管理的三个概念:第一种是在R的chron包忽视了当地人,每天的时区和日光节约时间的实施日期和时间。这种方法在大多数情况下,适当的经济时间序列。第二种方法,可在R的基础包中实现了POSIX标准的日期和时间对象,名为"POSIXt"。
Unfortunately, the representation of these objects is in some cases operating system dependent and especially under MS Windows several problems appeared over the time in the management of time zones and day light saving times. Rmetrics overcomes these difficulties with POSIX objects and introduce a new S4 class of 'timeDate' objects which allow for powerful methods to represent dates and times in different financial centers around the world.
不幸的是,这些对象代表的是在某些情况下,操作系统的依赖性,尤其是在MS Windows的几个问题出现在时间管理中的时区和日日光节约时间。 Rmetrics克服了这些困难与POSIX的对象和强大的方法允许在不同的金融中心,世界各地的代表日期和时间的的“TIMEDATE对象引入一个新的S4级。
Many of the basic functionalities of these objects are in common with S-Plus' timeDate objects and thus many of your privately written functions for SPlus/FinMetrics may also be used within the R/Rmetrics environment.
许多这些对象的基本功能是在共同与S-Plus的timeDate对象,从而许多的私人编写的函数为S-PLUS / FinMetrics可能也可以用在的R / Rmetrics环境。
A major difference is the time zone concept which is replaced by the "Financial Center" concept. The FinCenter character variable specifies where you are living and at which financial center you are working. With the variable myFinCenter you can overwrite the default setting with your personal settings. With the specification of the FinCenter your system knows what rules rules for day light saving times should be applied, what is your holiday calendar, what is your currency, what are your interest rate conventions. (Not all specifications are already implemented.) Many other aspects can be easily accessed when a financial center is named. So we can distinguish between Frankfurt and Zurich, which both belong to the same time zone, but differed in DST changes in the eighties and have different holiday calendars. Futhermore, since the underlying time refers to "GMT" and DST rules and all other information is available in local (ASCII) databases, we are sure, that R/Rmetrics delivers with such a date/time concept on every computer independent of the operating systemin use, identical results.
一个主要区别是时区的概念,它被替换为“金融中心”的概念。 FinCenter字符变量指定你在哪里生活和金融中心。随着变量myFinCenter你可以覆盖默认的设置与您的个人设置。有了规范的FinCenter你的系统的人都知道,日日光节约时间的规则应适用什么规则,什么是你的假期日历,什么是货币,什么是你的利率约定。 (并非所有的规格都已经实现。)时,可以很容易地访问一个金融中心被命名为许多其他方面。因此,我们可以区分法兰克福和苏黎世,都属于同一个时区,但不同的DST的变化,在八十年代,有不同的假期日历。进一步说,因为底层的时间指的是“GMT”和DST规则和所有其他信息是在本地(ASCII)数据库,我们确信,这的R / Rmetrics提供了这样一个日期/时间概念在每一台电脑上独立的作业系统素的使用,相同的结果。
Another important feature of the "timeDate" concept used here is the fact that we don't rely on American or European ways to write dates. We use consequently the ISO-8601 standard for date and time notations. <br>
"timeDate"概念用在这里的另一个重要特征是事实,我们不依赖于美国或欧洲的方式写日期。因此,我们使用的ISO-8601标准的日期和时间表示法。参考
Generation of 'timeDate' Objects
产生的“TIMEDATE对象
We have defined a timeDate class which is in many aspects similar to the S-Plus class with the same name, but has also some important advantageous differeneces. The S4 class has four Slots, the Data slot which holds date and time as 'POSIXct' objects in the standard ISO-8601 format, the Dim slot which gives the dimension of the data object (i.e. its length), the format specification slot and the FinCenter slot which holds the name of the financial center. By default this is the value
我们已经定义了timeDate类,这是在许多方面类似于S-PLUS的一类具有相同的名称,但也有一些重要的有利differeneces。 S4类有四个插槽,Data插槽持有的日期和时间“POSIXct的对象为标准的ISO-8601格式,Dim插槽,给出了数据对象的尺寸(即其长度),format规格插槽和FinCenter插槽持有的金融中心的名称。默认情况下,这个值
Three functions allow to cgenerate date/time objects: timeDate from character vectors, timeCalendar from date and time atoms, and timeSequence from a "from/to" or from a "from/length" sequence specification. Note, time zone transformations are easily handled by by the timeDate functions which can also take timeDate and POSIXt objects as inputs, while transforming them between financial centers and/or time zones specified by the arguments zone and FinCenter. Finally the function Sys.timeDate returns current system time in form of a timeDate object.<br>
三个功能允许cgenerate日期/时间对象:timeDate特征向量,timeCalendar日期和时间原子,timeSequence一个“/”或从“ /长“序列规范。请注意,时区转换很容易处理的timeDate功能,还可以timeDate和POSIXt对象作为输入,而他们之间的金融中心和/或时区指定的参数zone和FinCenter。最后,函数Sys.timeDate返回当前系统时间的形式的timeDate对象。<BR>
Tests and Representation of timeDate Objects:
测试和表示TIMEDATE对象:
Rmetrics has implemented several methods to represent timeDate objects. For example, the print method returns the date/time in square "[]" brackets to distinguish the output from other date and time objects. On top of the date and time output the name of the FinCenter is printed. The summary method returns a printed report with information about the timeDate object. Finally, the format methods allows to transform objects into a ISO conform formatted character strings. <br>
Rmetrics已实施的几种方法,,代表timeDate对象。例如,print方法返回的日期/时间在方"[]"括号来区分其他日期和时间对象的输出。在顶部的日期和时间输出的名称FinCenter被打印出来。的总结方法返回一个印刷的与信息timeDate对象的报告。最后,格式的方法可以将对象转换为一个ISO符合格式的字符串。参考
Mathematical Operations:
数学运算:
Rmetrics supports methods to perform many mathematical operations. Included are methods to extract or to replace subsets from timeDate objects, to perform arithmetic "+" and "-" operations, to group Ops generic functions, to return suitably lagged and iterated differences diff, to return differences difftimeDate of two timeDate objects, to concatenate objects, to replicate objects, to round objects, to truncate objects using trunc, to extract the first or last entry of a vector, to sort the objects of the elements of a date/time vector, and to revert 'timeDate' vector objects, among other functions. <br>
Rmetrics支持的方法来执行许多数学运算。包括方法提取或更换的子集从timeDate对象,执行算术"+"和"-"操作,组Ops泛型函数,返回合适的滞后,迭代的差异diff,返回分歧difftimeDate两个timeDate对象中,来连接对象,复制对象,round对象,以截断使用trunc“的对象提取的第一或最后一个条目的一个向量,sort一个日期/时间向量的元素的对象,并恢复“TIMEDATE矢量对象,以及其他功能。参考
Transformation of Objects:
改造的对象:
Rmetrics has also functions to transform dat/time objects between different representations. Included are methods to transform timeDate objects to character strings, to data frames, to POSIXct or POSIXlt objects, to julian counts. One can extract date/time atoms from calendar dates, and the months atoms from a timeDate object.
Rmetrics DAT / time对象的函数来转换之间不同的表现形式。包括改造timeDate对象的字符串,数据框的方法,POSIXct或POSIXlt对象,julian计数。可以提取日期/时间atoms从日历中的日期,和months原子从timeDate对象。
类对象----------Objects from the Class----------
Objects can be created for example by calls of the functions timeDate, timeCalender and timeCalendar among others.
例如,可以创建对象通过调用的功能timeDate,timeCalender和timeCalendar等等。
插槽----------Slots----------
Data: Object of class "POSIXct": a vector of POSIXct dates and times always related to "GMT".
Data:类的对象"POSIXct":总是与“GMT”POSIXct日期和时间的向量。
format: Object of class "character": a character string denoting the format specification of the input Data character vector.
format:类的对象"character":一个字符串表示的输入数据字符向量格式规范。
FinCenter: Object of class "character": a character string with the the location of the financial center named as "continent/city", or just "city".
FinCenter:类"character":一个字符串的金融中心命名为“大陆/城市”的位置,或只是“城市”的目标。
方法----------Methods----------
show signature(object = "timeDate"): prints an object of class 'timeDate'.
显示:signature(object = "timeDate"):打印对象的类的TIMEDATE“。
注意----------Note----------
Originally, these functions were written for Rmetrics users using R and Rmetrics under Microsoft's Windows XP operating system where time zones, daylight saving times and holiday calendars are not or insuffeciently supported.
本来,这些功能是微软的Windows XP操作系统的时区,夏令时间和假期日历或insuffeciently支持下使用R和Rmetrics的Rmetrics用户编写的。
The usage of the Ical Library and the introduction of the FinCenter concept was originally develloped for R Version 1.5. The timeDate and timeSeries objects were added for R Version 1.8.1. Minor changes were made to adapt the functions for R Version 1.9.1. As a consequence, newer concepts like the Date objects were not yet considered and included in this collection of date and time concepts. With R Version 2.3.0 a major update has been made adding many new generic functions and renaming a few already existing functions, please be aware of this.
在iCal图书馆的使用和引进的FinCenter的概念最初是develloped的R版本1.5。 timeDate和timeSeries对象中增加了R版本1.8.1。进行了小的改动,以适应功能的R版本1.9.1。因此,新的概念,如Date对象尚未考虑和包含在这个集合中的日期和时间的概念。随着R版本2.3.0已经取得了重大的更新增加了许多新的泛型函数和重命名一个已经存在的功能,请意识到这一点。
Note, the date/time conversion from an arbitry time zone to GMT cannot be unique, since date/time objects appear twice during the hour when DST changes and the isdt flag was not recorded. A bookkeeping which takes care if DST is effective or not is not yet included. However, in most applications this is not necessary since the markets are closed on weekends, especially at times when DST usually changes. It is planned for the future to implement the DST supporting this facility.
请注意,从arbitry时区的日期/时间转换为GMT不能是唯一的,因为日期/时间对象的过程中出现了两次小时DST的变化和ISDT的标志时,没有记录。簿记这需要照顾,如果DST是有效的或不还未计算在内。然而,在大多数应用中,这是没有必要的,因为市场在周末关闭,特别是在的时候DST通常改变。它计划在未来实施DST支持这一设施。
The ISO-8601 midnight standard has been implemented. Note, that for example "2005-01-01 24:00:00" is accepted as a valid date/time string.
ISO-8601午夜标准已经实施。请注意,例如“2005-01-01 24:00:00”接纳为有效的日期/时间字符串。
Also available is an automated format recognition, so the user has not longer specify the format string for the most common date/time formats.
同时还提供自动格式识别,因此用户不再指定的格式字符串的最常见的日期/时间格式。
实例----------Examples----------
## Examples for Objects of class 'timeDate':[的例子对象类的TIMEDATE“:]
## timeDate -[#TIMEDATE - ]
Sys.timeDate() # direct[直接]
timeDate(Sys.time()) # transformed from "POSIX(c)t"[转变“POSIX(C)T”]
# Local Time in Zurich[在苏黎世当地时间]
timeDate(Sys.time(), FinCenter = "Zurich")
# Character Vector Strings:[字频向量的字符串:]
dts = c("1989-09-28", "2001-01-15", "2004-08-30", "1990-02-09")
dts
tms = c( "23:12:55", "10:34:02", "08:30:00", "11:18:23")
tms
t1 <- timeDate(dts, format = "%Y-%m-%d", FinCenter = "GMT" )
t1
stopifnot(identical(t1, timeDate(dts, FinC = "GMT"))) # auto-format[自动格式]
timeDate(dts, format = "%Y-%m-%d", FinCenter = "Europe/Zurich")
timeDate(paste(dts, tms), format = "%Y-%m-%d %H:%M:%S",
zone = "GMT", FinCenter = "GMT")
timeDate(paste(dts, tms),
zone = "Europe/Zurich", FinCenter = "Europe/Zurich")
timeDate(paste(dts, tms), format = "%Y-%m-%d %H:%M:%S",
zone = "GMT", FinCenter = "Europe/Zurich")
## Non Standard Format:[#非标准格式:]
timeDate(paste(20:31, "03.2005", sep="."), format = "%d.%m.%Y")
# Note, ISO and American Formats are Auto-Detected:[请注意,国际标准化组织(ISO)和美国的格式会自动检测:]
timeDate("2004-12-31", FinCenter = "GMT")
timeDate("12/11/2004", FinCenter = "GMT")
timeDate("1/31/2004") # auto-detect American format[美国格式自动检测]
## ... from POSIX?t, and Using NAs:[#...从POSIX?吨,并使用NAS:]
## lsec <- as.POSIXlt(.leap.seconds) [#LSEC < - as.POSIXlt(leap.seconds)]
## lsec[c(2,4:6)] <- NA[LSEC [C(2,4:6)] < - NA]
## timeDate(lsec)[#TIMEDATE(LSEC)]
## dtms <- paste(dts,tms)[DTM的< - 粘贴(DTS,TMS)]
## dtms[2:3] <- NA[的DTM [2:3] < - NA]
## timeDate(dtms, FinCenter = "Europe/Zurich") # but in GMT[#TIMEDATE(DTMS,FinCenter“欧洲/苏黎世”),但在格林尼治标准时间]
## timeCalendar -[#timeCalendar - ]
getRmetricsOptions("currentYear")
timeCalendar() # 12 months of current year[本年度12个月]
timeCalendar(m = c(9, 1, 8, 2), d = c(28, 15, 30, 9),
y = c(1989, 2001, 2004, 1990), FinCenter = "GMT")
timeCalendar(m = c(9, 1, 8, 2), d = c(28, 15, 30, 9),
y = c(1989, 2001, 2004, 1990), FinCenter = "Europe/Zurich")
timeCalendar(h = c(9, 14), min = c(15, 23))
## timeSequence -[#timeSequence - ]
timeSequence(from = "2004-03-12", to = "2004-04-11",
format = "%Y-%m-%d", FinCenter = "GMT")
timeSequence(from = "2004-03-12", to = "2004-04-11",
format = "%Y-%m-%d", FinCenter = "Europe/Zurich")
## print | summary | format -[#打印|摘要|格式 - 。]
tC = timeCalendar()
print(tC)
summary(tC)
format(tC)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|