Skip to content

I can´t use column names directly in the group by, that cointain spanish letter ñ  #4708

Closed

Description

@pfv07

Hi
If i have a data.table that contain a column name with the letter ñ (spanish), i have error when i try to make a group by for this column:

dt <- data.table(a=1:3,año=c(2020,2021,2023))

dt[,sum(a),año]
# Error in eval(bysub, parent.frame(), parent.frame()) : 
#   objeto 'año' no encontrado

I need to put the column name in a list dt[,sum(a),.(año)] and thats work !!!

I using R 4.0.2 version and data.table 1.13.0

If I do the same in version R 3.5.3 and data.table data.table 1.12.8, i have the correct result !!!

Details
> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)

Matrix products: default

locale:
[1] LC_COLLATE=Spanish_Ecuador.1252  LC_CTYPE=Spanish_Ecuador.1252   
[3] LC_MONETARY=Spanish_Ecuador.1252 LC_NUMERIC=C                    
[5] LC_TIME=Spanish_Ecuador.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] data.table_1.13.0

loaded via a namespace (and not attached):
[1] compiler_4.0.2
> 
```

</details>

Activity

  1. MichaelChirico commented on Sep 20, 2020

    @MichaelChirico
    Member

    Thanks for the report. I've isolated the issue to this MRE:

    substitute(año) %chin% 'año'
    # [1] FALSE
    

    So año is not being recognized as a column name in the table, and it's sought in the calling environment (where it doesn't exist).

    Note another workaround:

    dt[,sum(a),'año']
    
  2. added this to the 1.14.1 milestone on May 13, 2021
  3. modified the milestones: 1.14.3, on Jul 19, 2022
  4. modified the milestones: , 1.15.1 on Oct 29, 2023
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

    encodingissues related to Encoding

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions