lundi 2 avril 2018

Match a value within a subset and return a value

I would like to return the ProjectID when certain criteria are met. For example, in the data below within each cluster where there is a project C and a project A the ProjectID for C will be returned in the row of project A. I have put an example below with the ProjectID being returned in the Dependent column. I have tried to solve the problem by using the group_by function within dplyr to separate each cluster into groups however I am unsure how to lookup the projects within each group to see if the criteria are met (in this case project C is within the cluster) and return the ProjectID. Would appreciate any advice on how to solve.

Cluster Project ProjectID Dependent
Aaa        A         1       3
Aaa        B         2
Aaa        C         3
Bbb        A         4
Bbb        B         5
Ccc        A         6       8
Ccc        B         7
Ccc        C         8
Ccc        D         9

Aucun commentaire:

Enregistrer un commentaire