Search code examples
rdata-manipulationnamissing-data

R won't recognize missing data


I have a dataset with multiple columns. In some columns all values are missing, in other columns only a few values. When importing to R, the missing values are only shown as empty cells and not as NA. This results in the problem that when I want to remove NA values with the na.omit() function nothing happens. How should I handle this problem?


Solution

  • You could replace all the empty values with NA by using the following code:

    library(dplyr)
    your_data_with_NA <- your_data %>% 
      mutate_all(na_if, "")