Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

((PLEASE ANSWER BY R STUDIO)) # Download the data file hmda_small . # folder and

ID: 3791667 • Letter: #

Question

((PLEASE ANSWER BY R STUDIO))

# Download the data file hmda_small . # folder and read the data into R using the read.csv() function.

Be sure to assign the data to an object called hmda when you read it in.

Here are the codes :

data_url <-

"https://raw.githubusercontent.com/wampeh1/Ecog314_Spring2017/master/lecture4/data/hmda_small.csv"

if ( ! file.exists("hmda_small.csv") ) {

download.file(data_url, "hmda_small.csv")

}

hmda_small <- read.csv("hmda_small.csv", stringsAsFactors = FALSE)

# Part 1: Create a bar chart of the average loan amount by racial and ethnic group. Make sure your axes are properly labeled and your chart has a title.

# Part 2: Create a bar chart of the fraction of loan denied by the financial institution by racial and ethnic group. Make sure your axes are properly labeled and your chart has a title.

# Part 3: Create a histogram of the loan amount.

# Part 4: Create a scatter plot of applicant income vs. loan amount. Do you see any relationship? # use the cor() function to calculate the correlation between the two variables.

Explanation / Answer

data_url <-"https://raw.githubusercontent.com/wampeh1/Ecog314_Spring2017/master/lecture4/data/hmda_small.csv"
if ( ! file.exists("hmda_small.csv") ) {
download.file(data_url, "hmda_small.csv")
}
hmda_small <- read.csv("hmda_small.csv", stringsAsFactors = FALSE)


# Part 1: Create a bar chart of the average loan amount by
#racial and ethnic group.
#Make sure your axes are properly labeled and your chart has a title.

hist(hmda_small$loan_amount_000s)
hist(hmda_small$loan_amount_000s, breaks = 12, col = "lightblue", border = "pink")