z5.
>
>A.K.
>
>
>
>
>
>
>
>
>From: C W
>To: arun
>Cc: R help ; Sarah Goslee
>Sent: Wednesday, December 5, 2012 4:47 PM
>
>Subject: Re: [R] data manipulation between vector and matrix
>
>
>Thanks for the
ystem elapsed
# 0.008 0.000 0.009
A.K.
From: C W
To: arun
Cc: R help ; Sarah Goslee
Sent: Wednesday, December 5, 2012 4:11 PM
Subject: Re: [R] data manipulation between vector and matrix
thanks, I knew about apply, but did not you you can put plu
0.008 0.000 0.009
>
>
> A.K.
>
>
>
>
>
> ________
> From: C W
> To: arun
> Cc: R help ; Sarah Goslee
> Sent: Wednesday, December 5, 2012 4:11 PM
> Subject: Re: [R] data manipulation between vector and matrix
>
>
>
HI,
In addition to ?sweep(), you can use
apply(-mat,1,`+`,x)
#or
library(plyr)
aaply(-mat,1,"+",x)
A.K.
- Original Message -
From: C W
To: Sarah Goslee
Cc: r-help
Sent: Wednesday, December 5, 2012 1:51 PM
Subject: Re: [R] data manipulation between vector and matr
aaply(-mat,1,"+",x)
>
>
> A.K.
>
>
>
>
>
>
> - Original Message -
> From: C W
> To: Sarah Goslee
> Cc: r-help
> Sent: Wednesday, December 5, 2012 1:51 PM
> Subject: Re: [R] data manipulation between vector and matrix
>
> Thanks, Sarah. First time
Thanks, Sarah. First time heard about sweep(), it worked just the way I
wanted.
Mike
On Wed, Dec 5, 2012 at 1:42 PM, Sarah Goslee wrote:
> Hi,
>
> On Wed, Dec 5, 2012 at 1:30 PM, C W wrote:
> > Dear list,
> > I was curious how to subtract a vector from matrix?
> >
> > Say, I have
> >
> > mat <
Hi,
On Wed, Dec 5, 2012 at 1:30 PM, C W wrote:
> Dear list,
> I was curious how to subtract a vector from matrix?
>
> Say, I have
>
> mat <- matrix(1:40, nrow=20, ncol=2)
>
> x <-c(1,2)
Thanks for the actual reproducible example.
> I want,
>
> x-mat[1,] and x-mat[2,], and so on... Basically, su
The only solution I found was
x-t(mu)
Is there a better way?
Mike
On Wed, Dec 5, 2012 at 1:30 PM, C W wrote:
> Dear list,
> I was curious how to subtract a vector from matrix?
>
> Say, I have
>
> mat <- matrix(1:40, nrow=20, ncol=2)
>
> x <-c(1,2)
>
> I want,
>
> x-mat[1,] and x-mat[2,], and so
Dear list,
I was curious how to subtract a vector from matrix?
Say, I have
mat <- matrix(1:40, nrow=20, ncol=2)
x <-c(1,2)
I want,
x-mat[1,] and x-mat[2,], and so on... Basically, subtract column elements
of x against column elements in mat.
But x-mat won't do it.
Thanks,
Mike
[[al
9 matches
Mail list logo