How to do it...

Perform the following steps with R:

> sales = sample(400:10000, 72, replace= TRUE) > sales Output: [1] 3304 7697 6715 3906 8963 9240 1423 5330 8298 7747 1686 2917 2004 4591 2213 1977 [17] 1101 7624 2814 4002 8284 6016 5875 6936 1336 6090 4190 7437 1968 3070 4013 5186 [33] 6560 7981 5496 8818 1991 3531 4624 895 5720 8481 826 435 6940 1723 9797 8261 [49] 8811 4933 6746 3978 913 5003 2372 3530 4724 7202 2765 4096 9258 8650 2719 7634 [65] 5129 5096 5449 7352 2729 5035 6370 9327 > my_newseries = ts(sales, start=c(2011,1), end=c(2016,12), frequency = 12) > my_newseries Output: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec 2011 3304 7697 6715 3906 8963 9240 1423 5330 8298 7747 1686 2917 2012 2004 4591 2213 1977 1101 7624 2814 4002 ...

Get Machine Learning with R Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.