[R] plot with different symbols and colors according to the factor levels

li li hannah.hlx at gmail.com
Tue Aug 30 18:50:07 CEST 2016


Hi all,
 I have the following data. I want to plot the data (y ~ conc)
with different symbols and colors corresponding to different levels of the
factor sample.
I could create a column with color and pch and then do the plot, but I am
sure there are much better ways.
Can anyone make suggestions?
  Hanna



   y         conc sample
1  33 20.000000000      1
2  33  5.000000000      1
3  35  1.250000000      1
4  43  0.312500000      1
5  58  0.078125000      1
6  54  0.019531250      1
7  57  0.004882812      1
8  57  0.001220703      1
9  32 20.000000000      1
10 32  5.000000000      1
11 34  1.250000000      1
12 52  0.312500000      1
13 57  0.078125000      1
14 58  0.019531250      1
15 59  0.004882812      1
16 50  0.001220703      1
17 34 20.000000000      2
18 34  5.000000000      2
19 38  1.250000000      2
20 53  0.312500000      2
21 57  0.078125000      2
22 57  0.019531250      2
23 57  0.004882812      2
24 52  0.001220703      2
25 34 20.000000000      2
26 33  5.000000000      2
27 36  1.250000000      2
28 48  0.312500000      2
29 58  0.078125000      2
30 57  0.019531250      2
31 58  0.004882812      2
32 53  0.001220703      2
33 34 20.000000000      2
34 35  5.000000000      2
35 37  1.250000000      2
36 49  0.312500000      2
37 55  0.078125000      2
38 59  0.019531250      2
39 57  0.004882812      2
40 54  0.001220703      2
41 36 20.000000000      3
42 33  5.000000000      3
43 36  1.250000000      3
44 51  0.312500000      3
45 57  0.078125000      3
46 57  0.019531250      3
47 59  0.004882812      3
48 56  0.001220703      3
49 33 20.000000000      3
50 32  5.000000000      3
51 35  1.250000000      3
52 47  0.312500000      3
53 57  0.078125000      3
54 56  0.019531250      3
55 57  0.004882812      3
56 53  0.001220703      3
57 33 20.000000000      3
58 34  5.000000000      3
59 38  1.250000000      3
60 52  0.312500000      3
61 56  0.078125000      3
62 61  0.019531250      3
63 56  0.004882812      3
64 55  0.001220703      3

	[[alternative HTML version deleted]]



More information about the R-help mailing list