Re: [R] compute values by condition in DF by rownames

2015-02-17 Thread JS Huang
Hi, I like the aggregate version. Here is an implementation with sapply and apply: > data X2 gbm_tcga lusc_tcga ucec_tcga_pub 1 gbm_tcga 1.0 0.14053719 -0.102847164 2 gbm_tcga 1.0 0.04413434 0.013568055 3 gbm_tcga 1.0 -0.200

Re: [R] compute values by condition in DF by rownames

2015-02-17 Thread Karim Mezhoud
Thanks JS I think aggregate function is better. Karim Le 17 févr. 2015 08:33, "JS Huang" a écrit : > Hi, > > I hope that someone can provide a better way to implement it. This is my > implementation. > > > data > X2 gbm_tcga lusc_tcga ucec_tcga_pub > 1 gbm_tcga 1.000

Re: [R] compute values by condition in DF by rownames

2015-02-16 Thread JS Huang
Hi, I hope that someone can provide a better way to implement it. This is my implementation. > data X2 gbm_tcga lusc_tcga ucec_tcga_pub 1 gbm_tcga 1.0 0.14053719 -0.102847164 2 gbm_tcga 1.0 0.04413434 0.013568055 3 gbm_tcga 1.00

Re: [R] compute values by condition in DF by rownames

2015-02-16 Thread PIKAL Petr
I named your data frame temp > aggregate(temp[,-1], list(temp[,1]), function(x) sum(abs(x)>.2)) Group.1 gbm_tcga lusc_tcga ucec_tcga_pub 1 gbm_tcga4 1 0 2 lusc_tcga1 4 0 3 ucec_tcga_pub0 0 4 Cheer