Skip to content

Daily Category Revenue-Stacked Bar Chart in ggplot2

16 messages · John Kane, Jeff Newmiller, Berend Hasselman +4 more

#
I am trying to use the ggplot2 to build a stacked bar chart for daily Revenue
by category. The chart would look have date on the x-axis, and revenue on
the y axis. The fill would be the categories themselves. I have searched a
great deal and have been unable to find exactly how to do this.



--
View this message in context: http://r.789695.n4.nabble.com/Daily-Category-Revenue-Stacked-Bar-Chart-in-ggplot2-tp4710431.html
Sent from the R help mailing list archive at Nabble.com.
1 day later
#
First http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example and http://adv-r.had.co.nz/Reproducibility.html

Second. It is very annoying to have posts come in from Nabble. Very few R-help readers use it and the total context of some post to R-help is usually lost. If possible could you post directly to R-help.

We have no idea of what your problem is (see above) but here is a very simple example of a stacked barchart using ggplot2. And since I am already complaining I have included a side-by-side version of the barchart as well. I think that stacked barcharts are not a good idea unless obfuscation is the desired outcome. It is too hard to compare quantities with no common baseline.

Good luck.

dat1  <-  structure(list(dates = structure(c(1L, 2L, 3L, 4L, 5L, 1L, 2L, 
3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L), .Label = c("1", 
"2", "3", "4", "5"), class = "factor"), revs = c(40, 7, 40, 20, 
35, 20, 15, 20, 15, 20, 15, 15, 35, 20, 20, 7, 7, 20, 7, 35), 
    typ....rep.LETTERS.1.2...10. = structure(c(1L, 2L, 1L, 2L, 
    1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 
    2L), .Label = c("A", "B"), class = "factor")), .Names = c("dates", 
"revs", "typ....rep.LETTERS.1.2...10."), row.names = c(NA, -20L
), class = "data.frame")

#Stacked barchart
ggplot(dat1, aes(dates, revs, fill = typ)) + geom_bar(stat = "identity")


#Grouped or dodged barchart (I don't think these are the real names)
ggplot(dat1, aes(dates, revs, fill = typ)) + geom_bar(stat = "identity", position="dodge")


John Kane
Kingston ON Canada
____________________________________________________________
Can't remember your password? Do you need a strong and secure password?
Use Password manager! It stores your passwords & protects your account.
#
Hi John, 

Great thanks for the examples! I am not sure what you are referring to when
you say a post from Nabble - I posted this directly on R-help. I actually
never heard of Nabble.

Stacked Bar charts are great for when you have a lot of moving parts and
need to be able to zero in on one of them (e.g. Advertising Placements).
Unfortunately, I can't post the data since it is confidential. 



--
View this message in context: http://r.789695.n4.nabble.com/Daily-Category-Revenue-Stacked-Bar-Chart-in-ggplot2-tp4710431p4710540.html
Sent from the R help mailing list archive at Nabble.com.
#
Then why do your messages contain the Nabble  footer:

View this message in context: http://r.789695.n4.nabble.com/Daily-Category-Revenue-Stacked-Bar-Chart-in-ggplot2-tp4710431p4710540.html
Sent from the R help mailing list archive at Nabble.com.

I think you are confused. You should be looking at

https://stat.ethz.ch/mailman/listinfo/r-help

and using your email client to send emails rather than posting on a web page.

---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.
On July 29, 2015 2:23:54 PM EDT, Hidden Markov Model <hussain at touchofmodern.com> wrote:
#
No, I'm not confused. I just posted on R help website. I don't know how to
use the email client to do anything which you are speaking of. If you would
like the posts to be made in an alternative way, then you will need to
provide clear direction. Sending someone to a help page which doesn't
reference what you are speaking about isn't actually helpful. 



--
View this message in context: http://r.789695.n4.nabble.com/Daily-Category-Revenue-Stacked-Bar-Chart-in-ggplot2-tp4710431p4710543.html
Sent from the R help mailing list archive at Nabble.com.
#
Since there IS NO R-help website that you can post on, you are definitely being confused by the Nabble website. This is a MAILING list that you interact with by sending emails to r-help at r-project.org, not a website forum. The trouble with Nabble is that it does confuse users, and breaks the continuity of emails that people who use it as it was intended to be used depend on.

For example, as a Nabble user you may not even be seeing the following footer that the rest of us live by:

PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

A more accurate web rendition of R-help than Nabble presents may be seen here:

https://stat.ethz.ch/pipermail/r-help/

which is mentioned at the link that you complained did not help you.

---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.
On July 29, 2015 2:37:56 PM EDT, Hidden Markov Model <hussain at touchofmodern.com> wrote:
#
The R help website is  NOT on Nabble. You posted from Nabble as can be seen from your message.
It can also be seen in what the internet browser displays. It is what we see in our email application.

Jeff gave you the correct advice.
Use your email client. Don?t use Nabble and your internet browser.
See the section Using R help on https://stat.ethz.ch/mailman/listinfo/r-help

Berend
#
Alright, I think I understand what you guys are talking about. It is still
not clear the relationship between R-help and Nabble since you guys haven't
actually answered that. 

Again, the best way to provide proper advice is to actually quote to portion
of the website you are sending people to, i.e., "To post a message to all
the list members, send email to r-help at r-project.org." 

But this still doesn't address the issue of why that is necessary in the
first place. Indeed, when a post is made the user sees the following
message, which seems to indicate that the method of posting doesn't actually
matter: 

"This forum is an archive/gateway which will forward your post to the
r-help at r-project.org mailing list".

Cheers! 





