[R] display math with subscripts from a sequence
Duncan Murdoch
murdoch@dunc@n @end|ng |rom gm@||@com
Sat Apr 18 21:34:03 CEST 2020
On 18/04/2020 3:10 p.m., Ranjan Maitra wrote:
> Dear friends,
>
> I am trying to display a sequence of characters x_1, x_2, ... x_30 on a plot.
>
> I know that I can use expression to do this by expression("x"[1]), etc. But, how do I do this efficiently for an entire sequence without having to type the individual expressions one by one?
e <- expression()
for (i in 1:30) e <- c(e, eval(substitute(expression(x[i]), list(i = i))))
plot(1:30, 1:30, type="n")
text(1:30, 1:30, labels=e)
Duncan Murdoch
More information about the R-help
mailing list