Copy the table data (leave out the column headings and the total line at the bottom) into the clipboard. Then
> Dta <- read.delim("clipboard", header=FALSE, stringsAsFactors=FALSE) > colnames(Dta) <- c("No", "State", "Abbrev", "Population", "Area.km", "PopDensity.km", "Area.mi", "PopDensity.mi") > rownames(Dta) <- Dta$No > Dta$No <- NULL > Dta <- transform(Dta, Area.km=as.numeric(gsub(",", "", Area.km)), Area.mi=as.numeric(gsub(",", "", Area.mi)), PopDensity.mi=as.numeric(gsub(",", "", PopDensity.mi))) > Dta <- transform(Dta, Population=Area.km*PopDensity.km) 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 > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Rolf Turner > Sent: Monday, October 22, 2012 10:47 PM > To: David Arnold > Cc: r-help@r-project.org > Subject: Re: [R] Downloading a html table > > On 23/10/12 16:17, David Arnold wrote: > > 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? > > 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 > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.