Re: [Rd] justify hard coded in format.ftable

2020-05-15 Thread SOEIRO Thomas
Thanks for the links. I agree that such a feature would be a nice addition, and 
could make ftable even more useful.

In the same spirit, I think it could be useful to mention the undocumented 
base::as.data.frame.matrix function in documentation of table and xtabs (in 
addition to the already mentioned base::as.data.frame.table). The conversion 
from ftable/table/xtabs to data.frame is a common task that some users seem to 
struggle with 
(https://stackoverflow.com/questions/10758961/how-to-convert-a-table-to-a-data-frame).

tab <- table(warpbreaks$wool, warpbreaks$tension)
as.data.frame(tab) # reshaped table
as.data.frame.matrix(tab) # non-reshaped table

To sum up, for the sake of clarity, these proposals address two different 
topics:
- The justify argument would reduce the need to reformat the exported ftable
- An ftable2df-like function (and the mention of as.data.frame.matrix in the 
documentation) would facilitate the reuse of ftable results for further 
analysis.

Thank you very much,

Thomas

> If you are looking at ftable could you also consider adding a way to convert 
> an ftable into a usable data.frame such as the ftable2df function defined 
> here:
> 
> https://stackoverflow.com/questions/11141406/reshaping-an-array-to-data-frame/11143126#11143126
> 
> and there is an example of using it here:
> 
> https://stackoverflow.com/questions/61333663/manipulating-an-array-into-a-data-frame-in-base-r/61334756#61334756
> 
> Being able to move back and forth between various base class representations 
> seems like something that would be natural to provide.
> 
> Thanks.
> 
> On Thu, May 14, 2020 at 5:32 AM Martin Maechler  
> wrote:
>>
>>> SOEIRO Thomas
>>> on Wed, 13 May 2020 20:27:15 + writes:
>>
>>> Dear all,
>>> I haven't received any feedback so far on my proposal to make 
>> "justify" argument available in stats:::format.ftable
>>
>>> Is this list the appropriate place for this kind of proposal?
>>
>> Yes, it is.. Actually such a post is even a "role model" post for 
>> R-devel.
>>
>>> I hope this follow-up to my message won't be taken as rude. Of course it's 
>>> not meant to be, but I'm not used to the R mailing lists...
>>
>> well, there could be said much, and many stories told here ... ;-)
>>
>>> Thank you in advance for your comments,
>>
>>> Best,
>>> Thomas
>>
>> The main reasons for "no reaction" (for such nice post) probably are 
>> combination of the following
>>
>> - we are busy
>> - if we have time, we think other things are more exciting
>> - we have not used ftable much/at all and are not interested.
>>
>> Even though the first 2 apply to me, I'll have a 2nd look into your 
>> post now, and may end up well agreeing with your proposal.
>>
>> Martin Maechler
>> ETH Zurich  and  R Core team
>>
>>
>>
>>
 Dear all,

 justify argument is hard coded in format.ftable:

 cbind(apply(LABS, 2L, format, justify = "left"),
 apply(DATA, 2L, format, justify = "right"))

 It would be useful to have the possibility to modify the argument between 
 c("left", "right", "centre", "none") as in format.default.

 The lines could be changed to:

 if(length(justify) != 2)
 stop("justify must be length 2")
 cbind(apply(LABS, 2L, format, justify = justify[1]),
 apply(DATA, 2L, format, justify = justify[2]))

 The argument justify could defaults to c("left", "right") for backward 
 compatibility.

 It could then allow:
 ftab <- ftable(wool + tension ~ breaks, warpbreaks)
 format.ftable(ftab, justify = c("none", "none"))

 Best regards,

 Thomas
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] justify hard coded in format.ftable

2020-05-15 Thread Gabor Grothendieck


If you are looking at ftable could you also consider adding
a way to convert an ftable into a usable data.frame such as
the ftable2df function defined here:

https://stackoverflow.com/questions/11141406/reshaping-an-array-to-data-frame/11143126#11143126

and there is an example of using it here:

https://stackoverflow.com/questions/61333663/manipulating-an-array-into-a-data-frame-in-base-r/61334756#61334756

Being able to move back and forth between various base class representations
seems like something that would be natural to provide.

Thanks.

