You are using ==
, which tests for pairwise equality (e.g., is the first row of df1$subject
equal to the first row of df2$subject
, are the second rows equal, etc.). Consider
c(1, 1, 2, 3) == c(1, 2, 3, 4)
# [1] TRUE FALSE FALSE FALSE
Instead, you want to be testing if each row of df1$subject
is in any row of df2$subject
. We can use %in%
for this:
c(1, 1, 2, 3) %in% c(1, 2, 3, 4)
# [1] TRUE TRUE TRUE TRUE
filterdata <- subset(
groupedmergedoutliers,
subject %in% filtercorrectpercent$subject
)
solved Filtering subjects below accuracy threshold in R [closed]