Problem

You want simple linear regression trend-line model that describes the relationship between two variables date/date-time and orders.

Alt text

Solution

• Create custom field that converts from human-readable date to epoch

Case date field in format "m/d/yyyy h:mm:ss AM/PM":
SecondDiff(createdate(getyear(<date field>),getmonth(<date field>),getday(<date field>)),createdate(1970,1,1))  

Case date field in format "m/d/yyyy":
SecondDiff(<date field>,createdate(1970,1,1))  AS r_date

• R script

Alt text Alt text

Whenever you use epoch field send it to R as aggregated argument.

Discussion

The regression command is lm for linear model. We will store that model in a variable called fit The order of the variables is dependent followed by a tilde “~” followed by a list of independent variables

References

https://stat.ethz.ch/R-manual/R-devel/library/stats/html/lm.html