ifelse statement or something else?

Hi Community

have 2 df


if you want to modify a data.frame based on information present in some other data.frame, you would be well advised to join your data.frames, so that they are explicitly bound together in the required way, this usually makes the required modifications trivial.
Have a look at this textbook:
13 Relational data | R for Data Science (had.co.nz)

Hi Nirgrahamuk
i dont want to join them, I just want to know the cases where leadd[priceRegion] = COEE[priceRegion] AND leadd[vesselSubSegment] = COEE[vesselSubsegment] and then mutate 2 new columns marking the rows where this is the case. (the mutation from the r code block)

I hear you saying that you don't want to join them, ...at least you didnt have that original intent.... but it is (in my personal opinion) the best way to arrive at your required output.

ps. your example lacks common priceRegions;
the leadd has only Meditteranean and that doesnt appear in the COEE you provided.

1 Like

I know it lacks common priceRegion (it is only a sample) in that case "rule = 0" and "lead = ML) from the mutate in the original post :slight_smile:

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.