Search code examples
rdataframefile-iotexxtable

Writing to file with xtable in R


I am using the xtable to produce tex output of a dataframe in R.3.3. Is there a way to write the output to a file? When I use it I am only able to obtain tex code in my R console.


Solution

  • The print() command for xtable objects takes a file= parameter to write to a file

    library(xtable)
    data(tli)
    tli.table <- xtable(tli[1:20, ])
    print(tli.table, file="table.txt")
    

    see ?print.xtable for all the options.