IDEMSInternational / R-Instat

A statistics software package powered by R
http://r-instat.org/
GNU General Public License v3.0
38 stars 102 forks source link

Include Add Margins dialog in the Prepare > Column: Factors menu? #9022

Open rdstern opened 3 months ago

rdstern commented 3 months ago

This is initially a question for @volloholic and @lilyclements. Margins for tables is quite an important idea. R has the addmargins function. I suggest it is a low-hanging fruit to include an Add Margins dialog in the Prepare > Column: Factor menu. The margins just add levels to the respective factors, so the actual tables incorporate them automatically. So adding marins is all just part of preparing data for analysis!

A by-product is that this is another reason that understanding about using factors is important in data analysis. (So it is pretty amazing that SPSS remains the main package for survey data analysis, while it still doesn't use factors!)

lilyclements commented 3 weeks ago

@rdstern I think I am misunderstanding! Do you see this "Add Margins" option as like, adding a new factor level ("Total", say), and the value for it to be to automatically calculate totals. And for this to be in our data set visible on the grid? I'm not sure how that fits into a "rectangle" format for our data set?

rdstern commented 3 weeks ago

@lilyclements it is exactly that, though there may sometimes be multiple margins, so it adds more than one level to a factor. The result is another data frame, so could also go into the reshape - but it is so linked to factors that I proposed it there. It adds the option to calculate any margins needed, before going into gt - so gt doesn't need to understand anything about margins.