which_non_na: Get indices of non-NA values

View source: R/na.R

which_non_naR Documentation

Get indices of non-NA values

Description

Get indices of non-NA values

Usage

which_non_na(...)

Arguments

...

k vectors of the same length n, regarded as k columns with each n rows

Value

A list of n numerical vectors. Each numerical vector has a size between 0 and k and contains the indices of the vectors whose elements are not na in the corresponding row.

Examples

library(tibble)
library(magrittr)
library(dplyr)
# Creates a list column containing (2,3);(3);(1,2,3)
tibble(a=c(NA, NA, 2), b=c(4, NA, 5), c=c(1, 2, 3)) %>%
  mutate(non_na_idc=which_non_na(a, b, c))

tidytidbits documentation built on March 18, 2022, 6:10 p.m.