On Mon, 2007-06-18 at 19:40 -0400, suman Duvvuru wrote:> Hello,
>
> I wanted to know how to plot a histogram using a vector of frequencies
> rather than the data vector as a whole. So I have two vectors: a vector of
> labels V1= c("A","B","C","D") and
vector B which is a vector of frequencies
> of A, B, C and D respectively V2=c(20,50,60,30). I wanted to plot a
> histogram of the labels using the frequencies. I could not figure out a way
> to do this using the 'hist' function which takes only the full data
vector
> as input. Could you please help me with this?
>
> Thank you,
> Suman
See ?barplot
To wit:
V1 <- c("A", "B", "C", "D")
V2 <- c(20, 50, 60, 30)
# Do the barplot, saving the bar midpoints in 'mp'
mp <- barplot(V2, names.arg = V1, ylim = c(0, 80))
# Now add the bar values above the bars
text(mp, V2, V2, pos = 3)
See ?text and ?mtext for adding annotation
HTH,
Marc Schwartz