<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Manasi Mahadik on Medium]]></title>
        <description><![CDATA[Stories by Manasi Mahadik on Medium]]></description>
        <link>https://medium.com/@manasimahadik?source=rss-c789683b86be------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*oAvHzgZm8H6elbQi_mYnzA.jpeg</url>
            <title>Stories by Manasi Mahadik on Medium</title>
            <link>https://medium.com/@manasimahadik?source=rss-c789683b86be------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 00:26:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@manasimahadik/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Exploring the gt (Grammar Of Tables) Package in R]]></title>
            <link>https://medium.com/data-science/exploring-the-gt-grammar-of-tables-package-in-r-7fff9d0b40cd?source=rss-c789683b86be------2</link>
            <guid isPermaLink="false">https://medium.com/p/7fff9d0b40cd</guid>
            <category><![CDATA[r]]></category>
            <category><![CDATA[tidyverse]]></category>
            <category><![CDATA[dataviz]]></category>
            <category><![CDATA[datatables]]></category>
            <category><![CDATA[gt]]></category>
            <dc:creator><![CDATA[Manasi Mahadik]]></dc:creator>
            <pubDate>Sun, 13 Sep 2020 02:54:33 GMT</pubDate>
            <atom:updated>2020-09-19T11:19:07.305Z</atom:updated>
            <content:encoded><![CDATA[<h4>Easily Create Presentation-Ready Display Tables</h4><p>I love <a href="https://cran.r-project.org/web/packages/magrittr/index.html">migrittr’s</a> forward-pipe %&gt;% operator. IMO, it is just the one of the most fitting, useful and natural, almost reflex like operator in all programming. In the past, it has propelled the <a href="https://www.tidyverse.org/">tidyverse</a> to data wrangling superstardom and it is now venturing into the task of making tables dramatically easy.</p><p>The gt package is the latest ambitious entry to make tables in R more accessible, modifiable and reproducible. It is aimed at being the ggplot2 for tables (in Hadley’s words, not mine) and given the magnanimous impact that the former had on the R viz, the package comes with immense pressure of its shoulders.</p><h3></h3><p>gt = grammar of tables. It aims to do for tables what ggplot2 did for graphics. It&#39;s still early days and tables are surprisingly complicated, but this is a very exciting package by a skilled developer! #rstats https://t.co/138FrCy5th</p><p>Here’s an illustration of the architecture of the gt package —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*PCc6HC87TY_FSiQY8nMNUA.png" /><figcaption>The Grammar Of Tables Layout. Source — GT Documentation, R Studio</figcaption></figure><p>We will be using the <a href="https://github.com/allisonhorst/palmerpenguins">palmer penguins</a> data, an alternative to the now <a href="https://armchairecology.blog/iris-dataset/">infamous</a> iris dataset. You can download the data <a href="https://github.com/manasi1096/TidyTuesday/blob/master/31July/Penguins_clean.csv">here</a>!</p><p>Post performing basic tidyverse verbs to filter and group the data in the desired shape, we invoke the gt() command and specify the desired row.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZxLjRtgLztgPJgoSWpUlwg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PyVHtbUmNrn0hFxgEWo1ow.jpeg" /></figure><p><strong>Add Column Spanners</strong></p><p>As evident, the above data is the simplest and rawest data table created. We now proceed to format it. We begin by adding column spanners and bringing male and female columns in their respective hood and customise their font and alignment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x2KNKGl62K3fYqCkuiBqmQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s6mIQafTOzWXEV3Sdn9cDQ.jpeg" /></figure><p><strong>Create Row Summary Statistics &amp; Format Data</strong></p><p>We can also add a descriptive statistic specifying mean or totals per metric within the table. This could enable relative comparison and could lead to rich insights. Here, I have calculated the yearly average bill length, bill depth and flipper in each island and formatted the number to include no decimals.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zWSszNMZWR5kjHEk14OBsA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QznIXe2_ygEfM0Fu2ruDzQ.jpeg" /></figure><p><strong>Add Colour &amp; Footnote</strong></p><p>Now the fun part, I have used one of the plethora of palettes available via the palatteer package and conditionally formatted shade of the table in accordance to the numeric value of the cell it represents. The gt package also a feature to add a footnote to the table. I have used it here to specify the metric in which the bill length, bill depth and flipper length and body mass is measured.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zhZAlBgJXSOk168AL9xQSA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BnxOerz45DZo71kqtiKZ6w.jpeg" /></figure><p><strong>Add Table Title, Subtitle &amp; Change Column Labels</strong></p><p>While the colours have bought in buoyancy to the table, a title is much needed. The package also enables the use of markdown text in the title/subtitle. Here I have used the emo::ji package to add cute little penguin emoji’s in my title. Since the column labels were still messy, I have also renamed &amp; formatted column tables to a shorter, more readable title.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ewR5jSCtK5az3h3d-Vn30g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lmJ_N_Hy3xGaB4W66L40FQ.jpeg" /></figure><p><strong>Add Background Colour &amp; Format Borders</strong></p><p>I know proceed to add custom colours to the remaining whitespace, i.e title, subtitle, row average and footnote. I have specified the desired HEX code referring to <a href="https://colorbrewer2.org/#type=sequential&amp;scheme=Purples&amp;n=3">this</a> colour brewer for aesthetic advice . I have also added dotted borders to the year rows and have thickened the borders along the island rows to amplify differentiation and boost readability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dpi9NUwZGgiShhxAUXErBQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P5NcTX5vFwSEA7gWPeatzg.jpeg" /></figure><p><strong>Adjust Font , Alignment &amp; Add Source Note</strong></p><p>As a last finishing touch and i order to ensure font uniformity, I have applied the Oswald font across the table and have centre aligned each cell. Lastly, below the footnote, I have added a source-note that states the data source.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QdI5Td0kbC8BaXazUKSu3A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/1*0MR0UkAYtzOeIjqzMgrK2w.png" /></figure><p>And that’s the final masterpiece! :D</p><p>Hope you enjoyed reading. You can reach out to me <a href="https://twitter.com/marvelsmanasi">here</a> &amp; <a href="https://www.linkedin.com/in/manasi-mahadik-a66b26146/">here</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7fff9d0b40cd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/exploring-the-gt-grammar-of-tables-package-in-r-7fff9d0b40cd">Exploring the gt (Grammar Of Tables) Package in R</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Decoding BTS’s ‘Map Of The Soul: 7’]]></title>
            <link>https://medium.com/data-science/decoding-btss-map-of-the-soul-7-a73ec4e78ed1?source=rss-c789683b86be------2</link>
            <guid isPermaLink="false">https://medium.com/p/a73ec4e78ed1</guid>
            <category><![CDATA[ggplot2]]></category>
            <category><![CDATA[highcharts]]></category>
            <category><![CDATA[visualization]]></category>
            <category><![CDATA[rstudio]]></category>
            <category><![CDATA[spotify]]></category>
            <dc:creator><![CDATA[Manasi Mahadik]]></dc:creator>
            <pubDate>Sun, 22 Mar 2020 16:28:52 GMT</pubDate>
            <atom:updated>2021-08-23T15:51:24.207Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Data Science In BTS’s ‘Map Of The Soul: 7’</h3><h4>Analysing BTS’s new album using data from the ‘Spotify’ and ‘Genius’ web API.</h4><p>The adjectives in Big Hit entertainment, BTS’s parent company’s name seems too paltry to describe the global mega stars that they have created. It is downright absurd to call BTS just big and hit, legendary and groundbreaking could come close. In fact the hysteria at a BTS concert is so massive that according to the <a href="https://www.cnbc.com/2018/05/25/how-bts-members-rose-to-success-in-k-pop.html">New York Times</a>, the noise level in their concerts are &quot;well past the noise level at which permanent hearing loss becomes a serious concern”. The band from Seoul contribute a whopping <a href="https://www.axios.com/bts-kpop-band-south-korea-gdp-3099f1dc-ce5c-4580-bf76-09df2d236f54.html">$ 4.65 billion</a> to South Korea’s GDP, more than the national airline, a comical irony because BTS can’t actually fly Korean Air. Some <a href="https://channel-korea.com/bts-sasaeng-fans/">sasaeng</a> fans of the BTS <em>ARMY</em> (Adorable Representative MC for Youth) illegally obtained their flight details, and hounded them during flights, making it impossible for them to fly any commercial airline.</p><h3>New York Times Music on Twitter</h3><p>Two train operators, one on each side of the train, were in charge of transporting Jimmy Fallon and BTS back and forth along a track from a Bowery platform to a Canal Street platform https://t.co/lBwz8WiJ4V</p><p>If BTS could time travel to 7 years back, at the cusp of their debut and flick a coin in a wishing well for every milestones they would go on to break, the well would well, choke. Their reality today is perhaps bigger than any dream the septet could have imagined. And at this level of intense super stardom and Midas like touch, they’ve made their comeback with thier fourth EP - ‘Map Of The Soul : 7’. In the months leading to the album release, BTS has promoted multiple singles, performed at the iconic transit hub — Grand Central Terminal in New York City for ‘The Tonight Show’, featured in a mini van for James Corden’s “Carpool Karaoke” , given multiple interviews and have done meticulously promotions both in America and South Korea. In fact, the<a href="https://www.quora.com/Why-is-Jung-Kook-of-BTS-called-Golden-Maknae"> <em>golden</em> <em>maknae</em> </a>of the group, Jungkook even ramped up his <a href="https://www.youtube.com/watch?v=v_9vgidPJ8g">english skills </a>to send words of love and appreciation to his American ARMY. The album received <a href="https://www.soompi.com/article/1383594wpp/bts-surpasses-4-million-stock-pre-orders-for-upcoming-album-map-of-the-soul-7">4 million pre-orders</a> and upon release sat at the zenith of every chart.</p><h3>Annie ⁷ ✨ on Twitter</h3><p>I think about this a lot, but I believe a big part of @BTS_twt&#39;s success and what has won people over, especially a lot of older fans, is their intelligence. Emotionally and cognitively, they are all extremely smart and thoughtful. They&#39;re much more than just pretty faces.</p><p>The new album is tasked with acknowledging and riding on their success story but also forging the band’s road ahead in the face of unprecedented media scrutiny. It is a love story about themselves, a much deserved <em>we made it </em>epiphany, along with a sigh of responsibility acknowledging that they are now entering uncharted waters- where no one has gone before, with the only records to break are the ones set by themselves.</p><p>BTS primarily sing their songs in Korean and almost immediately the translated lyrics are available online for their international audiences to interpret. I tapped into the genius Web API to understand the number of annotations per song. I used the ‘<em>GenuisR</em>’ package in R which provides a easy interface to access the Genius web API. The API client access management page needed to make the client_id and a client_secret can be found <a href="https://docs.genius.com/#/getting-started-h1">here</a>.<strong> </strong>Here is a small glimpse of the annotation track data-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*hptMApxHkxfH1eutAmrVyA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*jJW-ymqHPPr9UKomj8UevQ.png" /><figcaption><strong>Genius Annotations For Map Of The Soul : 7 s<em>ourced from the Genius API</em></strong></figcaption></figure><p>I have used highcharter() , the R wrapper for the Highcharts JS package in order to visualize the data. You can read more about applications of highcharter() in R from one of my previous posts <a href="https://towardsdatascience.com/exploring-highcharts-in-r-f754143efda7">here</a>. As expected, the most analyzed song is BTS’s biggest song till date- “Boy With Love (ft. Halsey)” followed by “ON (Ft. Sia)”. The next two songs are rather introspect ones, belonging to group’s rappers. J-Hope’s “Outro: Ego” which is a tribute to their journey <em>“Life not of J-Hope but Jeong Ho-seok flashes by”,</em> he says as the childhood pictures appear and Suga’s moving take on the struggles of fame, “Interlude : Shadow”.“Fame is like a shadow,” Suga told <a href="https://www.theguardian.com/music/2018/oct/11/how-bts-became-the-worlds-biggest-boyband"><em>The Guardian</em></a> just before the Korean superstars’ first UK shows in 2018. “There’s light and there’s darkness; it’s something that follows you constantly and not something you can run away from.” He carries that thought with him and makes it the central nemesis in his fiery rap album opener.</p><p>“<em>I wanna be a rap star/I wanna be the top</em>,” he begins in his rage engulfed sermon, blatantly laying out his ambition. But now the success the once-struggling producer longed for has well and truly been secured,it’s not as rose tinted as he imagined. “<em>I’m afraid, flying high is terrifying</em>,” he resigns. “<em>No one told me how lonely it is up here.</em>” Looping back to that idea of the titular shadow, he later raps from its perspective, warning himself: <em>“We are one body, sometimes we will clash/You can never break me off, this you must know.</em>” Lyrics reminiscent of Eminem’s “Almost famous” prescient warning <em>“Be careful what you wish for”</em>, and even the isolation and <em>“Tragic portrait of an artist //Tortured, trapped in his own drawings”</em> that Eminem paints in <em>“</em>Bad Guy<em>”.</em></p><p>Each member of the group comes with a story and their own distinctive style and musical inclement calling the album to generously makes space for everyone. It is rife with solo songs and duets between members allowing them to tell their story from their own lens and leading to melange of sonic ranges and genres. “The genre is BTS”- Jungkook, J-Hope and Jin recently said. In order to classify these esoteric tides and ebbs in melodies, I classified the the 20 song EP into four buckets basis their “Energy” and “Valence” i.e musical positiveness sonic scores sourced from the Spotify Web API.</p><p>To access the Spotify application program interface, I used the interface provided by the ‘Spotifyr’ package. The Spotify web developer API access needs a unique client_id and a client_secretwhich can be made <a href="https://developer.spotify.com/">here</a>. The ‘Spotify for Developers’ website created by Spotify is also an excellent resource for developers who are keen to use the Spotify interface. You can also link your own Spotify account and your playlist and do some nerdy analysis on what you actual listen to. You can find some wonderful use cases of integrating the Spotify web API in R <a href="https://medium.com/@simranvatsa5/taylor-f656e2a09cc3">here</a>, <a href="https://msmith7161.github.io/what-is-speechiness/">here</a>, <a href="https://towardsdatascience.com/predicting-my-mood-using-my-spotify-data-2e898add122a">here</a> and <a href="https://rpubs.com/womeimingzi11/how_my_spotify_looks_like">here</a>.</p><p>Below is a small glimpse of some of Spotify’s sonic attributes and their scores-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7PBBxD2wbutNMEIjXYWlLQ.png" /></figure><p>To create the visualization of the songs I used the wonderful <a href="https://ggplot2.tidyverse.org/">ggplot2</a> in R, a declaratively visualization creating system, based on <a href="https://amzn.to/2ef1eWp">The Grammar of Graphics</a>. The scatter bubbles in the chart are colored basis the sentiment they largely represent and are sized by their intensity of that sentiment.</p><p>“I think it’s less meaningful to put music into genres”, Suga once professed. With his “Interlude : Shadow” sulking at a 0.15 on the musical positivity index as compared to “Boy With Luv ft. Halsey” jumping with joy at 0.75, the group rebelliously runs free — clearly disbanding the conformities of genre definitions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*KYlELD5El0XUwmDZo4sLdw.png" /><figcaption><strong>Tracks classified basis energy and valence scores sourced from the Spotify API</strong></figcaption></figure><p>“BTS love each other so much, they don’t know what to do about it” — the editor of CREA magazine once proclaimed, after covering the group. This natural camradiere that they share gives fans something to hold on and helps keep up with their frenetic work schedule. “Friends”, a duet by V and Jimin lovingly shipped by fans as <em>Vimin</em>, is a tribute to their friendship — from being schoolmates and Big Hit trainees to being a part of the biggest band in music, they have indeed come a long way. <em>“One day when this cheer dies down, stay by my side” , </em>they make promises and like hopeful unjaded teenage lovers unbeknownst to the world ahead croon, <em>“For eternity, keep staying here” . </em>And with<em> “I remember our uniforms, our memories, each and every of our movies” </em>they pay a sweet homage to their boyhood days. The track is an antithesis to toxic masculinity and machismo and is a pleasant refreshing tale of an unabashed old school bromance<em>.</em></p><p>Scoring high on both energy and valence, the most joyful track award goes to the bubblegum pop hit from “Persona”, “Boy with Luv ft. Halsey”, the current record holder for the most viewed YouTube video in 24 hours. While Jungkook’s “My time” and Jin’s “Moon”, a tributes to the fans — <em>“you’re my earth, all I see is you”</em>, score in the chill and peaceful bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*apO9lf4CIpEX6BiIOkjszA.png" /><figcaption><strong>Data sourced from Spotify API</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*nNn-DRm-93H-ht6ckLkpKw.png" /><figcaption><strong>Data sourced from Spotify API</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*tpWNPyivywwZwiSkz3nk9A.png" /><figcaption><strong>Data sourced from Spotify API</strong></figcaption></figure><p>When Big Hit founder Bang PD first recruited the team’s leader and rapper, then known as Rap Monster, the intent was to create a hip-hop centric group. He switched to creating an idol group only after judging market sentiment and commercial viability, leading many of the hip-hop inclined trainees to exit the company. RM and Suga the group’s current rappers stayed resolute and loyal. Now with “MOTS : 7”, 7 years since their debut the transition into a commercially viable idol group seems complete. In order to visualize the transition of sonic elements in BTS albums, I created <a href="https://cran.r-project.org/web/packages/ggridges/vignettes/introduction.html">ridgeplots</a> using the geom_ridgeline() function in the ‘ggridges’ package in R. I then used the “<em>Speechiness</em>”, “<em>Acousticness</em>” and “<em>Liveness</em>” scores for this album and juxtaposed it with their debut album — “2 Cool 4 Skool”. The web developer API defines <em>speechiness</em> as the presence of spoken word in a track, <em>liveness</em> as the probability that the song was recorded with a live audience and <em>acousticness</em> as the likelihood of the song to be an acoustic one. The evolution is clear. Although the MOTS:7 has a whopping 20 tracks as compared to just 9 in their debut album, the overall liveness acousticness &amp; speechiness score is significantly lower in this album. Ringing falsettos,turbulent strings, gunshot effects, and plinking synth purge through the album, a testament to <a href="https://en.wikipedia.org/wiki/Map_of_the_Soul:_7">a whopping 74 individuals who are listed as either writers or producers</a>, a head dizzyingly large number of cooks to have in the kitchen.</p><p>Most artists evolve. Even the Beatles had to transition to go from “Love me Do” to “Hey Jude”. Art is a reflection of life and as life changes so does the art that artists create. But some songs of the album lack the genuinity &amp; authenticity that is usually expected in a BTS album, especially because they brand themselves mainly on these attributes. It seem like the company’s latest attempt for <a href="https://pitchfork.com/reviews/albums/bts-map-of-the-soul-7/">brand activation </a>with some numbers especially crafted for their sold out stadium tours and western audiences. From building BTS themed hotels, creating cinematic documentaries to producing K-dramas based on the lives of BTS members, Big Hit seems to cash in on everything that can carry the BTS tag and some songs in this album seem to be included to do exactly that — amplified with the curse of overproduction. It’s a centuries old dilemma, Louisa May Alcott <em>sold</em> her heroine to marriage in “Little women” , as necessitated for book to gain commercial viability in the 1860’s, I do hope that the evolution to the modern times that we live in will allow BTS to just let their heroine be.</p><p>I actively started listening to K-Pop in 2011, 2NE1, Big Bang and Shinee ruled over the industry and it was impossible to not fall into their trap. Fast forward 9 years later, Bom of 2NE1 was accused of drug trafficking, Big Bang’s Seungri is embroiled in a prostitution scandal and Shinee’s main vocalist <a href="https://en.wikipedia.org/wiki/Kim_Jong-hyun_(singer)">Jonghyun</a> tragically succumbed to suicide last year. Even recently Chen, a member of the Exo-M has <a href="https://studybreaks.com/culture/music/exo-chen-tying-knot/">reportedly received death threats</a> after he revealed that his previously undisclosed girlfriend and now fiancée, is pregnant, a deed many K-pop fans term absolute betrayal. The pressures of K-pop industry is intense and BTS are currently at the front line. They’re often treated like male china dolls, with their company deciding their hair color and sending security teams to accompany them to the washroom granting them no privacy even in the most basic sense. In a overly sanitized and conceited K-pop industry, V &amp; Suga have been refreshingly candid about struggling with fame and constant privacy invasion. In the last few albums they make as a septet before they leave to serve their <a href="https://www.bbc.com/news/newsbeat-50515696">compulsory military service</a>, I hope BTS’s message goes deeper and does not get filtered out in their massive entourage of producers and songwriters.</p><p><em>What Suga wants, Suga gets</em>. The once struggling delivery boy in Seoul has been openly ambitious of BTS’s next move. Sell out the Olympic stadium in Korea he proclaimed when BTS had just debuted, the billboard top hot 100 when no K-pop group had ever come close, performing at the Grammys he said next, to gasps of absurdity in the room. They’ve done it all, in spectacular fashion. If rules of reverence ever existed, BTS doesn’t know them. What’s next? A Grammy award for the rebels from Seoul, Suga recently said. The Grammy’s are 9 months from now, we will have to wait and watch if this time too Suga gets what he wants.</p><p>….</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a73ec4e78ed1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/decoding-btss-map-of-the-soul-7-a73ec4e78ed1">Decoding BTS’s ‘Map Of The Soul: 7’</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Iterate Your R Code Efficiently!]]></title>
            <link>https://medium.com/data-science/iterate-your-r-code-efficiently-3c621998eaea?source=rss-c789683b86be------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c621998eaea</guid>
            <category><![CDATA[loop]]></category>
            <category><![CDATA[purrr]]></category>
            <category><![CDATA[rstats]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Manasi Mahadik]]></dc:creator>
            <pubDate>Sun, 05 Jan 2020 22:30:41 GMT</pubDate>
            <atom:updated>2021-08-23T15:49:13.246Z</atom:updated>
            <content:encoded><![CDATA[<h4>A step-by-step guide to perform clean and efficient iterations in R.</h4><p>Inuits do not actually have a hundred names for snow. Turns out that’s part myth and part misunderstanding. Expanding a similar analogy to web speak, there are about a hundred ways to iterate code! To add to this, the<em> </em>syntax can be confusing and some of us also run the risk of just lazily resorting to <em>copy-pasting </em>the code 4 times. But it is important to recognise that this is a sub-optimal route and frankly impractical. As a general rule of thumb, if we need to run a block of code more than two times, it is a good idea to iterate! Here are two reasons why this will make your code richer-</p><ol><li>It draws attention to the part of code that is different, thus making it easier to spot the intent of the operation.</li><li>Due to its concise nature, you’re likely to encounter fewer bugs.</li></ol><p>It might take some time to wrap your head around the idea of iterating, but trust me, it’s worth the investment.</p><p>Now that you’re convinced to iterate — let’s jump right in!</p><p>Let’s pick the inbuilt R dataset- <em>air quality. </em>A snippet of the same is presented below-</p><pre>   Ozone Solar.R  Wind Temp Month Day<br>    41     190    7.4   67     5   1<br>    36     118    8.0   72     5   2<br>    12     149   12.6   74     5   3<br>    18     313   11.5   62     5   4<br>    23     299    8.6   65     5   7<br>    19      99   13.8   59     5   8</pre><p><strong>Problem 1</strong>: You want to find the standard deviation for each variable in the dataset-</p><p>You<em> could </em>copy-paste the same code for each column-</p><pre>sd(airquality$Ozone)<br><em> 33.27597</em></pre><pre>sd(airquality$Solar.R)<br><em>91.1523</em></pre><pre>sd(airquality$Wind)<br><em>3.557713</em></pre><pre>sd(airquality$Temp)<br><em>9.529969</em></pre><pre>sd(airquality$Month)<br><em>1.473434</em></pre><pre>sd(airquality$Day)<br><em>8.707194</em></pre><p>This is however impractical for large data sets and breaks the rule of thumb of not running the same operation more than twice. We have a solid case to iterate!</p><p>We can write a for()loop-</p><pre>stddev = vector(&quot;double&quot;, ncol(airquality))</pre><pre>for(i in seq_along(airquality))             <br>{<br> stddev[[i]] = sd(airquality[[i]])          <br> <br>}<br>stddev<br><em>33.275969 91.152302  3.557713  9.529969  1.473434  8.707194</em></pre><p>The loop does away with any repetition and is indeed more efficient than the first approach.</p><p>It is also imperative to pause and note that while seq_along()and length() are mostly used interchangeably to build a sequence in the for loop, there is one key difference. In case of a zero-length vector, seq_along() does the right thing, but length() takes the value of 0 and 1. Although you probably won’t create a zero-length vector deliberately, it’s easy to create them accidentally. If you use 1:length() instead of seq_along(), you’re likely to get a confusing error message</p><p>Or you could just <em>skip</em> the loop and do the trick with <em>just</em> a line of code using sapply() from base R’s apply()family -</p><pre>sapply(airquality, sd)</pre><pre> Ozone      Solar.R      Wind      Temp     Month     Day <br><em>33.275969 91.152302  3.557713  9.529969  1.473434  8.707194</em></pre><p>This is a great application of R’s functional programming capabilities and indeed does the job very neatly.</p><p>Let’s now take another step on the ladder of complexity and look at another problem.</p><p><strong>Problem 2</strong>: You want to find the standard deviation <em>and </em>median of each column in your dataset.</p><p>Since we have established that the first approach of <em>copy-pasting</em> is impractical, we weigh in on our iteration options.</p><p>We start by writing a for()loop-</p><pre>stddev =vector(&quot;double&quot;, ncol(airquality))<br> median =vector(&quot;double&quot;, ncol(airquality))</pre><pre>for(i in seq_along(airquality))<br> {<br>   stddev[[i]] = sd(airquality[[i]])<br>   median[[i]] = median(airquality[[i]])<br>  }</pre><pre> stddev<br> 33.275969 91.152302  3.557713  9.529969  1.473434  8.707194<br> median<br> 31.0 207.0   9.7  79.0   7.0  16.0</pre><p>Next, we take the functional programming route. Here, unlike the earlier example where we could directly use R’s inbuilt sd() function to calculate the standard deviation and pass it through sapply() , we need to create a custom function, as we need to calculate both the standard deviation and the median.</p><pre>f &lt;- function(x){<br>    list(sd(x),median(x))<br> }</pre><pre>sapply(airquality, f)</pre><pre>Ozone    Solar.R Wind     Temp     Month    Day     <br>33.27597 91.1523 3.557713 9.529969 1.473434 8.707194<br>31       207     9.7      79       7        16</pre><p>This is a very solid idea! The ability to pass a user built function to another function is thrilling and clearly showcases R’s functional programming capabilities to solve a wide variety of tasks. In fact, seasoned R users rarely ever use loops and resort to functional programming techniques to solve all iterative tasks. As used above, apply family of functions in base R (apply(), lapply(), tapply(), etc) are a great way to go about this, but even in the functional programming universe there is one package which has emerged as a favorite — <em>Purrr</em>. The <em>purrr</em> family of functions has more consistent syntax and has in built functionalities to carry out a wide variety of common iterative tasks.</p><p>The <em>Map()</em> functions form the cornerstone of the purrr’s iterative capabilities. Here are some of the forms it takes-</p><ul><li>map() makes a list.</li><li>map_lgl() makes a logical vector.</li><li>map_int() makes an integer vector.</li><li>map_dbl() makes a double vector.</li><li>map_chr() makes a character vector.</li></ul><p>Let’s use this idea to solve our earlier problem of calculating the median and standard deviation of each column-</p><pre>map_df(airquality, ~list(med = median(.x), sd = sd(.x)))</pre><p>Next, in order to another leap on the complexity ladder let’s pick the <em>gapminder</em> dataset from the <em>gapminder</em> library<em>. </em>A snippet of the same is presented below.(P.S- If you haven’t heard about the gapminder foundation, do check its website out <a href="https://www.gapminder.org/">here</a> . The foundation does some groundbreaking work on putting basic global facts into context)</p><pre>  country   continent year lifeExp  pop  gdpPercap<br>  Afghanistan Asia     1952   28.8  8425333  779.<br>  Afghanistan Asia     1957   30.3  9240934  821.<br>  Afghanistan Asia     1962   32.0  10267083 853.<br>  Afghanistan Asia     1967   34.0  11537966 836.<br>  Afghanistan Asia     1972   36.1  13079460 740.<br>  Afghanistan Asia     1977   38.4  14880372 786.</pre><p><strong>Problem 3: </strong>I want to know which country has the highest GDP Per Capita in each continent and in each year.</p><p>Using the for() loop approach-</p><pre>list = c(“continent”, “year”)<br>DF= data.frame()</pre><pre>for( i in list)<br>{<br> df = gapminder %&gt;% group_by_at(i) %&gt;% <br> top_n(1, gdpPercap) %&gt;% <br> mutate(Remark = paste0(“Country Max GDP Per capita in the “,i)) %&gt;% <br> data.frame()<br> DF = rbind(df,DF)<br>}<br>DF</pre><p>Using the Apply()approach-</p><pre>do.call(rbind, lapply(list, function(x)<br>{<br>  gapminder %&gt;% group_by_at(x) %&gt;% <br>    top_n(1, gdpPercap)%&gt;%<br>    mutate(Remark = paste0(&quot;Country with the max GDP Per capita in the &quot;,x)) %&gt;% <br>    data.frame<br>}))</pre><p>Using the Purrr::Map() approach-</p><pre>gapminder$year = as.character(gapminder$year)<br>map_dfr(list, ~gapminder %&gt;% group_by(!!sym(.x)) %&gt;% <br> top_n(1, gdpPercap)%&gt;%<br> mutate(Remark = paste0(“Country with the max GDP Per capita in the “,.x)) %&gt;% data.frame()</pre><p>All of the above three approaches lead to the same output (For the sake of brevity, I am not including the output here. You can have a look at it on my Github <a href="https://github.com/manasi1096/Iterations-in-R">here</a>). Again, while you can take your pick on which iterative route you want to take, the functional programming way is a clear winner on cogency.</p><p><em>Purrr</em> also has some inbuilt functions to deal with everyday iterative tasks! Below I have listed down a few popular ones.</p><p><strong><em>Task</em></strong>: Run a piecewise regression for each segment of the data. (Here, continent):</p><p><strong><em>Purrr solution</em></strong>:</p><pre>gapminder %&gt;% <br> split(.$Continent) %&gt;% <br> map(~lm(gdpPercap ~ lifeExp, data = .))</pre><p><strong>Task</strong>: Keep variables basis an arbitrary condition. (Here, if the variable is a factor):</p><p><strong><em>Purrr solution</em></strong>:</p><pre>gapminder %&gt;% <br>  keep(is.factor) %&gt;% <br>  str()</pre><p><strong>Task:</strong> Check if any variable meets the arbitrary condition(Here, if any variable is a character):</p><p><strong><em>Purrr solution:</em></strong></p><pre>gapminder%&gt;% <br>  some(is_character)</pre><p><strong>Task:</strong> Check if every variable meets the arbitrary condition(Here, if every variable is an integer):</p><p><strong><em>Purrr solution:</em></strong></p><pre>gapminder %&gt;% <br>  every(is.integer))</pre><p>Once you get accustomed to the syntax of <em>purrr</em>, you will need less time to actually write iterative code in R. However, one must never ever feel bad about writing loops in R. In fact, they are one of the fundamental blocks of programming and are profusely used throughout other languages. Some people even call loops slow. They’re wrong! (Well at least they’re rather out of date, as for loops haven’t been slow for many years). The chief benefit of using functions like map() and apply() is not speed, but clarity: they make your code easier to write and read.</p><blockquote><em>The important thing is that you solve the problem that you’re working on, not write the most concise and elegant code (although that’s definitely something you want to strive towards!)- Hadley Wickham</em></blockquote><p>Thanks for reading! You can view the code on my Github <a href="https://github.com/manasi1096/Iterations-in-R">here</a> or reach out to me <a href="https://www.linkedin.com/in/manasi-mahadik-a66b26146/">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c621998eaea" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/iterate-your-r-code-efficiently-3c621998eaea">Iterate Your R Code Efficiently!</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Decade In Review With R Shiny!]]></title>
            <link>https://medium.com/data-science/the-decade-in-review-with-r-shiny-ea57f8fa5e0e?source=rss-c789683b86be------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea57f8fa5e0e</guid>
            <category><![CDATA[r]]></category>
            <category><![CDATA[visualization]]></category>
            <category><![CDATA[r-shiny]]></category>
            <category><![CDATA[economic-development]]></category>
            <category><![CDATA[decade]]></category>
            <dc:creator><![CDATA[Manasi Mahadik]]></dc:creator>
            <pubDate>Tue, 19 Nov 2019 04:40:24 GMT</pubDate>
            <atom:updated>2019-11-19T04:40:24.707Z</atom:updated>
            <content:encoded><![CDATA[<h4>Visualising the evolution of the world development indicators during the past decade with R Shiny</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FtMVSFQBLrPaiW5KNGRlWw.jpeg" /></figure><p>It’s been a long year. Rather it’s been a looong decade. The ISIS has been officially wiped out, the battle against Polio was won, South Sudan ceremoniously became a country, Pluto went from being the beloved tiny planet to just a dwarf revolving the sun, Leicester City won the Premier League, Kanye released his iconic Yeezy’s, we can now listen to music on the go without long wires tangling up our hair, Apple’s became the world’s first trillion dollar company, Ted Mosby FINALLY told his children how he met their mother and I learnt R Shiny !</p><p>After much needed inspiration from Joe Cheng’s <a href="https://rdrr.io/github/jcheng5/googleCharts/">bindings of google charts</a> for Shiny, I have decided to put my last decades learning to good use!</p><p>Here is an interactive R Shiny app that plots the evolution of the world bank’s major development indicators for all countries in the last decade. The application allows you to choose the indicators to be plotted on the X &amp; Y axis dynamically along with the desired year.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/312/1*P8-MTTX6AIOWqwo64g8D5g.png" /></figure><p>Post the desired selection a bubble chart is plotted which plots the relationship between the two variables with the bubbles coloured by the country’s g<em>eographical region </em>&amp; sized by p<em>opulation.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VrnqMt8MiJZY1iIr-sN76w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wzduxwZKpZZKY2biko2T7w.png" /></figure><p>As shown above, a tooltip pops up when the cursor is hovered over each bubble indicating its characteristic value.</p><p>You can also watch the evolution of the two variables unfold over the past decade by clicking on the ‘play’ button placed diagonally under the year slider.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*t8ub2XuYADZ_UEVLckh4Lg.gif" /></figure><p>There is sufficient reason for cheer! People everywhere are living longer, getting richer, going to school &amp; many of us are even emitting lesser and lesser CO2 in the air.</p><p>Here’s to another decade of progress &amp; Shiny apps elucidating it!</p><p>You can find the dataset &amp; code on my github <a href="https://github.com/manasi1096/Visualizing-WDI-in-R-Shiny">here</a>.</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea57f8fa5e0e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/the-decade-in-review-with-r-shiny-ea57f8fa5e0e">The Decade In Review With R Shiny!</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring Highcharts in R]]></title>
            <link>https://medium.com/data-science/exploring-highcharts-in-r-f754143efda7?source=rss-c789683b86be------2</link>
            <guid isPermaLink="false">https://medium.com/p/f754143efda7</guid>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[r]]></category>
            <category><![CDATA[highcharts]]></category>
            <dc:creator><![CDATA[Manasi Mahadik]]></dc:creator>
            <pubDate>Sat, 05 Oct 2019 14:26:46 GMT</pubDate>
            <atom:updated>2020-09-17T16:07:59.927Z</atom:updated>
            <content:encoded><![CDATA[<h4>Visualizing trends &amp; patterns using data from ‘How I met your mother’</h4><p>This article originally started out as exploratory quest to understand data visually in R. What subsequently followed was scrambles of experimenting, testing and making leaps into the dark. During this period I also re-watched my favorite show — How I Met Your Mother, this time looking at some recurring patterns &amp; the body of data sets it has left behind. The need to form associations between the two parallels led me to document &amp; share this learning and that itself remains the inspiration of this article.</p><p>The general R viz space currently is pretty exciting as it is, g<a href="https://ggplot2.tidyverse.org/">gplot2 </a>dominating the game with Hadley Wickham’s trademark school of making complicated operations remarkably lithe. Its efficiency in being able to quickly visualize trends, and customize just about anything you’d want, makes it a solid &amp; a dependable tool to rely upon. <a href="https://plot.ly/r/">Plotly</a> on the other hand let’s you build remarkably beautiful D3 plots particularly for websites, dashboards. It allows flexibility to hover your keyboard or mouse and see data labels and lets you customize zoom to see specific details making it an exemplary go-to for R shiny apps &amp; markdown documents.</p><p>Entering the data viz space in 2009,was ‘Highcharts’ a D3JS module who’s current clientele boasts of Facebook, Microsoft &amp; Stack Overflow.</p><p>The <a href="https://www.highcharts.com/blog/about/">story</a> of Highcharts is perhaps one for the ages. Its maker, Torstein Hønsi , based in a small Norweign town surrounded by fjords, mountains and streams, was in the quest for a modest charting tool for updating his homepage with snow depth measurements from Vikjafjellet, the local mountain where his family keeps a cabin. Irked by the constant plug-ins he encountered, he took the leap of kick-started Highcharts. Since 2009, it remains the company Highsoft’s best selling product &amp; it is known around the world as a premier charting tool.</p><p>Joshua Kunst’s <a href="http://jkunst.com/highcharter/">Highcharter</a> package in R is a wrapper function to the original Highcharts Java Script library. This article explores some of its visual functionality using data concerning a show know for its proclivity with charts and viz- <em>How I Met Your Mother.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*6ZVmtYeCRXhjpE3WGWb8bg.png" /><figcaption>HIMYM features makes use of many aesthetic charts</figcaption></figure><p>There are two main functions in the package namely — hcharts() and highcharts() similar to Ggplot2’s qplot() and ggplot(). The former is single key shortcut while the latter makes use of html widgets and animations. Since this article draws some pretty elementary charts, the hcharts() function suffices for most of them . I have used the more elaborate highcharts() function in the final chart to combine the polar &amp; line chart.</p><p>Let’s jump in!-</p><p><strong>The grouped column chart</strong></p><p>The good old column chart is perhaps the most perineal charting option to display categorical data, for good reason. It effectively compares and contrasts data in an easy to read fashion.</p><p>Below I have plotted the number of drinks the HIMYM gang drinks through the series.</p><p>The syntax is fairly easy to navigate, using the hcharts() shortcut the first command itself suffices the task of creating the raw column chart, while the subsequent lines of command add layers of aesthetics &amp; information. Here- the title, subtitle, credits &amp; a custom theme.</p><p>Another aspect to note here is the extensive employment of <em>magrittr’s </em>(its co-developer Stefan Bache in the vignette insists it be pronounced with a sophisticated french accent) %&gt;%, the &#39;pipe’, making the syntax amicable for tidyverse users.</p><pre>Number_of_drinks %&gt;% <br>    <br>  hchart(type = &#39;column&#39;, hcaes(x = `HIMYM Character`, y = `Number of Drinks`, group = Type)) %&gt;%<br>    <br>  hc_title(text = &quot;How much did the gang really drink?&quot;,<br>           style = list(fontWeight = &quot;bold&quot;, fontSize = &quot;30px&quot;),<br>           align = &quot;center&quot;) %&gt;% <br>  <br>  hc_subtitle(text = <br>                    &quot;&#39;All I want was to have a regular beer at my            regular bar with my regular friends in my regular city.&#39;-Ted Mosby&quot;, <br>              style = list(fontWeight = &quot;bold&quot;),<br>              align = &quot;center&quot;) %&gt;% <br>  <br>  hc_credits(enabled = TRUE, <br>             text = &quot;Data Source: HIMYM;<a href="https://imgur.com/user/haaaaaaaveyoumetted">https://imgur.com/user/haaaaaaaveyoumetted</a>&quot;,<br>             style = list(fontSize = &quot;10px&quot;)) %&gt;% <br>  <br>  hc_add_theme(hc_theme_ffx())</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*SUlZMQyA-Ehqwvoa0WQCNw.jpeg" /><figcaption>Number of drinks by types of drinks &amp; show characters.</figcaption></figure><p><strong>The pie chart &amp; colored area chart</strong></p><p>Luckily the author of the highcharter package was presumably a fan of the show himself and included some data sets based the show in the package itself. For these two charts I have used those very data sets — Marshall’s favorite bars and pies. In the show, Marshall presents his preferences of his favorite bars &amp; pies in the form of pie &amp; bar chart to the gang. Here, his preferences are visualized in the form of a pie-chart &amp; a colored area chart. The syntax used is fairly similar to the first chart created. I have added custom desireble colors to these charts basis their <a href="https://htmlcolorcodes.com/">hex codes</a>. Although custom themes can be coded into the charts , the package itself has a vast repository of beguiling themes. Through out this article I have used the &#39;ffx&#39; theme, inspired from the Mozilla Firefox browser.</p><pre>#pie chart</pre><pre>favorite_bars %&gt;% </pre><pre> hchart(type = ‘pie’, hcaes(bars, percent)) %&gt;% </pre><pre> hc_title(text = “Marshall’s Favorite bars”,<br> align = “center”,<br> style = list(fontWeight = “bold”, fontSize = “30px”)) %&gt;% <br> hc_tooltip(enabled = T) %&gt;% </pre><pre> hc_subtitle(text = “In Percentage of Awesomness!”,<br> align = “center”,<br> style = list(fontWeight = “bold”)) %&gt;% </pre><pre> hc_add_theme(hc_theme_ffx()) %&gt;% </pre><pre> hc_credits(enabled = T,text = “Data source:HIMYM”)</pre><pre>#colored area graph<br><br>  favorite_pies %&gt;% </pre><pre>  mutate( segmentColor = c(&quot;#000004&quot;, &quot;#3B0F70&quot;, &quot;#8C2981&quot;,  &quot;#DE4968&quot;, &quot;#FE9F6D&quot;))%&gt;% </pre><pre>  hchart(type = &#39;coloredarea&#39;, hcaes(x = pies, y = percent))%&gt;% <br>  hc_title(text = &quot;Marshall&#39;s favorite pies&quot;,<br>           style = list(fontWeight = &quot;bold&quot;, fontSize = &quot;30px&quot;),<br>           align = &quot;center&quot;) %&gt;% </pre><pre>  hc_subtitle(text = &quot;In Percentage Of Tastiness!&quot;,<br>              style = list(fontWeight = &quot;bold&quot;),<br>              align = &quot;center&quot;) %&gt;% </pre><pre>  hc_add_theme(hc_theme_ffx())</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2zGDgFvZxBD3cSJ_Iui5Gg.png" /><figcaption>Marshall’s favorite bars &amp; pies- in a pie chart &amp; colored area graph respectively</figcaption></figure><p><strong>The bubble chart</strong></p><p>The penultimate chart is a bubble chart to visualize the top rated &amp; voted episodes of the series. The bubble chart unlike the scatter plot , allows the plotting of 3 D data- the size of the bubble adding to the dimensionality of the data. Here- the X axis represents the name of the episode and the Y axis represents the rating of the episode while the bubble represents the number of votes on IMDB. This helps us infer that although ‘The three day rule’ is rated among the top 10 episodes, it has minuscule votes and hence must be interpreted with caution. Call outs and annotations like this can also be added to the chart to point certain facts - the hc_annotation() function allowing the same.</p><pre>HighestRated %&gt;% </pre><pre> hchart(type = “bubble”, hcaes(x = ‘Episode’, y = Rating, size = Votes, color = <br> Votes), maxSize = “20%”) %&gt;% </pre><pre> hc_title(text = “Top Rated Episodes of HIMYM”,<br> style =list(fontWeight = “bold”, fontSize = “30px”),<br> align = “center”) %&gt;% </pre><pre> hc_subtitle(text = “What was your favorite episode?”, <br> align = “center”,<br> style =list(fontWeight = “bold”)) %&gt;% </pre><pre> hc_credits(enabled = T, text = “Size by Number of Votes,<br> Colored by Rating.<br> | Data Source- IMDB”) %&gt;% </pre><pre> hc_add_theme(hc_theme_ffx())</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*CtP8c4u8GesNRN1jfIbstQ.jpeg" /><figcaption>Top Rated episodes of the series, by Ratings &amp; Votes on IMDB</figcaption></figure><p><strong>The polar line chart</strong></p><p>Finally, a polar line chart is brought into play to gauge reactions to the much debated HIMYM finale.</p><p>This data set had a interesting spin to it. The HIMYM finale was subject to some serious jeering after it was aired (read <a href="https://mashable.com/2014/04/01/how-i-met-your-mother-finale-reaction/">here</a>, <a href="https://www.comedycentral.co.uk/news/how-i-met-your-mother-finale-reaction">here</a>, <a href="https://www.usatoday.com/story/life/entertainthis/2016/03/31/how-i-met-your-mother-series-finale-two-years-later-still-mad/82465776/">here </a>&amp; <a href="https://www.businessinsider.in/entertainment/tv/fans-are-not-happy-with-the-how-i-met-your-mother-series-finale/articleshow/33057530.cms">here</a>). In fact even researching for this article fired up some of the fury I first felt after I watched the finale, more than 5 years on. But the data, as it its sometimes known to do, tells us a startlingly altering story .</p><p>Majority of the folks studied by social analytics platform <a href="http://canvs.tv/">Canvs</a> felt buoyant about the finale. The Canvs algorithm used sentiment analysis of peoples twitter reactions to figure out how people feel of forms of entertainment.</p><p>The chart below visualizes this data set in the form of a polar line chart, coloring the most commonly shared ‘opinions’ in pink that is- reactions above the mean threshold of reactions while the rest is highlighted in yellow.</p><pre>highchart() %&gt;% </pre><pre> hc_chart(polar = TRUE) %&gt;% </pre><pre> hc_title(text = “HIMYM Finale Reactions”,<br> style = list(fontWeight = “bold”, fontSize = “30px”),<br> align = “center”) %&gt;% </pre><pre> hc_subtitle(text = “‘And that kids is the story of how I met your mother’”,<br> style = list(fontWeight = “bold”),<br> align = “center”) %&gt;% </pre><pre> hc_xAxis(categories = fans_react$Fans,<br> style = list(fontWeight = “bold”)) %&gt;% </pre><pre>hc_credits(enabled = TRUE,<br> text = “Data Source:Based on a study done by Canvs as reported by The Atlantic”) %&gt;% </pre><pre>hc_add_theme(hc_theme_ffx()) %&gt;%</pre><pre> hc_legend(enabled = FALSE) %&gt;% </pre><pre> hc_series(<br> list(<br> name = “Bars”,<br> data = fans_react$Contribution,<br> colorByPoint = TRUE,<br> type = “column”,<br> colors = ifelse(fans_react$Contribution &lt; mean(fans_react$Contribution),”#ffeda0&quot;,”#c51b8a”)<br> ),<br> list(<br> name = “line”,<br> data = fans_react$Contribution,<br> pointPlacement = “on”,<br> type = “line”))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*SR0xlsFoN-TVBipvg0nghg.jpeg" /><figcaption>HIMYM Finale reactions on twitter bucketed and visualized</figcaption></figure><p>Key takeaways-</p><ol><li>The Highcharter package in R with it’s navigable nature, graspable syntax and advanced D3JS visuals is a great addition to the R viz space, currently dominated by the Grammar of graphics Ggolot2 package.</li><li>It can be used to create the a wide range of charts like bubble charts, column charts, tree maps, time series graphs etc using similar syntax and arguments.</li><li>Not only does it support R objects but also employs the loved %&gt;% &#39;pipe’ operator making it seem incredibly familiar to tidyverse users. This homely syntax combined with stunning visuals makes it go-to tool in R shiny apps and R markdown documents.</li></ol><p>The code along with all data sets used can be found on github <a href="https://github.com/manasi1096/Highcharts-HIMYM">here</a> .</p><p>Thanks for reading! You can reach out to me <a href="https://twitter.com/ManasiM_10?s=09">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f754143efda7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/exploring-highcharts-in-r-f754143efda7">Exploring Highcharts in R</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>