Learn R Programming

OIdata (version 1.0)

processTable: 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

References

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

See Also

getTables

Examples

Run this code
## 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)

Run the code above in your browser using DataLab