Hi,
If you read in data and only give names to some columns, then subset and filter give different results. For example, assume the following data in file test.csv
t <- read.csv( textConnection("
1,11,16,21
2,12,17,22
3,13,18,23
4,14,19,24
5,15,20,25
"), header = FALSE)
colnames(t) <- c("ID", "X")
t
# ID X NA NA
#1 1 11 16 21
#2 2 12 17 22
#3 3 13 18 23
#4 4 14 19 24
#5 5 15 20 25
subset(t, ID < 3)
# ID X NA NA.1
#1 1 11 16 21
#2 2 12 17 22
t %>% dplyr::filter(ID < 3)
# ID X NA NA
#1 1 11 16 16
#2 2 12 17 17
filter() seems to make multiple copies of the first NA column it encounters. Obviously it is unwise to name some columns and not others, but it would be safer to make filter() more idiot-proof like subset().
Best wishes,
Jim