[R] Interaction plot type=o
Gavin Simpson
gavin.simpson at ucl.ac.uk
Mon Oct 3 12:08:02 CEST 2011
On Fri, 2011-09-30 at 12:33 -0400, David Winsemius wrote:
> On Sep 30, 2011, at 2:16 AM, Petr PIKAL wrote:
>
> >>
> >> 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.
Or use `fix()` or `fixInNamespace()` if this is just a one off.
G
> You can do it at the console on both the OS versions of R I have used.
> just copy the code and paste. Add the "<-" and the ,"o" and hit enter.
> Piece of cake.
>
> > I would start with adding "o" to type in function
> > definition and see how it behaves.
>
> I tested it. Worked as expected.
>
> > 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
> >>>
> >>>
>
> David Winsemius, MD
> West Hartford, CT
>
> ______________________________________________
> 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.
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Dr. Gavin Simpson [t] +44 (0)20 7679 0522
ECRC, UCL Geography, [f] +44 (0)20 7679 0565
Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/
UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
More information about the R-help
mailing list