[R] accessing elements located after $ symbol

Ben Bolker bbolker at gmail.com
Tue Oct 5 14:26:30 CEST 2010


Joshua Wiley <jwiley.psych <at> gmail.com> writes:

  [snip]

> Look at these examples:
> 
> test[interest]
> #or
> test[, interest]
> # but
> test[first]
> test[,first]
> 
> Notice that for `[`, the name of the column _must_ be quoted, or be an
> object itself.  

  or test[[first]] ; you probably do not want test[first] , which returns
a list of length 1 containing the column of interest, rather than the
column itself ...



More information about the R-help mailing list