Sample
df <- data.frame(
Birth_Date = c("1952-03-21", "1963-12-20", "1956-02-25", "1974-08-04", "1963-06-13", "1956-11-20", "1974-03-07", "1963-10-23", "1952-11-24", "1974-12-16"),
Items_Amount = c(68,189,69,19,299,79,149,149,29,189)
)
df
I'm trying to analyse a data-set, which has column Item_Amount(in $) and customer's birth-date spread across 90 years. Goal is to compare the sales percentage based on suitable age groups.
The main data frame contains date "BirthDate" column from "1902-02-13" to "1991-12-11" as dates not string
'data.frame': 350241 obs. of 1 variable:
$ BirthDate: Date, format: "1964-06-08" "1964-06-08" "1964-06-08" "1964-06-08" ...
> min(Trans_Cust$Birth_Date)
[1] "1902-02-13"
> difftime(max(Trans_Cust$Birth_Date),min(Trans_Cust$Birth_Date),units = "auto")
Time difference of 32808 days
> max(Trans_Cust$Birth_Date)
[1] "1991-12-11"
How Do I find the present ages based on "Birth_Date" column, store it to new column "Present_ages" and then proceed with calculating sum(Items_Amount)
grouped by present_ages.