Skip to content
Prev 374399 / 398513 Next

Converting a list to a data frame

Hi Kevin,

There is probably a better way, but it can be done in two steps like this

temp <- list(A=data.frame(x=1:2, y=3:4),B=data.frame(x=5:6,y=7:8))

temp <- lapply(names(temp), function(n, temp) {
  temp[[n]]$type <- n
  return(temp[[n]])
}, temp = temp)

do.call(rbind, temp)



On Wed, May 2, 2018 at 1:11 PM, Kevin E. Thorpe <kevin.thorpe at utoronto.ca>
wrote: