Re: [R] Verify that a grid is uniform

2015-04-07 Thread Marc Lamblin
Yes, it could be a reasonable choice but I am not sure in general. If min(abs(diff(z))) is significant (global minimum or accentuated local minimum) my abscissa is not uniform a priori without performing the control. 2015-04-07 0:55 GMT+02:00 Bert Gunter : > Does not min(abs(diff(z))) give you th

Re: [R] Verify that a grid is uniform

2015-04-06 Thread Bert Gunter
Does not min(abs(diff(z))) give you the scaling you need to set a tolerance? -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." Clifford Stoll On Mon, Apr 6, 2015 at 2:55 PM, M

Re: [R] Verify that a grid is uniform

2015-04-06 Thread Marc Lamblin
The first solution with diff works for uniform abscissa only with integer values. z <- seq(0, 10, length=100) all(diff(z) == z[2] - z[1] ) ## FALSE In this case, as you recommended, I could use signif or round or a tolerance for real numbers. In my particular case, in order to set a tolerance, I

Re: [R] Verify that a grid is uniform

2015-04-06 Thread Bert Gunter
... correction: you need to use absolute value for the comparison, of course. all(abs(diff(z) - z[2] + z[1]) < tol) -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." Clifford Sto

Re: [R] Verify that a grid is uniform

2015-04-06 Thread Bert Gunter
Perhaps ?diff might be useful here: z <- runif(20) all(diff(z) == z[2] - z[1] ) ## FALSE z <- seq_len(10) all(diff(z) == z[2] - z[1] ) ##TRUE You can use signif or round as before to allow for "near uniformity" or use ?zapsmall or an explicit comparison with a tolerancec instead of ==, e.g. all(

Re: [R] Verify that a grid is uniform

2015-04-06 Thread Marc Lamblin
The aim is to control if a given abscissa/grid is uniform or not. Abscissa in generic vector of real ordered numbers. Here a reproducibile code: # uniform abscissa/grid abscissa1 <- seq(0, 1, length=100) # non-uniform abscissa/grid abscissa2 <- sort(runif(100)) control1 <- all(signif(abscissa1[1

Re: [R] Verify that a grid is uniform

2015-04-06 Thread Sarah Goslee
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://stackoverflo

[R] Verify that a grid is uniform

2015-04-06 Thread Marc Lamblin
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 { #