中文 · PDF 168
#> 2 4172 #> 3 3004 #> 4 787 #> 5 37 #> 6 2332 #> # ...还有 1,994 行
- 如果你把所有列都读成字符向量,有时会更容易诊断问题:
challenge2 <- read_csv(readr_example("challenge.csv"), col_types = cols(.default = col_character()) )
这与 type_convert() 结合使用时特别有用,后者会将解析启发式规则应用于数据框中的字符列:
df <- tribble( ~x, ~y, "1", "1.21", "2", "2.32", "3", "4.56" ) df #> # A tibble: 3 × 2 #> x y #> #> 1 1 1.21 #> 2 2 2.32 #> 3 3 4.56 # 注意列类型 type_convert(df) #> Parsed with column specification: #> cols( #> x = col_integer(), #> y = col_double() #> ) #> # A tibble: 3 × 2 #> x y #> #> 1 1 1.21 #> 2 2 2.32 #> 3 3 4.56
- 如果你要读取一个非常大的文件,可能需要将 n_max 设置为一个较小的数字,比如 10,000 或 100,000。这会在你排除常见问题的过程中加快迭代速度。