Hi all,

I'm currently working through the "Beginner's Guide to R" (Zurr et al.) and
I'm wondering about the first exercise in chapter 3:

I imported the data from BirdFluCases.txt and executed the 'names' and 'str'
functions as follows:

Bird = read.table(file='C:\\rbook\\BirdFluCases2.txt', header=TRUE)
names(Bird)

[1] "Year"       "Azerbaijan" "Bangladesh" "Cambodia"   "China"
"Djibouti"   "Egypt"
 [8] "Indonesia"  "Iraq"       "LaoPDR"     "Myanmar"    "Nigeria"
"Pakistan"   "Thailand"
[15] "Turkey"     "VietNam"

str(Bird)

'data.frame':   6 obs. of  16 variables:
 $ Year      : int  2003 2004 2005 2006 2007 2008
 $ Azerbaijan: int  0 0 0 8 0 0
 $ Bangladesh: int  0 0 0 0 0 1
 $ Cambodia  : int  0 0 4 2 1 0
 $ China     : int  1 0 8 13 5 3
 $ Djibouti  : int  0 0 0 1 0 0
 $ Egypt     : int  0 0 0 18 25 7
 $ Indonesia : int  0 0 20 55 42 18
 $ Iraq      : int  0 0 0 3 0 0
 $ LaoPDR    : int  0 0 0 0 2 0
 $ Myanmar   : int  0 0 0 0 1 0
 $ Nigeria   : int  0 0 0 0 1 0
 $ Pakistan  : int  0 0 0 0 3 0
 $ Thailand  : int  0 17 5 3 0 0
 $ Turkey    : int  0 0 0 12 0 0
 $ VietNam   : int  3 29 61 0 8 5

I obtained the total number of bird flu cases in 2003 and 2005 respectively
with:

sum(Bird[1,2:16])

[1] 4

and

sum(Bird[3, 2:16])

[1] 98


I don't know how to obtain the answers for 'Which country has had the most
cases?', 'Which country has had the least bird flu deaths?' or (using
methods from chapter 2), 'What is the total number of bird flu cases per
country?' and 'What is the total number of cases per year?'

The rowSums and colSums functions haven't been introduced at this point in
the text.

Thanks,

Katie

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to