ti(tis)
ti()所属R语言包:tis
Time Index Objects
时间索引对象
译者:生物统计家园网 机器人LoveR
描述----------Description----------
The function ti is used to create time index objects, which are useful for date calculations and as indexes for tis (time indexed series).
函数ti用于创建索引对象,这是有用日期计算和tis(时间索引系列的索引)。
as.ti and asTi coerce an object to a time index, the difference being that as.ti calls the constructor ti, while asTi simply forces the class of its argument to be "ti" without any checking as to whether or not it makes sense to do so.
as.ti和asTi强制转换为对象的时间指标,所不同的是,as.ti调用构造函数ti,而asTi只是强迫之类的参数“台独”没有任何检查是否这样做是有意义的。
is.ti tests whether an object is a time index.
is.ti测试一个对象是否是一个指数。
couldBeTi tests whether or not x is numeric and has all elements within the range expected for a ti time index with the given tif. If tif is NULL (the default), the test is whether or not x could be a ti of any frequency. If so, it can be safely coerced to class ti by as.ti.
couldBeTi测试是否x是数字,有一个ti时间指数的tif预期的范围内的所有元素。如果tif是NULL(默认值),测试是否x可能是一个ti的任何频率。如果是这样的话,它可以安全地强制转换为类tias.ti。
用法----------Usage----------
ti(x, ...)
## S3 method for class 'Date'
ti(x, ...)
## Default S3 method:[默认方法]
ti(x, tif = NULL, freq = NULL, ...)
## S3 method for class 'jul'
ti(x, tif = NULL, freq = NULL, hour = 0, minute = 0, second = 0, ...)
## S3 method for class 'ssDate'
ti(x, ...)
## S3 method for class 'ti'
ti(x, tif = NULL, freq = NULL, ...)
## S3 method for class 'tis'
ti(x, ...)
## S3 method for class 'yearmon'
ti(x, ...)
## S3 method for class 'yearqtr'
ti(x, ...)
as.ti(x, ...)
asTi(x)
is.ti(x)
couldBeTi(x, tif = NULL)
参数----------Arguments----------
参数:x
object to be tested (is.ti) or converted into a ti object. As described in the details below, the constructor function ti can deal with several different kinds of x.
要测试的对象(is.ti),或转换成一个ti对象的。在下面的详细信息,构造函数ti可以处理几种不同类型的x。
参数:hour
used if and only if tif is an intraday frequency
用于当且仅当tif是盘中频率
参数:minute
used if and only if tif is an intraday frequency
用于当且仅当tif是盘中频率
参数:second
used if and only if tif is an intraday frequency
用于当且仅当tif是盘中频率
参数:...
other args to be passed to the method called by the generic function.
其他ARGS要传递给调用的方法的通用功能。
参数:tif
a ti Frequency, given as either a numerical code or a string. tif() with no arguments returns a list of the allowable numerical codes and names. Either tif or freq must be supplied for the variants of ti().
的Ti的频率,给定的数字代码或一个字符串。 tif()不带任何参数,返回一个列表,允许的数字代码和名称。无论是tif或freq必须提供的变种ti()。
参数:freq
some tif's can alternatively be specified by their frequency, such as 1 (annual), 2 (semiannual), 4 (quarterly), 6 (bimonthly), 12 (monthly), 24 (semimonthly), 26 (biweekly), 36 (tenday), 52 (weekly), 262 (business) and 365 (daily). Either tif or freq must be supplied for the variants of ti().
一些tifs可以选择指定用它们的频率,如1(年),2(每半年一次),4(季刊),6(双月刊),12(月刊),24(半月刊),26(双周),36(10天),52(每周一次),262(业务)和365(每日)。无论是tif或freq必须提供的变种ti()。
Details
详细信息----------Details----------
A ti has a tif (ti Frequency) and a period. The period represents the number of periods elapsed since the base period for that frequency. Adding or subtracting an integer to a ti gives another ti. Provided their corresponding element have matching tifs, the comparison operators <, >, <=, >=, == all work, and subtracting one ti from another gives the number of periods between them. See the examples section below.
Atitif(TI频率)和一个句点。本期间之数,频率为基期以来经过的时间段。添加或减去一个整数到一个ti给出了另一种ti。提供其相应的元素,具有匹配的tif的,比较运算符<, >, <=, >=, ==所有的工作,并减去1ti从另一个给出了它们之间的周期数。请参阅下面的示例一节。
The ti class implements methods for a number of generic functions, including "[", as.Date, as.POSIXct, as.POSIXlt, c, cycle, edit, format, frequency, jul, max, min, print, rep, seq, tif, tifName, time, ymd.
ti类实现方法的一些通用功能,包括"[",as.Date,as.POSIXct,as.POSIXlt,c,<X >,cycle,edit,format,frequency,jul,max,min,print rep,seq,tif,tifName,time。
ti is a generic function with specialized methods to handle jul, Date, ti. tis, yearmon and yearqtr objects.
ti是一个通用的功能与专门的方法来处理jul,Date,ti。 tis,yearmon和yearqtr对象。
The default method (ti.default) deals with character x by calling as.Date on it. Otherwise, it proceeds as follows:
默认的方法(ti.default)交易与字符“x通过调用as.Date就可以了。否则,它前进如下:
If x is numeric, a check is made to see if x could be a ti object that has somehow lost it's class attribute. Failing that, isYmd is used to see if it could be yyyymmdd date, then isTime is called to see if x could be a decimal time (a number between 1799 and 2200). If x is of length 2, an attempt to interpret it as a c(year, period) pair is made. Finally, if all else fails, as.Date(x) is called to attempt to create a Date object that can then be used to construct a ti.
如果x是数字,进行检查,看看x可能是一个ti对象莫名其妙地失去了它的阶级属性。做不到这一点,isYmd看,如果它可以为yyyymmdd的日期,然后isTime被称为看看x可能是一个的十进制时间(1799年和2200年之间的数字)。如果x是长度为2,试图将其解释为一个c(year, period)对。最后,如果一切都失败,as.Date(x)被称为试图创建一个Date对象,然后可以用来构建一个ti。
值----------Value----------
is.ti and couldBeTi return TRUE or FALSE.
is.ti和couldBeTi返回TRUE或FALSE。
as.ti returns a ti object.
as.ti返回一个ti对象。
asTi returns its argument with the class attribute set to "ti".
asTi返回其参数的类属性设置为“台独”。
ti constructs a ti object like x, except for two special cases:
ti构建了一个ti对象x,除了两种特殊情况:
1. If x is a tis series, the return value is a vector time index with elements corresponding to the observation periods of x.
1。如果x是tis系列,返回值是一个矢量指数与元素对应的观察期,x。
2. If x is a numeric object of length 2 interpretable as c(year, period), the return value is a single ti.
2。 x如果是一个数字对象长度为2的解释为c(year, period),返回值是一个单一的ti。
注意----------Note----------
The as.Date(x) call is not wrapped in a try-block, so it may be at the top of the stack when ti fails.
as.Date(x)调用不被包裹在try块,所以它可能是在堆栈的顶部时ti失败。
The return value from asTi is not guaranteed to be a valid ti object. For example, asTi("a") will not throw an error, and it will return the string "a" with a class attribute "ti", but that's not a valid time index.
asTi的返回值不保证有效的ti对象。例如,asTi("a")不会抛出一个错误,它会返回字符串“a”类属性“TI”,但是,这不是一个有效的时间指标。
参见----------See Also----------
jul, ymd, tif,
jul,ymd,tif,
实例----------Examples----------
z <- ti(19971231, "monthly") ## monthly ti for Dec 97[#每月TI为1997年12月]
is.ti(z) ## TRUE[#TRUE]
is.ti(unclass(z)) ## FALSE[#FALSE]
couldBeTi(unclass(z)) ## TRUE[#TRUE]
ymd(z + 4) ## 19980430[#19980430]
z - ti(c(1997,6), freq = 12) ## monthly ti for June 1997[#每月TI 1997年六月]
ti(z, tif = "wmonday") ## week ending Monday June 30, 1997[#每周截至1997年6月30日(星期一)]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|