knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
This package imports tabular data that is stored in a variety of text formats.
It uses Pandoc to convert various formats to HTML and then
imports them via rvest::html_table
.
devtools::install_github('noamross/texttable')
Note that testtable requires the latest pandoc, which can be downloaded here. To install via the command line:
Linux:
wget https://github.com/jgm/pandoc/releases/download/1.17.0.2/pandoc-1.17.0.2-1-amd64.deb sudo dpkg -i pandoc-1.17.0.2-1-amd64.deb
OSX (Homebrew):
brew install pandoc
Windows:
????
Enter tabular in the text format of your choice:
library(texttable) sample_table = " | My | Tabular | Data | |----|----------|------| | 1| Sample 1 | 0.3 | | 2| Sample 2 | 1.2 | " imported = texttable(sample_table) imported
Note that texttable()
will trim leading whitespace from character inputs by default.
Get tables out of text files, and even MS Word files:
tables = texttable('tests/testthat/tables.markdown') tables[[1]] word_tables = texttable('tests/testthat/tables.docx') word_tables[[1]]
Pandoc conversion of tables from latex
, haddock
, odt
, formats has known issues and
does not always work. For these formats texttable
will provide a warning,
as the output quality is unknown and will change with your current version of
Pandoc.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.