Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does reclass function in xts package do?

Tags:

r

xts

I thought it was for turning a xts object to its original class, but after I pass an xts object into it, it did not give me the original object back. What does it for?

My attempt

data(sample_matrix)
class(sample_matrix)
#"matrix"
class(reclass(as.xts(sample_matrix)))
#"xts" "zoo"
like image 418
ChaoYang Avatar asked Oct 21 '25 21:10

ChaoYang


1 Answers

From the docs

try.xts and reclass are functions that enable external developers access to the reclassing tools within xts to help speed development of time-aware functions, as well as provide a more robust and seemless end-user experience, regardless of the end-user's choice of data-classes.

if you use try.xts to convert a xtsible object to xts object , reclass or Reclass both should be able to convert it back to it's original class with all attributes intact.

class(Reclass(try.xts(sample_matrix)))
## [1] "matrix"

class(reclass(try.xts(sample_matrix)))
## [1] "matrix"
like image 183
CHP Avatar answered Oct 23 '25 13:10

CHP