Wednesday, March 30, 2016

Recoding Data in R

# recode missing values
A <- c(3, 2, NA, 5, 3, 7, NA, NA, 5, 2, 6)
A[ is.na(A) ] <- 0



#Let’s re-code all values less than 5 to the value 99.
A[ A < 5 ] <- 99
is.na(x1) <- which(x1 == 7)

No comments:

Post a Comment