Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-06-01 Thread Wacek Kusnierczyk
Martin Maechler wrote: >> "PS" == Petr Savicky >> on Sun, 31 May 2009 10:29:41 +0200 writes: >> > > [] > > PS> I appreciate the current version, which contains static > PS> const char* dropTrailing0(char *s, char cdec) ... > PS> mkChar(dropTrail

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-06-01 Thread Martin Maechler
> "PS" == Petr Savicky > on Sun, 31 May 2009 10:29:41 +0200 writes: [] PS> I appreciate the current version, which contains static PS> const char* dropTrailing0(char *s, char cdec) ... PS> mkChar(dropTrailing0((char *)EncodeReal(x, w, d, e, PS> OutDec), ..

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-31 Thread Petr Savicky
On Sat, May 30, 2009 at 07:32:52PM +0200, Martin Maechler wrote: > > "vQ" == Wacek Kusnierczyk > > on Sat, 30 May 2009 11:16:43 +0200 writes: [...] > vQ> one simple way to improve the code is as follows; instead of > (simplified) > > vQ> const char* dropTrailing(const char

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-30 Thread Wacek Kusnierczyk
Martin Maechler wrote: [...] > vQ> the first question is, why does ER return the string as const? it > vQ> appears that the returned pointer provides the address of a buffer > used > vQ> internally in ER, which is allocated *statically*. that is, each call > vQ> to ER operates

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-30 Thread Martin Maechler
> "vQ" == Wacek Kusnierczyk > on Sat, 30 May 2009 11:16:43 +0200 writes: vQ> Martin Maechler wrote: >> Hi Waclav (and other interested parties), >> >> I have committed my working version of src/main/coerce.c >> so you can prepare your patch against that. >>

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-30 Thread Martin Maechler
2009/5/30 Wacek Kusnierczyk : > Martin Maechler wrote: >> Hi Waclav (and other interested parties), >> >> I have committed my working version of src/main/coerce.c >> so you can prepare your patch against that. >> > > Hi Martin, > > One quick reaction (which does not resolve my original complaint):

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-30 Thread Uwe Ligges
Wacek Kusnierczyk wrote: Martin Maechler wrote: Hi Waclav (and other interested parties), I have committed my working version of src/main/coerce.c so you can prepare your patch against that. some further investigation and reflections on the code in StringFromReal (henceforth SFR), src/ma

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-30 Thread Wacek Kusnierczyk
Martin Maechler wrote: > Hi Waclav (and other interested parties), > > I have committed my working version of src/main/coerce.c > so you can prepare your patch against that. > some further investigation and reflections on the code in StringFromReal (henceforth SFR), src/main/coerce.c:315 (as in

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-29 Thread Wacek Kusnierczyk
Martin Maechler wrote: > Hi Waclav (and other interested parties), > > I have committed my working version of src/main/coerce.c > so you can prepare your patch against that. > Hi Martin, One quick reaction (which does not resolve my original complaint): you can have p non-const, and cast s to

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-29 Thread Martin Maechler
Hi Waclav (and other interested parties), I have committed my working version of src/main/coerce.c so you can prepare your patch against that. Thank you in advance! Martin On Fri, May 29, 2009 at 21:54, Wacek Kusnierczyk wrote: > Martin Maechler wrote: > > [...] >>     vQ> you return s, which s

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-29 Thread Wacek Kusnierczyk
Martin Maechler wrote: [...] > vQ> you return s, which should be the same pointer value (given the actual > vQ> code that does not modify the local variable s) with the same > pointed-to > vQ> string value (given the signature of the function). > > vQ> was perhaps > > vQ> char

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-29 Thread Wacek Kusnierczyk
Petr Savicky wrote: > On Fri, May 29, 2009 at 03:53:02PM +0200, Martin Maechler wrote: > >> my version of *using* the function was >> >> 1 SEXP attribute_hidden StringFromReal(double x, int *warn) >> 2 { >> 3 int w, d, e; >> 4 formatReal(&x, 1, &w, &d, &e, 0); >> 5 if (ISNA(x)) return NA_S

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-29 Thread Petr Savicky
On Fri, May 29, 2009 at 03:53:02PM +0200, Martin Maechler wrote: > my version of *using* the function was > > 1 SEXP attribute_hidden StringFromReal(double x, int *warn) > 2 { > 3 int w, d, e; > 4 formatReal(&x, 1, &w, &d, &e, 0); > 5 if (ISNA(x)) return NA_STRING; > 6 else return mkChar(d

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-29 Thread Martin Maechler
> "vQ" == Wacek Kusnierczyk > on Thu, 28 May 2009 00:36:07 +0200 writes: vQ> Martin Maechler wrote: >> >> I have very slightly modified the changes (to get rid of -Wall >> warnings) and also exported the function as Rf_dropTrailing0(), >> and tested the result wi

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-29 Thread Martin Maechler
> "PS" == Petr Savicky > on Thu, 28 May 2009 09:36:48 +0200 writes: PS> On Wed, May 27, 2009 at 10:51:38PM +0200, Martin Maechler wrote: >> I have very slightly modified the changes (to get rid of -Wall >> warnings) and also exported the function as Rf_dropTrailing0(),

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-28 Thread Petr Savicky
On Wed, May 27, 2009 at 10:51:38PM +0200, Martin Maechler wrote: > I have very slightly modified the changes (to get rid of -Wall > warnings) and also exported the function as Rf_dropTrailing0(), > and tested the result with 'make check-all' . Thank you very much for considering the patch. -Wall

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-27 Thread Wacek Kusnierczyk
Martin Maechler wrote: > > I have very slightly modified the changes (to get rid of -Wall > warnings) and also exported the function as Rf_dropTrailing0(), > and tested the result with 'make check-all' . > As the change seems reasonable and consequent, and as > it seems not to produce any problems

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-27 Thread Martin Maechler
> "PS" == Petr Savicky > on Sat, 23 May 2009 09:44:54 +0200 writes: PS> Function factor() in the current development version PS> (2009-05-22) guarantees that levels are different PS> character strings. However, they may represent the same PS> decimal number. The follow

[Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-23 Thread Petr Savicky
Function factor() in the current development version (2009-05-22) guarantees that levels are different character strings. However, they may represent the same decimal number. The following example is derived from a posting by Stavros Macrakis in thread "Match .3 in a sequence" in March nums <- 0