Re: [Rd] Augment base::replace(x, list, value) to allow list= to be a predicate?

2023-03-07 Thread Steve Martin
That's an interesting example, as it's conceptually similar to what Pavel is proposing, but structurally different. gsubfn() is more complicated than a simple switch in the body of the function, and wouldn't work well as an anonymous function. Multiple dispatch can nicely encompass both of these c

Re: [Rd] Undocumented change of dirname("C:/") on R-devel on Windows

2023-03-07 Thread Yihui Xie
Thanks a lot! I can confirm that it has been fixed indeed. Regards, Yihui On Mon, Feb 27, 2023 at 1:14 PM Tomas Kalibera wrote: > > On 2/27/23 17:02, Yihui Xie wrote: > > Hi Tomas, > > There has been an R CMD check error with xfun and r-devel on Windows for a > while: > https://www.r-project.

Re: [Rd] Augment base::replace(x, list, value) to allow list= to be a predicate?

2023-03-07 Thread Gabor Grothendieck
This could be extended to sub and gsub as well which gsubfn in the gusbfn package already does: library(gsubfn) gsubfn("^..", toupper, c("abc", "xyz")) ## [1] "ABc" "XYz" On Fri, Mar 3, 2023 at 7:22 PM Pavel Krivitsky wrote: > > Dear All, > > Currently, list= in base::replace(x, list, valu

Re: [Rd] Augment base::replace(x, list, value) to allow list= to be a predicate?

2023-03-07 Thread Pavel Krivitsky
Dear Serguei, On Mon, 2023-03-06 at 09:45 +0100, Serguei Sokol wrote: > Right, but anonymous function syntax can palliate to this: > > x |> (\(x) replace(x, is.na(x), 0))() This approach hardly makes for concise or readable code. > > Before modifying the base of R, we should examine existing >