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

type_convert ignores leading whitespace when imputing column type, and also imputes before trimming #1536

Open
markpurver opened this issue Mar 28, 2024 · 0 comments

Comments

@markpurver
Copy link

markpurver commented Mar 28, 2024

When converting to character to numeric with imputed column types (col_types=NULL), type_convert ignores leading whitespace when parsing (regardless of whether trim_ws is TRUE or FALSE). It trims trailing whitespace after parsing if trim_ws is TRUE. The argument description says that both leading and trailing whitespace should be trimmed before parsing if trim_ws is TRUE, and implies that neither should be ignored when parsing if trim_ws is FALSE.

# This gives columns of "1" and 2, rather than 1 and 2
type_convert(data.frame(a="1 ", b=" 2"), trim_ws=TRUE)
# This gives columns "1 " and 2, rather than "1 " and " 2"
type_convert(data.frame(a="1 ", b=" 2"), trim_ws=FALSE)
@markpurver markpurver changed the title type_convert ignores leading whitespace when parsing, and also parses before trimming type_convert ignores leading whitespace when imputing column type, and also imputes before trimming Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant