Tidy Tuesday live screencast: Analyzing Broadway shows in R

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone I'm Dave Robinson and welcome to another live screencast where I'll be analyzing data I've never seen before as usual I'll be analyzing using our in our studio and I'll be taking data from the tide a tuesday project an amazing project in our run by the our for data science online learning community this is the third time that have been doing a live screencast there should be about a 20 or 30 second delay latency I've found so if I ask a question it might take 20 or 30 seconds I am reading replies as they come in so feel free to comment if you're watching this live but if you're at any point during the doing analysis if you feel like oh this would be an interesting thing to study or to analyze or have you thought of asking this question using this package feel free to write the suggestion I'll probably see it I may or may not include it but I love getting suggestions as I go and trying them out so feel free to add your comments live if I ask questions feel free to answer them in the chat if you see me make a bug would love to get your correction and I'm really excited to get started with this live screencast today we are going to be looking at Broadway musicals days are contributed by Alex Cookson so thank you Alex we're inviting the UM has a blog post I tend to avoid looking at the blog post before I look at the data weekly box office grosses from Broadway so I'm not a Broadway super fan but I live in New York City and I'm a big fan of Broadway shows so I'm really excited to see some of the things that we can learn about that we can learn about Broadway shows alright the there's some data I've got the tie like to used a tidy Tuesday package the tie shoes they are packaged so I'm gonna create an arm D and start looking at data any other New Yorkers in the chat and then else is a fan of um fan of Broadway shows library tidy verse library tidy Tuesday I don't actually have to load it it's already there but an insect theme light which is my favorite ggplot2 theme loading in today's data let's look what we have oh I love I love this um you can see the the documentation for each of these data sets okay so let's start with um let's start with you see we have grow seeds we have synopses synopses is the shows so we can actually see what the show and so the text about the show okay we can see the consumer price index so this is I believe meant to measure inflation and let's see pre-1985 this darts - was in the name okay so some starts and I'm one of them to clean slang for that looks like the most important table is gonna be grosses and we have I see okay so the data comes since 1985 and we have um yeah this is gonna be the most interesting of these data's that wanted to spend the most time in I wonder if I'll use the Qaeda metrics package again so let's see somebody said happy birthday David it is not my birthday today maybe they're talking to another David but alright let's see I need to start with the chats we have their show we have the week within the year ooh this is so cool there's a lot of data we have the weekly gross overall looks like across all shows and then then weekly gross is just for this show we have the average ticket price the top ticket price looks like there's a lot of missing data in potential gross and let's see potential at least in the early years potential gross is weekly box office if everything was sold at full price okay average price of tickets so low there's so much ginger it's so many person metrics here I think that maybe using tidy metrics we've seen some people in the car in the comments who are fan who are interested in seeing more examples of tidy metrics I might absolutely do that so we have number previews uh yep performances percent capacity oh there's so much great data here I really like this I really like this data set I'm really really very excited about it okay so I'm gonna start by looking at some of the most obvious things we'd we'd want to look at which is graph um say one that one or two shows over time so in the Broadway shows alright so if I take Gross's my favorite musical is like a lot of people's favorite musicals Hamilton so I'm gonna do a Hamilton I saw it at the public and then and then sad once and Broadway no twice on Broadway League gross and that works well as a line plot alright so basically the weekly gross was going up and up and up and then it's basically instead stable at Wow three million a week I'm gonna expand limits by zero I'm gonna scale like an penny was I guess they were probably raising the ticket price during this period of time and the comma let's see the labels is scales comma not comma actually majors in a dollar so yeah it started at 1.5 million going up to 3 million and if I looked at the average ticket price I probably assumes that the same day yeah if I looked at the average ticket price I could do average ticket price and yeah you can see like basically the ticket prices were rising for Hamilton it's basically been sold out ever since it started in mid 2015 alright so we have see Hamilton now I could try other shows what other shows I liked a lot I like to think of one that's been on for a while I like Sunset Boulevard that was kind of on yeah that had a revival it's still on that's cool so it was on for a bit in the 90s was on since 2012 maybe that's a little shock before this I'm gonna try the lion fingers are just lying The Lion King oh why would I neglected to do you might have seen it will say color equals show and distinguish these shows so when we actually see this interesting is weekly gross for The Lion King is is has some kind of periodicity it spikes in particular months Pradas I'm gonna guess the summer months they tourism season Prague goes down the Sun at the end of each year I'm not exactly sure but they did is there's periodicity so showed up started in the nine in the 90s and it's been going up and up and up there was maybe was closed down really some closed down don't know what it would be closed for this is not sandy was he was 2012 this could be just a data issue but maybe it closed down for a bit in 2006 or 2007 alright and then we see basically Hamilton quickly was out pacing The Lion King in terms of weekly gross we might want to aggregate to month or quarter which tidy metrics is really really good for if we wanted to UM look at this so other people are suggesting ooh and the d-pad suggests maybe four week moving average would smoother than the graph yes but we're definitely doing that with in hiding metrics I'll show how to create things like a four week moving average Alex Alex cooks and helpfully noted that Lion King moved theaters in 2006 and that's why it's shut down for a week or two so it's not a data quality issue it's it's a real thing would briefly was very low that's really cool okay so I'm gonna I could keep looking at a couple individual shows I'm going to smooth this actually I think it I think it's really great to show I'm gonna show how we use tiny metrics to aggravate something with um data over time with particular periodicity so what I'm going to do is say take a look at our grosses I'm going to I'm gonna filter for one show to start The Lion King now right now there is a a column week ending I'm actually I need to rename that could date that's sign about to pom tidy metrics how matters you can find them github self and get up I'd say rename bait equals we the thing we have to do in order to work with the functions and then there's this function cross by periods cross by periods says that I'm I want to aggregate this I'm about to 1 it's kind of like a group I want to activate this perhaps across week Oh kind of already this week maybe I'm gonna skip that let's say month in quarter I'm gonna start with that and then I might do rolling windows so the um so I'm gonna do is look at month so this actually says I want to aggregate this by month and by quarter well this did is actually duplicated and grouped the data so it actually duplicated it so there's now a period column that represents whether it's a month or a quarter that we're looking at and I crossed by periods and then summarize gross equals sum of weekly gross so the total of the weekly grosses across a month is going to be across a month and the period is going to be the monthly gross so now I've got the period and this is gonna be either months periods and across um we cross a period of weeks and months so what does that look like well I could graph date gross G on line and say color equals period so now I've actually notice I've actually aggregated it across at the sit in the same line of code cross my period to summarize I've had rate across months and I've a created cross-quarter if I'd want to create a dashboard I could actually see like what is the UM I could actually see like oh look at the quarter look at the month or for that matter look at the year doesn't isn't supported yet by caddy metrics it should be it absolutely should be let me confirm that no you're supported I don't know why I didn't think I was supported oh great month quarter or a year normally I wouldn't graph all three of these it's not really helpful because I'm I might only graph one of these at a time but it might actually be helpful if I I didn't just maybe I don't just want gross maybe I also want to know the average ticket price so I want to say the average ticket price I'm actually gonna say USD gross I'm gonna put it in dollars and then I say average ticket price um it's not yet adjusted for inflation that's that's an issue then I'll say average ticket price is mean of average ticket price I say USD we're gonna see you later Wyant ID metrics really helpful to do on to start things with you US dollars if they're money so now I've got sure I can do gross buy period but I can also do um Oh USD gross now call and again it's not that helpful to buy period it might want to filter for just one at a time I could also do it by average ticket price so I'm advocating by multiple dimensions I this is actually a pretty kind of a neat graph this is like if you wanted to know the average ticket price by by year by quarter or by month and we see is like once you kinda get I'm gonna try and make the lines a little bit thicker I'm gonna what am I gonna do I'm gonna make I'm gonna do LT y equals to alpha equals 0.5 thick transparent no not LT why I meant to do size equals to size equals one you I'm trying to just like yeah trying to see kind of all of these at it at once this is kind of an interesting way of looking at it as you see Oh month has a periodicity quarter does as well it's it's maybe it's probably higher in the middle to quote it kind of looks like it's high in two quarters probably summer and fall and then lower and then by year just going up and that could that certainly looks to me like it's faster than inflation though it's actually pretty important that I do is span limits y equals zero on this this is average ticket price remember not on total gross it looks to me like it's pretty confident it's faster than inflation but yeah the story is um really Lion King and get for $150 oh yeah in case this is like average ticket price over time by month by quarter by year I could have filtered for just one of them I could have um or I can visualize all three of them at once so that's how frost by periods works anytime you have a date you can start aggregating by gross buy ticket price it's really pretty power I'm gonna tidy this a tiny bit more say scale Y continuous I should have done late library scales up here I love using I love setting this I was saying uh labels equals dollar format dollar format with the parentheses lets us say here's the ticket price and then I could have said access time Y is average ticket price color is period so this ends up being a pretty easy graph to make once you have crossed by periods in your pocket and it's good for showing how we can smooth it there's actually something else that we can do here someone mentioned a four week window so there's actually crossed by period supports looking at rolling rolling windows so I can say crossed by periods these are my period names month quarter year I also say windows is 28 we say 28 day at a four week rolling average oops looks like alright this this looks like this is that we're gonna need a there's a there's an issue here but hopefully it's still I'm fingers crossed it still worked but let's see how does this look yeah it looks um what's a casita I'm gonna remove the month for a moment you know works but just needs to be a so rolling like 20 to 28 days here's the periodicity what if I said instead of 28 days mommy what is um what's 12 weeks is that in 84 yeah 84 days I could have added multiple here it could've said 28 and 84 I could have even dropped the court the quarters in the years and then I look at it again and I say well oh I actually need to say I need to explicitly remove this period is null still still practicing with this yeah the story is like I can look at it a rolling 28 or 84 day window instead of 84 what if I said what if I said that I've rolling in year and it's kind of like a smoother version of that year graph of that like overall year graph so this like a Roley so the point is I can do rolling windows I can do periods I can do a lot of things so I'm gonna do I'm gonna do month quarter in here and then I'm gonna do window for 28-day was this is gesture one so I'm gonna go ahead and and include a 28-day window and these are my my summaries alright so the UM we looked at the USD gross you look at the average ticket price what other metrics might have looked at look at maybe I want to know that now see Seoul is gonna be a number so I'm gonna do let me see I'm gonna do number of seats sold is sum of seats sold so it's like here's how many that's another metric we could have calculated and would work across an entire month and then I want to say let's see potential gross potential gross is logical that let's just that it's all known it's a little that's a little discouraging let me look at average capacity average or PC key capacity how did it to capacity it would be seats all divided by seats in theater times the promised times the sum of the seats in theater yet the thing is that we for prosecco passing can usually just do average across percent capacity but we might do let me see we might say let me see percent capacity I'm gonna do this I think the proper way which is the sum of sum is that this is in the denominator and and what is in the numerator but sum of seats sold I think that's the way we would compute it I don't wanna do the average capacity because the capacity could change in the course of a month or a year or a period so this would be the you know this would be the story yes so PCT capacity and now I could graph that and I could graph it across each period so seed capacity I really like this data see capacity is PCT capacity percent format so one thing we see when we do it at a percent now the month in the and the role in 28 days are basically the same one thing we see is that like oh the capacity secret pass up I have a bug somewhere there's no way that sum of seats there's no way I really there's no way it's been see capacity 800 percent I'm going to just say mean of PCT capacity and hope that that's a little bit closer I'm not gonna spend a lot of time and getting this right I'm gonna react because like I'm I think oh I got what happened yeah that's not gonna work but the Sun bets on approach I was taking doesn't work with my cross by approach it doesn't it's not a big deal it just means I'm um I don't think the average of PCT capacity okay so the UM so somebody asked is the 28-day window a moving average or an average each 28 days it's a moving average so there was a record each day I'm gonna track I'm gonna say no periods and just look at the at the movie in window and the story is that the window is actually continuous it's not quite continuous because it will be actually um it'll act it's not quite this because we only have data once each week but the story is that it's um it is a 28 day moving average it's it's at the preceding 28 days for each date so if I if I show Lion King summarize arrange ascending date this is the result it's gonna have data for every day and the the aggregate prices but they're only gonna change once every week because we only have data per week we do not have daily grosses well this is a really good data set of showing tidy metrics I'm really um I'm really excited about it particularly for showing cross by periods and how we would use cross by periods to get moving windows and period aggregations in a tidy format so the UM all right let me see so I took a look at let me see ad piece of pita pasady and um here we go yes so this is another metric and notice this one is a percentage when I go in a rolling 28-day window this was that bit where it moved theaters but otherwise like that it's mostly filled to capacity with some exceptions since in the last about ten years it's been fully completed filter capacity this dip it started in the fall it's not no it didn't even saw the fall it started maybe the year ago it's not coronavirus awaited i'm not sure what maybe started this taping capacity in the last couple years but mostly mostly likings been close to capacity all right so that's a story about about blanking and summarize it I could do it for another show could do it for Hamilton date is still named this but uh anyway but Hamilton has been a little bit over 100 percent capacity consistently so it always sells out and sometimes so and so some additional space some standing-room-only or something like that so that's really um that's pretty cool okay so notice like this tool this crossed by periods I'm gonna I'm gonna bring back activating by month by quarter by year should I do it by much I do it by month month yeah I'll do it I'll leave I'll leave month in and then also by a 28-day window yeah alright so these are the metrics gonna be I'm gonna track thing is I could do this for one show and then I do it for another show dude if another show dude flip here you do it for another period I could keep going around that really we want to create an interactive dashboard that lets us explore this little s is explore this data ourselves so here's what I'm going to do there are too many shows right now too um there are too many shows to support to support using every graphene every shorter dashboard at least with with the stuff that comes built-in to tidy metrics and shiny metrics but I'm gonna show how to create a dashboard so lets you visualize several shows and let's see visual has a couple of shows and and then we have an interactive dashboard that lets you like examine their their the money they make the average ticket price how many seats was sold the capacity everything else each of these metrics across this um this dashboard we might even have a chance to correct for inflation which I haven't done yet you excited I'm excited share it if you're excited in the comments definitely go for it we're gonna be doing tiny metrics and shiny metrics what I would love for people to do is name in the comments a couple of their favorite Broadway shows preferably run ones that they're from that they know have run for at least a couple of years since 1985 and hopefully ones that I know how to spell I already included Hamilton of The Lion King he will go ahead and shout out other ones I really like lame is roblem oh um we have rent as Justin did I spell him at Leena's right let's find out I am just dreadful at French has everyone learned when I was analyzing the Tour de France and trying to I'm trying to UM pronounce things I spelled lame is right anyone else outing out um once we have Phantom of the Opera all right I will not be including cats I am NOT a fan of cats but I am a fan of wicked it's a great suggestion from Deepak and let's see Hamilton Lion King lay Mia's rent Phantom of the Opera and oh we got Harry Potter and the cursed child I'm gonna I'm gonna quickly guess this is how these things are spelled in the data set oops I'm not gonna call anything summarized anymore Harry Potter let's find out if Harry Potter's in the data there's a trick that I would do idea could say string detect show Potter and distinct show parts 1 & 2 that's enough that's an awful lot here parts 1 & 2 I might need I'm actually going to go ahead and oh the Phantom of the Opera alright since thank you so much so the AH we have eight shows here I'm gonna create a dashboard that lets us visualize these eight shows and I let you explore like let you or another Broadway fan explore these shows later I might have a chance to show how we do it for all of them let's take a little bit more work and the other thing that I'm gonna do is I'm gonna clean this a little bit I'm gonna say show is string remove from the show I'm gonna remove parts this is I'm trying to do a um I'm trying to I'm trying to remove the parts one and two I because gonna end up really big at any graph we make okay so now I I crossed by periods I summarize but I do one more thing I'm going to cross by dimensions on show what does that mean what that means is it cross by dimensions is a lot like group what it does it says show is a dimension of my metric it's a way I can break it down an overall metric like the amount of money made on Broadway to and breaking that that dimension and visualizing a graph get a more specific dimension within it and what I'm gonna do then is say here there's grosses and I'm gonna save this as shows summarized all right and the um let's see shows summarized here shows summarized and what happened when I did the crossbow I'm askin thrown an ungroup what happened when I did that because after a group by and summarize cross by boat what happened is it added a level called all check out that level in show it's called all that summarized across every show so it's like a cross these 1 2 3 4 5 6 7 8 shows the average ticket price in 1987 was $36 not quite because I think only only maybe only only a phantom and limit is maybe rent we're certainly only those three had opened by 1987 I don't think I doubt all three were playing but the idea is that I'm so average price would be a little confusing in the overall but we can look at that and we get it at the capacity across all of these shows so the UM we have shows some we have shows summarized and now if I visualize this I would probably want to look only at one period shows summarized and say color is show Oh oops period is let's say year let's say quarter years so so little data so now what we're seeing is like oh this is the total gross from each show or overall I could have dropped the show is not equal to overall at all and heck I could have actually done this is a stacked bar plot I could have said fill is show and now I saw oh this is how much money Broadway was making over time broken down by a couple of shows here's wicked showing up here's Hamilton showing up here's Harry Potter the cursed child torn up I think um yeah this dark green is lame is I when did I see it I saw it I've seen it I think twice on Broadway and I saw it around here in Oh sick do say no six was even play no six maybe I don't know when I saw it but the the lot uh and here's the appears Lion King and here is a stacked floor applause so like this is some ways we could visualize that I could also have looked at their average ticket price I filtered for period and show not equal to all and then I look at average ticket price these are two metrics that I decide to take a look at loops if I were doing an average ticket price I definitely do not want a stacked bar plot that's not a good visualize it it's not good when it's prices so now it's showing okay Hamilton is by far the most expensive show there's ever been on Broadway we remember we have adjusted for inflation I hope I have the chance to but I don't want to like distracting the other things we're doing and yeah so here was seem like okay here's here's Harry Potter which actually had a high price and lowered I wasn't the biggest fan of Harry Potter it wouldn't surprise me if they lower their ticket price a little bit The Lion King goes I have a ticket price going upward Book of Mormon briefly at a very high ticket price yes so we're getting a sense of how we can visualize each of these metrics and some of them need a bar plot and some of them need a line plot notice I'm doing all this stuff I'm doing this like I'm doing this filtering I'm doing this this Troy Board the way that I would make a dashboard I'm gonna move I don't know I have to try and get this code working again later if I want to have everything if I want kind of everything still going I hope I did I didn't bid something a cardinal sin of my screencast is that I edit code instead of starting new ones so this code doesn't work anymore I might get back to that later so the so so let's say we have shows summarized um yes so the story is these are metrics gross ticket price and B seats all PC capacity these are four metrics defined over time and the time and this in turn show is a dimension what we're going to do is take shows summarized where is it women we're to take it I'm gonna turn into a met into a metric in the tiny metrics framework we can do use metrics scaffold it's a helper function that gives me some stuff that I'm going to add to our to the top of our document here I'm actually adding editing it up here this format this uh user interface is going to change a little bit right now metrics Broadway revenue I'm giving a category in a sub category owner I get I put it in my email this just um this is stuff that right now patty metrics use I think it's gonna change at some point but a total gross USD I said not adjust it for inflation I'll put the same here I might delete and be seed sold I think it might not mean what I think it means I might be something I'm not and I'm not tickling interested average percentage opacity average across weeks and the time period so what I'm doing is I'm adding a little bit I'm adding that like a human readable title and description that's really essential if I'm gonna turn this into a metric and it turns into a dashboard also much we put you the documentation that user interface part upfront say an average ticket price USD oh if it's USD I should say USD average ticket price the prefix in a metric is meaningful it tells them the dashboard how to graph that so I'm actually gonna call this u.s. the average ticket price shoot no I'm not shoot shoot shoot that would would create a bar clock rather than a lie pop there's those little details that how tidy metrics works that I'm still worth Ramnath and I am the co-creator are still working out but I'm showing here's we do average ticket price here's PCP capacity or percent capacity average across weeks the time period and a dimensions is show shows title that's a solid description I probably need more description I'm going to be like production izing this this son might definitely turned into a blog post is a great data set terrific data set for showing high D metrics and shiny metrics so here's my metrics here are my dimensions I don't need this line anymore and what I do is I say shows summarize create metrics on it Oh NBC sold I need to rerun this line I hadn't done that yet so so notice I take my a of data this is the raw data I do a little bit of cleaning I get a subset I take a show I rename column the date I need that for cross my periods I group it by dimensions but also included all level I grew by periods month quarter year or a rolling 28-day window and then I summarized three metrics after that I'm actually going to move this code down because it's not as relevant to the metric framework it's like an example after I've done that I created my metric objects and now I have show metrics is now a list of three metric objects so now it's Broadway revenue that's the title USD gross which goes show which then shows Oh in this dimension in this month in the state in this VAT had the the metric had this value it tells me which periods of calculated in for it tells me when I saved it but can be really useful in it in a dashboard it tells me the dates this is called a cable metric oh I thought that was documentation that there isn't this is called evil metric and what it does is it um what it what it is is like it's a special version of a table that has this extra information with it it's really helpful for turning it into a meaningful visualization so this one note that like we treated three metrics the total gross the average ticket price and the average capacity these could all be interesting is interested Dean to someone who's um to someone who's into who's into Broadway so we're gonna make a dashboard out of each of these the way that that works is that will take on show metrics it's now a list of these three metrics here's one our total gross and we say uh and I'm gonna load up shiny metrics which can be installed from github it's still a work in progress I'm gonna say preview underscore metric of Broadway revenue USD gross open it in the browser and here's my my data it's look at what this is is a dashboard now of the total gross of a show in dollars and this is now a stack bar plot where I can look at um here's all my here's all my shows I thought there were eight oh it's an and and notice it's over only the last year I could switch it to all-time I could also have done just the last six months or I could have set a custom period so this all comes with shiny metrics this is called a metric panel it's really helpful for visualizing a metric with dimensions and periods over time so I'm so this is now my interactive dashboards a plotly dashboard of the gross of Broadway shows over time notice it took like one line it took a few lines of code to calculate and two lines of code created I didn't need to write the documentation but why did I did I leave it oops I did need to create the documentation but now we can see oh here are my shows look over all time you can look by month I could look by quarter I could look at rolling 28-day window well a 23-window is kind of a lot of data here but yeah here we go and now we can see oh here the gross of each of these shows and that and because it's a it's $1 it's looking at them aggregated so think about how you might use these metrics if you're at a company you could break down your annual current revenue by by various dimensions if you're analyzing let's say I don't coronavirus data you could say okay break down cases by country there's a lot of things you can do in terms of um there's a lot of things you can do in terms of look at a change over time this is a bug it only goes back why's it only goes back ten years I think that's has to do with shiny metrics that that looks at them might be a that might be about but um we just might not be able to get it farther back than 10 years it's calculated in the data but it might not show up okay I'll have to take a look at that that out later but the story is here's my shows over time well look at Hamilton popping up this plot Lisa um so I can easily say oh I just want to look at Hamilton by double-clicking on it or I want it or um once how do I get them all back others well remove or hit one to move just one or hit the CSV button to download this data as a CSV from this period so this is pretty cool sue and we even get documentation we get that sentence that I added that not adjusted for inflation and you have the CSV data if I clicked it downloads the data that you're currently looking at including the dimensions um in Broadway revenue see it tada CSV so yeah so that's looking at the total gross but I also could have looked at another one of my metrics what if I want to look at the ticket price I could have said the USD oh I think that I called this average ticket price no right I did have to I yeah this was an issue because it's an average I could have said Broadway revenue average ticket price the what was i complaining about the thing I was complaining about right there was that I'm not able to get this in that now this y-axis is not in dollars oh and look at all time so this is notice it doesn't say dollars here does it also doesn't go to zero there's a way to make go to zero I'm gonna have to try and remember this remember what it is but the story is now I've got an interactive visualization with and say oh here's by way in black you can see the overall average and then here I can see oh okay this went up this went down and you say oh let's say I don't care about let's say someone says Oh Leamas was only running for a little bit I don't want to include that in the visualization phantom runs the whole time wicked runs the whole time that's cool cursed child ran for a short time don't want to include it you'd say Book of Mormon okay you pointed you you can now you can edit this graph like a lot you can choose what you want to look at because the plot of the graph you can then say oh I looked by month but I really want to look like quarters smooth out that variation or by rolling Windows so stories all of this that's this I would buy it over and you can still export the data and whatever form so story is um you have your documentation these are the features of shiny metrics the idea is as long as you calculate the data in the right way there's a way to explore this um so this is so this is how kaity metrics and shiny metrics well by me and Ramnath adenosine work together to create interesting dashboards last one I'm going to include is PCT capacity percentages so this is actually what I was referring to before when you use PCT in your prefix it actually knows to make this a percentage and that's really helpful notice like there's so little customization the customization was I get a title a dimension which now has a M little browser window on top of it browser on top of it and now I can see okay here's the capacity and something interesting here is phantom is uh is going debt is sort of the only one that's been substantially going down over time wicked is down to like 86% Hamilton has consistently been over a hundred percent it's kind of the the idea I can look at all time I see a phantom has been mixed and yet lame is did not run for very long who can actually and its release its most recent iteration we can notice that's because it mostly um yeah you can take a look at that and most that was like in the UH did not was not completely sold out during that time period line can usually close to selling out Book of Mormon usually usually around selling out and and so on yeah so this is a an interactive visualization all right so the um so let's see all right and include pots some Ramirez is a fantastic question can you include a button in the dashboard to choose one of the three metrics the answer is sort of not by default so the story is I was just looking at three metrics and they're three lines of code the answers let me let me think for a second about whether I can I can show this in a whether I can show this in a in the time that I have how much time we have a fifth I have 17 minutes yes I can can I know I'm actually not going to take the risk sorry there is a package called shiny bombs Ramnath and I developed it and the friend was an opinionated frame work for organizing that for organizing dashboards so story of shiny bones is that you you put everything into a yeah mo file like this and then it sets up your metrics I don't think that I could in ten minutes set up a dashboard could I you know what I'm gonna try it okay few things I'm not going to do I'm not going to do any analysis that does isn't about parametric Shanti metrics of shiny bones I'm not going to be doing correcting for inflation which I would have done by joining this data with the CPI I'm just going to look at doing shiny bones and I should be able to do it in the next 16 minutes alright the way that shiny bones works is that do I have shiny bones installed here I think I do what I do is I can create a scaffold a shiny dashboard app using shiny bones so what I'm doing actually is creating a new our package shy - word app using shy bones and I'm gonna call it Broadway I'm creating a new yeah I'm creating a new type of - but I'm gonna do it in this folder repositories data screencasts and Broadway shine bones create project yeah I think I'm gonna be able to do this okay this is gonna be really cool I'm creating a shiny - shiny - were using shiny bones that that allows to visualize all three of these metrics at the same time so what I'm gonna do is I'm actually just save this we could save this in a lot of different ways I'm just gonna save RDS this to the file um Broadway shiny bones slash show metrics dot already yes I'm saving this to an RDS file which allows me in this app to load in so yeah I'm just gonna load it in as the data Dierks is designed to work well with shiny bones I have I'm gonna cross my fingers and hope that everyone else is crossing their fingers - I could use all the things I had because some of these this functionality is still a development but I want to show how you create an app using um shadow bones way say is read RTS the show metrics dot RDS so i'm reaiiy basically I'm bringing in my metrics I'm loading these I'm also gonna I'm also gonna load and I believe I have to guess I have to loan in shiny metrics to this is the Akhtar this is a lot of stuff that this is like the details of shiny bones you can ignore it mostly the story is mostly we're not gonna work in act are we're gonna work in this yeah mol file the way that that shiny bones works is that when you run the app it doesn't it doesn't look at your code it looks at this yamo file and uses that to scaffold that out your app it's kind of this is the ribcage of the app which is why it's called shiny buttons so you've got your dashboards we've got your widgets you've got your charts but this is saying is here's the components of the page in yamo if you haven't seen yama before yama looks like um yamo is this kind of format where it says here's a list here's items within it and then what i do is i go to app and i run it and what this actually does is it creates a shiny dashboard with those components the stories it doesn't yet right now it's not yet supported but this but notice that I didn't write code create dashboards widgets charts give them each of these cute little icons I just um we just have this built in this text icon and so on there's there's nothing else there so what I'm gonna do is delete these and here's the way we work I'm thinking about the second here's the way it's gonna look it's gonna be I'm gonna make it charts and the story is we say I remember myself one second here's how how do we do this it's been actually a while since I did this so thank you for every metric we're gonna say is a metric panel and I remind myself the arguments the story is I is shiny bones every one of these pages is a module so module given you shiny modules they're really powerful when you're creating larger apps they made each page self-contained shiny bones a way to hang a lot of modules off of that dashboard off that ribcage they were created in this ECMO so stories here I say well I want um metric Oh metric page is what's called nope nope I just remembered this doesn't work signs knots put it in here signs not all right ah look at me go that's okay I think I can I might still be able to get to work all right the story is I say here's my my text is revenue and each of these is going to get oh no yeah well let's see let's let's see it but if I can get it to work I'm missing something there's something I can't do here there's a there's a module that's not so we I supported um but I was so excited about I was so excited to show you folks shiny bones I might still do it I'm thinking about how to it expression I use a global variable I think there's a chance this how it works is action yes so this module oops oh I did this one module metric panel is the name of the module so this is a module metric panel as a shiny module and then it gets one argument metric so this is how and then think that's the way to do it exclamation point expression I might need to look that up if some remember is how to in yellow do um module metric panel I was pretty sure that what it was was mod oh I see it we're actually close here but there is a reason is this looks ugly it's because it's not that ugly but like this reason it looks a little bit off yes in answer quick answer tomorrow is that once it is answering uh one person all right so the story is here we go this actually worked this oh thank you for everyone cross their fingers because the story now is that I can actually say that was what I can then do is define my dashboard using three tabs revenue ticket price trace and average ticket price and let me see revenue ticket price and what was the third one um Oh capacity I might even shorten this just a price in capacity and I say I think this looks pretty darn close yes I took a minute to setup of what what just happened is with one llamo file I now created a three tab shiny app that I'll pop up in our charts here so that we could you can see is then like what happened here in in this llamo as we said well I want a tab called revenue I wanted to include a module column the module metric panel metric panel is a modules provided by the shiny Metro so you can use shiny shiny to bones without using shiny metrics so it uses the metric panel module and the argument of the metric panel module is is our metric object so this is the UM so this is here where I said okay here's my metric panel and here's what I'm passing to it and then this this is the messiest part it should it um it's where actually to say okay we're actually passing this is not a string it's an object in llamo you can do exclamation point expression there's a little bit of messing around with us here who someone pointed out that I did this wrong and this would be us the gross yes so I'm gonna show this I'm gonna visualize this one more time so the revenue price and capacity are all three three tabs that will cannot in here and notice like I didn't define the documentation or anything else that was defined at the time of the metric being calculated and saved notice that it tells me was last updated 18 minutes ago that could be helpful if for example your um we calculated metrics every day or every um or every hour but the story is now shiny bones allows us to create these tabs create these um these sidebars and if and shiny bones it's also really important about it is it separates the the itself it separates the structure of the dashboard from the contents of each of these components and that makes it really easy to rearrange things what if I actually wanted what if instead of putting these in separate tabs I want to put them in separate sidebars like separate like here what I would do is I'd move let's see I would move I think it goes like this I'm gonna rearrange a little bit I'm just kind of this we first look check if this works yeah and open a browser yet that works what I do is move that and say okay I'm gonna rearrange them and say revenue price capacity and then and then change this to average price average what is it average ticket price I think and change this to PC capacity and while I'm at it I can change these icons these icons come from the free version of font awesome which you can look at here say font awesome and check this out I can search finest was a really great set of I can search for I want the price one to have a dollar icon on it use is called a dollar - sign I want this this is I want capacity maybe that's people or seeped is anything for seat is a sign proceed share now I really wanted I really wanted one of these theater seats which I'm not really seen but I'm gonna try people people people people and Louise trying to find out Oh user oh I think there's users which I think actually without even looking it up I think looks good the story is like I just changed these icons and the module still remain the same revenue price capacity price I probably should have done oh I'm gonna make revenue I'm gonna switch this around I'm gonna say revenue is the dollar sign and price should probably check it if I can find that ticket check it out check it check it out you know and now I'm showing these three dashboards so noticing like I can image it on 10 minutes we went from having these on these Motley's this data calculated to having a Shawn app with like these three components on it and I can rename it I say this is called um it's called Broadway shows we don't have this app with each of these components revenue price capacity we would customized it through that yeah Malvado flat file so that is shiny bones I'm gonna walk you through the three packages one more time before we're done what if cher is here we have um here we firstly I did the UM to some regular cleaning with a tidy bus tidy metrics is what allowed when you cross by the mentions show and have our various levels as well as all I could have added other dimensions and then cross by periods you in like terms of month quarter and year the month quarter year and then calculate my metrics so this is Heidi metrics that's there's a cross by create you know Arkady metrics also has create as what supports create metrics then we have shiny metrics which allows to preview metric it's that metric panel module that lets us visualize these the this where I got one individual module that is shiny metrics and finally if I want to turn those individual modules into one big visualization that is shiny bones so these are three packages around earth and I have developed that are really powerful in terms of creating dashboards for exploring for exploring data so those in one hour from opening the data we now have I have the ability to look we have all this functionality in terms of um a kind of business intelligence of looking at our shows revenue that was pretty cool yeah okay that was funny I definitely learned a few places that are gonna be working on these on applications so alright that concludes our um my screencast feel free to stick around I'll turn around in the chat if you have any questions but I had an awesome time I hope you did too and I'll see you next week
Info
Channel: David Robinson
Views: 2,485
Rating: 5 out of 5
Keywords:
Id: OhY5ZaILRpg
Channel Id: undefined
Length: 57min 31sec (3451 seconds)
Published: Tue Apr 28 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.