[R] add median/mean line to stri-plot in lattice
Luigi Marongiu
marongiu.luigi at gmail.com
Thu Jan 23 21:55:08 CET 2014
dear all,
I set a series of variable subdivided in classes (there are 7 in here,
defined by the clause 'levels'), and I am showing the results in strip
chart using the package 'lattice'. Whitin each class the samples are
further subdivided in "active" (A) and "latent" (L). The function I have
written is:
stripplot(my.data.IP10$ratio ~
factor(my.data.IP10$TB)|factor(my.data.IP10$stimulus,
levels = c("ESAT6","CFP10","Rv3615c", "Rv2654", "Rv3879",
"Rv3873","PHA")),
my.data, hor=F, layout = c(7,1), scales = list(relation = "same"),
ylab=expression(bold("Ratio GOI/RG")), xlab=expression(bold("Antigen
stimulation")), main="IP10 expression", pch=19, col="black",
par.settings = list(strip.background=list(col="white")),
par.strip.text=list(font=2))
which defines the figure attached "IP10".
Providing the median or average values (that will depend on the
distribution of the final data), is there a way to add a line overlapping
each of these classes and subclasses? I reckon it will be a vector of 14
elements, which can be called "Mvect".
In addition is there a way to differently colour the subclasses? lest say
black for active and white for latent? I tried with 'group' but with not
success.
Thank you for any help, I am not quite familiar with the Latex codes. I am
also attaching the dataframe containing the data for further reference.
Best regards
Luigi
-------------- next part --------------
patient TB gene stimulus ratio
1 A264 A IP10 ESAT6 250.9
2 A264 A IP10 CFP10 399.1
3 A264 A IP10 Rv3615c 959.4
4 A264 A IP10 Rv2654 1.994
5 A264 A IP10 Rv3879 589.2
6 A264 A IP10 Rv3873 5.366
7 A264 A IP10 PHA 48.27
8 H041 L IP10 ESAT6 10.32
9 H041 L IP10 CFP10
10 H041 L IP10 Rv3615c 3.33
11 H041 L IP10 Rv2654
12 H041 L IP10 Rv3879 1
13 H041 L IP10 Rv3873
14 H041 L IP10 PHA 1
15 A263 A IP10 ESAT6 509.5
16 A263 A IP10 CFP10 991
17 A263 A IP10 Rv3615c 689.6
18 A263 A IP10 Rv2654 1285
19 A263 A IP10 Rv3879 683.7
20 A263 A IP10 Rv3873 468.7
21 A263 A IP10 PHA 47.08
22 N241 A IP10 ESAT6 8.534
23 N241 A IP10 CFP10 2.733
24 N241 A IP10 Rv3615c
25 N241 A IP10 Rv2654 11.18
26 N241 A IP10 Rv3879 10.41
27 N241 A IP10 Rv3873 0.7532
28 N241 A IP10 PHA
More information about the R-help
mailing list