r if na code example
Example 1: r na if
dat <- dat %>% mutate(x = replace(x, x<0, NA))
Example 2: if not na in r
lapply(apply(p, 1, function(x) which(!is.na(x)) ) , paste, collapse=", ")
dat <- dat %>% mutate(x = replace(x, x<0, NA))
lapply(apply(p, 1, function(x) which(!is.na(x)) ) , paste, collapse=", ")