[R] plot different groups as factors
Luigi Marongiu
marongiu.luigi at gmail.com
Thu Dec 19 01:18:50 CET 2013
dear all,
i would like to plot the value of different response groups. when i simply
use plot(y ~ x) i obtain a series of boxplots. i would rather use dots. i
also tried with stripchart(y ~ x), which gives better results but does not
place properly the labels since place them alphabetically.
in addition i actually have 6 response groups: 3 classes (low, medium,
high) and 2 sampling time (12 and 18 months).
how can i generate these individual groups and plot them in the correct
order (low, medium, high and 12, 18)? i believe is something to do with the
factors but i don't know how to implement them.
what i am looking for is to generate a figure such as the one i sketched in
the attached file. i also attached a dataframe version of my data. the
vectors containing the same data are:
time <-c( 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12)
class <-c( medium, medium, medium, medium, medium,
medium, medium, medium, medium, medium, medium,
medium, medium, medium, high, high, high, high,
high, high, high, low, low, low, low, low, low,
low, medium, medium, medium, medium, medium, medium,
medium, medium, medium, medium, medium, medium,
medium, medium, medium, medium, medium, medium, high,
high, high, high, high, high, high, high, high,
high, low, low, low, low, low, low, low, low,
low, low)
value <-c( 2.92, 0.01, 0.36, 3.16, 0.99, 0.38,
0.01, 5.1, 0.04, 0.01, 1.33, 4.13, 0.15, 0.15,
14.18, 4290.14, 26.8, 5.33, 17.58, 14.29, 248.5,
0.01, 0, 0, 0, 0, 0, 0, 0.151395382,
5.327863403, 5.10096383, 1.32567787, 4.352404124,
0.458606982, 2.915908912, 0.011996374, 0.364710382,
0.033016026, 3.161701212, 0.381564497, 0.010971385,
0.035646472, 0.014781805, 4.129708296, 0.153094117,
0.018497847, 15.09178491, 17.58393041, 14.17643928,
4290.143561, 26.79730719, 294.6367065, 14.2888441,
248.495231, 209.3131795, 2014.506722, 0.010751273,
0.002325138, 0.000637473, 0.003984336, 0.006018154,
0.003620907, 0.0000745936, 0.000142311, 0.002460417,
0.001280189)
Thank you very much for any help you could provide!
regards
Luigi
-------------- next part --------------
time class value
1 18 medium 2.92
2 18 medium 0.01
3 18 medium 0.36
4 18 medium 3.16
5 18 medium 0.99
6 18 medium 0.38
7 18 medium 0.01
8 18 medium 5.1
9 18 medium 0.04
10 18 medium 0.01
11 18 medium 1.33
12 18 medium 4.13
13 18 medium 0.15
14 18 medium 0.15
15 18 high 14.18
16 18 high "4,290.14"
17 18 high 26.8
18 18 high 5.33
19 18 high 17.58
20 18 high 14.29
21 18 high 248.5
22 18 low 0.01
23 18 low 0
24 18 low 0
25 18 low 0
26 18 low 0
27 18 low 0
28 18 low 0
29 12 medium 0.151395382
30 12 medium 5.327863403
31 12 medium 5.10096383
32 12 medium 1.32567787
33 12 medium 4.352404124
34 12 medium 0.458606982
35 12 medium 2.915908912
36 12 medium 0.011996374
37 12 medium 0.364710382
38 12 medium 0.033016026
39 12 medium 3.161701212
40 12 medium 0.381564497
41 12 medium 0.010971385
42 12 medium 0.035646472
43 12 medium 0.014781805
44 12 medium 4.129708296
45 12 medium 0.153094117
46 12 medium 0.018497847
47 12 high 15.09178491
48 12 high 17.58393041
49 12 high 14.17643928
50 12 high 4290.143561
51 12 high 26.79730719
52 12 high 294.6367065
53 12 high 14.2888441
54 12 high 248.495231
55 12 high 209.3131795
56 12 high 2014.506722
57 12 low 0.010751273
58 12 low 0.002325138
59 12 low 0.000637473
60 12 low 0.003984336
61 12 low 0.006018154
62 12 low 0.003620907
63 12 low 7.46E-05
64 12 low 0.000142311
65 12 low 0.002460417
66 12 low 0.001280189
More information about the R-help
mailing list