[R] order and rm()

Ott Toomet otoomet at econ.dk
Tue Nov 19 08:48:33 CET 2002


channelheader <- "CHH" # you need to define it
rm (c (channelheader, paste ("channel", 1:3, sep="")))

gives an error, but

rm (list=c (channelheader, paste ("channel", 1:3, sep="")))

should remove objects

CHH, channel1, channel2, channel3

It is possible to list objects using regexp (a generalisation of
wildcards, look ?grep).  E.g. you may write

objs <- ls(pattern="^channel[1-3]")
rm(list=c(channelhead, objs))

in order to achive the same result as above.
Perhaps it helps


 | From: "Balint, Jess" <JBalint at alldata.net>
 | Date: Mon, 18 Nov 2002 14:20:21 -0500
 | Hello all. I have two small questions in one post, for the sake of brevity.
 | 1. I have some objects that I want to delete. I have the line:
 | rm (c (channelheader, paste ("channel", 1:3, sep="")))
 | I have tried a few variations, including list=, but cannot figure it out. In
 | SAS, I can use a ':' as a wildcard. Is there any equivalent in R?
 | 2. Is there any possible was to order data by the second to last character?
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