-
Notifications
You must be signed in to change notification settings - Fork 112
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
switch check_type() to use cli package #1235
Conversation
R/misc.R
Outdated
classes <- map_chr(info$type, function(x) x[1]) | ||
counts <- vctrs::vec_split(info$variable, classes) | ||
counts$count <- lengths(counts$val) | ||
counts$text_len <- cli::console_width() - 19 - (counts$count > 1) - |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-19
- my count of the length of "• variable found: "
(counts$count > 1)
- whether variable has an s
or not
nchar(counts$key)
- length of the variable type
variable_collapse <- function(x, width) { | ||
x <- paste0("{.var ", x, "}") | ||
if (length(x) == 1) { | ||
res <- cli::ansi_strtrim(x, width = width) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the unlikely event that the single variable name is too large, i used cli::ansi_strtrim
to truncate the variable by itself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a big improvement! Feel free to re-request review when you feel this is in a good spot. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, looks good! Looks like there's one issue with duplicated column names; once that's resolved, thumbs up from me.
tests/testthat/_snaps/ratio.md
Outdated
@@ -23,7 +25,8 @@ | |||
Condition | |||
Error in `step_ratio()`: | |||
Caused by error in `prep()`: | |||
! All columns selected for the step should be double, or integer. | |||
x All columns selected for the step should be double or integer. | |||
* 8 factor variables found: `x5`, `x5`, `x5`, `x5`, ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's happening here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
solved with a call to unique()
0a36bb7
(#1235)
This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex https://reprex.tidyverse.org) and link to this issue. |
to close #1217.
This PR switches
check_type()
to use {cli} in its errors. Additionally and more importantly, it lists the offending variables and their types 🎉