I am trying to merge various .csv files into one dataframe using the following:
df<- list.files(path = "C:/Users...", pattern = "*.csv", full.names = TRUE) %>% lapply(read_csv) %>% bind_rows clean
However, I get an error saying that I can't combine X character variable and X double variable. Is there a way I can transform one of them to a character or double variable?
Since each csv file is slightly different, from my beginners standpoint, believe that lapply would be the best in this case, unless there is an easier way to get around this.
Thank you everyone for your time and attention!
read_csv
, you can usecol_types=
to set the classes. See readr.tidyverse.org/articles/readr.html – Gaynellbind_rows
is a safe or sane approach. It would help to see a few rows from a few files to see what you mean by "slightly different". – Gaynell