Extract table from a site to Rstudio

3

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?

    
asked by anonymous 10.10.2017 / 20:38

1 answer

6

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.

library(XML)

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

tabela1 <- readHTMLTable(URL, which = 1)
tabela1

tabela2 <- readHTMLTable(URL, which = 2)
tabela2

tabela4 <- readHTMLTable(URL, which = 4)
tabela4

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

    
10.10.2017 / 20:54