Tables from Rmarkdown to Word Document - using huxtables

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Tables from Rmarkdown to Word Document - using huxtables

Ashim Kapoor
Dear All,

I am reading this :-

https://hughjonesd.github.io/huxtable/huxtable.html

I quote from the above:

If you want to create Word or Powerpoint documents, install the flextable
package <https://cran.r-project.org/package=flextable> from CRAN. Huxtables
can then be automatically printed in Word documents. Or you can convert
them to flextable objects and include them in Word or Powerpoint documents.

My query is how do I do the former ? How do I do this --->  Huxtables can
then be automatically printed in Word documents.

I do understand how to do this ---> Or you can convert them to flextable
objects and include them in Word or Powerpoint documents.

Thank you,
Ashim

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Tables from Rmarkdown to Word Document - using huxtables

Rui Barradas
Hello,

This works for me:


library(dplyr)
library(huxtable)
library(flextable)
library(officer)

hx <- iris %>%
   group_by(Species) %>%
   summarise_if(is.numeric, mean) %>%
   as_hux() %>%
   add_colnames() %>%
   set_bold(1, , TRUE) %>%
   set_bottom_border(1, , 1) %>%
   set_width(0.99) %>%
   set_col_width(1:5, 0.99) %>%
   set_number_format(2)

hx

quick_docx(hx, file = "test.docx")


There are ways of doing the same without pipes, those functions don't
have the prefix 'set_'. But I believe that what's important is function
?quick_docx.

Hope this helps,

Rui Barradas

Às 11:37 de 11/12/19, Ashim Kapoor escreveu:

> Dear All,
>
> I am reading this :-
>
> https://hughjonesd.github.io/huxtable/huxtable.html
>
> I quote from the above:
>
> If you want to create Word or Powerpoint documents, install the flextable
> package <https://cran.r-project.org/package=flextable> from CRAN. Huxtables
> can then be automatically printed in Word documents. Or you can convert
> them to flextable objects and include them in Word or Powerpoint documents.
>
> My query is how do I do the former ? How do I do this --->  Huxtables can
> then be automatically printed in Word documents.
>
> I do understand how to do this ---> Or you can convert them to flextable
> objects and include them in Word or Powerpoint documents.
>
> Thank you,
> Ashim
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Tables from Rmarkdown to Word Document - using huxtables

Ashim Kapoor
On Wed, Dec 11, 2019 at 9:11 PM Rui Barradas <[hidden email]> wrote:

> Hello,
>
> This works for me:
>
>
> library(dplyr)
> library(huxtable)
> library(flextable)
> library(officer)
>
> hx <- iris %>%
>    group_by(Species) %>%
>    summarise_if(is.numeric, mean) %>%
>    as_hux() %>%
>    add_colnames() %>%
>    set_bold(1, , TRUE) %>%
>    set_bottom_border(1, , 1) %>%
>    set_width(0.99) %>%
>    set_col_width(1:5, 0.99) %>%
>    set_number_format(2)
>
> hx
>
> quick_docx(hx, file = "test.docx")
>
>
Does set_width work for you ? For me modifying the argument to set_width is
NOT working.


