Description Usage Arguments Details Value References See Also Examples
write.rtf
converts LaTeX files (with extension .tex) generated by R Sweave using package 'knitr' to Rich Text Format (RTF) files.
Features include: 1) conversion of R syntax highlighting; 2) conversion of tables generated by Hmisc::describe
, Hmisc::summary
, and
Hmisc::latex
; 3) conversion of mathematical equations; 4) conversion of graphics; 5) conversion of itemize and enumerate; 6) conversion of references.
1 |
tex |
is the tex value returned by |
path |
is the path value returned by |
name |
is the name of the output Rich Text Format file. |
outputlocation |
is the location where the Rich Text Format file is to be saved. The default location is the same as path. |
For files with graphics, dev must be set to 'png' in 'knitr' chunk options for write.rtf
to run properly.
write.rtf
returns a file in Rich Text Format (rtf).
Yihui Xie (2015). knitr: A General-Purpose Package for Dynamic Report Generation in R. R package version 1.10.5.
Frank E Harrell Jr, with contributions from Charles Dupont and many others. (2014). Hmisc: Harrell Miscellaneous. R package version 3.14-4. http://CRAN.R-project.org/package=Hmisc
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | ##Example 1
#Read a sample LaTeX file
file<-'connect3-minimal.tex'
filepath<-paste(sub("examples/.*","\\1",
system.file("examples","connect3-minimal.tex",package="connect3")),
"examples", sep='')
obj<-read.latex(file, filepath)
obj
#Convert a LaTeX file to a Rich Text Format file
tex<-obj$tex
path<-obj$path
name<-'connect3-minimal'
outputlocation<-gsub('\\\\','/',tempdir())
write.rtf(tex,path,name,outputlocation)
##Example 2
## Step 1: Download an R Sweave file using 'knitr' from:
## 'https://github.com/yihui/knitr/blob/master/inst/examples/knitr-minimal.Rnw'
## Step 2: Save it as 'knitr-minimal.Rnw' in a folder such: 'C:/Users/Desktop/tmp'.
## Change r code chunck options
## "<<boring-plots, fig.width=4, fig.height=4, out.width='.4\\linewidth'>>="
## to
## "<<boring-plots, fig.width=3, fig.height=3, out.width='.4\\linewidth', dev='png'>>=".
## Step 3: Click Compile PDF in RStudio
## Step 4: Read 'knitr-minimal.tex' file in the folder using function read.latex
# file<-'knitr-minimal.tex'
# filepath<-'C:/Users/Desktop/tmp'
# obj<-read.latex(file, filepath)
# obj
## Step 5: Converts 'knitr-minimal.tex' file to 'knitr-minimal.rtf' file using function write.rtf
# tex<-obj$tex
# path<-obj$path
# name<-'knitr-minimal'
# write.rtf(tex,path,name,outputlocation)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.