On Thu, May 14, 2020 at 5:32 AM Martin Maechler
 wrote:
>
> > SOEIRO Thomas
> > on Wed, 13 May 2020 20:27:15 + writes:
>
> > Dear all,
> > I haven't received any feedback so far on my proposal to make "justify" 
> argument available in stats:::format.ftable
>
> > Is this list the appropriate place for this kind of proposal?
>
> Yes, it is.. Actually such a post is even a "role model" post
> for R-devel.
>
> > I hope this follow-up to my message won't be taken as rude. Of course 
> it's not meant to be, but I'm not used to the R mailing lists...
>
> well, there could be said much, and many stories told here ... ;-)
>
> > Thank you in advance for your comments,
>
> > Best,
> > Thomas
>
> The main reasons for "no reaction" (for such nice post) probably
> are combination of the following
>
> - we are busy
> - if we have time, we think other things are more exciting
> - we have not used ftable much/at all and are not interested.
>
> Even though the first 2 apply to me, I'll have a 2nd look into
> your post now, and may end up well agreeing with your proposal.
>
> Martin Maechler
> ETH Zurich  and  R Core team
>
>
>
>
> >> Dear all,
> >>
> >> justify argument is hard coded in format.ftable:
> >>
> >> cbind(apply(LABS, 2L, format, justify = "left"),
> >> apply(DATA, 2L, format, justify = "right"))
> >>
> >> It would be useful to have the possibility to modify the argument 
> between c("left", "right", "centre", "none") as in format.default.
> >>
> >> The lines could be changed to:
> >>
> >> if(length(justify) != 2)
> >> stop("justify must be length 2")
> >> cbind(apply(LABS, 2L, format, justify = justify[1]),
> >> apply(DATA, 2L, format, justify = justify[2]))
> >>
> >> The argument justify could defaults to c("left", "right") for backward 
> compatibility.
> >>
> >> It could then allow:
> >> ftab <- ftable(wool + tension ~ breaks, warpbreaks)
> >> format.ftable(ftab, justify = c("none", "none"))
> >>
> >> Best regards,
> >>
> >> Thomas
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] justify hard coded in format.ftable

2020-05-15 Thread Gabor Grothendieck


One can use as.data.frame(as.matrix(tab)) to avoid calling
as.data.frame.matrix directly
(although I find I do use as.data.frame.matrix anyways sometimes even
though it is generally
better to call the generic.).

Also note that the various as.data.frame methods do not address the examples
in the SO links I posted which is why I mentioned it.

