I have 4 data frames that I want to merge to 1 big data frame.
They all have the same structure and same amount of columns, but some column names are a bit different, for example:
data frame 1- column name 1="dollar"
data frame 2- column name 1="Dollar"
I tried to use: colnames(df1)=colnames(df2), but each time I run the code it choses the names arbitrarily, once from data frame 1 and the next time from data frame 2.
Is there a way to merge the data frames and specify from which of the 4 data frames I want to take the column names?
If the only difference is in case you may consider standardizing the colnames() to lowercase (or uppercase, for all that matters) - and then join as required, without having to bother.
Consider this code, using the built in iris dataset (which follows a cruel and unusual naming convention).
Reg. the code snippets you a ask about, run this in your console: ?sample, ?runif and then the actual code, i.e. sample(1:10, 5) and runif(5). For a better understanding of relational data, read this chapter: https://r4ds.had.co.nz/relational-data.html