--
View this message in context: http://r.789695.n4.nabble.com/Daily-Category-Revenue-Stacked-Bar-Chart-in-ggplot2-tp4710431p4710549.html
Sent from the R help mailing list archive at Nabble.com.
#
On Jul 29, 2015, at 1:02 PM, Hidden Markov Model wrote:

            
Nabble's relationship to Rhelp? Nabble is an ongoing annoyance to the regular users and to the list moderators. It's web display format deceives naive users (who usually fail to read the Posting Guide as they were directed)  into thinking everyone sees what they see, and so they often fail to maintain the context of the discussion. Many regular contributors simply ignore the content from Nabble-originated postings.
Nabble lies. It is not an archive. I periodically get notices telling me that my old posts are going to be dropped. The real archive is: https://stat.ethz.ch/pipermail/r-help/

Nabble does forward messages to Rhelp and if a message passes the spam filters and the human moderators, it gets posted. Nabble then strips off the footers from the returned messages.

If you want to complain about Nabble not living up to your expectations, you should contact them. We did not ask them to mirror Rhelp.

You are expected to know how to control your own mail-client. Expecting us to educate you on the basics of computer use is unreasonable.
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
#
Alright thanks for clarifying. That's all a bit esoteric. Quite different
from "basics off computer use".  None of the documentation anyone mentioned
actually contains any of this. If Nabble is so bad, then why does anyone use
it? It doesn't make sense. You should probably write a wiki going forward so
you won't get upset every-time somebody asks a reasonable question. 



--
View this message in context: http://r.789695.n4.nabble.com/Daily-Category-Revenue-Stacked-Bar-Chart-in-ggplot2-tp4710431p4710560.html
Sent from the R help mailing list archive at Nabble.com.
#
Below.

Bert Gunter

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
   -- Clifford Stoll


On Wed, Jul 29, 2015 at 3:43 PM, Hidden Markov Model
<hussain at touchofmodern.com> wrote:
**You should probably write a wiki going forward so
 you won't get upset every-time somebody asks a reasonable question.**

Fortune nomination!

(I don't actually agree, but I thought it was amusing)
#
Hi Markov
I have no idea of what nabble is or why it exists but the real problem with it is that it looks like (is?) a form where questions and responses are threaded so that it is obvious what the on-going conversation is. 

So a nabble user will respond with something like :
Great but why xx1 is not a postive number? 

Unfortunately there no context.  Perhaps in the mailing list their origiinal question appeared 35 or 40 emails ago. In some cases, probably many the R-help readers have  decided the OP is not interested any more and had deleted the rest of the correspondence. Therefore they have no clue what the nabble user is blathering on about and is usually not inclined to go to nabble read possibly 4-10 posts etc.  

There are basically two ways of replying in a mailing list depending on personal preference and on exact needs.  Typically one top-posts if the answer is relatively self-contained. See my response.

The other way is in-line. This is used normally when the responder wants to deal with individual points in the code or make various specific comments.

In both cases the entire context of the original problem is maintained. Judidcious editing is okay but the main issues are always included in the post so any reader can have a quick look and understand what is happening.

Nabble posters seem never to provide context because they think they are in a forum. In many cases R-help users just are not willing to waste time doing what the original poster should have done

To properly participate in R-help you should go to the R home page and subscribe to the R-help mailing list there.
Feel free to do so. 
One thing to note about the R-help list. It can be incredibly helpful but is not terribly polite or, in some cases particularly tolerant of what is perceived as un-list behaviours and so people do get flames, sometimes deservedly and sometimes unjustly. Just hope you don't get Ripleyied.:)

I'll have to think about your use of a barchart. I think you are the first person who has ever come up with an explanation of why one would use a barchart that may make sense. Can you give me an example?

Well come to the R-help list (down with nabble)



John Kane
Kingston ON Canada
____________________________________________________________
Can't remember your password? Do you need a strong and secure password?
Use Password manager! It stores your passwords & protects your account.
#
Hi John, 

Certainly, that makes sense. Thank you for the clear explanation. I am
subscribed to the email list, it is how I knew you replied. A stacked bar
chart is great for managing and analyzing multi-ad placement Profit and
seeing the time series of the individual charts. Tableau makes it very easy
to use, since you can highlight a specific section and gray out the others
to zero in on issues. 



--
View this message in context: http://r.789695.n4.nabble.com/Daily-Category-Revenue-Stacked-Bar-Chart-in-ggplot2-tp4710431p4710595.html
Sent from the R help mailing list archive at Nabble.com.
#
You still don't get it, do you? 

First, the list is not "John". 

Second, and more importantly, those of us with threading mail programs (or "group by conversation" in Apple-speak) can fairly easily find Johns letter if we haven't deleted it yet. Those without threading will have to look back through the last 5 hours of mail to find it, which is probably not unbearable, but imagine what happens when people do the same thing with posts from 2012. 

And no, it is NOT reasonable to force readers to go to Nabble to find out what the h*ck you are on about!

There has been talk about making the Nabble gateways read-only. Hopefully, that will happen sooner rather than later.

-pd
....

  
    
#
Thanks Mom! 

"You still don't get it, do you? 

First, the list is not "John". 

Second, and more importantly, those of us with threading mail programs (or
"group by conversation" in Apple-speak) can fairly easily find Johns letter
if we haven't deleted it yet. Those without threading will have to look back
through the last 5 hours of mail to find it, which is probably not
unbearable, but imagine what happens when people do the same thing with
posts from 2012. 

And no, it is NOT reasonable to force readers to go to Nabble to find out
what the h*ck you are on about! 

There has been talk about making the Nabble gateways read-only. Hopefully,
that will happen sooner rather than later. 

-pd"



--
View this message in context: http://r.789695.n4.nabble.com/Daily-Category-Revenue-Stacked-Bar-Chart-in-ggplot2-tp4710431p4710598.html
Sent from the R help mailing list archive at Nabble.com.