我的数据如下:
dat <- structure(list(`[0,25)` = c(5L, 0L), freq = list(c(43, 20, 38,
27, 44, 177), c(5, 3, 12, 53, 73))), class = c("rowwise_df",
"tbl_df", "tbl", "data.frame"), row.names = c(NA, -2L), groups = structure(list(
.rows = structure(list(1L, 2L), ptype = integer(0), class = c("vctrs_list_of",
"vctrs_vctr", "list"))), row.names = c(NA, -2L), class = c("tbl_df",
"tbl", "data.frame")))
我只想在列中添加这个项目
[0,25)
(作为第一项)添加到列中的列表中
freq
.
期望输出
dat <- structure(list(`[0,25)` = c(5L, 0L), freq = list(c(5, 43, 20, 38,
27, 44, 177), c(0, 5, 3, 12, 53, 73))), class = c("rowwise_df",
"tbl_df", "tbl", "data.frame"), row.names = c(NA, -2L), groups = structure(list(
.rows = structure(list(1L, 2L), ptype = integer(0), class = c("vctrs_list_of",
"vctrs_vctr", "list"))), row.names = c(NA, -2L), class = c("tbl_df",
"tbl", "data.frame")))
我试过:
dat$freq <- lapply(dat$freq, \(x){
x <- append(dat$`[0,25)`, x)
x
})
但这是整个向量的附加。我该怎么做?