I indexed a data.frame with a factor index instead of character an received a wrong row. I was expecting to get a warning. How can this be explained?
df<-data.frame(A=1:4, B=2:5, C=3:6, row.names = c("6", "8", "9", "19"))
ci<-row.names(df)
fi<-as.factor(ci)
df
A B C
6 1 2 3
8 2 3 4
9 3 4 5
19 4 5 6
ci[1]
[1] "6"
fi[1]
[1] 6
Levels: 19 6 8 9
df[ci[1],]
A B C
6 1 2 3
df[fi[1],]
A B C
8 2 3 4