Skip to content
Back to formatted view

Raw Message

Message-ID: <200103151055.FAA19621@cattell.psych.upenn.edu>
Date: 2001-03-15T10:55:07Z
From: Jonathan Baron
Subject: Alternative to list()

>Suppose I have a dataset with 10 columns, let's call it "foo".
>
>Now if I want to extract out only column 2 ~ 8, then I know I can use =
>either:
>     foo[ ,2:8]
>or
>     fooNew <- list( foo[ ,2:8] )
>
>(Is there any other alternative, just out of curiosity?)
>
>But, if I only want, say, column 1, 4 and 7, I tried:
>     fooNew <- list( x =3D foo[ ,1], y =3D foo[ ,4], z =3D foo[ , 7]  )
>then when I type=20
>     fooNew
>I got a list of:
>  $x
>   ....
>   ....
>  $y
>   ....
>   ....
>  $z
>   ....
>   ....
>
>However what I really want is for them to be in vector/column form.  How =
>would I do this?

foo[,c(1,4,7)]

JOn
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._