[R] Accessing named elements of a vector
Matthias Gondan
matthias-gondan at gmx.de
Thu Feb 25 22:53:14 CET 2010
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,
vx$a is not
functional. Would it break existing compatibility if the $ would be
allowed to
access elements of a vector, as well?
Best regards,
Matthias
More information about the R-help
mailing list