listIf | R Documentation |
Simple list all of specified variable for which row data meets specific conditions. Option for removing NAs. Option to have output as list or collapsed string. First column use as default if no variable specified or variable specified is not within the datset.
listIf(data, varname = NULL, cond = NULL, collapse = FALSE, na.rm = FALSE)
data |
The dataset to process |
varname |
The ID varname which will be printed for each row where condition is not true |
cond |
The condition to verify |
collapse |
If true then ... |
na.rm |
Should missing be included |
A list of records
df1 <- data.frame(Id = c(1,2,3,4,5,6,7,8,9,10, NA_real_)
, A = c("a", "b", "c", "d", "e","a", "b", "c", "d", "e", "b")
, B = c("", "dog", "cat", "rabbit", "mole", "dog", "horse", "cat", "", NA_character_, "mouse")
)
listIf(data=df1, varname="Id", cond = A=="b", na.rm=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.