[R] Alternative to list()
Petr Pikal
petr.pikal at precheza.cz
Thu Mar 15 11:22:40 CET 2001
On 15 Mar 2001, at 19:33, Ko-Kang at xtra.co.nz wrote:
> Hi,
>
> 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] )
Hm. Why do you bother with list. I assume foo is either matrix or data
frame and for this I usually use
fooNew_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 = foo[ ,1], y = foo[ ,4], z = foo[ , 7] ) then
> when I type
> 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?
again
fooNew_foo[,c(1,4,7)]
can probably do what you want.
>
> Thanks in advance!
>
>
> Kevin
>
> -------------------------------------------------
> Ko-Kang Kevin Wang
> Statistical Analysis Division Leader
> Software Developers' Klub
> University of Auckland
> New Zealand
>
Hi.
Petr Pikal
Precheza a.s.
Nabr.Dr.E.Benese 24
tel: 00420 641 25 2257
+420 (0)724 008 364
petr.pikal at precheza.cz
p.pik at volny.cz
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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