-1

So I have a data set I need to make a bar graph with. The data set has a column for vaccination and for count. So looks like this.....

Polio       20

Polio       15

Varicella   30

Varicella.   45

I need a bar graph that lists the total number of varicella vaccinations and total number of polio vaccinations. I'm lost on how to do this.

d.b
  • 32,245
  • 6
  • 36
  • 77
CM4740
  • 1
  • 1
  • Some places to start: `library(ggplot2); qplot(your_data)`, or `?barplot`, or [Sum variable by group R-FAQ](https://stackoverflow.com/q/1660124/903061), or searching SO for [R and barplot](https://stackoverflow.com/questions/tagged/r+bar-chart?sort=votes&pageSize=50) turns up lots of examples. Where are you stuck? What did you try that didn't work? As-is, I think your question is too broad as it's not clear what you *can* do. – Gregor Thomas Jul 17 '17 at 16:52
  • I followed your link and The aggregate function is what I needed. Thanks for that. But how do I turn that into a bar graph for visual representation? I just need the x axis to say polio and varicella. They y axis to show the total numbers. – CM4740 Jul 17 '17 at 16:59
  • I'm a novice. This is for a R class I am taking for my degree – CM4740 Jul 17 '17 at 16:59
  • There are two links in my comment and a couple code snippets. Sounds like the one you looked at was useful, try out the others too. – Gregor Thomas Jul 17 '17 at 17:23

2 Answers2

0

Barplot(count) is what you're looking for refer to the link below

http://www.statmethods.net/graphs/bar.html

Giantrun
  • 21
  • 6
  • Thanks, corrected that. The histogram suits continuous data better but the question was specially about a bar chart. A sorted bar chart might do the job if there aren't too many categories. – Giantrun Jul 17 '17 at 17:33
  • Thanks again. Hist <> Barplot – Giantrun Jul 17 '17 at 17:51
0

Something like that could be useful?

data <- structure(list(vaccine = c("Polio", "Polio", "Varicella", "Varicella"),
                   value = c(20, 15, 30, 45)),
                   class = "data.frame", row.names = 1:4)
data

library("ggplot2")

ggplot(data, aes(x=vaccine, y=value)) + geom_bar(stat="identity")
valz
  • 36
  • 3