which_non_na: Get indices of non-NA values

Description Usage Arguments Value Examples

View source: R/na.R

Description

Get indices of non-NA values

Usage

1

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

1
2
3
4
5
6
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 8, 2021, 5:07 p.m.