add_as_heading: Add text as a heading (section name) to 'knitrContainer'

View source: R/add_as_heading.R

add_as_headingR Documentation

Add text as a heading (section name) to knitrContainer

Description

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.

Usage

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)

Arguments

container

knitr_container object.

obj

(string) a piece of text to be used as heading.

level

(integer) The level of heading (between 1 and 6). 1 is the top level section.

Details

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.

Author(s)

Vilmantas Gegzna

See Also

Other knitrContainer functions: Join(), add_as_, as.knitrContainer(), knitrContainer-class, print_all(), print(), summary()

Examples

# 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)


# 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")



GegznaV/knitrContainer documentation built on April 16, 2023, 1:38 p.m.