data("mtcars")
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
result <- mtcars %>%
  mutate(Efficiency = ifelse(mpg > 20, "Efficient", "Inefficient")) %>%
  select(mpg, cyl, hp, wt, Efficiency) %>%
  filter(cyl == 6) %>%
  summarise(
    Avg_MPG = mean(mpg, na.rm = TRUE),
    Avg_HP = mean(hp, na.rm = TRUE),
    Avg_Weight = mean(wt, na.rm = TRUE)
  ) %>%
  arrange(Avg_HP)

print(result)
##    Avg_MPG   Avg_HP Avg_Weight
## 1 19.74286 122.2857   3.117143