Skip to contents

A wrapper for [ with handling of NA's for use in dplyr::summarize()

Usage

extr_val(x, i, allNA_NA = TRUE, na.rm = TRUE)

Arguments

x

object from which to extract element(s)

i

index specifying element to extract.

allNA_NA

logical indicating whether NA should be returned when all(is.na(i)) == TRUE.

na.rm

a logical indicating whether missing index values should be removed.

Value

If all_NA = FALSE and na.rm = FALSE, identical to x[i].

If all_NA = FALSE and na.rm = TRUE, identical to x[i[!is.na(i)]].

If all_NA = TRUE, identical to x[i] unless all(is.na(i)) == TRUE, in which case returns NA