Skip to content

Instantly share code, notes, and snippets.

@stephenturner
Created February 24, 2011 03:09
Show Gist options
  • Save stephenturner/841686 to your computer and use it in GitHub Desktop.
Save stephenturner/841686 to your computer and use it in GitHub Desktop.
propmiss.r
propmiss <- function(dataframe) {
m <- sapply(dataframe, function(x) {
data.frame(
nmiss=sum(is.na(x)),
n=length(x),
propmiss=sum(is.na(x))/length(x)
)
})
d <- data.frame(t(m))
d <- sapply(d, unlist)
d <- as.data.frame(d)
d$variable <- row.names(d)
row.names(d) <- NULL
d <- cbind(d[ncol(d)],d[-ncol(d)])
return(d[order(d$propmiss), ])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment