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

Re: [R] zero weights in weighted.mean

2021-07-14 Thread Göran Broström
On 2021-07-14 19:43, Sorkin, John wrote: Gentlemen, At the risk of beating a dead horse, but in he spirit of learning more about R, aren't the two expressions functionally the same? One drops values where weight is zero. The other (in the case where we and infinity * 0, something one would

Re: [R] zero weights in weighted.mean

2021-07-14 Thread Sorkin, John
Gentlemen, At the risk of beating a dead horse, but in he spirit of learning more about R, aren't the two expressions functionally the same? One drops values where weight is zero. The other (in the case where we and infinity * 0, something one would not expect to see in data) also drops data

Re: [R] assign a data frame name from a list in do loop

2021-07-14 Thread Kai Yang via R-help
Hello Rui, it's very helpful.  Thank you, Kai On Wednesday, July 14, 2021, 10:07:57 AM PDT, Rui Barradas wrote: Hello, Just before for(j in 1:nrow(ora)) include the following code line (I have removed the underscore): sdif <- vector("list", length = nrow(ora)) In the loop:

Re: [R] assign a data frame name from a list in do loop

2021-07-14 Thread Rui Barradas
Hello, Just before for(j in 1:nrow(ora)) include the following code line (I have removed the underscore): sdif <- vector("list", length = nrow(ora)) In the loop: sdif[[j]] <- sqldf(etc) Also, once again, why noquote? It's better to form file names with file.path: rdcsv  <-

[R] assign a data frame name from a list in do loop

2021-07-14 Thread Kai Yang via R-help
Hello List, I wrote a script below to compare the difference of data frames structure (and will do something else). First of all I save the file list in a data frame ora, then I use for loop to 1. load the data from two resource, 2. generate data structure into two data frames, 3.do the

Re: [R] zero weights in weighted.mean

2021-07-14 Thread Göran Broström
Den 2021-07-14 kl. 13:16, skrev Duncan Murdoch: On 14/07/2021 6:00 a.m., Göran Broström wrote: I wonder about the last sentence in the Details section of the documentation of 'weighted.mean': "However, zero weights _are_ handled specially and the corresponding ‘x’ values are omitted from

Re: [R] zero weights in weighted.mean

2021-07-14 Thread Duncan Murdoch
On 14/07/2021 6:00 a.m., Göran Broström wrote: I wonder about the last sentence in the Details section of the documentation of 'weighted.mean': "However, zero weights _are_ handled specially and the corresponding ‘x’ values are omitted from the sum." The return value of weighted.mean.default

[R] zero weights in weighted.mean

2021-07-14 Thread Göran Broström
I wonder about the last sentence in the Details section of the documentation of 'weighted.mean': "However, zero weights _are_ handled specially and the corresponding ‘x’ values are omitted from the sum." The return value of weighted.mean.default is sum((x * w)[w != 0])/sum(w) and indeed,