If you have that dataset loaded to e.g. "df", you could try (and modify to
your needs) the following:

with(df, {plot(x~y, pch = type); abline(lm(x ~ y))})


The example shows hot to plot different symbols, like:

plot(df$x ~ df$y, pch = type)


And how to add the (total) regression line:

abline(lm(df$x ~ df$y))


Best,
Gergely

On Tue, Mar 20, 2012 at 00:52, AbouEl-Makarim Aboueissa <
[email protected]> wrote:

> Dear All:
>
> I want to create a scatter plot of grouping data. I have the variable x
> and y and the grouping variable type (1=group 1, 2=group 2) in the same
> plot.
>
> Also I need to add the fitted regression lines to the same plot.
>
> Also, how I can change (or adjust the dots for each type). for example use
> the square for one type and triangle for the other type.
>
> you can use the following data:
>
> type x y
> 1 3 4
> 1 2 2
> 1 4 55
> 1 3 4
> 1 2 3
> 2 11 22
> 1 2 33
> 2 34 11
> 2 2 6
> 2 35 77
> 2 64 8
> 1 32 12
> 1 12 40
> 2 67 30
> 2 3 43
> 2 4 23
> 1 2 15
> 1 5 51
> 1 8 6
> 2 9 23
> 2 56 16
> 1 43 27
> 2 21 17
> 1 12 27
> 1 34 47
> 1 2 25
> 2 5 24
> 2 6 15
> 2 7 16
> 1 8 34
> 1 9 7
> 2 4 89
> 1 22 32
> 2 3 4
> 1 11 33
> 1 45 55
> 2 2 76
> 1 1 32
> 2 45 12
> 1 1 45
> 2 3 32
> 1 2 78
> 1 4 5
> 1 5 4
> 1 6 23
> 2 7 45
> 1 9 32
> 2 7 78
> 2 1 45
> 2 20 22
>
>
>
> Thank you very much
> abou
>
>
>
> ==========================
> AbouEl-Makarim Aboueissa, Ph.D.
> Associate Professor of Statistics
> Graduate Program Coordinator
> Department of Mathematics & Statistics
> University of Southern Maine
> 96 Falmouth Street
> P.O. Box 9300
> Portland, ME 04104-9300
> USA
>
>
> Tel: (207) 228-8389
> Fax: (207) 780-5607
> Email: [email protected]
>          [email protected]
>
> Office: 301C Payson Smith
>
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-teaching
>

        [[alternative HTML version deleted]]

_______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-teaching

Reply via email to