Learn R Programming

physx (version 1.0)

griddata: Grid 1D point set

Description

Generates a regular 1D grid from a 1D point set, optionally with weights; similar to hist.

Usage

griddata(x, w = NULL, n = 20, xlim = NULL)

Arguments

x

N-element vector of points

w

optional N-element vector with weights

n

scalar specifying the number of equally space grid cells

xlim

2-element vector specifying the data range (data cropped if necessary). If not given, xlim is set to the full range of x.

Value

Returns a list of items

x

n-element vector of cell-center x-coordinates

xbreak

(n+1)-element vector of cell-edge x-coordinates

dx

spacing between x-coordinates

xlim

range of xbreak, same as input argument xlim, if given

n

n-element vector giving the number of points in each grid cell

m

n-element vector of weighted point counts (masses); only available if w is specified.

d

normalized number densities corresponding to n, such that sum(d)*dx=1.

c

normalized mass densities corresponding to m, such that sum(c)*dx=1; only available if w is specified.

See Also

griddata2

Examples

Run this code
# 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