[R] How to combine two rows in a data table into a third new row, such that the values in the row are added together in the new row?

Gregg g@@@powe|| @end|ng |rom protonm@||@com
Wed May 6 06:50:17 CEST 2020




I have a data table titled: "dt_count" - it contains:

> "","STATUS","N"
> "1","Resolved",650
> "2","Assigned",135
> "3","Closed",530
> "4","In Progress",56
> "5","Pending",75
> "6","Cancelled",20
> 

> I need to change the "dt_count" data table to a new data table that looks like this:
> 

> "","STATUS","N"
> "1","Resolved/Closed",1180
> "2","Assigned",135
> "3","In Progress",56
> "4","Pending",75
> "5","Cancelled",20
> 

> Or, to state the question:
> 

> I need to combine the "Resolved" Row with the "Closed" Row, into a Third new row titled "Resolved/Closed", whereby the "N" ticket count in each of the "Resolved" row and the "Closed" row are added together in the third new "Resolved/Closed" - also, would need the old "Resolved" Row with the "Closed" Rows to go away.
> 

> To complicate the issue, the rows in the "dt_count" data table when they are output, are not always in the same order.
> 

> I have the data.table library is installed.
> 

> I'm thinking there is a very easy way to do this... but I am not finding it. I've spent several hours searching thru among other things  - several data table cheatsheets, and I've also read thru this:
> https://cran.r-project.org/web/packages/data.table/vignettes/datatable-intro.html
> 

> Just can't sort it out. Just started using R a few weeks ago.
> 

> Any help would be so very much appreciated!
> 

> Thanks.
> 

> Gregg
> AZ, USA
> 



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 477 bytes
Desc: OpenPGP digital signature
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20200506/83cb4840/attachment.sig>


More information about the R-help mailing list