Skip to content
Prev 388615 / 398502 Next

Converting a list to a data frame

Hello,

No, it's not possible to work with a matrix in ggplot2.
Not even with an object of class "list".



l <- list(x=1:5, y=1:5)
d <- as.data.frame(l)
m <- as.matrix(d)

library(ggplot2)
ggplot(l, aes(x, y)) + geom_point()  # Error
ggplot(d, aes(x, y)) + geom_point()  # OK, as expected
ggplot(m, aes(x, y)) + geom_point()  # Error



Hope this helps,

Rui Barradas


?s 22:31 de 24/07/21, Jeff Reichman escreveu: