i obtained data in RDBMS with SQL and want to forecast the daily purchase using R.
Here is the first 12 rows of the data .
What i want to make is store the dataframe like in the image below, and in the end i will try to write function to Forecast it by each item title which is in the rows using exponential smoothing.
So far, i have succesfully done the title column. But i cannot make multiple date column exactly like the 2nd image above. Here is the code so far :
df1 <- data.frame()
dailydate <- as.Date(as.POSIXct(data$date_placed))
newdate <- unique(dailydate)
itemtitle <- as.character(data$title)
newitemtitle <- unique(itemtitle)
df1 <- data.frame(newitemtitle,t(dailydate))
Error in data.frame(newitemtitle, t(dailydate))
I cannot add new column into df1
,and also not yet find the way to match the daily quantity based on the title. I am open to any suggestion with this problem