Dear all; I am trying to get the minimum value of a column based on a factor column of the same data frame. My data frame is like the below: Code Y M D Q N O 41003 81 1 19 0.16 7.17 2.5 41003 77 9 22 0.197 6.8 2.2 41003 79 7 28 0.21 4.7 6.2 41005 79 8 17 0.21 5.5 7.2 41005 80 10 30 0.21 6.84 2.6 41005 80 12 20 0.21 6.84 2.4 41005 79 6 14 0.217 5.61 3.55 41009 79 2 21 0.218 5.56 4.04 41009 79 5 27 0.218 6.4 3.12 41009 80 11 29 0.22 6.84 2.8 41009 78 5 28 0.232 6 3.2 41009 81 8 20 0.233 6.39 1.6 41009 79 9 30 0.24 5.6 7.5 41017 79 10 20 0.24 5.3 7.1 41017 80 7 30 0.24 6.73 2.6
I want to get the minimum value of the "Q" column with the whole row values, according to the "Code" column which is a factor. Overall it will give me 4 rows, with the value of "Q". Below is a code that I used but it did not give me what I wanted. > x[which(x$Q == min(x$Q)),] Sincerely -- Best Regards Javad Bayat M.Sc. Environment Engineering Alternative Mail: bayat...@yahoo.com [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.