The Price Sensitivity Meter produces a series of intersection data points and aggregated data which can be useful for further analysis or reporting. This article outlines how to extract this data.
Requirements
A Price Sensitivity Meter created in Displayr as per How to Create a Price Sensitivity Meter (Van Westendorp Plot).
Method - Chart data
The underlying data used in the Price Sensitivity Meter can be extracted via R code:
1. Click the + icon in the toolbar > Calculation > Custom code.
2. We can use the attr function to return the ChartData attribute of our psm output by placing the below in the R CODE field:
attr(psm,"ChartData")
3. If the name of your chart is different under Properties > GENERAL > Name, you will need to replace psm in the above code.
The table will include the price variables in the columns and the price points in the rows.
Method - Intersection points
The intersection data points in the Price Sensitivity Meter can likewise be extracted via R code.
The way to reference the first intersection point label in a chart called psm, for example, is to include the index number (i.e. 1) of this data point in the annotations object and pull out the text parameter:
psm$htmlwidget$x$layoutAttrs[[2]]$annotations[[1]]$text
To return only the intersection point value from the X axis, we need to reference x instead of text:
psm$htmlwidget$x$layoutAttrs[[2]]$annotations[[1]]$x
To return only the intersection point value from the Y axis, we need to reference y and multiply by 100 due to being a percentage:
psm$htmlwidget$x$layoutAttrs[[2]]$annotations[[1]]$y*100
Note, when the Show option is set to Likelihood to buy, Revenue, or Likelihood to buy and Revenue, we need to instead reference the third layoutAttrs item by changing [[2]] to [[3]]:
psm$htmlwidget$x$layoutAttrs[[3]]$annotations[[1]]$x
Example 1 - Data point labels
To return all 4 standard data point labels when Attitude of respondents is selected in the Show option, we need to individually reference the text fields of each annotation as follows:
# Get output - change 'psm' to match chart name under 'Properties > GENERAL > Name'
z = psm
# Return each of the individual data point labels
cheap = z$htmlwidget$x$layoutAttrs[[2]]$annotations[[1]]$text
optimal = z$htmlwidget$x$layoutAttrs[[2]]$annotations[[2]]$text
indifferent = z$htmlwidget$x$layoutAttrs[[2]]$annotations[[3]]$text
expensive = z$htmlwidget$x$layoutAttrs[[2]]$annotations[[4]]$text
# Combine and remove line breaks
intersection.labels = c(cheap,optimal,indifferent,expensive)
intersection.labels = gsub("<br>"," ",intersection.labels)
Example 2 - Intersection price points and proportions
To return a table of all intersection points with price points and proportions included, we can use the following code:
# Get output - change 'psm' to match chart name under 'Properties > GENERAL > Name'
z = psm
# Get the last 'layoutAttrs' item
item = length(z$htmlwidget$x$layoutAttrs)
# Return each of the individual data points
cheap.x = z$htmlwidget$x$layoutAttrs[[item]]$annotations[[1]]$x
optimal.x = z$htmlwidget$x$layoutAttrs[[item]]$annotations[[2]]$x
indifferent.x = z$htmlwidget$x$layoutAttrs[[item]]$annotations[[3]]$x
expensive.x = z$htmlwidget$x$layoutAttrs[[item]]$annotations[[4]]$x
# Return each of the individual data point proportions
cheap.y = z$htmlwidget$x$layoutAttrs[[item]]$annotations[[1]]$y*100
optimal.y = z$htmlwidget$x$layoutAttrs[[item]]$annotations[[2]]$y*100
indifferent.y = z$htmlwidget$x$layoutAttrs[[item]]$annotations[[3]]$y*100
expensive.y = z$htmlwidget$x$layoutAttrs[[item]]$annotations[[4]]$y*100
# Combine
x.points = c(cheap.x,optimal.x,indifferent.x,expensive.x)
y.points = c(cheap.y,optimal.y,indifferent.y,expensive.y)
intersection.points = cbind("Price" = x.points, "Proportion of respondents" = y.points)
This same approach can be used to return the Trial intersection point when the Likelihood to buy setting is used and the Revenue intersection point when Revenue is used.
Next
How to Create a Price Sensitivity Meter (Van Westendorp Plot)
How to Extract Information from an Item using R