[R] Interaction plot type=o
David Winsemius
dwinsemius at comcast.net
Fri Sep 30 18:33:06 CEST 2011
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.
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
More information about the R-help
mailing list