I am running the following R code in a code block in org-mode.
#+begin_src R :session :results output latex :exports results
library(ggplot2)
library(xtable)
x <- rnorm(1000)
g0 <- ggplot(as.data.frame(x), aes(x)) +
geom_histogram(); g0
hist_dat <- ggplot_build(g0)$data[[1]]
hist_dat <- hist_dat |>
select(xmin, xmax, count)
print(xtable(hist_dat, digits = c(0, 1, 1, 0)), include.rownames = FALSE)
#+end_src
This creates the expected LaTeX code:
\begin{table}[ht]
\centering
\begin{tabular}{rrr}
\hline
xmin & xmax & count \\
\hline
-3.3 & -3.1 & 1 \\
-3.1 & -2.9 & 1 \\
-2.9 & -2.6 & 0 \\
-2.6 & -2.4 & 5 \\
-2.4 & -2.2 & 7 \\
-2.2 & -1.9 & 14 \\
-1.9 & -1.7 & 11 \\
-1.7 & -1.5 & 20 \\
-1.5 & -1.3 & 35 \\
-1.3 & -1.0 & 49 \\
-1.0 & -0.8 & 64 \\
-0.8 & -0.6 & 67 \\
-0.6 & -0.3 & 108 \\
-0.3 & -0.1 & 90 \\
-0.1 & 0.1 & 98 \\
0.1 & 0.3 & 85 \\
0.3 & 0.6 & 84 \\
0.6 & 0.8 & 62 \\
0.8 & 1.0 & 59 \\
1.0 & 1.3 & 35 \\
1.3 & 1.5 & 32 \\
1.5 & 1.7 & 22 \\
1.7 & 1.9 & 25 \\
1.9 & 2.2 & 13 \\
2.2 & 2.4 & 10 \\
2.4 & 2.6 & 1 \\
2.6 & 2.9 & 1 \\
2.9 & 3.1 & 0 \\
3.1 & 3.3 & 0 \\
3.3 & 3.6 & 1 \\
\hline
\end{tabular}
\end{table}
However, when I run org-export-dispatch and select export to LaTeX and As PDF file and open, I get nothing in the PDF (neither code nor the results). I wonder what I'm doing wrong.