[R] Plotting an interaction with error bars

Dror D Lev dror.teach at gmail.com
Wed Nov 4 08:36:48 CET 2009


Thank you Jim.

brkdn.plot() seems to be just the function I need.

Still, I wonder if there are lists of labels of the different measures
of central tendency (mct argument) and measures of dispersion (md)?

dror

-----------------------------

On Wed, Nov 4, 2009 at 7:41 AM, Jim Lemon <jim at bitwrit.com.au> wrote:
> On 11/03/2009 10:15 PM, Dror D Lev wrote:
>>
>> Hello.
>>
>> I need to plot a two-way interaction (5 levels X 3) with error bars.
>> The x.factor will be the five-levels var and the trace.factor will be
>> the three level var.
>>
>> I was able to find functions that draw error bars, but still couldn't
>> find a way to draw an interaction plot that looks like what is common
>> in psychological (and related) journals: the lines (three in my need)
>> are plotted in parallel and to avoid overlapping of the error bars a
>> small jitter is added.
>>
>> I was able to make plotmeans() {from gplots} draw the interaction but
>> with the lines plotted side by side (not parallel), resulting in three
>> panes of one line each. When I tried manually super-imposing (looping
>> a draw of one line for each level in the trace.factor) I got the
>> overall look, but the error bars overlap and are hard to distinguish.
>>
>> Another attempt I made was with ci.plot() {from pda}. Inputting an
>> aov() model resulted in a perfect plot of interaction but which is
>> very limited to handle - I was unable to add a legend, change symbols
>> etc.
>>
>> Does anybody knows if there is a way to manipulate either of the above
>> functions more then what I was able to?
>> Is there another function to draw interaction plots with error bars?
>>
>>
>
> Hi Dror,
> I think you want to offset the points in a group along the x axis so that
> the points and error bars don't overlap. Try introducing an x offset of
> maybe 0.1 in your try with plotmeans. To see an example of what this looks
> like and how it is done, have a look at brkdn.plot in the plotrix package.
>
> Jim
>
>




More information about the R-help mailing list