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

Question about net #93

Closed
robertogilsaura opened this issue Feb 1, 2022 · 2 comments
Closed

Question about net #93

robertogilsaura opened this issue Feb 1, 2022 · 2 comments

Comments

@robertogilsaura
Copy link

Hi @gdemin

I'm processing a product test. In this table, I need to hide (not display but compute in %) a category using net

My code...

data <- data.frame(reTEST=c(1,2,1,2,1,2,1,2,1,2,1,2,1,2), value=c(1,5,4,3,2,1,2,1,5,5,1,1,3,5))
data %>% 
    tab_cols('|'=unvr(reTEST)) %>% 
    tab_cells('|'=unvr(value)) %>% 
    tab_net_cells("Top Box (seguro compraría)" = 5, 
      "Top 2 Box (seguro y probable compraría)"= 4:5, 
      "Bottom 2 Box (seguro y probable no compraría)"=1:2, 
      "Rest"=hide(3)) %>%
    tab_stat_cpct(total_row_position = 'none') %>% 
    tab_cells('|'=unvr(value)) %>% 
    tab_stat_mean() %>% 
    tab_pivot()

I would need that category "Rest" don't display in table. I think that hide() and unhide() don't build the crosstab like I expect, without category Rest (3).

Is there anyway for this?

Thanks in advance, Gregory.

@gdemin
Copy link
Owner

gdemin commented Feb 2, 2022

Hi, @robertogilsaura
hide is for "hiding" items from which category consists. So it is applicable only for "subtotal" and absolutely useless for "nets". "nets" hide subitems by default.

In your case it is easier just remove row:

data %>% 
    tab_cols('|'=unvr(reTEST)) %>% 
    tab_cells('|'=unvr(value)) %>% 
    tab_net_cells("Top Box (seguro compraría)" = 5, 
                  "Top 2 Box (seguro y probable compraría)"= 4:5, 
                  "Bottom 2 Box (seguro y probable no compraría)"=1:2, 
                  "Rest"=3) %>%
    tab_stat_cpct(total_row_position = 'none') %>% 
    tab_cells('|'=unvr(value)) %>% 
    tab_stat_mean() %>% 
    tab_pivot() %>% 
    rows(!grepl("Rest", row_labels)) %>% 
    as.etable()

@robertogilsaura
Copy link
Author

Thanks a lot for your answer, @gdemin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants