Reproducible example
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(multiverse)
#> Loading required package: knitr
M <- multiverse()
inside(M, {
data <- rnorm(100, 50, 20)
x.mean <- mean(data, trim = branch(
trim_values,
"trim_none" ~ 0,
"trim_1pc" ~ 0.05,
"trim_5pc" ~ 0.025,
"trim_10pc" ~ 0.05
))
# Create a copy with a name attribute
x.mean_named <- x.mean
names(x.mean_named) <- "NAME"
})
# Extracts the relevant variable from the multiverse
M %>%
extract_variables(x.mean)
#> # A tibble: 4 × 7
#> .universe trim_values .parameter_assignment .code .results .errors
#> <int> <chr> <list> <list> <list> <list>
#> 1 1 trim_none <named list [1]> <named list [1]> <env> <lgl>
#> 2 2 trim_1pc <named list [1]> <named list [1]> <env> <lgl>
#> 3 3 trim_5pc <named list [1]> <named list [1]> <env> <lgl>
#> 4 4 trim_10pc <named list [1]> <named list [1]> <env> <lgl>
#> # ℹ 1 more variable: x.mean <dbl>
# Extracts the relevant named variable from the multiverse
M %>%
extract_variables(x.mean_named)
#> Error in `list_unchop()`:
#> ! Can't merge the outer name `x.mean_named` with a named vector.
#> Please supply a `.name_spec` specification.
Created on 2025-05-28 with reprex v2.1.1
Expected behavior would be either that the same output results from x.mean or x.mean_named (i.e. a call to unname() somewhere in the pipeline), or that the x.mean_named can be extracted with name attribute rather than returning an error.
Surprised this hasn't come up before as plenty of lm output, such as coefficient estimates, comes in the form of named vectors.
Session Info
> sessionInfo()
R version 4.3.3 (2024-02-29 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22621)
Matrix products: default
locale:
[1] LC_COLLATE=Spanish_Chile.utf8 LC_CTYPE=Spanish_Chile.utf8 LC_MONETARY=Spanish_Chile.utf8
[4] LC_NUMERIC=C LC_TIME=Spanish_Chile.utf8
time zone: Europe/Berlin
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] data.table_1.17.4 dplyr_1.1.4 multiverse_0.6.2 knitr_1.50
Reproducible example
Created on 2025-05-28 with reprex v2.1.1
Expected behavior would be either that the same output results from
x.meanorx.mean_named(i.e. a call tounname()somewhere in the pipeline), or that thex.mean_namedcan be extracted with name attribute rather than returning an error.Surprised this hasn't come up before as plenty of
lmoutput, such as coefficient estimates, comes in the form of named vectors.Session Info