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 5940203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:56:09+00:00 2026-05-22T15:56:09+00:00

I have three dataframes with this structure (but different values): V1 V2 2010-04-30 30

  • 0

I have three dataframes with this structure (but different values):

V1 V2
2010-04-30 30
2010-07-31 17
2010-10-02 20

I want to do a line chart in ggplot2 with 3 lines, one for each dataset. The problem is that i want to display in the Y axis the percentage relative to each dataset and not the global one.

How can i do this? Should i merge the two dataframes, or call three times geom_line() for the different dataframes and change there Y value?

  • 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-22T15:56:10+00:00Added an answer on May 22, 2026 at 3:56 pm

    There are lots of ways to do this, some probably pithier than this, but this gets you there:

    #Create three data frames along the lines of your example
    df1 <- data.frame(V1=c("2010-04-30","2010-07-31","2010-10-02"),V2=c(30,17,20))
    df2 <- data.frame(V1=c("2010-04-30","2010-07-31","2010-10-02"),V2=c(10,5,42))
    df3 <- data.frame(V1=c("2010-04-30","2010-07-31","2010-10-02"),V2=c(3,15,12))
    
    #Combine them and create a variable to distinguish between them
    df <- rbind(df1,df2,df3)
    df$type <- rep(letters[1:3],each=3)
    
    #Use ddply to calculate the proportion by group (there are _lots_ of other ways to do this part)
    df <- ddply(df,.(type),.fun=function(x){x$V3 <- x$V2/sum(x$V2);return(x)})
    #And plot
    ggplot(df,aes(x=as.Date(V1),y=V3)) + geom_line(aes(group=type,colour=type))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three tables: page, attachment, page-attachment I have data like this: page ID
I have three values I need to align in a dropdown box. How can
I have three tables tag , page , pagetag With the data below page
I have three models: class ReleaseItem < ActiveRecord::Base has_many :pack_release_items has_one :pack, :through =>
I have three unordered lists that have been created as Scriptaculous Sortables so that
I have three (C++) classes: Player, Hand, and Card. Player has a member, hand,
I have three divs : <div id=login /> <div id=content /> <div id=menu />
I have three TextBox controls on the page <asp:TextBox ID=TextBox1 runat=server AutoPostBack=True OnTextChanged=TextBox_TextChanged TabIndex=1>
I have three tables in the many-to-many format. I.e, table A, B, and AB
I have three easy questions. Does anybody use QuickTest Pro for automated testing? Any

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.