I am still pretty new to R and I have encountered the following error when trying to get the average values:
Error: Problem with `mutate()` input `inflight_exp`. x error in evaluating the argument 'x' in selecting a method for function 'rowMeans': unused argument (starts_with("Inflight")) i Input `inflight_exp` is `rowMeans(fal1 %>% select(starts_with("Inflight")))`. Backtrace: 9. dplyr::mutate(...) 11. dplyr:::mutate_cols(.data, ...)
I have reverse engineered some code I found on the Internet and I could not see the difference between their code and mine - please could someone assist and guide me what I am doing wrong?
Steps I took are as follows: Split the data in to 3 Elements:
- Online is criteria relating to online experiences
- Airport is criteria relating to factors experienced before the flight
- Inflight is the satisfaction criteria relating to inflight experience
fal1 = rename(fal, Inflight1 = seat_comfort,
Airport1 = departure_arrival_time_convenient,
Inflight2 = food_drink,
Airport2 = gate_location,
Inflight3 = inflightwifi_service,
Inflight4 = inflight_entertainment,
Online1 = online_support,
Online2 = ease_of_onlinebooking,
Inflight5 = onboard_service,
Inflight6 = leg_room_service,
Airport3 = baggage_handling,
Airport4 = checkin_service,
Inflight7 = cleanliness,
Online3 = online_boarding)
fal1 = fal1 %>%
mutate(inflight_exp = rowMeans(fal1 %>% select(starts_with("Inflight"))),
airport_exp = rowMeans(fal1 %>% select(starts_with("Airport"))),
online_exp = rowMeans(fal1 %>% select(starts_with("Online"))),
male = ifelse(gender == 1,0,1))