[R] Interaction plot type=o

Petr PIKAL petr.pikal at precheza.cz
Fri Sep 30 08:16:46 CEST 2011


> 
> David,
> thank you for your reply
> 
> I tried this
> attach(mtcars)
> interaction.plot(cyl, gear, mpg, type="o", pch=5:8, lty=1 )
> 
> but I got this error:
> Error in match.arg(type) : 'arg' should be one of "l", "p", "b"
> 
> and in ?interaction.plot, "o" it is not listed in type arguments.
> Is there any other way to force it to take the argument?

As David suggested you need to change code for interaction.plot. If you 
write

interaction.plot

you will get the code

> interaction.plot
function (x.factor, trace.factor, response, fun = mean, type = c("l", 
    "p", "b"), legend = TRUE, trace.label = 
deparse(substitute(trace.factor)), 
    fixed = FALSE, xlab = deparse(substitute(x.factor)), ylab = ylabel, 
    ylim = range(cells, na.rm = TRUE), lty = nc:1, col = 1, pch = c(1L:9, 
        0, letters), xpd = NULL, leg.bg = par("bg"), leg.bty = "n", 
    xtick = FALSE, xaxt = par("xaxt"), axes = TRUE, ...) 
{.......

Copy it into some suitable text editor (not Word please) and change it 
according to your wish. I would start with adding "o" to type in function 
definition and see how it behaves. Then you can copy the whole code to 
your modified function e.g.

my.int.plot <- function(x,....

and call 
my.int.plot(cyl, gear, mpg, type="o", pch=5:8, lty=1 )

Regards
Petr


> 
> Thanks
> Claudio
> 
> On Thu, Sep 29, 2011 at 9:00 PM, David Winsemius 
<dwinsemius at comcast.net>wrote:
> 
> >
> > On Sep 29, 2011, at 7:22 PM, Heverkuhn Heverkuhn wrote:
> >
> >  Hello,
> >> I was wondering if there is any equivalent of interaction.plot that 
allow
> >> you to set type="o"
> >> I tried to use interaction.plot and I have a gap between the symbols 
of
> >> the
> >> points and the line.
> >>
> >>
> > If it's OK to have the lines going right though the symbols, then go 
ahead,
> > hack the code. All you need to do is add ,"o" to the type arguments in 
the
> > argument list. The code's not hidden or anything that gets in your 
way.
> >
> >
> > David Winsemius, MD
> > West Hartford, CT
> >
> >
> 
>    [[alternative HTML version deleted]]
> 
> ______________________________________________
> 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