I want to change values in one column based on the presence of values in another column, when data are groups based on unique values of grouping variable.
I am using the mtcars data. I want to group these data based on the unique values of cyl, and then I want to create a variable called OD_gears that will display yes in every cell of the column associated with a given unique cyl value when there is a value of 5 present in any cell in the gears column associated with a given unique cyl value, and display no in cases where those criteria are not met.
In this case, every cell in the OD_gears column should have a value of yes in it, because at least 1 car associated with the unique cyl values has a value of 5 present in the gears column.
Is this possible to do? If so, how? Can I use the dplyr package and group_by() to help accomplish this task?
Aucun commentaire:
Enregistrer un commentaire