processTable: Process selected columns of a table into numbers

Description Usage Arguments Value Author(s) References See Also Examples

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

1
 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## 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)

OIdata documentation built on May 2, 2019, 2:14 p.m.