R

时间:2017-01-19 13:44:47

标签: r pattern-matching cluster-analysis sequencematcher

我试图编写一个简单的R序列聚类/分组/简化解决方案。我是一个初学者,没有使用R一段时间,所以请原谅简单而愚蠢的问题/解决方案。任务来自SAP,它们代表P2P流程的执行。

概述:

输入:经过一些建议后,我认为输入数据应该覆盖单词而不是它们的ID(我们不想比较数字而是简化单词序列)

选项1:SAP P2P中的步骤序列,如:

Sequence 1:Purchase Order/NB > Goods Receipt/TA > Invoice Receipt/NA > Goods Receipt/TA 
Sequence 2:Purchase Order/NB > Goods Receipt/TA > Invoice Receipt/NA 

我的数据集包含大约700个序列(测试100),它们都是短(5步)和长(甚至超过50)。

问题是我没有(在结果解释期间)想要比较所有700个序列,但我想以某种方式区分相似的序列。通常,特别是对于长序列,在20步之后发现差异,例如:

Seq1:PR> PO> GR> IR> GR> IR > GR> IR>付款

Seq2:PR> PO> GR> IR> IR> GR > GR> IR>付款

最后,它应该导致流程执行中的效率低下。 我的问题是,你有什么建议我如何处理问题之王?在阅读您的评论后,我不认为聚类方法是正确的。我不太关心我们是否应该使用集群或其他东西,重要的是简化流程。

我会感谢任何提示,建议等。

测试数据(>用作分隔符)。

