I have multiple files to concatenate its columns in a dataframe, but for each column I need to use the file name as column name. How should I do it?
For example:
In the file "amostra4A" I have two columns named "V1" and "V2", but I want to replace it for the file name and repeat the same way for the last files.
Sorry for same mistakes, I'm new in R.
Put the data frames into a list L such that the name of each data frame is the name you want to use. We will use
BODwhich comes with R. Convert the list to a data frame and change the names.That said it is normally assumed that column names in a data frame are unique and you are bound to run into subsequent problems if you do the above. Better would be to use a prefix of the A or B name followed by the column name so that the names are unique.
Note that if the data frames are sitting loose in the global environment an alternative to creating L is: