Re: [R] subgroup-based quantiles

2012-11-30 Thread R Kozarski
Dear Arun and Rui, thank you for replying, your commands are very helpful. Before you replied, Ive solved the issue with the following approach (for quartiles): myFun <- function(x, GENDER) { x.male <- cut(x, labels=c(1:4), breaks=quantile(split(x,GENDER) $ '1', seq(0,1,.25), na.rm=TRUE),incl

Re: [R] subgroup-based quantiles

2012-11-30 Thread arun
64 5 A.K. - Original Message - From: Rui Barradas To: R Kozarski Cc: r-help@r-project.org Sent: Friday, November 30, 2012 1:07 PM Subject: Re: [R] subgroup-based quantiles Hello, If you want Age quantiles by gender, you have to split the data by gender, apply the same code t

Re: [R] subgroup-based quantiles

2012-11-30 Thread Rui Barradas
1 #2 1 5810 #3 1 54 1 #4 2 7110 #5 2 64 5 A.K. - Original Message - From: Rui Barradas To: R Kozarski Cc: r-help@r-project.org Sent: Friday, November 30, 2012 1:07 PM Subject: Re: [R] subgroup-based quantiles Hello, If you

Re: [R] subgroup-based quantiles

2012-11-30 Thread Rui Barradas
Hello, If you want Age quantiles by gender, you have to split the data by gender, apply the same code then recombine the result. fun <- function(x){ Age_group <- cut(x[, "Age"], labels=c(1:10), breaks=quantile(x[, "Age"], seq(0,1,.1)), include.lowest = TRUE) cbind(x, A

[R] subgroup-based quantiles

2012-11-30 Thread R Kozarski
Dear R users, given the patient sample with their Gender and Age GENDER Age [1,] 2 45 [2,] 1 58 [3,] 1 54 [4,] 2 71 [5,] 2 64 ... I would like to create an another column which groups the patients wrt Gender specific Age quantiles, following me