[R] simple graphing question

William Deese williamdeese at gmail.com
Mon Feb 23 21:38:20 CET 2009


I have what should be a simple question but I've been unable to solve
it in a reasonable length of time. For example with data like
> ge
  product response scenario
1    wine        5     base
2   steel       10     base
3   sugar        4     base
4    wine      -10   policy
5   steel        1   policy
6   sugar      -20   policy

(In reality there would be similar groups of data of various sizes). I
would like to make dotplots with product on the left axis, x's for
policy and o's for base scenario, say in red and blue. I would like to
have horizontal lines from the product names across thru the x's and
o's to the other side. Because positive or negative responses are
important, I would like to have a vertical red line top to bottom at
0. I've experimented with dot.line, add.line to put in horizontal
lines but was unsuccessful. Although the following code puts a red
vertical line in, it is at the plot's left border.

gedot <-
function()
{
trellis.par.set(list(fontsize=list(text=12),
dot.symbol=list(pch=c(1,4), col=c("blue","red")) ))
print(dotplot(product ~ response, groups = scenario, pch=c(1,4),
xlab="", ylab=NULL))
panel.abline(v=0, col="red", reference=FALSE)
}

Help please.




More information about the R-help mailing list