dcomtois / summarytools

R Package to Quickly and Neatly Summarize Data
504 stars 77 forks source link

Var labels and qualitative variables #120

Open areus20 opened 4 years ago

areus20 commented 4 years ago

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.

dcomtois commented 4 years ago

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

areus20 commented 4 years ago

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!

dcomtois commented 4 years ago
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

areus20 commented 4 years ago

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 (%)
dcomtois commented 4 years ago

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!