繁体   English   中英

如何在R中合并列

[英]How to combine Columns in R

http://imgur.com/a/q4IdW “表格”

嗨,我有一个编码为投诉的文件,您可以在上面的链接中看到它,我需要找到一种方法来组合4列(主要问题,次要问题等),以便我可以对所有一起发行。 投诉可能有多个问题,因此这就是为什么要进行细分,但是出于分析目的,我希望将所有问题列都视为相同。 我是R的新手,所以请尝试用无法理解或可以很快使用Google的术语说话

> str(mydata)
'data.frame':   136 obs. of  25 variables:
 $ ï..Issue.ID                  : Factor w/ 136 levels "CAO-2017-01",..: 20 21 22 23 24 25 26 27 28 29 ...
 $ Reviewer.ID                  : Factor w/ 1 level "Vinokurov, A": 1 1 1 1 1 1 1 1 1 1 ...
 $ Review.Date                  : Factor w/ 3 levels "6/30/2017","7/14/2017",..: 1 1 1 1 1 2 2 2 2 2 ...
 $ CBA.ZIP.CODE                 : Factor w/ 61 levels "Allentown-Bethlehem-Easton, PA",..: 29 13 24 10 29 13 10 9 47 39 ...
 $ Source.of.complaint          : Factor w/ 7 levels "Advocate","Beneficiary",..: 7 7 3 7 6 7 2 3 3 3 ...
 $ Primary.Issue.Category       : Factor w/ 10 levels "Billing, coverage, coordination of benefits",..: 3 8 4 4 4 4 7 4 4 4 ...
 $ Secondary.Issue.Category     : Factor w/ 15 levels "","ABN issues ",..: 4 1 15 1 15 3 3 15 15 15 ...
 $ Third.Issue.Category         : Factor w/ 12 levels "","- Error -",..: 1 1 1 1 1 5 1 10 1 1 ...
 $ Fourth.Issue.Category        : Factor w/ 2 levels "","Low quantity/quality": 1 1 1 1 1 1 1 1 1 1 ...
 $ Reviewer.Issue.Notes         : logi  NA NA NA NA NA NA ...
 $ Primary.Equipment.Category   : Factor w/ 13 levels "Commode chairs",..: 9 7 2 8 2 9 10 10 2 2 ...
 $ Secondary.Equipment.Category : Factor w/ 7 levels "","- Error -",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ Third.Equipment.Category     : Factor w/ 10 levels "","- Error -",..: 1 1 1 1 1 2 1 2 1 1 ...
 $ Fourth.Equipment.Category    : logi  NA NA NA NA NA NA ...
 $ Reviewer.Equipment.Notes     : logi  NA NA NA NA NA NA ...
 $ Primary.Resolution.Category  : Factor w/ 16 levels "Beneficiary educated about DMEPOS\n",..: 9 12 15 12 5 14 13 9 5 10 ...
 $ Secondary.Resolution.Category: Factor w/ 18 levels "","- Error -",..: 1 1 3 1 4 7 7 17 15 1 ...
 $ Third.Resolution.Category    : Factor w/ 8 levels "","Beneficiary educated about inquiry ",..: 1 1 1 1 3 1 1 1 1 1 ...
 $ Fourth.Resolution.Category   : logi  NA NA NA NA NA NA ...
 $ Reviewer.Resolution.Notes    : logi  NA NA NA NA NA NA ...
 $ Future.Action                : Factor w/ 4 levels "no","No","yes",..: 4 4 2 2 2 2 3 4 1 1 ...
 $ Coder.1                      : Factor w/ 2 levels "Briskin-Limehouse, A",..: 1 1 1 1 1 2 2 2 2 2 ...
 $ Coder.1.Coded.Date           : Factor w/ 4 levels "6/30/2017","7/13/2017",..: 1 1 1 1 1 2 2 2 2 2 ...
 $ Coder.2                      : Factor w/ 1 level "Aliu, F": 1 1 1 1 1 1 1 1 1 1 ...
 $ Coder.2.Coded.Date           : Factor w/ 7 levels "6/30/2017","7/12/2017",..: 1 1 1 1 1 2 3 3 3 3 ...
> 

我得到的是:您有这样的事情:

        issue_1 issue_2 issue_3 issue_4
person1    0       0       0       1
person2    1       1       0       1
person3    1       0       1       1

其中1是问题的存在,0是相反的,来自某项调查。

你想展示这样的东西吗?

Issue_1 appeared 2x 
issue_2 appeared 1x
issue_4 appeared 3x

您能再检查一下然后回答吗?

请也使用str(your_data) ,因为您无法链接我们

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM