Table from a CSV file

This table is generated from a locally served CSV file1:

write.csv(iris, "data/df.csv")

Table from a JSON file

This table is generated from a JSON file on GitHub:


Alternatively, you can use getable::from_repo() to help you construct the url:

    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")

Table from Google Spreadsheet


In order to use this feature, make sure that the google spreadsheet is viewable for anyone who has the link.

Styling the table

Edit the styles in dfFromWeb.css to style the table.

  1. You may want to set echo=FALSE to hide the code chunk.↩︎