[R] Setting X-Axis labels in Lattice Barchart
Gregory Sawyer
gdsawyer at greatergood.com
Thu Aug 11 00:09:31 CEST 2011
Hello,
I'm attempting to plot out a series of bar charts of recency, frequency and monetary (RFM) scores using recency as a conditioning variable so we can see the details of the FM components. My dataset looks like this:
rfmCellPop{rfm_score, orecency, ofrequency, omonetary, cellpop}
Where rfm_score is the composite score (cellID),
oRecency, oFrequency and oMonetary are the respective parts of the score all in the range 1..5.
cellpop is the number of units in the cell
Not all cells are represented in the data -- most, but not all (94 out of a possible 125).
Here's my plot command:
barchart(cellpop~rfm_score | orecency, data=rfmCellPop, horizontal=FALSE,
scales=list(x=list(relation="free",rot=90,labels=rfmCellPop$rfm_score)),
strip=strip.custom(strip.levels=c(TRUE,TRUE)))
When I run this without the axis labels=, I get a running serial number for the x axis labels (1..94), the number of cells. When I run per above, it recycles the labels such that each panel starts over at cell 111 although the bars themselves are plotting the right population. I've been trying now for a couple of days to figure out how to get the correct cell labels on the panels, but I haven't been able to suss it out, I've tried things like:
labels=c(rfmCellPop$rfm_score)
labels=rfmCellPop[subscript,rfm_score]
labels=rfmCellPop$rfm_score[subscript]
lables=rfmCellPop$rfm_score
And Teh Google has failed me as well.
So I'm wondering where to go from here?
Thanks much,
--Gregory
Gregory Sawyer
Data Architect
GreaterGood Network / CharityUSA
More information about the R-help
mailing list