-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Description
The bind_rows output miss the label of column as shown in the below
library(dplyr, warn.conflicts = FALSE)
packageVersion("dplyr")
#> [1] '1.1.4'
df1 <- tibble(x = 1:2, y = letters[1:2])
df2 <- tibble(x = 4:5, z = 1:2)
attr(df1$x, "label") <- "df1 lable x"
attr(df2$x, "label") <- "df2 lable x"
output1 <- bind_rows(list(df1, df2))
attributes(output1$x)
#> NULL
output2 <- data.table::rbindlist(list(df1, df2), use.names = TRUE, fill = TRUE) |>
as.data.frame()
attributes(output2$x)
#> $label
#> [1] "df1 lable x"
output3 <- data.table::rbindlist(list(df2, df1), use.names = TRUE, fill = TRUE) |>
as.data.frame()
attributes(output3$x)
#> $label
#> [1] "df2 lable x"Created on 2025-02-26 with reprex v2.1.1
d-morrison
Metadata
Metadata
Assignees
Labels
No labels