collapse icon indicating copy to clipboard operation
collapse copied to clipboard

Pivot column with special characters

Open alearrigo opened this issue 1 year ago • 1 comments

Hi, I don't know if that's an issue or I'm doing something wrong but, given a long dataset

iris_long <- pivot(iris, "Species")

If I use pivot I have the correct result:

iris_long %>% 
  pivot(names = "variable",
        how = "wider")

but If I try to pivot on a variable with special characters like accented letters:

iris_long %>% 
  rename(vàriablè = variable) %>% 
  pivot(names = "vàriablè",
        how = "wider")

I get this error

Error in ckmatch(cols, nam) : Unknown columns: vàriablè

Thanks

alearrigo avatar Apr 23 '24 12:04 alearrigo

Hi, thanks for flagging this. Still need to look into it. Likely has something to do with string encoding. To be on the safe side always use accent free variable names, such as by applying janitor::clean_names() to your dataset before.

SebKrantz avatar Apr 30 '24 20:04 SebKrantz

This is now fixed.

SebKrantz avatar Aug 20 '24 10:08 SebKrantz