This article describes how to use subsections of larger tables and even custom R-based calculations in tables and visualizations.
For example, here we have a table that analyzes respondents' perceptions toward various colas, but we only want to graph a couple of them.
We would like to create a bar chart of the data, but rather than graph the entire table, we would like to create a graph of just the first column labeled Feminine.
Requirements
- A Displayr document
- A table that you would like to use as an input.
- Familiarity with Displayr's point-and-click R code interface - How to Use Point and Click Inside R Code
- Optional: If programming custom calculations some basic knowledge of programming with R - How to Learn R
Method 1 - Create a table that is a subsection of a larger table
- From the toolbar, select Table > Paste or Enter Table.
- Select an existing table from Data > Data Source > Data in the object inspector.
- Click into the the Data box, and then using the point-and-click method, select the cells you want to show in the table. In this example, we selected the first three rows in the table by selecting the first three row headings (table.q5[1:3, ]).
- Click Calculate.
This will create a sub-table that just contains the rows pertaining to Coca-Cola products.
Method 2 - Create a visualization based on a subsection of a larger table
- From the toolbar, select Table > Paste or Enter Table.
- From Data > Data Source > Data in the object inspector, select the table, or use the point-and-click method to select it on the page. See an example of this in the .gif below.
- Click into the the Data box, and then using the point-and-click method, select the cells you want to show in the table. In this example, we selected the first column of results (Feminine) for all brands in the table by selecting cells in the first column (table.q5[,1]).
- Click Calculate.
- In the Object Inspector, select Visualization > Bar > Bar.
Method 3 - Create a visualization based on a custom calculation
- From the toolbar, select Table > Paste or Enter Table.
- From Data > Data Source > Data in the object inspector, select the table, or use the point-and-click method to select it on the page. See an example of this in the .gif below.
- In the example below, we'll show the difference between column 1 (Feminine) and column 2 (Health Conscious), in the Data box, we can subtract column 2 from column 1 by typing in a minus between the table selections (table.q5[,1]-table.q5[,2]).
- In the Object Inspector, select Visualization > Bar > Bar.
Next
How to Use Point and Click Inside R Code
Creating and Modifying Visualizations