Organizing the report
1. Organizing the report
Let's discuss ways to organize information in your report.2. Lists and tables
You can add more information to your report using bulleted lists,3. Lists and tables
numbered lists, or tables.4. Bulleted lists
Items are added to a bulleted list using an asterisk, a hyphen, or a plus sign outside of any code chunks. You can structure the list formatting by adding indentation before an item on the list. Indenting a bullet will make it a sub-bullet. Notice that, in the example shown, each of the individual regions are sub-bullets of the first "Region" bullet. Let's create a list of the regions that are included in the Investment Annual Summary data. We have information on six different regions from the data and can see the bulleted list in the report when we knit the file.5. Numbered lists
Alternatively, we create a numbered list by adding numbers with periods before each item on the list. When we knit the file, we can see the list has been added to the report.6. Adding tables with kable()
We can add tables to the report using the kable() function from the knitr package. The knitr package is what runs each code chunk and knits the document. There are a number of options to customize the table, but it isn't possible to format the data within the table to perform tasks like combining cells. These data wrangling tasks should be done before using kable() to create the table. The indonesia_investment_projects_2012_summary provides the total investment of all projects in Indonesia in the 2012 fiscal year. Instead of printing this information as a tibble, we can call the kable() function and pass it the name of the dataset. When we knit the file, we see a table of the data.7. Modifying table column names
We can modify the column names of the table using the col-dot-names argument within the kable() function. We use the c function and pass it a list of the column names we'd like to appear in the final table.8. Table alignment
We can also modify the column alignment within the table, using the align argument. The default alignment for columns is right for numeric and left for all others. We see this reflected in the existing table, with total investment aligned on the right, and the project name and status aligned on the left. Let's modify this so everything is aligned to the center.9. Modifying table alignment
Alignment is specified using a single letter: l for left, r for right, and c for center. Since we have three columns and we want all columns to be center aligned, we specify align equals ccc in quotations.10. Adding table caption
Finally, we may want to add a caption to the table, which we can do using the caption argument and passing the caption as a string. Here, we include the caption "Table 1-point-1 The total investment summary for each project in Indonesia in the 2012 fiscal year."11. Let's practice!
Let's practice!Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.