summarytools icon indicating copy to clipboard operation
summarytools copied to clipboard

Var labels and qualitative variables

Open areus20 opened this issue 5 years ago • 5 comments

I was using the summarytools (freq) package for tables, and in the case of quantitative variables, there is no problem grouping multiple variables into a single table (except the variable label is not shown). But for several qualitative variables with the same categories, I can't find the option to collapse all in 1 single table, where the columns correspond to the categories. Thanks for the help.

areus20 avatar Jul 24 '20 15:07 areus20

Hi, could you show a rough example of what your desired output would be pls?

dcomtois avatar Jul 24 '20 19:07 dcomtois

An example would look like the table on the next page: https://community.rstudio.com/t/table-with-kable-and-formattable/30565, were orange grape and apple whe the variables that have the same categories ( A B C) and in the boxes you get frequency (and percentage ideally). Thanks!

areus20 avatar Jul 25 '20 04:07 areus20

Ok, let's simplify this a bit. Say you have this table. What would the frequency table you have in mind table look like?

col1 col2 col3
a a a
a b b
c b c

PS: You can use a tool like this one to create markdown tables: https://www.tablesgenerator.com/markdown_tables

dcomtois avatar Jul 25 '20 12:07 dcomtois

Thanks! Something like this data frame with factor variables col1,col2,col3 (1,2,3 are categories)

col1 col2 col3
2 3 1
3 1 1
2 1 3

To this table:

col1 col2 col3
1 1 (33.3%) 2 (%) 2 (%)
2 2 (66.6%) 0 (%) 0 (%)
3 0 (0%) 1 (%) 1 (%)

areus20 avatar Jul 26 '20 21:07 areus20

Seems easy enough... I just don't have much time on my hands this summer, so unless someone wants to give it a shot, it will probably have to wait a few more months.

Thanks for your suggestion, it's a neat idea!

dcomtois avatar Aug 06 '20 02:08 dcomtois