[R] Question about coplot() ...

Mark Myatt mark at myatt.demon.co.uk
Sun Dec 24 14:46:44 CET 2000


C. Joseph Lu <cjlu at ibm.stat.ncku.edu.tw> writes:
>Dear R-friends,
>
>For the following data:
>
>> xy
>     x     y i
>1  731 0.313 2
>2  739 0.340 2
>3  790 0.373 2
>4  855 0.451 2
>5  980 0.608 2
>6  575 0.156 1
>7  608 0.207 1
>8  630 0.249 1
>9  670 0.332 1
>10 838 0.377 1
>11 964 0.466 1
>
>> coplot(y ~ x|i, data=xy)
>coplot gives 3 panels, rather than 2, namely one for i=1 and one for
>i=2.
>
>Futhermore, when I extand data fram xy to have i=3 as follows:
>
>> xy
>     x     y i
>1  334 0.129 3
>2  365 0.198 3
>3  411 0.223 3
>4  731 0.313 2
>5  739 0.340 2
>6  790 0.373 2
>7  855 0.451 2
>8  980 0.608 2
>9  575 0.156 1
>10 608 0.207 1
>11 630 0.249 1
>12 670 0.332 1
>13 838 0.377 1
>14 964 0.466 1
>
>> coplot(y ~ x | i, data=xy)
>gives 4 panels, rather than 3.
>
>Is this appropriate (with default settings of coplot)?

Specify i as a factor, e.g.


coplot(y ~ x | factor(i), data=xy)

It seems to me that the default behaviour is correct as it does not
automatically coerce the conditioning variable to a factor. I must admit
that I often want this so I have written a separate function that does
that for me.


Mark


--
Mark Myatt


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list