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

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to