Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Character vector in R as itemized list with knitr

Tags:

r

latex

knitr

I have a vector (e.g. letters) that I want to incorporate into my .Rnw knitr document as an itemized list. How do I do this?

I have tried \Sexpr{letters} but it merely places commas between each:

a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z

Something like this is just as unhelpful:

\begin{itemize}
\item[\Sexpr{letters}]
\end{itemize}

What is the proper way to do this?

I'm looking for a result like:

  • a
  • b
  • c
  • d
  • e
  • f

etc.

like image 362
CephBirk Avatar asked Mar 17 '23 10:03

CephBirk


1 Answers

Or

\documentclass{article}
\begin{document}

Here is a list.

\begin{itemize}
<<results="asis", echo=FALSE>>=
cat(sprintf('\\item{%s}', letters[1:5]), sep = '\n')
@
\end{itemize}

That was a list.

\end{document}

enter image description here

like image 111
rawr Avatar answered Apr 07 '23 05:04

rawr