vendredi 23 novembre 2018

Reading data from webpage using R

I wrote the following html table

ID    X     Y     Depth P
<div class="WordSection1">
<p class="MsoPlainText">1046  256857      2632323     13    2.8</p>
<p class="MsoPlainText">1054  257090      2632039     13    1.1</p>
<p class="MsoPlainText">1057  257099      2631981     13    2.6</p>
<p class="MsoPlainText">1058  257071      2632004     9     2.1</p>
<p class="MsoPlainText">1060  257173      2632004     13    4</p>
<p class="MsoPlainText">1089  257194      2631660     13    14.1</p>
 

</div>

which looks like this to the readers of a webpage

ID    X     Y     Depth P

1046  256857      2632323     13    2.8

1054  257090      2632039     13    1.1

1057  257099      2631981     13    2.6

1058  257071      2632004     9     2.1

1060  257173      2632004     13    4

1089  257194      2631660     13    14.1

I am looking for the easiest way to read the table using R directly from the webpage. I am using:

library(RCurl)
library(XML)
d<-readHTMLTable(getURL('https://wordpresswebsiteaddress/data/') )

it does read it but gives me a whole bunch of other things when only "getURL" is used !! but when "readHTMLtable" is used on the top I only get the following:

> d
named list()

Am I missing something? Is there an easy way to read the table? thanks!




Aucun commentaire:

Enregistrer un commentaire