5

How does one typeset the R assignment operator ("<-")? Workarounds such as

\begin{description}
    \item[x \textless{}- c(1:3)] Create the vector [1 2 3] and assign it to an object named x.  %Illustrates workaround 1.
    \item[y $\leftangle$- c(10.4, 5.6, 3.1)] Create the vector [10.4 5.6 3.1] and assign it to an object named y.  %Illustrates workaround 2.
    \item[z $\leftarrow$ c(3.1, 6.4, 21.7)] Create the vector [3.1 6.4 21.7] and assign it to an object named z.  %Illustrates workaround 3.
\end{description}

are less than satisfactory.

4
  • 1
    Is \texttt{<-} enough for you?
    – Sigur
    Apr 5, 2014 at 18:02
  • 2
    Welcome to TeX.SX! I'd say \item[\texttt{x <- c(1:3)}] to underline the fact it's code. Also [1 2 3] might be $\begin{bmatrix} 1 & 2 & 3\end{bmatrix}$ because it's math.
    – egreg
    Apr 5, 2014 at 18:04
  • You could also use $\leftarrow$ or $\Leftarrow$ if you want something prettier. Apr 5, 2014 at 20:14
  • It looks much better if you make the whole assignment into a math formula. \item[$y \gets c(1,2,3)$] blah blah....
    – Thruston
    Apr 5, 2014 at 21:18

1 Answer 1

13

The sequence $\gets$ would do the trick.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .