*** APOLOGIZES FOR THOSE READING THE LIST THROUGH NABBLE THIS WAS ALREADY
POSTED THERE BUT NOT FORWARDED TO THE LIST FOR SOME UNKNOWN REASON ***
I have a dataset that looks like:
$ V1: factor with 4 levels
$ V2: factor with 4 levels
$ V3: factor with 2 levels
$ V4: num (summing up to 100 within V3 levels)
$ V5: num (nr of cases for each unique combination of V1*V2*V3 levels)
Quite new to lattice - I've started reading Deepayan's book a few days ago - I
have written the following:
barchart(V2 ~ V4 | V1,
data=d1,
groups=V3,
stack=TRUE,
auto.key= list(space="top"),
layout = c(1,4),
xlab=" "
)
which works just fine as a stacked bar chart with bars adding up to 100%. Now
what I would like to see is the number of cases showing next to the 4 x-axis's
labels - i.e. V2_L1, ... V2_L4.
In other words now I see something like:
*** V1_L1 ***
V2_L4 AAAVVVVVVV
V2_L3 AAVVVVVVVV
V2_L2 AAAAAVVVVV
V2_L1 AAVVVVVVVV
*** V1_L2 ***
V2_L4 AAAAAAVVVV
V2_L3 AVVVVVVVVV
etc...
But what I am looking for is something like:
*** V1_L1 ***
V2_L4 (n=60) AAAVVVVVVV
V2_L3 (n=10) AAVVVVVVVV
V2_L2 (n=52) AAAAAVVVVV
V2_L1 (n=15) AAVVVVVVVV
*** V1_L2 ***
V2_L4 (n=18) AAAAAAVVVV
V2_L3 (n=74) AVVVVVVVVV
etc...
How can I do that? I have tried:
V6 <- paste(V2," (n",V5,")")
but what i get when I run
barchart(V6 ~ V4 | V1,
data=d1,
groups=V3,
stack=TRUE,
auto.key= list(space="top"),
layout = c(1,4),
xlab=" "
)
is a bunch of empty bars due to the fact that the unique combinations have
risen.
Any help would be appreciated.
Thanks,
Luca
Mr. Luca Meyer
www.lucameyer.com
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.