Transform a time series object to Prophet data frame input format

ts_to_prophet(ts.obj, start = NULL)

Arguments

ts.obj

A univariate time series object of a class "ts", "zoo", "xts", with a daily, weekly, monthly , quarterly or yearly frequency

start

A date object (optional), if the starting date of the series is known. Otherwise, the date would be derive from the series index

Value

A data frame object

Examples

data(USgas) ts_to_prophet(ts.obj = USgas)
#> ds y #> 1 2000-01-01 2510.5 #> 2 2000-02-01 2330.7 #> 3 2000-03-01 2050.6 #> 4 2000-04-01 1783.3 #> 5 2000-05-01 1632.9 #> 6 2000-06-01 1513.1 #> 7 2000-07-01 1525.6 #> 8 2000-08-01 1653.1 #> 9 2000-09-01 1475.0 #> 10 2000-10-01 1567.8 #> 11 2000-11-01 1908.5 #> 12 2000-12-01 2587.5 #> 13 2001-01-01 2677.0 #> 14 2001-02-01 2309.5 #> 15 2001-03-01 2246.6 #> 16 2001-04-01 1807.2 #> 17 2001-05-01 1522.4 #> 18 2001-06-01 1444.4 #> 19 2001-07-01 1598.1 #> 20 2001-08-01 1669.2 #> 21 2001-09-01 1494.1 #> 22 2001-10-01 1649.1 #> 23 2001-11-01 1701.0 #> 24 2001-12-01 2120.2 #> 25 2002-01-01 2487.6 #> 26 2002-02-01 2242.4 #> 27 2002-03-01 2258.4 #> 28 2002-04-01 1881.0 #> 29 2002-05-01 1611.5 #> 30 2002-06-01 1591.4 #> 31 2002-07-01 1748.4 #> 32 2002-08-01 1725.7 #> 33 2002-09-01 1542.2 #> 34 2002-10-01 1645.9 #> 35 2002-11-01 1913.6 #> 36 2002-12-01 2378.9 #> 37 2003-01-01 2700.5 #> 38 2003-02-01 2500.3 #> 39 2003-03-01 2197.9 #> 40 2003-04-01 1743.5 #> 41 2003-05-01 1514.7 #> 42 2003-06-01 1368.4 #> 43 2003-07-01 1600.5 #> 44 2003-08-01 1651.6 #> 45 2003-09-01 1428.6 #> 46 2003-10-01 1553.2 #> 47 2003-11-01 1753.6 #> 48 2003-12-01 2263.7 #> 49 2004-01-01 2675.8 #> 50 2004-02-01 2511.1 #> 51 2004-03-01 2100.9 #> 52 2004-04-01 1745.2 #> 53 2004-05-01 1573.0 #> 54 2004-06-01 1483.7 #> 55 2004-07-01 1584.9 #> 56 2004-08-01 1578.0 #> 57 2004-09-01 1482.2 #> 58 2004-10-01 1557.2 #> 59 2004-11-01 1782.8 #> 60 2004-12-01 2327.7 #> 61 2005-01-01 2561.9 #> 62 2005-02-01 2243.0 #> 63 2005-03-01 2205.8 #> 64 2005-04-01 1724.9 #> 65 2005-05-01 1522.6 #> 66 2005-06-01 1534.1 #> 67 2005-07-01 1686.6 #> 68 2005-08-01 1695.1 #> 69 2005-09-01 1422.5 #> 70 2005-10-01 1428.2 #> 71 2005-11-01 1663.4 #> 72 2005-12-01 2326.4 #> 73 2006-01-01 2165.3 #> 74 2006-02-01 2144.4 #> 75 2006-03-01 2126.4 #> 76 2006-04-01 1681.0 #> 77 2006-05-01 1526.3 #> 78 2006-06-01 1550.9 #> 79 2006-07-01 1758.7 #> 80 2006-08-01 1751.7 #> 81 2006-09-01 1462.1 #> 82 2006-10-01 1644.2 #> 83 2006-11-01 1765.4 #> 84 2006-12-01 2122.8 #> 85 2007-01-01 2475.6 #> 86 2007-02-01 2567.0 #> 87 2007-03-01 2128.8 #> 88 2007-04-01 1810.1 #> 89 2007-05-01 1559.1 #> 90 2007-06-01 1555.2 #> 91 2007-07-01 1659.9 #> 92 2007-08-01 1896.1 #> 93 2007-09-01 1590.5 #> 94 2007-10-01 1627.8 #> 95 2007-11-01 1834.5 #> 96 2007-12-01 2399.2 #> 97 2008-01-01 2734.0 #> 98 2008-02-01 2503.4 #> 99 2008-03-01 2278.2 #> 100 2008-04-01 1823.9 #> 101 2008-05-01 1576.4 #> 102 2008-06-01 1604.2 #> 103 2008-07-01 1708.6 #> 104 2008-08-01 1682.9 #> 105 2008-09-01 1460.9 #> 106 2008-10-01 1635.8 #> 107 2008-11-01 1868.9 #> 108 2008-12-01 2399.7 #> 109 2009-01-01 2729.7 #> 110 2009-02-01 2332.5 #> 111 2009-03-01 2170.7 #> 112 2009-04-01 1741.3 #> 113 2009-05-01 1504.0 #> 114 2009-06-01 1527.8 #> 115 2009-07-01 1658.0 #> 116 2009-08-01 1736.5 #> 117 2009-09-01 1575.0 #> 118 2009-10-01 1666.5 #> 119 2009-11-01 1776.2 #> 120 2009-12-01 2491.9 #> 121 2010-01-01 2809.8 #> 122 2010-02-01 2481.0 #> 123 2010-03-01 2142.9 #> 124 2010-04-01 1691.8 #> 125 2010-05-01 1617.3 #> 126 2010-06-01 1649.5 #> 127 2010-07-01 1825.8 #> 128 2010-08-01 1878.9 #> 129 2010-09-01 1637.5 #> 130 2010-10-01 1664.9 #> 131 2010-11-01 1973.3 #> 132 2010-12-01 2714.1 #> 133 2011-01-01 2888.6 #> 134 2011-02-01 2452.4 #> 135 2011-03-01 2230.5 #> 136 2011-04-01 1825.0 #> 137 2011-05-01 1667.4 #> 138 2011-06-01 1657.3 #> 139 2011-07-01 1890.5 #> 140 2011-08-01 1891.8 #> 141 2011-09-01 1655.6 #> 142 2011-10-01 1744.5 #> 143 2011-11-01 2031.9 #> 144 2011-12-01 2541.9 #> 145 2012-01-01 2756.2 #> 146 2012-02-01 2500.7 #> 147 2012-03-01 2127.8 #> 148 2012-04-01 1953.1 #> 149 2012-05-01 1873.8 #> 150 2012-06-01 1868.4 #> 151 2012-07-01 2069.8 #> 152 2012-08-01 2008.8 #> 153 2012-09-01 1807.2 #> 154 2012-10-01 1901.1 #> 155 2012-11-01 2167.8 #> 156 2012-12-01 2503.9 #> 157 2013-01-01 2878.8 #> 158 2013-02-01 2567.2 #> 159 2013-03-01 2521.1 #> 160 2013-04-01 1967.5 #> 161 2013-05-01 1752.5 #> 162 2013-06-01 1742.9 #> 163 2013-07-01 1926.3 #> 164 2013-08-01 1927.4 #> 165 2013-09-01 1767.0 #> 166 2013-10-01 1866.8 #> 167 2013-11-01 2316.9 #> 168 2013-12-01 2920.8 #> 169 2014-01-01 3204.1 #> 170 2014-02-01 2741.2 #> 171 2014-03-01 2557.9 #> 172 2014-04-01 1961.7 #> 173 2014-05-01 1810.2 #> 174 2014-06-01 1745.4 #> 175 2014-07-01 1881.0 #> 176 2014-08-01 1933.1 #> 177 2014-09-01 1809.3 #> 178 2014-10-01 1912.8 #> 179 2014-11-01 2357.5 #> 180 2014-12-01 2679.2 #> 181 2015-01-01 3115.0 #> 182 2015-02-01 2925.2 #> 183 2015-03-01 2591.3 #> 184 2015-04-01 2007.9 #> 185 2015-05-01 1858.1 #> 186 2015-06-01 1899.9 #> 187 2015-07-01 2067.7 #> 188 2015-08-01 2052.7 #> 189 2015-09-01 1901.3 #> 190 2015-10-01 1987.3 #> 191 2015-11-01 2249.1 #> 192 2015-12-01 2588.2 #> 193 2016-01-01 3091.7 #> 194 2016-02-01 2652.3 #> 195 2016-03-01 2356.3 #> 196 2016-04-01 2083.8 #> 197 2016-05-01 1965.8 #> 198 2016-06-01 2000.7 #> 199 2016-07-01 2186.6 #> 200 2016-08-01 2208.4 #> 201 2016-09-01 1947.8 #> 202 2016-10-01 1925.2 #> 203 2016-11-01 2159.4 #> 204 2016-12-01 2866.3 #> 205 2017-01-01 2914.2 #> 206 2017-02-01 2340.6 #> 207 2017-03-01 2523.7 #> 208 2017-04-01 1932.5 #> 209 2017-05-01 1892.5 #> 210 2017-06-01 1910.9 #> 211 2017-07-01 2142.1 #> 212 2017-08-01 2094.3 #> 213 2017-09-01 1920.9 #> 214 2017-10-01 2032.0 #> 215 2017-11-01 2357.7 #> 216 2017-12-01 3084.5 #> 217 2018-01-01 3335.0 #> 218 2018-02-01 2705.9 #> 219 2018-03-01 2792.6 #> 220 2018-04-01 2346.3 #> 221 2018-05-01 2050.9 #> 222 2018-06-01 2058.7 #> 223 2018-07-01 2344.6 #> 224 2018-08-01 2307.7 #> 225 2018-09-01 2151.5 #> 226 2018-10-01 2279.1 #> 227 2018-11-01 2709.9 #> 228 2018-12-01 2993.1 #> 229 2019-01-01 3399.9 #> 230 2019-02-01 2999.2 #> 231 2019-03-01 2899.9 #> 232 2019-04-01 2201.1 #> 233 2019-05-01 2121.0 #> 234 2019-06-01 2115.2 #> 235 2019-07-01 2407.5 #> 236 2019-08-01 2437.2 #> 237 2019-09-01 2215.6 #> 238 2019-10-01 2472.3
# If known setting the start date of the input object ts_to_prophet(ts.obj = USgas, start = as.Date("2000-01-01"))
#> ds y #> 1 2000-01-01 2510.5 #> 2 2000-02-01 2330.7 #> 3 2000-03-01 2050.6 #> 4 2000-04-01 1783.3 #> 5 2000-05-01 1632.9 #> 6 2000-06-01 1513.1 #> 7 2000-07-01 1525.6 #> 8 2000-08-01 1653.1 #> 9 2000-09-01 1475.0 #> 10 2000-10-01 1567.8 #> 11 2000-11-01 1908.5 #> 12 2000-12-01 2587.5 #> 13 2001-01-01 2677.0 #> 14 2001-02-01 2309.5 #> 15 2001-03-01 2246.6 #> 16 2001-04-01 1807.2 #> 17 2001-05-01 1522.4 #> 18 2001-06-01 1444.4 #> 19 2001-07-01 1598.1 #> 20 2001-08-01 1669.2 #> 21 2001-09-01 1494.1 #> 22 2001-10-01 1649.1 #> 23 2001-11-01 1701.0 #> 24 2001-12-01 2120.2 #> 25 2002-01-01 2487.6 #> 26 2002-02-01 2242.4 #> 27 2002-03-01 2258.4 #> 28 2002-04-01 1881.0 #> 29 2002-05-01 1611.5 #> 30 2002-06-01 1591.4 #> 31 2002-07-01 1748.4 #> 32 2002-08-01 1725.7 #> 33 2002-09-01 1542.2 #> 34 2002-10-01 1645.9 #> 35 2002-11-01 1913.6 #> 36 2002-12-01 2378.9 #> 37 2003-01-01 2700.5 #> 38 2003-02-01 2500.3 #> 39 2003-03-01 2197.9 #> 40 2003-04-01 1743.5 #> 41 2003-05-01 1514.7 #> 42 2003-06-01 1368.4 #> 43 2003-07-01 1600.5 #> 44 2003-08-01 1651.6 #> 45 2003-09-01 1428.6 #> 46 2003-10-01 1553.2 #> 47 2003-11-01 1753.6 #> 48 2003-12-01 2263.7 #> 49 2004-01-01 2675.8 #> 50 2004-02-01 2511.1 #> 51 2004-03-01 2100.9 #> 52 2004-04-01 1745.2 #> 53 2004-05-01 1573.0 #> 54 2004-06-01 1483.7 #> 55 2004-07-01 1584.9 #> 56 2004-08-01 1578.0 #> 57 2004-09-01 1482.2 #> 58 2004-10-01 1557.2 #> 59 2004-11-01 1782.8 #> 60 2004-12-01 2327.7 #> 61 2005-01-01 2561.9 #> 62 2005-02-01 2243.0 #> 63 2005-03-01 2205.8 #> 64 2005-04-01 1724.9 #> 65 2005-05-01 1522.6 #> 66 2005-06-01 1534.1 #> 67 2005-07-01 1686.6 #> 68 2005-08-01 1695.1 #> 69 2005-09-01 1422.5 #> 70 2005-10-01 1428.2 #> 71 2005-11-01 1663.4 #> 72 2005-12-01 2326.4 #> 73 2006-01-01 2165.3 #> 74 2006-02-01 2144.4 #> 75 2006-03-01 2126.4 #> 76 2006-04-01 1681.0 #> 77 2006-05-01 1526.3 #> 78 2006-06-01 1550.9 #> 79 2006-07-01 1758.7 #> 80 2006-08-01 1751.7 #> 81 2006-09-01 1462.1 #> 82 2006-10-01 1644.2 #> 83 2006-11-01 1765.4 #> 84 2006-12-01 2122.8 #> 85 2007-01-01 2475.6 #> 86 2007-02-01 2567.0 #> 87 2007-03-01 2128.8 #> 88 2007-04-01 1810.1 #> 89 2007-05-01 1559.1 #> 90 2007-06-01 1555.2 #> 91 2007-07-01 1659.9 #> 92 2007-08-01 1896.1 #> 93 2007-09-01 1590.5 #> 94 2007-10-01 1627.8 #> 95 2007-11-01 1834.5 #> 96 2007-12-01 2399.2 #> 97 2008-01-01 2734.0 #> 98 2008-02-01 2503.4 #> 99 2008-03-01 2278.2 #> 100 2008-04-01 1823.9 #> 101 2008-05-01 1576.4 #> 102 2008-06-01 1604.2 #> 103 2008-07-01 1708.6 #> 104 2008-08-01 1682.9 #> 105 2008-09-01 1460.9 #> 106 2008-10-01 1635.8 #> 107 2008-11-01 1868.9 #> 108 2008-12-01 2399.7 #> 109 2009-01-01 2729.7 #> 110 2009-02-01 2332.5 #> 111 2009-03-01 2170.7 #> 112 2009-04-01 1741.3 #> 113 2009-05-01 1504.0 #> 114 2009-06-01 1527.8 #> 115 2009-07-01 1658.0 #> 116 2009-08-01 1736.5 #> 117 2009-09-01 1575.0 #> 118 2009-10-01 1666.5 #> 119 2009-11-01 1776.2 #> 120 2009-12-01 2491.9 #> 121 2010-01-01 2809.8 #> 122 2010-02-01 2481.0 #> 123 2010-03-01 2142.9 #> 124 2010-04-01 1691.8 #> 125 2010-05-01 1617.3 #> 126 2010-06-01 1649.5 #> 127 2010-07-01 1825.8 #> 128 2010-08-01 1878.9 #> 129 2010-09-01 1637.5 #> 130 2010-10-01 1664.9 #> 131 2010-11-01 1973.3 #> 132 2010-12-01 2714.1 #> 133 2011-01-01 2888.6 #> 134 2011-02-01 2452.4 #> 135 2011-03-01 2230.5 #> 136 2011-04-01 1825.0 #> 137 2011-05-01 1667.4 #> 138 2011-06-01 1657.3 #> 139 2011-07-01 1890.5 #> 140 2011-08-01 1891.8 #> 141 2011-09-01 1655.6 #> 142 2011-10-01 1744.5 #> 143 2011-11-01 2031.9 #> 144 2011-12-01 2541.9 #> 145 2012-01-01 2756.2 #> 146 2012-02-01 2500.7 #> 147 2012-03-01 2127.8 #> 148 2012-04-01 1953.1 #> 149 2012-05-01 1873.8 #> 150 2012-06-01 1868.4 #> 151 2012-07-01 2069.8 #> 152 2012-08-01 2008.8 #> 153 2012-09-01 1807.2 #> 154 2012-10-01 1901.1 #> 155 2012-11-01 2167.8 #> 156 2012-12-01 2503.9 #> 157 2013-01-01 2878.8 #> 158 2013-02-01 2567.2 #> 159 2013-03-01 2521.1 #> 160 2013-04-01 1967.5 #> 161 2013-05-01 1752.5 #> 162 2013-06-01 1742.9 #> 163 2013-07-01 1926.3 #> 164 2013-08-01 1927.4 #> 165 2013-09-01 1767.0 #> 166 2013-10-01 1866.8 #> 167 2013-11-01 2316.9 #> 168 2013-12-01 2920.8 #> 169 2014-01-01 3204.1 #> 170 2014-02-01 2741.2 #> 171 2014-03-01 2557.9 #> 172 2014-04-01 1961.7 #> 173 2014-05-01 1810.2 #> 174 2014-06-01 1745.4 #> 175 2014-07-01 1881.0 #> 176 2014-08-01 1933.1 #> 177 2014-09-01 1809.3 #> 178 2014-10-01 1912.8 #> 179 2014-11-01 2357.5 #> 180 2014-12-01 2679.2 #> 181 2015-01-01 3115.0 #> 182 2015-02-01 2925.2 #> 183 2015-03-01 2591.3 #> 184 2015-04-01 2007.9 #> 185 2015-05-01 1858.1 #> 186 2015-06-01 1899.9 #> 187 2015-07-01 2067.7 #> 188 2015-08-01 2052.7 #> 189 2015-09-01 1901.3 #> 190 2015-10-01 1987.3 #> 191 2015-11-01 2249.1 #> 192 2015-12-01 2588.2 #> 193 2016-01-01 3091.7 #> 194 2016-02-01 2652.3 #> 195 2016-03-01 2356.3 #> 196 2016-04-01 2083.8 #> 197 2016-05-01 1965.8 #> 198 2016-06-01 2000.7 #> 199 2016-07-01 2186.6 #> 200 2016-08-01 2208.4 #> 201 2016-09-01 1947.8 #> 202 2016-10-01 1925.2 #> 203 2016-11-01 2159.4 #> 204 2016-12-01 2866.3 #> 205 2017-01-01 2914.2 #> 206 2017-02-01 2340.6 #> 207 2017-03-01 2523.7 #> 208 2017-04-01 1932.5 #> 209 2017-05-01 1892.5 #> 210 2017-06-01 1910.9 #> 211 2017-07-01 2142.1 #> 212 2017-08-01 2094.3 #> 213 2017-09-01 1920.9 #> 214 2017-10-01 2032.0 #> 215 2017-11-01 2357.7 #> 216 2017-12-01 3084.5 #> 217 2018-01-01 3335.0 #> 218 2018-02-01 2705.9 #> 219 2018-03-01 2792.6 #> 220 2018-04-01 2346.3 #> 221 2018-05-01 2050.9 #> 222 2018-06-01 2058.7 #> 223 2018-07-01 2344.6 #> 224 2018-08-01 2307.7 #> 225 2018-09-01 2151.5 #> 226 2018-10-01 2279.1 #> 227 2018-11-01 2709.9 #> 228 2018-12-01 2993.1 #> 229 2019-01-01 3399.9 #> 230 2019-02-01 2999.2 #> 231 2019-03-01 2899.9 #> 232 2019-04-01 2201.1 #> 233 2019-05-01 2121.0 #> 234 2019-06-01 2115.2 #> 235 2019-07-01 2407.5 #> 236 2019-08-01 2437.2 #> 237 2019-09-01 2215.6 #> 238 2019-10-01 2472.3