Используя приведенный ниже набор данных, мне не удается удалить строки со значением «Not a stewardship group» в поле «Research». Основываясь на предыдущем анализе с использованием table(X$Research)
, я знаю, что количество строк, которые следует пропустить, равно 12. Если я использую пакет dplyr для выполнения filter(X, Research == "Not a stewardship group")
, на выходе будет 12 строк с отфильтрованным значением. Однако, если я запускаю filter(X, Research != "Not a stewardship group")
, удаляется 48 строк вместо 12.
Если я выполняю X[X$Research != "Not a stewardship group",]
, количество удаленных строк считается правильным, 12.
В чем может быть причина того, что команда filter()
ведет себя подобным образом при использовании логического оператора "! ="?
data: X <- structure(list(Research = structure(c(4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, NA, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, NA, 4L, 4L, 4L, 4L, NA, 4L, NA, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, NA, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, NA, 4L, 4L, 3L, 4L, 2L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, NA, 4L, 4L, 3L, 4L, 4L, 4L, 4L, 1L, 4L, 4L, 4L, NA, 4L, NA, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L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