Closed averissimo closed 6 months ago
This is a feature, not a bug. The user is encouraged to pick better names. They can add a digit themselves.
I don't think this is robust enough to filter out bad names. A Snapshot
, A.Snapshot
and A-Snapshot
collide while A_Snapshot
and a few other exceptions don't
We could debate if having symbols produce bad names, but I'm ok with the rationale. ~However, whitespace seems problematic as it wouldn't be visible on the UI.~
make.names(c("A Snapshot", "A.Snapshot", "A-Snapshot", "A$Snapshot", "A/Snapshot", "A%Snapshot"))
#> [1] "A.Snapshot" "A.Snapshot" "A.Snapshot" "A.Snapshot" "A.Snapshot"
#> [6] "A.Snapshot"
make.names("prefix\\|!\"#$%&/()=?»«'*+`´ºª~^çÇ.-_,;:<>¨·€ß@£§½¬{[]}¸¹¡suffix")
#> [1] "prefix....................ºª..çÇ.._........ß............suffix"
make.names(c("A_Snapshot", " A Snapshot ", " A Snapshot "))
#> [1] "A_Snapshot" "X.A.Snapshot." "X...A.Snapshot..."
~Maybe we could extend this feature to filter out whitespace and ALL the symbols (trimws(gsub("\\W|_", ".", trimws(names)), whitespace = "[.]")
) :smile:~
make_names <- function(names) {
checkmate::assert_character(names)
trimws(gsub("\\W|_", ".", make.names(trimws(names))), whitespace = "[.]")}
}
Nevermind, whitespace is protected somewhere before make.names
call.
Allowing only "_" and a few exceptions seems reasonable
Leading and trailing white space is removed, yes.
What happened?
How to reproduce:
Empty Snapshot
(space as separator between words)Empty.Snapshot
(.
as separator between words)This is due to the
base::make.names
function generating syntathically valid names for use in R.Additionally,
shinytest2::get_download()
function does not work well with output ID names that have dots in them.Suggestion:
{teal}