I am trying to get column names of NA columns using named pipes in R:-
df <- structure(data.frame(id = c(1, 2, NA, NA, NA, NA),
cat = c("SS","SS", "SS", "SV", "SV", "SV"),
val = c(220L, 222L, 223L, NA,NA, 2206L)),
.Names = c("id", "cat", "val"), class = "data.frame",
row.names = c(NA,-6L))
sapply(df, function(x) ((sum(is.na(x))))*.01)%>%
stack %>% rev %>% filter(values > 0) %>% setNames(nm=c("variable", "missing"))%>%
paste0(colnames ->NulCols)
But the code gives out error. Error in paste0(., NulCols <- colnames) : cannot coerce type 'closure' to vector of type 'character'
Want to create a list of NA Columns using named pipes only.