indexClass(xts)
indexClass()所属R语言包:xts
Extracting/Replacing the Class of an xts Index
取出/更换类的XTS指数
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Generic functions to extract, replace, and format the class of the index of an xts object.
通用函数来提取,替换和格式化XTS对象的索引之类的。
用法----------Usage----------
## S3 method for class 'xts'
index(x, ...)
## S3 replacement method for class 'xts'
index(x) <- value
.index(x, ...)
.index(x) <- value
indexClass(x)
indexClass(x) <- value
indexFormat(x)
indexFormat(x) <- value
convertIndex(x,value)
# time component extraction/conversion
.indexDate(x)
.indexday(x)
.indexmday(x)
.indexwday(x)
.indexweek(x)
.indexmon(x)
.indexyday(x)
.indexyear(x)
.indexhour(x)
.indexmin(x)
.indexsec(x)
参数----------Arguments----------
参数:x
xts object
XTS对象
参数:value
desired new class or format. See details
所需的新的类或格式。查看详细资料
参数:...
additional arguments (unused)
额外的参数(未使用)
Details
详细信息----------Details----------
The main accessor methods to an xts object's index is via the index and index<- replacement method. The structure of the index internally is now a numeric value corresponding to seconds since the epoch (POSIXct converted to numeric). This change allows for near native-speed matrix subsetting, as well as nearly instantaneous speed subsets by time.
主要的xts对象的索引访问方法来通过index和index<-替代方法。内部结构的索引现在是一个数值,对应于自纪元秒(POSIXct转换为数字)。这种变化使接近原生的速度矩阵子集,以及近乎瞬时的速度通过时间的子集。
A call to index translates to the desired class on-the-fly. The desired index class is stored as an attribute within the xts object. Upon a standard index call, this is used to convert the numeric value to the desired class.
index呼叫转换到所需的类的。所需的索引类作为XTS对象内的属性被存储。当一个标准的index调用,这是用来转换数字值到所需的类。
It is possible to view and set the class of the time-index of a given xts object via the indexClass function.
这是一个给定的xts对象通过时间指数之类的indexClass功能可以查看和设置。
To retrieve the raw numeric data a new accessor function (and replacement) has been added .index. This is primarily for internal use, but may be useful for end-users.
获取原始数字数据,一个新的访问函数(更换)已加入.index。这主要是为内部使用,但为最终用户可能是有用的。
.indexXXX functions are useful to extract time components of the underlying time index. The "indexClass" is virtual, and as such suitable conversions are made depending on the component requested.
.indexXXX功能是有用的,提取时间部件的基础时间指数。 indexClass是虚拟的,并且作为这样的合适的转换取决于成分要求。
The specified value for indexClass<- must be a character string containing one of the following: Date, POSIXct, chron, yearmon, yearqtr or timeDate.
指定的值indexClass<-必须是一个字符串,它包含下列操作之一:Date,POSIXct,chron,yearmon,yearqtr或timeDate。
indexFormat only manages the manner in which the object is displayed via print (also called automatically when the object is returned) and in conversion to other classes such as matrix. The valid values for indexFormat are the same for format.POSIXct, as this is the function that does the conversion internally.
indexFormat管理对象的显示方式,通过print(也称为自动返回对象时),在转换为其他类,如matrix。有效的为indexFormat值是相同的format.POSIXct,因为这是在内部进行转换的功能。
convertIndex returns a modified xts object, and does not alter the original.
convertIndex返回修改xts对象,并不会改变原来的。
Changing the index type may alter the behavior of xts functions expecting a different index, as well as the functionality of additional methods. Use with caution.
更改的索引类型,可能会改变xts功能,预期不同的索引,以及额外的方法的功能的行为。请谨慎使用。
(作者)----------Author(s)----------
Jeffrey A. Ryan
实例----------Examples----------
x <- timeBasedSeq('2010-01-01/2010-01-02 12:00')
x <- xts(1:length(x), x)
# all obs. in the first 6 and last 3 minutes of the[所有的OB。在第一个和最后3分钟]
# 8th and 15th hours on each day[第8和第15个小时的每一天]
x[.indexhour(x) %in% c(8,15) & .indexmin(x) %in% c(0:5,57:59)]
# change the index format[更改索引格式]
indexFormat(x) <- "%Y-%b-%d %H:%M:%OS3"
head(x)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|