I have a R function which can generate the LaTeX code (the output is the LaTex code) by using cat()
, while now I want to save these LaTeX code, but I don't know which function can save these LaTeX code...
I like to use the sink()
function:
latex.code <- function(){
cat("\\begin{align}\n")
cat("[X'X]^{-1}X'y\n")
cat("\\end{align}\n")
}
sink(file='ols.txt')
latex.code()
sink()
Edit: Obviously, you can choose the file path where the file will be saved by changing the sink argument such as: sink(file='c:/Users/Eva/Desktop/ols.txt')
, or sink(file='~/ols.txt')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With