I have a large R script I am trying to source in a LaTex document and then reference output from specific dataframes created in the source code in text in a LaTex paragraph.
When I compile the PDF I receive an error message that object num_stations is not found.
A small example:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\begin{document}
You can type R commands in your \LaTeX{} document and they will be properly run and the output printed in the document.
<<>>=
opts_chunk$set(echo=F,message=F, warnings=F)
#need com_dredge, table 2.1 and num_stations from this source code
source(file="S:/Adv/Scallop Central/2018 Scallop RSA/Industry Report/Industry Report.R")
#num_stations dataframe needed for text below
num_stations
@
This is a value $\Sexpr{num_stations$Number}$.
\end{document}
When I run the code chunk I dont think the source line is working. I have read a couple different options:
1. The source file needs to be in the same folder as the knitr file.
I tried this an got the error message cannot open the connection.
2. Type out the path in the source code.
I also tried that and got the same message.
3. Use
opts_knit$set(root.dir = '/Users/username/path_to_project').
I also tried this in the code chunk in the latex file and got the same message.
I would appreciate any help.

verbatimenvironment? – Sigur Feb 13 '19 at 21:09