Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

serve_example

A convenience function to serve examples in this package


Description

Use server functions to serve built-in examples of this package.

Usage

serve_example(name, FUN, ..., run = interactive())

Arguments

name

the directory name of the example under the directory system.file('examples', package = 'servr')

FUN

a server function that takes the example path as its first argument, e.g. httd, or rmdv1

...

other arguments passed to FUN

run

whether to run the example (this is mainly for R CMD check purposes: the examples will not be really served when the R session is not interactive, so they will not block R CMD check)

Value

NULL if run = FALSE, otherwise the value returned from FUN().

Examples

# R Markdown v1 or v2
servr::serve_example("rmd", servr::rmdv1)
servr::serve_example("rmd", servr::rmdv2)

# GNU Make
servr::serve_example("make1", servr::make)
servr::serve_example("make2", servr::make)

servr

A Simple HTTP Server to Serve Static Files or Dynamic Documents

v0.22
GPL
Authors
Yihui Xie [aut, cre] (<https://orcid.org/0000-0003-0645-5666>), Carson Sievert [ctb], Jesse Anderson [ctb], Ramnath Vaidyanathan [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.