Hi everyone, I determined the presence of three types parasites in a passerine bird over two years. I would like to create a bar chart that shows the proportion infected on the y and year/parasite on the x such that each type of parasite is grouped together (single label) and a bar for each year . This would show if there have been changes in the prevalence of a the parasite over two years. This is the summary data: Parasite Year Infected Leukocytozoon 2009 0.2564 Plasmodium 2009 0.3846 Hemoproteus 2009 0.0769 Leukocytozoon 2010 0.0562 Plasmodium 2010 0.7079 Hemoproteus 2010 0.3034 Any 2009 0.5128 Any 2010 0.7753 Here are rows 86 to 92. Band and site were recorded differently each year but these are not part of any calculation. Year band site Plasmodium Hemoproteus Leukocytozoon Any 86 2010 2341-06597 1041 1 1 1 1 87 2010 2341-06598 1041 0 0 0 0 88 2010 2341-06599 1042 1 1 0 1 89 2010 2341-06600 1042 0 1 0 1 90 2009 6443 SOSP0901 0 0 1 1 91 2009 6444 SOSP0902 0 1 0 1 92 2009 6445 SOSP0903 0 0 0 0 Any suggestions on how to create this plot would be greatly appreciated. Many thanks, Jeff ***************************************** Jeffrey A. Stratford, Ph.D. Department of Health and Biological Sciences 84 W. South St. Wilkes Univertsity, PA 18766 570-332-2942 http://web.wilkes.edu/jeffrey.stratford/ ***************************************** [[alternative HTML version deleted]]
Hi Jeff, One way to graph the differences between the two years for the first set of data is via barchart(), a function equivalent to barplot in the lattice package. Please check if with this portion of code (and with your data) the graph you get is quite self-explanatory. ################################### require(lattice) Lines<-"Parasite Year Infected Leukocytozoon 2009 0.2564 Plasmodium 2009 0.3846 Hemoproteus 2009 0.0769 Leukocytozoon 2010 0.0562 Plasmodium 2010 0.7079 Hemoproteus 2010 0.3034 Any 2009 0.5128 Any 2010 0.7753 " DF <- read.table(textConnection(Lines), skip=1, as.is = TRUE, col.names=c("Parasite", "Year", "Infected") ) barchart( Infected ~ Parasite, data=DF, groups=as.factor(Year), auto.key = list(space = "bottom"), origin=0 ) ############################## Regards, Carlos Ortega www.qualityexcellence.es On Wed, Jul 20, 2011 at 5:56 AM, Stratford, Jeffrey < jeffrey.stratford@wilkes.edu> wrote:> Hi everyone, > > > > I determined the presence of three types parasites in a passerine bird > over two years. I would like to create a bar chart that shows the > proportion infected on the y and year/parasite on the x such that each > type of parasite is grouped together (single label) and a bar for each > year . This would show if there have been changes in the prevalence of > a the parasite over two years. > > > > This is the summary data: > > > > Parasite Year Infected > > Leukocytozoon 2009 0.2564 > > Plasmodium 2009 0.3846 > > Hemoproteus 2009 0.0769 > > Leukocytozoon 2010 0.0562 > > Plasmodium 2010 0.7079 > > Hemoproteus 2010 0.3034 > > Any 2009 0.5128 > > Any 2010 0.7753 > > > > Here are rows 86 to 92. Band and site were recorded differently each > year but these are not part of any calculation. > > > > Year band site Plasmodium Hemoproteus Leukocytozoon Any > > 86 2010 2341-06597 1041 1 1 1 1 > > 87 2010 2341-06598 1041 0 0 0 0 > > 88 2010 2341-06599 1042 1 1 0 1 > > 89 2010 2341-06600 1042 0 1 0 1 > > 90 2009 6443 SOSP0901 0 0 1 1 > > 91 2009 6444 SOSP0902 0 1 0 1 > > 92 2009 6445 SOSP0903 0 0 0 0 > > > > Any suggestions on how to create this plot would be greatly appreciated. > > > > > Many thanks, > > > > Jeff > > > > > > ***************************************** > > Jeffrey A. Stratford, Ph.D. > > Department of Health and Biological Sciences > > 84 W. South St. > > Wilkes Univertsity, PA 18766 > > 570-332-2942 > > http://web.wilkes.edu/jeffrey.stratford/ > > ***************************************** > > > > > [[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. >[[alternative HTML version deleted]]
On 07/20/2011 01:56 PM, Stratford, Jeffrey wrote:> Hi everyone, > > > > I determined the presence of three types parasites in a passerine bird > over two years. I would like to create a bar chart that shows the > proportion infected on the y and year/parasite on the x such that each > type of parasite is grouped together (single label) and a bar for each > year . This would show if there have been changes in the prevalence of > a the parasite over two years. > > > > This is the summary data: > > > > Parasite Year Infected > > Leukocytozoon 2009 0.2564 > > Plasmodium 2009 0.3846 > > Hemoproteus 2009 0.0769 > > Leukocytozoon 2010 0.0562 > > Plasmodium 2010 0.7079 > > Hemoproteus 2010 0.3034 > > Any 2009 0.5128 > > Any 2010 0.7753 > > > > Here are rows 86 to 92. Band and site were recorded differently each > year but these are not part of any calculation. > > > > Year band site Plasmodium Hemoproteus Leukocytozoon Any > > 86 2010 2341-06597 1041 1 1 1 1 > > 87 2010 2341-06598 1041 0 0 0 0 > > 88 2010 2341-06599 1042 1 1 0 1 > > 89 2010 2341-06600 1042 0 1 0 1 > > 90 2009 6443 SOSP0901 0 0 1 1 > > 91 2009 6444 SOSP0902 0 1 0 1 > > 92 2009 6445 SOSP0903 0 0 0 0 > > > > Any suggestions on how to create this plot would be greatly appreciated. > >Hi Jeff, I think this could be done with the barNest function, nesting the year bars within the parasite bars. If you can't figure it out, send the complete dataset and I can provide an example. Jim