我正在尝试连接特定客户ID/订单日期组的字符串。我有一个 Dataframe :
customerid <- c("A1", "A1", "A2", "A2", "A3", "A3", "A3", "A4")
orderdate <- c("2018-09-14", "2018-09-14", "2018-09-15", "2018-09-15", "2020-08-21", "2020-08-21","2020-08-21", "2018-08-10")
orderid <- c("1", "2", "3", "4", "5", "6", "7", "8")
status <- c("review", "review", "review", "negative", "positive", "review", "review", "review")
df <- data.frame(customerid, orderdate, orderid, status)
我尝试按客户ID和订单日期分组。然后,对于每个组,我希望除1个“review”外的所有“review”更改为“duplicate”,并按customerid/orderdate连接所有订单ID。结果将为:
customerid <- c("A1", "A1", "A2", "A2", "A3", "A3", "A3", "A4")
orderdate <- c("2018-09-14", "2018-09-14", "2018-09-15", "2018-09-15", "2020-08-21", "2020-08-21","2020-08-21", "2018-08-10")
orderid <- c("1,2", "1,2", "3,4", "3,4", "5,6,7", "5,6,7", "5,6,7", "8")
status <- c("review", "duplicate", "review", "negative", "positive", "review", "duplicate", "review")
df <- data.frame(customerid, orderdate, orderid, status)
泰!
2条答案
按热度按时间aij0ehis1#
你可以试试
tzdcorbm2#
你可以试试
我不确定
negative
/positive
的确切条件,但是