'In read_csv(), how to combine use `col_names = TRUE` and `col_character`
In readr, where combine using parameter col_names = TRUE and col_character as below code3, it's failed and the error message as attached image. Anyone can help on this ? Thanks!
library(tidyverse)
# code1 ok
read_csv("a,b,c
1,2,3
4,5,6",col_character)
# code2 ok
read_csv("a,b,c
1,2,3
4,5,6",col_names = TRUE)
# code3 :failed
read_csv("a,b,c
1,2,3
4,5,6",col_names = TRUE,col_character)
Solution 1:[1]
wrap it around cols, e.g.
readr::read_csv("a,b,c
1,2,3
4,5,6",
col_names = TRUE,
col_types = readr::cols(.default = col_character())
)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Julian |

