LeonieHagitte / ShareSEM

0 stars 0 forks source link

The dataprep should be fine for now, but changes the names of variables - this should be fixed #5

Closed LeonieHagitte closed 10 months ago

LeonieHagitte commented 11 months ago

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

brandmaier commented 11 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).

brandmaier commented 11 months ago

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.

LeonieHagitte commented 10 months ago

I see - i will change this, or just rename it again( which would be a bit clunky though)

brandmaier commented 10 months ago

Please close this comment if this issue is solved, otherwise let me know where you are stuck, @LeonieHagitte .