ComenzarEmpieza gratis

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 ejercicio forma parte del curso

Scalable Data Processing in R

Ver curso

Instrucciones del ejercicio

  • Create a matrix from each chunk of "mortgage-sample.csv".
  • Add up the rows for all columns of race_table_chunks.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# 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]))
Editar y ejecutar código