This article describes how to create a CreateCustomTable R table (similar to a table with Autofit checked) below a visualization that aligns logos corresponding to the columns:
A visualization connected to a table. In this example, the table has been sorted based on percentage:
A table of logo URLs saved in Excel or similar containing the Brand name:
1. Select your table of logo URLs in Excel and press CTRL + C.
2. Go to your document page and press CTRL + V. This will create a pasted R table on your page.
3. Select Hide in the menu and drag the table off the page. By default it will be called Pasted.table.data.
4. Go to Calculation > Custom Code.
5. Paste the below under Properties > R CODE:
tab = Pasted.table.data
# match table order
m = match(tab[,"Brand"],rownames(table.Q3.Preferred.cola))
tab = tab[order(m),]
# set image urls
img = tab[,"URL"]
urls = paste0("<img style='margin:0 auto;' width='50' src='", img, "'>")
# create custom table
transpose = T)
- The above code pulls in the data from the pasted URL table.
- We use the match function to ensure that if the rows of the source table change order, the logos will match this change by mapping with the Brand column. You will need to ensure the labels are exactly the same as the table labels.
- The URLs are then placed within an img HTML tag with styling to automatically center and assign the width.
- Finally, we use flipFormat's CreateCustomTable function to display the images and transpose them as a single row.
6. Re-position and re-size your custom table of images by dragging until it lines up with your visualization with the correct spacing.