df1 and df2 have the same number of columns and the same column names. However, the column names in df2 are not in the same order.
The rownames of df2 match those in df1.
How can I generate a new df where I replace row4 and row5 of df1 with those from df2, and have the numbers replaced so that they retain the column order set in df1.
Something like this:
I've been attempting some merge() and match() functions trying to match the rows by row.names(df) with no luck. I would end up with additional columns, i.e. 6 columns after merging instead of 3, or get the addition of more rows.
If you add a column containing your row names (tibble::rownames_to_column), you can match by values in that column and by column names via dplyr::rows_upsert.