showObj | R Documentation |
Display an object in knitr code chunk and set the caption with cross reference.
showObj(oDf,objID=NULL,isDocx=FALSE,...)
oDf |
(data.frame or matrix) Refers to |
isDocx |
(boolean, FALSE) is the Rmd output word_document2? |
objID |
(character, NULL) The objID of the object in |
... |
parameters passed to |
An object identified by objID
, can be a ggplot2 or a table (flextable if isDocx T
; kable otherwise)
rmdTable
OUTPUTS
library(wfr)
library(ggplot2)
isDocx=TRUE
df1=data.frame(A=c("a","a","b3"),
B=c("b1","b2","b3"),
C1=1:3,C2=2:4)
colWidth = "2,1,1,1"
header = "A | A | C | C || A | A | C1 | C2"
footer = "A|Arkansas$~ref$|1|header
|| C1|Kansas$^ref$|x|header
|| a|Arizona|2|body"
tmpDir = tempdir()
ofn = file.path(tmpDir, "t1.csv")
saveOutput(df1,ofn,caption = "1st testing table",header = header,
footer = footer, colWidth = colWidth,fontSize = 12 )
saveOutput(qplot(1:10,1:10),oPath=tmpDir, caption = "1st testing fig")
ofn = file.path(tmpDir, "all.outputs.csv")
write.csv(OUTPUTS,ofn)
oDf=read.csv(ofn,stringsAsFactors = FALSE)
showObj(oDf,isDocx,objID = "tab1",rowHeaderInd=2)
showObj(oDf,objID = "fig2")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.