R | Visualization
| 17 May 2017 | by Tim Bock
Easily add images to a correspondence analysis plot in R

You can take your correspondence analysis plots to the next level by including images. Better still, you don’t need to paste in the images after the analysis is complete – you can include them right from the start.

The plot above shows the results of a correspondence analysis based on data from a study of how people perceive different carbonated soft drinks. Logos, which are from jpeg files, are shown instead of brand names, with lines and dots indicating the precise location of the brands. This post describes how to create this plot using R.

Step 1: Installing the packages

The first step is to install the flipDimensionReduction package and a series of dependent packages, which are listed below. Depending on how your R has been setup, you may need to install none of these (e.g., if using Displayr), or you may need to install more packages.


Step 2: Create the images

The next step is to create some images of similar sizes and have the files hosted somewhere. The function that creates the correspondence analysis expects URLs rather than local files.

Step 3: Create a data table

The main input to the correspondence analysis is a table of data. I have used data from the flipExampleData package, giving the table a name of csd.

data(csd.perceptions, package = "flipExampleData")
csd = csd.perceptions * 100

Step 4: Use CorrespondenceAnalysis

Next, we call the CorrespondenceAnalysis function. Here, we use the default arguments, other than telling it we want a scatterplot, and passing in the logos that we want to display:

 output = "Scatterplot",
 logos = c("",

If you check the help for this function, you will find parameters for lots of different types of customization, including resizing the logos, adding titles, etc.

Step 5: Rearrange any images using drag and drop

The resulting visualization, shown below, is an HTMLwidget, and the underlying d3 code allows you to drag and drop to rearrange the images and other labels. If you use Displayr to publish the R code, the state will be remembered (i.e., it will remember where you have moved things to).

To play around with the R code for this post in Displayr, click here.

The example in this post displays correctly in normal desktop installations of R for Windows, but due to a bug in R Studio does not render in their browser.

Author: Tim Bock

Tim Bock is the founder of Displayr. Tim is a data scientist, who has consulted, published academic papers, and won awards, for problems/techniques as diverse as neural networks, mixture models, data fusion, market segmentation, IPO pricing, small sample research, and data visualization. He has conducted data science projects for numerous companies, including Pfizer, Coca Cola, ACNielsen, KFC, Weight Watchers, Unilever, and Nestle. He is also the founder of Q, a data science product designed for survey research, which is used by all the world’s seven largest market research consultancies. He studied econometrics, maths, and marketing, and has a University Medal and PhD from the University of New South Wales (Australia’s leading research university), where he was an adjunct member of staff for 15 years.

Also published on Medium.

Follow by Email
follow us in feedly

Explore the data.

You can play around with the R code for this post in Displayr.


3 Comments. Share your thoughts.

  1. Paul Vaca

    Felicitaciones, sus post son de gran ayuda para el uso de la Heramienta R y perniten un uso y aprovechamiento de los datos, cintribuye al conocimiento y a entender los entornos economicos. Siga adelante!!!


Leave a Reply

Your email address will not be published. Required fields are marked *

Human? *