benjaminrich / table1

79 stars 26 forks source link

Feature request: ability to position the overall column to the left? #88

Closed Beduiz closed 1 year ago

Beduiz commented 2 years ago

Dear Benjamin,

It would be great if there was an option to position the overall column, just like the extra.col can be positioned with extra.col.pos. I tried with overall.pos = 1, but it didnt respond, and I also couldnt find this in the documentation, so I assume it is not a feature as of now?

Kind regards Eric

EpiPenny commented 2 years ago

Thanks for asking this. I am interested in this option too.

g-antonello commented 2 years ago

Same here

EpiPenny commented 1 year ago

Hi Everyone,

I was able to figure out how to do this based on an example posted here:

https://cran.r-project.org/web/packages/table1/vignettes/table1-examples.html

It's the last modification demonstrated in Example 1.

benjaminrich commented 1 year ago

@EpiPenny: you are quite right, this is a perfectly valid solution. But I think that what users would like is an easier way to do this. I've pushed a solution in b27cd6d. Basically, instead of just specifying a label like overall="Overall", if you want it to be on the left you give it the name "left", like this: overall=c(left="Overall").

EpiPenny commented 1 year ago

Hi,

Thanks for responding to this question!!! That definitely seems like a more straightforward solution. However, when I tried it, the overall column still printed on the right. Below is my code. Did I misunderstand how to implement your suggestion, or might the problem be related to using an older version of the package?

#Table 1
table1(~ earlycare_f + mage5yr_fa + mraceeth_f + smoke_f | 
                   preterm_f, 
                 data = birthsfin, 
                 overall=c(left="All Births"),
                 render.categorical = "Freq (PCTnoNA%)", 
                 render.missing = "Freq",
                 big.mark = ",",
                 #This makes caption bold in html but not not word
                 caption = "<b>Table 1. Characteristics of a Cohort of U.S., Singleton, Live Births by Preterm Birth Status Based on the 2006 U.S. Birth Certificate Data\u{1D43}</b>",
                 #This works for viewer, but not for exporting to word (use add_footer_lines for Word)
                 footnote = c("\u{1D43}Only births reported on the 2003 revised U.S. Standard Birth Certificate were eligible",
                           "\u{1D47}Preterm birth includes live births that occurred at gestational ages 21-36 weeks inclusive")
  )

Thanks!!!

benjaminrich commented 1 year ago

Hi @EpiPenny. In order to try this out prior to the CRAN release, you need to install the "development" version using the remotes package:

remotes::install_github("benjaminrich/table1")

Let me know if that works. Thanks.

benjaminrich commented 1 year ago

This has been implemented in CRAN release 1.4.3.

EpiPenny commented 1 year ago

Hi,

I tried it, and it worked perfectly!

Thanks so much for addressing this!