Skip to content

rbind cannot handle different name encodings #5452

Description

@MEO265

In the following case, the bind does not work:

x <- data.table(A = 1, B = 2, C = 3)
y <- copy(x)
setnames(x , c("Ä", "Ö", "Ü"))
setnames(y , iconv(c("Ä", "Ö", "Ü"), from = "UTF-8", to = "latin1"))
Encoding(names(x))
Encoding(names(y))
rbind(x,y)

Output:

[1] "UTF-8" "UTF-8" "UTF-8"
[1] "latin1" "latin1" "latin1"

Error in rbindlist(l, use.names, fill, idcol) (rbindbug.R#7): Column 1 ['Ä'] of item 2 is missing in item 1. Use fill=TRUE to fill with NA (NULL for list columns), or use.names=FALSE to ignore column names.
Show stack trace
> sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)

Matrix products: default

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] data.table_1.14.2

loaded via a namespace (and not attached):
[1] compiler_4.1.2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions