Вероятно, вам нужно назначить уникальный номер каждому product
и claim_type
.
library(dplyr)
df %>%
group_by(product, claim_type) %>%
mutate(actual_result = paste0('A', row_number()))
# date order product claim_type item_count desired_result actual_result
# <fct> <fct> <fct> <fct> <int> <fct> <chr>
#1 2019-12-01 QN123456 Jacket Alteration 1 A1 A1
#2 2019-12-07 QN123456 Jacket Alteration 1 A2 A2
#3 2019-12-11 QN123456 Pants Alteration 1 A1 A1
#4 2019-12-13 QN123456 Pants Alteration 1 A2 A2
#5 2019-12-18 QN123456 Pants Alteration 1 A3 A3
#6 2019-12-19 QN123456 Pants Alteration 1 A4 A4
данные
df <- structure(list(date = structure(1:6, .Label = c("2019-12-01",
"2019-12-07", "2019-12-11", "2019-12-13", "2019-12-18", "2019-12-19"
), class = "factor"), order = structure(c(1L, 1L, 1L, 1L, 1L,
1L), .Label = "QN123456", class = "factor"), product = structure(c(1L,
1L, 2L, 2L, 2L, 2L), .Label = c("Jacket", "Pants"), class = "factor"),
claim_type = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = "Alteration",
class = "factor"),item_count = c(1L, 1L, 1L, 1L, 1L, 1L),
desired_result = structure(c(1L,2L, 1L, 2L, 3L, 4L),
.Label = c("A1", "A2", "A3", "A4"),class = "factor")),
row.names = c(NA, -6L), class = "data.frame")