ifelse returns a value with the same shape as test which is filled with elements selected from either yes or no depending on whether the element of test is TRUE or FALSE. Usage: ifelse(test, yes, no) 示例: base_data$sbp<-ifelse(is.na(base_data$sbp_a1),base_data$sbp_m1,base_data$sbp_a1)