Learn R Programming

texPreview (version 1.4.2)

as.kable: Try to coerce an object into a knitr_kable object

Description

coerce objects into a knitr_kable class object with a latex format

Usage

as.kable(x)

Arguments

x

object

Value

an object of class knitr_kable

Examples

Run this code
# NOT RUN {
tex <- '\\begin{tabular}{llr}
\\hline
\\multicolumn{2}{c}{Item} \\\\
\\cline{1-2}
Animal    & Description & Price (\\$) \\\\
\\hline
Gnat      & per gram    & 13.65      \\\\
& each        & 0.01       \\\\
Gnu       & stuffed     & 92.50      \\\\
Emu       & stuffed     & 33.33      \\\\
Armadillo & frozen      & 8.99       \\\\
\\hline
\\end{tabular}'

ktex <- as.kable(tex)

class(ktex)

attributes(ktex)

ktex

# using an input call

x <- tex_preview(tex,returnType = 'input')

x

ktex_input <- as.kable(x)

class(ktex_input)

attributes(ktex_input)

ktex_input

# file path

x <- tex_preview(tex,returnType = 'input')

ktex_path <- as.kable(file.path(tempdir(),'tex_temp.tex'))

class(ktex_path)

attributes(ktex_path)

ktex_path

# }

Run the code above in your browser using DataLab