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:> 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) )A more typical and elegant usage would be histogram(~X|F, data = DATA, [...])> 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.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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
I've got some data that is recorded at various times during the day. I create a time stamp is created from date and time strings like this: > timestamp <- strptime( paste( datestring, timestring), "%D %X" ) Then I'd like to use lattice to plot the time dependence by doing something like > xyplot( value ~ timestamp | subject ) This fails with Error in as.double.default(x) : (list) object cannot be coerced to vector type 14 In addition: Warning message: Both x and y should be numeric in: xyplot( value ~ timestamp | subject ) I was sure I saw something like this on r-help recently, but I can't seem to track it down now. Can anyone help me out? Thanks, Mike -- Michael A. Miller mmiller3 at iupui.edu Imaging Sciences, Department of Radiology, IU School of Medicine -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._