coredata.xts: Extract/Replace Core Data of an xts Object

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Mechanism to extract and replace the core data of an xts object.

Usage

1
2
3
4
5
## S3 method for class 'xts'
coredata(x, fmt=FALSE, ...)

xcoredata(x,...)
xcoredata(x) <- value

Arguments

x

an xts object

fmt

should the rownames be formated in a non-standard way

value

non-core attributes to assign

...

further arguments [unused]

Details

Extract coredata of an xts object - removing all attributes except dim and dimnames and returning a matrix object with rownames converted from the index of the xts object.

The fmt argument, if TRUE, allows the internal index formatting specified by the user to be used. Alternatively, it may be a valid formatting string to be passed to format. Setting to FALSE will return the row names by simply coercing the index class to a character string in the default manner.

xcoredata is the functional complement to coredata, returning all of the attributes normally removed by coredata. Its purpose, along with the replacement function xcoredata<- is primarily for use by developers using xts to allow for internal replacement of values removed during use of non xts-aware functions.

Value

Returns either a matrix object for coredata, or a list of named attributes.

The replacement functions are called for their side-effects.

Author(s)

Jeffrey A. Ryan

See Also

coredata, xtsAttributes

Examples

1
2
3
4
data(sample_matrix)
x <- as.xts(sample_matrix, myattr=100)
coredata(x)
xcoredata(x)

