When column names have > (greater than) or < (lesser than) sign and I try to join on these columns, the column with the sign gets trimmed and I get an error like this one:
Error in colnamesInt(x, names(on), check_dups = FALSE) : argument specifying columns specify non existing column(s): cols[1]='COLUMN WITH'
Code to reproduce the issue
library(data.table)
table_a <- data.table(
`COLUMN WITH >FAILS` = character(),
BLA = integer(),
BLO = integer()
)
table_b <- data.table(
`COLUMN WITH >FAILS` = character(),
BLA = integer(),
BLI = integer(),
BLU = integer()
)
on = setdiff(names(table_a), c("BLA", "BLU", "BLO"))
table_a[table_b, on = on]
My scrappy workaround was to replace the special character before the join and put the original column name after the join, it works but doesn't look very elegant. I don't know if that is a known issue, I haven't found any documentation about this. Can you think of a better way of solving this?