I have two tables:
df_workingFile
group v
1 a 110
2 a 90
3 b 57
4 b 53
df_groupIDs
group
1 a
2 b
I want to pull in the maximum value from df_workingFile for a group label into df_groupIDs
df_groupIDs
groups max
1 a 110
2 b 57
I have code that does this, but it's really slow with large datasets.
data.frame(df_groupIDs, maxValue =
sapply(df_groupIDs$group, function(newCol)
max(subset(df_workingFile, newCol == df_workingFile$group)$v)))
Any suggestions on how to make this more efficient?