Non-NA values being replaced as NA during Excel File Import into R

  Kiến thức lập trình

I have an excel file which I have imported into R using read_excel. The excel file contains about 8000+ records with 58 columns. There are many cells with NA values. Across the different variables, they may be entered as “n/a”, “N/A”, “n/A”, “N/a”,”na”,”NA”, “n a”,”(blank)”.

When I’m importing the file, I use this code:

read_excel("path", col_names = TRUE, na = c("n/a", "N/A", "n/A", "N/a","na","NA", "n a",""))

In one column, I have records with this value NR, which stands for No Record and is not the same thing as NA.

When I run the read_excel code above, the NR becomes NA. If I take out the na = c("n/a", "N/A", "n/A", "N/a","na","NA", "n a","") section, the NR is imported as it should. How do I get R to recognize that NR is not the same thing? As a side note, I cannot change the NR notation to something else.