Try this:
plot(0)
ix <- as.double(1:3)
legend("top", as.expression(lapply(ix, function(i) bquote(r^.(i)))))
On Tue, Aug 25, 2009 at 8:45 AM, Michael Cho<remhc at
channing.harvard.edu> wrote:> Hi,
>
> Trying to do something fairly simple. ?I'm trying to get a legend that
> combines superscripts with a sequence, like this:
> r^2 = 1
> r^2 = 2
> r^2 = 3
> ...
> Except that r^2 is properly formatted as a superscript.
>
> I've been playing with "substitute" and
"expression" and can get an
> individual line to appear, but I can't seem to get the syntax correct
> so that I can get several of these to appear using ?"legend".
> this works:
> i<-1
> substitute(r^2==k,list(k=i))
>
> but not this
> i<-seq(1,10)
> substitute(r^2==k,list(k=i))
>
> Can anyone help?
>
> Thanks
>
> Michael
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
>