When building dashboards using Displayr, users tend focus on data tables and various visualizations (for understandable reasons). But suppose we want to display key metrics in a top-line bulleted list. How can we achieve this in Displayr? Fortunately, we can do this with some very simple R code.
In the example I will use here, I have three key sample profiling metrics that I want to provide in a bullet point list: population, Internet penetration and household income. In addition, I want to create a dynamic list so that I can filter by specific segments in my data. To do this in Displayr we will:
- Produce the source tables
- Create the dynamic bullet-point objects
- Create filters
- Publish the page
A Displayr Document
Creating the source tables
- Drag each of the three variables from the Data Sets tree onto the Page.
- Tick the Hidden from exported views checkbox in the Properties section of the Object Inspector (on the right side of the screen).
Now that I have the data tables I need, the next step is to create the bullet-point objects using some R code.
Creating the bullet point objects
- Calculation > Custom Code > create box on page.
- Enter the following in R CODE. You will need to modify table names to match the ones in your data.
- Copy and paste the following code. You will need to substitute the table names with the ones in your data. The Unicode character for a bullet is U2022
a <- "\U2022"
pop <- table.Population.size
bullet.1 <- paste(a,round(pop,0),"population")
a <- "\U2022"
internet <- table.Home.internet
bullet.2 <- paste(a," ",round(internet,1),"%"," Internet penetration",sep="")
a <- "\U2022"
income <- table.Household.Income
bullet.3 <- paste(a," $",round(income,0)," household income",sep="")
my.list <- paste(bullet.1, bullet.2, bullet.3, sep = "\n")
- Click Calculate
With a bit of formatting I get the following bulleted output:
Formatting options are available in the Properties section of the Object Inspector under APPEARANCE. Here you can modify things such as the font style, font size, color, border, etc.
Next, I want to create filter using a Life Stage segmentation variable.
- Select the Life Stage variable in the Data Sets tree and from the menus
- Select Insert > Filter > Filters from Selected Data. Displayr creates new filter variables and adds them to my Data Sets tree. These new variables are automatically available to be used as a filter (the Usable as a filter checkbox is ticked automatically in the Object Inspector when the filters are created. You can read more on filtering in Displayr here.
Publishing the page
Lastly, to publish the page
- Select the Publish > Publish as Web Pages
- Under Advanced Options, tick the Hide navigation pane checkbox
- Select Publish. You can dynamically filter the resulting web page output by any of the Life Stages filters. The bullet point list will update accordingly.