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 Windows, running cmd.exe, calling Rscript --vanilla -e "port R 
> --version R version 4.3.2 (2023-10-31 ucrt) -- "Eye Holes" Copyright (C) 2023 
> The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 
> (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are 
> welcome to redistribute it under the terms of the GNU General Public License 
> versions 2 or 3. For more information about these matters see 
> https://www.gnu.org/licenses/. C:\Users\hb> Rscript --vanilla -e "port 
> Rscript --vanilla -e "port
[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


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 ?`[`: "Character vectors will be 
matched to the names of the object...")

Steve


On Thursday, January 18th, 2024 at 2:51 PM, Jiří Moravec 
 wrote:


> Subsetting vector (including lists) returns the same number of elements
> as the subsetting vector, including unmatched elements which are
> reported as `NA` or `NULL` (in case of lists).
> 
> Consider:
> 
> ```
> menu = list(
> "bacon" = "foo",
> "eggs" = "bar",
> "beans" = "baz"
> )
> 
> select = c("bacon", "eggs", "spam")
> 
> menu[select]
> # $bacon
> # [1] "foo"
> #
> # $eggs
> # [1] "bar"
> #
> # $
> 
> # NULL
> 
> `Wouldn't it be more logical to return named vector/list including names of 
> unmatched elements when subsetting using names? After all, the unmatched 
> elements are already returned. I.e., the output would look like this:`
> 
> menu[select]
> # $bacon
> # [1] "foo"
> #
> # $eggs
> # [1] "bar"
> #
> # $spam
> # NULL
> 
> ```
> 
> The simple fix `menu[select] |> setNames(select)` solves, but it feels
> 
> to me like something that could be a default behaviour.
> 
> On slightly unrelated note, when I was asking if there is a better
> solution, the `menu[select]` seems to allocate more memory than
> `menu_env = list2env(menu); mget(select, envir = menu, ifnotfound = 
> list(NULL)`. Or the sapply solution. Is this a benchmarking artifact?
> 
> https://stackoverflow.com/q/77828678/4868692
> 
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel