Find position of first value greater than X in a vector

前端 未结 6 1315
粉色の甜心
粉色の甜心 2020-12-09 08:53

In R: I have a vector and want to find the position of the first value that is greater than 100.

6条回答
  •  春和景丽
    2020-12-09 09:34

    Just to mention, Hadley Wickham has implemented a function, detect_index, to do exactly this task in his purrr package for functional programming.

    I recently used detect_index myself and would recommend it to anyone else with the same problem.

    Documentation for detect_index can be found here: https://rdrr.io/cran/purrr/man/detect.html

提交回复
热议问题