On Thu, May 14, 2020 at 9:22 AM SOEIRO Thomas  wrote:
>
> Thanks for the links. I agree that such a feature would be a nice addition, 
> and could make ftable even more useful.
>
> In the same spirit, I think it could be useful to mention the undocumented 
> base::as.data.frame.matrix function in documentation of table and xtabs (in 
> addition to the already mentioned base::as.data.frame.table). The conversion 
> from ftable/table/xtabs to data.frame is a common task that some users seem 
> to struggle with 
> (https://stackoverflow.com/questions/10758961/how-to-convert-a-table-to-a-data-frame).
>
> tab <- table(warpbreaks$wool, warpbreaks$tension)
> as.data.frame(tab) # reshaped table
> as.data.frame.matrix(tab) # non-reshaped table
>
> To sum up, for the sake of clarity, these proposals address two different 
> topics:
> - The justify argument would reduce the need to reformat the exported ftable
> - An ftable2df-like function (and the mention of as.data.frame.matrix in the 
> documentation) would facilitate the reuse of ftable results for further 
> analysis.
>
> Thank you very much,
>
> Thomas
>
> > If you are looking at ftable could you also consider adding a way to 
> > convert an ftable into a usable data.frame such as the ftable2df function 
> > defined here:
> >
> > https://stackoverflow.com/questions/11141406/reshaping-an-array-to-data-frame/11143126#11143126
> >
> > and there is an example of using it here:
> >
> > https://stackoverflow.com/questions/61333663/manipulating-an-array-into-a-data-frame-in-base-r/61334756#61334756
> >
> > Being able to move back and forth between various base class 
> > representations seems like something that would be natural to provide.
> >
> > Thanks.
> >
> > On Thu, May 14, 2020 at 5:32 AM Martin Maechler 
> >  wrote:
> >>
> >>> SOEIRO Thomas
> >>> on Wed, 13 May 2020 20:27:15 + writes:
> >>
> >>> Dear all,
> >>> I haven't received any feedback so far on my proposal to make
> >> "justify" argument available in stats:::format.ftable
> >>
> >>> Is this list the appropriate place for this kind of proposal?
> >>
> >> Yes, it is.. Actually such a post is even a "role model" post for
> >> R-devel.
> >>
> >>> I hope this follow-up to my message won't be taken as rude. Of course 
> >>> it's not meant to be, but I'm not used to the R mailing lists...
> >>
> >> well, there could be said much, and many stories told here ... ;-)
> >>
> >>> Thank you in advance for your comments,
> >>
> >>> Best,
> >>> Thomas
> >>
> >> The main reasons for "no reaction" (for such nice post) probably are
> >> combination of the following
> >>
> >> - we are busy
> >> - if we have time, we think other things are more exciting
> >> - we have not used ftable much/at all and are not interested.
> >>
> >> Even though the first 2 apply to me, I'll have a 2nd look into your
> >> post now, and may end up well agreeing with your proposal.
> >>
> >> Martin Maechler
> >> ETH Zurich  and  R Core team
> >>
> >>
> >>
> >>
>  Dear all,
> 
>  justify argument is hard coded in format.ftable:
> 
>  cbind(apply(LABS, 2L, format, justify = "left"),
>  apply(DATA, 2L, format, justify = "right"))
> 
>  It would be useful to have the possibility to modify the argument 
>  between c("left", "right", "centre", "none") as in format.default.
> 
>  The lines could be changed to:
> 
>  if(length(justify) != 2)
>  stop("justify must be length 2")
>  cbind(apply(LABS, 2L, format, justify = justify[1]),
>  apply(DATA, 2L, format, justify = justify[2]))
> 
>  The argument justify could defaults to c("left", "right") for backward 
>  compatibility.
> 
>  It could then allow:
>  ftab <- ftable(wool + tension ~ breaks, warpbreaks)
>  format.ftable(ftab, justify = c("none", "none"))
> 
>  Best regards,
> 
>  Thomas



-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] justify hard coded in format.ftable

2020-05-14 Thread SOEIRO Thomas
I suspected it was partly due to the fact that ftable doesn't get much 
interest/isn't much used...

So thank you very much for answering, and for your time!

>> Dear all,
>> I haven't received any feedback so far on my proposal to make "justify" 
>> argument available in stats:::format.ftable
>>
>> Is this list the appropriate place for this kind of proposal?
> 
> Yes, it is.. Actually such a post is even a "role model" post for R-devel.
> 
>> I hope this follow-up to my message won't be taken as rude. Of course it's 
>> not meant to be, but I'm not used to the R mailing lists...
> 
> well, there could be said much, and many stories told here ... ;-)
> 
>> Thank you in advance for your comments,
>> 
>> Best,
>> Thomas
> 
> The main reasons for "no reaction" (for such nice post) probably are 
> combination of the following
> 
> - we are busy
> - if we have time, we think other things are more exciting
> - we have not used ftable much/at all and are not interested.
> 
> Even though the first 2 apply to me, I'll have a 2nd look into your post now, 
> and may end up well agreeing with your proposal.
> 
> Martin Maechler
> ETH Zurich  and  R Core team
> 
>>> Dear all,
>>>
>>> justify argument is hard coded in format.ftable:
>>>
>>> cbind(apply(LABS, 2L, format, justify = "left"),
>>> apply(DATA, 2L, format, justify = "right"))
>>>
>>> It would be useful to have the possibility to modify the argument between 
>>> c("left", "right", "centre", "none") as in format.default.
>>>
>>> The lines could be changed to:
>>>
>>> if(length(justify) != 2)
>>> stop("justify must be length 2")
>>> cbind(apply(LABS, 2L, format, justify = justify[1]),
>>> apply(DATA, 2L, format, justify = justify[2]))
>>>
>>> The argument justify could defaults to c("left", "right") for backward 
>>> compatibility.
>>>
>>> It could then allow:
>>> ftab <- ftable(wool + tension ~ breaks, warpbreaks)
>>> format.ftable(ftab, justify = c("none", "none"))
>>>
>>> Best regards,
>>>
>>> Thomas
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] justify hard coded in format.ftable

