[R] Addressing Columns in a Data Frame

Lorenzo Isella lorenzo.isella at gmail.com
Sat Feb 9 14:40:59 CET 2013


Dear All,
Probably a one liner, but I am banging my head against the floor.
Consider the following

DF <- data.frame(
    x=1:10,
    y=10:1,
    z=rep(5,10),
    a=11:20
  )

mn<-names(DF)

but then I cannot retrieve a column by doing e.g,

DF$mn[2]

I tried to play with the quotes and so on, but so far with no avail.
Any suggestion is welcome.
Cheers

Lorenzo



More information about the R-help mailing list