gdemin / expss

expss: Tables and Labels in R
https://cran.r-project.org/web/packages/expss/
84 stars 16 forks source link

Where deprecated in future #92

Closed robertogilsaura closed 2 years ago

robertogilsaura commented 2 years ago

Hi @gdemin

Nowadays, when we use function where in expss package, result is an object etable, but if we use the functon maditr::rows results in data.table.

Running this code ...

df <- data.frame(x=c(1,1,1,1,1,1,1,1,1,1,1,2,2,2,3,4,5))
library(expss)
library(maditr)
tab <- df %>% 
    tab_cols(total(label='|')) %>% 
    tab_cells('|'=unvr(x)) %>% 
    tab_stat_cases(total_row_position = 'none', label='casos') %>% 
    tab_stat_cpct(total_row_position = 'none', label='pct') %>%
    tab_last_hstack() %>% 
    tab_pivot()
tab <- where(tab,pct>50)
tab <- let(tab, pct=NULL)
tab

tab1 <- df %>% 
    tab_cols(total(label='|')) %>% 
    tab_cells('|'=unvr(x)) %>% 
    tab_stat_cases(total_row_position = 'none', label='casos') %>% 
    tab_stat_cpct(total_row_position = 'none', label='pct') %>%
    tab_last_hstack() %>% 
    tab_pivot()
tab1 <- etable(rows(tab1, pct>50))
tab1 <- let(tab1, pct=NULL)
tab1

tab2 <- df %>% 
    tab_cols(total(label='|')) %>% 
    tab_cells('|'=unvr(x)) %>% 
    tab_stat_cases(total_row_position = 'none', label='casos') %>% 
    tab_stat_cpct(total_row_position = 'none', label='pct') %>%
    tab_last_hstack() %>% 
    tab_pivot()
tab2 <- rows(tab2, pct>50)
tab2 <- let(tab2, pct=NULL)
tab2

we can test that object tab and tab1 are class etable but tab2 is class data.table. Function let show different ouput, too.

Will it be like this in the future?

PD. I have any code with this mixing where and let and I'ld want to avaluate the impact with this change.

Thanks in advance. Great job!!! We look forward to the new, more simplified version to add new features. Regards.

gdemin commented 2 years ago

Hi, @robertogilsaura

There will be a method called rows.etable. And rows will return etable. As you can see let already has this method.

robertogilsaura commented 2 years ago

Good news !

Thanks, Gregory .