Skip to contents

Checks how often a number (relevant_point) is being crossed by an number sequence (numeric_vector).

Usage

point_crosses(numeric_vector, relevant_point = 0)

Arguments

numeric_vector

Numbers, ordered by their time of appearance.

relevant_point

Number which has to be crossed.

Value

Number of times that numeric_vector crosses the relevant_point (0 to +Inf).

Details

The supplied vectors are assumed to be ordered by time.

References

Pfister, R., Tonn, S., Schaaf, M., Wirth, R. (2024). mousetRajectory: Mouse tracking analyses for behavioral scientists. The Quantitative Methods for Psychology, 20(3), 217-229. doi:10.20982/tqmp.20.3.p217

Examples

x_vals <- c(-1, 1, -1, 1, -1, 1)
point_crosses(x_vals, 0)
#> [1] 5
point_crosses(x_vals, 1)
#> [1] 0
point_crosses(x_vals, -1)
#> [1] 0