DB1 <- data.frame(orderItemID = c(1,2,3,4,5,6,7,8,9,10),
orderDate = c("1.1.12","1.1.12","1.1.12","1.1.12","1.1.12", "1.1.12","1.1.12","1.1.12","2.1.12","2.1.12"),
itemID = c(2,3,2,5,12,4,2,3,1,5),
size = factor(c("l", "s", "xl", "xs","m", "s", "l", "m", "xxs", "xxl")),
color = factor(c("blue", "black", "blue", "orange", "red", "navy", "red", "purple", "white", "black")),
customerID = c(33, 15, 1, 32, 14, 55, 33, 78, 94, 23))
Hey guys, I know I asked this question before (formulated bad) -but I hope I can get an answer with another title and a better description. In the data set have items with the same size or the same color, the same ItemID. And every registered user has his unique customerID. I want to identify when a user orders products (more then one) with the same itemID (in different sizes or colors = for example the user with the customerID = 33 orders the same item (ItemID = 2) in two different colors) and mark it in a new column named like "selection order"(for example) with "Yes" or "No".But it should shows me NOT an "Yes", wehn he or she orders an item with an other ID, too. I just want to get an "yes", when there is an order (at the same day or in the past) with the same ID more then once - regardless from other ID´s (other products). I´ve tried a lot already,but nothing works. There are a few thousand different userID´s and ItemId´s-so I can´t subset for every ID. I tried it with the duplicated function - but it´s not leding to a satisfactory solution: The problem with this is, that if the same person orders more then one object (customerID is dublicated then) and another person(customerID) orders an item with the same ID (itemID is dublicated then) it gives me a "yes": and it must be a "No" in this case. (in the example the duplicate function will give me an "yes" at orderItemID 4 instead of an "no")
Thanks for your help!