The data is sensitive and can't be published, the answer will be in the form of guesswork, which I will be perfectly happy with.
I'm trying to join a larger data.table with a smaller, and update some values. The smaller is loaded from a Excel spreadsheet via XLConnect.
The join is something like this:
d.tmp2 <- left_join(d.main, d.wb, by = c("Nr" = "Nr"))
The code executes but I don't get any matches (only NA:s), which is weird since these sample rows returns TRUE
(as it should):
d.wb[1]$Nr == d.main[39]$Nr
[1] TRUE
Edit:
The problem is solved in itself and has to do with how joins in R are handled. The encoding in the data were displayed as "Unknown" but still UTF-8 while the data table imported from Excel was explicitly set to UTF-8. Apperently it's fine to do logical comparisons with different(not really different) encodings but not joins.
Setting the encoding with iconv solved this. Still, I don't understand why logical comparisons and joins differ this much, it makes little sense to me. There is probably something I don't understand working here.