Re: [Rd] Should subsetting named vector return named vector including named unmatched elements?

2024-01-18 Thread Steve Martin via R-devel
Jiří, For your first question, the NA names make sense if you think of indexing with a character vector as the same as menu[match(select, names(menu))]. You're not indexing with "beans"; rather, "beans" becomes NA because it's not in the names of menu. (This is how it's documented in ?`[`:

Re: [Rd] tools::startDynamicHelp(): Randomly prevents R from exiting (on MS Windows)

2024-01-07 Thread Steve Martin via R-devel
Henrik, I was able to reproduce this both with Rscript and interactively using the same version of R you're using (fresh install) and Windows 10.0.22621.2715. It took about a dozen tries. Steve Original Message On Jan 6, 2024, 12:38, Henrik Bengtsson wrote: > ISSUE: On MS

Re: [Rd] [External] Re: zapsmall(x) for scalar x

2023-12-19 Thread Steve Martin
general than I initially thought. On Tue, 19 Dec 2023 at 11:25, Martin Maechler wrote: > > >>>>> Steve Martin > >>>>> on Mon, 18 Dec 2023 07:56:46 -0500 writes: > > > Does mFUN() really need to be a function of x and the NA values of x? I >

Re: [Rd] [External] Re: zapsmall(x) for scalar x

2023-12-18 Thread Steve Martin
scuss the above, > > but it seems a good time to do so now. > > > > Martin > > > > > > > > >> barry > > >> > > >> > > >> On Sun, Dec 17, 2023 at 2:17 PM Duncan Murdoch < > murdoch.dun...@

Re: [Rd] [External] Re: zapsmall(x) for scalar x

2023-12-17 Thread Steve Martin
osal wouldn't zap it to zero, and I don't >> see why summary() would if it was using your proposal. >> >> Duncan Murdoch >> >> On 17/12/2023 8:43 a.m., Gregory R. Warnes wrote: >> > Isn’t that the correct outcome? The user can change the number of digits

Re: [Rd] zapsmall(x) for scalar x

2023-12-16 Thread Steve Martin
Zapping a vector of small numbers to zero would cause problems when printing the results of summary(). For example, if zapsmall(c(2.220446e-16, ..., 2.220446e-16)) == c(0, ..., 0) then print(summary(2.220446e-16), digits = 7) would print Min. 1st Qu. MedianMean 3rd Qu.Max. 0

Re: [Rd] Use of `[` with array and resulting class

2023-09-29 Thread Steve Martin
This is due to `[` dropping dimensions by default. In your first example, think of a[1, , ] as having dimension c(1, 3, 2), but, because drop = TRUE, all dimensions of extent 1 (the first dimension) are dropped and the result has dimension c(3, 2). In your second example, b[1, , ] would have

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

[Rd] unsplit() mangles attributes

2022-11-01 Thread Steve Martin
Hello, Unsplitting a named vector that's been split sets all the names as missing. x <- 1:12 names(x) <- letters[x] f <- gl(2, 6) unsplit(split(x, f), f) 123456789 10 11 12 The unsplit() function correctly deals with row names when

Re: [Rd] partial matching of row names in [-indexing

2022-01-14 Thread Steve Martin
I don't think this is a bug in the documentation. The help page for `?[.data.frame` has the following in the last paragraph of the details: Both [ and [[ extraction methods partially match row names. By default neither partially match column names, but [[ will if exact = FALSE (and with a warning

[Rd] Should Position() use match.fun()?

2021-09-09 Thread Steve Martin
Hello, All of the funprog functions except Position() use match.fun() early in the body of the function. (Filter() seems to rely on lapply() for this, but the effect is the same.) In most cases this isn't a problem, but I can't see why Position() shouldn't look something like Position2 <-