[R] iteration loop shortening

Jason Turner jasont at indigoindustrial.co.nz
Mon Feb 11 18:45:16 CET 2002


On Mon, Feb 11, 2002 at 09:45:01AM -0500, jimi adams wrote:
> i have a loop inside of which i am selecting elements from a list
> i am wondering if once the points are selected there is a way to remove
> the element from the list, not reduce it to zero, but actually remove
> the element from the list

List indecies are one way to do it...

> aa<-list(foo=c(1,2,3),bar=c(5:10),baz=rep("hi",6))
> aa
$foo
[1] 1 2 3

$bar
[1]  5  6  7  8  9 10

$baz
[1] "hi" "hi" "hi" "hi" "hi" "hi"

> bb<-aa[-2]
> bb
$foo
[1] 1 2 3

$baz
[1] "hi" "hi" "hi" "hi" "hi" "hi"

Any others?

Cheers

Jason
-- 
Indigo Industrial Controls Ltd.
64-21-343-545
jasont at indigoindustrial.co.nz
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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