简体   繁体   中英

How to combine Columns in R

http://imgur.com/a/q4IdW "table"

Hi, I have a file that has coded complaints, you can see it in the link above, and I need to find a way to combine the 4 columns(primary issue, secondary issue, etc) so that I can then sum up all the issues together. it is possible for a complaint to have multiple issues, so that is why it is broken down like this, but for analysis purposes I want to treat all the issue columns as the same. I am very new to R so please try and speak in terms ill be able to understand or can google fairly quickly

> 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 ...
> 

What i got is: You have something like this:

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

where 1 is presence of issue, and 0 the opposite, took from some survey.

would you like to show something like this?

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

Could you check and answer again, please?

Please, use str(your_data) too, since you can't link us

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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