[R] Multiple stacked barplots on the same graph?

Stéphane CRUVEILLER scruveil at genoscope.cns.fr
Wed Dec 5 09:02:30 CET 2007


Hi,

the same error message is displayed with geom="bar" as parameter.
here is the output of dput:

 > dput(mydata)
structure(list(Categorie = structure(c(1L, 12L, 8L, 2L, 5L, 7L,
16L, 6L, 15L, 11L, 10L, 13L, 14L, 3L, 4L, 9L, 17L, 1L, 12L, 8L,
2L, 5L, 7L, 16L, 6L, 15L, 11L, 10L, 13L, 14L, 3L, 4L, 9L, 17L
), .Label = c("Amino acid biosynthesis", "Biosynthesis of cofactors, 
prosthetic groups, and carriers",
"Cell envelope", "Cellular processes", "Central intermediary metabolism",
"DNA metabolism", "Energy metabolism", "Fatty acid and phospholipid 
metabolism",
"Mobile and extrachromosomal element functions", "Protein fate",
"Protein synthesis", "Purines, pyrimidines, nucleosides, and nucleotides",
"Regulatory functions", "Signal transduction", "Transcription",
"Transport and binding proteins", "Unknown function"), class = "factor"),
    Part = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("common",
    "specific"), class = "factor"), Total = c(3.03, 1.65, 1.52,
    2.85, 3.4, 11.81, 10.51, 1.95, 2.08, 2.51, 2.23, 7.63, 1.88,
    2.76, 7.21, 1.08, 20.75, 0.35, 0.17, 0.08, 0.18, 0.42, 2.05,
    1.98, 0.63, 0.17, 0.2, 0.3, 1.58, 0.27, 0.83, 1.38, 3.56,
    11.63), chr1 = c(4.55, 2.37, 1.77, 4.68, 3.19, 12.49, 13.56,
    2.81, 3.13, 4.58, 3.26, 7.3, 2.06, 3.41, 7.9, 0.22, 22.45,
    0.16, 0.06, 0.09, 0.19, 0.09, 0.7, 0.85, 0.22, 0.06, 0.03,
    0.32, 0.66, 0.06, 0.63, 0.38, 1.14, 6.17), chr2 = c(1.68,
    1.06, 1.55, 1.02, 4.57, 13.87, 7.85, 0.98, 1.06, 0.27, 1.2,
    9.88, 2.13, 2.53, 7.71, 0.4, 22.38, 0.71, 0.35, 0.09, 0.22,
    0.98, 3.9, 3.24, 0.22, 0.22, 0.49, 0.31, 2.79, 0.62, 1.33,
    1.95, 0.44, 16), pl = c(0, 0, 0, 0, 0, 0.17, 4.27, 1.03,
    0.34, 0, 0.68, 0.68, 0, 0.17, 1.54, 8.38, 5.3, 0, 0, 0, 0,
    0, 2.22, 3.25, 4.44, 0.51, 0, 0.17, 1.88, 0, 0, 4.62, 28.72,
    24.27)), .Names = c("Categorie", "Part", "Total", "chr1",
"chr2", "pl"), class = "data.frame", row.names = c(NA, -34L))


thx,

Stéphane.

hadley wickham wrote:
> On Dec 4, 2007 10:34 AM, Stéphane CRUVEILLER <scruveil at genoscope.cns.fr> wrote:
>   
>> Hi,
>>
>> I tried this method but it seems that there is something wrong with my
>> data frame:
>>
>>
>> when I type in:
>>
>>  > qplot(x=as.factor(Categorie),y=Total,data=mydata)
>>
>> It displays a graph with 2 points in each category...
>> but if  I add the parameter geom="histogram"
>>
>>  > qplot(x=as.factor(Categorie),y=Total,data=mydata,geom="histogram")
>>
>>
>> Error in storage.mode(test) <- "logical" :
>>         object "y" not found
>>
>> any hint about this...
>>     
>
> Could you copy and paste the output of dput(mydata) ?
>
> (And I'd probably write the plot call as: qplot(Categorie, Total,
> data=mydata, geom="bar"), since it is a bar plot, not a histogram)
>
>   

-- 
"La science a certes quelques magnifiques réussites à son actif mais
à tout prendre, je préfère de loin être heureux plutôt qu'avoir raison." 
D. Adams
-- 
AGC website <http://www.genoscope.cns.fr/agc>
	Stéphane CRUVEILLER Ph. D.
Genoscope - Centre National de Séquencage
Atelier de Génomique Comparative
2, Rue Gaston Cremieux CP 5706
91057 Evry Cedex - France
Phone: +33 (0)1 60 87 84 58
Fax: +33 (0)1 60 87 25 14
scruveil at genoscope.cns.fr



More information about the R-help mailing list