[R] Hmisc xYplot won't do conditioning on factors?

Mark Difford mark_difford at yahoo.co.uk
Fri Feb 29 16:09:11 CET 2008


Hi Ivan,

>> It appears that xYplot, unlike "standard" xyplot (or coplot to that
>> matter)
>> does not accept factors as x variable in formula.

To add to what you have said.  It may not be too well documented in ?xYplot,
but xYplot() is really designed to do a number of very useful things with
two sets of _numeric_ variables, viz x and y.

The help file for xYplot() does also mention the "subfunction"
numericScale(), about which it says:

"numericScale is a utility function that facilitates using xYplot to plot
variables that are not considered to be numeric but which can readily be
converted to numeric using as.numeric()."

This does what you want, and a little bit more (for timeDate variables).  It
also documents what you say is not documented;)

HTH, Mark.


Ivan Adzhubey wrote:
> 
> Hi,
> 
> Since nobody replied, I'd rather post this self-reply for the sake of 
> documenting the solution.
> 
> It appears that xYplot, unlike "standard" xyplot (or coplot to that
> matter) 
> does not accept factors as x variable in formula. With x converted to
> numeric 
> everything worked as expected. This small discrepancy was not documented
> on 
> xYplot help page.
> 
> --Ivan
> 
> 
> On Tuesday 26 February 2008 07:47:14 pm Ivan Adzhubey wrote:
>> Hi,
>>
>> I am trying to replace (lattice) standard xyplot with xYplot variant from
>> Hmisc package to be able to add error bars to my plots. However, this
>> does
>> not work, e.g:
>>
>> library(lattice)
>> d <- data.frame(
>> 	SKU=gl(3, 1, 21, labels=c("a", "b", "c")),
>> 	Weekday=gl(7, 3, 21),
>> 	QCRate=runif(21))
>>
>> xyplot(QCRate ~ Weekday | SKU, data=d)
>>
>> (this plots nice 3 panels as per a,b,c conditionals)
>>
>> library(Hmisc)
>>
>> > xYplot(QCRate ~ Weekday | SKU, data=d)
>>
>> Error in Summary.factor(1:7, na.rm = TRUE) :
>>   range not meaningful for factors
>>
>> Is there a workaround?
>>
>> Thanks,
>> Ivan
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: http://www.nabble.com/Hmisc-xYplot-won%27t-do-conditioning-on-factors--tp15703668p15760460.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list