I am trying to read a csv file using readr::read_csv in R. The csv file that I am importing has about 150 columns, I am just including the first few columns for the example. I a
Yes. For example to force numeric data to be treated as characters:
examplecsv = "a,b,c\n1,2,a\n3,4,d"
read_csv(examplecsv)
# A tibble: 2 x 3
# a b c
#
#1 1 2 a
#2 3 4 d
read_csv(examplecsv, col_types = cols(b = col_character()))
# A tibble: 2 x 3
# a b c
#
#1 1 2 a
#2 3 4 d
Choices are:
col_character()
col_date()
col_time()
col_datetime()
col_double()
col_factor() # to enforce, will never be guessed
col_integer()
col_logical()
col_number()
col_skip() # to force skip column
More: http://readr.tidyverse.org/articles/readr.html