which_non_na {tidytidbits} | R 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))
[Package tidytidbits version 0.3.2 Index]