read.md: Read a markdown table into a data frame

Description Usage Arguments Details Value Examples

View source: R/md.R

Description

read.md and read_md are functions to read a markdown table into a data.frame or tibble, respectively.

Usage

1
2
3
4
5
6
7
8
9
read.md(
  file = clipr::read_clip(),
  delim = "|",
  stringsAsFactors = FALSE,
  strip.white = TRUE,
  ...
)

read_md(file = clipr::read_clip(), delim = "|", trim_ws = TRUE, ...)

Arguments

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 read.delim().

strip.white, trim_ws

Trim leading and trailing whitespace from each column before parsing.

...

Passed along to read.delim() or readr::read_delim() by read.md and read_md, respectively. Applied after empty and markdown-only lines have been removed.

Details

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().

Value

For read.md, a data.frame; for read_md, a tibble.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
read.md(
'+:--+--:+
 | x | y |
 +:==+==:+
 | 1 | 2 |
 | 3 | 4 |')

read_md(
'| x | y |
 | 1 | 2 |
 | 3 | 4 |')

alistaire47/read.so documentation built on April 23, 2020, 12:50 p.m.