df_A <- tribble(
~id, ~type, ~min_price, ~max_price,
"1", "X", 10, 40,
"1", "Y", 20, 50,
"1", NA, 15, 70,
"2", "X", 40, 90,
"2", "Y", 23, 100,
)
现在,我想获取显示每个id和类型的“ min_price”的最小值和最大值的行。所以我编码:
data_x <- df_A %>%
group_by(id, type) %>%
summarise(min_price_1 = min(min_price),
min_price_2 = max(min_price))
但是在这种情况下,我输了其他专栏。当我用mutate代替它时,它会更复杂。
如何获得它?