madr
2010-Dec-08 10:16 UTC
[R] how to strip list from NA values looking only at one column ?
I have got a list with 3 colums x,y,z, now I want do delete whole rows where column z has NA values I am not intereted in x and y columns if there are also NA values or not, moreover I do not want to touch them because if there would be NA that would mean a more serious error for me, and I have cath for that somewhere else I am asking because I only saw an example where function loops over all columns in a row and deletes row when any of them is NA, and that would be more time consuming I suppose than only traverse list by one column. -- View this message in context: r.789695.n4.nabble.com/how-to-strip-list-from-NA-values-looking-only-at-one-column-tp3077971p3077971.html Sent from the R help mailing list archive at Nabble.com.
jim holtman
2010-Dec-08 10:36 UTC
[R] how to strip list from NA values looking only at one column ?
Are you using a 'dataframe' instead of a 'list"? If it is a dataframe, then the following will work: df <- df[!is.na(df$z), ] # only keep rows without z == NA On Wed, Dec 8, 2010 at 5:16 AM, madr <madrazel at interia.pl> wrote:> > I have got a list with 3 colums x,y,z, now I want do delete whole rows where > column z has NA values > > I am not intereted in x and y columns if there are also NA values or not, > moreover I do not want to touch them because if there would be NA that would > mean a more serious error for me, and I have cath for that somewhere else > > I am asking because I only saw an example where function loops over all > columns in a row and deletes row when any of them is NA, and that would be > more time consuming I suppose than only traverse list by one column. > -- > View this message in context: r.789695.n4.nabble.com/how-to-strip-list-from-NA-values-looking-only-at-one-column-tp3077971p3077971.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Data Munger Guru What is the problem that you are trying to solve?