Description Usage Arguments Details Examples
The as.response
functions simplify serving up R objects as server
responses.
1 2 3 4 5 6 7 8 9 10 11 12 13 | as.response(x, ...)
## S3 method for class 'character'
as.response(x, directory = "views", collapse = "\n",
...)
## S3 method for class 'data.frame'
as.response(x, format = "json", ...)
## S3 method for class 'matrix'
as.response(x, ...)
is.response(x)
|
x |
Any R object. |
directory |
A character string specifying the system folder of the file
|
collapse |
A character string specifying how to collapse the lines read
from |
format |
A character string, determining the form of the HTTP response.
Can be one of |
... |
Additional arguments passed on to methods. |
as.response.character
expects x
is a character string
specifying a file name. The default directory for the file is "views", but a
different path may be specified with the directory
argument. If the
file exists the contents are read and set as the response body. The response
Content-Type is guessed from the file extension using
guess_type
.
as.response.data.frame
coerces and serves up a data frame.
Several response types are possible.
CSV (text/csv) - Same format as write.csv, without row names.
HTML (text/html) - Formatted by simpleHtmlTable.
Additional arguments may be passed to the formatter using ...
.
JSON (application/json) - The
data frame is coerced using the as.json
function and additional
arguments may be passed to as.json
using ...
.
Text (text/plain) - Simple text rendering.
1 2 3 | is.response(logical(1))
is.response(response())
is.response(3030)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.