for(i in length(refunded_customers$buyer_email)) {
x <- i+1
if(refunded_customers$buyer_type[i] == "regular" &&
any(refunded_customers$buyer_email[i] ==
refunded_customers$buyer_email[
x:tail(which(
refunded_customers$transaction_date ==
(refunded_customers$transaction_date[i] + 90)
), n=1)
]
)
) {
refunded_customers[i,10] <- "not churn"
}
when I use above code I get "refunded_customers$transaction_date[i] + : argument of length 0" error
However when I run the part causing the error outside of the loop (like the one below) it works. Can you identify what the problem is?
any(refunded_customers$buyer_email[12]== refunded_customers$buyer_email[32:(tail(which(refunded_customers$transaction_date==(refunded_customers$transaction_date[12]+30)), n=1))])