powered by
Generates a regular 1D grid from a 1D point set, optionally with weights; similar to hist.
griddata(x, w = NULL, n = 20, xlim = NULL)
N-element vector of points
optional N-element vector with weights
scalar specifying the number of equally space grid cells
2-element vector specifying the data range (data cropped if necessary). If not given, xlim is set to the full range of x.
Returns a list of items
n-element vector of cell-center x-coordinates
(n+1)-element vector of cell-edge x-coordinates
spacing between x-coordinates
range of xbreak, same as input argument xlim, if given
n-element vector giving the number of points in each grid cell
n-element vector of weighted point counts (masses); only available if w is specified.
w
normalized number densities corresponding to n, such that sum(d)*dx=1.
normalized mass densities corresponding to m, such that sum(c)*dx=1; only available if w is specified.
griddata2
# NOT RUN { set.seed(1) x = runif(2000) g = griddata(x,xlim=c(0,1)) plot(g$x,g$n,xlim=c(0,1),ylim=c(0,max(g$n)),pch=20,type='l') # }
Run the code above in your browser using DataLab