Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201894

R Customer state concatenate string

$
0
0

I would like to use levenshtein distance to calculate the behaviour of a customer and in which status the customer was in each year concatenated with the previous status.

In Tableau, I have calculated the following column to display in each year the customer can be: (Not a customer (Not), new Customer (New), Same revenue (Same), Less Revenue (Down), More Revenue (UP) and be Lapsed (Lapsed).

Now I would like to display a customer for instance in year 2019 and see his history, like this: NOT-NEW-UP-UP-SAME-SAME-DOWN and extract a customer table of 2019 year customers to calculate levenshtein.

Costomer - Year - Customer State
Apple      2012   NOT
Apple      2013   NOT
Apple      2014   NEW
Apple      2015   UP
Apple      2016   DOWN
Apple      2017   LAPSED
Apple      2018   RETURN
Costomer - Year - Customer State - Cust. concatenated
Apple      2012   NOT         NOT
Apple      2013   NOT         NOT-NOT
Apple      2014   NEW         NOT-NOT-NEW
Apple      2015   UP          ..
Apple      2016   DOWN        ..
Apple      2017   LAPSED      ..
Apple      2018   RETURN      NOT-NOT-NEW-UP-DOWN-LAPSED-RETURN

Many Thanks for your help!


Viewing all articles
Browse latest Browse all 201894

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>