[英]Reshaping and calculation of data in R
I am new to R and I would like to use it to write a simple code to visualize the Defect removal efficiency for software defect (Fixed defects / Unresolved defects) * 100 based on the priority of the bugs我是R的新手,我想用它写一个简单的代码来可视化软件缺陷的缺陷去除效率(已修复缺陷/未解决缺陷)* 100基于错误的优先级
I have exported some data sample from Jira:我从 Jira 导出了一些数据样本:
Priority Resolution Created Resolved
P3 Unresolved 28.02.2017 28.02.2017
P3 Unresolved 28.02.2017 28.02.2017
P1 Fixed 27.02.2017 06.03.2017
P2 Fixed 27.02.2017 14.03.2017
P1 Unresolved 24.02.2017 13.03.2017
P1 duplicate 21.02.2017 02.03.2017
P1 Fixed 24.02.2017 07.03.2017
I would like to reshape this table and at the same time do some calculations.我想重塑这张表,同时做一些计算。 This is very easy using excel pivot tables but I would like to script it with R
使用 excel 数据透视表这很容易,但我想用 R 编写脚本
Expected output:预期输出:
Resolution P1 P2 P3 Grand Total
duplicate 2 2
Fixed 4 4 1 9
Unresolved 2 2 4 8
Grand Total 8 6 5 19
Also, I would like to see the trend of the resolution (Something like the following)另外,我想看看分辨率的趋势(类似于以下内容)
Dates P1 unresolved P1 fixed P1 DRE, % P2 unresolved P2 fixed P2 DRE, %
date1 5 0 0% 20 3 15%
date1 + 7 6 2 33% 37 4 11%
date1 + 14 9 3 33% 40 4 10%
How this could be achieved by R programming?这如何通过 R 编程来实现?
These functions from the janitor package mimic Excel's PivotTable: janitor 包中的这些函数模仿 Excel 的数据透视表:
library(janitor)
dat %>%
tabyl(Resolution, Priority) %>%
adorn_totals(c("row", "col"))
Resolution P1 P2 P3 Total
duplicate 1 0 0 1
Fixed 2 1 0 3
Unresolved 1 0 2 3
Total 4 1 2 7
Data used:使用的数据:
dat <- read.table(text = "Priority Resolution Created Resolved
P3 Unresolved 28.02.2017 28.02.2017
P3 Unresolved 28.02.2017 28.02.2017
P1 Fixed 27.02.2017 06.03.2017
P2 Fixed 27.02.2017 14.03.2017
P1 Unresolved 24.02.2017 13.03.2017
P1 duplicate 21.02.2017 02.03.2017
P1 Fixed 24.02.2017 07.03.2017", header = TRUE)
Here is an answer for the first part using just table.这是仅使用表格的第一部分的答案。 I saved your data into a file in the same directory, comma-separating the values.
我将您的数据保存到同一目录中的文件中,以逗号分隔值。
data = read.csv('jira_data.csv')
new_data = table(data$Resolution, data$Priority)
new_data = addmargins(new_data)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.