diff --git a/R/interlaced.R b/R/interlaced.R index 23a3978..992265f 100644 --- a/R/interlaced.R +++ b/R/interlaced.R @@ -96,7 +96,7 @@ new_interlaced <- function(value_channel, na_channel, ...) { ) for (i in names(attributes(value_channel))) { - if (i != "class") { + if (i != "class" && i != "names") { if (!is.null(attr(v, i))) { cli_abort("attribute {i} in value vector conflicts with interlaced") } diff --git a/tests/testthat/test-interlaced.R b/tests/testthat/test-interlaced.R index d5bcda1..e071c03 100644 --- a/tests/testthat/test-interlaced.R +++ b/tests/testthat/test-interlaced.R @@ -222,3 +222,10 @@ test_that("model.frame drops na_channel", { expect_equal(value_channel(mod$b), c(1, 3)) expect_equal(na_channel(mod$b), unspecified(2)) }) + +test_that("vector names are preserved", { + foo <- interlaced(c(a=1, b=2, c=-99), c(-99)) + + expect_equal(names(foo), c("a", "b", "c")) + expect_equal(value_channel(foo), c(a=1, b=2, c=NA)) +})