Calculate normal and weighted means while excluding gaps in data
des_mean(
tracks, ctarget, cweight = "", cgaps = "", cname = "mean", drop = TRUE,
t_id = "id", des_df = ""
)
psyo
. Data frame with tracks.
character
. Column name of tracks
that contains the variable for the calculation.
character
. Column name of tracks
that contains the weight for the calculation.
character
. Column name of tracks
that marks gaps with TRUE
.
character
. Column name of the returned calculation result.
logical
. If TRUE
and only one observation is returned drop the data frame
and collapse the return value to a vector
.
character or numeric. Column name in tracks
that identifies the separate tracks.
data frame
. Function results will be merge with this data frame.
Data frame
id of the track
calculated mean of the track
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.
des_summary
, des_duplicates
, des_first
, des_last
, des_length
, des_max
, des_min
, des_sd
, des_sum
# NOT RUN {
# Get example data
data(psyo_rounds2)
psyo_rounds2 <- psyo_rounds2[ c(1:5,11:15) ,]
# clean-up data
psyo_rounds2 <- average_duplicates(psyo_rounds2)
# Add gap segments
psyo_rounds2 <- t_time_difference(psyo_rounds2)
psyo_rounds2 <- mark_time_gaps(psyo_rounds2)
# Add speed
psyo_rounds2 <- t_speed(psyo_rounds2)
# Calculate different means
normal <- des_mean(psyo_rounds2, "speed", cname = "normal")
weighted <- des_mean(
psyo_rounds2, "speed", cweight = "time_difference", cname = "weighted"
)
segmented <- des_mean(
psyo_rounds2, "speed", cgaps= "time_gap", cname = "segmented"
)
segmented_weighted <- des_mean(
psyo_rounds2,
"speed",
cweight = "time_difference",
cgaps = "time_gap",
cname = "segmented_weighted"
)
# }
Run the code above in your browser using DataLab