Module 2 exercise part 1 walk through

Part 1 The first thing you want to do is read the data into r do this by;

bird = read.csv("BirdFlu_deaths.csv")

now use the functions names(), head(), and str() to get an overview of the data

names(bird)
## [1] "Country" "yr2003"  "yr2004"  "yr2005"  "yr2006"  "yr2007"  "yr2008"
head(bird)
##      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
str(bird)
## '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 ...

now we are going to find the row number containing highest number of deaths for 2005 using the which() function

which.max(bird$yr2005)
## [1] 15

using the row number you can identify which country it takes place in

#([19, Vietnam])

now we are going to do the same thing for 2007

which.max(bird$yr2007)
## [1] 7
#([37, Indonesia])