I will be using the code from Exercise 2, Part 1.
# First, lets read in the file.
BirdFlu_deaths = read.csv("BirdFlu_deaths.csv")
#This next code will list out the column names.
names(BirdFlu_deaths)
## [1] "Country" "yr2003" "yr2004" "yr2005" "yr2006" "yr2007" "yr2008"
#Head will display the first few rows of the dataset.
head(BirdFlu_deaths)
## Country yr2003 yr2004 yr2005 yr2006 yr2007 yr2008
## 1 Azerbaijan 0 0 0 5 0 0
## 2 Bangladesh 0 0 0 0 0 0
## 3 Cambodia 0 0 4 2 1 0
## 4 China 1 0 5 8 3 3
## 5 Djibouti 0 0 0 0 0 0
## 6 Egypt 0 0 0 10 9 3
#Let's look at the internal structure
str(BirdFlu_deaths)
## 'data.frame': 15 obs. of 7 variables:
## $ Country: chr "Azerbaijan" "Bangladesh" "Cambodia" "China" ...
## $ yr2003 : int 0 0 0 1 0 0 0 0 0 0 ...
## $ yr2004 : int 0 0 0 0 0 0 0 0 0 0 ...
## $ yr2005 : int 0 0 4 5 0 0 13 0 0 0 ...
## $ yr2006 : int 5 0 2 8 0 10 45 2 0 0 ...
## $ yr2007 : int 0 0 1 3 0 9 37 0 2 0 ...
## $ yr2008 : int 0 0 0 3 0 3 15 0 0 0 ...
#I got confused on what to do, so let's utilize ?
?which
## starting httpd help server ... done
#Figured it out, use which.max to find the row with the highest value, within the column yr2005.
which.max(BirdFlu_deaths$yr2005)
## [1] 15
#Now we know the row, let's figure out which country that is.
BirdFlu_deaths[15,1]
## [1] "Vietnam"
#Let's now figure out the row with the most deaths for the column yr2007.
which.max(BirdFlu_deaths$yr2007)
## [1] 7
#Got that figured out, now let's see which country is in that row.
BirdFlu_deaths[7,1]
## [1] "Indonesia"