there is no need for 'apply' here, because R can handle vectors. ord<-m[,1]+m[,2]/m[,1]
Am 02.02.2011 15:12, schrieb ADias: > > Hi > > I have this function and this matrix: > > function(x,y) x+y/x > > m<-matrix(c(1,2,4,2,10,8),3,2) > >> m > [,1] [,2] > [1,] 1 2 > [2,] 2 10 > [3,] 4 8 > > each row represent a point (x,y) in a chart and I want via my fucntion to > calculate the image in order to get this results: > > for point (1,2) I would get 1+2/1 = 3 > for point (2,10) I would get 2+10/2 = 7 > for point (4,8) I would get 4+8/4 = 6 > > I have tried using sapply here but I get this: > >> sapply(m,function(x,y) x+y/x) > Error in y/x : 'y' is missing > > what I am doing wrong? > > thanks > ADias -- Eik Vettorazzi Institut für Medizinische Biometrie und Epidemiologie Universitätsklinikum Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790 ______________________________________________ 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.