[R] Verify that a grid is uniform

Sarah Goslee sarah.goslee at gmail.com
Mon Apr 6 16:32:53 CEST 2015


Without a reproducible example that includes some sample data (fake is
fine), the code you used (NOT in HTML format), and some clear idea of
what output you expect, it's impossible to figure out how to help you.
Here are some suggestions for creating a good reproducible example:
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

Without knowing what you want, it looks like abscissa is a vector, and
so I'm not sure how this defines a grid, but
length(unique(diff(vec)))
might help. Note that this DOES NOT account for machine precision in any way.

Sarah

On Mon, Apr 6, 2015 at 7:50 AM, Marc Lamblin <marcgg.lamblin at gmail.com> wrote:
> I need to control of a given grid is uniform. This control using signif
> until now works:
>
> if (all(signif(abscissa[1:(length(abscissa) - 1) + 1] -
> abscissa[1:(length(abscissa) - 1)]) == signif(rep((range(abscissa)[2] -
>          range(abscissa)[1])/(length(abscissa) - 1), length(abscissa) -
> 1)))) {
> # other stuff
> }
>
> Does someone have some suggestions to improve this control? Thanks in
> advance!! :)
>
> Marc
>
>         [[alternative HTML version deleted]]
>


-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list