Saren Tasciyan
2019-Mar-29 15:38 UTC
[Rd] Bug in the "reformulate" function in stats package
Well, first I can't sign in bugzilla myself, that is why I wrote here first. Also, I don't know if I have the time at the moment to provide tests, multiple examples or more. If that is not ok or welcomed, that is fine, I can come back, whenever I have more time to properly report the bug. I didn't find the existing bug report, sorry for that. Yes, it is related. My problem was that I have column names with spaces and current solution doesn't solve it. I have a solution, which works for me and maybe also for others. Either, someone can register me to bugzilla or I can post it here, which could give some direction to developers. I don't mind whichever is preferred here. Best, Saren On 29.03.19 09:29, Martin Maechler wrote:>>>>>> Saren Tasciyan >>>>>> on Thu, 28 Mar 2019 17:02:10 +0100 writes: > > Hi, > > I have found a bug in reformulate function and have a solution for it. I > > was wondering, where I can submit it? > > > Best, > > Saren > > > Well, you could have given a small reproducible example > depicting the bug, notably when posting here: > Just a prose text with no R code or other technical content is > almost always not really appropriate fo the R-devel mailing list. > > Further, in such a case you should google a bit and hopefully > have found > https://www.r-project.org/bugs.html > > which also mention reproducibility (and many more useful things). > > Then it also tells you about R's bug repository, also called > "R's bugzilla" at https://bugs.r-project.org/ > > and if you are diligent (but here, I'd say bugzilla is > (configured?) far from ideal), you'd also find bug PR#17359 > > https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17359 > > which was reported already on Nov 2017 .. and only fixed > yesterday (in the "cleanup old bugs" process that happens > often before the big new spring release of R). > > So is your bug the same as that one? > > Martin > > > -- > > Saren Tasciyan > > /PhD Student / Sixt Group/ > > Institute of Science and Technology Austria > > Am Campus 1 > > 3400 Klosterneuburg, Austria > > > ______________________________________________ > > R-devel at r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-devel-- Saren Tasciyan /PhD Student / Sixt Group/ Institute of Science and Technology Austria Am Campus 1 3400 Klosterneuburg, Austria
The main thing is to post the "small reproducible example".
My (rather long term experience) can be written
if (exists("reproducible example") ) {
DeveloperFixHappens()
} else {
NULL
}
JN
On 2019-03-29 11:38 a.m., Saren Tasciyan wrote:> Well, first I can't sign in bugzilla myself, that is why I wrote here
first. Also, I don't know if I have the time at
> the moment to provide tests, multiple examples or more. If that is not ok
or welcomed, that is fine, I can come back,
> whenever I have more time to properly report the bug.
>
> I didn't find the existing bug report, sorry for that.
>
> Yes, it is related. My problem was that I have column names with spaces and
current solution doesn't solve it. I have a
> solution, which works for me and maybe also for others.
>
> Either, someone can register me to bugzilla or I can post it here, which
could give some direction to developers. I
> don't mind whichever is preferred here.
>
> Best,
>
> Saren
>
>
> On 29.03.19 09:29, Martin Maechler wrote:
>>>>>>> Saren Tasciyan
>>>>>>> ???? on Thu, 28 Mar 2019 17:02:10 +0100 writes:
>> ???? > Hi,
>> ???? > I have found a bug in reformulate function and have a
solution for it. I
>> ???? > was wondering, where I can submit it?
>>
>> ???? > Best,
>> ???? > Saren
>>
>>
>> Well, you could have given a small reproducible example
>> depicting the bug, notably when posting here:
>> Just a prose text with no R code or other technical content is
>> almost always not really appropriate fo the R-devel mailing list.
>>
>> Further, in such a case you should google a bit and hopefully
>> have found
>> ??????? https://www.r-project.org/bugs.html
>>
>> which also mention reproducibility (and many more useful things).
>>
>> Then it also tells you about R's bug repository, also called
>> "R's bugzilla" at https://bugs.r-project.org/
>>
>> and if you are diligent (but here, I'd say bugzilla is
>> (configured?) far from ideal), you'd also find bug PR#17359
>>
>> ??? https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17359
>>
>> which was reported already on Nov 2017 .. and only fixed
>> yesterday (in the "cleanup old bugs" process that happens
>> often before the big new spring release of R).
>>
>> So is your bug the same as that one?
>>
>> Martin
>>
>> ???? > --
>> ???? > Saren Tasciyan
>> ???? > /PhD Student / Sixt Group/
>> ???? > Institute of Science and Technology Austria
>> ???? > Am Campus 1
>> ???? > 3400 Klosterneuburg, Austria
>>
>> ???? > ______________________________________________
>> ???? > 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
I suspect that the issue is addressed (obliquely) in the examples,
which shows that variables with spaces in them (or otherwise
'non-syntactic', i.e. not satisfying the constraints of legal R symbols)
can be handled by protecting them with backticks (``)
## using non-syntactic names:
reformulate(c("`P/E`", "`% Growth`"), response =
as.name("+-"))
It seems to me there could be room for a *documentation* patch (stating
explicitly that if termlabels has length > 1 its elements are
concatenated with "+", and explicitly stating that non-syntactic names
must be protected with back-ticks). (There is a little bit of obscurity
in the fact that the elements of termlabels don't have to be
syntactically valid names: many will be included in formulas if they can
be interpreted as *parseable* expressions, e.g. reformulate("x<2"))
I would be happy to give it a shot if the consensus is that it would
be worthwhile.
One workaround to the OP's problem is below (may be worth including
as an example in docs)
> z <- c("a variable","another variable")
> reformulate(z)
Error in parse(text = termtext, keep.source = FALSE) :
<text>:1:6: unexpected symbol
1: ~ a variable
^> reformulate(sprintf("`%s`",z))
~`a variable` + `another variable`
On 2019-03-29 11:54 a.m., J C Nash wrote:> The main thing is to post the "small reproducible example".
>
> My (rather long term experience) can be written
>
> if (exists("reproducible example") ) {
> DeveloperFixHappens()
> } else {
> NULL
> }
>
> JN
>
> On 2019-03-29 11:38 a.m., Saren Tasciyan wrote:
>> Well, first I can't sign in bugzilla myself, that is why I wrote
here first. Also, I don't know if I have the time at
>> the moment to provide tests, multiple examples or more. If that is not
ok or welcomed, that is fine, I can come back,
>> whenever I have more time to properly report the bug.
>>
>> I didn't find the existing bug report, sorry for that.
>>
>> Yes, it is related. My problem was that I have column names with spaces
and current solution doesn't solve it. I have a
>> solution, which works for me and maybe also for others.
>>
>> Either, someone can register me to bugzilla or I can post it here,
which could give some direction to developers. I
>> don't mind whichever is preferred here.
>>
>> Best,
>>
>> Saren
>>
>>
>> On 29.03.19 09:29, Martin Maechler wrote:
>>>>>>>> Saren Tasciyan
>>>>>>>> ???? on Thu, 28 Mar 2019 17:02:10 +0100 writes:
>>> ???? > Hi,
>>> ???? > I have found a bug in reformulate function and have a
solution for it. I
>>> ???? > was wondering, where I can submit it?
>>>
>>> ???? > Best,
>>> ???? > Saren
>>>
>>>
>>> Well, you could have given a small reproducible example
>>> depicting the bug, notably when posting here:
>>> Just a prose text with no R code or other technical content is
>>> almost always not really appropriate fo the R-devel mailing list.
>>>
>>> Further, in such a case you should google a bit and hopefully
>>> have found
>>> ??????? https://www.r-project.org/bugs.html
>>>
>>> which also mention reproducibility (and many more useful things).
>>>
>>> Then it also tells you about R's bug repository, also called
>>> "R's bugzilla" at https://bugs.r-project.org/
>>>
>>> and if you are diligent (but here, I'd say bugzilla is
>>> (configured?) far from ideal), you'd also find bug PR#17359
>>>
>>> ??? https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17359
>>>
>>> which was reported already on Nov 2017 .. and only fixed
>>> yesterday (in the "cleanup old bugs" process that happens
>>> often before the big new spring release of R).
>>>
>>> So is your bug the same as that one?
>>>
>>> Martin
>>>
>>> ???? > --
>>> ???? > Saren Tasciyan
>>> ???? > /PhD Student / Sixt Group/
>>> ???? > Institute of Science and Technology Austria
>>> ???? > Am Campus 1
>>> ???? > 3400 Klosterneuburg, Austria
>>>
>>> ???? > ______________________________________________
>>> ???? > 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
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>