I want to merge these two column vectors but with the condition to apply the smallest number to the df1
. I know this is not clear at all so you can hopefully see what I mean below.
df1 df2
ID Age
1 10
1 9
1 50
2 24
3 30
3 2
I want to use these to create a new data frame that looks like this
new_df
ID (Youngest) Age
1 9
1 9
1 9
2 24
3 2
3 2
More clearly I wanna pick out the smallest number for each unique ID
from df1
and apply this to all rows of the corresponding ID
. I am just hugely stuck on how to do with this with my limited R knowledge of merge()
is not doing much for me.