From ripley at stats.ox.ac.uk  Wed Jan 21 11:31:06 2009
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Wed, 21 Jan 2009 10:31:06 +0000 (GMT)
Subject: [Rd] Floating point excepting when cbind()ing a matrix of grobs
 (orenvironments) with a 0-column matrix
In-Reply-To: <77EB52C6DD32BA4D87471DCD70C8D7007BD906@NA-PA-VBE03.na.tibco.com>
References: <f8e6ff050901190718j65b829c5q68be435a14d8ae9b@mail.gmail.com>
	<77EB52C6DD32BA4D87471DCD70C8D7007BD906@NA-PA-VBE03.na.tibco.com>
Message-ID: <alpine.OSX.1.00.0901211030100.88949@tystie.local>

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



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