s-news
[Top] [All Lists]

UPDATE: Loops to create "what" for rm(list=what)

To: "S-plus list (S-plus list)" <s-news@wubios.wustl.edu>
Subject: UPDATE: Loops to create "what" for rm(list=what)
From: "P.J.Wells" <P.J.Wells@open.ac.uk>
Date: Fri, 25 Apr 2003 14:36:41 +0100
In my summary I wrote:

object.names[j] <- paste(...

# This works for me (tho' I'd be interested to know why I get warnings like
#
# Warning messages:
#   Warning in remove(list): "a1.foo.b1.bar" to be removed not in database
#
# -- but a1.foo.b1.bar is nonetheless removed)


Alan Zaslavsky has pointed out that:

> for (i in 1:length(A.list)) for (j in 1:length(B.list))
        rm(list=paste(A.list[i], ".foo.",B.list[j], ".bar", sep=""))

does the trick and avoids the warinng messages associated with


> object.names <- vector(length=length(B.list))
> for (i in 1:length(A.list))
        for (j in 1:length(B.list)){
                        assign(object.names[j], paste(A.list[i], ".foo.",
B.list[j], ".bar", sep=""))
                        rm(list=object.names)
                }


and similar, which result from the fact that

> for each j you execute the rm(list=object.names).
> However when j=1, only the first element of object.names has been changed,
> the rest are still the original value of "FALSE".


Julian Wells

School of Management
The Open University
Walton Hall
Milton Keynes
MK7 6AA
United Kingdom

(01908) 654658
+44 (1908) 654658 

<Prev in Thread] Current Thread [Next in Thread>
  • UPDATE: Loops to create "what" for rm(list=what), P.J.Wells <=