markfairbanks / tidytable

Tidy interface to 'data.table'
https://markfairbanks.github.io/tidytable/
Other
450 stars 32 forks source link

pivot_wider. cannot handle spaces or special characters in the column names #569

Closed nick-youngblut closed 2 years ago

nick-youngblut commented 2 years ago

At least for tidytable v0.8.0, pivot_wider. cannot handle any columns that must be identified with backticks.

Reprex:

mpg %>%
  rename.("model of car" = model) %>%
  pivot_wider.(names_from='trans', values_from='cty')

Error:

Error in str2lang(x) : <text>:1:22: unexpected symbol
1: manufacturer + model of
^
markfairbanks commented 2 years ago

All fixed - thanks for catching this.

pacman::p_load(tidytable)

df <- tidytable("a a" = 1,
                "names" = c("a", "b"),
                "val" = 1:2)

df %>%
  pivot_wider.(names_from = names, values_from = val)
#> # A tidytable: 1 × 3
#>   `a a`     a     b
#>   <dbl> <int> <int>
#> 1     1     1     2
nick-youngblut commented 2 years ago

Thanks @markfairbanks for the quick fix!