Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dilernia tables patch #54

Merged
merged 6 commits into from
Aug 26, 2024
Merged

Conversation

dilernia
Copy link
Contributor

Patched the functions producing flextable objects to fix column width issue when knitting to Word. Did so by adding autofit() and fit_to_width() calls at the end of the functions that return flextable objects. This adds redundancy to the code, but minimized / prevented changes to the other functions in the package.

@ian-curtis
Copy link
Owner

Hey! Thank you for this!

Do you know if this is a widespread issue across all tables or just those in the files you edited here? I ask because I wonder if your edits would be better placed in R/utils.R in the finalize_tbl() function. The function currently runs

...
flextable::autofit() %>%
flextable::fit_to_width(6) %>%
flextable::set_caption(...)

at the very end but I wonder if it's not working due to the caption being the last step rather than before the auto fitting, if that makes sense.

Based on your testing, would it make more sense to convert your edits here into

...
flextable::set_caption(...) %>%
flextable::autofit() %>%
flextable::fit_to_width(6) # or 7.5

and put it in the finalize_tbl() function?

@dilernia
Copy link
Contributor Author

dilernia commented Aug 23, 2024 via email

@ian-curtis
Copy link
Owner

After some testing, I believe the issue some from set_header_labels() coming after the original fitting functions in finalize_tbl(). I'm going to try to merge your pull request and use it as a starting point to consolidate some code. I'm thinking a new utility function called fit_tbl() that can easily be run at any time by anyone and can also be called at the end of every one of the functions you edited here.

@ian-curtis ian-curtis merged commit a0ac419 into ian-curtis:main Aug 26, 2024
1 check passed
@dilernia
Copy link
Contributor Author

dilernia commented Aug 28, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants