[S] data subset with NA values only in a Trellis graph

Andreas Krause (Andreas.Krause@genedata.com)
Tue, 09 Jun 1998 18:55:39 +0200

Trellis graph functions exit (sometimes with an unclear message) if one of the
subsets to graph contains only missings.
xdata <- data.frame (x=rnorm(50), sub=sample(letters[1:4], 50, replace=T))
xdata$x[xdata$sub=="d"] <- NA # set all x where sub="d" to NA

Trellis panel functions don't really like being passed only NA's

histogram (~ x | sub, data=xdata)
Error in histogram( ~ x | sub, data = xdata): breaks do not span the range of x
in plot 4

# qqmath comes up with a proper message at least
qqmath (~ x | sub, xdata)
Error: naxy2: Vector of all missing values

Does anybody have a nice approach of circumventing this dropout, preferrably
with an empty graph as indication that the data set consists of NA's only ?

Btw, other functions have other interesting behavior:
by (xdata$x, xdata$sub, summary) # fine
by (xdata$x, xdata$sub, mean)
Error in as.double: Cannot coerce mode list to double: .Data = list(..

This was run in an SGI Splus 3.4 environment and under Splus 4 Windoze.

andreas krause

Dr. Andreas Krause, GeneData AG, Postfach 254, CH-4016 Basel
mailto:Andreas.Krause@genedata.com   http://www.genedata.com
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news