I got an error message like "Error: expecting a single value" in dplyr. What for?

I want to give some condition for counting, and here is my code. It seems to me that there is no problem in my code.
Why does this give me an error like "Error: expecting a single value"?

cust_online_trip = data %>% group_by(CUST_NO_ID) %>% 
   summarise(t_trip_before = ifelse(exp_mob ==1,length(S_TRHEAD_SK[before_1st_mob_shop ==1]),length(S_TRHEAD_SK[before_app_launch ==1])),
             online_trip_before = ifelse(exp_mob ==1,length(S_TRHEAD_SK[before_1st_mob_shop ==1 & channel == "online"]),
                                      length(S_TRHEAD_SK[before_app_launch ==1 & channel == "online"])))
+4
source share

Source: https://habr.com/ru/post/1656417/


All Articles