
Last chance! 50% off unlimited learning
Sale ends in
Run function on each track in a psyo
data frame. The function is in form of a character expression.
apply_tracks(tracks, exp,
arg1 = "", arg2 = "", arg3 = "", arg4 = "",arg5 = "", arg6 = "", arg7 = "",
arg8 = "", arg9 = "", t_id = "id", info = FALSE
)
character. The function and arguments that will be evaluated.
multiple. Arguments that will be sent to the target function.
multiple. Arguments that will be sent to the target function.
multiple. Arguments that will be sent to the target function.
multiple. Arguments that will be sent to the target function.
multiple. Arguments that will be sent to the target function.
multiple. Arguments that will be sent to the target function.
multiple. Arguments that will be sent to the target function.
multiple. Arguments that will be sent to the target function.
multiple. Arguments that will be sent to the target function.
Unique by time sorted ID for every coordinate within a track. Use t_id = ""
to make no selection but take all data.
logical. Measures the time consumption for each track calculation.
If you use 'psyosphere' for commercial use or research, please support us by include one off the following references:
MIT license: "psyosphere" by B. Ziepert, E. G. Ufkes & P. W. de Vries from https://CRAN.R-project.org/package=psyosphere
APA: Ziepert, B., Ufkes, E., & de Vries, P. W. (2018). psyosphere: Analyse GPS Data. Retrieved from https://CRAN.R-project.org/package=psyosphere
APA: Vries, P., Ziepert, B., & Ufkes, E. (2016). "De psychologie van bewegingen GPS-technologie voor de analyse van natuurlijk gedrag." Tijdschrift voor Human Factors 2: 11-15.
Don't use this function for 'psyosphere' main functions. Most of the 'psyosphere' functions have apply_tracks()
already included. By adding it again you can get strange results or break the function.
Only return the changed "eval_track" as result. The function is splitting a psyo
data frame in sub tracks. After changes are applied that sub tracks or merged together again. Therefore, it is important to only work in the sub track. If for instance every time the psyo
data frame is returned by the evaluated function than the data frame gets stacked again and again on top of itself. See the examples below for how this can look like.
# NOT RUN {
# Working examples -------------------------------------------------------------
# Test function for examples
test_sum <- function(track, more = 0) {
track$lon_sum <- sum(track$lon) + more
return(track)
}
# Simple example
data(psyo)
psyo <- apply_tracks(
psyo,"test_sum(eval_track)"
)
# See all data as one track
data(psyo)
psyo <- apply_tracks(
psyo,"test_sum(eval_track)", t_id =""
)
# Use of arguments
data(psyo)
psyo <- apply_tracks(
psyo,"test_sum(eval_track, arg1)", arg1 = 5
)
# What not to do ---------------------------------------------------------------
# Only return the changed "eval_track" as result. The following examples show
# what can go wrong otherwise.
test_wrong <- function(selected_track, all_tracks) {
all_tracks$sum <- all_tracks$lon + all_tracks$lat
return(all_tracks)
}
data(psyo)
psyo <- psyo[psyo[,c("p_id")]== 0,]
psyo <- apply_tracks(
psyo,"test_wrong(eval_track, arg1)", arg1 = psyo
)
# }
Run the code above in your browser using DataLab