![]() Knitr::kable(caption = "Deaths from unintentional injuries in Scotland") Pivot_wider(names_from = AgeGroup, values_from = total_deaths) %>% # Change the orientation of the table so that age groups become the variable headings Summarise(total_deaths = sum(NumberOfDeaths)) %>% # Create a summary of total number of deaths for neater appearance to the table and demonstration of the figures # Group the table according to injury type, age, and sex # Apply filters in same was as in plots so looking at one year, whole of Scotland, and exlucing "All" entriesįilter(Year = "2018", HBR = "S92000003", AgeGroup != "All" & Sex != "All", InjuryType != "Accidental exposure" & InjuryType != "All")%>% # Create table of number of deaths by injury type, age, and sex ![]() Does anyone have any suggestions? # Read in mortality data ![]() I have tried a couple of things in kableExtra but couldn't get it to work. I have made a table which looks ok - but I would like to create subdivision of rows to divide the results by male and female to make it look neater, as well as format the heading font size and make it a more attractive appearance. I am looking at the PHS open data for unintentional injuries and making a table looking at total Scotland data for 2018. You are welcome to visit my personal blog Scripts and Statistics for more R tutorials.I am in the process of working out how to create a neat table (and have never made a table at all before so just starting out!). I hope you find this post useful and If you have any question please post a comment below. The second macro called FormatFigures merely reduces the size of all figures in the active MS Word document to 45% of its original size.įor Each shp In ActiveDocument.InlineShapes RowHeight:=18, HeightRule:=wdRowHeightExactly Finally, the row height is set to 18 pt exactly. Furthermore, we define font name ( Arial) and font size ( 8 pt), space before ( 6 pt) and after ( 10 pt) the table. A list of other table styles can be found under the following link. With wdTableFormatGrid2, we use a table style predefined in MS Word. The first macro called FormatTables customizes the format of all tables of the active MS Word document. Since I want drafts to be as compact as possible, tables and figures should not to be too space consuming. The following two macros are very helpful to format drafts. There are loads of tutorials explaining how to write a macro for MS Word, e.g Usman Javaid’s Create Macros In Word 2010. ![]() MS Word macros are written in VBA (Visual Basic for Applications) and can be accessed from a menu list or from the tool bar and run by simply clicking. In this blog post, I show how to quickly format tables and figures in the final MS Word document using a macro). Thus, I usually customize tables and figures in the final MS Word document. However, options for customizing tables and figures are rather limited in Rmarkdown. Tables can be formated using either the knitr package’s kable() function or several functions of the pander package.įigure sizes can be determined in the chunk options, e.g. When writing research papers using Rmarkdown (*.Rmd), we have several options to format the output of the final MS Word document (.docx). In research, we usually publish the most important findings in tables and figures.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |