Help
Hi, ?set.seed(42) mat1 <- matrix(sample(40,5*3,replace=TRUE),ncol=3) mat2 <- apply(mat1,1,sort,decreasing=TRUE) ?mat2[1,]- mat2[2,] A.K. Thank you. And if I have a lot of rows? How can I apply this for row?
On Sunday, February 9, 2014 8:20 PM, arun <smartpink111 at yahoo.com> wrote:
Based on the data. vec1 <- c(56,98,15) vec2 <- sort(vec1,decreasing=TRUE) ?vec2[1]-vec2[2] #[1] 42 A.K. Hi, I need some help in a simple thing.... If I have 3 classes like ? ?56 ? ? 98 ? ?15, I need do max1-max2 where the max 1 is the maximun (98) and the max2 is the second maximun (56)... How can I do this in R? To obtain the max I used ?apply(data, 1, max), but...and the other? Thanks