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,f
On 18-04-2013, at 07:20, 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,func
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]
3 matches
Mail list logo