dhfly
刚好干过这事,代码如下
qq = as.data.frame(matrix(1:12, nrow = 3, ncol = 4))
test.l = list(qq=qq)
test.l.addname = lapply(1:length(test.l),function(i){
df = test.l[[i]]
name = names(test.l)[i]
df$name = name
return(df)
})
test.l.addname
#> [[1]]
#> V1 V2 V3 V4 name
#> 1 1 4 7 10 qq
#> 2 2 5 8 11 qq
#> 3 3 6 9 12 qq
<sup>Created on 2019-03-06 by the reprex package (v0.2.1)</sup>