[R] intervals and data frames

Erin Hodgess hodgess at gator.dt.uh.edu
Mon Jun 6 17:51:14 CEST 2005


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, the interval will run from -.8 to -.6.
There will be several intervals.

Again, nothing interesting so far.

However, now I want to set up something that I will call
r1.  Essentially, r1 "runs" between -1 and 1 as well.
I want to place a value in r1 between -.8 and -.6 for my interval,
and zeros elsewhere.

I'm trying to use a data frame in which the first column represents
the values from -1 to 1.  The remaining columns are initially set to
zero.  Also, I'm trying to avoid loops.

Any suggestions would be much appreciated.

Thanks in advance,
Sincerely
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: hodgess at gator.uhd.edu




More information about the R-help mailing list