Type: | Package |
Title: | Fetching Tabular Data "Onload" in Compiled R Markdown HTML Documents |
Version: | 1.0.3 |
Description: | Dynamically retrieve data from the web to render HTML tables on inspection in R Markdown HTML documents. |
URL: | https://yongfu.name/getable/, https://github.com/liao961120/getable/ |
BugReports: | https://github.com/liao961120/getable/issues/ |
Depends: | R (≥ 3.4.0) |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
LazyData: | true |
Suggests: | jsonlite, rmarkdown |
RoxygenNote: | 7.1.1 |
VignetteBuilder: | knitr |
Imports: | knitr |
NeedsCompilation: | no |
Packaged: | 2020-10-02 13:31:40 UTC; liao |
Author: | Yongfu Liao |
Maintainer: | Yongfu Liao <liao961120@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2020-10-02 13:42:06 UTC |
Convert Data Frame to Valid JSON Format for Serving
Description
Convert Data Frame to Valid JSON Format for Serving
Usage
df2json(df, output = "./data/df.json", ...)
Arguments
df |
A data frame. |
output |
A string. The path to the exported data frame. |
... |
Additional arguments arguments passed on to toJSON. |
Build URL to a file from GitHub Repository
Description
This function builds a URL in the form:
https://raw.githubusercontent.com/<username>/<repo>/<branch>/<path>
.
Usage
from_repo(username, repo, path, branch = "master")
Arguments
username |
A string. The owner of the repo. |
repo |
A string. The name of the repo. |
path |
A string. The path to the file. |
branch |
A string. The branch the file is on. |
Value
An URL to the path.
Examples
from_repo(
username = "liao961120",
repo = "getable",
path = "docs/demo/data/df.json",
branch = "master")
renderTable(
from_repo(
username = "liao961120",
repo = "getable",
path = "docs/demo/data/df.json",
branch = "master")
)
Render HTML Table in R Markdown with Data from Web
Description
This function is expected to work with getable
's R Markdown
template, which contains an .html
file, a .js
file,
and a .css
file in addition to the .Rmd
source file.
The function creates an HTML string and insert it into the HTML file
rendered from Rmd. The code in the .js
file then process the
HTML string and retrieve data from web to create an HTML table dynamically
when users view the rendered HTML file in the browser (a server is needed to
served the file).
Usage
renderTable(url = "./data/df.csv", isjson = FALSE)
Arguments
url |
A string. The URL to the source data of the table to be
created. Could be a relative path (relative to the |
isjson |
Boolean. Whether the format of the self-hosted file is
json. Defaults to |
Value
A string representing an HTML div tag.
Examples
renderTable("https://raw.githubusercontent.com/liao961120/getable/master/docs/demo/data/df.csv")