[R] Pulling columns out of a data.frame
Ko-Kang Kevin Wang
ko-kang at xtra.co.nz
Fri Aug 10 02:16:35 CEST 2001
To pull out a column, say myColumn, you can do something like:
myColumn["name1"]
or
myColumn[c("name1", "name2")]
To convert to factor I believe you can use the factor() command.
Cheers,
Kevin
>
> From: "Rachel Cunliffe" <rachel at stat.auckland.ac.nz>
> Date: Fri, 10 Aug 2001 11:06:42 +1200
> To: "[R]" <r-help at stat.math.ethz.ch>
> Subject: [R] Pulling columns out of a data.frame
>
> Hi there
>
> Probably a very simple solution to this problem.
>
> I have a character vector eg c("name1","name2","name3") and I want to pull
> out these columns from a data.frame, converting each of these columns into
> factors also.
>
> Many thanks
>
> Rachel
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>
-----------------------------------
Ko-Kang Kevin Wang
Statistical Analysis Division Leader
Software Developers' Klub (SDK)
University of Auckland
New Zealand
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list