[Tex/LaTex] How tontegrate R code in TeXStudio

rrstudio

I am writing my thesis in TeXStudio. One chapter features plots / analysis etc. that I am writing in a markdown in RStudio.

Is there a way to kinda "link" the documents so the output from R is displayed in my TeXStudio document and updated automatically in case I change my code in R?

best wishes (:

Best Answer

If I understood you correctly, you just have to save the plots as pictures (.png, .jpg etc.) in your LaTeX figures folder and open them as usual. You can also specify in LaTeX any other folder on your computer by giving the full path.

\begin{figure}[htbp]
\centering
\includegraphics[width=0.5\textwidth]{F:/User/Thesis/R_Project/figures/example.PNG}
\caption[Title of Figure]{Actual Caption. It's nice if you understand the fig. by just reading this caption.}
\label{fig:res_r_lable}
\end{figure}