A Calculation (also called an R Output) is an item in the Report tree or on a Page that is created using R code. Some Calculations are built-in analyses and visualizations from the menu. You can also create custom Calculations to create custom outputs or dynamic inputs to other items. Custom calculations are denoted with a small Calculation icon in the Report tree, and will always have a Code button in Properties
> Data > Attributes.
Technical details
The Roles of Calculations in Displayr
A Calculation performs two related roles within Displayr. They can be used as:
- A final output to be displayed in the Report.
- An input to other items -- such as subset tables, reordered tables, combined tables, custom row names, unique values after filtering, and more.
Creating a Calculation
Create Calculations (R Outputs) using the following instructions:
- Click Calculation
> Custom Code either from the + menu in the Report tree or the toolbar.
- If using the toolbar, click the Page to position the Calculation.
- Enter the code in the Code
panel.
- Press Calculate if the output doesn't calculate automatically.
As mentioned, many options in the menus are the results of Calculations and based on R code. You can adjust the display options under the Data > Output:
- Show as lets you choose between text and table (when appropriate).
- Include R code lets you display the R code in a box next to the result. The code will be highlighted appropriately.
- Show raw R output shows the R terminal view, where you see each line of code that is processed and anything that is printed. This is useful for troubleshooting R code, as you can see which line of code is returning an error and preview intermediate objects and calculations in the script.
See How to Add a Custom Calculation for more details.
Appearance of a Calculation
A Calculation can appear as different types, see Calculation Types.
Reference
From the Displayr release of the 7th June 2021, an R Output is referred to as a Calculation or Custom Calculation.