Impute empty values as na in the variable browser#700
Conversation
| #' @returns (`vector`) a vector with empty strings imputed as `NA`, if provided. | ||
| #' @keywords internal | ||
| impute_blanks_as_na <- function(var) { | ||
| var <- as.vector(var) |
There was a problem hiding this comment.
Yeah, this was the main issue that was raised. If the factor has a level that is "" (or a character vector that has "") it will NOT be considered as NA, dropping the factor was the only way to consider them as NA.
I'm still keeping the PR as a draft because the request is unclear if we need to be doing this.
There was a problem hiding this comment.
Will this not influence the plotting, like change the order of categories on the axis or in the color key?
There was a problem hiding this comment.
We explicitly change the NAs to <Missing> before we plot them. Previously the label was NA with a different color. Now, we're just displaying it as <Missing> because it is in line with the tern::df_explicit_na()
r$> df_explicit_na(data.frame(col = c("A", "B", NA, "C")))
col
1 A
2 B
3 <Missing>
4 CAgain, so much of a feature request here. Nothing is clear as of now. So, it's still a draft and we can talk about what we want.
|
. |
| #' @param var (`vector`) a vector of any type and length | ||
| #' @returns (`vector`) a vector with empty strings imputed as `NA`, if provided. | ||
| #' @keywords internal | ||
| impute_blanks_as_na <- function(var) { |
There was a problem hiding this comment.
teal.modules.general Imports tern. Why write a new function rather than use one from the dependency?
There was a problem hiding this comment.
I don't think there is such an imputation function in tern. However, It can be used when replacing NA with <Missing> 👍🏽
There was a problem hiding this comment.
Honestly, I don't think we should be even imputing things. The true bug is that the data had empty strings which should be the app developer's responsibility to fix before injecting it into the teal app.
There was a problem hiding this comment.
I don't think there is such an imputation function in
tern
Look again ?tern::df_explicit_na 😉
There was a problem hiding this comment.
Oh great! I'll use it. Thanks!

Closes #697