Last data update: 2014.03.03

R: Process selected columns of a table into numbers
processTableR Documentation

Process selected columns of a table into numbers

Description

Given a table where some columns represent numeric values but are cluttered with info like dollar signs, percent signs, among other symbols, this function cleans up those columns and converts the entire table into a data frame.

Usage

 processTable(Table, num = NULL, Names = NULL) 

Arguments

Table

A table of character entries, usually an item from the list of tables returned by getTables.

num

Column numbers for the numerical columns.

Names

Column names to add to the final data frame.

Value

A data frame.

Author(s)

David M Diez

References

OpenIntro (http://www.openintro.org/)

See Also

getTables

Examples

## Not run: 
URL     <- "http://en.wikipedia.org/wiki/Poverty_in_the_United_States"
Tables  <- getTables(URL)
thisOne <- which(sapply(Tables, "[", 1, 1) == "Persons in Family Unit")
if(length(thisOne) > 0){
  temp <- Tables[[thisOne[1]]]
  processTable(temp[-c(1),], 1:4)
}
# warning may be produced for one entry
#  "each additional person adds"

## End(Not run)

Results