nps: Calculate a Net Promoter Score

Description Usage Arguments Value Author(s) See Also Examples

Description

This function calculates a Net Promoter Score from a vector of Recommend scores, ideally numeric ones. An attempt will be made to coerce factor, or character data. NA values, either in the data, or generated by type coercion, are automatically omitted from the calculation. No warning is given in the former case. Net Promoter Scores generated are on a [-1,1] scale; you may want to multiply them by 100 (and perhaps round them!) prior to presentation.

Usage

1
2
3
nps(x, breaks = getOption("nps.breaks"), na.rm = FALSE)

nps_(x)

Arguments

x

A vector of Recommend scores

breaks

A vector of length three, giving integer Likert scale break-points for Net Promoter categories. Best practice is to set the values you'd like to use at the start of a session, with options(nps.breaks = c(0, 6, 8, 10)) (for the usual setting of 0-6 being Detractors, 7-8 being Passives and 9-10 being Promoters, also the package default), or whichever values you would like. However, a vector may be supplied directly.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

Value

a Net Promoter Score.

Author(s)

Brendan Rocks foss@brendanrocks.com

See Also

npc

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# This will generate 1000 dummy Likelihood to Recommend reponses
x <- sample(
  0:10, 1000, replace = TRUE,
  prob = c(0.02, 0.01, 0.01, 0.01, 0.01, 0.03, 0.03, 0.09, 0.22, 0.22, 0.35)
)

# Here are the proportions of respondents giving each Likelihood to
# Recommend response
prop.table(table(x))

# Here's a histrogram of the scores
hist(
  x, breaks = -1:10,
  col = c(rep("red", 7), rep("yellow", 2), rep("green", 2))
)

# Here's a barplot. It's very similar, though for categorical responses
# it's often slightly easier to interpret.
barplot(
 prop.table(table(x)),
 col = c(rep("red", 7), rep("yellow", 2), rep("green", 2))
)

# Here's the NPS
nps(x)

# You can round it if you like
round(nps(x)) ; round(nps(x), 1)

brendan-R/nps documentation built on May 13, 2019, 5:07 a.m.