[R] referring to a data-frame column using a variable

Rolf Turner r.turner at auckland.ac.nz
Mon Nov 12 20:49:03 CET 2007


On 13/11/2007, at 8:42 AM, Bernd Jagla wrote:

> Hi,
>
>
>
> I would like to refer to a column in a data frame using a variable.  
> How
> would I do this?
>
>
>
> Something like:
>
>
>
> c1<-"column1"
>
> dat${c1}
>
>
>
> where names(dat) includes 'column1'

	Use dat[[c1]].

		cheers,

			Rolf Turner

######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}



More information about the R-help mailing list