Message-ID: <1320242791779-3973412.post@n4.nabble.com>
Date: 2011-11-02T14:06:31Z
From: David Winsemius
Subject: Creating deciles on data using one variable
In-Reply-To: <1320239988595-3973086.post@n4.nabble.com>
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.