Plot a data frame as a table

前端 未结 2 906
梦谈多话
梦谈多话 2020-12-08 10:44

I am moving away from Word/Excel tables and trying to generate a table in R. I have a data frame that I\'d like to simply print as a plot, while being able

相关标签:
2条回答
  • 2020-12-08 11:28

    Since I am going for the bonus points:

       #Plot your table with table Grob in the library(gridExtra)
       ss <- tableGrob(x)
    
       #Make a scatterplot of your data
       k <- ggplot(x,aes(x=x$"Value 1",y=x$"Value 2")) + 
       geom_point()
    
       #Arrange them as you want with grid.arrange
       grid.arrange(k,ss)
    

    You can change the number of rows, columns, height and so on if you need to.

    Good luck with it enter image description here

    http://cran.r-project.org/web/packages/gridExtra/gridExtra.pdf

    0 讨论(0)
  • 2020-12-08 11:35

    Try this. Yes use pdf() to plot a PDF file (e.g. mydf.pdf) or png() to plot a png file:

    library(gridExtra)
    pdf("mypdf.pdf", height=6, width=4)
    grid.table(x)
    dev.off()
    

    enter image description here

    0 讨论(0)
提交回复
热议问题