Title: | Fetching Tabular Data "Onload" in Compiled R Markdown HTML Documents |
---|---|
Description: | Dynamically retrieve data from the web to render HTML tables on inspection in R Markdown HTML documents. |
Authors: | Yongfu Liao [aut, cre] |
Maintainer: | Yongfu Liao <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.3 |
Built: | 2024-11-05 05:43:09 UTC |
Source: | https://github.com/liao961120/getable |
Convert Data Frame to Valid JSON Format for Serving
df2json(df, output = "./data/df.json", ...)
df2json(df, output = "./data/df.json", ...)
df |
A data frame. |
output |
A string. The path to the exported data frame. |
... |
Additional arguments arguments passed on to toJSON. |
This function builds a URL in the form:
https://raw.githubusercontent.com/<username>/<repo>/<branch>/<path>
.
from_repo(username, repo, path, branch = "master")
from_repo(username, repo, path, branch = "master")
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. |
An URL to the path.
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") )
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") )
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).
renderTable(url = "./data/df.csv", isjson = FALSE)
renderTable(url = "./data/df.csv", isjson = FALSE)
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 |
A string representing an HTML div tag.
renderTable("https://raw.githubusercontent.com/liao961120/getable/master/docs/demo/data/df.csv")
renderTable("https://raw.githubusercontent.com/liao961120/getable/master/docs/demo/data/df.csv")