14
$\begingroup$

Here is a dummy piece of R code.

pca <- prcomp(matrix(rnorm(10*10), ncol=10))
pca$x
    pca$rotation

The third line appears indented, whereas it is not in the source. Removing the $ sign from the line unindents it, so it looks like a collision between MathJax and Markdwon (at least Showdown).

How can I use the $ notation in R code while avoiding this?

$\endgroup$
14
$\begingroup$

I think this is a bug.

One work-around (which applies only to code not broken across lines) is to include an end-of-line comment containing an additional dollar sign: they cancel each other in pairs.

E.g.,

pca <- prcomp(matrix(rnorm(10*10), ncol=10))
pca$x                                   # This dollar sign works around the mathjax bug: $
pca$rotation
$\endgroup$
1
  • 2
    $\begingroup$ I was afraid of that solution... :-( $\endgroup$ – gui11aume Sep 19 '12 at 13:01

You must log in to answer this question.

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