-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
Consolidate coerce_to_numeric()
into to_numeric()
via a new argument
#206
Comments
I think the currently existing argument |
@bwiernik @vincentarelbundock what do you think? Do you have suggestions for argument names? Currently, the If a vector has character or string levels, I think the currently existing argument Suggestions? library(datawizard)
f1 <- factor(c(1, 2, 3, 4))
f2 <- factor(c(5, 6, 7 , 8))
to_numeric(f1, dummy_factors = FALSE)
#> [1] 1 2 3 4
to_numeric(f2, dummy_factors = FALSE)
#> [1] 1 2 3 4
to_numeric(f2, dummy_factors = FALSE, preserve_levels = TRUE)
#> [1] 5 6 7 8
f1 <- factor(c("a", "b", "c", "d"))
to_numeric(f1, dummy_factors = FALSE)
#> [1] 1 2 3 4
to_numeric(f1, dummy_factors = FALSE, preserve_levels = TRUE)
#> [1] 1 2 3 4
# which argument for `to_numeric()` could behave like `coerce_to_numeric()`?
coerce_to_numeric(f1)
#> [1] a b c d
#> Levels: a b c d Created on 2022-08-05 by the reprex package (v2.0.1) |
Sorry, I'm probably not the right person to ask. I'm a grumpy old man who likes base R 😣 |
I'm not asking you about the functionality ;-) I'd like to know from a native speaker which argument name sounds best for this task :-) And you did your Bsc in 2007, you can't be older than me. 😝 |
Honestly, I think I just want to challenge the premise of the question: I think a function called |
The reason for this discussion is that we had several internal So we need an additional argument, unless you want to maintain all our internal functions. :-) |
I would argue that in those cases clarity and maintainability is best achieved by a standard Being more verbose and sticking with base R is often preferable, IMHO. But obviously, I haven't seen all the use cases, so you know better. And to be clear, this isn't a big deal to me; I just have difficulty to not give opinions. |
I generally agree with Vincent that If an argument is used to trigger this conditional behavior, it should be very explicit that this is what the argument does, and it should be independent of the I would prefer a separate function like |
|
I really don't understand the context where |
I don't know, but it's used in modelbased for example: |
So Line 151 in 34cf6bf
If we change this to something like data[["_Row"]] <- as.numeric(row.names(data)) we can remove this function. WDYT? |
Its usage in |
No, make to internal instead. Else |
No description provided.
The text was updated successfully, but these errors were encountered: