To find the smallest number by group in R, we can use the group_by and summarize functions from the dplyr package:
main.r93 chars6 lines
where data is the name of the dataset, group_var is the name of the variable used to group the data, and numeric_var is the name of the numerical variable for which we want to find the smallest value.
This code will group the data by the group_var variable and then calculate the minimum value of numeric_var within each group. The result will be a new dataset with two columns: group_var and min_value.
gistlibby LogSnag