Skip to content

lattice and histogram

3 messages · (Ted Harding), Deepayan Sarkar

#
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
--- Ted.Harding at nessie.mcc.ac.uk wrote:
A more typical and elegant usage would be

histogram(~X|F, data = DATA, [...])
This is definitely a bug, which should be fixed in the
next release of lattice. For now, what I can suggest
is to change a couple of lines in the histogram()
function. Replace


xlim.l <- min(xlim.l, tem$xlim[1])
xlim.u <- max(xlim.u, tem$xlim[2])

by


xlim.l <- min(xlim.l, tem$xlim[1], na.rm = TRUE)
xlim.u <- max(xlim.u, tem$xlim[2], na.rm = TRUE)

This should take care of your problem, though there
still might be some other similar loopholes.

PS: variable names like F might cause problems, since
a lot of the lattice code use F/T instead of
FALSE/TRUE. Again, this should not be so, and will be
fixed in the next release.


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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 28-Jul-01 Deepayan Sarkar wrote:
Thanks, I'll give it a try.
That hadn't occurred to me! (I was using A, B, C, ... as
variable names because those are the letters identifying
columns in the spreadsheet I imported the data from).
But you're surely right: the user should not need to
bear in mind a lot of reserved symbols which he should
not use as variable names. Looking forward to the next
release!

Ted.1

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