Skip to content
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

Use a named col_type #571

Closed
llrs opened this issue May 24, 2019 · 1 comment
Closed

Use a named col_type #571

llrs opened this issue May 24, 2019 · 1 comment

Comments

@llrs
Copy link

llrs commented May 24, 2019

I am reading a bunch of files with several columns, in some files these columns are in the files and in some other they are not (but they always contain the same information). In total there are 74 column names but I have 13, 13, 35, 38, 38, 44, 44 and 52 columns in each file.

read_xlsx is having a hard time guessing what type is each column. I would like to provide a named col_type such that if the column name is found it applies that type of data. Now I need to explore each file and look what type of data has each column and in which position in order to specify the type.

Currently only the position of col_type sets the type of the column. This would mean silently remove the missing col_types if there aren't in the file being read.

As a mock example I would like to be able to do something like this:

col_type <- c("Fecha" = "date", "count" = "numeric", "position" = "text")
# Files of two columns
read_xlsx(file1, col_type = col_type)
# Files of all three columns in different order than the first one
read_xlsx(file1, col_type = col_type)

Ideally the check of the type should be done before cleaning the names (I have some columns with duplicate column names).

@jennybc
Copy link
Member

jennybc commented May 25, 2019

#198 is the current issue re: upgrading col type specification, specifically making readxl more like readr (or, perhaps today, also more like vroom). So, I'm closing this in favour of #198. You're welcome to add details to that thread or allow this link to implicitly do that.

@jennybc jennybc closed this as completed May 25, 2019
@lock lock bot locked and limited conversation to collaborators Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants