Align two data.frames next to each other with knitr?

前端 未结 2 1621
天涯浪人
天涯浪人 2020-12-06 12:26

I\'m new to knitr (and also quite new to R), so this might be a dumb question...

I have two data.frames, which both have two columns, but different numbers of rows.

2条回答
  •  北海茫月
    2020-12-06 13:11

    Would you settle for "an image" of data.frames? Clearly my solution is crude, feel free to fiddle with the details (spacing between data.frames, for example).

    Two data.frames, side by side
    ========================================================
    
    ```{r}
    library(gridExtra)
    x <- data.frame(a = runif(5), b = runif(5))
    y <- data.frame(a = runif(7), b = runif(7))
    
    grid.arrange(tableGrob(x), tableGrob(y), ncol = 2)
    ```
    

    enter image description here

提交回复
热议问题