\documentclass[a4paper]{article}
\usepackage{fontspec}
\usepackage{amsfonts}
\usepackage{minted}

\setsansfont{Myriad Pro}
\setmonofont{Inconsolata}

\setlength\parindent{0pt}

\begin{document}
\renewcommand{\theFancyVerbLine}{
  \sffamily\textcolor[rgb]{0.5,0.5,0.5}{\scriptsize\arabic{FancyVerbLine}}}

Here is a short demo of the minted \LaTeX\ package, with \textsf{R} and \textsf{Python} code.

\begin{minted}[mathescape,
               gobble=2]{r}
  # generate fake data
  x <- rnorm(100)
  y <- 1.2*x + rnorm(100)
  # summarize $x$ and $y$
  apply(cbind(x, y), 2, function(x) c(mean(x), sd(x, na.rm=TRUE)))
  # fit a linear model $\mathbb{E}(y|x)=\beta_0+\beta_1x+\varepsilon$, where $\varepsilon\sim\mathcal{N}(0,1)$.
  summary(lm.fit <- lm(y ~ x))
\end{minted}

In the above, we have enabled the \verb|mathescape| option: Really awesome!
\vspace*{2em}

And here is a well-known recursive function:

\begin{minted}[mathescape,
               linenos,
               numbersep=5pt,
               gobble=2,
               frame=lines,
               framesep=2mm]{python}
  def factorial(n):
      if n == 1:
          return 1
      else:
          return n * factorial(n-1)
\end{minted}
\end{document}
