Skip to Content
Author's profile photo Andreas Forster

Custom R Component – Density Plots for Multiple Variables

Density plots can be helpful to understand the distribution of a variable. This component uses a feature introduced with SAP Predictive Analytics 2.2 to output multiple R charts

  • A density plot that displays the distributions of all selected variables overlayed in the same chart
  • Individual density plots for each selected variable

All.png

Disclaimer

Please note that this component is not an official release by SAP and that it is provided as-is without any guarantee or support. Please test the component to ensure it works for your purposes.

Prerequisites

R libraries ggplot2, reshape2 and RColorBrewer must be installed.

Limitations

Please let me know should you encounter any limitations.

Usage

These parameters can be set by the user.

Parameter Description
Numerical Variables

One or more numerical variables to be displayed in the density plots.

No output columns added by this component.

How to Implement

The component can be downloaded as .spar file from GitHub. Then deploy it as described here. You just need to import it through the option “Import/Model Component”, which you will find by clicking on the plus-sign at the bottom of the list of the available algorithms.

Example

You can try out the component wtih our own data or with the file EuropeanUrbanAudit.csv. It contains a small part of a perception survey done by Eurostat in 2009 about the quality of life in 75 different European cities. Categories that were asked for are (in abbreviated terms): Affordable Housing, Availability of Good Jobs, Integration of Foreigners, Satisfaction with Public Transport, Cultural Facilities, Sport Facilities and Green Spaces. The number indicates a synthetic index of satisfaction (0-100). So the higher the value, the more satisfied people are.

The screenshot at the top of this article shows the overlay plot of all densities. Here is an example of one of the individual density plots.

/wp-content/uploads/2015/07/single_746844.png

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      This is very useful! Thanks a million for sharing Andreas, much appreciated.