Search code examples
rr-markdownpandocequationpapaja

How to write an Equation in R (papaja)?


I'm trying to write this equation using the papaja package:

\begin{equation}
\tag{1}
$$LogVolume_(dcr)=$\alpha$ +$\beta$DMonday+$\gamma$DTuesday+...+$\delta$DSaturday+ $\epsilon$ $$ 
\end{equation}

It is a basic regression model equation but I'm having issues when trying to knit to pdf. I wrote it according to this article

I get the following error in the output:

! Undefined control sequence.
l.137 $$\LogVolume
                  _(dcr)=$\alpha$ +$\beta$DMonday+$\gamma$DTuesday+...+$\del...

Error: Failed to compile bbbb.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. 
See bbbb.log for more info.

Can anyone help me understand where the problem is? Thank you very much!


Solution

  • It's hard to know for sure - it might matter whether you're trying to compile to HTML or PDF, for example, and what else is in your document - but this works for me in an HTML document:

    \begin{equation}
    \tag{1}
    \textrm{LogVolume}_{dcr}=\alpha +\beta \cdot \textrm{DMonday}+ 
          \gamma \cdot \textrm{DTuesday} +...+\delta \cdot \textrm{DSaturday}+ \epsilon
    \end{equation}
    

    Basically, I eliminated unnecessary $s. (I also made your variables Roman rather than italic; used {} around your subscript; and added center-dots for multiplication.)

    enter image description here