Skip to content
Prev 306284 / 398506 Next

Rows not common in dataframes

%in% returns a logical vector. You should experiment with that operator without the indexing to complicate things for a bit to understand it.

If you read the "Introduction to R" sections on indexing, they describe three kinds of indexing. You can only use string indexing to access by name or rowname/colname. If you wish to index according to the contents of your vector/matrix/data frame, you need to find the matching data first. If you are satisfied with accessing the data in the order it appears in the object, then logical indexing is often simplest and %in% works. If you want to specify the order, or if you want to duplicate values in your output, you probably need integer indexing, in which case you need match. If you want to extract data on complex conditions (involving multiple tests) you probably need logical indexing, and cannot simultaneously specify ordering or duplication.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.
Chintanu <chintanu at gmail.com> wrote: