For the following data set,
Genre Amount
Comedy 10
Drama 30
Comedy 20
Action 20
Comedy 20
Drama 20
I want to construct a ggplot2 line graph, where the x-axis is Genre
and the y-axis is the sum of all amounts (conditional on the Genre
).
I have tried the following:
p = ggplot(test, aes(factor(Genre), Gross)) + geom_point()
p = ggplot(test, aes(factor(Genre), Gross)) + geom_line()
p = ggplot(test, aes(factor(Genre), sum(Gross))) + geom_line()
but to no avail.
factor
, sincestringsAsFactors
is the default behaviour. – Jijib