Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Scalable Data Processing in R

Cursus bekijken

Oefeninstructies

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

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# 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]))
Code bewerken en uitvoeren