Manolo
July 22, 2022, 9:26pm
1
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
FJCC
July 23, 2022, 12:47am
2
Does this give you what you want?
library(dplyr)
d_01 |> filter(cut=="Good", price*0.2 > price_02)
No rows meet those conditions.
system
Closed
August 16, 2022, 1:51pm
4
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.