Create a bar graph with pre-summarized data using ggplot2
ggplot2, r
Solution
What you need is `stat="identity"`
For example, this line
ggplot(data=binfile, aes(x=V1, y=V2)) + geom_bar(stat="identity")
gives me this plot
Is that what you're after?
Problem
I have following data in a file called binFile ``` 78 1 79 4 80 33 81 150 82 714 83 2663 84 8834 85 25679 86 63654 87 139731 88 265909 89 441686 90 639773 91 803736 92 879616 93 832181 94 682584 95 480228 96 290093 97 149299 98 65443 99 24487 100 7487 101 1835 102 402 103 59 104 10 ``` How do I create a simple bar graph from this data where the first column is along the x-axis and the height of the bar should be proportional to the corresponding value in second column. Till now, I have tried the following: ``` binData <- read.table("binFile") costBars = ggplot(binData,aes(x=V1,y=V2)) finalPlot2 = costBars + geom_bar() finalPlot2 ``` However these commands generate the following error? ``` stat_bin: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this. Error in pmin(y, 0) : object 'y' not found ```