[R] Understanding lattice barchart() display

Bert Gunter gunter.berton at gene.com
Wed Oct 24 00:35:26 CEST 2012


I believe you are misunderstanding what a barchart is (or maybe I do,
since I never use 'em). I believe that there should be one quant value
for each tclass and stream, and you have several.

?panel.barchart

is the place to look for documentation for details of any lattice
display. Note especially the "horizontal" argument details (also in
?barchart).

You may also wish to consider ?bwplot instead.

-- Bert

On Tue, Oct 23, 2012 at 2:59 PM, Rich Shepard <rshepard at appl-ecosys.com> wrote:
>   I've a data frame with this structure:
>
> 'data.frame':   1987 obs. of  11 variables:
>  $ site         : Factor w/ 24 levels "B(W)","BC-1",..: 1 1 2 2 2 1 1 1 ...
>  $ sampdate     : Date, format: "2000-07-18" "2000-07-18" ...
>  $ tclass       : Factor w/ 8 levels "Annelida","Arachnida",..: 1 5 5 5 5
> ...
>  $ torder       : Factor w/ 18 levels "Achtinedida",..: 13 5 5 10 13 5 7 ...
>  $ tfamily      : Factor w/ 81 levels "","Ameletidae",..: 79 46 46 14 42 ...
>  $ tgenus       : Factor w/ 206 levels "","Acentrella",..: 1 10 10 1 140 ...
>  $ tspecies     : Factor w/ 60 levels "","aequalis",..: 1 1 1 1 1 1 1 ...
>  $ quant        : int  22 527 22 22 11 97 333 11 108 11 ...
>  $ stream       : Factor w/ 7 levels "BCrk","JCrk",..: 1 1 1 1 1 1 1 1 ...
>  $ basin        : Factor w/ 2 levels "H","O": 2 2 2 2 2 2 2 2 2 2 ...
>
>   When I create a bar chart for tclass by stream the resulting bars appear
> to have multiple segments (see attached pdf) from this command:
>
> barchart(quant ~ tclass | stream, data = benthos, main = 'Taxonomic
> Classes', xlab = 'Class Name', ylab = 'Number/square meter', scales = list(x
> = list(rot = 90)))
>
> and I want to understand what the segments represent. I thought the formula
> 'quant ~ tclass' would produce one bar per class. I cannot find the answer
> in the ?barchart help page (it may be there and I'm not seeing it) or the
> Lattice book. Your help in increasing my understanding is appreciated.
>
> TIA,
>
> Rich
> ______________________________________________
> R-help at 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.
>



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm




More information about the R-help mailing list