| html_table_cells | R Documentation |
One row per cell of one <table>, with its position in the grid that
html_table() builds: spans are placed, clipped and checked exactly as
there, and rows are numbered in the same logical order, header rows
included. Use it when the data frame loses what you need: which cells are
headers, how far they span, or the links inside them.
html_table_cells(x, trim = TRUE, absolute = FALSE, limits = html_limits())
x |
A nodeset holding exactly one |
trim |
Whether to trim each cell's text; see |
absolute |
If |
limits |
Resource limits from |
A data frame with one row per <td> or <th>, in grid order
(by row, then column), and columns:
row, column: the integer position of the cell's top-left slot;
rowspan, colspan: the integer number of rows and columns it
covers, after rowspan="0" is expanded and spans are clipped;
section: "thead", "tbody" or "tfoot"; rows directly in the
table are "tbody";
header: TRUE for a <th>;
text: the cell's cleaned text, without nested tables, as in
html_table();
links: a list of character vectors, the href of each <a> and
<area> in the cell, outside nested tables.
Other extraction:
html_forms(),
html_links(),
html_list(),
html_table(),
html_url()
doc <- html_parse(paste0(
"<table><tr><th rowspan=2>Package<th colspan=2>Links",
"<tr><th>Home<th>Docs",
"<tr><td>zuhtml<td><a href='https://example.org/'>site</a>",
"<td><a href='/ref/'>ref</a> <a href='/news/'>news</a></table>"
), base_url = "https://example.org/pkg/")
cells <- html_table_cells(html_element(doc, "table"), absolute = TRUE)
cells[, c("row", "column", "rowspan", "colspan", "header", "text")]
cells$links[[7]]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.