regex - paste r commands inside rmarkdown file -


i want function place piece of markdown in readme.rmd file. include rcode that executed when new version of readme file rendered.

this want in readme.rmd:

[![last-changedate](https://img.shields.io/badge/last%20change-r gsub("-", "--", sys.date())-yellowgreen.svg)](/commits/master)"

which @ knitr time turn nicely formated shield date.

however paste in document have escape of characters:

paste0("`r ", "gsub(\"-\", \"--\", sys.date())", "`")

but results [![last-changedate](https://img.shields.io/badge/last%20change-`r gsub(\"-\", \"--\", sys.date())`-yellowgreen.svg)](/commits/master)" , cannot rendered rmarkdown error: unexpected input: gsub(\ ^....

with suggestion of chinsoon12:
" using single quote works? i.e. use paste0("r ", "gsub('-', '--', sys.date())", "") "

my problem solved! paste double , single quotes.

paste0("https://img.shields.io/badge/last%20change-", "`r ", "gsub('-', '--', sys.date())", "`", "-yellowgreen.svg")


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo