I am working on a script involving mobility mapping in R. I am using ggplot, ggmap, and stamenmap to do this. I would like to be able to use the length of geom_path as a variable in order to separate those who travel long distances from those who travel short distances, etc. Before I get too far into this, can path or line length be used as a variable? If so, how do I access it?
Asked
Active
Viewed 139 times
0
-
1No. ggplot will not calculate the length of the path for you. You'd have to calculate this value before creating the plot. It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Jul 02 '19 at 14:49
-
Thank you @MrFlick. This was just a simple question that I could not find any information about, so I assumed ggplot did not include that anyway. I am working with coordinates, so I suppose I will have to calculate max distance for each person with good ol' Pythagoras. – Jacob Etheridge Jul 02 '19 at 14:59
-
To calculate a geospatial path, take a look the "geosphere" package. – Dave2e Jul 02 '19 at 15:47