New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A easy way to read all columns as character #148

Closed
TuSKan opened this Issue Apr 23, 2015 · 4 comments

Comments

Projects
None yet
3 participants
@TuSKan

TuSKan commented Apr 23, 2015

Hi Hadley,

I couldn't find a easier way to read all columns as a character than this:
header <- read_csv("file.csv", n_max = 1)
read_csv("file.csv", col_types = paste0(rep("c", ncol(header)), collapse = "") )
I will be great to specify just one type for all columns like that:
read_csv("file.csv", col_types = "c" )

@leoluyi

This comment has been minimized.

leoluyi commented Apr 30, 2015

Need one-for-all, auto recycled col_types argument setting, too!

It would be very helpful when one doesn't want col type to be imputed, but to keep all the data information as character for following manipulations.

@hadley

This comment has been minimized.

Member

hadley commented Sep 22, 2015

You can now do col_types = cols(.default = "c")

@leoluyi

This comment has been minimized.

leoluyi commented Oct 16, 2015

devtools::install_github("hadley/readr")
x <- "A\tB\n1\tD"
readr::read_tsv(x, col_types = cols(.default = "c"))

got this error message

Error: not compatible with STRSXP
In addition: Warning message:
Unnamed `col_types` should have the same length as `col_names`. Using smaller of the two. 

(readr version 0.1.1.9000)

@hadley

This comment has been minimized.

Member

hadley commented Oct 16, 2015

@leoluyi please open a new issue

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.