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

Support a logical column type? #270

Closed
jennybc opened this Issue Feb 24, 2017 · 2 comments

Comments

2 participants
@jennybc
Member

jennybc commented Feb 24, 2017

It seems like an empty column should be filled with logical NAs but currently readxl fills with NA_real_. I think @hadley has already concurred, at least in principle (tidyverse/tidyverse#34 (comment)). Also comes up if all the cells in a column match one of the strings in na.

That seems easy enough to do. But it begs the question whether this should be the only way for readxl to return a logical vector. Should "logical" become a new column type that can be guessed or that user could specify?

Excel cells can be of Boolean type, so that can be detected when guessing or when enforcing user-specified col types.

But do you take it further? How much effort to make with logical-ish strings and numbers?

@hadley

This comment has been minimized.

Member

hadley commented Feb 24, 2017

I think there are two questions here:

  • Should we support a logical column type for boolean values in Excel (I'd say yes)

  • Should we provide better coercion tools from one type to another? As well as logical, we need to think about string to date or string to number as well. This might be quite a bit of work, but it's worth exploring.

@jennybc jennybc added the feature label Feb 25, 2017

jennybc added a commit that referenced this issue Feb 26, 2017

Handle xls record type BoolErr (number 517); fixes #259, relates to #… (
#274)

* Handle xls record type BoolErr (number 517); fixes #259, relates to #270, relates to #62

This record type is also used for errors, but only errors that are not a result of a formula, which is most of them. So if OP on #62 provides an example, we could conceivably do more in the else branch here.

* Fix NEWS

@jennybc jennybc added this to TODO in jennybc Feb 26, 2017

@jennybc

This comment has been minimized.

Member

jennybc commented Mar 1, 2017

The logical column type is added in #277, along with the expected coercions (logical to numeric or text, numeric or text to logical).

Should we provide better coercion tools from one type to another? As well as logical, we need to think about string to date or string to number as well. This might be quite a bit of work, but it's worth exploring.

I don't think string to date is urgent. If Excel recognizes a string as a date, believe me, it converts the cell to date with great zeal! So dates-as-strings are quite rare in nature. Plus it is easy enough to convert character to date on the R side.

I'm going to do string to number, which is #217.

@jennybc jennybc closed this in #277 Mar 5, 2017

@jennybc jennybc moved this from TODO to Done in jennybc Mar 10, 2017

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