Hi Henrique and Erik I still get a error. See below.
apply(veh_drg_animal1[ ,c("readCount","gene_length")] ,1, stats, total=55000000) Error in FUN(newX[, i], ...) : element 1 is empty; the part of the args list of '(' being evaluated was: (length_gene) stats<- function(count,length_gene,total) { ( count/( total * (length_gene ) ) ) * ( 10^9) } Thanks! -Abhi On Tue, Apr 27, 2010 at 2:18 PM, Henrique Dallazuanna <www...@gmail.com> wrote: > Try this: > > apply( veh_drg_animal1[ , c("readCount","gene_length")] ,1, stats, agr3 = > your_constant) > > > On Tue, Apr 27, 2010 at 3:10 PM, Abhishek Pratap <abhishek....@gmail.com> > wrote: >> >> Hi All >> >> Slightly lost on how should I pass values to a function I am calling >> using apply. >> >> >> apply( veh_drg_animal1[ , c("readCount","gene_length")] ,1, stats() ) >> >> here stats is a custom function where I want to pass two parameters >> from data frame as shown and a third argument which is constant per >> instance of apply. >> >> >> stats <- function ( arg1,agr2,agr3) { >> ## computation using three parameters >> } >> >> ______________________________________________ >> 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. > > > > -- > Henrique Dallazuanna > Curitiba-Paraná-Brasil > 25° 25' 40" S 49° 16' 22" O > ______________________________________________ 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.