Re: [R] Variable which has the maximum value of DF

2007-10-15 Thread jim holtman
You can also use arr.ind=TRUE to get the indices of the maximum value: > Lines <- "var1 var2 var3 var4 var5 var6 + + 0 2 1 2 0 0 + 2 3 7 6 0 1 + 1.54 9 9 6 0 + 1.06 1022 3 3 + " > DF <- read.table(text

Re: [R] Variable which has the maximum value of DF

2007-10-15 Thread Peter Dalgaard
Henrique Dallazuanna wrote: > Perhaps, > > names(which.max(sapply(DF, max))) > Nice. I was thinking along the lines of M <- as.matrix(DF) colnames(M)[col(M)[which.max(M)]] > > On 15/10/2007, Lauri Nikkinen <[EMAIL PROTECTED]> wrote: > >> Hi, >> >> Suppose I have a data.frame like this >> >>

Re: [R] Variable which has the maximum value of DF

2007-10-15 Thread Henrique Dallazuanna
Perhaps, names(which.max(sapply(DF, max))) On 15/10/2007, Lauri Nikkinen <[EMAIL PROTECTED]> wrote: > > Hi, > > Suppose I have a data.frame like this > > Lines <- "var1 var2 var3 var4 var5 var6 > > 0 2 1 2 0 0 > 2 3 7 6 0 1 > 1.54 9 9

[R] Variable which has the maximum value of DF

2007-10-15 Thread Lauri Nikkinen
Hi, Suppose I have a data.frame like this Lines <- "var1 var2 var3 var4 var5 var6 0 2 1 2 0 0 2 3 7 6 0 1 1.54 9 9 6 0 1.06 1022 3 3 " DF <- read.table(textConnection(Lines), skip=1) names(DF) <-