R - How to vectorize with apply family function and avoid while/for loops in this case?
问题 In this case (more details could be found in this question: Count how many observations in the rest of the dat fits multiple conditions? (R)) This is a dataset called event, containing thousands of events (observations) and I selected several rows to show you the data structure. It contains the "STATEid", "date" of occurrence, and geographical coordinates in two variables "LON" "LAT". I am writing to calculate a new variable (column) for each row. This new variable should be: "Given any