I´m writing my thesis in LaTeX (using Overleaf) and I analyzed some data in R. So I have a R script where I perform a bunch of tests and regressions. Now I want to e.g. include the t-statistic and p-value in the Text.
x <- rnorm(10, 180, 10)
y <- rnorm(10, 150, 10)
Our Hypothesis that x is taller than y was accepted (t =t.test(x , y)$statisic; p = t.test(x, y)$p.value).
S.t. In the final pdf it says:
Our Hypothesis that x is taller than y was accepted (t =-7.8841, p = 0.000).
What is the easiest way to do this? What is the workflow?
I`d be thankful for any advice using LaTeX. Even more so for advice for Overleaf.
datatoolpackage if you are willing to save some of the results inside a file and read into your LaTeX code later. Another way is write18 which you might be able to run a shell command with that. However, if you are using overleaf as a online editor, only the first suggestion might worth trying. – Majid Abdolshah Mar 27 '19 at 23:13sagetexpackage uses open source computer algebra system SAGE which includes R, see here. If you don't mind using Cocalc then you have access to SAGE, which should let you run R, and insert the results into your LaTeX document, similar to my answer here which used SAGE but not R in calculating descriptive statistics. Sagetex documentation here. – DJP Mar 27 '19 at 23:33sagetexdocument says "Similarly, the R statistical computing environment includes Sweave, which lets you do the same thing with R code and LATEX". So maybe worth looking into Sweave. Maybe something like this? – DJP Mar 27 '19 at 23:39knitrlike this: https://tex.stackexchange.com/a/481061/ – Ross Mar 27 '19 at 23:48