row binding issue in multiple dataframes in R

12 views Asked by At

I am currently working on data from 92 countries. I have a total of 92 dataset. I want to append the 92 dataset into one dataframe. I encountered error message while using for loop to combine using bind_rows() command.I also need your suggestion on how to add a new id column to the new data frame using a filenames of each data. can you please help me with this?

filenames=list.files(
  path="data",
  full.names=TRUE
)
filenames
global_data<-filenames %>%
  lapply(read_stata) %>%
  bind_rows()

I tried this commands to read files and append using bind rows command. here are my codes:

filenames=list.files(
  path="data",
  full.names=TRUE
)
filenames
global_data<-filenames %>%
  lapply(read_stata) %>%
  bind_rows()

it gives me error message like this:

Error in `bind_rows()`:
! Can't combine `..1$site` <character> and `..5$site` <double>.
0

There are 0 answers