Re: [R] "spreading out" a numeric vector

2008-03-24 Thread Levi Waldron
Would this function be worth submitting to some existing cran library? I'd be willing to document it and add error-checking if there is somewhere that it belongs (with credit to Greg of course, unless Greg wants to submit it himself). I am using it in conjunction with a function I wrote which dra

Re: [R] "spreading out" a numeric vector

2008-03-24 Thread Levi Waldron
*Thank you* Greg, this function works perfectly! I had imagined that the ideal solution would iteratively modify the vector to fix new violations of mindiff created by each subsequent spreading of tight clusters, but couldn't figure how to do it. A small note, the vector x must be sorted before u

Re: [R] "spreading out" a numeric vector

2008-03-24 Thread Greg Snow
-Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Levi Waldron > Sent: Saturday, March 22, 2008 7:03 PM > To: R-help mailing list > Subject: [R] "spreading out" a numeric vector > > I am creating a timeline plot, but runn

Re: [R] "spreading out" a numeric vector

2008-03-23 Thread Jim Lemon
Levi Waldron wrote: > I am creating a timeline plot, but running into a problem in positions > where the values to plot are too close together to print the text > without overlap... Hi Levi, This may not be what you want, but spread.labels in the plotrix package tries to evenly space labels for u

Re: [R] "spreading out" a numeric vector

2008-03-22 Thread Levi Waldron
On Sat, Mar 22, 2008 at 9:58 PM, jim holtman <[EMAIL PROTECTED]> wrote: > Is this close to what you want? > > > spread <- function(x, mindiff=0.5){ > + unique(as.integer(x / mindiff) * mindiff) > + } > > > > > x <- c(1,2,seq(2.1,2.3,0.1),3,4) > > x > [1] 1.0 2.0 2.1 2.2 2.3 3.0 4.0 > > s

Re: [R] "spreading out" a numeric vector

2008-03-22 Thread jim holtman
Is this close to what you want? > spread <- function(x, mindiff=0.5){ + unique(as.integer(x / mindiff) * mindiff) + } > > x <- c(1,2,seq(2.1,2.3,0.1),3,4) > x [1] 1.0 2.0 2.1 2.2 2.3 3.0 4.0 > spread(x) [1] 1 2 3 4 > > spread(x,.2) [1] 1.0 2.0 2.2 3.0 4.0 > On Sat, Mar 22, 2008 at 8:03 PM, L

[R] "spreading out" a numeric vector

2008-03-22 Thread Levi Waldron
I am creating a timeline plot, but running into a problem in positions where the values to plot are too close together to print the text without overlap. The simplest way I can think of to solve this (although there may be other ways?) is to create a new numeric vector whose values are as close as