I want to get the earliest day in the data set for every MemberID
. But i need to do a ifelse in the aggregate
function to sort out some data. Because there are lots of transaction record but i only need the earliest one after the user adopt to mobile channel (Mobile=="1"
).
aggregate(Mobile$OrderDate, by=list(MemberID=Mobile$MemberID),min)
aggregate(OrderDate ~ MemberID, data=Mobile, function(x) if(Mobile=="1")
min(OrderDate) else NA )
Should be a list like this:
MEMBERID Date
212 2009/04/20
....