text_data <- c("Invoice Posting (Logistics invoice) > Purchase order/ZR > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Clearing /KZ", 
"Purchase order/NB", "Purchase order/NB > Goods Receipt/WE", 
"Purchase order/NB > Goods Receipt/WE > Goods Return/WE", "Purchase order/NB > Goods Receipt/WE > Goods Return/WE > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ", 
"Purchase order/NB > Goods Receipt/WE > Invoice Posting (Account maintenance) > Invoice Receipt (Account maintenance)/AE", 
"Purchase order/NB > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE", 
"Purchase order/NB > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Clearing /KZ", 
"Purchase order/NB > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Clearing /ZA", 
"Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice)", 
"Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ", 
"Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ", 
"Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ", 
"Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /ZA", 
"Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Clearing /KZ > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ", 
"Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ", 
"Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ", 
"Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /ZA", 
"Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/ZI > Invoice Posting (Logistics invoice) > Clearing /AB", 
"Purchase order/NB > Goods Return/WE", "Purchase order/NB > Goods Return/WE > Credit Note (Logistics invoice)/RE > Credit Note Posting (Logistics invoice) > Clearing /KZ", 
"Purchase order/NB > Goods Return/WE > Credit Note (Logistics invoice)/RE > Credit Note Posting (Logistics invoice) > Clearing /ZA", 
"Purchase order/NB > Goods Return/WE > Credit Note Posting (Account maintenance) > Credit Note (Account maintenance)/AE", 
"Purchase order/NB > Goods Return/WE > Credit Note Posting (Logistics invoice) > Credit Note (Logistics invoice)/RE > Clearing /KZ", 
"Purchase order/NB > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Clearing /KZ", 
"Purchase order/NB > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Clearing /ZA", 
"Purchase order/NB > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Clearing /KZ", 
"Purchase order/UB", "Purchase order/UB > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Goods Receipt/WE", 
"Purchase order/ZB", "Purchase order/ZB > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/IE > Clearing /ZA", 
"Purchase order/ZB > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/IE > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/IE > Clearing /ZA", 
"Purchase order/ZB > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/IE > Invoice Posting (Logistics invoice)", 
"Purchase order/ZB > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/IE > Invoice Posting (Logistics invoice) > Clearing /ZA", 
"Purchase order/ZB > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/IE", 
"Purchase order/ZB > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/IE > Clearing /ZA", 
"Purchase order/ZB > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/IE > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/IE > Clearing /ZA", 
"Purchase order/ZB > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/IE > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/IE > Clearing /ZA", 
"Purchase order/ZR", "Purchase order/ZR > Goods Receipt/WE", 
"Purchase order/ZR > Goods Receipt/WE > Goods Return/WE", "Purchase order/ZR > Goods Receipt/WE > Goods Return/WE > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ", 
"Purchase order/ZR > Goods Receipt/WE > Invoice Posting (Account maintenance) > Invoice Receipt (Account maintenance)/AE", 
"Purchase order/ZR > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE", 
"Purchase order/ZR > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Clearing /KZ", 
"Purchase order/ZR > Goods Receipt/WE > Invoice Receipt (Account maintenance)/AE > Invoice Posting (Account maintenance)", 
"Purchase order/ZR > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice)", 
"Purchase order/ZR > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /AB", 
"Purchase order/ZR > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /AB > Credit Note (Logistics invoice, cancel)/RE > Credit Note Posting (Logistics invoice, cancel) > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ", 
"Purchase order/ZR > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /AB > Credit Note (Logistics invoice, cancel)/RE > Invoice Receipt (Logistics invoice)/RE > Credit Note Posting (Logistics invoice, cancel) > Invoice Posting (Logistics invoice) > Clearing /KZ", 
"Purchase order/ZR > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /AB > Credit Note (Logistics invoice, cancel)/RE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Credit Note Posting (Logistics invoice, cancel) > Clearing /KZ", 
"Purchase order/ZR > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ", 
"Purchase order/ZR > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ", 
"Purchase order/ZR > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Credit Note (Logistics invoice)/RE > Credit Note Posting (Logistics invoice)", 
"Purchase order/ZR > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Credit Note (Logistics invoice)/RE > Credit Note Posting (Logistics invoice) > Clearing /KZ", 
"Purchase order/ZR > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Clearing /KZ", 
"Purchase order/ZR > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ", 
"Purchase order/ZR > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ", 
"Purchase order/ZR > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE", 
"Purchase order/ZR > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Clearing /KZ", 
"Purchase order/ZR > Invoice Receipt (Logistics invoice)/RE > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Clearing /KZ", 
"Purchase order/ZR > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Clearing /KZ", 
"Purchase requisition/NB", "Purchase requisition/NB > PR release - MRP /  RFQ / purchase order", 
"Purchase requisition/NB > PR release - RFQ / purchase order", 
"Purchase requisition/NB > Purchase order/NB", "Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE", 
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Posting (Account maintenance) > Invoice Receipt (Account maintenance)/AE", 
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE", 
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Clearing /AB", 
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Clearing /KZ", 
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Clearing /ZA", 
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ", 
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ", 
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ", 
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice)", 
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /AB", 
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /AB > Credit Note (Logistics invoice, cancel)/RE > Invoice Receipt (Logistics invoice)/RE > Credit Note Posting (Logistics invoice, cancel) > Invoice Posting (Logistics invoice) > Clearing /KZ", 
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /AB > Credit Note (Logistics invoice, cancel)/RE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Credit Note Posting (Logistics invoice, cancel) > Clearing /KZ", 
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ", 
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ", 
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ", 
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /ZA", 
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ", 
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /ZA", 
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Clearing /KZ", 
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice)", 
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ", 
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/ZI > Invoice Posting (Logistics invoice) > Clearing /AB", 
"Purchase requisition/NB > Purchase order/NB > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE", 
"Purchase requisition/NB > Purchase order/NB > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Clearing /AB", 
"Purchase requisition/NB > Purchase order/NB > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Clearing /KZ", 
"Purchase requisition/NB > Purchase order/NB > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Clearing /ZA", 
"Purchase requisition/NB > Purchase order/ZB > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/IE", 
"Purchase requisition/NB > Purchase order/ZB > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/IE > Clearing /ZA", 
"Purchase requisition/NB > Purchase order/ZB > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/IE", 
"Purchase requisition/NB > Purchase order/ZB > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/IE > Clearing /ZA", 
"Purchase requisition/RV")

0 个答案:

没有答案