[R-SIG-Finance] xts and na.omit "unsupported type"

Jose Iparraguirre D'Elia Jose at erini.ac.uk
Thu Dec 10 15:29:57 CET 2009


Hello Fabrizio,

I guess that the problem lies in the class of object you create with
xts. 
na.omit works with data frames, etc., but not with the xts class.
So, I would do the following (it worked):

library(xts)
x = xts(1:10,as.Date(1:10))
y = xts(c(NA,9:1),as.Date(1:10))

> na.omit(as.data.frame(x>y))
              V1
1970-01-03 FALSE
1970-01-04 FALSE
1970-01-05 FALSE
1970-01-06 FALSE
1970-01-07  TRUE
1970-01-08  TRUE
1970-01-09  TRUE
1970-01-10  TRUE
1970-01-11  TRUE

Work from here. Hope this helps,

Jose


-----Original Message-----
From: r-sig-finance-bounces at stat.math.ethz.ch
[mailto:r-sig-finance-bounces at stat.math.ethz.ch] On Behalf Of Fabrizio
Pollastri
Sent: 10 December 2009 14:12
To: r-sig-finance at stat.math.ethz.ch
Subject: [R-SIG-Finance] xts and na.omit "unsupported type"

Hello,
I have to remove NAs from a logical xts, but I get the error:

Error in na.omit.xts(x > y) : unsupported type

Example code:

library(xts)
x = xts(1:10,as.Date(1:10))
y = xts(c(NA,9:1),as.Date(1:10))
na.omit(x > y)

What I am missing?

Kind regards,
Fabrizio Pollastri

_______________________________________________
R-SIG-Finance at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.



More information about the R-SIG-Finance mailing list