Calculate the arithmetic mean of an integer column
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(data_frame), | intent(in) | :: | df | |||
integer, | intent(in) | :: | col_index |
function df_mean_integer(df, col_index) result(avg) type(data_frame), intent(in) :: df integer, intent(in) :: col_index real(rk) :: avg integer(ik), 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() /= INTEGER_NUM) error stop "column is not integer type" col = data_col % geti() avg = real(sum(col), rk) / real(size(col), rk) end function df_mean_integer