Hi everyone I'm trying to use sigma2.mat<-apply(ri.mat,2,'-n/2*log(sum(ri.mat^2)/n)') but it's not working. Is it wrong to use that kind of FUN in apply ? or am I doing something wrong ?! Thank's ernesto -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Jos? Ernesto Jardim <ernesto at ipimar.pt> writes:> Hi everyone > > I'm trying to use > > sigma2.mat<-apply(ri.mat,2,'-n/2*log(sum(ri.mat^2)/n)') > > but it's not working. > > Is it wrong to use that kind of FUN in apply ? or am I doing something > wrong ?!Yes and yes... That syntax means that you want to use a function called "-n/2*log(sum(ri.mat^2)/n)". I think you mean sigma2.mat<-apply(ri.mat,2, function(x) -n/2*log(sum(x^2)/n) ) (assuming that the variable "n" exists, otherwise you might something like function(x){n<-length(x); -n/2*log(sum(x^2)/n)} ) -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Jos? Ernesto Jardim wrote:> > Hi everyone > > I'm trying to use > > sigma2.mat<-apply(ri.mat,2,'-n/2*log(sum(ri.mat^2)/n)') > > but it's not working. > > Is it wrong to use that kind of FUN in apply ? or am I doing something > wrong ?!I think you can construct a new FUN to apply for example: fun<-function(x,n){ y_-n/2*log(sum(x^2)/n) return(y) } and then apply it sigma2.mat<-apply(ri.mat,2,fun) or use sigma2.mat<-apply(ri.mat,2, function(x,n){-n/2*log(sum(x^2)/n)} ) -- =============================================================Alvaro Colina |-|o||o||o||o||o||o||o||o||o|- Area de Quimica Analitica | Pza. Misael Banuelos s/n Facultad de Ciencias | 09001. Burgos. Spain Universidad de Burgos | Phone: 34-947-258817 e-mail: acosa at ubu.es | FAX: 34-947-258831 =============================================================-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Fri, 4 Aug 2000, Jos? Ernesto Jardim wrote:> sigma2.mat<-apply(ri.mat,2,'-n/2*log(sum(ri.mat^2)/n)')apply( data, 2, function(x)-n/2*log(x) ) ...perhaps helps P. ** To YOU I'm an atheist; to God, I'm the Loyal Opposition. Woody Allen ** P.Malewski Tel.: 0531 500965 Maschplatz 8 Email: P.Malewski at tu-bs.de ************************38114 Braunschweig******************************** -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._