read.md
and read_md
are functions to read a markdown table into a
data.frame or tibble, respectively.
read.md( file = clipr::read_clip(), delim = "|", stringsAsFactors = FALSE, strip.white = TRUE, ... ) read_md(file = clipr::read_clip(), delim = "|", trim_ws = TRUE, ...)
file | A path to a file, a connection, or literal data (either a single string or a vector of lines). If unspecified, reads from the clipboard. |
---|---|
delim | A string to use as a column delimiter. For most markdown tables, this is the pipe: "|". |
stringsAsFactors | A logical value indicating whether to convert string
columns to factors. Passed along to |
strip.white, trim_ws | Trim leading and trailing whitespace from each column before parsing. |
... | Passed along to |
For read.md
, a data.frame; for read_md
, a tibble.
The file
parameter will accept a filepath or connection, but given that
these functions are built for interactive use, they are built to accept a
single string containing the data (distinguished from a filepath by the
presence of a newline) or a vector of lines, as may be generated by
clipr::read_clip()
.
read.md( '+:--+--:+ | x | y | +:==+==:+ | 1 | 2 | | 3 | 4 |')#> x y #> 1 1 2 #> 2 3 4read_md( '| x | y | | 1 | 2 | | 3 | 4 |')#> # A tibble: 2 x 2 #> x y #> <dbl> <dbl> #> 1 1 2 #> 2 3 4