# NOT RUN {
sample1 <- minimal_html("<table>
<tr><th>Col A</th><th>Col B</th></tr>
<tr><td>1</td><td>x</td></tr>
<tr><td>4</td><td>y</td></tr>
<tr><td>10</td><td>z</td></tr>
</table>")
sample1 %>%
html_element("table") %>%
html_table()
# Values in merged cells will be duplicated
sample2 <- minimal_html("<table>
<tr><th>A</th><th>B</th><th>C</th></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td colspan='2'>4</td><td>5</td></tr>
<tr><td>6</td><td colspan='2'>7</td></tr>
</table>")
sample2 %>%
html_element("table") %>%
html_table()
# If a row is missing cells, they'll be filled with NAs
sample3 <- minimal_html("<table>
<tr><th>A</th><th>B</th><th>C</th></tr>
<tr><td colspan='2'>1</td><td>2</td></tr>
<tr><td colspan='2'>3</td></tr>
<tr><td>4</td></tr>
</table>")
sample3 %>%
html_element("table") %>%
html_table()
# }
Run the code above in your browser using DataLab