Skip to content
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

Handle column names with non-identifier characters #451

Closed
Jollywatt opened this issue Sep 14, 2023 · 1 comment · Fixed by #452
Closed

Handle column names with non-identifier characters #451

Jollywatt opened this issue Sep 14, 2023 · 1 comment · Fixed by #452
Labels
bug an unexpected problem or unintended behavior

Comments

@Jollywatt
Copy link

Jollywatt commented Sep 14, 2023

Column names with non-standard characters don't seem to always be handled correctly:

# works
mtcars %>% dtplyr::lazy_dt() %>% mutate(`a.b` = 2) %>% group_by(`a.b`) %>% count()

# breaks
mtcars %>% dtplyr::lazy_dt() %>% mutate(`a b` = 2) %>% group_by(`a b`) %>% count()
#> Error in eval(bysub, x, parent.frame()) : object '`a b`' not found

Using package versions

dtplyr 1.3.1
data.table 1.14.8
dplyr 1.1.0

...on platform with version:

platform       x86_64-redhat-linux-gnu     
arch           x86_64                      
os             linux-gnu                   
system         x86_64, linux-gnu           
status                                     
major          3                           
minor          6.0                         
year           2019                        
month          04                          
day            26                          
svn rev        76424                       
language       R                           
version.string R version 3.6.0 (2019-04-26)
nickname       Planting of a Tree  

Thanks for your time

@markfairbanks markfairbanks added the bug an unexpected problem or unintended behavior label Sep 17, 2023
@markfairbanks
Copy link
Collaborator

All set, thanks for catching this!

# pak::pak("tidyverse/dtplyr")
library(dtplyr)
library(dplyr, warn.conflicts = FALSE)

x <- 3

dt <- lazy_dt(tibble(`a a` = rep("a", 3)))

dt %>%
  group_by(`a a`) %>%
  count()
#> Source: local data table [1 x 2]
#> Groups: a a
#> Call:   `_DT1`[, .(n = .N), keyby = .(`a a`)]
#> 
#>   `a a`     n
#>   <chr> <int>
#> 1 a         3
#> 
#> # Use as.data.table()/as.data.frame()/as_tibble() to access results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants