Skip to content
Prev 388600 / 398502 Next

Converting a list to a data frame

Here is a reprex that does what I think you want:

ex <- list(mcmc = matrix(1:12, ncol = 3, byrow=TRUE),
           NULL, c("a","b", "s"))

dex <- data.frame(ex$mcmc)
names(dex) <- ex[[3]]
a  b  s
1  1  2  3
2  4  5  6
3  7  8  9
4 10 11 12

If this is not correct, you should provide a **plain text** reprex.

Of course, even if correct, this is not a template. The exact process will
depend on the structure of the list.

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Sat, Jul 24, 2021 at 6:19 AM Jeff Reichman <reichmanj at sbcglobal.net>
wrote: