Open areus20 opened 4 years ago
Hi, could you show a rough example of what your desired output would be pls?
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!
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
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 (%) |
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!
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.