rnw2rmd: Convert vognettes from *.Rnw to *.Rmd

Description Usage Arguments References Examples

View source: R/rnw2rmd2.R View source: R/rnw2rmd.R

Description

This is a much enhanced R port of Perl code gists from GitHub [1, 2]. It tries its best to convert old Sweave vignettes into R markdown. Please do not expect it to do wonders, but to give you a good starting point for conversions.

This is a much enhanced R port of Perl code gists from GitHub [1, 2]. It tries its best to convert old Sweave vignettes into R markdown. Please do not expect it to do wonders, but to give you a good starting point for conversions.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
rnw2rmd(
  file,
  output = "rmarkdown::html_vignette",
  output_options = c(toc = "true"),
  engine = "knitr::rmarkdown",
  csl = NULL
)

rnw2rmd(
  file,
  output = "rmarkdown::html_vignette",
  output_options = c(toc = "true"),
  engine = "knitr::rmarkdown",
  csl = NULL
)

Arguments

file

Path to an *.Rnw file to convert.

output

Character string defining the R markdown output format.

output_options

A named character vector with additional options. If you need more than the default indentaion, you have to provide it directly (see default values for toc_float).

engine

Character string defining the VignetteEngine value.

csl

Character string defining a CSL style file for the bibliography. Please note that you will have to provide an existing file of that name in an appropriate location, like the *.Rmd file's directory. Ignored if NULL, or if no bibliography was detected.

eval

Logical, a default value for all R code chunks that are found. This is like a safety net to be able to disable all code by default. Setting the default value will be omitted if set to NULL.

replace

An optional list of named character vectors with regular expressions to do custom replacements in the text body. The list must contain vectors with two character elements named from and to, to define what expressions should be replaced and with what.

flattr_id

Character string, the ID value of your Flattr meta tag. If set will be added to the header of the resulting HTML file of the vignette.

write_file

Logical, if set to TRUE results will be written to a file in the same directory as the input file, but with *.Rmd file ending. Default is FALSE, meaning results are returned as a character string.

overwrite

Logical, whether existing files should be overwritten if write_file=TRUE.

References

[1] https://gist.github.com/mikelove/5618f935ace6e389d3fbac03224860cd

[2] https://gist.github.com/lgatto/d9d0e3afcc0a4417e5084e5ca46a4d9e

[1] https://gist.github.com/mikelove/5618f935ace6e389d3fbac03224860cd

[2] https://gist.github.com/lgatto/d9d0e3afcc0a4417e5084e5ca46a4d9e

Examples

 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
## Not run: 
rnw2rmd(file.path(find.package("roxyPackage"),"doc","roxyPackage_vignette.Rnw"))

# use a fancy theme (not so good for CRAN, bloats the HTML file)
rnw2rmd(
  file.path(find.package("roxyPackage"),"doc","roxyPackage_vignette.Rnw"),
  output="html_document",
  output_options=c(
    theme="cerulean",
    highlight="kate",
    toc="true",
    toc_float="\n      collapsed: false\n      smooth_scroll: false",
    toc_depth=3
  )
)

## End(Not run)
## Not run: 
rnw2rmd(file.path(find.package("roxyPackage"), "doc", "roxyPackage_vignette.Rnw"))

# use a fancy theme (not so good for CRAN, bloats the HTML file)
rnw2rmd(
  file.path(find.package("roxyPackage"), "doc", "roxyPackage_vignette.Rnw"),
  output = "html_document",
  output_options = c(
    theme = "cerulean",
    highlight = "kate",
    toc = "true",
    toc_float = "\\n      collapsed: false\\n      smooth_scroll: false",
    toc_depth = 3
  )
)

## End(Not run)

GegznaV/spMisc documentation built on April 26, 2020, 5:59 p.m.