Time difference between quarters

#using zoo library to transform my dates into quarters
sample_dataframe$First_purchase_quarter <- as.yearqtr((sample_dataframe$First_Purchase_date), "%Y-%m-%d")
sample_dataframe$Recent_Purchase_quarter <- as.yearqtr((sample_dataframe$Recent_Purchase_date), "%Y-%m-%d")

sample_dataframe$diff <- (sample_dataframe[, 4] - sample_dataframe[, 3]) * 4
head(sample_dataframe$diff)
[1] 1 7 2

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top