Jeremy - 3 years ago 146

R Question

Within my graph, I have included a label of the formula used to find the displayed data:

`text(0,2,expression(paste(EMA[i], " = (", P[i], " x ",alpha,") + ",`

EMA[i-1], " x (1-",alpha,") where ",alpha," = ", frac(2,1+N))),adj=0)

The first question - The above is part of a function I am creating, which N is an adjustable argument. I would like the N above, within the frac brackets, to display whatever value N equals when the function is run. Is this possible?

Second question, how can I replace each "x" with the actual multiplication symbol. I was unable to find this, the search is a nightmare.

Thank you!

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

You can get this using `bquote`

instead of `expression`

and wrapping the N in `.()`

. Also, you can get the times sign by just using the appropriate Unicode character.

```
N = 3
plot(NULL, xlim=c(-1,4), ylim=c(-3,3))
text(0,2,bquote(paste(EMA[i], " = (", P[i], " × ",alpha,") + ",
EMA[i-1], " × (1-",alpha,") where ",alpha," = ", frac(2,1+.(N)))),adj=0)
```

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**