[R] Creating a histogram from a frequency vector
ccberry @end|ng |rom uc@d@edu
Thu Oct 10 18:34:58 CEST 2019
> On Oct 9, 2019, at 9:58 AM, Rui Barradas <ruipbarradas using sapo.pt> wrote:
> Here are 3 ways.
For a large number of bars, sometimes this:
plot( y, type='h') # maybe use lwd=5
> The first are almost the same, they use base graphics.
> x <- 1:6
> y <- c(73,53,42,67,41,50)
> barplot(setNames(y, x))
> names(y) <- x
> And 3:
> ggplot(data.frame(x, y), aes(x, y)) +
> Hope this helps,
> Rui Barradas
> Às 16:12 de 09/10/19, Nick Wray via R-help escreveu:
>> I have a vector like say 73,53,42,67,41,50 where these numbers are the number of occurrences of the data values 1,2,3,4,5,6 - so in essence I have the frequency bit from the hist() function. I can't see an elegant way (there are clearly messy workarounds like generating a vector of 73 1's, 53 2's etc) of creating a histogram from this data set. Is there one?
>> Thanks Nick Wray
>> [[alternative HTML version deleted]]
>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help