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 BOD which comes with R. Convert the list to a data frame and change the names.
L <- list(A = BOD, B = BOD)
DF <- as.data.frame(L)
names(DF) <- sub("\\..*", "", names(DF))
DF
## A A B B
## 1 1 8.3 1 8.3
## 2 2 10.3 2 10.3
## 3 3 19.0 3 19.0
## 4 4 16.0 4 16.0
## 5 5 15.6 5 15.6
## 6 7 19.8 7 19.8
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.
as.data.frame(L)
## A.Time A.demand B.Time B.demand
## 1 1 8.3 1 8.3
## 2 2 10.3 2 10.3
## 3 3 19.0 3 19.0
## 4 4 16.0 4 16.0
## 5 5 15.6 5 15.6
## 6 7 19.8 7 19.8
Note that if the data frames are sitting loose in the global environment an alternative to creating L is:
A <- BOD
B <- BOD
L <- mget(c("A", "B"))
dputfunction. You can find out how to use it here: youtu.be/3EID3P1oisg