add_as_heading() converts obj to character,
formats it as a heading of a section and includes it in the
container. Function print_objects will print the object as text.
add_as_heading(container = NULL, obj, level = 1)
add_as_section(container = NULL, obj, level = 1)
add_as_subsection(container = NULL, obj)
add_as_heading1(container = NULL, obj)
add_as_heading2(container = NULL, obj)
add_as_heading3(container = NULL, obj)
add_as_heading4(container = NULL, obj)
add_as_heading5(container = NULL, obj)
add_as_heading6(container = NULL, obj)knitr_container object.
(string) a piece of text to be used as heading.
(integer) The level of heading (between 1 and 6). 1 is the top level section.
All the remaining functions listed here are wrappers of
add_as_heading with different value of parameter
level passed to add_as_heading:
In add_as_section() default value of level = 1.
In add_as_heading1() default value of level = 1.
In add_as_subsection() default value of level = 2.
In add_as_heading2() default value of level = 2.
In add_as_heading3() default value of level = 3.
In add_as_heading4() default value of level = 4.
In add_as_heading5() default value of level = 5.
In add_as_heading6() default value of level = 6.
Other knitrContainer functions:
Join(),
add_as_,
as.knitrContainer(),
knitrContainer-class,
print_all(),
print(),
summary()
# Find more examples in link `knitrContainer-class`
# Initialize container
container <- knitrContainer()
# Fill the container
container %<>% add_as_heading1(obj = "Heading 1")
container %<>% add_as_heading2(obj = "Heading 2")
container %<>% add_as_heading3(obj = "Heading 3")
container %<>% add_as_heading4(obj = "Heading 4")
container %<>% add_as_heading5(obj = "Heading 5")
container %<>% add_as_heading6(obj = "Heading 6")
container %<>% add_as_heading(obj = "Heading 5", level = 5)
container %<>% add_as_heading(obj = "Heading 6", level = 6)
container %<>% add_as_section(obj = "Heading 1")
container %<>% add_as_subsection(obj = "Heading 2")
# Print the contents of the container
print_all(container)
#> Warning:
#> The option "results" of the current knitr chunk is set to "markup".
#> This may lead to incorrect output.
#> Use option `results = "asis"`
#>
#>
#>
#> # Heading 1
#>
#>
#>
#>
#>
#> ## Heading 2
#>
#>
#>
#>
#>
#> ### Heading 3
#>
#>
#>
#>
#>
#> #### Heading 4
#>
#>
#>
#>
#>
#> ##### Heading 5
#>
#>
#>
#>
#>
#> ###### Heading 6
#>
#>
#>
#>
#>
#> ##### Heading 5
#>
#>
#>
#>
#>
#> ###### Heading 6
#>
#>
#>
#>
#>
#> # Heading 1
#>
#>
#>
#>
#>
#> ## Heading 2
#>
#>
# Operator `%<>%` updates the object `container`
?`%<>%`
# These 2 lines are equivalent:
container <- add_as_section(container, obj = "Heading 1")
container %<>% add_as_section(obj = "Heading 1")