Re: [R] tapply & hist

About this list Date view Thread view Subject view Author view Attachment view

From: Gabor Grothendieck (ggrothendieck@myway.com)
Date: Fri 14 May 2004 - 06:46:40 EST


Message-id: <loom.20040513T224351-293@post.gmane.org>


As another respondent already mentioned, Lattice is probably the way to
go on this one but if you do want to use tapply try this:

names(Pot) <- SGruppo
dummy <- tapply(Pot,SGruppo,function(x)hist(x,main=names(x)[1],xlab=NULL))

Vittorio <v.demartino2 <at> virgilio.it> writes:

:
: I'm learning how to use tapply.
: Now I'm having a go at the following code in which dati contains almost 600
: lines, Pot - numeric - are the capacities of power plants and SGruppo - text
: - the corresponding six technologies
("CCC", "CIC","TGC", "CSC","CPC", "TE").
: .....................................................
:
: dati=sqlQuery(canale,"select Id,SGruppo,Classe, NGruppo,ProdNetta,Pot from
: SintesiQuery")
: attach(dati)
: # Grouping by technology
: tapply(Pot,SGruppo,sum)
: ...................................
: # Histograms by technology
: par(mfrow=c(2,3))
: tapply(Pot,SGruppo,hist)
: detach(dati)
:
: It all works great but tapply(Pot,SGruppo,hist) produces 6 histograms with
: the titles and the xlab labels in a generic form, something like integer[1],
: integer[2], ....... while I'd like to have each graph indicating the
: mentioned technologies.
: I've been trying issuing
: tech=c("CCC", "CIC","TGC", "CSC","CPC", "TE")
: tapply(Pot,SGruppo,hist, main=tech)
:
: but R prints in each histogram the six values in the title without cycling
: among them.
:
: How can I obtain what I want?
:
: Ciao
: Vittorio

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Mon 31 May 2004 - 23:05:10 EST