示例数据:
names <- c("Cycling1.opr", "Cycling2.opr", "Cycling3.opr")
mydf1 <- data.frame(V1=c(1:5), V2=c(21:25))
mydf2 <- data.frame(V1=c(1:10), V2=c(21:30))
mydf3 <- data.frame(V1=c(1:30), V2=c(21:50))
opr <- list(mydf1,mydf2,mydf3)
mydf4 <- data.frame(timestamp=c(1:5))
mydf5 <- data.frame(timestamp=c(1:10))
mydf6 <- data.frame(timestamp=c(1:30))
timestamp <- list(mydf4,mydf5,mydf6)
names(opr) <- names
names(timestamp) <- names
每个列表(opr和timestamp)总是有相同数量的data.frames,并且当具有相同的名称时,这些data.frames中的每个总是具有相同的长度。我想做的是将每个名称相似的 Dataframe 合并为一个 Dataframe ,作为最终列表(可能命名为finalopr)的一部分,其结构如下所示。
final_opr <- read.table(header = TRUE, text = "
z.surv.mos raceeth year.2cat pt nevent ncensor nrisk cum.ev cum.cen pointflg pe se lower.cl upper.cl
'38' 36. 1. 1. 0.10896243930756 9. 0. 311. 2474. 1. 1. 0.89103756069243 0.00591553159512 0.09796374785164 0.12119598770184
'134' 36. 1. 2. 0.12919986395988 3. 9. 96. 2469. 958. 1. 0.87080013604011 0.00860912091676 0.11338170396883 0.14722485430136
'183' 36. 2. 1. 0.10763696166101 0. 0. 33. 287. 4. 1. 0.89236303833898 0.01746946721576 0.07830897003442 0.14794876641234
'246' 36. 2. 2. 0.0918969557367 0. 1. 9. 342. 107. 1. 0.90810304426329 0.01975702415208 0.06029765195198 0.1400560419898
'289' 36. 3. 1. 0.14186152615109 2. 0. 72. 440. 12. 1. 0.8581384738489 0.01550071018085 0.11451353670001 0.17574073058836
'366' 36. 3. 2. 0.12701814940611 1. 2. 21. 496. 198. 1. 0.87298185059388 0.01904081251339 0.09468155080317 0.17039866945242
'412' 36. 4. 1. 0.05405405405405 0. 0. 2. 35. 0. 1. 0.94594594594594 0.03717461110299 0.01404207131432 0.20807761862723
'452' 36. 4. 2. 0.09393141727008 0. 1. 2. 40. 13. 1. 0.90606858272991 0.05797150600236 0.02802051731609 0.31488038035974
'491' 36. 5. 1. 0.08880901672474 1. 0. 48. 505. 19. 1. 0.91119098327525 0.01228353765126 0.06772108402588 0.11646360310182
'563' 36. 5. 2. 0.11716939090588 1. 0. 20. 616. 239. 1. 0.88283060909411 0.01608823714602 0.08952365586359 0.15335238527538
")
1条答案
按热度按时间c7rzv4ha1#
结构如下: