-
Notifications
You must be signed in to change notification settings - Fork 0
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
Make minus
work for type_convert()
#20
Comments
But at the moment, we should signal that it is not supported https://github.com/chainsawriot/minty/blob/912bb3609aab1b894cea97dcb9533d0753b5ad51/R/parser.R#L646 |
It errs only in the case of using shorthand. text_only <- as.data.frame(sapply(head(PlantGrowth), as.character))
readr::type_convert(text_only, col_types = list(weight = "?", group = "-"))
#> weight
#> 1 4.17
#> 2 5.58
#> 3 5.18
#> 4 6.11
#> 5 4.50
#> 6 4.61
readr::type_convert(text_only, col_types = readr::cols(weight = readr::col_guess(), group = readr::col_skip()))
#> weight
#> 1 4.17
#> 2 5.58
#> 3 5.18
#> 4 6.11
#> 5 4.50
#> 6 4.61
readr::type_convert(text_only, col_types = "?-")
#> Warning: Insufficient `col_types`. Guessing 1 columns.
#> Error in if (is.na(name)) {: argument is of length zero
minty::type_convert(text_only, col_types = list(weight = "?", group = "-"))
#> weight
#> 1 4.17
#> 2 5.58
#> 3 5.18
#> 4 6.11
#> 5 4.50
#> 6 4.61
minty::type_convert(text_only, col_types = readr::cols(weight = readr::col_guess(), group = readr::col_skip()))
#> weight
#> 1 4.17
#> 2 5.58
#> 3 5.18
#> 4 6.11
#> 5 4.50
#> 6 4.61
minty::type_convert(text_only, col_types = "?-")
#> Warning: Insufficient `col_types`. Guessing 1 columns.
#> Error in if (is.na(name)) {: argument is of length zero Created on 2024-03-18 with reprex v2.1.0 |
|
This bunch of code doesn't look useful for |
The check for missing column names is the reason for "?-" not working. And "?-" is sufficient in the following case. text_only <- as.data.frame(sapply(head(PlantGrowth), as.character))
## Wont work already
minty::type_convert(text_only, col_types = "?")
#> Error: `df` and `col_types` must have consistent lengths:
#> * `df` has length 2
#> * `col_types` has length 1
minty::type_convert(text_only, col_types = "?-?")
#> Error: `df` and `col_types` must have consistent lengths:
#> * `df` has length 2
#> * `col_types` has length 3
minty::type_convert(text_only, col_types = "?-")
#> Warning: Insufficient `col_types`. Guessing 1 columns.
#> Error in if (is.na(name)) {: argument is of length zero
minty::type_convert(text_only, col_types = "--")
#> Warning: Insufficient `col_types`. Guessing 2 columns.
#> Error in if (is.na(name)) {: argument is of length zero
## also not working
minty::type_convert(text_only, col_types = list("?", "-"))
#> Warning: Insufficient `col_types`. Guessing 1 columns.
#> Error in if (is.na(name)) {: argument is of length zero
minty::type_convert(text_only, col_types = readr::cols(weight = readr::col_skip(), group = readr::col_skip(), aaa = readr::col_skip()))
#> data frame with 0 columns and 6 rows Created on 2024-03-19 with reprex v2.1.0 |
tidyverse/readr#1509
The text was updated successfully, but these errors were encountered: