Skip to content

docs: add @return, @details, and example to type_convert() documentation - #1637

Closed
LeonidasZhak wants to merge 1 commit into
tidyverse:mainfrom
LeonidasZhak:docs/type_convert-mixed-parsability-example
Closed

docs: add @return, @details, and example to type_convert() documentation#1637
LeonidasZhak wants to merge 1 commit into
tidyverse:mainfrom
LeonidasZhak:docs/type_convert-mixed-parsability-example

Conversation

@LeonidasZhak

Copy link
Copy Markdown

What

Adds missing documentation to type_convert():

  1. @return tag: Documents that the function returns a data frame with character columns converted to guessed types, and that unparsable values become NA with a warning.

  2. @details section: Explains that column types are guessed using guess_parser(), and notes that the numeric parser recognizes some alphanumeric strings as valid numbers (e.g., "100e5", "100L", "100S"). Suggests using explicit cols() specifications to avoid unexpected parsing.

  3. Example: Shows parsing failure with explicit col_types = cols(x = col_double()).

Why

Partially addresses #1562. While the underlying Qi parser behavior (treating F/L/S as floating-point suffixes) requires a C++ code fix, this PR documents the current behavior so users can understand and work around it.

Validation

  • tools::checkRd("man/type_convert.Rd") — clean
  • Example runs correctly:
    df <- data.frame(x = c("100", "200", "abc"), stringsAsFactors = FALSE)
    type_convert(df, col_types = cols(x = col_double()))
    # Warning: [2, 1]: expected a double, but got 'abc'
    #     x
    # 1 100
    # 2 200
    # 3  NA

Files changed

  • R/type_convert.R (roxygen source)
  • man/type_convert.Rd (generated)

- Add @return tag documenting that unparsable values become NA with a warning
- Add @details explaining that guess_parser() is used for type guessing
- Note that numeric parser recognizes some alphanumeric strings (e.g., '100e5', '100L', '100S') as valid numbers
- Add example showing parsing failure with explicit col_types

Addresses tidyverse#1562 (partially - documentation of behavior, not the underlying parser bug)
@LeonidasZhak

Copy link
Copy Markdown
Author

Withdrawing this small automated PR while I consolidate an oversized batch of contributions and reduce maintainer review burden. Sorry for the noise, and thank you for maintaining the project.

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

Successfully merging this pull request may close these issues.

1 participant