Example output

Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

           Open     High      Low    Close
  [1,] 50.03978 50.11778 49.95041 50.11778
  [2,] 50.23050 50.42188 50.23050 50.39767
  [3,] 50.42096 50.42096 50.26414 50.33236
  [4,] 50.37347 50.37347 50.22103 50.33459
  [5,] 50.24433 50.24433 50.11121 50.18112
  [6,] 50.13211 50.21561 49.99185 49.99185
  [7,] 50.03555 50.10363 49.96971 49.98806
  [8,] 49.99489 49.99489 49.80454 49.91333
  [9,] 49.91228 50.13053 49.91228 49.97246
 [10,] 49.88529 50.23910 49.88529 50.23910
 [11,] 50.21258 50.35980 50.17176 50.28519
 [12,] 50.32385 50.48000 50.32385 50.41286
 [13,] 50.46359 50.62395 50.46359 50.60145
 [14,] 50.61724 50.68583 50.47359 50.48912
 [15,] 50.62024 50.73731 50.56627 50.67835
 [16,] 50.74150 50.77336 50.44932 50.48644
 [17,] 50.48051 50.60712 50.40269 50.57632
 [18,] 50.41381 50.55627 50.41278 50.41278
 [19,] 50.35323 50.35323 50.02142 50.02142
 [20,] 50.16188 50.42090 50.16044 50.42090
 [21,] 50.36008 50.43875 50.21129 50.21129
 [22,] 50.03966 50.16961 50.03670 50.16961
 [23,] 50.10953 50.26942 50.06387 50.23145
 [24,] 50.20738 50.28268 50.12913 50.24334
 [25,] 50.16008 50.16008 49.94052 50.07024
 [26,] 50.06041 50.09777 49.97267 50.01091
 [27,] 49.96586 50.00217 49.87468 49.88096
 [28,] 49.85624 49.93038 49.76308 49.91875
 [29,] 49.85477 50.02180 49.77242 50.02180
 [30,] 50.07049 50.22578 50.07049 50.22578
 [31,] 50.22448 50.41376 50.19101 50.35784
 [32,] 50.44503 50.53490 50.36064 50.36928
 [33,] 50.37219 50.46912 50.29880 50.43109
 [34,] 50.48183 50.55509 50.40203 50.55509
 [35,] 50.52389 50.69783 50.45977 50.69783
 [36,] 50.71661 50.71661 50.49865 50.49865
 [37,] 50.49322 50.69693 50.49322 50.60611
 [38,] 50.58531 50.84734 50.58531 50.81383
 [39,] 50.83331 50.89683 50.67686 50.67686
 [40,] 50.68923 50.72696 50.60707 50.69562
 [41,] 50.67849 50.91776 50.67849 50.91160
 [42,] 50.88990 50.96653 50.83604 50.96653
 [43,] 50.90056 51.00299 50.87935 50.90106
 [44,] 50.95283 51.04699 50.80317 51.04699
 [45,] 51.06330 51.11401 50.94681 51.05185
 [46,] 51.12879 51.12879 51.00613 51.02164
 [47,] 50.97722 51.13653 50.95260 51.13653
 [48,] 51.18414 51.32090 51.13713 51.15151
 [49,] 51.29502 51.32342 51.13524 51.17899
 [50,] 51.13725 51.14940 50.93523 50.93523
 [51,] 50.92940 50.92940 50.69880 50.77325
 [52,] 50.72111 50.86597 50.65718 50.86597
 [53,] 50.84392 50.96946 50.73060 50.76498
 [54,] 50.78360 50.86453 50.76692 50.79534
 [55,] 50.78960 50.93187 50.78960 50.84776
 [56,] 50.88168 50.88168 50.75481 50.75481
 [57,] 50.74333 50.78909 50.61874 50.69206
 [58,] 50.69435 50.77091 50.59881 50.77091
 [59,] 50.81620 50.81620 50.56451 50.57075
 [60,] 50.60980 50.72061 50.50808 50.61559
 [61,] 50.73241 50.73241 50.40929 50.41033
 [62,] 50.39273 50.40881 50.24922 50.32636
 [63,] 50.26501 50.34050 50.26501 50.29567
 [64,] 50.27464 50.32019 50.16380 50.16380
 [65,] 50.14458 50.20278 49.91381 49.91381
 [66,] 49.93149 50.00364 49.84893 49.91839
 [67,] 49.92377 49.92377 49.74242 49.80712
 [68,] 49.79370 49.88984 49.70385 49.88698
 [69,] 49.83062 49.88295 49.76031 49.78806
 [70,] 49.82763 49.90311 49.67049 49.74033
 [71,] 49.69628 49.70863 49.37924 49.37924
 [72,] 49.36270 49.53735 49.30746 49.53735
 [73,] 49.57374 49.62310 49.39876 49.49600
 [74,] 49.44900 49.65285 49.42416 49.59500
 [75,] 49.55666 49.55666 49.33564 49.34714
 [76,] 49.29778 49.67857 49.29778 49.65463
 [77,] 49.62747 49.65407 49.51604 49.54590
 [78,] 49.59529 49.62003 49.42321 49.50690
 [79,] 49.49765 49.53961 49.41610 49.51807
 [80,] 49.42306 49.42306 49.31184 49.39687
 [81,] 49.27281 49.27281 48.93095 48.93095
 [82,] 48.86635 48.86635 48.52684 48.52684
 [83,] 48.50649 48.50649 48.33409 48.33973
 [84,] 48.34210 48.44637 48.28969 48.28969
 [85,] 48.25248 48.41572 48.23648 48.30851
 [86,] 48.33090 48.53595 48.33090 48.53595
 [87,] 48.59236 48.69988 48.57432 48.69988
 [88,] 48.74562 49.00218 48.74562 48.93546
 [89,] 48.95616 49.09728 48.95616 48.97490
 [90,] 48.94407 48.97816 48.80962 48.87032
 [91,] 48.90488 49.08400 48.90488 49.06316
 [92,] 49.06071 49.24525 48.96928 49.24525
 [93,] 49.22579 49.37335 49.19913 49.34736
 [94,] 49.41435 49.41435 49.30641 49.33776
 [95,] 49.33621 49.41900 49.33621 49.41900
 [96,] 49.45170 49.60950 49.45170 49.53819
 [97,] 49.54338 49.58968 49.41806 49.41806
 [98,] 49.44429 49.50234 49.33828 49.50234
 [99,] 49.55704 49.78776 49.55704 49.76984
