0

so, I am trying to subset a file by a row number id that I gave it. parcels$row_number includes 7075 observations that run from 1-7075; miss_list is a list that has 29 of those row numbers, that I am trying to isolate. I ran this, but got the following error:

parcels_subset<- parcels%>% subset(parcels$row_number == miss_list)

In parcels$row_number == miss_list :   longer object length is not a multiple of shorter object length

Any suggestions would be appreciated! (parcels$row number and miss_list are both characters if that matters)

tchoup
  • 971
  • 4
  • 11
  • 2
    We may need `%in%` instead of `==` i..e `subset(parcels, row_number %in% miss_list)` – akrun Sep 22 '21 at 22:41
  • yep, worked perfectly. Can you help me understand why? – tchoup Sep 22 '21 at 22:42
  • 1
    See https://stackoverflow.com/questions/42637099/difference-between-the-and-in-operators-in-r – MrFlick Sep 22 '21 at 22:42
  • 1
    It is just that `==` is elementwise comparison operator. It works only when the length is 1 (recycles) or when both the lenghts are same – akrun Sep 22 '21 at 22:42

0 Answers0