از بسته listings استفاده کنید:
\documentclass{article}
\usepackage{listings}
\usepackage{xepersian}
\settextfont{Yas}
\setdigitfont{Tahoma}
\begin{document}
\begin{latin}
\begin{lstlisting}[language=R,escapechar={|}, basicstyle=\small\ttfamily]
>set.seed(1234)
>Formula<-Species|$\sim$|Sepal.Length+Sepal.Width+Petal.Length+Petal.Width
>iris_nnet<-nnet(Formula, data=iris, size=3, maxit=200)
>pred_nnet<-predict(iris_nnet, type="class")
>print(table(pred_nnet, iris$Species))
\end{lstlisting}
\end{latin}
\end{document}