[100,] 49.74550 49.81925 49.74550 49.74623
[101,] 49.75079 49.75470 49.61732 49.72996
[102,] 49.70708 49.85332 49.69245 49.73339
[103,] 49.74154 49.77340 49.70159 49.75552
[104,] 49.74707 49.79341 49.66299 49.70942
[105,] 49.74915 49.86289 49.71091 49.83886
[106,] 49.84698 49.95456 49.77754 49.95456
[107,] 49.93794 50.07208 49.92484 50.07208
[108,] 50.02441 50.02991 49.83945 49.83945
[109,] 49.76042 49.92847 49.69808 49.91103
[110,] 49.98954 50.20123 49.98954 50.20123
[111,] 50.31203 50.33781 50.24788 50.32556
[112,] 50.32009 50.32009 49.87574 49.88539
[113,] 49.87340 49.90184 49.72769 49.72769
[114,] 49.73385 49.88622 49.73385 49.88472
[115,] 49.89064 49.89064 49.74899 49.79201
[116,] 49.80530 49.80530 49.50814 49.50814
[117,] 49.54688 49.55497 49.29186 49.29186
[118,] 49.30289 49.30289 49.05676 49.13529
[119,] 49.13825 49.33974 49.11500 49.33974
[120,] 49.34572 49.52635 49.34572 49.47138
[121,] 49.47062 49.47062 49.34261 49.38521
[122,] 49.46328 49.69097 49.46328 49.58677
[123,] 49.59963 49.59963 49.41375 49.41375
[124,] 49.38428 49.40266 49.10310 49.10310
[125,] 49.16606 49.45999 49.16606 49.45999
[126,] 49.49188 49.49188 49.13572 49.13572
[127,] 49.13282 49.25507 49.13282 49.18930
[128,] 49.17739 49.17739 48.72708 48.72708
[129,] 48.83479 48.84549 48.38001 48.38001
[130,] 48.25456 48.25456 47.96904 47.96904
[131,] 47.96813 48.03286 47.89262 48.01935
[132,] 48.05550 48.05550 47.66209 47.66209
[133,] 47.64469 47.72505 47.58212 47.65930
[134,] 47.60647 47.74053 47.51796 47.72686
[135,] 47.72065 47.90717 47.70913 47.86683
[136,] 47.79430 47.79430 47.55140 47.62938
[137,] 47.65013 47.75117 47.65013 47.68423
[138,] 47.65552 47.77986 47.60536 47.60536
[139,] 47.56210 47.93085 47.56210 47.93085
[140,] 47.96582 48.02903 47.78072 47.78072
[141,] 47.81830 47.94825 47.81155 47.82946
[142,] 47.93593 48.08242 47.88763 47.90068
[143,] 47.89041 48.03077 47.88413 48.01130
[144,] 47.98234 48.17543 47.94507 48.16058
[145,] 48.14521 48.14521 47.92649 47.99613
[146,] 48.01018 48.02166 47.90193 47.90193
[147,] 47.90142 47.93398 47.64718 47.64718
[148,] 47.65665 47.89342 47.65446 47.87252
[149,] 47.78866 47.93267 47.78866 47.83291
[150,] 47.82845 47.84044 47.73780 47.73780
[151,] 47.74432 47.74432 47.54820 47.65123
[152,] 47.60223 47.74542 47.56796 47.72569
[153,] 47.71215 47.71215 47.50198 47.50198
[154,] 47.51516 47.53545 47.32342 47.37642
[155,] 47.41090 47.48217 47.21116 47.22930
[156,] 47.36581 47.41233 47.23306 47.40048
[157,] 47.42099 47.50637 47.35320 47.45262
[158,] 47.48449 47.53089 47.42814 47.48360
[159,] 47.38669 47.74770 47.38669 47.74770
[160,] 47.74899 47.74899 47.28685 47.28685
[161,] 47.27807 47.30884 47.14660 47.14660
[162,] 47.19411 47.41834 47.18153 47.41834
[163,] 47.46135 47.52004 47.43083 47.43083
[164,] 47.43279 47.43279 47.33490 47.34884
[165,] 47.33306 47.40490 47.26157 47.36779
[166,] 47.36452 47.40463 47.26056 47.26056
[167,] 47.24783 47.47249 47.24783 47.39521
[168,] 47.43470 47.56336 47.36424 47.36424
[169,] 47.46055 47.73353 47.46055 47.67220
[170,] 47.71126 47.81759 47.66843 47.66843
[171,] 47.71012 47.71012 47.61106 47.62921
[172,] 47.56849 47.59266 47.32549 47.32549
[173,] 47.22873 47.24771 47.09144 47.24771
[174,] 47.23996 47.30287 47.20932 47.22764
[175,] 47.20471 47.42772 47.13405 47.42772
[176,] 47.44300 47.61611 47.44300 47.61611
[177,] 47.62323 47.71673 47.60015 47.62769
[178,] 47.67604 47.70460 47.57241 47.60716
[179,] 47.63629 47.77563 47.61733 47.66471
[180,] 47.67468 47.94127 47.67468 47.76719
$index
  [1] 1167696000 1167782400 1167868800 1167955200 1168041600 1168128000
  [7] 1168214400 1168300800 1168387200 1168473600 1168560000 1168646400
 [13] 1168732800 1168819200 1168905600 1168992000 1169078400 1169164800
 [19] 1169251200 1169337600 1169424000 1169510400 1169596800 1169683200
 [25] 1169769600 1169856000 1169942400 1170028800 1170115200 1170201600
 [31] 1170288000 1170374400 1170460800 1170547200 1170633600 1170720000
 [37] 1170806400 1170892800 1170979200 1171065600 1171152000 1171238400
 [43] 1171324800 1171411200 1171497600 1171584000 1171670400 1171756800
 [49] 1171843200 1171929600 1172016000 1172102400 1172188800 1172275200
 [55] 1172361600 1172448000 1172534400 1172620800 1172707200 1172793600
 [61] 1172880000 1172966400 1173052800 1173139200 1173225600 1173312000
 [67] 1173398400 1173484800 1173571200 1173657600 1173744000 1173830400
 [73] 1173916800 1174003200 1174089600 1174176000 1174262400 1174348800
 [79] 1174435200 1174521600 1174608000 1174694400 1174780800 1174867200
 [85] 1174953600 1175040000 1175126400 1175212800 1175299200 1175385600
 [91] 1175472000 1175558400 1175644800 1175731200 1175817600 1175904000
 [97] 1175990400 1176076800 1176163200 1176249600 1176336000 1176422400
