Calculate differences between consecutive rows (result has n-1 elements)
Returns an array where each element is the difference between consecutive values
@param[in] df The data frame instance @param[in] col_index Index of the column @return Array of differences with n-1 elements
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(data_frame), | intent(in) | :: | df | |||
integer, | intent(in) | :: | col_index |
function df_diff_integer(df, col_index) result(differences) type(data_frame), intent(in) :: df integer, intent(in) :: col_index integer(ik), dimension(:), allocatable :: differences integer(ik), dimension(:), allocatable :: col integer :: i, n col = df_get_col_integer(df, col_index) n = size(col) if (n < 2) then allocate (differences(0)) return end if allocate (differences(n - 1)) do i = 1, n - 1 differences(i) = col(i + 1) - col(i) end do end function df_diff_integer