[R] Math expressions in pie chart labels?
Uwe Ligges
ligges at statistik.uni-dortmund.de
Wed May 3 18:05:06 CEST 2006
Gabor Grothendieck wrote:
> On 5/3/06, Uwe Ligges <ligges at statistik.uni-dortmund.de> wrote:
>
>> Johannes Graumann wrote:
>>
>> > On Tuesday 02 May 2006 23:33, Uwe Ligges wrote:
>> >
>> >>Then please read ?plotmath and use it:
>> >>
>> >>labels = expression("" >= 0.66, "" == 0.33, "" <= -0.33, "" <= -0.66)
>> >
>> >
>> > Error in lab != "" : comparison is not allowed for expressions
>> > In addition: Warning message:
>> > is.na() applied to non-(list or vector) in: is.na(lab <- labels[i])
>> >
>> > I don't seem to be the only one having problems with this ;0)
>>
>>
>> Then please tell us the details, I just tried successfully:
>>
>> plot(1:10, xaxt="n")
>> axis(1, at = c(1,3,5,7), labels =
>> expression("" >= 0.66, "" == 0.33, "" <= -0.33, "" <= -0.66))
>>
>
> I think the discussion applies to pie:
>
>> pie(c(1,3,5,7), labels =
>
> + expression("" >= 0.66, "" == 0.33, "" <= -0.33, "" <= -0.66))
> Error in lab != "" : comparison is not allowed for expressions
> In addition: Warning message:
> is.na() applied to non-(list or vector) in: is.na(lab <- labels[i])
>
Ah, I see, this happens in pie()'s line:
if (!is.na(lab <- labels[i]) && lab != "") {
where lab is one element of the expression.
I'd like to propose to change that line to
if (!is.na(lab <- labels[i]) && nchar(lab) > 0) {
Uwe Ligges
More information about the R-help
mailing list