2020-05-14 Thread Martin Maechler
> SOEIRO Thomas 
> on Wed, 13 May 2020 20:27:15 + writes:

> Dear all,
> I haven't received any feedback so far on my proposal to make "justify" 
argument available in stats:::format.ftable

> Is this list the appropriate place for this kind of proposal?

Yes, it is.. Actually such a post is even a "role model" post
for R-devel.

> I hope this follow-up to my message won't be taken as rude. Of course 
it's not meant to be, but I'm not used to the R mailing lists...

well, there could be said much, and many stories told here ... ;-)

> Thank you in advance for your comments,

> Best,
> Thomas

The main reasons for "no reaction" (for such nice post) probably
are combination of the following

- we are busy
- if we have time, we think other things are more exciting
- we have not used ftable much/at all and are not interested.

Even though the first 2 apply to me, I'll have a 2nd look into
your post now, and may end up well agreeing with your proposal.

Martin Maechler
ETH Zurich  and  R Core team




>> Dear all,
>> 
>> justify argument is hard coded in format.ftable:
>> 
>> cbind(apply(LABS, 2L, format, justify = "left"),
>> apply(DATA, 2L, format, justify = "right"))
>> 
>> It would be useful to have the possibility to modify the argument 
between c("left", "right", "centre", "none") as in format.default.
>> 
>> The lines could be changed to:
>> 
>> if(length(justify) != 2)
>> stop("justify must be length 2")
>> cbind(apply(LABS, 2L, format, justify = justify[1]),
>> apply(DATA, 2L, format, justify = justify[2]))
>> 
>> The argument justify could defaults to c("left", "right") for backward 
compatibility.
>> 
>> It could then allow:
>> ftab <- ftable(wool + tension ~ breaks, warpbreaks)
>> format.ftable(ftab, justify = c("none", "none"))
>> 
>> Best regards,
>> 
>> Thomas

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] justify hard coded in format.ftable

2020-05-13 Thread SOEIRO Thomas
Dear all,

I haven't received any feedback so far on my proposal to make "justify" 
argument available in stats:::format.ftable

Is this list the appropriate place for this kind of proposal?

I hope this follow-up to my message won't be taken as rude. Of course it's not 
meant to be, but I'm not used to the R mailing lists...

Thank you in advance for your comments,

Best,

Thomas

> Dear all,
>
> justify argument is hard coded in format.ftable:
>
> cbind(apply(LABS, 2L, format, justify = "left"),
>   apply(DATA, 2L, format, justify = "right"))
>
> It would be useful to have the possibility to modify the argument between 
> c("left", "right", "centre", "none") as in format.default.
>
> The lines could be changed to:
>
> if(length(justify) != 2)
>   stop("justify must be length 2")
> cbind(apply(LABS, 2L, format, justify = justify[1]),
>   apply(DATA, 2L, format, justify = justify[2]))
>
> The argument justify could defaults to c("left", "right") for backward 
> compatibility.
>
> It could then allow:
> ftab <- ftable(wool + tension ~ breaks, warpbreaks)
> format.ftable(ftab, justify = c("none", "none"))
>
> Best regards,
>
> Thomas

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] justify hard coded in format.ftable

2020-05-10 Thread SOEIRO Thomas
Dear all,

justify argument is hard coded in format.ftable:

cbind(apply(LABS, 2L, format, justify = "left"),
  apply(DATA, 2L, format, justify = "right"))

It would be useful to have the possibility to modify the argument between 
c("left", "right", "centre", "none") as in format.default.

The lines could be changed to:

if(length(justify) != 2)
  stop("justify must be length 2")
cbind(apply(LABS, 2L, format, justify = justify[1]),
  apply(DATA, 2L, format, justify = justify[2]))

The argument justify could defaults to c("left", "right") for backward 
compatibility.

It could then allow:
ftab <- ftable(wool + tension ~ breaks, warpbreaks)
format.ftable(ftab, justify = c("none", "none"))

Best regards,

Thomas

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel