[R] bar chart issue

Jim Lemon jim at bitwrit.com.au
Wed Jul 20 13:36:38 CEST 2011


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



More information about the R-help mailing list