[R] Fwd: which is faster for or apply

2014-12-31 Thread Karim Mezhoud
Thanks, It seems for loop spends less time ;) with dim(DataFrame) [1] 338 70 For loop has user system elapsed 0.012 0.000 0.012 and apply has user system elapsed 0.020 0.000 0.021 Ô__ c/ /'_;kmezhoud (*) \(*) ⴽⴰⵔⵉⵎ ⵎⴻⵣⵀⵓⴷ http://bioinformatics.tn/ On Wed, Dec

Re: [R] Fwd: which is faster for or apply

2014-12-31 Thread Martin Morgan
On 12/31/2014 12:22 AM, Karim Mezhoud wrote: Thanks, It seems for loop spends less time ;) with dim(DataFrame) [1] 338 70 For loop has user system elapsed 0.012 0.000 0.012 and apply has user system elapsed 0.020 0.000 0.021 The timings are so short that the answer

Re: [R] Fwd: which is faster for or apply

2014-12-31 Thread Karim Mezhoud
Many Many Many thanks! it is a demonstrative lesson. I need time to test all examples :) Thank you for your time and support. Happy and Healthy New Year Ô__ c/ /'_;kmezhoud (*) \(*) ⴽⴰⵔⵉⵎ ⵎⴻⵣⵀⵓⴷ http://bioinformatics.tn/ On Wed, Dec 31, 2014 at 2:38 PM, Martin Morgan

Re: [R] Fwd: which is faster for or apply

2014-12-31 Thread Karim Mezhoud
Concretely I request cbioportal through cgsdr package. Depending of Cases and Genetic profiles I receive in general data.frame with heterogeneous structure. The bad one if the returned data.frame is composed by numeric and character columns. in this case numeric columns are considered as factor.

Re: [R] Fwd: which is faster for or apply

2014-12-31 Thread Karim Mezhoud
Yes the last one this the best. But I need to test if returned data.frame is with factor or character: cidx - sapply(df, is.factor) or cidx - sapply(df, is.character) Thanks Ô__ c/ /'_;kmezhoud (*) \(*) ⴽⴰⵔⵉⵎ ⵎⴻⵣⵀⵓⴷ http://bioinformatics.tn/ On Wed, Dec 31, 2014 at 5:24 PM, Karim

Re: [R] Fwd: which is faster for or apply

2014-12-31 Thread Karim Mezhoud
for both cidx - !(sapply(df, is.numeric)) df[cidx] - lapply(df[cidx], as.numeric) Ô__ c/ /'_;kmezhoud (*) \(*) ⴽⴰⵔⵉⵎ ⵎⴻⵣⵀⵓⴷ http://bioinformatics.tn/ On Wed, Dec 31, 2014 at 5:51 PM, Karim Mezhoud kmezh...@gmail.com wrote: Yes the last one this the best. But I need to test if

Re: [R] Fwd: which is faster for or apply

2014-12-31 Thread William Dunlap
But this heterogeneity comes even with only supposed numeric data.frame (gene expression). here an example ibrary(cgdsr) GeneList - c(DDR2, HPGDS, MS4A2,SSUH2,MLH1 ,MSH2, ATM ,ATR, MDC1 ,PARP1) cgds-CGDS(http://www.cbioportal.org/public-portal/;) str(getProfileData(cgds,GeneList,

Re: [R] Fwd: which is faster for or apply

2014-12-31 Thread Karim Mezhoud
Thanks, please find what I got: str(getProfileData(cgds,GeneList, stad_tcga_methylation_hm27,stad_tcga_methylation_hm27)) 'data.frame':48 obs. of 10 variables: $ ATM : num NA NA NA NA NA NA NA NA NA NA ... $ ATR : num NA NA NA NA NA NA NA NA NA NA ... $ DDR2 : num 0.714 0.857 0.549