Calculate the bearing between more than two data points
<p>I have some tracking data and I want to calculate the <a href="https://en.wikipedia.org/wiki/Bearing_(navigation)" rel="nofollow">bearing</a> over the course of the track. For two points we can use function from the <code>fossil</code> package:</p>

<pre><code># earth.bear(long1, lat1, long2, lat2)
earth.bear(-10.54427, 52.11112, -10.55493, 52.10944)
# 255.6118
</code></pre>

<p>However, this won't work for more than two points. Here's some sample data:</p>

<pre><code>tracks &lt;- read.table(text = 
"latitude,  longitude
52.111122,  -10.544271
52.10944,   -10.554933
52.108898,  -10.558025
52.108871,  -10.560946
52.113991,  -10.582005
52.157223,  -10.626506
52.194977,  -10.652878
52.240215,  -10.678817
52.26421,   -10.720366
52.264015,  -10.720642", header = TRUE, sep = ",")
</code></pre>