ifelse ( 조건, True일 때 리턴할 값, False일 때 리턴할 값)
library(tidyverse)
a = read_spss("C:/data/HN22_ALL1/HN22_ALL.sav")
aa = data.frame(a)
b = aa[c("sex", "age", HE_BMI", "BPI")]
summary(b)
dim(b)
b2 = b[b$BP1 <= 4,]
dim(b2)
b3 = na.omit(b2)
dim(b3)
library(tidyverse)
b3$B = case_when(
- b3$BP1==1~4,
- b3$BP1==2~3,
- b3$BP1==3~2,
- b3$BP1==4~1)
View(b3)