Skip to content

Handle column names with non-identifier characters #451

Closed

Description

@Jollywatt

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

Activity

  1. added
    bugan unexpected problem or unintended behavior
    on Sep 17, 2023
  2. markfairbanks commented on Sep 19, 2023

    @markfairbanks
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions