I have a data frame ***df*** with the following variables: ***Test***, ***A***, ***p*** and ***D***. I want to print ***A*** against ***p***, grouping by variable ***D*** levels.

I am using ***xyplot*** to do so and ***type=('p','l')*** to plot the points and the connecting lines between points. This procedure connects all points of the same level of variable ***D***. The problem is that I want to connect only the points from the same ***Test***.

Any clue how this can be done? Or if it is possible to do it with *xyplot*?

Example for data

```
    Test         A           p     D
95    32 0.0000000 0.010148395 55.04
96    32 0.2746429 0.018040352 55.04
97    32 1.0000000 0.019101864 55.04
271   72 0.0000000 0.005900593 22.64
272   72 0.1677419 0.006708547 22.64
273   72 0.4290323 0.009770698 22.64
274   72 1.0000000 0.010637487 22.64
275   73 0.0000000 0.005175419 22.64
276   73 0.2242424 0.006683234 22.64
277   73 0.3793939 0.009750174 22.64
278   73 1.0000000 0.012231502 22.64

```

This is the code I am using:

```
xyplot(A ~ p, data=df, groups=D, type=c("p","l"))

```

This is an example of what I would like to achieve. Maybe it is not possible with `xyplot`.

[Example of what I want to achieve](https://i.stack.imgur.com/YlAik.jpg)