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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:46:38+00:00 2026-06-02T18:46:38+00:00

I have managed to aggregate some data into the following: Month Year Number 1

  • 0

I have managed to aggregate some data into the following:

   Month Year Number
1     1  2011   3885
2     2  2011   3713
3     3  2011   6189
4     4  2011   3812
5     5  2011    916
6     6  2011   3813
7     7  2011   1324
8     8  2011   1905
9     9  2011   5078
10   10  2011   1587
11   11  2011   3739
12   12  2011   3560
13    1  2012   1790
14    2  2012   1489
15    3  2012   1907
16    4  2012   1615

I am trying to create a barplot where the bars for the months are next to each other, so for the above example January through April will have two bars (one for 2011 and one for 2012) and the remaining months will only have one bar representing 2011.

I know I have to use beside=T, but I guess I need to create some sort of matrix in order to get the barplot to display properly. I am having an issue figuring out what that step is. I have a feeling it may involve matrix but for some reason I am completely stumped to what seems like a very simple solution.

Also, I have this data: y=c('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec') which I would like to use in my names.arg. When I try to use it with the above data it tells me undefined columns selected which I am taking to mean that I need 16 variables in y. How can I fix this?

  • 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-06-02T18:46:39+00:00Added an answer on June 2, 2026 at 6:46 pm

    To use barplot you need to rearrange your data:

    dat <- read.table(text = "   Month Year Number
    1     1  2011   3885
    2     2  2011   3713
    3     3  2011   6189
    4     4  2011   3812
    5     5  2011    916
    6     6  2011   3813
    7     7  2011   1324
    8     8  2011   1905
    9     9  2011   5078
    10   10  2011   1587
    11   11  2011   3739
    12   12  2011   3560
    13    1  2012   1790
    14    2  2012   1489
    15    3  2012   1907
    16    4  2012   1615",sep = "",header = TRUE)
    
    y <- c('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec')
    
    barplot(rbind(dat$Number[1:12],c(dat$Number[13:16],rep(NA,8))),
            beside = TRUE,names.arg = y)
    

    enter image description here

    Or you can use ggplot2 with the data pretty much as is:

    dat$Year <- factor(dat$Year)
    dat$Month <- factor(dat$Month)
    ggplot(dat,aes(x = Month,y = Number,fill = Year)) + 
        geom_bar(position = "dodge") + 
        scale_x_discrete(labels = y)
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have managed to bring the following output with this query SELECT DISTINCT IF(purchaseproduct_customerid=0,contactperson,vendorname)
I have managed to run hadoop examples grep, wordcount... however I am finding some
I have managed to create my own IList sub class using some code i
I have managed to use SAPI Text-To-Speech in Delphi/Lazarus by using the following code:
I have managed to get myself confused about some elements of memory management. I
I have managed to set up Cassandra + Thrift and the Python wrapper for
I have managed to get a cron job to run a rake task by
I have managed to create a custom action in C# using MakeSfxCA which is
I have managed to put this condition and rule below together to redirect a
I have managed objects that have image properties. Since storing large blobs in CoreData

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.