[R] multiple histograms from a dataframe

David Winsemius dwinsemius at comcast.net
Sun Feb 12 05:10:14 CET 2012


On Feb 11, 2012, at 6:25 PM, Adel ESSAFI wrote:

>
>
> Le 11 février 2012 02:33, David Winsemius <dwinsemius at comcast.net> a  
> écrit :
>
> On Feb 10, 2012, at 7:05 PM, Adel ESSAFI wrote:
>
> Hi list
>
>
> I  need some help for drawing some histograms
>
> I have a dataframe , say,
> X Y Z T
>
> I want to draw a histogram Z-T for each value of the couple (X-Y).
> When I use thus syntax
>
> library(lattice)
> histogram(law[,3] ~ law[,66] | law[,1] )
>
> Perhaps (but untested in the absence of data);
>
>  histogram( Z ~ T | interaction(X, Y)  , data=dfrmname )
>
> Thanks ,
> that helped a lot.
>
> now, I have another problem: I want  to draw many (two) figures  
> together.
> The par(new=T) directve does not recognize the ploy provided by  
> lattice library

Par is for base graphics. xyplot is part of lattice and grid graphics.

> when I tired :
> > xyplot(law[,66] ~ law[,3]| interaction(law[,1],law[,2]),type='l')
> > par(new=T)
> Warning message:
> In par(new = T) : calling par(new=TRUE) with no plot
> > xyplot(law[,67] ~ law[,3]| interaction(law[,1],law[,2]),type='l')
>
> and the second xyplot() draws a new figure.
>
> what can I do to draw to figures together using lattice?

You need to describe what you mean by "together". It is possible that  
the goup parameter is what you want but that's just a guess. It's also  
possible that the formular operator "+" will give you what you desire.  
Perhaps:

xyplot( law[,67] + law[,66] ~ law[,3]| interaction(law[,1],law[, 
2]),type='l')

>
> it draws multiple histograms but by selecting distinct values of   
> law[,1]
> The deal is to make the same thing but for a couple of columns

That doesn't make any sense to me. But then I do apologize for the  
English language. It's horribly complex and syntactically a mess.


>
> Thanks in advance for help
>
> Adel
>
>
> -- 
>
> David Winsemius, MD
> West Hartford, CT
>
> -- 
> PhD candidate in Computer Science
> Address
> 3 avenue lamine, cité ezzahra, Sousse 4000
> Tunisia
> tel: +216 97 246 706 (+33640302046 jusqu'au 15/6)
> fax: +216 71 391 166

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list