Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4048716
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:51:08+00:00 2026-05-20T13:51:08+00:00

For the following data set, Genre Amount Comedy 10 Drama 30 Comedy 20 Action

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T13:51:09+00:00Added an answer on May 20, 2026 at 1:51 pm

    If you don’t want to compute a new data frame before plotting, you cvan use stat_summary in ggplot2. For example, if your data set looks like this :

    R> df <- data.frame(Genre=c("Comedy","Drama","Action","Comedy","Drama"),
    R+                  Amount=c(10,30,40,10,20))
    R> df
       Genre Amount
    1 Comedy     10
    2  Drama     30
    3 Action     40
    4 Comedy     10
    5  Drama     20
    

    You can use either qplot with a stat="summary" argument :

    R> qplot(Genre, Amount, data=df, stat="summary", fun.y="sum")
    

    Or add a stat_summary to a base ggplot graphic :

    R> ggplot(df, aes(x=Genre, y=Amount)) + stat_summary(fun.y="sum", geom="point")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following data set that I am trying to plot with ggplot2,
I have a data set that looks like the following: movie (year) genre for
I have the following data set, which represents nodes in a directed graph. CREATE
I have the following data set structure: date time_in_hours price Sep 03 08 9.76
I'm having the following data set (note that my database/schemata is somewhat complex so
I have the swiss data set provided by R, which has the following form:
I am using PHP/Mongo to query a data set like the following: { description:
Hey guys, given a data set in plain text such as the following: ==Events==
I have the following set of data: ID | CREATED | USER -------------------------- 1
I have the following data set called t : n <- 12 t <-

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.