3
votes

I made the graph below using ggplot:

ggplot(subset(monthly.rate, year=="2015"), aes(x=a6ncopo)) + geom_bar() 

graph

Here the number of observations at each time point (and therefore the number of rows) are being summed for each time point.

I want to make the same graph but using geom_line to make a line graph. But of course I get the error 'requires the following missing aesthetics: y'.

How do I get ggplot2 to plot a line graph using the number of rows on the y axis, the same way it easily handles using geom_bar?

Dput:

(removed)
1
can you give an example data?user6376316
Yes OK, one secondSamuel Harper
@Learner OK I have given a dputSamuel Harper
I suppose your dput is just a subset, because it does not produce the same output... Anyway, a quick way to do what you want is to add stat="count" to your geom_line.scoa
Sorry! the time is a6ncopo, the axis labels have just been changed.Samuel Harper

1 Answers

0
votes

Answered in comments:

ggplot(subset(df, year=="2015"), aes(x=a6ncopo)) + 
    geom_bar() +
    geom_line(stat="count")