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

col_types_concise(): collector for "unknown" type, cf. colClasses=NA #188

HenrikBengtsson opened this Issue Jun 9, 2015 · 0 comments


None yet
1 participant

HenrikBengtsson commented Jun 9, 2015

I'm trying out readr and I like what I see :)

I'm missing a way to specify "I let you" choose the best class for the column, cf.

> cat("a\t2\t1.2", file="foo.tsv")

> str(read.table("foo.tsv", colClasses=c("character", "integer", NA)))
'data.frame':   1 obs. of  3 variables:
 $ V1: chr "a"
 $ V2: int 2
 $ V3: num 1.2

> str(readr::read_tsv("foo.tsv", col_names=FALSE))
Classes 'tbl_df', 'tbl' and 'data.frame':       1 obs. of  3 variables:
 $ X1: chr "a"
 $ X2: int 2
 $ X3: num 1.2

> str(readr::read_tsv("foo.tsv", col_names=FALSE, col_types="cid"))
Classes 'tbl_df', 'tbl' and 'data.frame':       1 obs. of  3 variables:
 $ X1: chr "a"
 $ X2: int 2
 $ X3: num 1.2

but ideally also something like:

> str(readr::read_tsv("foo.tsv", col_names=FALSE, col_types="ci?"))
 $ X1: chr "a"
 $ X2: int 2
 $ X3: num 1.2

PS. I picked '?' as in R.utils::colClasses("ci?") == c("character", "integer", "NA"). Related and minor: Did you consider using another symbol than underscore for skipping a column, because it becomes hard to count when there are several of them in a row, e.g. c______i v. c------i.

@hadley hadley closed this in d2d7c3e Jul 9, 2015

@lock lock bot locked and limited conversation to collaborators Sep 25, 2018

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