[R] lattice and histogram

(Ted Harding) Ted.Harding at nessie.mcc.ac.uk
Sat Jul 28 17:56:16 CEST 2001


Hello again folks,

Thanks to all for the advice on getting hold of "grid"
and "lattice". I think I'm getting the hang of it.

This produces very satisfying arrays of histograms.
The typical command I am using is

  histogram( ~ DATA.df$X | DATA.df$F, \
             type=c("count"), layout=c(5,5) )

Now I'd like to ask a question slightly more subtle
than "Where is it?"

Reminder: I have data with 25 levels of a factor "F".
There are in fact several variables.

For some variables, say again typically "X", for one
(or sometimes more) level of "F" all values of "X" are
missing (coded as "NA" in the data file).

If I run the above command with such a variable "X",
I get

Error in if (lim[1] > lim[2]) stop("Improper value of limit") ;
        missing value where logical needed

There is no problem if, at given level of "F", "X" is a mixture
of good values and "NA"s; it seems to do the right thing by
simply ignoring the latter. It's the case of "data = empty set"
that seems to cause the trouble.

I can work round this by modifying the original data file,
for each such variable "X", so that the lines with "F" equal
to the offending value[s] are deleted. Using this file, I then
get an array of histograms of "X" for all levels of "F" with
valid data for "X", but of course for no others (so that the
layout in fact changes from plot to plot).

What I would REALLY like to do is, for such values of "F",
to get a "null histogram", i.e. an empty box, where I would have
got a real histogram if I had valid data, but labelled above
(as for the real histograms) with the value of the factor.

Any suggestions or advice?

With thanks yet again,
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 167 1972
Date: 28-Jul-01                                       Time: 16:56:16
------------------------------ XFMail ------------------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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