0

I know its a very basic question but I just don't understand why there is a difference in:

  extracted_df1 <- df_merged[df_merged$ID >69 & df_merged$ID <73 , ]
  extracted_df2 <- subset(df_merged, ID == 70:72)

With the first method I get 6574 observations and with the second method I get just 2190 observations. Why is that?

I would like to use the second method, however it seems that with this method I miss some values?!

Thanks, niki

1 Answers1

1

You should use %in%, e.g.,

subset(df_merged, ID %in% 70:72)

to check if values in ID fall within the range 70:72

ThomasIsCoding
  • 96,636
  • 9
  • 24
  • 81