setwd("D:/R_edu/data")
loans=read.csv("loans.csv")
if (loans$status == "A"){loans$bad_good <-0
}else if (loans$status == "B") {loans$bad_good <-1
}else if (loans$status == "D") {loans$bad_good <-1
}else{
loans$bad_good <-NA
}
报错:
Warning messages:
1: In if (loans$status == "A") { :
the condition has length > 1 and only the first element will be used
2: In if (loans$status == "B") { :
the condition has length > 1 and only the first element will be used