У меня есть нижеупомянутый столбец в R:
structure(list(product = c("-", "A", "B", "CC", "XA", "RD",
"IS", "FD"), count.1 = c(969, 324, 11, 161, 185, 79, 231, 9),
Per.1 = c(49.21, 16.46, 0.56, 8.18, 9.4, 4.01, 11.73,
0.46), remark = c("F2", "", "F1", "NA", "K4", "-",
"-", "-"), count.2 = c("1708", "215", "35", "9", "2", "-",
"-", "-"), per.2 = c(86.74, 10.92, 1.78, 0.46, 0.1,
NA, NA, NA), status = c("Go", "hold", "-", "-", "-", "-", "-",
"-"), count.3 = c("1717", "200", "52", "-", "-", "-", "-",
"-"), per.3 = c(87.2, 10.16, 2.64, NA, NA, NA, NA,
NA)), .Names = c("product", "count.1", "per.1", "remark",
"count.2", "per.2", "status", "count.3", "per.3"
), row.names = c(NA, -8L), class = c("data.table", "data.frame"
), .internal.selfref = <pointer: 0x185b2f8>)
Я хочу суммировать от столбца 2 до 9 и добавить %
знак в столбцах 3,6 и 9.
Вывод запроса типа:
product count.1 per.1 remark count.1 per.2 Status count.3 per.3
- 969 49.21% F2 1708 86.74% Go 1717 87.20%
A 324 16.46% 215 10.92% Hold 200 10.16%
B 11 0.56% F1 35 1.78% - 52 2.64%
CC 161 8.18% NA 9 0.46% - - NA
XA 185 9.40% K4 2 0.10% - - NA
RD 79 4.01% - - NA - - NA
IS 231 11.73% - - NA - - NA
RD 9 0.46% - - NA - - NA
Total 1969 100.01% - 1969 100.00% - 1969 100.00%