R and LaTeX work very well together. Let me show you how to generate a LaTeX table from a R variable.
First, install the
xtable package if it’s not already.
Next load the package and create the tex-file with the table variable
result. For illustration purposes, I create a matrix with random values.
library(xtable) result <- replicate(6, rnorm(10)) # random matrix print(xtable(result), type="latex", file="output.tex")
Since you probably don’t need an object that holds the LaTeX code, creating and writing the code to a file is combined in one command.
Note: You can control the number of digits using:
The minus puts numbers into scientific format.