I am merging 10 CSV files using R. before I merge I add some columns which were not present in the original ones.
path = "C:\Users\User\Documents\data\Reports"
combined <- list.files(path=path,
pattern="*.csv",
full.names = TRUE) %>%
lapply(read_csv) %>%
bind_rows
write.csv(combined,"C:\Users\User\Documents\data\Reports\Reports_merged.csv", row.names = FALSE)
However, when I merge I get the following error:
Error in stop_vctrs(message, class = c(class, "vctrs_error_incompatible"),
More details:
Rows: 2187 Columns: 29
-- Column specification --------------------------------------------------------------
Delimiter: ","
chr (12): id, title, text, user_pseudo_id, course_id, topic_id, commentable_id, c...
dbl (2): sentiment, Year
lgl (13): video_timestamp, video_id, accepted_answer_id, collab_space_id, collab_...
dttm (2): created_at, updated_at
i Use `spec()` to retrieve the full column specification for this data.
i Specify the column types or set `show_col_types = FALSE` to quiet this message.
Warning: One or more parsing issues, see `problems()` for details
Rows: 19141 Columns: 29
-- Column specification --------------------------------------------------------------
Delimiter: ","
chr (14): id, title, text, user_pseudo_id, course_id, topic_id, commentable_id, c...
dbl (2): sentiment, Year
lgl (11): video_timestamp, video_id, accepted_answer_id, collab_space_id, collab_...
dttm (2): created_at, updated_at
i Use `spec()` to retrieve the full column specification for this data.
i Specify the column types or set `show_col_types = FALSE` to quiet this message.
Warning: One or more parsing issues, see `problems()` for details
Rows: 11640 Columns: 29
-- Column specification --------------------------------------------------------------
Delimiter: ","
chr (19): id, title, text, user_pseudo_id, created_at, updated_at, accepted_answer...
dbl (2): sentiment, Year
lgl (8): video_timestamp, video_id, file_id, answer_prediction, sticky, deleted, ...
i Use `spec()` to retrieve the full column specification for this data.
i Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 14283 Columns: 29
-- Column specification --------------------------------------------------------------
Delimiter: ","
chr (18): id, title, text, user_pseudo_id, accepted_answer_id, course_id, collab_...
dbl (3): answer_prediction, sentiment, Year
lgl (6): video_timestamp, video_id, file_id, sticky, deleted, closed
dttm (2): created_at, updated_at
i Use `spec()` to retrieve the full column specification for this data.
i Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 19983 Columns: 29
-- Column specification --------------------------------------------------------------
Delimiter: ","
chr (18): id, title, text, user_pseudo_id, accepted_answer_id, course_id, collab_...
dbl (4): video_timestamp, answer_prediction, sentiment, Year
lgl (5): video_id, file_id, sticky, deleted, closed
dttm (2): created_at, updated_at
i Use `spec()` to retrieve the full column specification for this data.
i Specify the column types or set `show_col_types = FALSE` to quiet this message.
Warning: One or more parsing issues, see `problems()` for details
Rows: 29448 Columns: 29
-- Column specification --------------------------------------------------------------
Delimiter: ","
chr (18): id, title, text, user_pseudo_id, accepted_answer_id, course_id, collab_...
dbl (4): video_timestamp, answer_prediction, sentiment, Year
lgl (5): video_id, file_id, sticky, deleted, closed
dttm (2): created_at, updated_at
i Use `spec()` to retrieve the full column specification for this data.
i Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 15266 Columns: 29
-- Column specification --------------------------------------------------------------
Delimiter: ","
chr (18): id, title, text, user_pseudo_id, accepted_answer_id, course_id, collab_...
dbl (3): video_timestamp, sentiment, Year
lgl (6): video_id, file_id, answer_prediction, sticky, deleted, closed
dttm (2): created_at, updated_at
i Use `spec()` to retrieve the full column specification for this data.
i Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 18871 Columns: 29
-- Column specification --------------------------------------------------------------
Delimiter: ","
chr (18): id, title, text, user_pseudo_id, accepted_answer_id, course_id, collab_...
dbl (3): video_timestamp, sentiment, Year
lgl (6): video_id, file_id, answer_prediction, sticky, deleted, closed
dttm (2): created_at, updated_at
i Use `spec()` to retrieve the full column specification for this data.
i Specify the column types or set `show_col_types = FALSE` to quiet this message.
Warning: One or more parsing issues, see `problems()` for details
Rows: 31080 Columns: 29
-- Column specification --------------------------------------------------------------
Delimiter: ","
chr (15): id, title, text, user_pseudo_id, accepted_answer_id, course_id, topic_i...
dbl (3): video_timestamp, sentiment, Year
lgl (9): video_id, collab_space_id, collab_space_title, file_id, answer_predicti...
dttm (2): created_at, updated_at
i Use `spec()` to retrieve the full column specification for this data.
i Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 10345 Columns: 29
-- Column specification --------------------------------------------------------------
Delimiter: ","
chr (18): id, title, text, user_pseudo_id, accepted_answer_id, course_id, collab_...
dbl (3): video_timestamp, sentiment, Year
lgl (6): video_id, file_id, answer_prediction, sticky, deleted, closed
dttm (2): created_at, updated_at
i Use `spec()` to retrieve the full column specification for this data.
i Specify the column types or set `show_col_types = FALSE` to quiet this message.
Error in `stop_vctrs()`:
! Can't combine `created_at` <datetime<UTC>> and `created_at` <character>.
Backtrace:
1. ... %>% bind_rows
2. dplyr::bind_rows(.)
3. vctrs::vec_rbind(!!!dots, .names_to = .id)
4. vctrs `<fn>`()
5. vctrs::vec_default_ptype2(...)
...
9. vctrs `<fn>`()
10. vctrs::vec_default_ptype2(...)
11. vctrs::stop_incompatible_type(...)
12. vctrs:::stop_incompatible(...)
13. vctrs:::stop_vctrs(...)
But I have these two columns in datetime
format in the original ones. It is a bit annoying as to which file this error is in.
Attaching the session Information:
> sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)
Matrix products: default
locale:
[1] LC_COLLATE=English_India.1252
[2] LC_CTYPE=English_India.1252
[3] LC_MONETARY=English_India.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_India.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base
other attached packages:
[1] data.table_1.14.0 magrittr_2.0.1
[3] googleLanguageR_0.3.0 forcats_0.5.1
[5] stringr_1.4.0 dplyr_1.0.5
[7] purrr_0.3.4 readr_2.1.2
[9] tidyr_1.1.3 tibble_3.1.0
[11] ggplot2_3.3.6 tidyverse_1.3.1
[13] textcat_1.0-7
loaded via a namespace (and not attached):
[1] fs_1.5.0 lubridate_1.7.10
[3] bit64_4.0.5 httr_1.4.2
[5] googleAuthR_2.0.0 tools_4.0.5
[7] backports_1.2.1 utf8_1.2.1
[9] R6_2.5.0 DBI_1.1.1
[11] colorspace_2.0-0 withr_2.4.1
[13] tidyselect_1.1.0 bit_4.0.4
[15] curl_4.3 compiler_4.0.5
[17] sentimentr_2.9.0 franc_1.1.4
[19] cli_3.3.0 rvest_1.0.0
[21] xml2_1.3.2 NLP_0.2-1
[23] slam_0.1-48 scales_1.1.1
[25] tm_0.7-8 askpass_1.1
[27] digest_0.6.27 rmarkdown_2.14
[29] base64enc_0.1-3 pkgconfig_2.0.3
[31] htmltools_0.5.2 tau_0.0-23
[33] dbplyr_2.1.1 fastmap_1.1.0
[35] rlang_1.0.2 readxl_1.3.1
[37] rstudioapi_0.13 generics_0.1.0
[39] jsonlite_1.7.2 qdapRegex_0.7.5
[41] vroom_1.5.7 textclean_0.9.3
[43] Rcpp_1.0.8.3 munsell_0.5.0
[45] fansi_0.4.2 lifecycle_1.0.0
[47] stringi_1.5.3 yaml_2.2.1
[49] grid_4.0.5 parallel_4.0.5
[51] crayon_1.4.1 slider_0.2.1
[53] haven_2.4.1 hms_1.0.0
[55] knitr_1.31 pillar_1.6.0
[57] stopwords_2.2 reprex_2.0.0
[59] glue_1.6.2 evaluate_0.14
[61] modelr_0.1.8 vctrs_0.3.6
[63] lexicon_1.2.1 tzdb_0.3.0
[65] cellranger_1.1.0 gtable_0.3.0
[67] openssl_1.4.3 assertthat_0.2.1
[69] cachem_1.0.4 xfun_0.22
[71] syuzhet_1.0.6 broom_0.7.6
[73] gargle_1.2.0 memoise_2.0.0
[75] warp_0.2.0 ISOcodes_2021.02.24
[77] ellipsis_0.3.2