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)) 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? Thank you! Aleksey -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Aleksey Naumov <naumov at acsu.buffalo.edu> writes:> 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)) > > 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?I don't have V&R with me, but does this look somewhat right? contour(table(cut(x,pretty(x,8)),cut(y,pretty(y,8)))) [of course the table() construction won't actually plot a 2d histogram...] -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._