Re: [R] Using different function (parameters) with apply

2013-04-18 Thread andrija djurovic
Hi. It would be easier to help you if you show us the result you are trying to obtain. Here are my attempts: sweep(a,2,div, FUN=/) [,1] [,2] [,3] [1,]1 2.0 2.33 [2,]2 2.5 2.67 [3,]3 3.0 3.00 or a/matrix(rep(div,3),ncol=3, byrow=TRUE) [,1] [,2]

Re: [R] Using different function (parameters) with apply

2013-04-18 Thread Berend Hasselman
On 18-04-2013, at 07:20, Sachinthaka Abeywardana sachin.abeyward...@gmail.com wrote: Hi All, I have the following problem (read the commented bit below): a-matrix(1:9,nrow=3) a [,1] [,2] [,3] [1,]147 [2,]258 [3,]369 div-1:3

Re: [R] Using different function (parameters) with apply

2013-04-18 Thread David Winsemius
On Apr 17, 2013, at 10:20 PM, Sachinthaka Abeywardana wrote: Hi All, I have the following problem (read the commented bit below): a-matrix(1:9,nrow=3) a [,1] [,2] [,3] [1,]147 [2,]258 [3,]369 div-1:3 apply(a,2,function(x)x/div)

[R] Using different function (parameters) with apply

2013-04-17 Thread Sachinthaka Abeywardana
Hi All, I have the following problem (read the commented bit below): a-matrix(1:9,nrow=3) a [,1] [,2] [,3] [1,]147 [2,]258 [3,]369 div-1:3 apply(a,2,function(x)x/div) ##want to divide each column by div- instead each row is divided## [,1]