[R] evaluating density objects

ripley@stats.ox.ac.uk ripley at stats.ox.ac.uk
Thu Nov 14 18:17:43 CET 2002

On Thu, 14 Nov 2002, Hinnerk Boriss wrote:

> Is there a way to evaluate "density" objects other than with plot, so
> that I can write data points to a file and plot them with gnuplot? Can
> anyone help?

?density tells you


     If `give.Rkern' is true, the number R(K), otherwise an object with
     class `"density"' whose underlying structure is a list containing
     the following components.

       x: the `n' coordinates of the points where the density is

       y: the estimated density values.


so you could for example do

dens <- density(...)
write.table(data.frame(x=dens$x, y=dens$y), "somefile")

I have no idea why anyone would want to plot in gnuplot rather than in R,
and hence don't know what formats gnuplot accepts.

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