This article describes how to go from a standard table...
...to a table that shows the average across the rows and and average across the columns:
Requirements
A table with more than one rows and more than one columns.
Method
1. In the toolbar, go to Insert a calculation > custom code. Click-and-drag the crosshairs to create an output on the Page.
2. In the code editor, type in tab
=
and position the cursor after the = sign.
3. On the Page, hover over the original table, and click the table's reference name in the top left. It'll look something like this before you click (where in this example, the table reference name is table.q5
4. Now paste in the following below that first line to calculate the averages:
attr.avg = colMeans(tab)
tab2 = rbind(tab,"Average" = attr.avg)
brand.avg = rowMeans(tab2)
new.tab = cbind(tab2,"Average" = brand.avg)
This code calculates the average for the columns via colMeans
and then adds this as a table row using rbind
. Next, it calculates the average of the rows via rowMeans
and then adds this as a table column using cbind
.
5. Select this output and in the object inspector, go to Appearance > Appearance > Decimals to adjust decimal places and Number format to add a percentage sign.