TLDR; is there a Julia version of R’s which() function?
I’m rewriting some code from R to Julia. I’ve gotten comfortable with the DataFrames subset function but in addition to returning rows I occassionally need to access relative to a specific row that meets a given condition. My data records a series of simulated aircraft flights. They always start at a given position but vary in end point and duration. To find the beginning of each run I subset the data as follows:
I’d like to be able to get the last row of each run as well. In R I would use the which() function which returns a vector of indices in the original dataframe that match the given condition. Then I know that the end positions abutt the start positions and I can shift the correct elements of the start position vector to get the end position vector.
To get the index of the last row of I flight I know that it is the index one prior to the start of the next flight so for example if startIndex = [1,10,17,25] then the end index for flight 1 would be 9 (the index prior to the start of flight 2) and so forth so in this case endIndex = [9,16,24,nrow(df)].