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
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
>>
>>
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
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) <-
4 matches
Mail list logo