Hi! For some reason, this is throwing errors and saying I'm missing parentheses or comma depending on what I do. Any suggestions or adjustments would be much appreciate.
Existing code:
dx <- tibble::tribble(
~PSQI3_hr_PSQI3_5, ~PSQI3_AMPM_PSQI3_5, ~PSQI4_hr_PSQI4_5, ~PSQI4_AMPM_PSQI4_5,
"9", "1", "11", "1",
"8", "1", "8", "1",
"10", "1", "12", "2",
"5", "1", "5", "1",
"9", "1", "9", "1",
"6", "1", "5", "2"
)
dx <- mutate(SFSWeekday = ifelse(((dx$PSQI3_hr_PSQI3_5 == dplyr::between(left = 6, right = 9)) & dx$PSQI3_AMPM_PSQI3_5 == "AM"), 3,
ifelse((dx$PSQI3_hr_PSQI3_5 == dplyr::between(left = 9, right = 11)) & dx$PSQI3_AMPM_PSQI3_5 == "AM"), 2,
ifelse((dx$PSQI3_hr_PSQI3_5 == dplyr::between(left = 12, right = 1)) & dx$PSQI3_AMPM_PSQI3_5 == "PM"), 1, 0)
SFSWeekend = ifelse(((dx$PSQI4_hr_PSQI4_5 == dplyr::between(left = 6, right = 9)) & dx$PSQI4_AMPM_PSQI4_5 == "AM"), 3,
ifelse((dx$PSQI4_hr_PSQI4_5 == dplyr::between(left = 9, right = 11)) & dx$PSQI4_AMPM_PSQI4_4 == "AM"), 2,
ifelse((dx$PSQI4_hr_PSQI4_5 == dplyr::between(left = 12, right = 1)) & dx$PSQI4_AMPM_PSQI4_5 == "PM") 1, 0))
Thank you!