Re: [R] retrieving object name

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Tue 11 Jul 2006 - 00:29:29 EST

Use drop = FALSE. For example using builtin data frame BOD we can display the Time column with its heading:

BOD[, "Time", drop = FALSE]

On 7/10/06, Laurent Deniau <laurent.deniau@cern.ch> wrote:
> I have a data frame with named columns and I would like to know if it is
> possible to retrieve a column name once selected:
>
> print(colnames(df)) # assumes to print "col1" "col2"
> print.name(df$col1) # would like to print "col1"
> print.name(df$col2) # would like to print "col2"
>
> So what the print.name function should do?
>
> My aim is not to print the column name but to select some settings from
> the column name withing the function (i.e. print.name), while this
> function is applied to several columns of the list/data.frame. Actually,
> I solved the problem by providing an extra parameter like:
>
> print.name(df$col1, "col1")
>
> but since I may have many of these columns/parameters combination, this
> is rather error prone and it would be much better if I could detect
> which columns of the data frame I am dealing with.
>
> Thanks.
>
> ld.

>
> ______________________________________________
> 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 Tue Jul 11 00:42:35 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 Tue 11 Jul 2006 - 02:15:45 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.