[R] Multiple Histograms in R

Gerrit Draisma gdraisma at xs4all.nl
Fri Apr 21 14:07:21 CEST 2017


Prateek,
Does lattice do what you want?
HTH Gerrit

ppdat<-read.table(text="mou_mean,totalmrc_mean,rev_range,mou_range,Churn
23,24,25,27,1
45,46,47,49,1
43,44,45,47,1
45,46,47,49,0
56,57,58,60,0
67,68,69,71,1
67,68,69,71,0
44,45,46,48,1
33,34,35,37,0
90,91,92,94,1
87,88,89,91,1
76,77,78,80,1
33,34,35,37,1
44,45,46,48,1",
sep=",",header=TRUE)
library(lattice)
ppdat <- reshape(ppdat,times=names(ppdat)[1:4],
		 varying=list(names(ppdat)[1:4]),
		 direction="long",
		 timevar="Characteristic",
		 v.name="Value")
histogram(Churn~Value|Characteristic,nint=10,data=ppdat)


>  Message: 1
> Date: Thu, 20 Apr 2017 16:54:35 +0530
> From: prateek pande <prtkpande at gmail.com>
> To: Hasan Diwan <hasan.diwan at gmail.com>
> Cc: r-help mailing list <r-help at r-project.org>
> Subject: Re: [R] Multiple Histograms in R
> Message-ID:
> 	<CAGAjD9nzM31+L9AwJ5x-GWUoHfTCFi9SRs-JLp7po-YH+Go-ow at mail.gmail.com>
> Content-Type: text/plain; charset="UTF-8"
> 
> HI Hasan,
> 
> Thanks for sharing the solution. Really appreciate it.
> 
> But i was reading somewhere that we cannot use par with ggplot 2 . we can
> only use grid extra to have multiple plots in a single view.
> 
> Is it right?
> 
> Regards
> Prateek
> Message: 2
> Date: Thu, 20 Apr 2017 12:26:47 +0000
> From: Ulrik Stervbo <ulrik.stervbo at gmail.com>
> To: prateek pande <prtkpande at gmail.com>, Hasan Diwan
> 	<hasan.diwan at gmail.com>
> Cc: r-help mailing list <r-help at r-project.org>
> Subject: Re: [R] Multiple Histograms in R
> Message-ID:
> 	<CAKVAULNZvmbAO5AFmOnzYvvP8vcjgzq-3FfcCWX3eGaiPKXsog at mail.gmail.com>
> Content-Type: text/plain; charset="UTF-8"
> 
> Hi Prateek,
> 
> maybe facet_* with ggplot is what you are looking for
> 
> HTH
> Ulrik
>



More information about the R-help mailing list