[R] hist2d() function in R?
Prof Brian D Ripley
ripley at stats.ox.ac.uk
Mon Mar 27 08:20:32 CEST 2000
On Sun, 26 Mar 2000, Aleksey Naumov wrote:
> Dear R users,
>
> I am just starting with R (v. 1.0.0) and I use Vehables & Ripley's
> MASS book for examples.
> In the intro session, there is an example of a 2D histogram on an 8x8
> grid:
>
> x <- rnorm(1000)
> y <- rnorm(1000)
> contour(hist2d(x,y,,,8,8))
Not in the current edition of MASS! (Not even in the 1997 second edition.)
Also, that is not a 2D histogram, but a 2D density plot. (The comment
refers to that and the next two lines.)
> R complains:
>
> Error in contour(hist2d(x, y, , , 8, 8)) :
> couldn't find function "hist2d"
>
> I looked for hist2d() in the manual (including the latest development
> version), but didn't
> find it. Is there such a function or a suitable substitute?
The R scripts for MASS3 (in the MASS package in the VR bundle) have
x <- rnorm(1000)
y <- rnorm(1000)
dd <- kde2d(x,y)
contour(dd)
persp(dd, theta=-30, phi=30, d=5)
image(dd)
which does work in R, and is a much improved substitute.
In general, if you want to use MASS with R you need the 1999 edition and
to look at the scripts for R (and the on-line R complements).
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list