在 read_csv() 中,如何结合使用 `col_names = TRUE` 和 `col_character`
In read_csv(), how to combine use `col_names = TRUE` and `col_character`
在 readr 中,使用参数 col_names = TRUE
和 col_character
结合使用,如下代码 3,它失败了,错误消息如附图所示。任何人都可以帮忙吗?谢谢!
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)
将它环绕在 cols
周围,例如
readr::read_csv("a,b,c
1,2,3
4,5,6",
col_names = TRUE,
col_types = readr::cols(.default = col_character())
)
在 readr 中,使用参数 col_names = TRUE
和 col_character
结合使用,如下代码 3,它失败了,错误消息如附图所示。任何人都可以帮忙吗?谢谢!
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)
将它环绕在 cols
周围,例如
readr::read_csv("a,b,c
1,2,3
4,5,6",
col_names = TRUE,
col_types = readr::cols(.default = col_character())
)