Re: [R] ls() pattern question

2021-07-15 Thread Bert Gunter
Yes,. Thanks for the clarification. I tried to indicate this with my comment about it being used as the "name" argument of ls(). What I should have said is that it is syntactically wrong as a way to specify an argument of any function -- "myarg != something" does not specify anything about the

Re: [R] ls() pattern question

2021-07-15 Thread Duncan Murdoch
On 14/07/2021 8:21 p.m., Bert Gunter wrote: Actually fun( param != something..) is syntactically incorrect in the first place for any function! You have to be careful with absolute statements: > f <- function(pattern) cat("It's legal!") > f(pattern != something..) It's legal! "pattern

Re: [R] ls() pattern question

2021-07-14 Thread Kai Yang via R-help
Thanks Andrew. it works well. --- Kai On Wednesday, July 14, 2021, 05:22:01 PM PDT, Bert Gunter wrote: Actually fun( param != something..) is syntactically incorrect in the first place for any function! ls sees "pat != whatever"  as the "name" argument of ls() and can't make any

Re: [R] ls() pattern question

2021-07-14 Thread Bert Gunter
Actually fun( param != something..) is syntactically incorrect in the first place for any function! ls sees "pat != whatever" as the "name" argument of ls() and can't make any sense of it, of course. Bert Gunter "The trouble with having an open mind is that people keep coming along and

Re: [R] ls() pattern question

2021-07-14 Thread Andrew Simmons
Hello, First, `ls` does not support `!=` for pattern, but it's actually throwing a different error. For `rm`, the objects provided into `...` are substituted (not evaluated), so you should really do something like rm(list = ls(pattern = ...)) As for all except "con", "DB2", and "ora", I would

[R] ls() pattern question

2021-07-14 Thread Kai Yang via R-help
Hello List, I have many data frames in environment.  I need to keep 3 data frames only, con DB2 and ora.  I write the script to do this.  rm(ls(pattern != c("(con|DB2|ora)"))) but it give me an error message: Error in rm(ls(pattern != c("(con|DB2|ora)"))) :    ... must contain names or