download_table: Download a online table

View source: R/download_table.R

download_tableR Documentation

Download a online table

Description

Download a online table

Usage

download_table(url, xpath, save_as)

Arguments

url

url of the webpage containing the table

xpath

xpath of the table

save_as

save table as "save_as.csv" file

Details

Inspect the webpage, highlight css code for table, right click then copy –> copy XPath, and paste inside SINGLE quote ' ' as xpath contains double quotes.

Package xml2 is required for rvest. Need to import it explicitly in the package.

Value

a data frame or a saved csv file

Examples

## Not run: 
table_df <-  download_table(
    'https://en.wikipedia.org/wiki/Judgment_of_Paris_(wine)',
    '//*[@id="mw-content-text"]/div/table[5]',
    "wine.csv"
)

## End(Not run)

GL-Li/mytoolbox documentation built on May 16, 2024, 4:29 p.m.