Comparing the Borrower Race/Ethnicity and their Proportions
In this exercise, you'll compare the US race and ethnic proportions to proportion of total borrowers by race or ethnicity. This will provide an initial check to see if each group is borrowing at a rate comparable to its proportional representation in the United States. The task is similar to the last exercise, but this time you'll use iotools
to accomplish it.
Este exercício faz parte do curso
Scalable Data Processing in R
Instruções do exercício
- Create a matrix from each chunk of
"mortgage-sample.csv"
. - Add up the rows for all columns of
race_table_chunks
.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# Create table of the borrower_race
race_table_chunks <- ___(
"mortgage-sample.csv", function(chunk) {
x <- ___(chunk, sep = ",", type = "integer")
colnames(x) <- mort_names
table(x[, "borrower_race"])
}, CH.MAX.SIZE = 1e5)
# Add up the columns
race_table <- ___(race_table_chunks)
# Find the proportion
borrower_proportion <- race_table[1:7] / sum(race_table[1:7])
# Create the matrix
matrix(c(pop_proportion, borrower_proportion), byrow = TRUE, nrow = 2,
dimnames = list(c("Population Proportion", "Borrower Proportion"), race_cat[1:7]))