This article describes how to customize the formatting of Displayr's tables, similar to what's possible in Excel. It allows you to turn a table like this:
...into one that looks like this:
More specifically:
- Format Entire Tables
- Format Cells
- Reset to table default formats
- Worked Example: Formatting a column of cells
- Worked Example: Changing the font for a cell
Requirements
-
A table with a format as one of the following:
- Built-in drag-and-drop table. For more information, see: Creating Summary Tables and Crosstabs.
- A basic R-based table, such as a combined table, pasted or entered table, or a table created using a custom calculation.
- A Calculation Grid, see How to Use Calculation Grid in Displayr.
- See How to Select the Type of Table that is Right for You for more information about the types of tables available.
-
Tables specifically that cannot be customized per this article are:
- Table with Custom Formatting (also known as Autofit) and any other table created via the Visualization > Specialty Tables menu. These must be customized via the Chart or Data tab in the object inspector.
- Custom tables created via R Code with the CreateCustomTable(), formattable, or DT functions. These are HTML based, and any HTML based table created must be customized via the code.
Format Entire Tables
Click a table so that the entire object is selected. Go to the object inspector and select the Appearance > Appearance menu.
The following properties can be customized:
- Font family and size
- Built-in Table style
- Table panes such as freezing row/column names when scrolling
- Significance testing
- Decimals and Number format
- Reset formatting changes to the original default
Format Cells
Click on a cell or cells you want to format. You can also format the row and column headers. Once you've selected your desired cell(s) within a table, go to the object inspector and select the Appearance > Appearance menu.
Using this menu, you can customize the selected cell(s). You can also have multiple formatting styles within the same table.
The following properties can be customized:
- Font type, size, and style
- Paragraph formatting, such as vertical and horizontal alignment within the cell
- Fill color
- Border style, placement, and color
- Significance (note that significance properties apply to the whole table)
- Decimals and Number format
Reset to table default formats
If you need to revert the formatting to the table's initial state, you can reset the table to the default format at any time. To do so:
- Highlight the cell(s) you want to revert to the table default formats.
- Right-click > Reset > Table Formats or click Appearance > Appearance > Reset formatting in the object inspector.
Worked Example: Formatting a column of cells
Let's format the first column of the table to add more decimal places.
1. Click the first cell in the column, hold down the Shift key or click and drag, and select all the cells you want to reformat.
2. Select Appearance > Appearance > Decimals and click the Increase decimals button until you get the desired precision.
3. To revert to the default formats, right-click the highlighted cells and select Reset > Cell Formatting.
Worked Example: Changing the font for a cell
Let's say you consider the fact that 33% of respondents Love Coca-Cola an important finding and want it to stand out in the table.
- Select the cell.
- Select Appearance > Appearance > Font and click
to change the font to Bold.
- Increase the font size value to the desired size. In this example, we changed it from 10 to 12.
The results are as follows:
Technical details
For built-in tables (drag-and-drop):
Formats are retained on export to PowerPoint or Excel and are editable in the exported files.
Cell formatting stays with the specific cell it is added to, even when that cell is moved using sorting, Rules, transposing the table, and other methods of changing the look and feel of the table.
For example, the table on the left is not sorted and the table on the right is sorted in descending order based on the "Love + Like" column. The cell shading is retained based on the original shading of each row:
For R-based tables:
Formats are retained on export to PowerPoint or Excel, but are not editable in the exported files.
If the underlying R code changes, data changes, or the table is sorted, the formatting will not 'follow' the cells but will stay where it was.
In the example below, I've sorted the "Love + Like" column in descending order, but the row shading does not follow the cells and remains in an alternating pattern as originally applied:
In addition, once R-based tables are sorted or filtered, cell selection becomes disabled and you will not be able to make cell-specific modifications.
Next
How to Customize Default Row and Column Labels in Displayr Tables
How to Add a Custom Table Footnote