Trying to include R Code with listings package
\lstinputlisting{}
should not be inside a \begin{lstlisting}
and \end{lstlisting}
pair. Remove the begin and end and it should work as expected.
I have no sufficient reputation to comment, so I will point out that you need to include
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}
after the color
package.