distance_peers {psyosphere} | R Documentation |
Add distance in meters to peers within the same selection
distance_peers( tracks, cpeer = "", single = FALSE, average = TRUE, cname = "average_dis", bind = TRUE, drop = TRUE, t_id = "id" )
tracks |
|
cpeer |
character. Column that identifies peers. |
single |
logical. Append distances to each participant independently. |
average |
logical. Append average distances to peers. |
cname |
|
bind |
logical. Return the distance as list ( |
drop |
|
t_id |
character or numeric. Column name in |
The function also determines the distance if the time stamps of the coordinates don't match. Please look at the example section for the details.
If you use Psyosphere for commercial use or research, please support us by include one off the following references:
Creative Commons: "Psyosphere" by B. Ziepert, E. G. Ufkes & P. W. de Vries from analyse-gps.com / CC-BY-SA-4.0
APA: de Vries, P. W., et al. (2016). "De psychologie van bewegingen GPS-technologie voor de analyse van natuurlijk gedrag." Tijdschrift voor Human Factors 2: 11-15.
Be aware: this function can take a lot time. You can use average_coordinates
first to test your script with a small sample.
Benjamin Ziepert. Please send feedback to: feedback-psyosphere@analyse-gps.com.
distance_line
, distance_point
, distance_psyo
# Simple example --------------------------------------------------------------- data(psyo_rounds2) data(psyo_line_map) psyo_rounds2 <- psyosphere::distance_peers(psyo_rounds2) # Test single intersect position with same timestamp --------------------------- # # p1 --------x-------> p2 # ^ # | # | # p3 # # We have two tracks. From track 1 we have p1 and p2 at a certain time. From # tracks 2 we have point 3. Point 3 has a time between p1 and p2. We want to # know what the distance from point 3 is to track 1 at the time of point 3. For # this we need determine point x. # # Create the points p1 <- data.frame(time = "2016-01-01 01:00:00", lon = 0, lat = 0, id = "1") p2 <- data.frame(time = "2016-01-01 03:00:00", lon = 2, lat = 0, id = "1") p3 <- data.frame(time = "2016-01-01 02:00:00", lon = 1, lat = 1, id = "2") p1$time <- as.POSIXct(p1$time) p2$time <- as.POSIXct(p2$time) p3$time <- as.POSIXct(p3$time) # Combine into a line for illustration on a map line <- rbind(p1, p2, p3) line_plot <- plot_tracks(line, plot = psyo_line_map) # line_plot <- plot_tracks(line) line_plot # As one could gess x should heve the coordinates lon 0 and lat 1. With the # following map you see that this is the case. x <- psyosphere:::timed_destination_point_private(p1, p2, p3, "id") x$ele <- NULL x[,"dot_color"] <- "red" plot_tracks(x, plot = line_plot)