Error: Can't combine `date` <date> and `date` <character>.

I have many of csv files that want to merged them and when merged them to I get this error Error: Can't combine `date` <date> and `date` <character>.
how can fix it?

path <- "myPath"
merged_df <- list.files(path = path,
                        pattern = "\\.csv$",
                        full.names = TRUE) %>% 
    set_names() %>%  
    map_dfr(read_csv, .id = "file_name") %>% 

With read_csv() you can set the column type when reading a file. If col_type=NULL the function will guess based on the top 1000 rows. It sounds like read_csv is reading a column as diffent types and map_dfr is trying to combine those rows. You can pass the additional argument col_type withinmap_dft based on whatever column hold the date information.

I would read everything as.character(). See ?read_csv for a better explanation of how to use col_type=

1 Like

thanks, but how can use this argument in up code?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.