Hi, first post here so apologies if I offend anyone by my ignorance.
I am struggling to subset the rows of my data frame based on values in another data frame.
I wish to subset my data frame (df1) using values from my other data frame (df2).
For the rows that match on drug name, I wish to change all values in column df1$strength to 'all'.
Here is a reprex
df1 <- data.frame(Drugs = c("Drug A","Drug A","Drug B"), strength = c(50,100,300))
df2 <- data.frame(Drugs = c("Drug A","Drug X","Drug Z")
I wish to overwrite the strength values in df1 based on the presence of the drugs in df2.
The output of df2 should look as follows:
df1 <- data.frame(Drugs = c("Drug A","Drug A","Drug B"), strength = c(all,all,300))