[R] xYplot error

Frank Harrell f.harrell at Vanderbilt.Edu
Wed Jul 28 15:17:32 CEST 2010



Frank E Harrell Jr   Professor and Chairman        School of Medicine
                      Department of Biostatistics   Vanderbilt University

On Wed, 28 Jul 2010, Kang Min wrote:

> Hi Frank,
>
> Thanks for the suggestion. using numericScale() does work for Dotplot,
> but there're still a few issues:
>
> 1. My factor names are Plot A, PF, MSF, and YSF, so numericScale turns
> that into 3, 2, 1, 4 and the x-axis is plotted 1, 2, 3, 4. Is there
> any way I can retain the same order on the graph?

Not sure why you are using numericScale.  You can use the original 
factor variable.  If you need to re-order its levels for plotting 
using reorder.factor.

  >
> 2. I can't get the error bars displayed even after using
> method="bars", only the mean, lower and upper bounds of the data as
> points.
>
> This the line I used: Dotplot(cbind(mort, mort + stand, mort - stand)
> ~ numericScale(site) | type, data = mort, method="bands")

That looks OK but I can't test it right now.  Please continue to have 
a look, and if you still don't see the problem provide a tiny 
reproducible example with self-contained data I can access.

Frank

  >
> Thanks for your help.
>
> KM
>
> On Jul 27, 9:58 pm, Frank Harrell <f.harr... at vanderbilt.edu> wrote:
>> If the x-axis variable is really a factor, xYplot will not handle it.
>> You probably need a dot chart instead (see Hmisc's Dotplot).
>>
>> Note that it is unlikely that the confidence intervals are really
>> symmetric.
>> Frank
>>
>>
>>
>> On Tue, 27 Jul 2010, Kang Min wrote:
>>> Hi,
>>
>>> I'm trying to plot a graph with error bars using xYplot in the Hmisc
>>> package. My data looks like this.
>>
>>> mort                    stand         site    type
>>> 0.042512776   0.017854525   Plot A   ST
>>> 0.010459803   0.005573305     PF      ST
>>> 0.005188321   0.006842107    MSF    ST
>>> 0.004276068   0.011592129    YSF     ST
>>> 0.044586495   0.035225266   Plot A   LD
>>> 0.038810662   0.037355408     PF     LD
>>> 0.027567430   0.020523820    MSF   LD
>>> 0.024698872   0.020320976    YSF   LD
>>
>>> Having read previous posts on xYplot being unable to plot x-axis as
>>> factors, I used numericScale, but I still get this error.
>>
>>> Error in label.default(xv, units = TRUE, plot = TRUE, default =
>>> as.character(xvname),  :
>>>  the default string cannot be of length greater then one
>>
>>> I used:
>>
>>> xYplot(cbind(mort, mort + stand, mort - stand) ~ numericScale(site) |
>>> type, method="bars")
>>
>>> Am I missing something or doing something wrong?
>>
>>> Thanks.
>>> KM
>>
>>> ______________________________________________
>>> R-h... at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>
>> ______________________________________________
>> R-h... at r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> 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.
>


More information about the R-help mailing list