[R] intervals and data frames

2005-06-06 Thread Erin Hodgess
Dear R people: I have a vector which runs from -1 to 1, by .1, inclusively. Easy to set up. x - seq(-1,1,.1) I then sample 3 numbers from x. y - sample(x, 3) Suppose one of my values is -0.7. I want to set up an interval around that y1 - pmax(y-0.1,-1) y2 - pmin(y+0.1,1) For the value -.7,

RE: [R] intervals and data frames

2005-06-06 Thread Huntsinger, Reid
the possibilities. Reid Huntsinger -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Erin Hodgess Sent: Monday, June 06, 2005 11:51 AM To: r-help@stat.math.ethz.ch Subject: [R] intervals and data frames Dear R people: I have a vector which runs from -1 to 1, by .1

Re: [R] intervals and data frames

2005-06-06 Thread Sebastian Luque
Hi, I thought this would be close to what you wanted: x - seq(-1,1,.1) y - sample(x, 3) r1 - vector(mode = numeric, length = length(x)) sapply(y, function(k) { y1 - max(k - 0.1, -1) y2 - min(k + 0.1, 1) r1[x = y1 x = y2] - 1 r1 }) but found that it's not replacing 3 elements of r1