<?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[sangarg - Medium]]></title>
        <description><![CDATA[Data Science - Medium]]></description>
        <link>https://medium.com/sangarg?source=rss----292529695ee1---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>sangarg - Medium</title>
            <link>https://medium.com/sangarg?source=rss----292529695ee1---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 04:04:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/sangarg" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Visualization mpg data set In R, GGplot2::mpg]]></title>
            <link>https://medium.com/sangarg/visualization-mpg-data-set-in-r-ggplot2-mpg-708664558e9b?source=rss----292529695ee1---4</link>
            <guid isPermaLink="false">https://medium.com/p/708664558e9b</guid>
            <category><![CDATA[r-programming]]></category>
            <category><![CDATA[blogging]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[ggplot2]]></category>
            <category><![CDATA[data-visualization]]></category>
            <dc:creator><![CDATA[Sandeep Garg]]></dc:creator>
            <pubDate>Sun, 22 Mar 2020 04:10:09 GMT</pubDate>
            <atom:updated>2020-03-22T04:10:16.149Z</atom:updated>
            <content:encoded><![CDATA[<h3>Visualization Of mpg data set In R, GGplot2::mpg</h3><p><em>This data set contains a subset of the fuel economy data.It contains only models which had a new release every year between 1999 and 2008 .</em></p><p>you can download or check data set for mpg in below mentioned link:</p><p><a href="https://vincentarelbundock.github.io/Rdatasets/datasets.html">https://vincentarelbundock.github.io/Rdatasets/datasets.html</a></p><p>NOTE: search&gt; mpg after opening the link then you can download the data set.</p><h3><strong>Lets Start R program to visualize the data set:</strong></h3><p>library(tidyverse) &gt; ggplot2::mpg</p><p><strong>#Format of a data set: Data frame with 234 rows and 11 variables</strong><br>1 manufacturer<br>2 model &gt; model name<br>3 displ &gt; engine displacement, in litres or size of engine<br>4 year &gt; year of manufacture<br>5 cyl &gt; number of cylinders<br>6 trans &gt; type of transmission<br>7 drv &gt; f = front-wheel drive, r = rear wheel drive, 4 = 4 wheel drive<br>8 cty &gt; city miles per gallon<br>9 hwy &gt; highway miles per gallon or efficiency<br>10 fl &gt; fuel type<br>11 class &gt; “type” of car</p><p><strong><em>#Lets see whats makes difference of size of cyl on efficency of car</em></strong></p><blockquote>ggplot2:: ggplot(data = mpg)+aes(x=displ,y= hwy) +geom_point()</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*xYi38xWNVxMQVQcJkQkZwA.jpeg" /><figcaption><strong>This indicates that efficiency of car is inversely proportional to size of engine.</strong></figcaption></figure><p><strong>#Lets visualize it in more efficient way:</strong></p><blockquote>ggplot(data = mpg)+aes(x=displ,y=hwy,color=class)+geom_point()+<br> facet_wrap(.~year)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6m-GFfPQTk3KJn0WQZ6S-w.jpeg" /><figcaption><strong>Cylinders VS efficiency getting increased over year from 1999 to 2008</strong></figcaption></figure><p>NOTE: In above graph we can also note that we have some outliers where some cars have cylinders more than or equal to 6 but still have good efficiency.</p><h3><strong>#Lets see whats is impact of drive type of efficiency.</strong></h3><blockquote>ggplot(data=mpg)+geom_jitter(aes(x=displ,y=hwy,color=drv),show.legend = FALSE) + geom_smooth(mapping = aes(x=displ,y=hwy))+<br> facet_wrap(.~drv)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ipDcWEYNDXyKIuXSdxc1uw.jpeg" /></figure><p><em>Efficiency is better for front type wheel drive than rear and four wheel drive.</em></p><blockquote>table(mpg$manufacturer) <em>#Gives the list of manufacturer</em></blockquote><blockquote>ggplot(data=mpg) + geom_bar(mapping=aes(x=manufacturer,fill=manufacturer))</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PoCmTjdTmwzvFuDk47nYaQ.jpeg" /><figcaption><strong>Manufacturers counts</strong></figcaption></figure><h3><strong>#Car classes Vs Manufacturer</strong></h3><p>ggplot(data=mpg) +geom_bar(mapping=aes(x=class,fill=manufacturer),color=”black”)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*46uvJGYQE013LOSOw1RGWg.jpeg" /><figcaption><strong>Class VS manufacturer</strong></figcaption></figure><p>GGPLOT2 library is “Grammar of graphics” which is very dynamic and efficient package for visualization. As here we see that with using ggplot how we extract useful information from tidy or untidy data set.</p><p>Later we are going to learn more about R and package and how to use them.</p><p>Stay tuned!!! and Thanks for giving time to read this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=708664558e9b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/sangarg/visualization-mpg-data-set-in-r-ggplot2-mpg-708664558e9b">Visualization mpg data set In R, GGplot2::mpg</a> was originally published in <a href="https://medium.com/sangarg">sangarg</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>