[R] Add group name in barchart
info at aghmed.fsnet.co.uk
Wed Dec 3 12:57:27 CET 2014
Comments in line
On 02/12/2014 23:27, Silong Liao wrote:
> Dear ALL,
> I have a dataset contains 2 variables: mate (mating groups) and ratio (ratio of number of mothers and fathers). And mate is an identifer which consists three components: year, flock (flk), and tag.
> I am using command "barchart" under package "lattice" to generate plots of ratio against mate divided by each flock (See attachment). I want to put flock names onto the corresponding plots, but don't know how.
> Cheers, Sid
in general it is a bad idea to use attach, use the data= parameter if
> mate ratio1 2007.102.A 21.285712 2007.102.B 68.200003 2007.102.C 59.500004 2007.102.D 19.333335 2007.102.E 72.333336 2007.102.F 35.50000
> str(ratiodata$mate) #factor
> str(ratiodata$ratio) #num
>  102 2 2744 2747 2749 391 4357 4880 3001 3003 3004 3855 3658 4588 4591 4631
So what did this give you for flk?
This could be
barchart(ratio ~ mate | flk, data = ratiodata)
which is much easier to read.
So what did it label the panels with?
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> No virus found in this message.
> Checked by AVG - www.avg.com
> Version: 2015.0.5577 / Virus Database: 4235/8673 - Release Date: 12/03/14
More information about the R-help