Closed LeonieHagitte closed 10 months ago
This usually happens if you have columns with identical names across both datasets. Typical solution is to remove the duplicate columns before merging (unless they really are different things, then rename them before merging).
One possible solution:
dup_col_ids <- which(names(df1) %in% names(df2))
df1 <- df1[,-dup_col_ids]
However, note that this removes all duplicate column names. If you merge on columns with the same name in both datasets (e.g., ID), this will also be removed. Thus, you would have to remove the index of the ID column from dup_col_ids
before dropping the columns.
I see - i will change this, or just rename it again( which would be a bit clunky though)
Please close this comment if this issue is solved, otherwise let me know where you are stuck, @LeonieHagitte .
when mering the dfs ( i presume) the variable names get changed, by adding the suffix ".x" e.g. gender and yrbirth - this becomes an issue when trying to convert the df into an mx-object later on - a solution, without renaming it again after the merge would be nice. @brandmaier