Each built-in Displayr table stores attribute parameters which can be called via R using the attributes command. When performing R table calculations, there will be times when these attributes will carry over to your custom tables, but you may wish to alter some of them.
This article describes how to update attribute parameters in R tables, such as the underlying table statistic:
This can be important, as a table with a Count statistic parameter will be viewed by Displayr, and in turn any visualization, as a non-percentage.
An R table that performs a calculation based on the counts of two tables. In this example, we will calculate preference based on awareness:
1. Select Calculation > Custom Code.
2. Update the Name and Label in the object inspector under Properties > GENERAL.
3. Paste the below under Properties > R CODE:
pref = table.preference / table.awareness * 100
Because the source tables are both using Count, the final result also shows as Count in the column header and we can't add a % symbol.
4. We can confirm the attribute parameters in this R table by calling the following:
Here, the statistic parameter is clearly Count.
5. To change the underlying statistic label, we can use the attr command and then return our updated pref table:
attr(pref,"statistic") = "%"
6. Press the % symbol under Properties > APPEARANCE > Number format and the table will display as expected.