Subsetting data frame by factor level
问题 I have a big data frame with state names in one colum and different indexes in the other columns. I want to subset by state and create an object suitable for minimization of the index or a data frame with the calculation already given. Here's one simple (short) example of what I have m x y 1 A 1.0 2 A 2.0 3 A 1.5 4 B 3.0 5 B 3.5 6 C 7.0 I want to get this m x y 1 A 1.0 2 B 3.0 3 C 7.0 I don't know if a function with a for loop is necessary. Like minimize<-function(x,...) for (i in m$x){ do