# Getting Started with R on MIT’s 14.74x (Foundations of Development Policy)

I noticed that a major grievance of many students enrolled in MIT‘s latest edX course on development policy (Foundations of Development Policy: Advanced Development Economics) was that there wasn’t enough done to get them going with the R assignments. I have posted the R code for the homework (past the deadline, of course) of the first 2 weeks, so that others get a hang of the level of R that might be needed to solve these assignments in the following weeks. I’m willing to help out those needing help getting up to speed with R required for this course. For specific queries, leave your message in the comments section.

A great place to get spend time learning R before taking Foundations of Development Policy (14.74x) would be another edX course that’s been getting great reviews recently: Introduction to R Programming

R Code for Home Work (Week 1)

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # set working directory to local directory where the data is kept setwd("~/IGIDR/Development Economics - MIT/Homework Assignment 01") # read the data wb_dev_ind = read.csv("wb_dev_ind.csv") # summarize data summary(wb_dev_ind) # Question 1 # What is the Mean of GDP per capita? What is the standard deviation of GDP per capita? meanGDPperCapita = mean(wb_dev_ind\$gdp_per_capita, na.rm = TRUE) print(round(meanGDPperCapita)) sdGDPperCapita = sd(wb_dev_ind\$gdp_per_capita, na.rm = TRUE) print(round(sdGDPperCapita)) # Question 2 # What is the mean illiteracy rate across all countries? What is the standard deviation? illiteracy_all = numeric(nrow(wb_dev_ind)) wb_dev_ind\$illiteracy_all = illiteracy_all wb_dev_ind\$illiteracy_all = 100 - wb_dev_ind\$literacy_all meanIlliteracy = mean(wb_dev_ind\$illiteracy_all, na.rm = TRUE) print(round(meanIlliteracy)) sdIlliteracy = sd(wb_dev_ind\$illiteracy_all, na.rm = TRUE) print(round(sdIlliteracy)) # Question 3 # What is the mean infant mortality rate across all countries? What is the standard deviation? meanInfantMortality = mean(wb_dev_ind\$infant_mortality, na.rm = TRUE) print(round(meanInfantMortality)) sdInfantMortality = sd(wb_dev_ind\$infant_mortality, na.rm = TRUE) print(round(sdInfantMortality)) # Question 4 # What is the mean male illiteracy rate? What is the mean female illiteracy rate? illiteracy_male = numeric(nrow(wb_dev_ind)) wb_dev_ind\$illiteracy_male = illiteracy_male wb_dev_ind\$illiteracy_male = 100 - wb_dev_ind\$literacy_male meanIlliteracyMale = mean(wb_dev_ind\$illiteracy_male, na.rm = TRUE) print(round(meanIlliteracyMale)) sdIlliteracyMale = sd(wb_dev_ind\$illiteracy_male, na.rm = TRUE) print(round(sdIlliteracyMale)) illiteracy_female = numeric(nrow(wb_dev_ind)) wb_dev_ind\$illiteracy_female = illiteracy_female wb_dev_ind\$illiteracy_female = 100 - wb_dev_ind\$literacy_female meanIlliteracyFemale = mean(wb_dev_ind\$illiteracy_female, na.rm = TRUE) print(round(meanIlliteracyFemale)) sdIlliteracyFemale = sd(wb_dev_ind\$illiteracy_female, na.rm = TRUE) print(round(sdIlliteracyFemale)) # Question 5 # What are the mean, minimum, and maximum illiteracy rate among the 50 richest countries richest50 = wb_dev_ind[order(wb_dev_ind\$gdp_per_capita, decreasing = TRUE),][1:50,] summary(richest50) # Question 6 # What are the mean, minimum, and maximum illiteracy rate among the 50 poorest countries? poorest50 = wb_dev_ind[order(wb_dev_ind\$gdp_per_capita),][1:50,] summary(poorest50) # Question 7 # What are the mean, minimum, and maximum infant mortality rate among the 50 richest countries? summary(richest50) # Question 8 # What are the mean, minimum, and maximum infant mortality rate among the 50 poorest countries? summary(poorest50) # Question 9 # What is the median GDP per capita? summary(wb_dev_ind) # Question 10-12 # Regress the infant mortality rate on per capita GDP, and then answer questions 10-12 model1 = lm(infant_mortality ~ gdp_per_capita, data = wb_dev_ind) summary(model1) # Question 13 # Regress the illiteracy rate on GDP per capita. Is the coefficient on per capita GDP significantly different from zero at the 5% level? model2 = lm(illiteracy_all ~ gdp_per_capita, data = wb_dev_ind) summary(model2) # Question 14 # Regress the infant mortality rate on the illiteracy rate. Graph a scatter plot of the data as well as the regression line. model3 = lm(infant_mortality ~ illiteracy_all, data = wb_dev_ind) summary(model3) plot(wb_dev_ind\$illiteracy_all, wb_dev_ind\$infant_mortality) abline(model3)
view raw HW01.R hosted with ❤ by GitHub

R Code for Home Work (Week 2)

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
view raw HW02.R hosted with ❤ by GitHub

I hope this helps!

## 5 thoughts on “Getting Started with R on MIT’s 14.74x (Foundations of Development Policy)”

1. Sait says:

Thank you ..very enlighted..would you please also put some comments for land homework assignment..

Like

2. jeet says:

R Code for Home Work (Week 3) 03 education homework

Like

• katty says:

i too need pls guide me

Like

3. Ashu says:

Hi,
I would want help with the 3 week homework of foundation if development policy

Like

• katty says:

i am also need pls guide me if you have

Like