add_as_: Add object to 'knitrContainer'

add_as_R Documentation

Add object to knitrContainer

Description

Functions to transform and add objects to knitrContainer. Objects, that can be included in R list, can also be included in knitrContainer.

add_as_heading() subfamily functions have separate description page.

Usage

add_as_is(container = NULL, obj)

add_as_plotly_widget(container = NULL, obj)

add_as_pander(container = NULL, obj, ...)

add_as_text(container = NULL, obj)

add_as_strings(container = NULL, obj)

add_as_code(container = NULL, obj, comment = FALSE, highlight = FALSE)

add_as_code_r(container = NULL, obj, comment = FALSE, highlight = "r")

add_as_code_js(container = NULL, obj, comment = FALSE, highlight = "js")

add_as_output(container = NULL, obj, comment = TRUE, highlight = FALSE)

add_as_data(
  container = NULL,
  obj,
  give.name = match.call()$obj %>% c %>% as.character %>% make.names %>%
    substr(1, 60)
)

add_as_cmd(container = NULL, obj)

add_as_cmd_str(container = NULL, obj)

Arguments

container

knitr_container object.

obj

An object to be added to the container.

...

Options to be passed to pander.

comment

Either logical or a string:
If TRUE - default knitr chunk of code comment symbols are used (usually ##).
If FALSE (default) or NA - no comment is used.
If a string, the entered symbols are used as comment symbols.

highlight

Either NULL, FALSE or a string with name of programming language for which rules of code highlighting will be applied. Default is "r".

give.name

A string, that gives a name of a data set passed as obj.
**Default value** is the name passed as input obj. If the imput is is not a name of an object, then sequence of functions is applied to make a valind name from first 60 symbols of the input: match.call()$obj %>% c %>% as.character %>% make.names %>% substr(1,60).

Details

Following functions convert and format an object obj such that it could be appropriatly printed (or evaluated) by applying function print_all().

add_as_is() includes object obj in the container without transformation ("as is"). Function print_all will print it using regular print function. Note that in R Markdaown Rmd file knitr chunk option results='asis' may distort the "beautiful" formatting of the printed object. This function is appropriate to ingludde ggplot2 plots, if they have to be displayed as gg plots and not plotly plots.

add_as_text() converts obj to character, formats as text and includes it in the container. Function print_all will print it as text ('as-is').

add_as_heading() converts obj to character, formats it as a heading of section and includes it in the container. Function print_all will print it as text.

add_as_plotly_widget() converts plotly objects to plotly htmlwidget (details in as_widget) and includes it in the container. Function print_all will print it as plotly htmlwidget and attach html dependencies.

add_as_pander() formats supported types of obj with An R Pandoc Writer's function pander and includes it in the container. Function print_all will print the object as text.

add_as_strings converts input to vectors of chatacter and saves every vector as sepatate strings (i.e. separate paragraphs).

add_as_code() saves object as text and prints it formatted as code (i.e., as formatted text).

add_as_code_r() saves object as text and prints it formatted as R code text.

add_as_code_js() saves object as text and prints it formatted as Java Script code.

add_as_output() saves object as text and prints it formatted as output text.

add_as_data() adds object (data frame, list, vector, etc.) to the container. When function print_all the object is not printed, but just extracted and assigned in the environment env (by default to the parent frame) to the object which name is entered as value of parameter give.name.

add_as_cmd() takes unquoted expression and converts it to a string. The expression is going to be evaluated when function print_all is applied.

add_as_cmd_str() is the same as add_as_cmd(), just object must be entered entered as a string.

Author(s)

Vilmantas Gegzna

See Also

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

Examples

# Find examples in link `knitrContainer-class`


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