[R] column name handling and long labels

Henrique Dallazuanna wwwhsd at gmail.com
Thu Feb 21 13:13:38 CET 2008


Try this:

mydf <- data.frame(s8v2=rnorm(10), s12v3=runif(10), s1a5=rnorm(10),
s6v1=rnorm(10))
pos <- match(c('s8v2', 's1a5'), names(mydf))
mydf[,seq(pos[1], pos[2])]

On 21/02/2008, Werner Wernersen <pensterfuzzer at yahoo.de> wrote:
> Thank you very much, Henrique! The comment function is
>  exactly what I was looking for.
>
>  Regarding 1) why example was bad: The column names
>  don't follow an easy pattern but are more like "s8v2",
>  "s12v3", "s6v1" etc.
>
>  Kind regards,
>   Werner
>
>
>  --- Henrique Dallazuanna <wwwhsd at gmail.com> schrieb:
>
>
>  > 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
>  >
>  >
>
>
>
>
>        __________________________________  Ihre erste Baustelle? Wissenswertes für Bastler und Hobby Handwerker. www.yahoo.de/clever
>
>


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



More information about the R-help mailing list