I need to deciles data containing more than one variables using any one variable. I am using script below :
id <-c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20) tot <-c(1230, 1230, 2345, 3456, 456, 4356, 123, 124, 987, 785, 5646, 345, 2345, 3456, 456, 4356, 123, 124, 987, 785) data <- data.frame ( cbind(id , tot)) data$decile<-cut(data$tot,quantile(data$tot,(0:10)/10),include.lowest=TRUE,lable=TRUE) data$decile New variable "decile" taking values as below where as I need it should take values from 1,2..10, Where I am going wrong? ----------------- You have a factor with labels, but if you use as.numeric(data$decile) you will get what you were aiming for. -- david -- View this message in context: http://r.789695.n4.nabble.com/Creating-deciles-on-data-using-one-variable-tp3973086p3973412.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list 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.