NPS: Get Net Promoter Score

View source: R/marketing.R

NPSR Documentation

Get Net Promoter Score

Description

Calculates the Net Promoter Score for grouped or ungrouped data.

Usage

NPS(x, rating, c_group, df_levels)

Arguments

x

dataframe

rating

string identifying the column of the rating

c_group

string with the column name to group the data frame.

df_levels

data frame containing range for each type (Promoters, Passives, Detractors) df_levels <- tibble::tibble(Detractors = c(1,6), Passives = c(7,8), Promoters = c(9,10))

Details

NPS = Ratio Promoters - Ratio Detractors, whereas the Ratio of Promoters is calculated by count of Promoters / count total and the the Ratio of Detractors is calculated by count of Detractors / count total. If the c_group parameter is available the NPS score will be calculated for each group. If the df_levels parameter is provided the level to find Promoters, Passives and Detractors can be defined by this definition. The parameter df_levels is by standard: Detractors (1...6), Passives (7,8), Promoters (9,10) whereas the number shall be be integers only.

Examples

library(tidyverse)
# Test data
df_data <- tibble::tibble(user   = c(letters[1:10],rep("a",5)),
                   Feedback = c(1:10,rep(10,5)),
                   Gruppe = c(rep("A",10),rep("B",5)))

NPS(df_data, "Feedback", "Gruppe")
NPS(df_data, "Feedback")

df_levels <- tibble::tibble(Detractors= c(1,3),Passives= c(4,4), Promoters= c(5,5))
df_data <- tibble::tibble(user   = c(letters[1:10],rep("a",5)),
                  Feedback = c(1:5,rep(5,10)),
                  Gruppe = c(rep("A",10),rep("B",5)))
NPS(df_data, "Feedback", "Gruppe",df_levels)
NPS(df_data, "Feedback",df_levels = df_levels)

wagnius-GmbH/slvwagner documentation built on Jan. 19, 2025, 7:10 a.m.