Re: [R] Element-by-element division

2015-07-29 Thread peter dalgaard
> On 28 Jul 2015, at 15:53 , Sarah Goslee wrote: > > Sure, there are lots of ways to do everything in R. But mixing in > apply muddles the issue, since apply() and sweep() use different logic > to determine MARGIN. Actually, apply() and sweep() were designed together and use exactly the SAME l

Re: [R] Element-by-element division

2015-07-28 Thread Sarah Goslee
to:r-help-boun...@r-project.org] On Behalf Of Sarah Goslee > Sent: Tuesday, July 28, 2015 8:32 AM > To: Steven Yen; r-help > Subject: Re: [R] Element-by-element division > > Hi, > > It's a good idea to keep discussion on R-help, so others can > participate and the results

Re: [R] Element-by-element division

2015-07-28 Thread David L Carlson
opology Texas A&M University College Station, TX 77840-4352 -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Sarah Goslee Sent: Tuesday, July 28, 2015 8:32 AM To: Steven Yen; r-help Subject: Re: [R] Element-by-element division Hi, It's a good i

Re: [R] Element-by-element division

2015-07-28 Thread Sarah Goslee
Hi, It's a good idea to keep discussion on R-help, so others can participate and the results make it into the archives. On Mon, Jul 27, 2015 at 9:11 PM, Steven Yen wrote: > Thanks Sarah. That serves my need. I however find ?sweep hard to comprehend. Heh. The help makes it seem more complicated

Re: [R] Element-by-element division

2015-07-27 Thread Sarah Goslee
Hi, See ?sweep For instance, to get your matrix two: > sweep(a, 2, b, "/") [,1] [,2] [1,]2 24 [2,]4 28 [3,]6 32 [4,]8 36 [5,] 10 40 Sarah On Mon, Jul 27, 2015 at 4:04 PM, Steven Yen wrote: > I need help with element-by-element division. Below, matrices a and

[R] Element-by-element division

2015-07-27 Thread Steven Yen
I need help with element-by-element division. Below, matrices a and c are both 5 x 2 and element-by-element division works as (I) expected. What if matrix is 1 by 2: to divide first column of a by b[1] and second column of a by b[2]. I had to go around (two ways) to make it work. In Gauss, these ca