[R] R help
arun
smartpink111 at yahoo.com
Thu Feb 6 17:16:33 CET 2014
HI,
I am not sure this is what you meant.
a <- read.table(text="1 2 3 4 5 6
1 Mal 1 Layer 22 M 100000
2 Mahesh 2 Actor 45 M 150000000
3 Tarak 3 Actor 30 M 150000000
4 Pawan 4 Actor 47 M 150000000
5 Charan 5 Actor 32 M 100000000
6 Prabhas 6 Actor 32 M 100000000
7 Arjun 7 Actor 31 M 90000000
8 Naresh 8 Actor 29 M 30000000
9 Nithin 9 Actor 30 M 30000000
10 Puri 10 Director 38 M 100000000",sep="",header=TRUE,check.names=FALSE,stringsAsFactors=FALSE)
res1 <- setNames(as.data.frame(table(cut(a[,4],breaks=seq(0,100,by=20),labels=c("0-20","20-40","40-60","60-80","80-100")))),c("Bins","count"))
#or
res2 <- setNames(as.data.frame(table(cut(a$`4`,breaks=seq(0,100,by=20),labels=c("0-20","20-40","40-60","60-80","80-100")))),c("Bins","count"))
identical(res1,res2)
#[1] TRUE
#or change the colnames and apply your code
colnames(a)[4] <- "AGE"
A.K.
On Thursday, February 6, 2014 3:47 AM, Malyadri Putchakayala <malyadri.putchakayala at nuevora.com> wrote:
1 2 3 4 5 6
1 Mal 1 Layer 22 M 100000
2 Mahesh 2 Actor 45 M 150000000
3 Tarak 3 Actor 30 M 150000000
4 Pawan 4 Actor 47 M 150000000
5 Charan 5 Actor 32 M 100000000
6 Prabhas 6 Actor 32 M 100000000
7 Arjun 7 Actor 31 M 90000000
8 Naresh 8 Actor 29 M 30000000
9 Nithin 9 Actor 30 M 30000000
10 Puri 10 Director 38 M 100000000
a<-read.csv("X:T11.csv",stringsAsFactors=F)
Bins<-as.data.frame(table(cut(a$AGE,breaks=seq(0,100,by=20),
labels=c("0-20","20-40","40-60","60-80","80-100"))))
colnames(Bins) <- c("Bins", "count")
Bins
HI,
Above code I am Using with Which one Integer then I am Binning a$AGE. Now ,
My dataset Not Mention Variable Names Then How to Find Binning.(How bin
above dataset )
More information about the R-help
mailing list