[R] column name handling and long labels

Henrique Dallazuanna wwwhsd at gmail.com
Thu Feb 21 12:16:43 CET 2008


Try this:

1)
mydf[1,paste("col", 4:8, sep="")]

2) You can use comment function:

comment(mydf) <- c("Column number1", "Column number2")

or

comment(mydf$col1) <- "Column number1 etc"

then

comment(mydf) and comment(mydf$col1) to see the labels


On 21/02/2008, Werner Wernersen <pensterfuzzer at yahoo.de> wrote:
> Hi,
>
>  I have two loosely related questions which could make
>  my live again a bit easier:
>
>  1) Is there a simple way to select a range of columns
>  in a data frame using column names?
>  I am thinking of something like mydf[1,"col4":"col8"]
>
>  2) I have a data frame with many columns and they all
>  have short variable names which is good in most cases
>  but sometimes it would be nice to have also a longer
>  descriptive name / label attached to the variable
>  which could then be used for printing and latex
>  output. Has anybody come up with a convenient way to
>  do that?
>  Right now, I am using always match or merge in case of
>  row names.
>
>  Many thanks,
>   Werner
>
>  ______________________________________________
>  R-help at r-project.org mailing list
>  https://stat.ethz.ch/mailman/listinfo/r-help
>  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>  and provide commented, minimal, self-contained, reproducible code.
>


-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O



More information about the R-help mailing list