diff --git a/R/ctl_colonnade.R b/R/ctl_colonnade.R index 0134f7562..e6c49d95b 100644 --- a/R/ctl_colonnade.R +++ b/R/ctl_colonnade.R @@ -59,7 +59,10 @@ ctl_colonnade <- function(x, has_row_id = TRUE, width = NULL, out <- pmap(my_extra_cols, function(x, title, cols) { out <- as.list(x)[cols] if (!is.null(title)) { - names(out) <- paste0(paste0(title, "$", collapse = ""), names(out)) + title_empty <- rep_along(title, "") + new_names <- paste0(paste0(title_empty, "$", collapse = ""), names(out)) + new_names[[1]] <- paste0(paste0(title, "$", collapse = ""), names(out)[[1]]) + names(out) <- new_names } out }) diff --git a/tests/testthat/_snaps/tbl-format-setup.md b/tests/testthat/_snaps/tbl-format-setup.md index 1a6b907c9..dbecdcf02 100644 --- a/tests/testthat/_snaps/tbl-format-setup.md +++ b/tests/testthat/_snaps/tbl-format-setup.md @@ -534,7 +534,7 @@ # ... with 3 more variables: # `col 01`$`col 03` , - # `col 01`$`col 04` , + # $`col 04` , # `col 05` Code tbl_format_setup(x, width = 36) @@ -551,7 +551,7 @@ # ... with 3 more variables: # `col 01`$`col 03` , - # `col 01`$`col 04` , + # $`col 04` , # `col 05` Code tbl_format_setup(x, width = 37) @@ -568,7 +568,7 @@ # ... with 3 more variables: # `col 01`$`col 03` , - # `col 01`$`col 04` , + # $`col 04` , # `col 05` Code tbl_format_setup(x, width = 38) @@ -585,7 +585,7 @@ # ... with 3 more variables: # `col 01`$`col 03` , - # `col 01`$`col 04` , + # $`col 04` , # `col 05` Code tbl_format_setup(x, width = 39) @@ -602,7 +602,7 @@ # ... with 3 more variables: # `col 01`$`col 03` , - # `col 01`$`col 04` , + # $`col 04` , # `col 05` Code tbl_format_setup(x, width = 40) @@ -619,8 +619,7 @@ # ... with 3 more variables: # `col 01`$`col 03` , - # `col 01`$`col 04` , - # `col 05` + # $`col 04` , `col 05` Code tbl_format_setup(x, width = 41) Output @@ -636,8 +635,7 @@ # ... with 3 more variables: # `col 01`$`col 03` , - # `col 01`$`col 04` , - # `col 05` + # $`col 04` , `col 05` Code tbl_format_setup(x, width = 42) Output @@ -653,8 +651,7 @@ # ... with 3 more variables: # `col 01`$`col 03` , - # `col 01`$`col 04` , - # `col 05` + # $`col 04` , `col 05` Code tbl_format_setup(x, width = 43) Output @@ -670,8 +667,7 @@ # ... with 3 more variables: # `col 01`$`col 03` , - # `col 01`$`col 04` , - # `col 05` + # $`col 04` , `col 05` Code tbl_format_setup(x, width = 44) Output @@ -687,7 +683,7 @@ # ... with 2 more variables: # `col 01`$`col 03` , - # `col 01`$`col 04` + # $`col 04` Code tbl_format_setup(x, width = 45) Output @@ -703,7 +699,7 @@ # ... with 2 more variables: # `col 01`$`col 03` , - # `col 01`$`col 04` + # $`col 04` Code tbl_format_setup(x, width = 46) Output @@ -719,7 +715,7 @@ # ... with 2 more variables: # `col 01`$`col 03` , - # `col 01`$`col 04` + # $`col 04` Code tbl_format_setup(x, width = 47) Output @@ -735,7 +731,7 @@ # ... with 2 more variables: # `col 01`$`col 03` , - # `col 01`$`col 04` + # $`col 04` Code tbl_format_setup(x, width = 48) Output @@ -751,7 +747,7 @@ # ... with 2 more variables: # `col 01`$`col 03` , - # `col 01`$`col 04` + # $`col 04` Code tbl_format_setup(x, width = 49) Output @@ -766,8 +762,7 @@ 3 3.23 c c # ... with 2 more variables: - # `col 01`$`col 03` , - # `col 01`$`col 04` + # `col 01`$`col 03` , $`col 04` Code tbl_format_setup(x, width = 50) Output @@ -782,8 +777,7 @@ 3 3.23 c c # ... with 2 more variables: - # `col 01`$`col 03` , - # `col 01`$`col 04` + # `col 01`$`col 03` , $`col 04` Code tbl_format_setup(x, width = 51) Output @@ -798,8 +792,7 @@ 3 3.23 c c # ... with 2 more variables: - # `col 01`$`col 03` , - # `col 01`$`col 04` + # `col 01`$`col 03` , $`col 04` Code tbl_format_setup(x, width = 52) Output @@ -814,8 +807,7 @@ 3 3.23 c c # ... with 2 more variables: - # `col 01`$`col 03` , - # `col 01`$`col 04` + # `col 01`$`col 03` , $`col 04` Code tbl_format_setup(x, width = 53) Output @@ -830,8 +822,7 @@ 3 3.23 c c # ... with 2 more variables: - # `col 01`$`col 03` , - # `col 01`$`col 04` + # `col 01`$`col 03` , $`col 04` Code tbl_format_setup(x, width = 54) Output