df_mean_real Function

public function df_mean_real(df, col_index) result(avg)

Calculate the arithmetic mean of a real column

Computes the average value of all elements in a real-valued column

@param[in] df The data frame instance @param[in] col_index Index of the column (1-based) @return Mean value of the column

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(in) :: df
integer, intent(in) :: col_index

Return Value real(kind=rk)


Source Code

    function df_mean_real(df, col_index) result(avg)
        type(data_frame), intent(in) :: df
        integer, intent(in) :: col_index
        real(rk) :: avg

        real(rk), dimension(:), allocatable :: col
        type(column) :: data_col

        if (col_index < 1 .or. col_index > df % ncols()) error stop "column index out of range"

        data_col = df % get_data_col(col_index)
        if (data_col % get_type() /= REAL_NUM) error stop "column is not real type"

        col = data_col % getr()
        avg = sum(col) / real(size(col), rk)
    end function df_mean_real