[R] removing NA from an its object

kevin bartz kbartz at loyaltymatrix.com
Tue Jun 29 18:34:16 CEST 2004


What did you try with "apply"? It seems to work for me. I did

x2[!apply(is.na(x2), 1, any),]

and got the desired results.

Kevin

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Laura Holt
Sent: Tuesday, June 29, 2004 9:26 AM
To: r-help at stat.math.ethz.ch
Subject: [R] removing NA from an its object

Hi again!

I have the following its object:
>class(x1)
[1] "its"
attr(,"package")
[1] "its"
>x1
             FTSE     DAX
2004-06-07 4491.6 4017.81
2004-06-08 4504.8 4018.95
2004-06-09 4489.5 3997.76
2004-06-10 4486.1 4021.64
2004-06-11 4484.0 4014.56
2004-06-14 4433.2 3948.65
2004-06-15 4458.6 3987.30
2004-06-16 4491.1 4003.24
2004-06-17 4493.3 3985.46
2004-06-18 4505.8 3999.79
2004-06-21 4502.2 3989.31
2004-06-22     NA 3928.39
2004-06-23     NA 3945.10
2004-06-24     NA 4007.05
2004-06-25     NA 4013.35
2004-06-28     NA 4069.35

I want to create an its object with no NAs; that is, if there is an NA in 
any column, strike the entire row.


I did the following:
>x2 <- its(na.omit(x1))
>x2
             FTSE     DAX
2004-06-07 4491.6 4017.81
2004-06-08 4504.8 4018.95
2004-06-09 4489.5 3997.76
2004-06-10 4486.1 4021.64
2004-06-11 4484.0 4014.56
2004-06-14 4433.2 3948.65
2004-06-15 4458.6 3987.30
2004-06-16 4491.1 4003.24
2004-06-17 4493.3 3985.46
2004-06-18 4505.8 3999.79
2004-06-21 4502.2 3989.31
attr(,"na.action")
2004-06-22 2004-06-23 2004-06-24 2004-06-25 2004-06-28
        12         13         14         15         16
attr(,"class")
[1] "omit"
>class(x2) <- "its"
>

My question:  is this the best way to accomplish the goal, please?  I tried 
apply with "all" and is.na but I got strange results.

Thanks.
R Version 1.9.1
Sincerely,
Laura
mailto: lauraholt_983 at hotmail.com


Married. http://lifeevents.msn.com/category.aspx?cid=married

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html




More information about the R-help mailing list