Created
February 25, 2020 18:54
-
-
Save cddesja/bc2c90f293cbcde8e0c2d096eb132b0b to your computer and use it in GitHub Desktop.
clean up the NAs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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