How to find slope of time series variable
<p>I have a time series data similar to this</p>
<pre><code>            val
2015-10-15  7.85
2015-10-16  8
2015-10-19  8.18
2015-10-20  5.39
2015-10-21  2.38
2015-10-22  1.98
2015-10-23  9.25
2015-10-26  14.29
2015-10-27  15.52
2015-10-28  15.93
2015-10-29  15.79
2015-10-30  13.83
</code></pre>
<p>How can i find the slope of the adjecent rows (eg 8 and 7.85) of <strong>val</strong> variable and print it in a different column in R or python</p>
<p>I know the formula for a slope that is</p>
<p><a href="https://i.stack.imgur.com/BCmZj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BCmZj.png" alt="enter image description here" /></a></p>
<p>but the problem is how we will take difference of <strong>x</strong> (that is date) values in a time series data
(Here x is date and y is val)</p>