rnps()
generates n
random possible net promoter scores based on a sample
of promoter, passive, and detractor responses.
qnps()
simulates a sample of NPS scores, then produces sample quantiles
corresponding to the given probabilities.
Usage
rnps(n, promoters, passives, detractors)
qnps(
p,
promoters,
passives,
detractors,
sims = 10000,
na.rm = FALSE,
names = FALSE,
...
)
Arguments
- n
number of observations to generate.
- promoters, passives, detractors
counts of promoters, passives, and detractors
- p
vector of quantiles.
- sims
number of simulated NPS scores to generate and use in the sample quantile calculation.
- na.rm
logical; if true, any
NA
andNaN
s are removed before the quantiles are computed.- names
logical; if true, the result has a
names
attribute. Set toFALSE
to speedup with manyprobs
.- ...
additional params to pass to
stats::quantile()
Examples
# generate 10 nps scores based on a sample of 100 respondents
rnps(10, 70, 20, 10)
#> [1] 0.6315986 0.5566031 0.5924313 0.6293267 0.6126970 0.6664050 0.5764176
#> [8] 0.5217812 0.6472890 0.5826048
# estimate the 95% nps quantile range of a sample of 100 respondents
qnps(c(0.025, 0.5, 0.975), 70, 20, 10)
#> [1] 0.4619675 0.6042957 0.7202297