library(getable)
This table is generated from a locally served CSV file1:
write.csv(iris, "data/df.csv")
renderTable("data/df.csv")
This table is generated from a JSON file on GitHub:
renderTable("https://raw.githubusercontent.com/liao961120/getable/master/docs/demo/data/df.json")
Alternatively, you can use getable::from_repo()
to help you construct the url:
renderTable(
from_repo(
username = "liao961120",
repo = "getable",
path = "docs/demo/data/df.json",
branch = "master")
)
Note the JSON format of the source data in df.json
:
[
{
"colname1": "value1-1",
"colname2": "value1-2",
"colname3": "value1-3"
},
{
"colname1": "value2-1",
"colname2": "value2-2",
"colname3": "value2-3"
},
...
]
You can convert data frames to this format simply with jsonlite::toJSON(df, dataframe = "rows")
or save it to a json text file with getable::df2file()
:
df <- data.frame(
id = 1:2,
name = c("john", "smith"),
phone = c("3366-3366", "02-3366-3366")
)
getable::df2json(df, "data/df.json")
getable::renderTable("https://docs.google.com/spreadsheets/d/1KV8XOlBcax3gca5s6Wl7M06nVrpui39hHGXDv-K6gM8/edit?usp=sharing")
In order to use this feature, make sure that the google spreadsheet is viewable for anyone who has the link.
Edit the styles in dfFromWeb.css
to style the table.
You may want to set echo=FALSE
to hide the code chunk.↩︎