I am trying to merge (join) multiple data tables (obtained with fread from 5 csv files) to form a single data table. I get an error when I try to merge 5 data tables, but wo
Using reshaping gives you a lot more flexibility in how you want to name your columns.
library(dplyr)
library(tidyr)
list(DT1, DT2, DT3, DT4, DT5) %>%
bind_rows(.id = "source") %>%
mutate(source = paste("y", source, sep = ".")) %>%
spread(source, y)
Or, this would work
library(dplyr)
library(tidyr)
list(DT1 = DT1, DT2 = DT2, DT3 = DT3, DT4 = DT4, DT5 = DT5) %>%
bind_rows(.id = "source") %>%
mutate(source = paste(source, "y", sep = ".")) %>%
spread(source, y)