Search code examples
rdataframefiltersubset

Find rows with certain combination of values


I have a data frame that looks like this

iso_o iso_d FLOW FLOW_0 
  185   190   NA     NA         
  185   190   NA     NA         
  185   190   NA     NA  
  185   190    1     NA         
  185   190   NA     NA 
  185   190   NA   4249            
  185   114    1     NA 

Now I want to know which rows and the number of rows that have for example "185" in iso_o and "190" in iso_d. Can anyone point me in the right direction?


Solution

  • We can try subset

    > subset(df, iso_o == 185 & iso_d == 190)
      iso_o iso_d FLOW FLOW_0
    1   185   190   NA     NA
    2   185   190   NA     NA
    3   185   190   NA     NA
    4   185   190    1     NA
    5   185   190   NA     NA
    6   185   190   NA   4249