d <- read_excel("Rawdata.xlsx") d$sleep <- d$Total_Sleep_Time/100 quantile(d$sleep,c(1/3,2/3)) quantile(d$BMI,c(1/3,2/3)) quantile(d$Age,c(1/3,2/3)) quantile(d$Total_Sleep_Time,c(1/4,2/4,3/4)) d$sleep_CAT <- with(d,case_when(sleep>=42~0, sleep>=39~1, sleep>=36~2, sleep <36~3)) d$sleep_CAT <- factor(d$sleep_CAT3,levels = c('0','1','2','3')) d$Gender <- factor(d$Gender,levels = c('1','2')) #where 1 represents male and 2 represents female d$city <- factor(d$city_countryside,levels = c('1','2')) d$edu <- with(d,case_when(education>=8~2, education>=6~1, education <6~0)) d$edu <- factor(d$edu,levels = c('0','1','2')) d$BMInew <- with(d,case_when(BMI>=22.95~2, BMI>=19.89~1, BMI <19.89~0)) d$Agenew <- with(d,case_when(BMI>=26~2, BMI>=24~1, BMI <24~0)) d$BMInew <- factor(d$BMInew,levels = c('0','1','2')) d$Agenew <- factor(d$Agenew,levels = c('0','1','2'))