Re: [R] Subtracting elements of a vector from each other stepwise

2013-09-13 Thread Michael Budnick
gt; >>> #4 12 10 6 0 > >>> which(dist(x)==min(dist(x))) > >>> #[1] 1 > >>> A.K. > >> > >>Yes, but you need to set the diagonal to NA, or something -- the > >OP > >> doesn't want to include self-comparison. It also

Re: [R] Subtracting elements of a vector from each other stepwise

2013-09-12 Thread Ben Bolker
On 13-09-11 07:06 PM, Ben Harrison wrote: > If I were Michael (OP) right now, I think my head would be spinning. > > As a newbie myself, I know how hard it is to read R code for the first > time, so could it also be part of the newsgroup etiquette to at least > partially explain provided code to n

Re: [R] Subtracting elements of a vector from each other stepwise

2013-09-11 Thread Jeff Newmiller
to use >> arr.ind=TRUE in which(). You're right that dist() would be a hair >more >> efficient that outer(...), though >> >>> >>> >>> >>> - Original Message - >>> From: Ben Bolker >>> To: r-h...@stat.math.

Re: [R] Subtracting elements of a vector from each other stepwise

2013-09-11 Thread Ben Harrison
Michael Budnick snet.net> To: r-help r-project.org Cc: Sent: Tuesday, September 10, 2013 4:06 PM Subject: [R] Subtracting elements of a vector from each other stepwise I am trying to figure out how to create a loop that will take the difference of each member of a vector from each other and also

Re: [R] Subtracting elements of a vector from each other stepwise

2013-09-10 Thread arun
r-help@r-project.org Cc: Sent: Tuesday, September 10, 2013 4:06 PM Subject: [R] Subtracting elements of a vector from each other stepwise I am trying to figure out how to create a loop that will take the difference of each member of a vector from each other and also spit out which one has the least diffe

[R] Subtracting elements of a vector from each other stepwise

2013-09-10 Thread Michael Budnick
I am trying to figure out how to create a loop that will take the difference of each member of a vector from each other and also spit out which one has the least difference. I do not want the vector member to subtract from itself or it must be able to disregard the 0 obtained from subtracting from

Re: [R] Subtracting elements of a vector from each other stepwise

2013-09-10 Thread Ben Bolker
gt; From: Michael Budnick snet.net> > To: r-help r-project.org > Cc: > Sent: Tuesday, September 10, 2013 4:06 PM > Subject: [R] Subtracting elements of a vector from each other stepwise > > I am trying to figure out how to create a loop that will take the > difference of e

Re: [R] Subtracting elements of a vector from each other stepwise

2013-09-10 Thread Ben Bolker
> > > - Original Message - > From: Ben Bolker > To: r-h...@stat.math.ethz.ch > Cc: > Sent: Tuesday, September 10, 2013 5:39 PM > Subject: Re: [R] Subtracting elements of a vector from each other stepwise > > arun yahoo.com> writes: > >> >>

Re: [R] Subtracting elements of a vector from each other stepwise

2013-09-10 Thread arun
: Sent: Tuesday, September 10, 2013 5:39 PM Subject: Re: [R] Subtracting elements of a vector from each other stepwise arun yahoo.com> writes: > > Hi, > Not sure this is what you wanted: > >  sapply(seq_along(x), function(i) {x1<- x[i]; x2<- x[-i]; x3<-x2[whi