# NOT RUN {
# Example forgetting to use weighted statistics --------------------------------
data(psyo)
tracks <- t_speed(psyo)
tracks <- t_time_difference(tracks, units = "secs")
# Without weighted statistics
mean(tracks[,c("speed")], na.rm = TRUE)
sd(tracks[,c("speed")], na.rm = TRUE)
# With weighted statistics
des_mean(tracks, "speed", "time_difference", t_id = "")
Hmisc::wtd.mean(
tracks[,c("speed")], as.numeric(tracks[,c("time_difference")])
)
sqrt(Hmisc::wtd.var(
tracks[,c("speed")], as.numeric(tracks[,c("time_difference")])
))
# }
Run the code above in your browser using DataLab