Hi Pateek,
Try this:
ppdat<-read.table(text="Values Churn
21 1
22 1
31.2 1
32 1
35 0
43 1
45 0
67 1
67 0
76 0
89 1",
header=TRUE)
ppdat$Valbin<-cut(ppdat$Values,breaks=c(20.9,43.7,66.3,89.1))
binPct<-function(x) return(100*sum(x)/length(x))
binnedPct<-by(ppdat$Churn,ppdat$Valbin,binPct)
bpctdf<-data.frame('Binned data'=names(binnedPct),
'churn%'=as.vector(binnedPct))
bpctdf
Jim
On Tue, Apr 18, 2017 at 5:20 AM, prateek pande <[email protected]> wrote:
> I have a data, in the form mentioned below.
>
> Values Churn
> 21 1
> 22 1
> 31.2 1
> 32 1
> 35 0
> 43 1
> 45 0
> 67 1
> 67 0
> 76 0
> 89 1
>
> Now i want to bin the values variables into bins and corresponding that
> want the churn percentage, like mentioned below
> Binned data churn%
> (20.9,43.7] 0.83
> (43.7,66.3] 0
> (66.3,89.1] 0.50
>
> Please help
>
> « Return to Rcom-l <http://r.789695.n4.nabble.com/Rcom-l-f930477.html> | 3
> v
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [email protected] mailing list -- To UNSUBSCRIBE and more, see
> 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.
______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
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.