1. ==
необходимо заменить на %in%
, а
2. NA
заменить на NA_character_
.
Ошибка "Error: must be a character vector, not a logical vector"
обусловлена 2-й.
total_s2_data <- total_s2_data %>%
mutate(frame_cat = case_when(
frameNum %in% c(1:63, 120:193, 488:543, 580:625) ~ "anticipatory",
frameNum %in% c(64:69, 194:219, 544:563, 626:653) ~ "phone",
frameNum %in% c(70:193, 220:297, 564:625, 654:725) ~ "carryover",
TRUE ~ NA_character_)
)
head(total_s2_data)
# frameNum frame_cat
#1 1 anticipatory
#2 2 anticipatory
#3 3 anticipatory
#4 4 anticipatory
#5 5 anticipatory
#6 6 anticipatory