I'm using this code chunk which works in Rstudio IDE, but it's not working in rstudio.cloud. I'm guessing it has something to do with the ` but the data comes in like that and I can't use dplyr::rename() on it either.
I get this error:
Error in stringi::stri_trans_general(replaced_names, id = "Greek-Latin;Latin-ASCII;Accents-Any;Any-ASCII") :
A '::id' rule specifies an unknown transliterator. (U_INVALID_ID)
I was able to reproduce this issue in my RStudio Cloud instance. I don't know the underlying cause, but it appears to be something to do with clean_names itself, as it happens with every data frame I've tried, including ones with legal names. Here's an example using the built-in billboard data frame:
library(tidyverse)
library(janitor)
# Change to an illegal column name in the first position
names(billboard)[1] = "Province/State"
Now let's use set_names to change / to _, making the name legal. Even then we still get the error from clean_names:
billboard %>%
pivot_longer(cols = -`Province/State`:-date.entered) %>%
set_names(gsub("/","_", names(.))) %>%
clean_names()
Error in stringi::stri_trans_general(replaced_names, id = "Greek-Latin;Latin-ASCII;Accents-Any;Any-ASCII") :
A '::id' rule specifies an unknown transliterator. (U_INVALID_ID)
Actually, the same error occurs even if the names all start out legal:
clean_names(mtcars)
Error in stringi::stri_trans_general(replaced_names, id = "Greek-Latin;Latin-ASCII;Accents-Any;Any-ASCII") :
A '::id' rule specifies an unknown transliterator. (U_INVALID_ID)
Here's a workaround:
billboard %>%
pivot_longer(cols = -`Province/State`:-date.entered) %>%
set_names(tolower(make.names(names(.))))
Hopefully someone else will be able to explain why clean_names is erroring in RStudio Cloud.
Sorry about this, this is a bug in janitor 2.0.0 that surfaced after it went to CRAN. We're hoping to get a quick fix into CRAN ASAP. In the meantime, users can try install stringi locally with install.packages("stringi", configure.args="--disable-pkg-config") -- if RStudio Cloud can be configured with that setup as well, that might solve it there.
In the meantime you can follow progress on that janitor GitHub issue linked above.
The problem has now been fixed in the development version and the fix will soon be pushed to CRAN. You can get the development version by running devtools::install_github("sfirke/janitor").