> There are ways of doing the same without pipes, those functions don't
> have the prefix 'set_'. But I believe that what's important is function
> ?quick_docx.
>
> Hope this helps,
>
> Rui Barradas
>
> Às 11:37 de 11/12/19, Ashim Kapoor escreveu:
> > Dear All,
> >
> > I am reading this :-
> >
> > https://hughjonesd.github.io/huxtable/huxtable.html
> >
> > I quote from the above:
> >
> > If you want to create Word or Powerpoint documents, install the flextable
> > package <https://cran.r-project.org/package=flextable> from CRAN.
> Huxtables
> > can then be automatically printed in Word documents. Or you can convert
> > them to flextable objects and include them in Word or Powerpoint
> documents.
> >
> > My query is how do I do the former ? How do I do this --->  Huxtables can
> > then be automatically printed in Word documents.
> >
> > I do understand how to do this ---> Or you can convert them to flextable
> > objects and include them in Word or Powerpoint documents.
> >
> > Thank you,
> > Ashim
> >
> >       [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Tables from Rmarkdown to Word Document - using huxtables

Ashim Kapoor
Hello once again,

for me,set_caption is not working as well. Here is my Rmd file :-

---
title: Testing Huxtables
author: Ashim Kapoor
output: word_document
---

```{r}
library(dplyr)
library(huxtable)

hx <- iris %>%
   group_by(Species) %>%
   summarise_if(is.numeric, mean) %>%
   as_hux() %>%
   add_colnames() %>%
   set_bold(1, , TRUE) %>%
   set_bottom_border(1, , 1) %>%
   set_width(0.3) %>%
   set_col_width(1:5, 1.5) %>%
   set_number_format(2) %>%
   set_caption("Table 1:")

hx
```

Thank you,
Ashim

On Thu, Dec 12, 2019 at 12:57 PM Ashim Kapoor <[hidden email]> wrote:

>
>
> On Wed, Dec 11, 2019 at 9:11 PM Rui Barradas <[hidden email]> wrote:
>
>> Hello,
>>
>> This works for me:
>>
>>
>> library(dplyr)
>> library(huxtable)
>> library(flextable)
>> library(officer)
>>
>> hx <- iris %>%
>>    group_by(Species) %>%
>>    summarise_if(is.numeric, mean) %>%
>>    as_hux() %>%
>>    add_colnames() %>%
>>    set_bold(1, , TRUE) %>%
>>    set_bottom_border(1, , 1) %>%
>>    set_width(0.99) %>%
>>    set_col_width(1:5, 0.99) %>%
>>    set_number_format(2)
>>
>> hx
>>
>> quick_docx(hx, file = "test.docx")
>>
>>
> Does set_width work for you ? For me modifying the argument to set_width
> is NOT working.
>
>
>> There are ways of doing the same without pipes, those functions don't
>> have the prefix 'set_'. But I believe that what's important is function
>> ?quick_docx.
>>
>> Hope this helps,
>>
>> Rui Barradas
>>
>> Às 11:37 de 11/12/19, Ashim Kapoor escreveu:
>> > Dear All,
>> >
>> > I am reading this :-
>> >
>> > https://hughjonesd.github.io/huxtable/huxtable.html
>> >
>> > I quote from the above:
>> >
>> > If you want to create Word or Powerpoint documents, install the
>> flextable
>> > package <https://cran.r-project.org/package=flextable> from CRAN.
>> Huxtables
>> > can then be automatically printed in Word documents. Or you can convert
>> > them to flextable objects and include them in Word or Powerpoint
>> documents.
>> >
>> > My query is how do I do the former ? How do I do this --->  Huxtables
>> can
>> > then be automatically printed in Word documents.
>> >
>> > I do understand how to do this ---> Or you can convert them to flextable
>> > objects and include them in Word or Powerpoint documents.
>> >
>> > Thank you,
>> > Ashim
>> >
>> >       [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>> >
>>
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Tables from Rmarkdown to Word Document - using huxtables

Rui Barradas
Hello,

You're right, none of the two seems to be working.

set_width gives me tables of the same width no matter what value I pass
as argument.

And set_caption is asking for a flextable object, doesn't work with
huxtable.

I don't know how to solve it right now, I will try later.

Rui Barradas

Às 10:51 de 12/12/19, Ashim Kapoor escreveu:

> Hello once again,
>
> for me,set_caption is not working as well. Here is my Rmd file :-
>
> ---
> title: Testing Huxtables
> author: Ashim Kapoor
> output: word_document
> ---
>
> ```{r}
> library(dplyr)
> library(huxtable)
>
> hx <- iris %>%
>     group_by(Species) %>%
>     summarise_if(is.numeric, mean) %>%
>     as_hux() %>%
>     add_colnames() %>%
>     set_bold(1, , TRUE) %>%
>     set_bottom_border(1, , 1) %>%
>     set_width(0.3) %>%
>     set_col_width(1:5, 1.5) %>%
>     set_number_format(2) %>%
>     set_caption("Table 1:")
>
> hx
> ```
>
> Thank you,
> Ashim
>
> On Thu, Dec 12, 2019 at 12:57 PM Ashim Kapoor <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>
>
>     On Wed, Dec 11, 2019 at 9:11 PM Rui Barradas <[hidden email]
>     <mailto:[hidden email]>> wrote:
>
>         Hello,
>
>         This works for me:
>
>
>         library(dplyr)
>         library(huxtable)
>         library(flextable)
>         library(officer)
>
>         hx <- iris %>%
>             group_by(Species) %>%
>             summarise_if(is.numeric, mean) %>%
>             as_hux() %>%
>             add_colnames() %>%
>             set_bold(1, , TRUE) %>%
>             set_bottom_border(1, , 1) %>%
>             set_width(0.99) %>%
>             set_col_width(1:5, 0.99) %>%
>             set_number_format(2)
>
>         hx
>
>         quick_docx(hx, file = "test.docx")
>
>     Does set_width work for you ? For me modifying the argument to
>     set_width is NOT working.
>
>         There are ways of doing the same without pipes, those functions
>         don't
>         have the prefix 'set_'. But I believe that what's important is
>         function
>         ?quick_docx.
>
>         Hope this helps,
>
>         Rui Barradas
>
>         Às 11:37 de 11/12/19, Ashim Kapoor escreveu:
>          > Dear All,
>          >
>          > I am reading this :-
>          >
>          > https://hughjonesd.github.io/huxtable/huxtable.html
>          >
>          > I quote from the above:
>          >
>          > If you want to create Word or Powerpoint documents, install
>         the flextable
>          > package <https://cran.r-project.org/package=flextable> from
>         CRAN. Huxtables
>          > can then be automatically printed in Word documents. Or you
>         can convert
>          > them to flextable objects and include them in Word or
>         Powerpoint documents.
>          >
>          > My query is how do I do the former ? How do I do this --->
>         Huxtables can
>          > then be automatically printed in Word documents.
>          >
>          > I do understand how to do this ---> Or you can convert them
>         to flextable
>          > objects and include them in Word or Powerpoint documents.
>          >
>          > Thank you,
>          > Ashim
>          >
>          >       [[alternative HTML version deleted]]
>          >
>          > ______________________________________________
>          > [hidden email] <mailto:[hidden email]> mailing
>         list -- To UNSUBSCRIBE and more, see
>          > https://stat.ethz.ch/mailman/listinfo/r-help
>          > PLEASE do read the posting guide
>         http://www.R-project.org/posting-guide.html
>          > and provide commented, minimal, self-contained, reproducible
>         code.
>          >
>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Tables from Rmarkdown to Word Document - using huxtables

Ashim Kapoor
Dear Rui,

No problem and Many thanks.

Best Regards,
Ashim

On Fri, Dec 13, 2019 at 12:09 AM Rui Barradas <[hidden email]> wrote:

> Hello,
>
> You're right, none of the two seems to be working.
>
> set_width gives me tables of the same width no matter what value I pass
> as argument.
>
> And set_caption is asking for a flextable object, doesn't work with
> huxtable.
>
> I don't know how to solve it right now, I will try later.
>
> Rui Barradas
>
> Às 10:51 de 12/12/19, Ashim Kapoor escreveu:
> > Hello once again,
> >
> > for me,set_caption is not working as well. Here is my Rmd file :-
> >
> > ---
> > title: Testing Huxtables
> > author: Ashim Kapoor
> > output: word_document
> > ---
> >
> > ```{r}
> > library(dplyr)
> > library(huxtable)
> >
> > hx <- iris %>%
> >     group_by(Species) %>%
> >     summarise_if(is.numeric, mean) %>%
> >     as_hux() %>%
> >     add_colnames() %>%
> >     set_bold(1, , TRUE) %>%
> >     set_bottom_border(1, , 1) %>%
> >     set_width(0.3) %>%
> >     set_col_width(1:5, 1.5) %>%
> >     set_number_format(2) %>%
> >     set_caption("Table 1:")
> >
> > hx
> > ```
> >
> > Thank you,
> > Ashim
> >
> > On Thu, Dec 12, 2019 at 12:57 PM Ashim Kapoor <[hidden email]
> > <mailto:[hidden email]>> wrote:
> >
> >
> >
> >     On Wed, Dec 11, 2019 at 9:11 PM Rui Barradas <[hidden email]
> >     <mailto:[hidden email]>> wrote:
> >
> >         Hello,
> >
> >         This works for me:
> >
> >
> >         library(dplyr)
> >         library(huxtable)
> >         library(flextable)
> >         library(officer)
> >
> >         hx <- iris %>%
> >             group_by(Species) %>%
> >             summarise_if(is.numeric, mean) %>%
> >             as_hux() %>%
> >             add_colnames() %>%
> >             set_bold(1, , TRUE) %>%
> >             set_bottom_border(1, , 1) %>%
> >             set_width(0.99) %>%
> >             set_col_width(1:5, 0.99) %>%
> >             set_number_format(2)
> >
> >         hx
> >
> >         quick_docx(hx, file = "test.docx")
> >
> >     Does set_width work for you ? For me modifying the argument to
> >     set_width is NOT working.
> >
> >         There are ways of doing the same without pipes, those functions
> >         don't
> >         have the prefix 'set_'. But I believe that what's important is
> >         function
> >         ?quick_docx.
> >
> >         Hope this helps,
> >
> >         Rui Barradas
> >
> >         Às 11:37 de 11/12/19, Ashim Kapoor escreveu:
> >          > Dear All,
> >          >
> >          > I am reading this :-
> >          >
> >          > https://hughjonesd.github.io/huxtable/huxtable.html
> >          >
> >          > I quote from the above:
> >          >
> >          > If you want to create Word or Powerpoint documents, install
> >         the flextable
> >          > package <https://cran.r-project.org/package=flextable> from
> >         CRAN. Huxtables
> >          > can then be automatically printed in Word documents. Or you
> >         can convert
> >          > them to flextable objects and include them in Word or
> >         Powerpoint documents.
> >          >
> >          > My query is how do I do the former ? How do I do this --->
> >         Huxtables can
> >          > then be automatically printed in Word documents.
> >          >
> >          > I do understand how to do this ---> Or you can convert them
> >         to flextable
> >          > objects and include them in Word or Powerpoint documents.
> >          >
> >          > Thank you,
> >          > Ashim
> >          >
> >          >       [[alternative HTML version deleted]]
> >          >
> >          > ______________________________________________
> >          > [hidden email] <mailto:[hidden email]> mailing
> >         list -- To UNSUBSCRIBE and more, see
> >          > https://stat.ethz.ch/mailman/listinfo/r-help
> >          > PLEASE do read the posting guide
> >         http://www.R-project.org/posting-guide.html
> >          > and provide commented, minimal, self-contained, reproducible
> >         code.
> >          >
> >
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.