Skip to content

Downloading a html table

4 messages · David Arnold, Rolf Turner, David L Carlson +1 more

#
All,

A friend of mine would like to use this data with his stats class:

http://www.worldatlas.com/aatlas/populations/usapoptable.htm

I can't figure a way of capturing this data due to the mysql commands in the
source code.

Any thoughts?

David.



--
View this message in context: http://r.789695.n4.nabble.com/Downloading-a-html-table-tp4647091.html
Sent from the R help mailing list archive at Nabble.com.
#
On 23/10/12 16:17, David Arnold wrote:
Copying and pasting, and then editing the resulting file just a wee bit 
(changing
the blanks in state names to underscores) gave me a file that was readily
readable by read.table().

Is the column of state populations really blank?  Or is there something
funny happening with my web browser?

     cheers,

         Rolf Turner
#
Copy the table data (leave out the column headings and the total line at the
bottom) into the clipboard. Then
"PopDensity.km", "Area.mi", "PopDensity.mi")
Area.mi=as.numeric(gsub(",", "", Area.mi)),
     PopDensity.mi=as.numeric(gsub(",", "", PopDensity.mi)))
The last line computes the Population from the Area and Population Density.

----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352
#
Rather than requiring manual tweaking,

library(XML)
readHTMLTable("http://www.worldatlas.com/aatlas/populations/usapoptable.htm")

will do the job for us.

 D.
On 10/22/12 8:17 PM, David Arnold wrote: