类别重叠分析 [英] Category Overlap Analysis

查看:29
本文介绍了类别重叠分析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试进行一些类别重叠分析,并且需要帮助.

I am trying to perform some category overlap analysis and need help.

我有由客户服务票构成的数据.票证上标有类别数据.票证可以包含多个类别标签.

I have data made up of customer service tickets. The tickets are labeled with category data. Tickets can contain multiple category labels.

我有一个查询,其中提取票证ID和类别.对于具有多个类别的ID,我会获得多行.我正在寻找一种显示类别重叠的方法,例如:多少票具有类别A,具有A和B,B和C等.

I have a query that pulls ticket ids and categories. I get multiple rows for IDs with more than one category. I am looking for a way to show the category overlap, for example: how many tickets have category A, have A and B, B and C, etc..

我希望能够在Excel或R中执行此操作,以便可以轻松地将其合并到我的管理报告中.

I would like to be able to perform this in Excel or R so that it can easily be incorporated into reports for my management.

我的查询输出示例如下:

An example of my query output is as follows:

category  ticket_id

A   3975472 
D   3975472 
B   3975472 
P   3969484 
B   3969484 
S   3969484 
P   3968360 
C   3968360 
D   3964048 
A   3964048 
C   3963748 
E   3963748

谢谢!

我希望获得这样的输出:

I was hoping to achieve an output such as:

推荐答案

Excel 中,您可以使用数据透视表来做到这一点:

In Excel you could do this with a Pivot table:

R 中,假设数据位于名为 df 的数据框中,则可以执行以下操作:

In R, assuming the data is in a data frame named df, you could do something like this:

table(df$ticket_id, df$category)
#         A B C D E P S
# 3963748 0 0 1 0 1 0 0
# 3964048 1 0 0 1 0 0 0
# 3968360 0 0 1 0 0 1 0
# 3969484 0 1 0 0 0 1 1
# 3975472 1 1 0 1 0 0 0

这篇关于类别重叠分析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