Let’s try this again.
Original data sources:
http://data.worldbank.org/data-catalog/GDP-ranking-table
http://data.worldbank.org/data-catalog/ed-stats
#load dplyr library
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
#download files from git
download.file("https://raw.githubusercontent.com/uky994/STA-4233.-INTRODUCTION-TO-PROGRAMMING-AND-DATA-MANAGEMENT-IN-R/master/GDP.csv", destfile = "gdp.csv")
download.file("https://raw.githubusercontent.com/uky994/STA-4233.-INTRODUCTION-TO-PROGRAMMING-AND-DATA-MANAGEMENT-IN-R/master/FEDSTATS_Country.csv", destfile = "fed.csv")
#read in gdp file
countries = read.csv("gdp.csv", skip=4, nrows = 190)
#clean gdp file
countries <- select(countries,"X", "X.1", "X.3", "X.4") #select necessary columns
countries = rename(countries,CountryCode=X, Rank=X.1, Economy=X.3, Total=X.4) #rename the variables
countries$Total<-as.numeric(gsub(",","",countries$Total)) #coerce Total to be numeric after stripping out commas with gsub
#read in fed file
education = read.csv("fed.csv")
all = merge(countries, education, by = "CountryCode")
dim(all)
## [1] 189 34
all <- arrange(all, desc(Rank))
What is the 13th country in the resulting data frame?
head(all,13)[33]
## Table.Name
## 1 Tuvalu
## 2 Kiribati
## 3 Marshall Islands
## 4 Palau
## 5 São Tomé and Principe
## 6 Micronesia, Fed. Sts.
## 7 Tonga
## 8 Dominica
## 9 Comoros
## 10 Samoa
## 11 St. Vincent and the Grenadines
## 12 Grenada
## 13 St. Kitts and Nevis