s-news
[Top] [All Lists]

Re: Question re objects() and remove()

To: "Peter Flom" <flom@ndri.org>
Subject: Re: Question re objects() and remove()
From: John Fox <jfox@mcmaster.ca>
Date: Fri, 17 May 2002 07:33:31 -0400
Cc: s-news@lists.biostat.wustl.edu
Dear Peter,

I realized, after reading Chuck Cleland's similar answer to your question, that I misread what you want to do -- that is, you want to *keep* objects with periods, not to delete them. As Chuck Cleland suggested, using a negative subscript with the result from grep will do the trick.

Sorry for the confusion,
 John

My original faulty advice:


You can use grep to filter the names. The exact form depends upon the version of S-PLUS. For example, the following expression works in S-PLUS 2000 for Windows:

        objects()[grep('*.*', objects())]

while the following works in S-PLUS 6.0 for Windows:

        objects()[grep('\\.', objects())]

Once you have the names, you can use remove to erase them -- e.g., remove(objects()[grep('\\.', objects())])

-----------------------------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
email: jfox@mcmaster.ca
phone: 905-525-9140x23604
web: www.socsci.mcmaster.ca/jfox
-----------------------------------------------------


<Prev in Thread] Current Thread [Next in Thread>