[R] Accessing named elements of a vector

2010-02-25 Thread Matthias Gondan
Dear R developers, A great R feature is that elements of vectors, lists and dataframes can have names: vx = c(a=1, b=2) lx = list(a=1, b=2) Accessing element a of vx: vx['a'] Accessing element a of lx: lx[['a']] or lx$a Might be a matter of taste, but I like the $ very much. Unfortunately,

Re: [R] Accessing named elements of a vector

2010-02-25 Thread Henrique Dallazuanna
You can convert this to list: as.list(vx)$a On Thu, Feb 25, 2010 at 6:53 PM, Matthias Gondan matthias-gon...@gmx.de wrote: Dear R developers, A great R feature is that elements of vectors, lists and dataframes can have names: vx = c(a=1, b=2) lx = list(a=1, b=2) Accessing element a of