, September 10, 2013 5:39 PM
Subject: Re: [R] Subtracting elements of a vector from each other
stepwise
arun smartpink111 at 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[which.min(abs(x1-x2))];c(x1,x3
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
of a vector from each other stepwise
arun smartpink111 at 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[which.min(abs(x1-x2))];c(x1,x3)})
# [,1] [,2] [,3] [,4]
#[1,] 17 19 23 29
#[2,] 19 17 19 23
A.K
elements of a vector from each other
stepwise
arun smartpink111 at 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[which.min(abs(x1-x2))];c(x1,x3)})
# [,1] [,2] [,3] [,4]
#[1,] 17 19 23 29
#[2,] 19 17
...@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 smartpink111 at 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[which.min(abs
...@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 smartpink111 at 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[which.min
arun smartpink111 at 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[which.min(abs(x1-x2))];c(x1,x3)})
# [,1] [,2] [,3] [,4]
#[1,] 17 19 23 29
#[2,] 19 17 19 23
A.K.
It's a little inefficient
Hi,
Not sure this is what you wanted:
sapply(seq_along(x), function(i) {x1- x[i]; x2- x[-i];
x3-x2[which.min(abs(x1-x2))];c(x1,x3)})
# [,1] [,2] [,3] [,4]
#[1,] 17 19 23 29
#[2,] 19 17 19 23
A.K.
- Original Message -
From: Michael Budnick mbudnic...@snet.net
To:
8 matches
Mail list logo