Run the following line in R on the computer to obtain a biva
Run the following line in R on the computer to obtain a bivariate table for hair and eye color in a sample of 279 men:
male.HairEyeColor <- HairEyeColor[,,1]
Make a stacked relative frequency barplot with hair color on the x-axis. Add a legend. Use the
category colors “saddlebrown” for brown eyes, “lightblue” for blue eyes, “violet” for hazel eyes, and “palegreen” for green eyes.
Among blonds, what eye color is most prevalent in the sample?
Solution
the R CODE is
male.HairEyeColor <- HairEyeColor[,,1]
barplot(male.HairEyeColor,beside=F,names.arg=c(\"Black\",\"Brown\",\"Red\",\"Blond\"),xlab=\"HAIR COLOR\",col=c(\"saddlebrown\",\"lightblue\",\"violet\",\"palegreen\"))
legend(\"topright\",legend=c(\"Black\",\"Brown\",\"Red\",\"Blond\"),fill=c(\"saddlebrown\",\"lightblue\",\"violet\",\"palegreen\"),title=\"HAIR COLOR\")
among blonds,Blue eye color is most prevalent as it has the maximum frequency.
![Run the following line in R on the computer to obtain a bivariate table for hair and eye color in a sample of 279 men: male.HairEyeColor <- HairEyeColor[,,1] Run the following line in R on the computer to obtain a bivariate table for hair and eye color in a sample of 279 men: male.HairEyeColor <- HairEyeColor[,,1]](/WebImages/25/run-the-following-line-in-r-on-the-computer-to-obtain-a-biva-1066339-1761557842-0.webp)