Re: [R] Name of a column

From: David Hugh-Jones <davidhughjones_at_gmail.com>
Date: Fri 16 Jun 2006 - 21:14:08 EST

  1. You don't need to say truc==T. truc is already a logical vector.
  2. colnames are just another vector, so do

colnames(truc)[truc]

Dave

On 15/06/06, David Hajage <dhajage@gmail.com> wrote:
> Hello,
>
> My problem is quite simply, but I didn't find any solution...
>
> I have a vector :
>
> > truc
> longueur30 longueur40 longueur50 longueur60 longueur70 longueur80
> longueur90
> 34 FALSE FALSE FALSE FALSE TRUE FALSE
> FALSE
>
> I would like to have the name of the column where there is "TRUE".
>
> > colnames(truc)
> [1] "longueur30" "longueur40" "longueur50" "longueur60" "longueur70"
> [6] "longueur80" "longueur90"
>
> > truc[truc == T]
> [1] TRUE
>
> > colnames(truc[truc == T])
> NULL
>
> How can I do it ?
>
> Thank you for your help.
>
> --
> David
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Jun 16 21:22:19 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 17 Jun 2006 - 00:11:39 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.