markfairbanks / tidytable

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

`distinct` not working with lists #773

Closed luispfonseca closed 11 months ago

luispfonseca commented 11 months ago

See reprex below. Possible context in https://github.com/Rdatatable/data.table/issues/3332

library(grid)
library(ggplotify)

p1 <- as.grob(~barplot(1:10))

library(tidytable)
#> 
#> Attaching package: 'tidytable'
#> The following objects are masked from 'package:stats':
#> 
#>     dt, filter, lag
#> The following object is masked from 'package:base':
#> 
#>     %in%

tidytable(
  a = rep(1,2),
  grob = rep(list(p1), 2)
) %>% 
  distinct(a, grob)
#> Error in forderv(x, by = by, sort = FALSE, retGrp = TRUE): Column 2 passed to [f]order is type 'list', not yet supported.

Created on 2023-10-20 with reprex v2.0.2

luispfonseca commented 11 months ago

Just to confirm, it works with dplyr:

library(grid)
library(ggplotify)

p1 <- as.grob(~barplot(1:10))

library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union

tibble(
  a = rep(1, 2),
  grob = rep(list(p1), 2)
) %>% 
  distinct(a, grob)
#> # A tibble: 1 × 2
#>       a grob   
#>   <dbl> <list> 
#> 1     1 <gTree>

Created on 2023-10-20 with reprex v2.0.2

markfairbanks commented 11 months ago

All set - thanks for catching this!

# install.packages("pak")
# pak::pak("markfairbanks/tidytable")
library(tidytable)

df <- tidytable(x = 1, l = list(1, 1))

distinct(df)
#> # A tidytable: 1 × 2
#>       x l        
#>   <dbl> <list>   
#> 1     1 <dbl [1]>