Try to make the table that is already included in your document more beautiful.
My tip is to first save the table in a variable. Then you can pass this variable into the table functions:
penguins_sum <- penguins %>%
filter(!(is.na(sex))) %>%
group_by(species, sex) %>%
summarize(
bill_length = mean(bill_length_mm, na.rm = TRUE),
bill_depth = mean(bill_depth_mm, na.rm = TRUE),
flipper_length = mean(flipper_length_mm, na.rm = TRUE),
body_mass = mean(body_mass_g, na.rm = TRUE)
)
penguins_sum
kable
Start with the kable
function. Before you use it, load the knitr
package
in the setup chunk.
You can for example:
booktabs
option (only works in PDF output, is ignored for HTML and Word output)Knit the document to different target output formats and see how the table looks like.
kableExtra
The following now only works for PDF and HTML output. If you want to keep knitting
to word, you later have to switch back to only using kable
.
Don’t forget to load the kableExtra
package in the setup chunk.
Start adding extra styling to the table. For example, you can
kable_styling
, e.g
latex_options
and/or bootstrap_options
Have a look at ?kable_styling
for more options.
If you still have time, have a look at the package documentation of kableExtra
for PDF tables or HTML tables to find many more options and examples.