How to subset o filter a data frame

I want to subset or filter a data frame to keep only the rows with cut == "Good, when the 20% of the price is greater than the value of price_02. How can I do that?

d_01 <- diamonds |> 
  filter(cut == "Good" | cut == "Premium", carat == 0.29) |>
  dplyr::select(carat, cut, price) |>
  slice(1:10) |>
  mutate(price_02 = c(800, 760, 779, 738, 789, 750, 740, 779, 748, 789))
d_01

Does this give you what you want?

library(dplyr)
d_01 |> filter(cut=="Good", price*0.2 > price_02)

No rows meet those conditions.

Thank you very much.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.