Hi R community. I have 10 excel files having same column names with single sheets in each file. How can I combine the into one single file using R?
I want to know how to code after the portion shown below.
there are several options here. One solution could be to use lapply() with a list of the relevant sheets (e.g. generated with list.files()) and the function read_excel() you already used. This will result in a list of data.frames, which can be combined using e.g. data.table::rbindlist(). This functions takes the list as an argument and you can tell it to add an id column (which will be numeric 1:length(list)). You will have to specify the corresponding values of your Id column with an data.table::fcase() or dplyr::case_when() statement, if you wish not to keep the numeric default.