Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- df = read.csv('data.csv', stringsAsFactors = FALSE,
- colClasses = colClass,na.strings = c("NA", ""))
- df = na.omit(df)
- df <- df[!apply(df, 1, function(x){all(x=="")}),]
- df <- df[complete.cases(df),]
- df[is.na(df)] <- ""
- # example data
- dat <- tribble(~col1, ~col2,
- 1, "",
- 2, "some string",
- 3, "another string")
- dat
- # A tibble: 3 x 2
- col1 col2
- <dbl> <chr>
- 1 1.00 ""
- 2 2.00 some string
- 3 3.00 another string
- dat %>%
- na_if("") %>%
- na.omit()
- # A tibble: 2 x 2
- col1 col2
- <dbl> <chr>
- 1 2.00 some string
- 2 3.00 another string
Add Comment
Please, Sign In to add comment