Q:

How to join without losing information?

I have several data frames with the following structure:
   january        february       march       april

   Id   A  B      Id   A  B      Id  A  B    Id   A   B
   1    4  4       1   2  3       3  9  7    1    4   3
   2    3  5       2   2  7       2  2  4    4    6   2
   3    6  8       4   9  9                  2    3   5 
   4    7  8  

I would like to bring them into one single data frame which contains ´NA´ for the missing ID' and there corresponding attributes. The results has might look like:
                Id   janA janB   febA  febB    marA marB   aprA aprB
                1     4     4     2     3       NA   NA     4    3
                2     3     5     2     7       2    4      3    5
                3     6     8     NA    NA      9    7      NA   NA
                4     7     8     9     9       NA   NA     6    2

Given some data:
           ID<-c(1,2,3,4)
           A<-c(4,3,6,7)
           B<-c(4,5,8,8)
           jan<-data.frame(ID,A,B)
           ID<-c(1,2,4)
           A<-c(2,2,9)
           B<-c(3,7,9)
           feb<-data.frame(ID,A,B)
           ID<-c(3,2)
           A<-c(9,2)
           B<-c(7,4)
           mar<-data.frame(ID,A,B)
           ID<-c(1,4,2)
           A<-c(4,6,3)
           B<-c(6,2,5)
           apr<-data.frame(ID,A,B)

What I have tried:
          test <- rbind(jan, feb,mar,apr)
          test <- rbind.fill(jan, feb, mar,apr) 

A:

You can use merge within Reduce.
First, let's prepare a list with the data and change the column names to janA, janB, febA, ...
list_df <- list(
  jan = jan,
  feb = feb,
  mar = mar,
  apr = apr
)
list_df <- lapply(names(list_df), function(name_month){
  df_month <- list_df[[name_month]]
  names(df_month)[-1] <- paste0(name_month, names(df_month)[-1])
  df_month
})

Reduce will merge all of them.
Reduce(function(x, y) merge(x, y, by = "ID", all = TRUE), list_df)

