While importing data from an excel file using the read_excel
function in the readxl
package, I have tried specifying a number for the na
argument but it does not recode the missing values. The data was entered with a numeric value as the missing response.
Example data (in r rather than an excel file though):
missing <- data.frame(a = c(1, 2, 3, 4),
b = c(99, 2, 3, 4),
c = c(1, 99, 3, 4))
If the above data were a separate excel file I tried reading it in like so:
data <- read_excel("C:/.../missing.xlsx", na = 99)
Instead of recoding the 99's to be NA, they just get read in as numbers. I'd like to see a data frame like this without having to use a separate step to recode the data:
a b c
1 1 NA 1
2 2 2 NA
3 3 3 3
4 4 4 4