Stack and reshape I don't think this maps exactly to the merge function but. In order to make the code with Reduce work, I changed the names of the y columns. When your x columns do not have the same values, a nested join will not give the desired solution: DT1]]]] If it's just those 5 datatables (where x is the same for all datatables), you could also use nested joins: # set the key for each datatable to 'x' Why does this happen, and is there any way to merge an arbitrary number of data tables with the same column names without changing any of the column names? I have a workaround, where, if I change the 2nd column name for DT1: setnames(DT1, "y", "new_y") Please remove or rename theĭuplicate(s) and try again. Reduce(function(.) merge(., all = TRUE, by = "x"), list(DT1, DT2, DT3, DT4, DT5))Įrror in (., all = TRUE, by = "x") : x has someĭuplicated column name(s): y.x,y.y. I get an error when I try to merge 5 data tables, but works fine when I merge only 4. I am trying to merge (join) multiple data tables (obtained with fread from 5 csv files) to form a single data table.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |