[Rd] Floating point excepting when cbind()ing a matrix of grobs (orenvironments) with a 0-column matrix

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Jan 21 11:31:06 CET 2009


Thank you: I've applied something similar (this was another in-line 
patch that did not apply, even when I fixed the line wrap).

On Mon, 19 Jan 2009, William Dunlap wrote:

> I think the following patch to src/main/bind.c fixes it up.
> If the length of an argument to [cr]bind is 0 then it wont't
> try to add any data from it to the output any more, just as
> is done with the other modes of data.  It was getting the FPE
> from i%k when k==0.
>
> Index: src/main/bind.c
> ===================================================================
> --- src/main/bind.c     (revision 47617)
> +++ src/main/bind.c     (working copy)
> @@ -1218,10 +1218,12 @@
>                case LISTSXP:
>                    PROTECT(u = coerceVector(u, mode));
>                    k = LENGTH(u);
> -                   idx = (!isMatrix(u)) ? rows : k;
> -                   for (i = 0; i < idx; i++)
> -                       SET_VECTOR_ELT(result, n++,
> -                                      duplicate(VECTOR_ELT(u, i % k)));
> +                   if (k>0) {
> +                       idx = (!isMatrix(u)) ? rows : k;
> +                       for (i = 0; i < idx; i++)
> +                           SET_VECTOR_ELT(result, n++,
> +                                          duplicate(VECTOR_ELT(u, i %
> k)));
> +                   }
>                    UNPROTECT(1);
>                    break;
>                default:
>
> Bill Dunlap
> TIBCO Software Inc - Spotfire Division
> wdunlap tibco.com
>
>> -----Original Message-----
>> From: r-devel-bounces at r-project.org
>> [mailto:r-devel-bounces at r-project.org] On Behalf Of hadley wickham
>> Sent: Monday, January 19, 2009 7:18 AM
>> To: r-devel at r-project.org
>> Subject: [Rd] Floating point excepting when cbind()ing a
>> matrix of grobs (orenvironments) with a 0-column matrix
>>
>> library(grid)
>> e <- rectGrob()
>> # OR:
>> # e <- environment()
>>
>> a <- matrix(list(e), ncol = 1, nrow = 2)
>> b <- matrix(ncol = 0, nrow = 2)
>>
>> cbind(a, b)
>>
>> cbind(a, b)
>>
>> This reliably crashes R for me.
>>
>> I realise this is a rather esoteric error condition, but it crops up
>> for me when creating matrices of grobs to be turned into a ggplot2
>> plot.
>>
>> Hadley
>>
>> --
>> http://had.co.nz/
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list