[R] plot labeling and expressions

Johannes Graumann johannes_graumann at web.de
Wed Jan 16 12:09:07 CET 2008


Uwe Ligges wrote:

> 
> 
> Johannes Graumann wrote:
>> Hi all,
>> 
>> I'm trying to use an iteration that appends something to vector
>> 'peaklabels' like so:
>> peaklabelNames <- append(
>>         peaklabelNames,
>>         substitute(i^{z+phantom()}*" ("*a*"AMU)",list(i="y2",z=2,a=0))
>> )
>> The vector is supposed to be used with 'text' to put labels on signals in
>> an impulse plot.
>> 
>> While not vectorized
>>         substitute(i^{z+phantom()}*" ("*a*"AMU)",list(i="y2",z=2,a=0))
>> works for me, the vectorized form doesn't. The labels are represented as
>>         "y2"^2 (AMU)
>> (note the '"' in the printed string). Can anyone please give me a hint on
>> how to resolve this?
> 
> 
> I do not know what you mean by vectorized form. Can you give an example
> what you want to achieve and what you tried to do so?

Thanks for looking at this.

The actual code looks something like this:

peaklabelNames <- c()
for(i in sequence(10)){
        peaklabelNames <- append(
                peaklabelNames,
                substitute(i^{z+phantom()}*" ("*a*"AMU)",list(i="y2",z=2,a=0))
        )
}

and is than used after 'plot' as

text(somex,somey,labels=peaklabelNames)

That doesn't work as described above.

Thanks for your time, Joh




More information about the R-help mailing list