Hello..I'm having a hard time running this code:
data = read.delim(file = 'purchases.txt', header = FALSE, sep = '\t', dec = '.')
colnames(data) = c('customer_id', 'purchase_amount', 'date_of_purchase')
data <- with(data, data[!(customer_id == "" | is.na(customer_id)), ])
data$date_of_purchase = as.Date(data$date_of_purchase, "%Y/%m/%d")
data$year_of_purchase = as.numeric(format(data$date_of_purchase, "%Y"))
data$days_since = as.numeric(difftime(time1 = "2019/03/25",
time2 = data$date_of_purchase,
units = "days"))
After running: data$date_of_purchase = as.Date(data$date_of_purchase, "%y/%m/%d"); the first row as an example had an initial date of: 16/12/2017 then the value became 0016-12-20.
I want the date to be displayed as 2017/12/16 and not the obtained value of 0016-12-20.
Thank you for your assistance!