Skip to content

Instantly share code, notes, and snippets.

@cddesja
Created February 25, 2020 18:54
Show Gist options
  • Save cddesja/bc2c90f293cbcde8e0c2d096eb132b0b to your computer and use it in GitHub Desktop.
Save cddesja/bc2c90f293cbcde8e0c2d096eb132b0b to your computer and use it in GitHub Desktop.
clean up the NAs
cleanNAs <- function(x){
if(sum(is.na(x)) == length(x)) {
x <- NA
} else
x <- x[!is.na(x)]
x
}
dat <- read.csv("testing.csv", header = TRUE)
dat$clean <- apply(dat, 1, cleanNAs)
dat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment