How to manipulate how readr::type_convert handle columns with empty text?

25 Views Asked by At

I would like to modfy the type_convert() function in readr package to set columns with empty variables to col_character() in stead of col_logical(). Any suggestions?

How it works:

str(readr::type_convert(data.frame(a = c("", ""), b = c("", "a"))))
# cols(
#  a = col_logical(),
#  b = col_character()
# )
#
# 'data.frame': 2 obs. of  2 variables:
#  $ a: logi  NA NA
#  $ b: chr  NA "a"

How I would like it to work:

str(readr::type_convert(data.frame(a = c("", ""), b = c("", "a")), some_tricky_setting))
# cols(
#  a = col_character(),
#  b = col_character()
# )
#
# 'data.frame': 2 obs. of  2 variables:
#  $ a: chr  NA NA
#  $ b: chr  NA "a"
0

There are 0 best solutions below