[R-SIG-Mac] legend function and Inf warnings

Duncan Murdoch murdoch@dunc@n @ending from gm@il@com
Sat Oct 20 18:09:27 CEST 2018


On 20/10/2018 11:23 AM, Ossenbruggen, Paul wrote:
> 	I receive warnings() that make debugging difficult. I have two questions:

I think you've posted this to the wrong list.  Maybe R-help instead?

> 
> 1. In this part of my script, I want my script to return “Inf”. I receive the following warning.
> 
> In min(df12.[df12.[, 7] <= 0, 1]) :
>    no non-missing arguments to min; returning Inf
> 
> Is there are command to eliminate the warning message?


You can add another value and suppress the message:

min(c()) gives the warning, min(c(), 2) will give 2.  You'll need to 
find some value that you can distinguish from a real minimum...

Sorry, no comment on your other question.

Duncan Murdoch

> 
> 2. I use the following legend that returns a plot that I am happy with and no errors:
> 
> legend("topright",
>               title = "",
>               legend = c(
>                 expression("Predictions:"),
>                 bquote(bar(u)[A] == .(u.a)),
>                 bquote(bar(u)[D] == .(u.d))
>               ),
>               cex = c(0.75,0.75,0.75)
>               )
> 
> At the same time, I receive the following warnings:
> 
> warnings()
> Warning messages:
> 1: In if (xc < 0) text.width <- -text.width :
>    the condition has length > 1 and only the first element will be used
> 2: In strheight(legend, units = "user", cex = cex)/yc :
>    longer object length is not a multiple of shorter object length
> 3: In w0 * rep.int(0:(ncol - 1), rep.int(n.legpercol, ncol)) :
>    longer object length is not a multiple of shorter object length
> 4: In left + xchar + xextra + (w0 * rep.int(0:(ncol - 1),  ... :
>    longer object length is not a multiple of shorter object length
> 5: In (rep.int(1L:n.legpercol, ncol)[1L:n.leg] - 1 + !is.null(title)) *  ... :
>    longer object length is not a multiple of shorter object length
> 6: In top - 0.5 * yextra - ymax - (rep.int(1L:n.legpercol,  ... :
>    longer object length is not a multiple of shorter object length
> 7: In xt + x.intersp * xchar :
>    longer object length is not a multiple of shorter object length
> 8: In if (xc < 0) text.width <- -text.width :
>    the condition has length > 1 and only the first element will be used
> 9: In if (xc < 0) text.width <- -text.width :
>    the condition has length > 1 and only the first element will be used
> 
> If I remove “bquote” from “legend,” no warnings are produced.
> 
> By the way, “xc,” “yextra”, and other variable listed are not part of my script. I have no idea what to do with the warning information.
> 
> Is there a better way to write my “legend” code?
> 
> Thanks,
> Paul
> 
> 
> 
> 
> 
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>



More information about the R-SIG-Mac mailing list