Extract table from a site to Rstudio

Posted on

Question :

Hello, I want to get the Brazilian table, for example from this site “ link ” and extract for a dateset in Rstudio, so that whenever the table updates according to the games, it updates itself in rstudio as well. Can you help me?


Answer :

For this I usually use the XML package. Lets say which table of the web page you are interested in. In this case this page has several. The third one has nothing of interest, so I extracted the numbers 1, 2, and 4.


URL <- "http://globoesporte.globo.com/futebol/brasileirao-serie-a/"

tabela1 <- readHTMLTable(URL, which = 1)

tabela2 <- readHTMLTable(URL, which = 2)

tabela4 <- readHTMLTable(URL, which = 4)

Note that you can use the arguments of the base function R read.table , namely the argument stringsAsFactors may be important.


Leave a Reply

Your email address will not be published. Required fields are marked *