[103] 1176508800 1176595200 1176681600 1176768000 1176854400 1176940800
[109] 1177027200 1177113600 1177200000 1177286400 1177372800 1177459200
[115] 1177545600 1177632000 1177718400 1177804800 1177891200 1177977600
[121] 1178064000 1178150400 1178236800 1178323200 1178409600 1178496000
[127] 1178582400 1178668800 1178755200 1178841600 1178928000 1179014400
[133] 1179100800 1179187200 1179273600 1179360000 1179446400 1179532800
[139] 1179619200 1179705600 1179792000 1179878400 1179964800 1180051200
[145] 1180137600 1180224000 1180310400 1180396800 1180483200 1180569600
[151] 1180656000 1180742400 1180828800 1180915200 1181001600 1181088000
[157] 1181174400 1181260800 1181347200 1181433600 1181520000 1181606400
[163] 1181692800 1181779200 1181865600 1181952000 1182038400 1182124800
[169] 1182211200 1182297600 1182384000 1182470400 1182556800 1182643200
[175] 1182729600 1182816000 1182902400 1182988800 1183075200 1183161600
attr(,"tzone")
[1] ""
attr(,"tclass")
[1] "POSIXct" "POSIXt" 

$.indexCLASS
[1] "POSIXct" "POSIXt" 

$tclass
[1] "POSIXct" "POSIXt" 

$.indexTZ
[1] ""

$tzone
[1] ""

$myattr
[1] 100

$class
[1] "xts" "zoo"

xts documentation built on May 2, 2019, 5:18 p.m.