birdfludata_data <- read.csv("BirdFlu_deaths.csv")Excersize 6
My first report
The goal is to explain the first part of module 2
This sets up a variable to be the csv of bird flue deaths
names(birdfludata_data)[1] "Country" "yr2003" "yr2004" "yr2005" "yr2006" "yr2007" "yr2008"
head(birdfludata_data) 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(birdfludata_data)'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 ...
This brings up the header of the data nd shows the structure
which.max(birdfludata_data$yr2005)[1] 15
birdfludata_data[15,"Country"][1] "Vietnam"
which.max(birdfludata_data$yr2007)[1] 7
birdfludata_data[7,"Country"][1] "Indonesia"
This code finds the column that contains the max value from the year 2005 and the second row returns the country using the column 15 and the row named country.
It does the same process with a different year.