[R] retrieving object name
laurent.deniau at cern.ch
Mon Jul 10 15:54:02 CEST 2006
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:
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.
More information about the R-help