I was trying to turn nonsense data to NA. (ex: wage column that has -4, -3. poverty ratio column has -4,-5, character type column has numbers such as -4, -5)
I used a predefined vector to define which are nonsense data:
nulldata <- c(-5, -4, -3, -2, -1, '')
then, I created a for loop to iterate thru each column to check if there are data like those in the column. the for loop I created:
for(i in 1: ncol(df)){
df[, i][df[, i] %in% nulldata] <- NULL
}
the error I get is:
Error in df[, i][df[, i] %in% nulldata] <- NULL :
replacement has length zero
not sure does anybody else getting the same error