Data frame to word table?

后端 未结 3 2106
一整个雨季
一整个雨季 2020-12-24 15:45

Is there a way to easily turn a data frame into a Word table via rmarkdown?

If I use rmarkdown in RStudio to create a Word document I get a nicely printed table but

3条回答
  •  一生所求
    2020-12-24 16:04

    Here is a very low-tech (and fast) way to do it

    source("http://michael.hahsler.net/SMU/EMIS7332/R/copytable.R") 
    

    and run the example

    copytable(summary(iris))
    

    now copy&paste and you are done!

    Just for reference, here is also the source code for the copytable function:

    library(xtable)
    
    copytable <- function(x, ...) {
      f <- tempfile(fileext=".html")
      print(xtable(x, ...), "html", file = f)
      browseURL(f)
    }
    

提交回复
热议问题