<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Rsquared Academy Blog - Explore Discover Learn</title>
    <link>https://blog.rsquaredacademy.com/</link>
    <description>Recent content on Rsquared Academy Blog - Explore Discover Learn</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <copyright>&amp;copy; 2014-2022. All rights reserved.</copyright>
    <lastBuildDate>Tue, 30 May 2023 00:00:00 +0000</lastBuildDate>
    
        <atom:link href="https://blog.rsquaredacademy.com/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>Introducing standby</title>
      <link>https://blog.rsquaredacademy.com/introducing-standby-alerts-notifications-tooltips-loading-screens-shiny/</link>
      <pubDate>Tue, 30 May 2023 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/introducing-standby-alerts-notifications-tooltips-loading-screens-shiny/</guid>
      <description>&lt;script src=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/header-attrs/header-attrs.js&#34;&gt;&lt;/script&gt;


&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/github-standby.png&#34; width=&#34;70%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;We are excited to announce the &lt;a href=&#34;https://standby.rsquaredacademy.com&#34;&gt;standby&lt;/a&gt; package. It allows you to easily create alerts, notifications, tooltips and loading screens in Shiny. The package was developed as part of our internal tools for developing shiny apps and we are glad to share it with the rest of the community.&lt;/p&gt;
&lt;div id=&#34;installation&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Installation&lt;/h2&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Install release version from CRAN
install.packages(&amp;quot;standby&amp;quot;)

# Install development version from GitHub
# install.packages(&amp;quot;devtools&amp;quot;)
devtools::install_github(&amp;quot;rsquaredacademy/standby&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;loading-screens&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Loading Screens&lt;/h2&gt;
&lt;p&gt;To use spinners/loaders from &lt;strong&gt;standby&lt;/strong&gt; in your Shiny application, include the
following in the &lt;strong&gt;UI&lt;/strong&gt; part of the app:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Include the dependencies using the appropriate &lt;code&gt;use*&lt;/code&gt; functions
(&lt;code&gt;useSpinkit()&lt;/code&gt; in the below example).&lt;/li&gt;
&lt;li&gt;Wrap the target output using corresponding rendering function
(&lt;code&gt;spinkit()&lt;/code&gt; in the below example).&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;example&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Example&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(shiny)
library(standby)

ui &amp;lt;- fluidPage(

  standby::useSpinkit(), # include dependencies
  fluidRow(
    standby::spinkit(plotOutput(&amp;quot;plot1&amp;quot;)), # wrap output inside loader
    actionButton(&amp;quot;render&amp;quot;, &amp;quot;Render&amp;quot;)
  )

)

server &amp;lt;- function(input, output, session) {

    output$plot1 &amp;lt;- renderPlot({
      input$render
      Sys.sleep(3)
      hist(mtcars$mpg)
    })

}

shinyApp(ui, server)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;details&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Details&lt;/h3&gt;
&lt;p&gt;The below table displays the dependency and rendering functions along with references:&lt;/p&gt;
&lt;table&gt;
&lt;colgroup&gt;
&lt;col width=&#34;6%&#34; /&gt;
&lt;col width=&#34;15%&#34; /&gt;
&lt;col width=&#34;13%&#34; /&gt;
&lt;col width=&#34;64%&#34; /&gt;
&lt;/colgroup&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;center&#34;&gt;Index&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;Dependency&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;Render&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;Reference&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;code&gt;useThreeDots()&lt;/code&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;code&gt;threeDots()&lt;/code&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;a href=&#34;https://github.com/nzbin/three-dots&#34;&gt;Three Dots&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;code&gt;useSpinkit()&lt;/code&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;code&gt;spinkit()&lt;/code&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;a href=&#34;https://github.com/tobiasahlin/SpinKit&#34;&gt;SpinKit&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;3&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;code&gt;useVizLoad()&lt;/code&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;code&gt;vizLoad()&lt;/code&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;a href=&#34;https://github.com/RIDICS/Loading-Visualization&#34;&gt;Loading Visualization&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;4&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;code&gt;useSpinners()&lt;/code&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;code&gt;spinners()&lt;/code&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;a href=&#34;https://github.com/lukehaas/css-loaders&#34;&gt;Spinners&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;5&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;code&gt;useLoaders()&lt;/code&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;code&gt;loaders()&lt;/code&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;a href=&#34;https://github.com/raphaelfabeni/css-loader&#34;&gt;Loaders&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;alerts-and-notifications&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Alerts and Notifications&lt;/h2&gt;
&lt;p&gt;To use alerts or notifications from &lt;strong&gt;buzz&lt;/strong&gt; in your Shiny application, follow the below steps:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Include the dependencies in the &lt;strong&gt;UI&lt;/strong&gt; part of the app using the appropriate
&lt;code&gt;use*&lt;/code&gt; functions (&lt;code&gt;useToast()&lt;/code&gt; in the below example).&lt;/li&gt;
&lt;li&gt;Include the corresponding rendering function in the &lt;strong&gt;Server&lt;/strong&gt; part of the
app (&lt;code&gt;toast()&lt;/code&gt; in the below example).&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;example-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Example&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(shiny)
library(standby)
ui &amp;lt;- fluidPage(
  useBootBox(), # include dependencies
  actionButton(inputId = &amp;quot;notify&amp;quot;,
               label   = &amp;quot;Show Notification&amp;quot;)
)
server &amp;lt;- function(input, output, session) {
  observeEvent(input$pnotify, {
    bootBox(class = &amp;quot;rubberBand&amp;quot;) # display the alert
  })
}
shinyApp(ui, server)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;details-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Details&lt;/h3&gt;
&lt;p&gt;The below table displays the dependency and rendering functions along with references:&lt;/p&gt;
&lt;table&gt;
&lt;colgroup&gt;
&lt;col width=&#34;5%&#34; /&gt;
&lt;col width=&#34;13%&#34; /&gt;
&lt;col width=&#34;17%&#34; /&gt;
&lt;col width=&#34;63%&#34; /&gt;
&lt;/colgroup&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;center&#34;&gt;Index&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;Dependency&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;Render&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;Reference&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;code&gt;useAlertify()&lt;/code&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;code&gt;alertify_alert()&lt;/code&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;a href=&#34;https://github.com/MohammadYounes/AlertifyJS&#34;&gt;Alertify&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;code&gt;useAlertify()&lt;/code&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;code&gt;alertify_notify()&lt;/code&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;a href=&#34;https://github.com/MohammadYounes/AlertifyJS&#34;&gt;Alertify&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;3&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;code&gt;useBootBox()&lt;/code&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;code&gt;bootBox()&lt;/code&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;a href=&#34;https://github.com/bootboxjs/bootbox&#34;&gt;BootBox&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;4&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;code&gt;useMicroTip()&lt;/code&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;code&gt;microTip()&lt;/code&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;a href=&#34;https://github.com/ghosh/microtip&#34;&gt;MicroTip&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;5&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;code&gt;useNS()&lt;/code&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;code&gt;notice()&lt;/code&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;a href=&#34;https://tympanus.net/Development/NotificationStyles/&#34;&gt;Notification Styles&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;6&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;code&gt;useNotify()&lt;/code&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;code&gt;notify()&lt;/code&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;a href=&#34;https://github.com/sciactive/pnotify&#34;&gt;PNotify&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;7&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;code&gt;useTingle()&lt;/code&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;code&gt;tingle()&lt;/code&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;a href=&#34;https://github.com/robinparisi/tingle&#34;&gt;Tingle&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;8&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;code&gt;useToast()&lt;/code&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;code&gt;toast()&lt;/code&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;a href=&#34;https://github.com/marcelodolza/iziToast&#34;&gt;iziToast&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;learning-more&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Learning More&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://standby.rsquaredacademy.com&#34;&gt;Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/rsquaredacademy/standby&#34;&gt;GitHub&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;inspiration-acknowledgement&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Inspiration &amp;amp; Acknowledgement&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;https://standby.rsquaredacademy.com&#34;&gt;standby&lt;/a&gt; takes inspiration from the following wonderful packages:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/daattali/shinycssloaders&#34;&gt;shinycssloaders&lt;/a&gt; by &lt;a href=&#34;https://github.com/daattali&#34;&gt;Dean Attali&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/JohnCoene/waiter&#34;&gt;waiter&lt;/a&gt; by &lt;a href=&#34;https://john-coene.com/&#34;&gt;John Coene&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We found the following books extremely helpful while working on the package and in general for developing Shiny apps. We would like to express out heartful gratitude to the respective authors for making them available for free to the community.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://unleash-shiny.rinterface.com/index.html&#34;&gt;Outstanding User Interfaces with Shiny&lt;/a&gt; by&lt;a href=&#34;https://github.com/DivadNojnarg&#34;&gt;David Granjon&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://book.javascript-for-r.com/&#34;&gt;JavaScript for R&lt;/a&gt; by &lt;a href=&#34;https://john-coene.com/&#34;&gt;John Coene&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;getting-help&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Getting Help&lt;/h2&gt;
&lt;p&gt;If you encounter a bug, please file a minimal reproducible example using
&lt;a href=&#34;https://reprex.tidyverse.org/index.html&#34;&gt;reprex&lt;/a&gt; on github. For questions and clarifications,
use &lt;a href=&#34;https://stackoverflow.com/&#34;&gt;StackOverflow&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;feedback&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Feedback&lt;/h2&gt;
&lt;p&gt;All feedback is welcome. Issues (bugs and feature requests) can be posted to
&lt;a href=&#34;https://github.com/rsquaredacademy/standby/issues&#34;&gt;github tracker&lt;/a&gt;.
For help with code or other related questions, feel free to reach out to us
at &lt;a href=&#34;mailto:pkgs@rsquaredacademy.com&#34; class=&#34;email&#34;&gt;pkgs@rsquaredacademy.com&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Introducing yahoofinancer</title>
      <link>https://blog.rsquaredacademy.com/introducing-yahoofinancer-fetch-data-from-yahoo-finance-api/</link>
      <pubDate>Fri, 04 Nov 2022 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/introducing-yahoofinancer-fetch-data-from-yahoo-finance-api/</guid>
      <description>&lt;script src=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/header-attrs/header-attrs.js&#34;&gt;&lt;/script&gt;


&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/github-yfr.png&#34; width=&#34;70%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;We are excited to announce the &lt;a href=&#34;https://yahoofinancer.rsquaredacademy.com&#34;&gt;yahoofinancer&lt;/a&gt; package. The yahoofinancer R package allows the retrieval of nearly all data visible via the Yahoo Finance front-end and aims to reduce the pre-processing steps needed in analyzing such data.&lt;/p&gt;
&lt;p&gt;yahoofinancer is inspired by and a port of the Python package &lt;a href=&#34;https://yahooquery.dpguthrie.com/&#34;&gt;yahooquery&lt;/a&gt;. yahoofinancer is &lt;strong&gt;not&lt;/strong&gt; affiliated, endorsed, or vetted by Yahoo, Inc. It’s an open-source tool that uses Yahoo’s publicly available APIs, and is intended for research and educational purposes.&lt;/p&gt;
&lt;p&gt;With yahoofinancer, you can fetch the following data related to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;company
&lt;ul&gt;
&lt;li&gt;quote&lt;/li&gt;
&lt;li&gt;summary&lt;/li&gt;
&lt;li&gt;statistics&lt;/li&gt;
&lt;li&gt;historical data&lt;/li&gt;
&lt;li&gt;profile&lt;/li&gt;
&lt;li&gt;financials&lt;/li&gt;
&lt;li&gt;analysis&lt;/li&gt;
&lt;li&gt;options&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;index
&lt;ul&gt;
&lt;li&gt;summary&lt;/li&gt;
&lt;li&gt;historical data&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;currency&lt;/li&gt;
&lt;li&gt;market summary&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;installation&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Installation&lt;/h2&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Install release version from CRAN
install.packages(&amp;quot;yahoofinancer&amp;quot;)

# Install development version from GitHub
# install.packages(&amp;quot;devtools&amp;quot;)
devtools::install_github(&amp;quot;rsquaredacademy/yahoofinancer&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;usage&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Usage&lt;/h2&gt;
&lt;/div&gt;
&lt;div id=&#34;ticker&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Ticker&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;Ticker&lt;/code&gt; class is the main workhorse of the package and through it we can
obtain most of the data related to a company.&lt;/p&gt;
&lt;div id=&#34;instantiate-ticker-class&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Instantiate Ticker Class&lt;/h4&gt;
&lt;p&gt;We can instantiate the &lt;code&gt;Ticker&lt;/code&gt; class by passing the company’s ticker symbol.
For instance, to get data for &lt;a href=&#34;https://finance.yahoo.com/quote/AAPL/&#34;&gt;Apple Inc.&lt;/a&gt;,
pass &lt;code&gt;aapl&lt;/code&gt; as the first argument to the &lt;code&gt;Ticker&lt;/code&gt; class.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;aapl &amp;lt;- Ticker$new(&amp;#39;aapl&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can use the &lt;code&gt;validate()&lt;/code&gt; function to validate a symbol.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;regular-market-price&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Regular Market Price&lt;/h4&gt;
&lt;p&gt;Let us begin by getting the real time price of &lt;a href=&#34;https://finance.yahoo.com/quote/AAPL/&#34;&gt;Apple Inc.&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;aapl$quote$regularMarketPrice&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 138.88&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Summary&lt;/h4&gt;
&lt;p&gt;To retrieve data from the &lt;a href=&#34;https://finance.yahoo.com/quote/AAPL/&#34;&gt;Summary&lt;/a&gt; tab, use the &lt;code&gt;summary_detail&lt;/code&gt; property on the &lt;code&gt;Ticker&lt;/code&gt; class.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;aapl$summary_detail&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## $maxAge
## [1] 1
## 
## $priceHint
## [1] 2
## 
## $previousClose
## [1] 145.03
## 
## $open
## [1] 142.06
## 
## $dayLow
## [1] 138.76
## 
## $dayHigh
## [1] 142.795
## 
## $regularMarketPreviousClose
## [1] 145.03
## 
## $regularMarketOpen
## [1] 142.06
## 
## $regularMarketDayLow
## [1] 138.76
## 
## $regularMarketDayHigh
## [1] 142.795
## 
## $dividendRate
## [1] 0.92
## 
## $dividendYield
## [1] 0.0063
## 
## $exDividendDate
## [1] 1667520000
## 
## $payoutRatio
## [1] 0.1473
## 
## $fiveYearAvgDividendYield
## [1] 1
## 
## $beta
## [1] 1.246644
## 
## $trailingPE
## [1] 23.74017
## 
## $forwardPE
## [1] 20.36364
## 
## $volume
## [1] 97918516
## 
## $regularMarketVolume
## [1] 97918516
## 
## $averageVolume
## [1] 85440921
## 
## $averageVolume10days
## [1] 96881500
## 
## $averageDailyVolume10Day
## [1] 96881500
## 
## $bid
## [1] 0
## 
## $ask
## [1] 138.63
## 
## $bidSize
## [1] 800
## 
## $askSize
## [1] 1300
## 
## $marketCap
## [1] 2.307158e+12
## 
## $fiftyTwoWeekLow
## [1] 129.04
## 
## $fiftyTwoWeekHigh
## [1] 182.94
## 
## $priceToSalesTrailing12Months
## [1] 5.85086
## 
## $fiftyDayAverage
## [1] 150.0812
## 
## $twoHundredDayAverage
## [1] 156.2758
## 
## $trailingAnnualDividendRate
## [1] 0.9
## 
## $trailingAnnualDividendYield
## [1] 0.006205612
## 
## $currency
## [1] &amp;quot;USD&amp;quot;
## 
## $tradeable
## [1] FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;statistics&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Statistics&lt;/h4&gt;
&lt;p&gt;If you are looking to retrieve data from the &lt;a href=&#34;https://finance.yahoo.com/quote/AAPL/key-statistics?p=AAPL&#34;&gt;Statistics&lt;/a&gt; tab, use the following properties:&lt;/p&gt;
&lt;div id=&#34;key-statistics&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Key Statistics&lt;/h5&gt;
&lt;p&gt;The &lt;code&gt;key_stats&lt;/code&gt; property returns KPIs for a given symbol. It is available raw&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;head(map(aapl$key_stats, &amp;#39;raw&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## $maxAge
## NULL
## 
## $priceHint
## [1] 2
## 
## $enterpriseValue
## [1] 2.293495e+12
## 
## $forwardPE
## [1] 20.36364
## 
## $profitMargins
## [1] 0.2531
## 
## $floatShares
## [1] 15891255395&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or formatted&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;head(map(aapl$key_stats, &amp;#39;fmt&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## $maxAge
## NULL
## 
## $priceHint
## [1] &amp;quot;2&amp;quot;
## 
## $enterpriseValue
## [1] &amp;quot;2.29T&amp;quot;
## 
## $forwardPE
## [1] &amp;quot;20.36&amp;quot;
## 
## $profitMargins
## [1] &amp;quot;25.31%&amp;quot;
## 
## $floatShares
## [1] &amp;quot;15.89B&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;valuation_measures&lt;/code&gt; property retrieves valuation measures for most recent
four quarters.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;aapl$valuation_measures&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##         date enterprise_value enterprise_value_ebitda_ratio
## 1 2021-09-30     2.384485e+12                  2.384485e+12
## 2 2021-12-31     2.963725e+12                  2.963725e+12
## 3 2022-03-31     2.888888e+12                  2.888888e+12
## 4 2022-06-30     2.269030e+12                  2.269030e+12
## 5 2022-09-30     2.274841e+12                  2.274841e+12
##   enterprise_value_revenue_ratio forward_pe_ratio   market_cap     pb_ratio
## 1                   2.384485e+12     2.384485e+12 2.384485e+12 2.384485e+12
## 2                   2.963725e+12     2.963725e+12 2.963725e+12 2.963725e+12
## 3                   2.888888e+12     2.888888e+12 2.888888e+12 2.888888e+12
## 4                   2.269030e+12     2.269030e+12 2.269030e+12 2.269030e+12
## 5                   2.274841e+12     2.274841e+12 2.274841e+12 2.274841e+12
##       pe_ratio    peg_ratio     ps_ratio
## 1 2.384485e+12 2.384485e+12 2.384485e+12
## 2 2.963725e+12 2.963725e+12 2.963725e+12
## 3 2.888888e+12 2.888888e+12 2.888888e+12
## 4 2.269030e+12 2.269030e+12 2.269030e+12
## 5 2.274841e+12 2.274841e+12 2.274841e+12&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;historical-data&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Historical Data&lt;/h4&gt;
&lt;p&gt;Use the &lt;code&gt;get_history()&lt;/code&gt; method to retrieve historical pricing data for a given
symbol. By default, it returns YTD data.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;head(aapl$get_history())&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                  date    volume   high    low   open  close adj_close
## 1 2022-01-03 14:30:00 104487900 182.88 177.71 177.83 182.01  181.2599
## 2 2022-01-04 14:30:00  99310400 182.94 179.12 182.63 179.70  178.9594
## 3 2022-01-05 14:30:00  94537600 180.17 174.64 179.61 174.92  174.1992
## 4 2022-01-06 14:30:00  96904000 175.30 171.64 172.70 172.00  171.2912
## 5 2022-01-07 14:30:00  86709100 174.14 171.03 172.89 172.17  171.4605
## 6 2022-01-10 14:30:00 106765600 172.50 168.17 169.08 172.19  171.4804&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To get data from a specific date upto the current date, use the &lt;code&gt;start&lt;/code&gt;
argument to supply the initial date. The time between data points can be
specified using the &lt;code&gt;interval&lt;/code&gt; argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;aapl$get_history(start = &amp;#39;2022-10-20&amp;#39;, interval = &amp;#39;1d&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                   date    volume   high    low   open  close adj_close
## 1  2022-10-20 13:30:00  64522000 145.89 142.65 143.02 143.39    143.39
## 2  2022-10-21 13:30:00  86464700 147.85 142.65 142.87 147.27    147.27
## 3  2022-10-24 13:30:00  75981900 150.23 146.00 147.19 149.45    149.45
## 4  2022-10-25 13:30:00  74732300 152.49 149.36 150.09 152.34    152.34
## 5  2022-10-26 13:30:00  88194300 151.99 148.04 150.96 149.35    149.35
## 6  2022-10-27 13:30:00 109180200 149.05 144.13 148.07 144.80    144.80
## 7  2022-10-28 13:30:00 164762400 157.50 147.82 148.20 155.74    155.74
## 8  2022-10-31 13:30:00  97943200 154.24 151.92 153.16 153.34    153.34
## 9  2022-11-01 13:30:00  80379300 155.45 149.13 155.08 150.65    150.65
## 10 2022-11-02 13:30:00  93604600 152.17 145.00 148.95 145.03    145.03
## 11 2022-11-03 13:30:00  97572100 142.80 138.75 142.06 138.88    138.88&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To retrieve data between two specific dates, use both the &lt;code&gt;start&lt;/code&gt; and &lt;code&gt;end&lt;/code&gt;
argument. The dates should be either &lt;code&gt;String&lt;/code&gt; or &lt;code&gt;Date&lt;/code&gt; object in &lt;code&gt;yyyy-mm-dd&lt;/code&gt;
format.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;aapl$get_history(start = &amp;#39;2022-10-01&amp;#39;, end = &amp;#39;2022-10-14&amp;#39;, interval = &amp;#39;1d&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                  date    volume   high    low   open  close adj_close
## 1 2022-10-03 13:30:00 114311700 143.07 137.69 138.21 142.45    142.45
## 2 2022-10-04 13:30:00  87830100 146.22 144.26 145.03 146.10    146.10
## 3 2022-10-05 13:30:00  79471000 147.38 143.01 144.07 146.40    146.40
## 4 2022-10-06 13:30:00  68402200 147.54 145.22 145.81 145.43    145.43
## 5 2022-10-07 13:30:00  85859100 143.10 139.45 142.54 140.09    140.09
## 6 2022-10-10 13:30:00  74899000 141.89 138.57 140.42 140.42    140.42
## 7 2022-10-11 13:30:00  77033700 141.35 138.22 139.90 138.98    138.98
## 8 2022-10-12 13:30:00  70433700 140.36 138.16 139.13 138.34    138.34
## 9 2022-10-13 13:30:00 113224000 143.59 134.37 134.99 142.99    142.99&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;period&lt;/code&gt; arguments allows the user to retrieve data for specific length of time.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;aapl$get_history(period = &amp;#39;1mo&amp;#39;, interval = &amp;#39;1d&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                   date    volume   high    low   open  close adj_close
## 1  2022-10-04 13:30:00  87830100 146.22 144.26 145.03 146.10    146.10
## 2  2022-10-05 13:30:00  79471000 147.38 143.01 144.07 146.40    146.40
## 3  2022-10-06 13:30:00  68402200 147.54 145.22 145.81 145.43    145.43
## 4  2022-10-07 13:30:00  85859100 143.10 139.45 142.54 140.09    140.09
## 5  2022-10-10 13:30:00  74899000 141.89 138.57 140.42 140.42    140.42
## 6  2022-10-11 13:30:00  77033700 141.35 138.22 139.90 138.98    138.98
## 7  2022-10-12 13:30:00  70433700 140.36 138.16 139.13 138.34    138.34
## 8  2022-10-13 13:30:00 113224000 143.59 134.37 134.99 142.99    142.99
## 9  2022-10-14 13:30:00  88512300 144.52 138.19 144.31 138.38    138.38
## 10 2022-10-17 13:30:00  85250900 142.90 140.27 141.07 142.41    142.41
## 11 2022-10-18 13:30:00  99136600 146.70 140.61 145.49 143.75    143.75
## 12 2022-10-19 13:30:00  61758300 144.95 141.50 141.69 143.86    143.86
## 13 2022-10-20 13:30:00  64522000 145.89 142.65 143.02 143.39    143.39
## 14 2022-10-21 13:30:00  86464700 147.85 142.65 142.87 147.27    147.27
## 15 2022-10-24 13:30:00  75981900 150.23 146.00 147.19 149.45    149.45
## 16 2022-10-25 13:30:00  74732300 152.49 149.36 150.09 152.34    152.34
## 17 2022-10-26 13:30:00  88194300 151.99 148.04 150.96 149.35    149.35
## 18 2022-10-27 13:30:00 109180200 149.05 144.13 148.07 144.80    144.80
## 19 2022-10-28 13:30:00 164762400 157.50 147.82 148.20 155.74    155.74
## 20 2022-10-31 13:30:00  97943200 154.24 151.92 153.16 153.34    153.34
## 21 2022-11-01 13:30:00  80379300 155.45 149.13 155.08 150.65    150.65
## 22 2022-11-02 13:30:00  93604600 152.17 145.00 148.95 145.03    145.03
## 23 2022-11-03 13:30:00  97572100 142.80 138.75 142.06 138.88    138.88&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Please view the &lt;a href=&#34;https://yahoofinancer.rsquaredacademy.com/reference/ticker-class#arguments-5&#34;&gt;documentation&lt;/a&gt; to see the valid values for &lt;code&gt;interval&lt;/code&gt; and &lt;code&gt;period&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;profile&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Profile&lt;/h4&gt;
&lt;p&gt;Retrieve data from the &lt;a href=&#34;https://finance.yahoo.com/quote/AAPL/profile?p=AAPL&#34;&gt;Profile&lt;/a&gt;
tab. The &lt;code&gt;summary_profile&lt;/code&gt; property returns the business summary for a given
symbol.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;aapl$summary_profile&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## $address1
## [1] &amp;quot;One Apple Park Way&amp;quot;
## 
## $city
## [1] &amp;quot;Cupertino&amp;quot;
## 
## $state
## [1] &amp;quot;CA&amp;quot;
## 
## $zip
## [1] &amp;quot;95014&amp;quot;
## 
## $country
## [1] &amp;quot;United States&amp;quot;
## 
## $phone
## [1] &amp;quot;408 996 1010&amp;quot;
## 
## $website
## [1] &amp;quot;https://www.apple.com&amp;quot;
## 
## $industry
## [1] &amp;quot;Consumer Electronics&amp;quot;
## 
## $sector
## [1] &amp;quot;Technology&amp;quot;
## 
## $longBusinessSummary
## [1] &amp;quot;Apple Inc. designs, manufactures, and markets smartphones, personal computers, tablets, wearables, and accessories worldwide. It also sells various related services. In addition, the company offers iPhone, a line of smartphones; Mac, a line of personal computers; iPad, a line of multi-purpose tablets; and wearables, home, and accessories comprising AirPods, Apple TV, Apple Watch, Beats products, and HomePod. Further, it provides AppleCare support and cloud services store services; and operates various platforms, including the App Store that allow customers to discover and download applications and digital content, such as books, music, video, games, and podcasts. Additionally, the company offers various services, such as Apple Arcade, a game subscription service; Apple Fitness+, a personalized fitness service; Apple Music, which offers users a curated listening experience with on-demand radio stations; Apple News+, a subscription news and magazine service; Apple TV+, which offers exclusive original content; Apple Card, a co-branded credit card; and Apple Pay, a cashless payment service, as well as licenses its intellectual property. The company serves consumers, and small and mid-sized businesses; and the education, enterprise, and government markets. It distributes third-party applications for its products through the App Store. The company also sells its products through its retail and online stores, and direct sales force; and third-party cellular network carriers, wholesalers, retailers, and resellers. Apple Inc. was incorporated in 1977 and is headquartered in Cupertino, California.&amp;quot;
## 
## $fullTimeEmployees
## [1] 164000
## 
## $companyOfficers
## list()
## 
## $maxAge
## [1] 86400&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;company_officers&lt;/code&gt; property retrieves top executives for given symbol and
their total pay package.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;aapl$company_officers&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                       name age                                         title
## 1      Mr. Timothy D. Cook  60                                CEO &amp;amp; Director
## 2        Mr. Luca  Maestri  57                                  CFO &amp;amp; Sr. VP
## 3  Mr. Jeffrey E. Williams  57                       Chief Operating Officer
## 4   Ms. Katherine L. Adams  57                   Sr. VP, Gen. Counsel &amp;amp; Sec.
## 5     Ms. Deirdre  O&amp;#39;Brien  54                     Sr. VP of People &amp;amp; Retail
## 6         Mr. Chris  Kondo  NA              Sr. Director of Corp. Accounting
## 7        Mr. James  Wilson  NA                      Chief Technology Officer
## 8          Ms. Mary  Demby  NA                     Chief Information Officer
## 9        Ms. Nancy  Paxton  NA Sr. Director of Investor Relations &amp;amp; Treasury
## 10       Mr. Greg  Joswiak  NA                 Sr. VP of Worldwide Marketing
##    year_born fiscal_year total_pay exercised_value unexercised_value
## 1       1961        2021  16386559               0                 0
## 2       1964        2021   5018883               0                 0
## 3       1964        2021   5017437               0                 0
## 4       1964        2021   5014533               0                 0
## 5       1967        2021   5061191               0                 0
## 6         NA          NA        NA               0                 0
## 7         NA          NA        NA               0                 0
## 8         NA          NA        NA               0                 0
## 9         NA          NA        NA               0                 0
## 10        NA          NA        NA               0                 0&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;financials&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Financials&lt;/h4&gt;
&lt;p&gt;The &lt;code&gt;get_balance_sheet()&lt;/code&gt; method retrieves balance sheet data for most recent
four quarters or most recent four years.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;aapl$get_balance_sheet(&amp;#39;annual&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 4 x 24
##   end_date          cash short~1 net_r~2 inven~3 other~4 total~5 long_~6 prope~7
##   &amp;lt;date&amp;gt;           &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;
## 1 2022-09-24 23646000000 2.47e10 6.09e10  4.95e9 2.12e10 1.35e11 1.21e11 8.42e10
## 2 2021-09-25 34940000000 2.77e10 5.15e10  6.58e9 1.41e10 1.35e11 1.28e11 4.95e10
## 3 2020-09-26 38016000000 5.29e10 3.74e10  4.06e9 1.13e10 1.44e11 1.01e11 4.53e10
## 4 2019-09-28 48844000000 5.17e10 4.58e10  4.11e9 1.24e10 1.63e11 1.05e11 3.74e10
## # ... with 15 more variables: other_assets &amp;lt;dbl&amp;gt;, total_assets &amp;lt;dbl&amp;gt;,
## #   accounts_payable &amp;lt;dbl&amp;gt;, short_long_term_debt &amp;lt;dbl&amp;gt;,
## #   other_current_liab &amp;lt;dbl&amp;gt;, long_term_debt &amp;lt;dbl&amp;gt;, other_liab &amp;lt;dbl&amp;gt;,
## #   total_current_liabilities &amp;lt;dbl&amp;gt;, total_liab &amp;lt;dbl&amp;gt;, common_stock &amp;lt;dbl&amp;gt;,
## #   retained_earnings &amp;lt;dbl&amp;gt;, treasury_stock &amp;lt;dbl&amp;gt;,
## #   other_stockholder_equity &amp;lt;dbl&amp;gt;, total_stockholder_equity &amp;lt;dbl&amp;gt;,
## #   net_tangible_assets &amp;lt;dbl&amp;gt;, and abbreviated variable names ...&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;get_income_statement()&lt;/code&gt; method retrieves income statement data for most
recent four quarters or most recent four years.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;aapl$get_income_statement(&amp;#39;annual&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 4 x 16
##   end_date   total_rev~1 cost_~2 gross~3 resea~4 selli~5 total~6 opera~7 total~8
##   &amp;lt;date&amp;gt;           &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;   &amp;lt;int&amp;gt;
## 1 2022-09-24     3.94e11 2.24e11 1.71e11 2.63e10 2.51e10 2.75e11 1.19e11 -3.34e8
## 2 2021-09-25     3.66e11 2.13e11 1.53e11 2.19e10 2.20e10 2.57e11 1.09e11  2.58e8
## 3 2020-09-26     2.75e11 1.70e11 1.05e11 1.88e10 1.99e10 2.08e11 6.63e10  8.03e8
## 4 2019-09-28     2.60e11 1.62e11 9.84e10 1.62e10 1.82e10 1.96e11 6.39e10  1.81e9
## # ... with 7 more variables: ebit &amp;lt;dbl&amp;gt;, interest_expense &amp;lt;dbl&amp;gt;,
## #   income_before_tax &amp;lt;dbl&amp;gt;, income_tax_expense &amp;lt;dbl&amp;gt;,
## #   net_income_from_continuing_ops &amp;lt;dbl&amp;gt;, net_income &amp;lt;dbl&amp;gt;,
## #   net_income_applicable_to_common_shares &amp;lt;dbl&amp;gt;, and abbreviated variable
## #   names 1: total_revenue, 2: cost_of_revenue, 3: gross_profit,
## #   4: research_development, 5: selling_general_administrative,
## #   6: total_operating_expenses, 7: operating_income, ...&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;get_cash_flow()&lt;/code&gt; method retrieves cash flow data for most recent four
quarters or most recent four years.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;aapl$get_cash_flow(&amp;#39;annual&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 4 x 20
##   end_date   net_inc~1 depre~2 chang~3 change~4 change~5 chang~6 chang~7 total~8
##   &amp;lt;date&amp;gt;         &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;
## 1 2022-09-24   9.98e10 1.11e10 1.00e10 -1.82e 9  9.93e 9  1.48e9 -8.39e9 1.22e11
## 2 2021-09-25   9.47e10 1.13e10 2.98e 9 -1.01e10  1.40e10 -2.64e9 -6.15e9 1.04e11
## 3 2020-09-26   5.74e10 1.11e10 6.52e 9  6.92e 9 -1.98e 9 -1.27e8  8.81e8 8.07e10
## 4 2019-09-28   5.53e10 1.25e10 5.08e 9  2.45e 8 -2.55e 9 -2.89e8 -8.96e8 6.94e10
## # ... with 11 more variables: capital_expenditures &amp;lt;dbl&amp;gt;, investments &amp;lt;dbl&amp;gt;,
## #   other_cashflows_from_investing_activities &amp;lt;int&amp;gt;,
## #   total_cashflows_from_investing_activities &amp;lt;dbl&amp;gt;, dividends_paid &amp;lt;dbl&amp;gt;,
## #   net_borrowings &amp;lt;dbl&amp;gt;, other_cashflows_from_financing_activities &amp;lt;int&amp;gt;,
## #   total_cash_from_financing_activities &amp;lt;dbl&amp;gt;, change_in_cash &amp;lt;dbl&amp;gt;,
## #   repurchase_of_stock &amp;lt;dbl&amp;gt;, issuance_of_stock &amp;lt;int&amp;gt;, and abbreviated
## #   variable names 1: net_income, 2: depreciation, 3: change_to_netincome, ...&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;analysis&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Analysis&lt;/h4&gt;
&lt;div id=&#34;earnings-estimate&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Earnings Estimate&lt;/h5&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;aapl$earnings_trend$earnings_estimate&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##         date period analyst avg_estimate low_estimate high_estimate
## 1 2022-12-31     0q      27         2.08         1.93          2.20
## 2 2023-03-31    +1q      26         1.47         1.34          1.61
## 3 2023-09-30     0y      33         6.26         5.40          6.87
## 4 2024-09-30    +1y      28         6.82         6.01          7.36
## 5       &amp;lt;NA&amp;gt;    +5y      NA           NA           NA            NA
## 6       &amp;lt;NA&amp;gt;    -5y      NA           NA           NA            NA
##   year_ago_eps
## 1         2.10
## 2         1.52
## 3         6.11
## 4         6.26
## 5           NA
## 6           NA&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;revenue-estimate&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Revenue Estimate&lt;/h5&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;aapl$earnings_trend$revenue_estimate&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##         date period analyst avg_estimate low_estimate high_estimate
## 1 2022-12-31     0q      23  1.27082e+11  1.21204e+11   1.32365e+11
## 2 2023-03-31    +1q      23  9.73035e+10  8.96080e+10   1.02950e+11
## 3 2023-09-30     0y      32  4.07153e+11  3.86805e+11   4.19743e+11
## 4 2024-09-30    +1y      26  4.28651e+11  4.05730e+11   4.48983e+11
## 5       &amp;lt;NA&amp;gt;    +5y      NA           NA           NA            NA
## 6       &amp;lt;NA&amp;gt;    -5y      NA           NA           NA            NA
##   year_ago_revenue
## 1               NA
## 2               NA
## 3      3.94328e+11
## 4      4.07153e+11
## 5               NA
## 6               NA&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;earnings-history&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Earnings History&lt;/h5&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;aapl$earnings_history&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      quarter period eps_estimate eps_actual eps_difference surprise_percent
## 1 2021-12-31    -4q         1.89       2.10           0.21            0.111
## 2 2022-03-31    -3q         1.43       1.52           0.09            0.063
## 3 2022-06-30    -2q         1.16       1.20           0.04            0.034
## 4 2022-09-30    -1q         1.27       1.29           0.02            0.016&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;eps-trend&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;EPS Trend&lt;/h5&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;aapl$earnings_trend$eps_trend&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##         date period current seven_days_ago thirty_days_ago sixty_days_ago
## 1 2022-12-31     0q    2.08           2.13            2.13           2.12
## 2 2023-03-31    +1q    1.47           1.52            1.53           1.52
## 3 2023-09-30     0y    6.26           6.43            6.46           6.45
## 4 2024-09-30    +1y    6.82           6.90            6.88           6.88
## 5       &amp;lt;NA&amp;gt;    +5y      NA             NA              NA             NA
## 6       &amp;lt;NA&amp;gt;    -5y      NA             NA              NA             NA
##   ninety_days_ago
## 1            2.11
## 2            1.52
## 3            6.43
## 4            6.79
## 5              NA
## 6              NA&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;eps-revision&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;EPS Revision&lt;/h5&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;aapl$earnings_trend$eps_revision&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##         date period up_last_7_days up_last_30_days down_last_30_days
## 1 2022-12-31     0q              4               6                15
## 2 2023-03-31    +1q              4               5                13
## 3 2023-09-30     0y              3               5                24
## 4 2024-09-30    +1y              2               4                 9
## 5       &amp;lt;NA&amp;gt;    +5y             NA              NA                NA
## 6       &amp;lt;NA&amp;gt;    -5y             NA              NA                NA
##   down_last_90_days
## 1                NA
## 2                NA
## 3                NA
## 4                NA
## 5                NA
## 6                NA&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;growth-estimates&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Growth Estimates&lt;/h5&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;aapl$earnings_trend$growth&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##         date period      growth
## 1 2022-12-31     0q -0.01000000
## 2 2023-03-31    +1q -0.03300000
## 3 2023-09-30     0y  0.02500000
## 4 2024-09-30    +1y  0.08899999
## 5       &amp;lt;NA&amp;gt;    +5y  0.08890000
## 6       &amp;lt;NA&amp;gt;    -5y  0.22590000&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;options&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Options&lt;/h4&gt;
&lt;div id=&#34;option-chain&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Option Chain&lt;/h5&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;head(aapl$option_chain)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 6 x 16
##   expiration          option_type contra~1 strike curre~2 last_~3 change perce~4
##   &amp;lt;dttm&amp;gt;              &amp;lt;chr&amp;gt;       &amp;lt;chr&amp;gt;     &amp;lt;dbl&amp;gt; &amp;lt;chr&amp;gt;     &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;
## 1 2022-11-04 00:00:00 call        AAPL221~     70 USD        69.8      0       0
## 2 2022-11-04 00:00:00 call        AAPL221~     75 USD        64.6      0       0
## 3 2022-11-04 00:00:00 call        AAPL221~     80 USD        59.7      0       0
## 4 2022-11-04 00:00:00 call        AAPL221~     85 USD        59.6      0       0
## 5 2022-11-04 00:00:00 call        AAPL221~     90 USD        50.0      0       0
## 6 2022-11-04 00:00:00 call        AAPL221~     95 USD        44.9      0       0
## # ... with 8 more variables: open_interest &amp;lt;int&amp;gt;, bid &amp;lt;dbl&amp;gt;, ask &amp;lt;dbl&amp;gt;,
## #   contract_size &amp;lt;chr&amp;gt;, last_trade_date &amp;lt;dttm&amp;gt;, implied_volatility &amp;lt;dbl&amp;gt;,
## #   in_the_money &amp;lt;lgl&amp;gt;, volume &amp;lt;int&amp;gt;, and abbreviated variable names
## #   1: contract_symbol, 2: currency, 3: last_price, 4: percent_change&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;option-expiration-dates&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Option Expiration Dates&lt;/h5&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;aapl$option_expiration_dates&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;2022-11-04&amp;quot; &amp;quot;2022-11-11&amp;quot; &amp;quot;2022-11-18&amp;quot; &amp;quot;2022-11-25&amp;quot; &amp;quot;2022-12-02&amp;quot;
##  [6] &amp;quot;2022-12-09&amp;quot; &amp;quot;2022-12-16&amp;quot; &amp;quot;2023-01-20&amp;quot; &amp;quot;2023-02-17&amp;quot; &amp;quot;2023-03-17&amp;quot;
## [11] &amp;quot;2023-04-21&amp;quot; &amp;quot;2023-05-19&amp;quot; &amp;quot;2023-06-16&amp;quot; &amp;quot;2023-07-21&amp;quot; &amp;quot;2023-09-15&amp;quot;
## [16] &amp;quot;2024-01-19&amp;quot; &amp;quot;2024-03-15&amp;quot; &amp;quot;2024-06-21&amp;quot; &amp;quot;2025-01-17&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;option-strikes&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Option Strikes&lt;/h5&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;aapl$option_strikes&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  30.0  35.0  40.0  45.0  50.0  55.0  60.0  65.0  70.0  75.0  80.0  85.0
## [13]  90.0  95.0 100.0 105.0 110.0 115.0 120.0 125.0 126.0 127.0 128.0 129.0
## [25] 130.0 131.0 132.0 133.0 134.0 135.0 136.0 137.0 138.0 139.0 140.0 141.0
## [37] 142.0 143.0 144.0 145.0 146.0 147.0 148.0 149.0 150.0 152.5 155.0 157.5
## [49] 160.0 162.5 165.0 167.5 170.0 172.5 175.0 177.5 180.0 185.0 190.0 195.0
## [61] 200.0 205.0 210.0 215.0 220.0 225.0 230.0 235.0 240.0 245.0 250.0 255.0
## [73] 260.0 265.0 270.0 275.0 280.0 285.0 290.0 295.0 300.0 310.0 320.0&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;holding-pattern&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Holding Pattern&lt;/h4&gt;
&lt;p&gt;Data showing breakdown of owners of given symbol(s), insiders, institutions, etc.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;aapl$major_holders&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## $maxAge
## [1] 1
## 
## $insidersPercentHeld
## [1] 0.00072
## 
## $institutionsPercentHeld
## [1] 0.60186
## 
## $institutionsFloatPercentHeld
## [1] 0.60229
## 
## $institutionsCount
## [1] 5463&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Top 10 owners of a given symbol.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;aapl$institution_ownership&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##          date                  organization percent_held   position
## 1  2022-06-30    Vanguard Group, Inc. (The)           NA 1277319054
## 2  2022-06-30                Blackrock Inc.           NA 1028688317
## 3  2022-06-30       Berkshire Hathaway, Inc           NA  894802319
## 4  2022-06-30      State Street Corporation           NA  598178524
## 5  2022-06-30                      FMR, LLC           NA  344317974
## 6  2022-06-30 Geode Capital Management, LLC           NA  278256192
## 7  2022-06-30 Price (T.Rowe) Associates Inc           NA  237910783
## 8  2022-06-30                Morgan Stanley           NA  182450565
## 9  2022-06-30    Northern Trust Corporation           NA  179828922
## 10 2022-06-30   Bank of America Corporation           NA  149133915
##           value percent_change
## 1  177394076456         0.0058
## 2  142864238487         0.0010
## 3  124270150431         0.0044
## 4   83075036333        -0.0255
## 5   47818881910        -0.0207
## 6   38644221303         0.0227
## 7   33041050704         0.0207
## 8   25338735358         0.4585
## 9   24974641565        -0.0333
## 10  20711718843         0.0328&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;others&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Others&lt;/h4&gt;
&lt;p&gt;Data related to historical recommendations (buy, hold, sell) for a given symbol.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;aapl$recommendation_trend&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   period strong_buy buy hold sell strong_sell
## 1     0m         11  21    6    0           0
## 2    -1m         13  25    6    1           0
## 3    -2m         14  25    7    1           0
## 4    -3m         13  20    8    0           0&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Technical indicators for given symbol.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;aapl$technical_insights$secReports[[1]]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## $id
## [1] &amp;quot;0000320193-22-000108_320193&amp;quot;
## 
## $type
## [1] &amp;quot;Periodic Financial Reports&amp;quot;
## 
## $title
## [1] &amp;quot;10-K : Periodic Financial Reports&amp;quot;
## 
## $description
## [1] &amp;quot;Annual report pursuant to Section 13 and 15(d)&amp;quot;
## 
## $filingDate
## [1] 1.666915e+12
## 
## $snapshotUrl
## [1] &amp;quot;https://cdn.yahoofinance.com/prod/sec-reports-thumbnails/0000320193/000032019322000108/thumbnail.png&amp;quot;
## 
## $formType
## [1] &amp;quot;10-K&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Symbols displayed in the &lt;strong&gt;People Also Watch&lt;/strong&gt; sidebar.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;aapl$recommendations&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   symbol    score
## 1   AMZN 0.323217
## 2   TSLA 0.303238
## 3   META 0.288718
## 4   GOOG 0.286876
## 5   NFLX 0.218178&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;indices&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Indices&lt;/h2&gt;
&lt;p&gt;Use the &lt;code&gt;Index&lt;/code&gt; class for getting all data related to indices from Yahoo Finance API.&lt;/p&gt;
&lt;div id=&#34;instantiate-index-class&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Instantiate Index Class&lt;/h4&gt;
&lt;p&gt;We can instantiate the &lt;code&gt;Index&lt;/code&gt; class by passing the index symbol. For instance,
to get data for &lt;a href=&#34;https://finance.yahoo.com/quote/%5ENSEI?p=%5ENSEI&#34;&gt;Nifty 50&lt;/a&gt;,
pass &lt;code&gt;^NSEI&lt;/code&gt; as the first argument to the &lt;code&gt;Index&lt;/code&gt; class.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;nifty &amp;lt;- Index$new(&amp;#39;^NSEI&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;summary-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Summary&lt;/h4&gt;
&lt;p&gt;Use the &lt;code&gt;summary_detail&lt;/code&gt; property to retrieve data from the &lt;a href=&#34;https://finance.yahoo.com/quote/%5ENSEI?p=%5ENSEI&#34;&gt;Summary&lt;/a&gt; tab.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;nifty$summary_detail&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## $language
## [1] &amp;quot;en-US&amp;quot;
## 
## $region
## [1] &amp;quot;US&amp;quot;
## 
## $quoteType
## [1] &amp;quot;INDEX&amp;quot;
## 
## $typeDisp
## [1] &amp;quot;Index&amp;quot;
## 
## $quoteSourceName
## [1] &amp;quot;Free Realtime Quote&amp;quot;
## 
## $triggerable
## [1] TRUE
## 
## $customPriceAlertConfidence
## [1] &amp;quot;HIGH&amp;quot;
## 
## $currency
## [1] &amp;quot;INR&amp;quot;
## 
## $tradeable
## [1] FALSE
## 
## $cryptoTradeable
## [1] FALSE
## 
## $messageBoardId
## [1] &amp;quot;finmb_INDEXNSEI&amp;quot;
## 
## $exchangeTimezoneName
## [1] &amp;quot;Asia/Kolkata&amp;quot;
## 
## $exchangeTimezoneShortName
## [1] &amp;quot;IST&amp;quot;
## 
## $gmtOffSetMilliseconds
## [1] 19800000
## 
## $market
## [1] &amp;quot;in_market&amp;quot;
## 
## $esgPopulated
## [1] FALSE
## 
## $regularMarketChangePercent
## [1] 0.1238129
## 
## $regularMarketPrice
## [1] 18075.05
## 
## $marketState
## [1] &amp;quot;REGULAR&amp;quot;
## 
## $exchange
## [1] &amp;quot;NSI&amp;quot;
## 
## $shortName
## [1] &amp;quot;NIFTY 50&amp;quot;
## 
## $firstTradeDateMilliseconds
## [1] 1.190001e+12
## 
## $priceHint
## [1] 2
## 
## $regularMarketChange
## [1] 22.35156
## 
## $regularMarketTime
## [1] 1667552435
## 
## $regularMarketDayHigh
## [1] 18108
## 
## $regularMarketDayRange
## [1] &amp;quot;18017.15 - 18108.0&amp;quot;
## 
## $regularMarketDayLow
## [1] 18017.15
## 
## $regularMarketVolume
## [1] 0
## 
## $regularMarketPreviousClose
## [1] 18052.7
## 
## $bid
## [1] 0
## 
## $ask
## [1] 0
## 
## $bidSize
## [1] 0
## 
## $askSize
## [1] 0
## 
## $fullExchangeName
## [1] &amp;quot;NSE&amp;quot;
## 
## $regularMarketOpen
## [1] 18053.4
## 
## $averageDailyVolume3Month
## [1] 275566
## 
## $averageDailyVolume10Day
## [1] 245930
## 
## $fiftyTwoWeekLowChange
## [1] 2891.65
## 
## $fiftyTwoWeekLowChangePercent
## [1] 0.1904481
## 
## $fiftyTwoWeekRange
## [1] &amp;quot;15183.4 - 18350.95&amp;quot;
## 
## $fiftyTwoWeekHighChange
## [1] -275.8984
## 
## $fiftyTwoWeekHighChangePercent
## [1] -0.01503456
## 
## $fiftyTwoWeekLow
## [1] 15183.4
## 
## $fiftyTwoWeekHigh
## [1] 18350.95
## 
## $fiftyDayAverage
## [1] 17526.7
## 
## $fiftyDayAverageChange
## [1] 548.3535
## 
## $fiftyDayAverageChangePercent
## [1] 0.03128676
## 
## $twoHundredDayAverage
## [1] 16994.76
## 
## $twoHundredDayAverageChange
## [1] 1080.293
## 
## $twoHundredDayAverageChangePercent
## [1] 0.06356624
## 
## $sourceInterval
## [1] 15
## 
## $exchangeDataDelayedBy
## [1] 15
## 
## $symbol
## [1] &amp;quot;^NSEI&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;historical-data-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Historical Data&lt;/h4&gt;
&lt;p&gt;Use the &lt;code&gt;get_history()&lt;/code&gt; method to retrieve historical data for a given
index. By default, it returns YTD data.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;nifty$get_history(start = &amp;#39;2022-10-20&amp;#39;, interval = &amp;#39;1d&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                   date volume     high      low     open    close adj_close
## 1  2022-10-20 03:45:00 249600 17584.15 17421.00 17423.10 17563.95  17563.95
## 2  2022-10-21 03:45:00 277700 17670.15 17520.75 17622.85 17576.30  17576.30
## 3  2022-10-24 03:45:00  45000 17777.55 17707.40 17736.35 17730.75  17730.75
## 4  2022-10-25 03:45:00 251400 17811.50 17637.00 17808.30 17656.35  17656.35
## 5  2022-10-27 03:45:00 324600 17783.90 17654.50 17771.40 17736.95  17736.95
## 6  2022-10-28 03:45:00 250000 17838.90 17723.70 17756.40 17786.80  17786.80
## 7  2022-10-31 03:45:00 227200 18022.80 17899.90 17910.20 18012.20  18012.20
## 8  2022-11-01 03:45:00 349900 18175.80 18060.15 18130.70 18145.40  18145.40
## 9  2022-11-02 03:45:00 270900 18178.75 18048.65 18177.90 18082.85  18082.85
## 10 2022-11-03 03:45:00 213000 18106.30 17959.20 17968.35 18052.70  18052.70
## 11 2022-11-04 09:00:35      0 18108.00 18017.15 18053.40 18075.05  18075.05&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To get data from a specific date upto the current date, use the &lt;code&gt;start&lt;/code&gt;
argument to supply the initial date. The time between data points can be
specified using the &lt;code&gt;interval&lt;/code&gt; argument.&lt;/p&gt;
&lt;p&gt;To retrieve data between two specific dates, use both the &lt;code&gt;start&lt;/code&gt; and &lt;code&gt;end&lt;/code&gt;
argument. The dates should be either &lt;code&gt;String&lt;/code&gt; or &lt;code&gt;Date&lt;/code&gt; object in &lt;code&gt;yyyy-mm-dd&lt;/code&gt;
format.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;nifty$get_history(start = &amp;#39;2022-10-01&amp;#39;, end = &amp;#39;2022-10-14&amp;#39;, interval = &amp;#39;1d&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                  date volume     high      low     open    close adj_close
## 1 2022-10-03 03:45:00 278400 17114.65 16855.55 17102.10 16887.35  16887.35
## 2 2022-10-04 03:45:00 226000 17287.30 17117.30 17147.45 17274.30  17274.30
## 3 2022-10-06 03:45:00 265500 17428.80 17315.65 17379.25 17331.80  17331.80
## 4 2022-10-07 03:45:00 216300 17337.35 17216.95 17287.20 17314.65  17314.65
## 5 2022-10-10 03:45:00 234000 17280.15 17064.70 17094.35 17241.00  17241.00
## 6 2022-10-11 03:45:00 282600 17261.80 16950.30 17256.05 16983.55  16983.55
## 7 2022-10-12 03:45:00 256000 17142.35 16960.05 17025.55 17123.60  17123.60
## 8 2022-10-13 03:45:00 266400 17112.35 16956.95 17087.35 17014.35  17014.35&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;period&lt;/code&gt; arguments allows the user to retrieve data for specific length of time.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;nifty$get_history(period = &amp;#39;1mo&amp;#39;, interval = &amp;#39;1d&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                   date volume     high      low     open    close adj_close
## 1  2022-10-04 03:45:00 226000 17287.30 17117.30 17147.45 17274.30  17274.30
## 2  2022-10-06 03:45:00 265500 17428.80 17315.65 17379.25 17331.80  17331.80
## 3  2022-10-07 03:45:00 216300 17337.35 17216.95 17287.20 17314.65  17314.65
## 4  2022-10-10 03:45:00 234000 17280.15 17064.70 17094.35 17241.00  17241.00
## 5  2022-10-11 03:45:00 282600 17261.80 16950.30 17256.05 16983.55  16983.55
## 6  2022-10-12 03:45:00 256000 17142.35 16960.05 17025.55 17123.60  17123.60
## 7  2022-10-13 03:45:00 266400 17112.35 16956.95 17087.35 17014.35  17014.35
## 8  2022-10-14 03:45:00 227000 17348.55 17169.75 17322.30 17185.70  17185.70
## 9  2022-10-17 03:45:00 212200 17328.55 17098.55 17144.80 17311.80  17311.80
## 10 2022-10-18 03:45:00 239500 17527.80 17434.05 17438.75 17486.95  17486.95
## 11 2022-10-19 03:45:00 210500 17607.60 17472.85 17568.15 17512.25  17512.25
## 12 2022-10-20 03:45:00 249600 17584.15 17421.00 17423.10 17563.95  17563.95
## 13 2022-10-21 03:45:00 277700 17670.15 17520.75 17622.85 17576.30  17576.30
## 14 2022-10-24 03:45:00  45000 17777.55 17707.40 17736.35 17730.75  17730.75
## 15 2022-10-25 03:45:00 251400 17811.50 17637.00 17808.30 17656.35  17656.35
## 16 2022-10-27 03:45:00 324600 17783.90 17654.50 17771.40 17736.95  17736.95
## 17 2022-10-28 03:45:00 250000 17838.90 17723.70 17756.40 17786.80  17786.80
## 18 2022-10-31 03:45:00 227200 18022.80 17899.90 17910.20 18012.20  18012.20
## 19 2022-11-01 03:45:00 349900 18175.80 18060.15 18130.70 18145.40  18145.40
## 20 2022-11-02 03:45:00 270900 18178.75 18048.65 18177.90 18082.85  18082.85
## 21 2022-11-03 03:45:00 213000 18106.30 17959.20 17968.35 18052.70  18052.70
## 22 2022-11-04 09:00:36      0 18108.00 18017.15 18053.40 18074.30  18074.30&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Please view the &lt;a href=&#34;https://yahoofinancer.rsquaredacademy.com/reference/index-class#arguments-2&#34;&gt;documentation&lt;/a&gt; to see the valid values for &lt;code&gt;interval&lt;/code&gt; and &lt;code&gt;period&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;currency&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Currency&lt;/h2&gt;
&lt;div id=&#34;summary-2&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Summary&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;currency_summary()&lt;/code&gt; retrieve information available via the Summary tab in
Yahoo Finance.. View the &lt;a href=&#34;https://yahoofinancer.rsquaredacademy.com/reference/currency_summary.html&#34;&gt;documentation&lt;/a&gt; to learn more.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;currency_summary(from = &amp;quot;USD&amp;quot;, to = &amp;quot;INR&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## $language
## [1] &amp;quot;en-US&amp;quot;
## 
## $region
## [1] &amp;quot;US&amp;quot;
## 
## $quoteType
## [1] &amp;quot;CURRENCY&amp;quot;
## 
## $typeDisp
## [1] &amp;quot;Currency&amp;quot;
## 
## $quoteSourceName
## [1] &amp;quot;Delayed Quote&amp;quot;
## 
## $triggerable
## [1] TRUE
## 
## $customPriceAlertConfidence
## [1] &amp;quot;HIGH&amp;quot;
## 
## $currency
## [1] &amp;quot;INR&amp;quot;
## 
## $shortName
## [1] &amp;quot;USD/INR&amp;quot;
## 
## $regularMarketChangePercent
## [1] -0.2913199
## 
## $regularMarketPrice
## [1] 82.485
## 
## $regularMarketChange
## [1] -0.2409973
## 
## $regularMarketDayHigh
## [1] 82.731
## 
## $regularMarketDayLow
## [1] 82.45
## 
## $regularMarketPreviousClose
## [1] 82.726
## 
## $bid
## [1] 82.48
## 
## $ask
## [1] 82.53
## 
## $regularMarketOpen
## [1] 82.731
## 
## $fiftyTwoWeekLow
## [1] 73.6975
## 
## $fiftyTwoWeekHigh
## [1] 83.386
## 
## $fiftyDayAverage
## [1] 81.12029
## 
## $twoHundredDayAverage
## [1] 78.23625
## 
## $exchange
## [1] &amp;quot;CCY&amp;quot;
## 
## $messageBoardId
## [1] &amp;quot;finmb_INR_X&amp;quot;
## 
## $exchangeTimezoneName
## [1] &amp;quot;Europe/London&amp;quot;
## 
## $exchangeTimezoneShortName
## [1] &amp;quot;GMT&amp;quot;
## 
## $gmtOffSetMilliseconds
## [1] 0
## 
## $market
## [1] &amp;quot;ccy_market&amp;quot;
## 
## $esgPopulated
## [1] FALSE
## 
## $marketState
## [1] &amp;quot;REGULAR&amp;quot;
## 
## $regularMarketTime
## [1] 1667552433
## 
## $regularMarketDayRange
## [1] &amp;quot;82.45 - 82.731&amp;quot;
## 
## $regularMarketVolume
## [1] 0
## 
## $bidSize
## [1] 0
## 
## $askSize
## [1] 0
## 
## $fullExchangeName
## [1] &amp;quot;CCY&amp;quot;
## 
## $averageDailyVolume3Month
## [1] 0
## 
## $averageDailyVolume10Day
## [1] 0
## 
## $fiftyTwoWeekLowChange
## [1] 8.787498
## 
## $fiftyTwoWeekLowChangePercent
## [1] 0.1192374
## 
## $fiftyTwoWeekRange
## [1] &amp;quot;73.6975 - 83.386&amp;quot;
## 
## $fiftyTwoWeekHighChange
## [1] -0.901001
## 
## $tradeable
## [1] FALSE
## 
## $cryptoTradeable
## [1] FALSE
## 
## $fiftyTwoWeekHighChangePercent
## [1] -0.01080518
## 
## $firstTradeDateMilliseconds
## [1] 1.070237e+12
## 
## $priceHint
## [1] 4
## 
## $fiftyDayAverageChange
## [1] 1.364708
## 
## $fiftyDayAverageChangePercent
## [1] 0.01682326
## 
## $twoHundredDayAverageChange
## [1] 4.248749
## 
## $twoHundredDayAverageChangePercent
## [1] 0.05430665
## 
## $sourceInterval
## [1] 15
## 
## $exchangeDataDelayedBy
## [1] 0
## 
## $symbol
## [1] &amp;quot;USDINR=X&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;converter&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Converter&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;currency_converter()&lt;/code&gt; retrieve current conversion rate between two currencies as
well as historical rates.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;currency_converter(&amp;#39;GBP&amp;#39;, &amp;#39;USD&amp;#39;, &amp;#39;2022-07-01&amp;#39;, &amp;#39;2022-07-10&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                  date     high      low     open    close volume adj_close
## 1 2022-06-30 23:00:00 1.216205 1.198064 1.215998 1.216086      0  1.216086
## 2 2022-07-03 23:00:00 1.216515 1.208634 1.210580 1.210273      0  1.210273
## 3 2022-07-04 23:00:00 1.212606 1.190051 1.211402 1.211446      0  1.211446
## 4 2022-07-05 23:00:00 1.198638 1.187761 1.194957 1.194914      0  1.194914
## 5 2022-07-06 23:00:00 1.202183 1.191001 1.191895 1.192321      0  1.192321
## 6 2022-07-07 23:00:00 1.205531 1.192194 1.203196 1.202805      0  1.202805&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The time between data points can be specified using the &lt;code&gt;interval&lt;/code&gt; argument.
The &lt;code&gt;period&lt;/code&gt; arguments allows the user to retrieve data for specific length of time.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;currency_converter(&amp;#39;GBP&amp;#39;, &amp;#39;USD&amp;#39;, period = &amp;#39;1mo&amp;#39;, interval = &amp;#39;1d&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                   date     high      low     open    close volume adj_close
## 1  2022-10-03 23:00:00 1.144597 1.128222 1.133967 1.133414      0  1.133414
## 2  2022-10-04 23:00:00 1.149491 1.122776 1.145056 1.145134      0  1.145134
## 3  2022-10-05 23:00:00 1.138343 1.112038 1.135589 1.135538      0  1.135538
## 4  2022-10-06 23:00:00 1.122372 1.109201 1.116520 1.116208      0  1.116208
## 5  2022-10-09 23:00:00 1.111086 1.102354 1.107444 1.107273      0  1.107273
## 6  2022-10-10 23:00:00 1.117131 1.100183 1.107849 1.107641      0  1.107641
## 7  2022-10-11 23:00:00 1.109866 1.092645 1.096780 1.096780      0  1.096780
## 8  2022-10-12 23:00:00 1.136196 1.105828 1.109927 1.110556      0  1.110556
## 9  2022-10-13 23:00:00 1.135873 1.116196 1.130148 1.130391      0  1.130391
## 10 2022-10-16 23:00:00 1.143864 1.121705 1.123873 1.124417      0  1.124417
## 11 2022-10-17 23:00:00 1.141201 1.125809 1.135525 1.135396      0  1.135396
## 12 2022-10-18 23:00:00 1.134984 1.122246 1.133954 1.134430      0  1.134430
## 13 2022-10-19 23:00:00 1.133324 1.117368 1.120951 1.121101      0  1.121101
## 14 2022-10-20 23:00:00 1.129318 1.106378 1.122536 1.122146      0  1.122146
## 15 2022-10-23 23:00:00 1.137980 1.127485 1.133645 1.134469      0  1.134469
## 16 2022-10-24 23:00:00 1.149954 1.127370 1.130544 1.130774      0  1.130774
## 17 2022-10-25 23:00:00 1.162358 1.143419 1.146066 1.146224      0  1.146224
## 18 2022-10-26 23:00:00 1.164415 1.155095 1.163345 1.163819      0  1.163819
## 19 2022-10-27 23:00:00 1.160012 1.150616 1.156738 1.156604      0  1.156604
## 20 2022-10-31 00:00:00 1.161332 1.147987 1.160079 1.159595      0  1.159595
## 21 2022-11-01 00:00:00 1.156524 1.144675 1.147184 1.146815      0  1.146815
## 22 2022-11-02 00:00:00 1.152738 1.145856 1.149214 1.148950      0  1.148950
## 23 2022-11-03 00:00:00 1.142178 1.116258 1.138226 1.138433      0  1.138433
## 24 2022-11-04 08:59:42 1.124088 1.115101 1.115922 1.122322      0  1.122322&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;View the &lt;a href=&#34;https://yahoofinancer.rsquaredacademy.com/reference/currency_converter.html&#34;&gt;documentation&lt;/a&gt; to learn more.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;learning-more&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Learning More&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://yahoofinancer.rsquaredacademy.com&#34;&gt;Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/rsquaredacademy/yahoofinancer&#34;&gt;GitHub&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;feedback&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Feedback&lt;/h2&gt;
&lt;p&gt;All feedback is welcome. Issues (bugs and feature requests) can be posted to
&lt;a href=&#34;https://github.com/rsquaredacademy/yahoofinancer/issues&#34;&gt;github tracker&lt;/a&gt;.
For help with code or other related questions, feel free to reach out to us
at &lt;a href=&#34;mailto:pkgs@rsquaredacademy.com&#34; class=&#34;email&#34;&gt;pkgs@rsquaredacademy.com&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Handling Categorical Data in R - Part 4</title>
      <link>https://blog.rsquaredacademy.com/handling-categorical-data-in-r-part-4/</link>
      <pubDate>Fri, 14 Jan 2022 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/handling-categorical-data-in-r-part-4/</guid>
      <description>&lt;script src=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/header-attrs/header-attrs.js&#34;&gt;&lt;/script&gt;


&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/forcats-part-4.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;This is part 4 of a series on “Handling Categorical Data in R” where we are learning to &lt;strong&gt;read&lt;/strong&gt;, &lt;strong&gt;store&lt;/strong&gt;, &lt;strong&gt;summarize&lt;/strong&gt;, &lt;strong&gt;reshape&lt;/strong&gt; &amp;amp; &lt;strong&gt;visualize&lt;/strong&gt; categorical data.&lt;/p&gt;
&lt;p&gt;Below are the links to the other articles of this series:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://blog.rsquaredacademy.com/handling-categorical-data-in-r-part-1/&#34;&gt;Part 1 - Introduction to Factor&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://blog.rsquaredacademy.com/handling-categorical-data-in-r-part-2/&#34;&gt;Part 2 - Summarize Categorical Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://blog.rsquaredacademy.com/handling-categorical-data-in-r-part-3/&#34;&gt;Part 3 - Reshape Categorical Data&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this article, we will explore the different ways of visualizing categorical data using &lt;a href=&#34;https://ggplot2.tidyverse.org/&#34;&gt;ggplot2&lt;/a&gt;.&lt;/p&gt;
&lt;div id=&#34;resources&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Resources&lt;/h2&gt;
&lt;p&gt;You can download all the data sets, R scripts, practice questions and their solutions from our &lt;a href=&#34;https://github.com/rsquaredacademy-education/online-courses/&#34;&gt;GitHub&lt;/a&gt; repository.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In this section, we will learn to visualize categorical data. We will look at the following type of plots:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;univariate bar plot&lt;/li&gt;
&lt;li&gt;bivariate bar plot
&lt;ul&gt;
&lt;li&gt;grouped&lt;/li&gt;
&lt;li&gt;stacked&lt;/li&gt;
&lt;li&gt;proportional&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;mosaic plot&lt;/li&gt;
&lt;li&gt;pie chart&lt;/li&gt;
&lt;li&gt;donut chart&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We will be using &lt;a href=&#34;https://ggplot2.tidyverse.org&#34;&gt;ggplot2&lt;/a&gt; package throughout this article. So you should know the basics of data visualization with ggplot2. If you are new to or have never used ggplot2, do not worry. We have several &lt;a href=&#34;https://blog.rsquaredacademy.com/data-visualization/index.html&#34;&gt;tutorials&lt;/a&gt; and an &lt;a href=&#34;https://viz-ggplot2.rsquaredacademy.com/&#34;&gt;ebook&lt;/a&gt; on ggplot2, you can go through them first and then come back to this article. Let us read the case study data before we start our visualization journey.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# read data
data &amp;lt;- readRDS(&amp;#39;analytics.rds&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;bar-plot&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Bar Plot&lt;/h2&gt;
&lt;p&gt;Bar charts provide a visual representation of categorical data. The bars can be plotted either vertically or horizontally. The categories/groups appear along the horizontal X axis and the height of the bar represents a measured value.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(data) +
  geom_bar(aes(x = device), fill = &amp;quot;blue&amp;quot;) +
  xlab(&amp;quot;Device&amp;quot;) + ylab(&amp;quot;Count&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2022-01-14-handling-categorical-data-in-r-part-4_files/figure-html/bar_plot-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In the above example, the bars represent the count/frequency of the categories. If the bars represent continuous data, the value could be &lt;em&gt;mean&lt;/em&gt; or &lt;em&gt;sum&lt;/em&gt; of the variable being represented.&lt;/p&gt;
&lt;div id=&#34;grouped-bar-plot&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Grouped Bar Plot&lt;/h3&gt;
&lt;p&gt;A grouped bar chart plots values for two levels of a categorical variable instead of one. You should use grouped bar chart when making comparisons across different categories of data. Use it when you want to look at how the second category variable changes within each level of the first and vice versa.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(data) +
  geom_bar(aes(x = device, fill = gender), position = &amp;quot;dodge&amp;quot;) +
  xlab(&amp;quot;Device&amp;quot;) + ylab(&amp;quot;Count&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2022-01-14-handling-categorical-data-in-r-part-4_files/figure-html/grouped_bar_plot-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;stacked-bar-plot&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Stacked Bar Plot&lt;/h3&gt;
&lt;p&gt;In stacked bar plots, the bars are stacked on top of each other instead of placing them next to each other. Use stacked bar plots while looking at cumulative value.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(data) +
  geom_bar(aes(x = device, fill = gender)) +
  xlab(&amp;quot;Device&amp;quot;) + ylab(&amp;quot;Count&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2022-01-14-handling-categorical-data-in-r-part-4_files/figure-html/stacked_bar_plot-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;proportional-bar-plot&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Proportional Bar Plot&lt;/h3&gt;
&lt;p&gt;Also known as percent stacked plot, the height of all bars in this plot are the same. The distribution of the second categorical variable is scaled to 1 or 100. The length of each bar is determined by its share in the category. Use this when you want to concurrently observe each of several variables as they fluctuate and as their percentage ratio’s change.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;data %&amp;gt;% 
  select(device, gender) %&amp;gt;% 
  table() %&amp;gt;% 
  tibble::as_tibble() %&amp;gt;% 
  ggplot(aes(x = device, y = n, fill = gender)) +
  geom_bar(stat = &amp;quot;identity&amp;quot;, position = &amp;quot;fill&amp;quot;) +
  xlab(&amp;quot;Device&amp;quot;) + ylab(&amp;quot;Gender&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2022-01-14-handling-categorical-data-in-r-part-4_files/figure-html/prop_bar_plot-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;mosaic-plot&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Mosaic Plot&lt;/h2&gt;
&lt;p&gt;A mosaic plot is a graphical representation of a two way table or contingency table. It was introduced by Hartigan &amp;amp; Kleiner and is divided into rectangles. Proportions on horizontal axis represents the number of observations for each level of the X variable. The vertical length of each rectangle is proportional to the proportion of Y variable in each level of X variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(data = data) +
  geom_mosaic(aes(x = product(channel, device), fill = channel)) +
  xlab(&amp;quot;Device&amp;quot;) + ylab(&amp;quot;Channel&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2022-01-14-handling-categorical-data-in-r-part-4_files/figure-html/mosaic_plot-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;pie-chart&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Pie Chart&lt;/h2&gt;
&lt;p&gt;Pie chart is a circular chart, divided into slices to show relevant sizes of data. It shows the distribution of the different levels of a categorical variable as a circle is divided into radial slices. Each level corresponds with a single slice of the circle and size indicates the proportion of the level. Use it when comparing each group’s contribution to the whole as opposed to comparing groups to each other.&lt;/p&gt;
&lt;div id=&#34;base-r&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Base R&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;data %&amp;gt;% 
  pull(device) %&amp;gt;%
  table() %&amp;gt;%
  pie()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2022-01-14-handling-categorical-data-in-r-part-4_files/figure-html/pie_chart-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;d-pie-chart&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;3D Pie Chart&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;data %&amp;gt;% 
  pull(device) %&amp;gt;% 
  table() %&amp;gt;% 
  pie3D(explode = 0.1)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2022-01-14-handling-categorical-data-in-r-part-4_files/figure-html/pie_chart_3d-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;ggplot2&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;ggplot2&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;data %&amp;gt;% 
  pull(device) %&amp;gt;% 
  fct_count() %&amp;gt;% 
  rename(device = f, count = n) %&amp;gt;% 
  ggplot() +
  geom_bar(aes(x = &amp;quot;&amp;quot;, y = count, fill = device), width = 1, stat = &amp;quot;identity&amp;quot;) +
  coord_polar(&amp;quot;y&amp;quot;, start = 0)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2022-01-14-handling-categorical-data-in-r-part-4_files/figure-html/gg_pie_chart-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;donut-chart&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Donut Chart&lt;/h2&gt;
&lt;p&gt;Donut chart is a variation of the pie chart. It has a round hole in the middle which makes it look like a donut. The focus is on the length of the arcs and not the proportions of the slices. Blank spaces inside donut chart can be used to display information inside it.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;data %&amp;gt;% 
  pull(device) %&amp;gt;% 
  fct_count() %&amp;gt;% 
  rename(device = f, count = n) %&amp;gt;% 
  ggdonutchart(&amp;quot;count&amp;quot;, label = &amp;quot;device&amp;quot;, fill = &amp;quot;device&amp;quot;, color = &amp;quot;white&amp;quot;,
               palette = c(&amp;quot;#00AFBB&amp;quot;, &amp;quot;#E7B800&amp;quot;, &amp;quot;#FC4E07&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2022-01-14-handling-categorical-data-in-r-part-4_files/figure-html/gg_donut_chart-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Summary&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Bar charts provide a visual representation of categorical data.&lt;/li&gt;
&lt;li&gt;Use grouped bar chart to make comparison against different categories of data.&lt;/li&gt;
&lt;li&gt;Use stacked bar chart while looking at cumulative data.&lt;/li&gt;
&lt;li&gt;Use proportional bar chart when you want to concurrently observe each of the several variables as they fluctuate.&lt;/li&gt;
&lt;li&gt;Use mosaic plot to discover associations between two variables.&lt;/li&gt;
&lt;li&gt;Use pie chart and donut chart when comparing each group’s contribution to the whole.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;your-turn&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Your Turn…&lt;/h2&gt;
&lt;p&gt;Generate all the below plots:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Bar plot of &lt;code&gt;channel&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2022-01-14-handling-categorical-data-in-r-part-4_files/figure-html/plot_1-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;ol start=&#34;2&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Display grouped bar plot of &lt;code&gt;user_type&lt;/code&gt; by &lt;code&gt;channel&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2022-01-14-handling-categorical-data-in-r-part-4_files/figure-html/plot_2-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;ol start=&#34;3&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Display stacked bar plot of &lt;code&gt;channel&lt;/code&gt; by &lt;code&gt;gender&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2022-01-14-handling-categorical-data-in-r-part-4_files/figure-html/plot_3-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;ol start=&#34;4&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Display proportional bar plot of &lt;code&gt;channel&lt;/code&gt; by &lt;code&gt;device&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2022-01-14-handling-categorical-data-in-r-part-4_files/figure-html/plot_4-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;ol start=&#34;5&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Display mosaic plot of &lt;code&gt;device&lt;/code&gt; by &lt;code&gt;channel&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2022-01-14-handling-categorical-data-in-r-part-4_files/figure-html/plot_5-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;ol start=&#34;6&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Display pie or donut chart of &lt;code&gt;channel&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div id=&#34;pie-chart-1&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;6.1 Pie Chart&lt;/h5&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2022-01-14-handling-categorical-data-in-r-part-4_files/figure-html/plot_6-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;d-pie-chart-1&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;6.2 3D Pie Chart&lt;/h5&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2022-01-14-handling-categorical-data-in-r-part-4_files/figure-html/plot_7-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;pie-chart-ggplot2&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;6.3 Pie Chart (ggplot2)&lt;/h5&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2022-01-14-handling-categorical-data-in-r-part-4_files/figure-html/plot_8-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;donut-chart-1&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;6.4 Donut Chart&lt;/h5&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2022-01-14-handling-categorical-data-in-r-part-4_files/figure-html/plot_9-1.png&#34; width=&#34;960&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;*As the reader of this blog, you are our most important critic and commentator.
We value your opinion and want to know what we are doing right, what we could
do better, what areas you would like to see us publish in, and any other words
of wisdom you are willing to pass our way.&lt;/p&gt;
&lt;p&gt;We welcome your comments. You can email to let us know what you did or did not
like about our blog as well as what we can do to make our post better.*&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Email: &lt;a href=&#34;mailto:support@rsquaredacademy.com&#34; class=&#34;email&#34;&gt;support@rsquaredacademy.com&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Handling Categorical Data in R - Part 3</title>
      <link>https://blog.rsquaredacademy.com/handling-categorical-data-in-r-part-3/</link>
      <pubDate>Thu, 13 Jan 2022 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/handling-categorical-data-in-r-part-3/</guid>
      <description>&lt;script src=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/header-attrs/header-attrs.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/kePrint/kePrint.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/lightable/lightable.css&#34; rel=&#34;stylesheet&#34; /&gt;


&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/forcats-part-3.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;This is part 3 of a series on “Handling Categorical Data in R” where we are learning to &lt;strong&gt;read&lt;/strong&gt;, &lt;strong&gt;store&lt;/strong&gt;, &lt;strong&gt;summarize&lt;/strong&gt;, &lt;strong&gt;reshape&lt;/strong&gt; &amp;amp; &lt;strong&gt;visualize&lt;/strong&gt; categorical data.&lt;/p&gt;
&lt;p&gt;Below are the links to the other articles of this series:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://blog.rsquaredacademy.com/handling-categorical-data-in-r-part-1/&#34;&gt;Part 1 - Introduction to Factor&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://blog.rsquaredacademy.com/handling-categorical-data-in-r-part-2/&#34;&gt;Part 2 - Summarize Categorical Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://blog.rsquaredacademy.com/handling-categorical-data-in-r-part-4/&#34;&gt;Part 4 - Visualize Categorical Data&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this article, we will learn to manipulate/reshape categorical data by changing the value and order of levels/categories.&lt;/p&gt;
&lt;div id=&#34;table-of-contents&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Table of Contents&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#resources&#34;&gt;Resources&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#intro&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#changevalue&#34;&gt;How to change value of levels?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#addremove&#34;&gt;How to add or remove levels?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#changeorder&#34;&gt;How to change order of levels?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#practice&#34;&gt;Practice Questions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;resources&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Resources&lt;/h2&gt;
&lt;p&gt;You can download all the data sets, R scripts, practice questions and their solutions from our &lt;a href=&#34;https://github.com/rsquaredacademy-education/online-courses/&#34;&gt;GitHub&lt;/a&gt; repository.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;intro&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In this section, our focus will be on handling the levels of a categorical variable, and exploring the &lt;a href=&#34;https://forcats.tidyverse.org/&#34;&gt;forcats&lt;/a&gt; package for the same. We will basically look at 3 key operations or transformations we would like to do when it comes to factors which are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;change value of levels&lt;/li&gt;
&lt;li&gt;add or remove levels&lt;/li&gt;
&lt;li&gt;change order of levels&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Before we start working with the value of the levels, let us read the case study data and take a quick look at some of the functions we used in the previous articles.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# read data
data &amp;lt;- readRDS(&amp;#39;analytics.rds&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We will store the source of traffic as &lt;code&gt;channel&lt;/code&gt; instead of referring to the column in the &lt;code&gt;data.frame&lt;/code&gt; every time.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;channel &amp;lt;- data$channel&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us go back to the function we used for tabulating data, &lt;code&gt;fct_count()&lt;/code&gt;. If you observe the result, it is in the same order as displayed by &lt;code&gt;levels()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fct_count(channel)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 8 x 2
##   f                   n
##   &amp;lt;fct&amp;gt;           &amp;lt;int&amp;gt;
## 1 (Other)          6073
## 2 Affiliates       7388
## 3 Direct          39853
## 4 Display          3375
## 5 Organic Search 139668
## 6 Paid Search      4395
## 7 Referral        35615
## 8 Social           8031&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you want to sort the results by the count i.e. most common level comes at the top, use the &lt;code&gt;sort&lt;/code&gt; argument.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_sort.png&#34; width=&#34;90%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fct_count(channel, sort = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 8 x 2
##   f                   n
##   &amp;lt;fct&amp;gt;           &amp;lt;int&amp;gt;
## 1 Organic Search 139668
## 2 Direct          39853
## 3 Referral        35615
## 4 Social           8031
## 5 Affiliates       7388
## 6 (Other)          6073
## 7 Paid Search      4395
## 8 Display          3375&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you want to view the proportion along with the count, set the &lt;code&gt;prop&lt;/code&gt; argument to &lt;code&gt;TRUE&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fct_count(channel, prop = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 8 x 3
##   f                   n      p
##   &amp;lt;fct&amp;gt;           &amp;lt;int&amp;gt;  &amp;lt;dbl&amp;gt;
## 1 (Other)          6073 0.0248
## 2 Affiliates       7388 0.0302
## 3 Direct          39853 0.163 
## 4 Display          3375 0.0138
## 5 Organic Search 139668 0.571 
## 6 Paid Search      4395 0.0180
## 7 Referral        35615 0.146 
## 8 Social           8031 0.0329&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;One of the important steps in data preparation/sanitization is to check if the levels are valid i.e. only levels which should be present in the data are actually present. &lt;code&gt;fct_match()&lt;/code&gt; can be used to check validity of levels. It returns a logical vector if the level is present and an error if not.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;table(fct_match(channel, &amp;quot;Social&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##  FALSE   TRUE 
## 236367   8031&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;changevalue&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Change Value of Levels&lt;/h2&gt;
&lt;p&gt;In this section, we will learn how to change the value of the levels. In order to keep it interesting, we will state an objective from our case study and then map it into a function from the &lt;a href=&#34;https://forcats.tidyverse.org/&#34;&gt;forcats&lt;/a&gt; package.&lt;/p&gt;
&lt;div id=&#34;combine-both-paid-organic-search-into-a-single-level-search&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Combine both Paid &amp;amp; Organic Search into a single level, Search&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_collapse.png&#34; width=&#34;90%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In this case, we want to change the value of two levels, &lt;em&gt;Paid Search&lt;/em&gt; &amp;amp; &lt;em&gt;Organic Search&lt;/em&gt; and give them the common value &lt;em&gt;Search&lt;/em&gt;. You can also look at it as collapsing two levels into one. There are two functions we can use here:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;fct_collapse()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;fct_recode()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let us look at &lt;code&gt;fct_collapse()&lt;/code&gt; first. After specifying the categorical variable, we specify the new value followed by a character vector of the existing values. Remember, the new value is not enclosed in quotes (single or double) but the existing values must be a &lt;code&gt;character&lt;/code&gt; vector.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fct_count(
  fct_collapse(
    channel,
    Search = c(&amp;quot;Paid Search&amp;quot;, &amp;quot;Organic Search&amp;quot;)
  )
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 7 x 2
##   f               n
##   &amp;lt;fct&amp;gt;       &amp;lt;int&amp;gt;
## 1 (Other)      6073
## 2 Affiliates   7388
## 3 Direct      39853
## 4 Display      3375
## 5 Search     144063
## 6 Referral    35615
## 7 Social       8031&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the case of &lt;code&gt;fct_recode()&lt;/code&gt;, each value being changed must be specified in a new line. Similar to
&lt;code&gt;fct_collapse()&lt;/code&gt;, the new value is not enclosed in quotes but the existing values must be.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_recode.png&#34; width=&#34;90%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fct_count(
  fct_recode(
    channel,
    Search = &amp;quot;Paid Search&amp;quot;,
    Search = &amp;quot;Organic Search&amp;quot;
  )
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 7 x 2
##   f               n
##   &amp;lt;fct&amp;gt;       &amp;lt;int&amp;gt;
## 1 (Other)      6073
## 2 Affiliates   7388
## 3 Direct      39853
## 4 Display      3375
## 5 Search     144063
## 6 Referral    35615
## 7 Social       8031&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;a href=&#34;https://dplyr.tidyverse.org/&#34;&gt;dplyr&lt;/a&gt; and &lt;a href=&#34;https://cran.r-project.org/package=car&#34;&gt;car&lt;/a&gt; packages also have recode functions.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;retain-only-those-channels-which-have-driven-a-minimum-traffic-of-5000-to-the-website&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Retain only those channels which have driven a minimum traffic of 5000 to the website&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_lump_1.png&#34; width=&#34;90%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Instead of having all the channels, we desire to retain only those channels which have driven at least &lt;em&gt;5000&lt;/em&gt; visits to the website. What about the rest of the channels which have driven less than &lt;em&gt;5000&lt;/em&gt;? We will recategorize them as &lt;strong&gt;Other&lt;/strong&gt;. Keep in mind that we already have a &lt;strong&gt;(Other)&lt;/strong&gt; level in our data. &lt;code&gt;fct_lump_min()&lt;/code&gt; will lump together all levels which do not have a minimum count specified. In our case study, only &lt;strong&gt;Display&lt;/strong&gt; drives less than &lt;em&gt;5000&lt;/em&gt; visits and it will be categorized into &lt;strong&gt;Other&lt;/strong&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fct_count(fct_lump_min(channel, 5000))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 7 x 2
##   f                   n
##   &amp;lt;fct&amp;gt;           &amp;lt;int&amp;gt;
## 1 (Other)          6073
## 2 Affiliates       7388
## 3 Direct          39853
## 4 Organic Search 139668
## 5 Referral        35615
## 6 Social           8031
## 7 Other            7770&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;retain-only-top-3-referring-channels-and-categorize-rest-into-other&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Retain only top 3 referring channels and categorize rest into Other&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_lump_2.png&#34; width=&#34;90%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Suppose you decide to retain only the top 3 channels in terms of the traffic driven to the website. In our
case study, these are &lt;strong&gt;Direct&lt;/strong&gt;, &lt;strong&gt;Organic Search&lt;/strong&gt; and &lt;strong&gt;Referral&lt;/strong&gt;. We want to retain these 3 levels and categorize the rest as &lt;strong&gt;Other&lt;/strong&gt;. &lt;code&gt;fct_lump_n()&lt;/code&gt; will retain top &lt;code&gt;n&lt;/code&gt; levels by count/frequency and lump the rest into &lt;strong&gt;Other&lt;/strong&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fct_count(fct_lump_n(channel, 3))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 4 x 2
##   f                   n
##   &amp;lt;fct&amp;gt;           &amp;lt;int&amp;gt;
## 1 Direct          39853
## 2 Organic Search 139668
## 3 Referral        35615
## 4 Other           29262&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In our case, &lt;code&gt;n&lt;/code&gt; is 3 and hence the top 3 channels in terms of traffic driven are retained while the rest are
lumped into &lt;strong&gt;Other&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;retain-only-those-channels-which-have-driven-at-least-2-of-the-overall-traffic&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Retain only those channels which have driven at least 2% of the overall traffic&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_lump_3.png&#34; width=&#34;90%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In the second scenario above, we retained channels based on minimum traffic driven by them to the website.
The criteria was count of visits. If you want to specify the criteria as a percentage or proportion instead of count, use &lt;code&gt;fct_lump_prop()&lt;/code&gt;. The criteria is a value between &lt;strong&gt;0&lt;/strong&gt; and &lt;strong&gt;1&lt;/strong&gt;. In our case study, we want to retain channels that have driven at least &lt;strong&gt;2%&lt;/strong&gt; of the overall traffic. Hence, we have specified the criteria as &lt;code&gt;0.02&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fct_count(fct_lump_prop(channel, 0.02))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 7 x 2
##   f                   n
##   &amp;lt;fct&amp;gt;           &amp;lt;int&amp;gt;
## 1 (Other)          6073
## 2 Affiliates       7388
## 3 Direct          39853
## 4 Organic Search 139668
## 5 Referral        35615
## 6 Social           8031
## 7 Other            7770&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, only &lt;strong&gt;Display&lt;/strong&gt; drives less than &lt;strong&gt;2%&lt;/strong&gt; of overall traffic and has been lumped into &lt;strong&gt;Other&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;retain-the-following-channels-and-merge-the-rest-into-other&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Retain the following channels and merge the rest into Other&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Organic Search&lt;/li&gt;
&lt;li&gt;Direct&lt;/li&gt;
&lt;li&gt;Referral&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the previous scenarios, we have been retaining or lumping channels based on some criteria like count or
percentage of traffic driven to the website. In this scenario, we want to retain certain levels by specifying
their labels and combine the rest into &lt;strong&gt;Other&lt;/strong&gt;. While we can use &lt;code&gt;fct_collapse()&lt;/code&gt; or &lt;code&gt;fct_recode()&lt;/code&gt;, a more
appropriate function would be &lt;code&gt;fct_other()&lt;/code&gt;. We will do a comparison of the three functions in a short while.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_others.png&#34; width=&#34;90%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;fct_other()&lt;/code&gt; has two arguments, &lt;code&gt;keep&lt;/code&gt; and &lt;code&gt;drop&lt;/code&gt;. &lt;code&gt;keep&lt;/code&gt; is used when we know the levels we want to retain
and &lt;code&gt;drop&lt;/code&gt; is used when we know the levels we want to drop. In this scenario, we know the levels we want to
retain and hence we will use the &lt;code&gt;keep&lt;/code&gt; argument and specify them. &lt;strong&gt;Organic Search&lt;/strong&gt;, &lt;strong&gt;Direct&lt;/strong&gt; and &lt;strong&gt;Referral&lt;/strong&gt; will be retained while the rest of the channels will be lumped into &lt;strong&gt;Other&lt;/strong&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fct_count(
  fct_other(
    channel, 
    keep = c(&amp;quot;Organic Search&amp;quot;, &amp;quot;Direct&amp;quot;, &amp;quot;Referral&amp;quot;))
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 4 x 2
##   f                   n
##   &amp;lt;fct&amp;gt;           &amp;lt;int&amp;gt;
## 1 Direct          39853
## 2 Organic Search 139668
## 3 Referral        35615
## 4 Other           29262&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;merge-the-following-channels-into-other-and-retain-rest-of-them&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Merge the following channels into Other and retain rest of them:&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Display&lt;/li&gt;
&lt;li&gt;Paid Search&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_others_drop.png&#34; width=&#34;90%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In this scenario, we know the levels we want to drop and hence we will use the &lt;code&gt;drop&lt;/code&gt; argument and specify
them. &lt;strong&gt;Display&lt;/strong&gt; and &lt;strong&gt;Paid Search&lt;/strong&gt; will be lumped into &lt;strong&gt;Other&lt;/strong&gt; while the rest of the channels will be retained.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fct_count(
  fct_other(
    channel, 
    drop = c(&amp;quot;Display&amp;quot;, &amp;quot;Paid Search&amp;quot;)
  )
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 7 x 2
##   f                   n
##   &amp;lt;fct&amp;gt;           &amp;lt;int&amp;gt;
## 1 (Other)          6073
## 2 Affiliates       7388
## 3 Direct          39853
## 4 Organic Search 139668
## 5 Referral        35615
## 6 Social           8031
## 7 Other            7770&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the previous scenario, we said we will compare &lt;code&gt;fct_other()&lt;/code&gt; with &lt;code&gt;fct_collapse()&lt;/code&gt; and &lt;code&gt;fct_recode()&lt;/code&gt;. Let us use the other two functions as well and see the difference.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# collapse
fct_count(
  fct_collapse(
  channel,
  Other = c(&amp;quot;(Other)&amp;quot;, &amp;quot;Affiliate&amp;quot;, &amp;quot;Display&amp;quot;, &amp;quot;Paid Search&amp;quot;, &amp;quot;Social&amp;quot;)
  )
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: Unknown levels in `f`: Affiliate&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 5 x 2
##   f                   n
##   &amp;lt;fct&amp;gt;           &amp;lt;int&amp;gt;
## 1 Other           21874
## 2 Affiliates       7388
## 3 Direct          39853
## 4 Organic Search 139668
## 5 Referral        35615&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# recode
fct_count(
  fct_recode(
  channel,
  Other = &amp;quot;(Other)&amp;quot;, 
  Other = &amp;quot;Affiliate&amp;quot;, 
  Other = &amp;quot;Display&amp;quot;, 
  Other = &amp;quot;Paid Search&amp;quot;, 
  Other = &amp;quot;Social&amp;quot;
  )
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: Unknown levels in `f`: Affiliate&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 5 x 2
##   f                   n
##   &amp;lt;fct&amp;gt;           &amp;lt;int&amp;gt;
## 1 Other           21874
## 2 Affiliates       7388
## 3 Direct          39853
## 4 Organic Search 139668
## 5 Referral        35615&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can observe, &lt;code&gt;fct_other()&lt;/code&gt; requires less typing and is easier to specify.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;anonymize-the-data-set-before-sharing-it-with-your-colleagues&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Anonymize the data set before sharing it with your colleagues&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_anonymize.png&#34; width=&#34;90%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Anonymizing data is extremely important when you are sharing sensitive data with others. Here, we want
to anonymize the channels which drive traffic to the website so that we can share it with others without
divulging the names of the channels. &lt;code&gt;fct_anon()&lt;/code&gt; allows us to anonymize the levels in the data. Using the
&lt;code&gt;prefix&lt;/code&gt; argument, we can specify the prefix to be used while anonymizing the data.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fct_count(fct_anon(channel, prefix = &amp;quot;ch_&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 8 x 2
##   f          n
##   &amp;lt;fct&amp;gt;  &amp;lt;int&amp;gt;
## 1 ch_1    6073
## 2 ch_2    8031
## 3 ch_3    4395
## 4 ch_4   39853
## 5 ch_5  139668
## 6 ch_6    3375
## 7 ch_7   35615
## 8 ch_8    7388&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;key-functions&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Key Functions&lt;/h3&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Function
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;fct_collapse()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Collapse factor levels
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;fct_recode()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Recode factor levels
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;fct_lump_min()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Lump factor levels with count lesser than specified value
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;fct_lump_n()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Lump all levels except the top n levels
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;fct_lump_prop()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Lump factor levels with count lesser than specified proportion
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;fct_lump_lowfreq()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Lump together least frequent levels
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;fct_other()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Replace levels with Other level
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;fct_anon()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Anonymize factor levels
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;addremove&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Add / Remove Levels&lt;/h2&gt;
&lt;p&gt;In this small section, we will learn to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;add new levels&lt;/li&gt;
&lt;li&gt;drop levels&lt;/li&gt;
&lt;li&gt;make missing values explicit&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;add-a-new-level-blog&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Add a new level, Blog&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_expand.png&#34; width=&#34;90%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;fct_expand()&lt;/code&gt; allows us to add new levels to the data. The label of the new level must be specified after the variable name and must be enclosed in quotes. If the level already exists, it will be ignored. Let us add a new level, &lt;code&gt;Blog&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;levels(fct_expand(channel, &amp;quot;Blog&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;(Other)&amp;quot;        &amp;quot;Affiliates&amp;quot;     &amp;quot;Direct&amp;quot;         &amp;quot;Display&amp;quot;       
## [5] &amp;quot;Organic Search&amp;quot; &amp;quot;Paid Search&amp;quot;    &amp;quot;Referral&amp;quot;       &amp;quot;Social&amp;quot;        
## [9] &amp;quot;Blog&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;drop-existing-level&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Drop existing level&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_drop.png&#34; width=&#34;90%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;On the other hand, &lt;code&gt;fct_drop()&lt;/code&gt; will drop levels which have no values i.e. unused levels. If you want
to drop only specific levels, use the &lt;code&gt;only&lt;/code&gt; argument and specify the name of the level in quotes. Let us drop the new level we added in the previous example.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;levels(fct_drop(fct_expand(channel, &amp;quot;Blog&amp;quot;)))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;(Other)&amp;quot;        &amp;quot;Affiliates&amp;quot;     &amp;quot;Direct&amp;quot;         &amp;quot;Display&amp;quot;       
## [5] &amp;quot;Organic Search&amp;quot; &amp;quot;Paid Search&amp;quot;    &amp;quot;Referral&amp;quot;       &amp;quot;Social&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;make-missing-values-explicit&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Make missing values explicit&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_explicit_na.png&#34; width=&#34;90%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In our data set, the gender column has many missing values, and in R, missing values are represented by &lt;code&gt;NA&lt;/code&gt;. Suppose you are sharing the data or analysis with someone who is not an R user, and does not know what &lt;code&gt;NA&lt;/code&gt; represents. In such a scenario, we can use the &lt;code&gt;fct_explicit_na()&lt;/code&gt; function to make the missing values in the gender column explicit i.e. it will appear as &lt;code&gt;(Missing)&lt;/code&gt; instead of &lt;code&gt;NA&lt;/code&gt;. This will help non R users to understand that there are missing values in the data.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fct_count(fct_explicit_na(data$gender))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 x 2
##   f              n
##   &amp;lt;fct&amp;gt;      &amp;lt;int&amp;gt;
## 1 female     40565
## 2 male       61617
## 3 (Missing) 142216&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;key-functions-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Key Functions&lt;/h3&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Function
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;fct_expand()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Add additional levels to a factor
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;fct_drop()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Drop unused factor levels
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;fct_explicit_na()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Make missing values explicit
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;changeorder&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Change Order of Levels&lt;/h2&gt;
&lt;p&gt;In this last section, we will learn how to change the order of the levels. We will look at the following scenarios from our case study:&lt;/p&gt;
&lt;p&gt;We want to make&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Organic Search the first level&lt;/li&gt;
&lt;li&gt;Referral the third level&lt;/li&gt;
&lt;li&gt;Display the last level&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;make-organic-search-the-first-level&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Make Organic Search the first level&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_relevel_1.png&#34; width=&#34;90%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In this scenario, we want the levels to appear in a certain order. In the first case, we want &lt;strong&gt;Organic Search&lt;/strong&gt; to be the first level. &lt;code&gt;fct_relevel()&lt;/code&gt; allows us to manually reorder the levels. To move a level to the beginning, specify the label (it must be enclosed in quotes).&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;levels(channel)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;(Other)&amp;quot;        &amp;quot;Affiliates&amp;quot;     &amp;quot;Direct&amp;quot;         &amp;quot;Display&amp;quot;       
## [5] &amp;quot;Organic Search&amp;quot; &amp;quot;Paid Search&amp;quot;    &amp;quot;Referral&amp;quot;       &amp;quot;Social&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;levels(fct_relevel(channel, &amp;quot;Organic Search&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Organic Search&amp;quot; &amp;quot;(Other)&amp;quot;        &amp;quot;Affiliates&amp;quot;     &amp;quot;Direct&amp;quot;        
## [5] &amp;quot;Display&amp;quot;        &amp;quot;Paid Search&amp;quot;    &amp;quot;Referral&amp;quot;       &amp;quot;Social&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;make-referral-the-third-level&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Make Referral the third level&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_relevel_2.png&#34; width=&#34;90%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;after&lt;/code&gt; argument is useful when we want to move the level to the end or anywhere between the beginning and end. In the second case, we want &lt;strong&gt;Referral&lt;/strong&gt; to be the third level. After specifying the label, use the &lt;code&gt;after&lt;/code&gt; argument and specify the level after which &lt;strong&gt;Referral&lt;/strong&gt; should appear. Since we want to move it to the third position, we will set the value of &lt;code&gt;after&lt;/code&gt; to &lt;code&gt;2&lt;/code&gt; i.e. &lt;strong&gt;Referral&lt;/strong&gt; should come after the second position.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;levels(channel)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;(Other)&amp;quot;        &amp;quot;Affiliates&amp;quot;     &amp;quot;Direct&amp;quot;         &amp;quot;Display&amp;quot;       
## [5] &amp;quot;Organic Search&amp;quot; &amp;quot;Paid Search&amp;quot;    &amp;quot;Referral&amp;quot;       &amp;quot;Social&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;levels(fct_relevel(channel, &amp;quot;Referral&amp;quot;, after = 2))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;(Other)&amp;quot;        &amp;quot;Affiliates&amp;quot;     &amp;quot;Referral&amp;quot;       &amp;quot;Direct&amp;quot;        
## [5] &amp;quot;Display&amp;quot;        &amp;quot;Organic Search&amp;quot; &amp;quot;Paid Search&amp;quot;    &amp;quot;Social&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;make-display-the-last-level&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Make Display the last level&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_relevel_3.png&#34; width=&#34;90%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In this last case, we want to move &lt;strong&gt;Display&lt;/strong&gt; to the end. If you know the number of levels, you can specify a value here. In our data, there are eight channels i.e. eight levels, so we can set the value of &lt;code&gt;after&lt;/code&gt; to &lt;code&gt;7&lt;/code&gt;. What happens when we do not know the number of levels or if they tend to vary? In such cases, to move a level to the end, set the value of &lt;code&gt;after&lt;/code&gt; to &lt;code&gt;Inf&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;levels(channel)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;(Other)&amp;quot;        &amp;quot;Affiliates&amp;quot;     &amp;quot;Direct&amp;quot;         &amp;quot;Display&amp;quot;       
## [5] &amp;quot;Organic Search&amp;quot; &amp;quot;Paid Search&amp;quot;    &amp;quot;Referral&amp;quot;       &amp;quot;Social&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;levels(fct_relevel(channel, &amp;quot;Display&amp;quot;, after = Inf))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;(Other)&amp;quot;        &amp;quot;Affiliates&amp;quot;     &amp;quot;Direct&amp;quot;         &amp;quot;Organic Search&amp;quot;
## [5] &amp;quot;Paid Search&amp;quot;    &amp;quot;Referral&amp;quot;       &amp;quot;Social&amp;quot;         &amp;quot;Display&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us now look at a scenario where we want to order the levels by&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;frequency (largest to smallest)&lt;/li&gt;
&lt;li&gt;order of appearance (in data)&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;order-levels-by-frequency&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Order levels by frequency&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_infreq.png&#34; width=&#34;90%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In the first case, the levels with the most frequency should appear at the top. &lt;code&gt;fct_infreq()&lt;/code&gt; will order the
levels by their frequency.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# reorder levels
levels(channel)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;(Other)&amp;quot;        &amp;quot;Affiliates&amp;quot;     &amp;quot;Direct&amp;quot;         &amp;quot;Display&amp;quot;       
## [5] &amp;quot;Organic Search&amp;quot; &amp;quot;Paid Search&amp;quot;    &amp;quot;Referral&amp;quot;       &amp;quot;Social&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;levels(fct_infreq(channel))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Organic Search&amp;quot; &amp;quot;Direct&amp;quot;         &amp;quot;Referral&amp;quot;       &amp;quot;Social&amp;quot;        
## [5] &amp;quot;Affiliates&amp;quot;     &amp;quot;(Other)&amp;quot;        &amp;quot;Paid Search&amp;quot;    &amp;quot;Display&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;order-levels-by-appearance&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Order levels by appearance&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_inorder.png&#34; width=&#34;90%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In the second case, the order of the levels should be the same as the order of their appearance in the data. &lt;code&gt;fct_inorder()&lt;/code&gt; will order the levels according to the order in which they appear in the data.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# reorder levels
levels(channel)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;(Other)&amp;quot;        &amp;quot;Affiliates&amp;quot;     &amp;quot;Direct&amp;quot;         &amp;quot;Display&amp;quot;       
## [5] &amp;quot;Organic Search&amp;quot; &amp;quot;Paid Search&amp;quot;    &amp;quot;Referral&amp;quot;       &amp;quot;Social&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;levels(fct_inorder(channel))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Organic Search&amp;quot; &amp;quot;Direct&amp;quot;         &amp;quot;Referral&amp;quot;       &amp;quot;Affiliates&amp;quot;    
## [5] &amp;quot;(Other)&amp;quot;        &amp;quot;Social&amp;quot;         &amp;quot;Display&amp;quot;        &amp;quot;Paid Search&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;reverse-the-order-of-the-levels&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Reverse the order of the levels&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_rev.png&#34; width=&#34;90%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The order of the levels can be reversed using &lt;code&gt;fct_rev()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# reorder levels
levels(channel)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;(Other)&amp;quot;        &amp;quot;Affiliates&amp;quot;     &amp;quot;Direct&amp;quot;         &amp;quot;Display&amp;quot;       
## [5] &amp;quot;Organic Search&amp;quot; &amp;quot;Paid Search&amp;quot;    &amp;quot;Referral&amp;quot;       &amp;quot;Social&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;levels(fct_rev(channel))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Social&amp;quot;         &amp;quot;Referral&amp;quot;       &amp;quot;Paid Search&amp;quot;    &amp;quot;Organic Search&amp;quot;
## [5] &amp;quot;Display&amp;quot;        &amp;quot;Direct&amp;quot;         &amp;quot;Affiliates&amp;quot;     &amp;quot;(Other)&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;randomly-shuffle-the-order-of-the-levels&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Randomly shuffle the order of the levels&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_shuffle.png&#34; width=&#34;90%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The order of the levels can be randomly shuffled using &lt;code&gt;fct_shuffle()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# reorder levels
levels(channel)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;(Other)&amp;quot;        &amp;quot;Affiliates&amp;quot;     &amp;quot;Direct&amp;quot;         &amp;quot;Display&amp;quot;       
## [5] &amp;quot;Organic Search&amp;quot; &amp;quot;Paid Search&amp;quot;    &amp;quot;Referral&amp;quot;       &amp;quot;Social&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;levels(fct_shuffle(channel))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Organic Search&amp;quot; &amp;quot;Referral&amp;quot;       &amp;quot;Display&amp;quot;        &amp;quot;(Other)&amp;quot;       
## [5] &amp;quot;Direct&amp;quot;         &amp;quot;Paid Search&amp;quot;    &amp;quot;Affiliates&amp;quot;     &amp;quot;Social&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;key-functions-2&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Key Functions&lt;/h3&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Function
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;fct_relevel()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Reorder factor levels
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;fct_shift()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Shift factor levels
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;fct_infreq()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Reorder factor levels by frequency
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;fct_rev()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Reverse order of factor levels
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;fct_inorder()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Reorder factor levels by first appearance
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;fct_shuffle()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Randomly shuffle factor levels
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;practice&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Your Turn…&lt;/h2&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;p&gt;Display the count/frequency of the following variables in the descending order&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;device&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;landing_page&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;exit_page&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Check if &lt;code&gt;laptop&lt;/code&gt; is a level in the &lt;code&gt;device&lt;/code&gt; column.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Combine the following levels in &lt;code&gt;landing_page&lt;/code&gt; into &lt;code&gt;Account&lt;/code&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;My Account&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Register&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Sign In&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Your Info&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Combine levels in &lt;code&gt;landing_page&lt;/code&gt; that drive less than 1000 visits.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Get top 10 landing and exit pages.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Get landing pages that drive at least 5% of the total traffic to the website.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Retain only the following levels in the &lt;code&gt;browser&lt;/code&gt; column:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Chrome&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Firefox&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Safari&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Edge&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Anonymize landing and exit page levels.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Make &lt;code&gt;Home&lt;/code&gt; first level in the &lt;code&gt;landing_page&lt;/code&gt; column.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Make &lt;code&gt;Apparel&lt;/code&gt; second level in the &lt;code&gt;landing_page&lt;/code&gt; column.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Make &lt;code&gt;Specials&lt;/code&gt; last level in the &lt;code&gt;landing_page&lt;/code&gt; column.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Order the levels in the browser by frequency:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Order the levels in landing page by appearance:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Shuffle the levels in os&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reverse the levels in browser&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;*As the reader of this blog, you are our most important critic and commentator.
We value your opinion and want to know what we are doing right, what we could
do better, what areas you would like to see us publish in, and any other words
of wisdom you are willing to pass our way.&lt;/p&gt;
&lt;p&gt;We welcome your comments. You can email to let us know what you did or did not
like about our blog as well as what we can do to make our post better.*&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Email: &lt;a href=&#34;mailto:support@rsquaredacademy.com&#34; class=&#34;email&#34;&gt;support@rsquaredacademy.com&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Handling Categorical Data in R - Part 2</title>
      <link>https://blog.rsquaredacademy.com/handling-categorical-data-in-r-part-2/</link>
      <pubDate>Wed, 12 Jan 2022 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/handling-categorical-data-in-r-part-2/</guid>
      <description>&lt;script src=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/header-attrs/header-attrs.js&#34;&gt;&lt;/script&gt;


&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/forcats-part-2.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;This is part 2 of a series on “Handling Categorical Data in R” where we are learning to &lt;strong&gt;read&lt;/strong&gt;, &lt;strong&gt;store&lt;/strong&gt;, &lt;strong&gt;summarize&lt;/strong&gt;, &lt;strong&gt;reshape&lt;/strong&gt; &amp;amp; &lt;strong&gt;visualize&lt;/strong&gt; categorical data.&lt;/p&gt;
&lt;p&gt;Below are the links to the other articles of this series:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://blog.rsquaredacademy.com/handling-categorical-data-in-r-part-1/&#34;&gt;Part 1 - Introduction to Factor&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://blog.rsquaredacademy.com/handling-categorical-data-in-r-part-3/&#34;&gt;Part 3 - Reshape Categorical Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://blog.rsquaredacademy.com/handling-categorical-data-in-r-part-4/&#34;&gt;Part 4 - Visualize Categorical Data&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this article, we will learn to summarize categorical data. In the process, we will do a deep dive on working with tables in R and explore a diverse set of packages.&lt;/p&gt;
&lt;div id=&#34;table-of-contents&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Table of Contents&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#resources&#34;&gt;Resources&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#intro&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#tables&#34;&gt;Tables in R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#practice&#34;&gt;Practice Questions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;resources&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Resources&lt;/h2&gt;
&lt;p&gt;You can download all the data sets, R scripts, practice questions and their solutions from our &lt;a href=&#34;https://github.com/rsquaredacademy-education/online-courses/&#34;&gt;GitHub&lt;/a&gt; repository.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;intro&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;Categorical data cannot be summarized in the same way as numeric data. It does not make sense to look at range, standard deviation etc. since data consists of a few distinct values only. So how do we summarize such data? We can look at&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;count/frequency&lt;/li&gt;
&lt;li&gt;proportion&lt;/li&gt;
&lt;li&gt;cumulative frequency&lt;/li&gt;
&lt;li&gt;cross table&lt;/li&gt;
&lt;li&gt;contingency table etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this section, we will explore the above ways of summarizing categorical data. We will also spend some time
learning about tables as you will be using them extensively while working with categorical data. R has many packages for tabulating data and we list and explore all of them in the R scripts shared in the GitHub repository.&lt;/p&gt;
&lt;div id=&#34;number-of-categories&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Number of Categories&lt;/h3&gt;
&lt;p&gt;From our case study, we want to know the number of devices used to browse the website, the name of the
devices and the proportion of traffic they drive to our website. Let us read the case study data set before we analyze the website traffic.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# read data
data &amp;lt;- readRDS(&amp;#39;analytics.rds&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us begin with the number of devices. To view the number of groups/categories in a categorical variable, use &lt;code&gt;nlevels()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;nlevels(data$device)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There are 3 categories of devices used by the visitors to browse the website. This can also be used for data
sanitization i.e. as an analyst you know that there are only 3 valid categories of device into which any visitor can be classified into. If you see more than 3 categories, you might want to check if there are any issues in data collection or processing. Now that we know there are 3 categories of devices, let us check if they are valid. The &lt;code&gt;levels()&lt;/code&gt; function will return the labels of the groups.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;category-names&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Category Names&lt;/h3&gt;
&lt;p&gt;Knowing the number of levels is useful but not sufficient. &lt;code&gt;levels()&lt;/code&gt; is one of the most useful functions when it comes to dealing with categorical data.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;levels(data$device)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Desktop&amp;quot; &amp;quot;Mobile&amp;quot;  &amp;quot;Tablet&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Other functions that you can use include &lt;code&gt;unique()&lt;/code&gt; and &lt;code&gt;fct_unique()&lt;/code&gt;. Both these functions will return the unique names/labels along with the levels while &lt;code&gt;levels()&lt;/code&gt; returns the labels of the levels.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;unique(data$device)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] Desktop Mobile  Tablet 
## Levels: Desktop Mobile Tablet&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fct_unique(data$device)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] Desktop Mobile  Tablet 
## Levels: Desktop Mobile Tablet&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;names-counts&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Names &amp;amp; Counts&lt;/h3&gt;
&lt;p&gt;So we have checked the number of devices and their names. Let us now examine their distribution
i.e. count/frequency. &lt;code&gt;table()&lt;/code&gt; and &lt;code&gt;summary()&lt;/code&gt; will display the levels and their counts while &lt;code&gt;fct_count()&lt;/code&gt;
will return a tibble with 2 columns (level &amp;amp; count). It is extremely useful for further data processing or
visualization (using ggplot2).&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;table(data$device)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Desktop  Mobile  Tablet 
##  177282   63482    3634&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fct_count(data$device)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 x 2
##   f            n
##   &amp;lt;fct&amp;gt;    &amp;lt;int&amp;gt;
## 1 Desktop 177282
## 2 Mobile   63482
## 3 Tablet    3634&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;summary(data$device)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Desktop  Mobile  Tablet 
##  177282   63482    3634&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;tables&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Tables&lt;/h2&gt;
&lt;p&gt;In the previous section, we used the &lt;code&gt;table()&lt;/code&gt; function to tabulate categorical data. We will
recreate the tabulation for device and store it in a new variable tab.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tab &amp;lt;- table(data$device)
tab&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Desktop  Mobile  Tablet 
##  177282   63482    3634&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What does this function return? It is not a &lt;code&gt;vector&lt;/code&gt;, &lt;code&gt;list&lt;/code&gt;, &lt;code&gt;data.frame&lt;/code&gt; or &lt;code&gt;matrix&lt;/code&gt;. Let us use the &lt;code&gt;class()&lt;/code&gt; function to check the class of the object returned by &lt;code&gt;table()&lt;/code&gt;. It returns an object of the class &lt;strong&gt;table&lt;/strong&gt;. This is a new type of object. Let us spend some time understanding tables as they are useful for organizing and summarizing categorical data. &lt;strong&gt;table&lt;/strong&gt; is also the most used object when it comes to dealing with categorical data.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;table()&lt;/code&gt; function returns the counts of the categories but let us say we want to view the proportion or
percentage instead of counts i.e. the proportion or percentage of traffic driven to our website by the different devices. The &lt;code&gt;proportions()&lt;/code&gt; or &lt;code&gt;prop.table()&lt;/code&gt; function comes in handy in such cases. It takes a table object as input (tab in our case).&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;prop.table(tab)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##    Desktop     Mobile     Tablet 
## 0.72538237 0.25974844 0.01486919&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;proportions(tab)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##    Desktop     Mobile     Tablet 
## 0.72538237 0.25974844 0.01486919&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To get the percentages, multiply the output by 100. Use the &lt;code&gt;round()&lt;/code&gt; function to round the decimal places
according to your requirements.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;proportions(tab) * 100&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##   Desktop    Mobile    Tablet 
## 72.538237 25.974844  1.486919&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;round(proportions(tab) * 100, 2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Desktop  Mobile  Tablet 
##   72.54   25.97    1.49&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So far, we have used &lt;code&gt;table()&lt;/code&gt; to tabulate a single categorical variable. It can be used for a lot
more than just tabulating data. We can examine the relationship between two categorical variables as well
as create multidimensional tables. Let us look at the relationship between &lt;strong&gt;gender&lt;/strong&gt; and &lt;strong&gt;device&lt;/strong&gt; in our case study. Does gender affect the type of device used? To answer this, we will create a two way or cross table. In the &lt;code&gt;table()&lt;/code&gt; function, we can specify multiple variables by separating them with a comma.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tab2 &amp;lt;- table(data$gender, data$device)
tab2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##         
##          Desktop Mobile Tablet
##   female   32803   7268    494
##   male     46418  14503    696
##   &amp;lt;NA&amp;gt;     98061  41711   2444&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Keep in mind that the order of the variables matter. Rows represent the first variable while column represents the second.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;table(data$device, data$gender)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##          
##           female  male  &amp;lt;NA&amp;gt;
##   Desktop  32803 46418 98061
##   Mobile    7268 14503 41711
##   Tablet     494   696  2444&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;proportions()&lt;/code&gt; function works with two way tables as well.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;proportions(tab2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##         
##              Desktop      Mobile      Tablet
##   female 0.134219593 0.029738378 0.002021293
##   male   0.189927904 0.059341729 0.002847814
##   &amp;lt;NA&amp;gt;   0.401234871 0.170668336 0.010000082&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;proportions(tab2) * 100&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##         
##             Desktop     Mobile     Tablet
##   female 13.4219593  2.9738378  0.2021293
##   male   18.9927904  5.9341729  0.2847814
##   &amp;lt;NA&amp;gt;   40.1234871 17.0668336  1.0000082&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We would like to introduce another function at this point of time, &lt;code&gt;margin.table()&lt;/code&gt;. What does this function do? It computes the marginal frequencies i.e. the sum of the rows or columns. It takes a &lt;strong&gt;table&lt;/strong&gt; object as input. The &lt;code&gt;margin&lt;/code&gt; argument allows us to specify whether we want the sum of rows or columns. &lt;code&gt;1&lt;/code&gt; indicates rows and &lt;code&gt;2&lt;/code&gt; indicates columns.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;margin.table(tab2, 1) # sum of rows&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## female   male   &amp;lt;NA&amp;gt; 
##  40565  61617 142216&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;margin.table(tab2, 2) # sum of columns&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Desktop  Mobile  Tablet 
##  177282   63482    3634&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If the margin argument is NULL (which it is by default), the function returns the sum of all cells of the table.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;margin.table(tab2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 244398&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;table()&lt;/code&gt; does not display row or column labels. It does display the group labels though. Let us revisit the output from &lt;code&gt;tab2&lt;/code&gt;. You can observe that while it includes the group labels, the row and column labels are missing. The output from the &lt;code&gt;dimnames()&lt;/code&gt; function shows the group labels of the variables but the row &amp;amp; column labels are absent.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dimnames(tab2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [[1]]
## [1] &amp;quot;female&amp;quot; &amp;quot;male&amp;quot;   NA      
## 
## [[2]]
## [1] &amp;quot;Desktop&amp;quot; &amp;quot;Mobile&amp;quot;  &amp;quot;Tablet&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;names(tab2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## NULL&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;names(dimnames(tab2)) &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;&amp;quot; &amp;quot;&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The output from &lt;code&gt;names(dimnames(tab2))&lt;/code&gt; is also empty. Let us add the variable names as the row &amp;amp; column
labels to &lt;code&gt;tab2&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;names(dimnames(tab2)) &amp;lt;- c(&amp;quot;Gender&amp;quot;, &amp;quot;Device&amp;quot;)
tab2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##         Device
## Gender   Desktop Mobile Tablet
##   female   32803   7268    494
##   male     46418  14503    696
##   &amp;lt;NA&amp;gt;     98061  41711   2444&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now look at the output from &lt;code&gt;tab2&lt;/code&gt; and you can observe the difference. The same is also visible when we run
&lt;code&gt;dimnames(tab2)&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dimnames(tab2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## $Gender
## [1] &amp;quot;female&amp;quot; &amp;quot;male&amp;quot;   NA      
## 
## $Device
## [1] &amp;quot;Desktop&amp;quot; &amp;quot;Mobile&amp;quot;  &amp;quot;Tablet&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To add margin totals to the table, use &lt;code&gt;addmargins()&lt;/code&gt;. Like &lt;code&gt;proportions()&lt;/code&gt; and &lt;code&gt;margin.table()&lt;/code&gt;, it also takes a &lt;code&gt;table&lt;/code&gt; object as the input.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;addmargins(tab2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##         Device
## Gender   Desktop Mobile Tablet    Sum
##   female   32803   7268    494  40565
##   male     46418  14503    696  61617
##   &amp;lt;NA&amp;gt;     98061  41711   2444 142216
##   Sum     177282  63482   3634 244398&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;rowSums()&lt;/code&gt; returns the row total while &lt;code&gt;colSums()&lt;/code&gt; returns the column total. They are similar to &lt;code&gt;margin.table()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rowSums(tab2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## female   male   &amp;lt;NA&amp;gt; 
##  40565  61617 142216&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;colSums(tab2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Desktop  Mobile  Tablet 
##  177282   63482    3634&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;xtabs()&lt;/code&gt; is another way of creating multidimensional tables in R. In comparison to &lt;code&gt;table()&lt;/code&gt;, it&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;uses &lt;code&gt;formula&lt;/code&gt; notation for input&lt;/li&gt;
&lt;li&gt;the data argument ensures variable names are referenced instead of using $ i.e. &lt;code&gt;data$variable&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;displays row &amp;amp; column labels by default&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tabx &amp;lt;- xtabs(~gender+device, data = data)
tabx&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##         device
## gender   Desktop Mobile Tablet
##   female   32803   7268    494
##   male     46418  14503    696
##   &amp;lt;NA&amp;gt;     98061  41711   2444&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The following functions work with &lt;code&gt;xtabs()&lt;/code&gt; as well&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;proportions()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;margin.table()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;addmargins()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;proportions(tabx)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##         device
## gender       Desktop      Mobile      Tablet
##   female 0.134219593 0.029738378 0.002021293
##   male   0.189927904 0.059341729 0.002847814
##   &amp;lt;NA&amp;gt;   0.401234871 0.170668336 0.010000082&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;margin.table(tabx, 1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## gender
## female   male   &amp;lt;NA&amp;gt; 
##  40565  61617 142216&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;margin.table(tabx, 2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## device
## Desktop  Mobile  Tablet 
##  177282   63482    3634&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;addmargins(tabx)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##         device
## gender   Desktop Mobile Tablet    Sum
##   female   32803   7268    494  40565
##   male     46418  14503    696  61617
##   &amp;lt;NA&amp;gt;     98061  41711   2444 142216
##   Sum     177282  63482   3634 244398&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So far, we have been working with one or two dimensional tables. Both the &lt;code&gt;table()&lt;/code&gt; and &lt;code&gt;xtabs()&lt;/code&gt; functions are capable of creating multidimensional tables. Keep in mind that multidimensional tables are complex and it becomes increasingly difficult to understand or interpret them.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tab3 &amp;lt;- xtabs(~gender+device+channel, data = data)
tab3&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## , , channel = (Other)
## 
##         device
## gender   Desktop Mobile Tablet
##   female     786    258      0
##   male      1063    507     19
##   &amp;lt;NA&amp;gt;      2173   1186     81
## 
## , , channel = Affiliates
## 
##         device
## gender   Desktop Mobile Tablet
##   female    1314     60      0
##   male      1714    169      0
##   &amp;lt;NA&amp;gt;      3518    548     65
## 
## , , channel = Direct
## 
##         device
## gender   Desktop Mobile Tablet
##   female    4785    977     59
##   male      7010   2381     95
##   &amp;lt;NA&amp;gt;     15824   8292    430
## 
## , , channel = Display
## 
##         device
## gender   Desktop Mobile Tablet
##   female     123    753    104
##   male       210    491     73
##   &amp;lt;NA&amp;gt;       554    911    156
## 
## , , channel = Organic Search
## 
##         device
## gender   Desktop Mobile Tablet
##   female   17109   4480    282
##   male     25016   9563    448
##   &amp;lt;NA&amp;gt;     54071  27223   1476
## 
## , , channel = Paid Search
## 
##         device
## gender   Desktop Mobile Tablet
##   female     645    230     22
##   male       887    478     26
##   &amp;lt;NA&amp;gt;      1274    782     51
## 
## , , channel = Referral
## 
##         device
## gender   Desktop Mobile Tablet
##   female    7387     74      0
##   male      9251    185      0
##   &amp;lt;NA&amp;gt;     18052    615     51
## 
## , , channel = Social
## 
##         device
## gender   Desktop Mobile Tablet
##   female     654    436     27
##   male      1267    729     35
##   &amp;lt;NA&amp;gt;      2595   2154    134&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;ftable&lt;/strong&gt; stands for flat tables and is useful for printing attractive tables. It makes it easy to read and interpret multidimensional tables. In the next example, we will use &lt;code&gt;ftable()&lt;/code&gt; to print the tables we have created in the previous examples and compare the outputs.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ftable(tabx)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##        device Desktop Mobile Tablet
## gender                             
## female          32803   7268    494
## male            46418  14503    696
## NA              98061  41711   2444&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ftable(tab2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##        Device Desktop Mobile Tablet
## Gender                             
## female          32803   7268    494
## male            46418  14503    696
## NA              98061  41711   2444&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ftable(tab3)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                channel (Other) Affiliates Direct Display Organic Search Paid Search Referral Social
## gender device                                                                                      
## female Desktop             786       1314   4785     123          17109         645     7387    654
##        Mobile              258         60    977     753           4480         230       74    436
##        Tablet                0          0     59     104            282          22        0     27
## male   Desktop            1063       1714   7010     210          25016         887     9251   1267
##        Mobile              507        169   2381     491           9563         478      185    729
##        Tablet               19          0     95      73            448          26        0     35
## NA     Desktop            2173       3518  15824     554          54071        1274    18052   2595
##        Mobile             1186        548   8292     911          27223         782      615   2154
##        Tablet               81         65    430     156           1476          51       51    134&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;By default, missing values (NAs) are excluded from tables. Let us modify the gender data from our case study a bit and see how the &lt;code&gt;table()&lt;/code&gt; function deals with missing values. We won’t explicitly specify &lt;code&gt;NA&lt;/code&gt; as a level while recreating the gender data.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;gen &amp;lt;- as.factor(as.character(data$gender))
table(gen)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## gen
## female   male 
##  40565  61617&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, &lt;code&gt;table()&lt;/code&gt; excludes missing values while tabulating the data. In order to ensure that missing
values are also counted, we can use the &lt;code&gt;useNA&lt;/code&gt; argument. It can take two values:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;ifany&lt;/li&gt;
&lt;li&gt;always&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the first case, it will show &lt;code&gt;NA&lt;/code&gt; as a level and the count only if there are missing values in the data. In the second case, it will always show &lt;code&gt;NA&lt;/code&gt; as a level irrespective of whether there are missing values in the data or not.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;table(gen, useNA = &amp;quot;ifany&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## gen
## female   male   &amp;lt;NA&amp;gt; 
##  40565  61617 142216&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;table(data$device, useNA = &amp;quot;always&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Desktop  Mobile  Tablet    &amp;lt;NA&amp;gt; 
##  177282   63482    3634       0&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In this final section on tables, we will learn how to select/access the different parts of a &lt;code&gt;table&lt;/code&gt;. We will use &lt;code&gt;[&lt;/code&gt; operator to select rows and columns of a table (it is similar to selecting data from a
&lt;code&gt;data.frame&lt;/code&gt;). Below are a few examples:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;select first row&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tab2[1, ]           &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Desktop  Mobile  Tablet 
##   32803    7268     494&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;select first column&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tab2[, 1]           &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## female   male   &amp;lt;NA&amp;gt; 
##  32803  46418  98061&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;select first two rows&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tab2[1:2, ]         &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##         Device
## Gender   Desktop Mobile Tablet
##   female   32803   7268    494
##   male     46418  14503    696&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;select first two columns&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tab2[, 1:2]        &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##         Device
## Gender   Desktop Mobile
##   female   32803   7268
##   male     46418  14503
##   &amp;lt;NA&amp;gt;     98061  41711&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;select nth row&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tab2[2, ]          &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Desktop  Mobile  Tablet 
##   46418   14503     696&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;select nth column&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tab2[, 2]          &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## female   male   &amp;lt;NA&amp;gt; 
##   7268  14503  41711&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;select row by group label&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tab2[&amp;quot;female&amp;quot;, ]   &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Desktop  Mobile  Tablet 
##   32803    7268     494&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;select column by group label&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tab2[, &amp;quot;Mobile&amp;quot;]   &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## female   male   &amp;lt;NA&amp;gt; 
##   7268  14503  41711&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Before we end this section, let us learn how to test if an object is of class table using &lt;code&gt;is.table()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;is.table(tab2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next, we will look at different R packages for two way/contingency tables.&lt;/p&gt;
&lt;div id=&#34;contingency-table&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Contingency Table&lt;/h3&gt;
&lt;p&gt;For cross tables with output similar to SAS or SPSS, use any of the below:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;CrossTable()&lt;/code&gt; from the &lt;a href=&#34;cran.r-project.org/package=gmodels&#34;&gt;gmodels&lt;/a&gt; package&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ds_cross_table()&lt;/code&gt; from the &lt;a href=&#34;https://descriptr.rsquaredacademy.com&#34;&gt;descriptr&lt;/a&gt; package&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;gmodels::CrossTable(data$device, data$gender)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  102182 
## 
##  
##              | data$gender 
##  data$device |    female |      male | Row Total | 
## -------------|-----------|-----------|-----------|
##      Desktop |     32803 |     46418 |     79221 | 
##              |    58.228 |    38.334 |           | 
##              |     0.414 |     0.586 |     0.775 | 
##              |     0.809 |     0.753 |           | 
##              |     0.321 |     0.454 |           | 
## -------------|-----------|-----------|-----------|
##       Mobile |      7268 |     14503 |     21771 | 
##              |   218.694 |   143.975 |           | 
##              |     0.334 |     0.666 |     0.213 | 
##              |     0.179 |     0.235 |           | 
##              |     0.071 |     0.142 |           | 
## -------------|-----------|-----------|-----------|
##       Tablet |       494 |       696 |      1190 | 
##              |     0.986 |     0.649 |           | 
##              |     0.415 |     0.585 |     0.012 | 
##              |     0.012 |     0.011 |           | 
##              |     0.005 |     0.007 |           | 
## -------------|-----------|-----------|-----------|
## Column Total |     40565 |     61617 |    102182 | 
##              |     0.397 |     0.603 |           | 
## -------------|-----------|-----------|-----------|
## 
## &lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;descriptr::ds_cross_table(data, device, gender)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##     Cell Contents
##  |---------------|
##  |     Frequency |
##  |       Percent |
##  |       Row Pct |
##  |       Col Pct |
##  |---------------|
## 
##  Total Observations:  244398 
## 
## ----------------------------------------------------------------------------
## |              |                          gender                           |
## ----------------------------------------------------------------------------
## |       device |       female |         male |           NA |    Row Total |
## ----------------------------------------------------------------------------
## |      Desktop |        32803 |        46418 |        98061 |       177282 |
## |              |        0.134 |         0.19 |        0.401 |              |
## |              |         0.19 |         0.26 |         0.55 |         0.73 |
## |              |         0.81 |         0.75 |         0.69 |              |
## ----------------------------------------------------------------------------
## |       Mobile |         7268 |        14503 |        41711 |        63482 |
## |              |         0.03 |        0.059 |        0.171 |              |
## |              |         0.11 |         0.23 |         0.66 |         0.26 |
## |              |         0.18 |         0.24 |         0.29 |              |
## ----------------------------------------------------------------------------
## |       Tablet |          494 |          696 |         2444 |         3634 |
## |              |        0.002 |        0.003 |         0.01 |              |
## |              |         0.14 |         0.19 |         0.67 |         0.01 |
## |              |         0.01 |         0.01 |         0.02 |              |
## ----------------------------------------------------------------------------
## | Column Total |        40565 |        61617 |       142216 |       244398 |
## |              |        0.166 |        0.252 |        0.582 |              |
## ----------------------------------------------------------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We list and explore different R packages for summarizing categorical data in our GitHub repository.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;key-functions&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Key Functions&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_module_4_functions.png&#34; width=&#34;70%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;practice&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Your Turn…&lt;/h2&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;p&gt;Display the number of levels in&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;browser&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;channel&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;landing_page&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;exit_page&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Display the categories in&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;os&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;channel&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;browser&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;gender&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;user_type&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Display the count/frequency of&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;channel&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;user_type&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Examine the distribution of the following and summarize your observations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;channel&lt;/code&gt; by &lt;code&gt;user_type&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;device&lt;/code&gt; by &lt;code&gt;purchase_flag&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;channel&lt;/code&gt; by &lt;code&gt;device&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;channel&lt;/code&gt; by &lt;code&gt;purchase_flag&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;user_type&lt;/code&gt; by &lt;code&gt;purchase_flag&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;*As the reader of this blog, you are our most important critic and commentator.
We value your opinion and want to know what we are doing right, what we could
do better, what areas you would like to see us publish in, and any other words
of wisdom you are willing to pass our way.&lt;/p&gt;
&lt;p&gt;We welcome your comments. You can email to let us know what you did or did not
like about our blog as well as what we can do to make our post better.*&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Email: &lt;a href=&#34;mailto:support@rsquaredacademy.com&#34; class=&#34;email&#34;&gt;support@rsquaredacademy.com&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Handling Categorical Data in R - Part 1</title>
      <link>https://blog.rsquaredacademy.com/handling-categorical-data-in-r-part-1/</link>
      <pubDate>Fri, 07 Jan 2022 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/handling-categorical-data-in-r-part-1/</guid>
      <description>&lt;script src=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/header-attrs/header-attrs.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/kePrint/kePrint.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/lightable/lightable.css&#34; rel=&#34;stylesheet&#34; /&gt;


&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/forcats-part-1.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;This is part 1 of a series on “Handling Categorical Data in R.” Almost every data science project involves working with categorical data, and we should know how to &lt;strong&gt;read&lt;/strong&gt;, &lt;strong&gt;store&lt;/strong&gt;, &lt;strong&gt;summarize&lt;/strong&gt;, &lt;strong&gt;reshape&lt;/strong&gt; &amp;amp; &lt;strong&gt;visualize&lt;/strong&gt; such data. Working with categorical data is different from working with other data types such as numbers or text. In this article, we will understand what categorical data is, how R stores it using &lt;strong&gt;factor&lt;/strong&gt;, and explore the rich set of functions (built-in &amp;amp; through packages) provided by R for working with such data. Throughout the series, we will also &lt;strong&gt;work through a case study&lt;/strong&gt; to better understand the concepts we learn. Happy learning!&lt;/p&gt;
&lt;p&gt;Below are the links to the other articles of this series:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://blog.rsquaredacademy.com/handling-categorical-data-in-r-part-2/&#34;&gt;Part 2 - Summarize Categorical Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://blog.rsquaredacademy.com/handling-categorical-data-in-r-part-3/&#34;&gt;Part 3 - Reshape Categorical Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://blog.rsquaredacademy.com/handling-categorical-data-in-r-part-4/&#34;&gt;Part 4 - Visualize Categorical Data&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;table-of-contents&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Table of Contents&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#resources&#34;&gt;Resources&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#intro&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#casestudy&#34;&gt;Case Study&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#factors&#34;&gt;Factors&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;resources&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Resources&lt;/h2&gt;
&lt;p&gt;You can download all the data sets, R scripts, practice questions and their solutions from our &lt;a href=&#34;https://github.com/rsquaredacademy-education/online-courses/&#34;&gt;GitHub&lt;/a&gt; repository.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;intro&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;Before we begin our deep dive on categorical data, let us get a quick overview of different data types. Feel free to skip this section if you know the difference between nominal and ordinal data.&lt;/p&gt;
&lt;div id=&#34;data-types&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data Types&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_data_types.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In the chart above, we can see that data can be primarily classified into &lt;strong&gt;qualitative&lt;/strong&gt; or &lt;strong&gt;quantitative&lt;/strong&gt;. (&lt;strong&gt;The word categorical is used interchangeably with qualitative throughout the series&lt;/strong&gt;). Qualitative data consists of labels or names. Quantitative data, on the other hand, consists of numbers and indicate how much or how many. This brings us to the next level of classification:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;discrete&lt;/li&gt;
&lt;li&gt;continuous&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the chart, we can observe that qualitative data is always &lt;strong&gt;discrete&lt;/strong&gt; where as quantitative data may be &lt;strong&gt;discrete&lt;/strong&gt; or &lt;strong&gt;continuous&lt;/strong&gt;. Qualitative data is further classified into&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;nominal&lt;/li&gt;
&lt;li&gt;ordinal&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;First, we will understand discrete and continuous data, and then proceed to explore nominal and ordinal data.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Discrete Data&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_discrete.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Discrete data arises in situations where counting is involved. It can take on only a finite number of values and cannot be divided into smaller parts. For example, let us consider the number of students in a class. We can have 5 0r 10 students but not 5.5 students (we can’t have half a student).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Continuous Data&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_measure.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Continuous data arises in situations where measuring is involved. It can take any numeric value in a specified range and can be divided into smaller parts and still have meaning. Examples include money, temperature, length, volume etc.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;categorical-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Categorical Data&lt;/h3&gt;
&lt;p&gt;Since our interest is in categorical data, we will spend more time understanding the different types of categorical data through various examples. Let us begin by formally defining categorical data:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;it is always discrete&lt;/li&gt;
&lt;li&gt;it may be divided into groups&lt;/li&gt;
&lt;li&gt;consists of names or labels&lt;/li&gt;
&lt;li&gt;takes on limited &amp;amp; fixed number of possible values&lt;/li&gt;
&lt;li&gt;arises in situation when counting is involved&lt;/li&gt;
&lt;li&gt;analysis generally involves the use of data tables&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;dichotomous&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Dichotomous&lt;/h3&gt;
&lt;p&gt;A categorical variable that can take on exactly two values is termed as &lt;strong&gt;binary&lt;/strong&gt; or &lt;strong&gt;dichotomous&lt;/strong&gt; variable.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_yes_no.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;polychotomous&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Polychotomous&lt;/h3&gt;
&lt;p&gt;Categorical variables with more than two possible values are called &lt;strong&gt;polychotomous&lt;/strong&gt; variables.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_yes_no_maybe.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;ordinal&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Ordinal&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_satisfaction_rating.jpg&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In ordinal data, the categories can be ordered or ranked. Examples include&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;socio-economic status&lt;/li&gt;
&lt;li&gt;education level&lt;/li&gt;
&lt;li&gt;income level&lt;/li&gt;
&lt;li&gt;satisfaction rating&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;While we can rank the categories, we cannot assign a value to them. For example, in satisfaction ranking, we cannot say that like is twice as positive as dislike i.e. we are unable to say how much they differ from each other.
While the order or rank of data is meaningful, the difference between two pieces of data cannot be measured/determined or are meaningless. Ordinal data provide information about relative comparisons, but not the magnitude of the differences.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;nominal&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Nominal&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_transportation_mode.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Nominal data do not have an intrinsic order and cannot be ordered or measured. Examples include&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;blood group&lt;/li&gt;
&lt;li&gt;gender&lt;/li&gt;
&lt;li&gt;religion&lt;/li&gt;
&lt;li&gt;color&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Categorical data are sometimes coded with numbers, with those numbers replacing names. Although such numbers might appear to be quantitative, they are actually categorical data. When they do take numerical values, those numbers do not have any mathematical meaning. Examples include months expressed in numbers.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;casestudy&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Case Study&lt;/h2&gt;
&lt;p&gt;As is the practice, throughout this series, we will work on a case study related to an e-commerce firm. As most of you would already be aware, a lot of data is captured when you go on the internet by the websites you browse as well as by third party cookies. Data collected is then used to display ads as well as to feed to recommendation algorithms.&lt;/p&gt;
&lt;p&gt;The data used in the case study represents the basic information that is captured when users visit any
website. It closely resembles real world data for an e-commerce store. We will try to generate insights
about the visitors to be used by an imaginary marketing team for better targeting and promotion. The case study data set can be imported using the RStudio IDE or R code.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_web_analytics.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data&lt;/h3&gt;
&lt;p&gt;The data set is available in both &lt;strong&gt;CSV&lt;/strong&gt; &amp;amp; &lt;strong&gt;RDS&lt;/strong&gt; formats.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;CSV&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If you want to specify the data types while reading the data, use the &lt;a href=&#34;https://readr.tidyverse.org/&#34;&gt;readr&lt;/a&gt; package. We have explored how to import data into R in a previous &lt;a href=&#34;https://blog.rsquaredacademy.com/import-data-into-r-part-1/&#34;&gt;article&lt;/a&gt;. We will read a subset of columns from the data set (it has 20 columns) which will cover both nominal and ordinal data types. To import the data, we will use the &lt;code&gt;read_csv()&lt;/code&gt; function. The first input is the name of the data set, &lt;code&gt;analytics.csv&lt;/code&gt;. Ensure that the name is enclosed in single/double quotes.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;read_csv(&amp;quot;analytics_raw.csv&amp;quot;, 
         col_types = cols_only(device = col_factor(levels = c(&amp;quot;Desktop&amp;quot;, &amp;quot;Tablet&amp;quot;, &amp;quot;Mobile&amp;quot;)), 
                               gender = col_factor(levels = c(&amp;quot;female&amp;quot;, &amp;quot;male&amp;quot;, &amp;quot;NA&amp;quot;)), 
                               user_rating = col_factor(levels = c(&amp;quot;1&amp;quot;, &amp;quot;2&amp;quot;, &amp;quot;3&amp;quot;, &amp;quot;4&amp;quot;, &amp;quot;5&amp;quot;),
                                                        ordered = TRUE)))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## New names:
## * `` -&amp;gt; ...1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 244,398 x 3
##    device  gender user_rating
##    &amp;lt;fct&amp;gt;   &amp;lt;fct&amp;gt;  &amp;lt;ord&amp;gt;      
##  1 Desktop female 4          
##  2 Mobile  NA     5          
##  3 Desktop NA     4          
##  4 Desktop NA     5          
##  5 Desktop NA     4          
##  6 Mobile  NA     4          
##  7 Desktop NA     4          
##  8 Desktop NA     4          
##  9 Desktop female 5          
## 10 Desktop NA     4          
## # ... with 244,388 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Since we are specifying the column data types while importing the data, we will use the &lt;code&gt;col_types&lt;/code&gt;
argument to list out the data types. As we are reading in a subset of the columns and not all of them,
we will use the &lt;code&gt;cols_only()&lt;/code&gt; function indicating that only the columns specified must be read in and not
all of them.&lt;/p&gt;
&lt;p&gt;Categorical data and the levels/groups are specified using the &lt;code&gt;col_factor()&lt;/code&gt; function. Use the
&lt;code&gt;levels&lt;/code&gt; argument to specify the levels/groups and the &lt;code&gt;ordered&lt;/code&gt; argument to indicate if the data is ordinal. By default, it is set to &lt;code&gt;FALSE&lt;/code&gt;, change this to &lt;code&gt;TRUE&lt;/code&gt; if the column is ordinal.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;RDS&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;.rds&lt;/code&gt; file can be read using &lt;code&gt;readRDS()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;data &amp;lt;- readRDS(&amp;#39;analytics.rds&amp;#39;)
head(data)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 6 x 19
##   device  os        browser user_type channel gender frequency recency page_depth
##   &amp;lt;fct&amp;gt;   &amp;lt;fct&amp;gt;     &amp;lt;fct&amp;gt;   &amp;lt;fct&amp;gt;     &amp;lt;fct&amp;gt;   &amp;lt;fct&amp;gt;      &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;      &amp;lt;dbl&amp;gt;
## 1 Desktop Windows   Chrome  New Visi~ Organi~ female         1       0          1
## 2 Mobile  iOS       Safari  Returnin~ Organi~ &amp;lt;NA&amp;gt;           3       1          1
## 3 Desktop Chrome OS Chrome  New Visi~ Direct  &amp;lt;NA&amp;gt;           1       0          5
## 4 Desktop Macintosh Chrome  Returnin~ Organi~ &amp;lt;NA&amp;gt;           2       0          1
## 5 Desktop Macintosh Chrome  Returnin~ Referr~ &amp;lt;NA&amp;gt;           5       8          1
## 6 Mobile  Android   Chrome  New Visi~ Organi~ &amp;lt;NA&amp;gt;           1       0          5
## # ... with 10 more variables: hour_of_day &amp;lt;chr&amp;gt;, age &amp;lt;dbl&amp;gt;, duration &amp;lt;dbl&amp;gt;,
## #   landing_page &amp;lt;fct&amp;gt;, exit_page &amp;lt;fct&amp;gt;, country &amp;lt;fct&amp;gt;, quantity &amp;lt;dbl&amp;gt;,
## #   revenue &amp;lt;dbl&amp;gt;, purchase_flag &amp;lt;lgl&amp;gt;, user_rating &amp;lt;dbl&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;data-dictionary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data Dictionary&lt;/h3&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Column
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
device
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Device used to browse the website
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
os
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Operating system of the device
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
browser
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Browser used to visit the website
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
user_type
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
New or returning visitor
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
channel
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Source of traffic
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
gender
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Gender of the visitor
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
frequency
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Count of visits to the website
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
recency
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Number of days since last visit
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
page_depth
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Number of website pages browsed
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
hour_of_day
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Hour of day
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
age
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Age of the visitor
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
duration
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Time spent on the website (in seconds)
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
landing_page
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Page on which visitor landed
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
exit_page
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Page on which visitor exited
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
country
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Country of origin
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
city
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
City of the visitor
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
quantity
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Number of units purchased
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
revenue
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Total revenue
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
purchase_flag
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Whether the visitor checked out?
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
user_rating
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Website UI rating given by visitor
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Now that we have an overview of the case study, let us move on to the next section where we explore how R stores categorical data using factors.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;factors&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Factors&lt;/h2&gt;
&lt;p&gt;In this very important section, we will learn how R&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;stores categorical data&lt;/li&gt;
&lt;li&gt;checks if given data is categorical&lt;/li&gt;
&lt;li&gt;converts other data types to factor&lt;/li&gt;
&lt;li&gt;handles missing values in categorical data&lt;/li&gt;
&lt;li&gt;specifies the orders of the categories/levels&lt;/li&gt;
&lt;li&gt;stores ordinal data&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In R, categorical data is stored as &lt;code&gt;factor&lt;/code&gt;. Before we explore the &lt;code&gt;factor&lt;/code&gt; family of functions, let us generate the sample data we will use in this module. We will generate the &lt;code&gt;device&lt;/code&gt; column from the case study data set using the &lt;code&gt;sample()&lt;/code&gt; function. We provide the following inputs to generate the data:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;values from which the data must be generated&lt;/li&gt;
&lt;li&gt;the size of the sample&lt;/li&gt;
&lt;li&gt;indicate if the values must be repeated (TRUE/FALSE)&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;device &amp;lt;- sample(c(&amp;quot;Desktop&amp;quot;, &amp;quot;Mobile&amp;quot;, &amp;quot;Tablet&amp;quot;), size = 25, replace = TRUE)
device&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;Mobile&amp;quot;  &amp;quot;Mobile&amp;quot;  &amp;quot;Tablet&amp;quot;  &amp;quot;Mobile&amp;quot;  &amp;quot;Mobile&amp;quot;  &amp;quot;Mobile&amp;quot;  &amp;quot;Tablet&amp;quot; 
##  [8] &amp;quot;Tablet&amp;quot;  &amp;quot;Desktop&amp;quot; &amp;quot;Mobile&amp;quot;  &amp;quot;Mobile&amp;quot;  &amp;quot;Mobile&amp;quot;  &amp;quot;Tablet&amp;quot;  &amp;quot;Mobile&amp;quot; 
## [15] &amp;quot;Desktop&amp;quot; &amp;quot;Tablet&amp;quot;  &amp;quot;Desktop&amp;quot; &amp;quot;Mobile&amp;quot;  &amp;quot;Mobile&amp;quot;  &amp;quot;Tablet&amp;quot;  &amp;quot;Desktop&amp;quot;
## [22] &amp;quot;Mobile&amp;quot;  &amp;quot;Tablet&amp;quot;  &amp;quot;Mobile&amp;quot;  &amp;quot;Mobile&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;membership-testing&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Membership Testing&lt;/h3&gt;
&lt;p&gt;Great! We have successfully generated the sample data and along the way learnt a new R function for sampling. First, let us check if the sample is a &lt;code&gt;factor&lt;/code&gt; using the membership function &lt;code&gt;is.factor()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;is.factor(device)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Membership testing functions always have the prefix &lt;code&gt;is_&lt;/code&gt; and return only logical values. If the object is a member of the specified class, they return &lt;code&gt;TRUE&lt;/code&gt; else &lt;code&gt;FALSE&lt;/code&gt;. Since our sample data is not stored as a factor, R has returned &lt;code&gt;FALSE&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;coercion&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Coercion&lt;/h3&gt;
&lt;p&gt;Let us try to coerce it into &lt;code&gt;factor&lt;/code&gt; using the coercion function &lt;code&gt;as.factor()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;as.factor(device)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] Mobile  Mobile  Tablet  Mobile  Mobile  Mobile  Tablet  Tablet  Desktop
## [10] Mobile  Mobile  Mobile  Tablet  Mobile  Desktop Tablet  Desktop Mobile 
## [19] Mobile  Tablet  Desktop Mobile  Tablet  Mobile  Mobile 
## Levels: Desktop Mobile Tablet&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Do you spot any difference in the output? In the last line, it displays the levels or categories of the variable. Don’t worry if you didn’t spot it. We are just getting started and you will pick it up by the end of this section. Another function that can be used to coerce data into factor is &lt;code&gt;as_factor()&lt;/code&gt; from the &lt;a href=&#34;https://forcats.tidyverse.org/&#34;&gt;forcats&lt;/a&gt; package.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;as_factor(device)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] Mobile  Mobile  Tablet  Mobile  Mobile  Mobile  Tablet  Tablet  Desktop
## [10] Mobile  Mobile  Mobile  Tablet  Mobile  Desktop Tablet  Desktop Mobile 
## [19] Mobile  Tablet  Desktop Mobile  Tablet  Mobile  Mobile 
## Levels: Mobile Tablet Desktop&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Did you notice any difference between these two functions? Focus on the last line of the output where the
levels are displayed. Now observe the order of the levels. &lt;code&gt;as.factor()&lt;/code&gt; displays levels in the alphabetical order whereas &lt;code&gt;as_factor()&lt;/code&gt; displays them in order of appearance in the data. &lt;strong&gt;Mobile&lt;/strong&gt;, followed by &lt;strong&gt;Tablet&lt;/strong&gt;, and then &lt;strong&gt;Desktop&lt;/strong&gt;. If you look at the data, they appear in the same order.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;factor-function&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Factor Function&lt;/h3&gt;
&lt;p&gt;If you want finer control while creating factors, use the &lt;code&gt;factor()&lt;/code&gt; function. &lt;code&gt;as.factor()&lt;/code&gt; should suffice in most cases but use &lt;code&gt;factor()&lt;/code&gt; when you want to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;specify levels&lt;/li&gt;
&lt;li&gt;modify labels&lt;/li&gt;
&lt;li&gt;include &lt;code&gt;NA&lt;/code&gt; as a level/category&lt;/li&gt;
&lt;li&gt;create ordered factors&lt;/li&gt;
&lt;li&gt;specify order of levels&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The first input is a vector, usually a numeric or character vector with a small number of unique values. In our example, it is a character vector of length 25 (i.e. 25 values) but 3 unique values.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;factor(device)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] Mobile  Mobile  Tablet  Mobile  Mobile  Mobile  Tablet  Tablet  Desktop
## [10] Mobile  Mobile  Mobile  Tablet  Mobile  Desktop Tablet  Desktop Mobile 
## [19] Mobile  Tablet  Desktop Mobile  Tablet  Mobile  Mobile 
## Levels: Desktop Mobile Tablet&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you want to specify the levels or categories, use the &lt;code&gt;levels&lt;/code&gt; argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;factor(device, levels = c(&amp;quot;Desktop&amp;quot;, &amp;quot;Mobile&amp;quot;, &amp;quot;Tablet&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] Mobile  Mobile  Tablet  Mobile  Mobile  Mobile  Tablet  Tablet  Desktop
## [10] Mobile  Mobile  Mobile  Tablet  Mobile  Desktop Tablet  Desktop Mobile 
## [19] Mobile  Tablet  Desktop Mobile  Tablet  Mobile  Mobile 
## Levels: Desktop Mobile Tablet&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Levels not specified will be replaced by &lt;code&gt;NA&lt;/code&gt;. Let us specify only &lt;strong&gt;Desktop&lt;/strong&gt; and &lt;strong&gt;Mobile&lt;/strong&gt; as the levels in the device column and see what happens.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;factor(device, levels = c(&amp;quot;Desktop&amp;quot;, &amp;quot;Mobile&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] Mobile  Mobile  &amp;lt;NA&amp;gt;    Mobile  Mobile  Mobile  &amp;lt;NA&amp;gt;    &amp;lt;NA&amp;gt;    Desktop
## [10] Mobile  Mobile  Mobile  &amp;lt;NA&amp;gt;    Mobile  Desktop &amp;lt;NA&amp;gt;    Desktop Mobile 
## [19] Mobile  &amp;lt;NA&amp;gt;    Desktop Mobile  &amp;lt;NA&amp;gt;    Mobile  Mobile 
## Levels: Desktop Mobile&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, &lt;strong&gt;Tablet&lt;/strong&gt; has been replaced by &lt;code&gt;NA&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;modify-labels&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Modify Labels&lt;/h3&gt;
&lt;p&gt;You can change the labels of the levels using the &lt;code&gt;labels&lt;/code&gt; argument. The labels must be in the same order as the levels. We will modify the labels to &lt;strong&gt;Desk&lt;/strong&gt;, &lt;strong&gt;Mob&lt;/strong&gt; &amp;amp; &lt;strong&gt;Tab&lt;/strong&gt; for &lt;strong&gt;Desktop&lt;/strong&gt;, &lt;strong&gt;Mobile&lt;/strong&gt; &amp;amp; &lt;strong&gt;Tablet&lt;/strong&gt; respectively.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;factor(device, 
       levels = c(&amp;quot;Desktop&amp;quot;, &amp;quot;Mobile&amp;quot;, &amp;quot;Tablet&amp;quot;),
       labels = c(&amp;quot;Desk&amp;quot;, &amp;quot;Mob&amp;quot;, &amp;quot;Tab&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] Mob  Mob  Tab  Mob  Mob  Mob  Tab  Tab  Desk Mob  Mob  Mob  Tab  Mob  Desk
## [16] Tab  Desk Mob  Mob  Tab  Desk Mob  Tab  Mob  Mob 
## Levels: Desk Mob Tab&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can see that not only the values but the levels are also modified.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;missing-values&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Missing Values&lt;/h3&gt;
&lt;p&gt;Let us regenerate the device column but include some missing values (&lt;code&gt;NA&lt;/code&gt;) deliberately to see how &lt;code&gt;factor()&lt;/code&gt; handles them.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# sample with missing values
device &amp;lt;- sample(c(&amp;quot;Desktop&amp;quot;, &amp;quot;Mobile&amp;quot;, &amp;quot;Tablet&amp;quot;, NA), size = 25, replace = TRUE)
device&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;Desktop&amp;quot; &amp;quot;Tablet&amp;quot;  &amp;quot;Tablet&amp;quot;  NA        &amp;quot;Mobile&amp;quot;  NA        &amp;quot;Desktop&amp;quot;
##  [8] &amp;quot;Desktop&amp;quot; &amp;quot;Tablet&amp;quot;  &amp;quot;Mobile&amp;quot;  &amp;quot;Tablet&amp;quot;  &amp;quot;Desktop&amp;quot; &amp;quot;Desktop&amp;quot; &amp;quot;Mobile&amp;quot; 
## [15] NA        &amp;quot;Desktop&amp;quot; &amp;quot;Mobile&amp;quot;  &amp;quot;Tablet&amp;quot;  &amp;quot;Mobile&amp;quot;  &amp;quot;Mobile&amp;quot;  &amp;quot;Tablet&amp;quot; 
## [22] NA        &amp;quot;Desktop&amp;quot; &amp;quot;Tablet&amp;quot;  &amp;quot;Mobile&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# store as categorical data
factor(device)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] Desktop Tablet  Tablet  &amp;lt;NA&amp;gt;    Mobile  &amp;lt;NA&amp;gt;    Desktop Desktop Tablet 
## [10] Mobile  Tablet  Desktop Desktop Mobile  &amp;lt;NA&amp;gt;    Desktop Mobile  Tablet 
## [19] Mobile  Mobile  Tablet  &amp;lt;NA&amp;gt;    Desktop Tablet  Mobile 
## Levels: Desktop Mobile Tablet&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;NA&lt;/code&gt; is not shown as one of the levels. Why does this happen? By default, it will ignore them. If you look
at the arguments of the &lt;code&gt;factor()&lt;/code&gt; function, the &lt;code&gt;exclude&lt;/code&gt; argument is set to &lt;code&gt;NA&lt;/code&gt; by default i.e. &lt;code&gt;NA&lt;/code&gt; is excluded automatically. What should we do to ensure that &lt;code&gt;NA&lt;/code&gt; is also treated as a level? In order to treat &lt;code&gt;NA&lt;/code&gt; as a level, set the &lt;code&gt;exclude&lt;/code&gt; argument to &lt;code&gt;NULL&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;factor(device, exclude = NULL)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] Desktop Tablet  Tablet  &amp;lt;NA&amp;gt;    Mobile  &amp;lt;NA&amp;gt;    Desktop Desktop Tablet 
## [10] Mobile  Tablet  Desktop Desktop Mobile  &amp;lt;NA&amp;gt;    Desktop Mobile  Tablet 
## [19] Mobile  Mobile  Tablet  &amp;lt;NA&amp;gt;    Desktop Tablet  Mobile 
## Levels: Desktop Mobile Tablet &amp;lt;NA&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, &lt;code&gt;NA&lt;/code&gt; is displayed as one of the levels in the data.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;ordered-factors&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Ordered Factors&lt;/h3&gt;
&lt;p&gt;So far, we have been looking at nominal data. Let us now explore how R handles ordered data. We will generate a new data set of satisfaction ratings to use in this section. Satisfaction ratings are
widely used to measure a customer’s satisfaction with an organization, service or a product.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rating &amp;lt;- sample(c(&amp;quot;Dislike&amp;quot;, &amp;quot;Neutral&amp;quot;, &amp;quot;Like&amp;quot;), size = 25, replace = TRUE)
rating&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;Like&amp;quot;    &amp;quot;Dislike&amp;quot; &amp;quot;Neutral&amp;quot; &amp;quot;Dislike&amp;quot; &amp;quot;Neutral&amp;quot; &amp;quot;Like&amp;quot;    &amp;quot;Neutral&amp;quot;
##  [8] &amp;quot;Dislike&amp;quot; &amp;quot;Dislike&amp;quot; &amp;quot;Dislike&amp;quot; &amp;quot;Dislike&amp;quot; &amp;quot;Neutral&amp;quot; &amp;quot;Dislike&amp;quot; &amp;quot;Neutral&amp;quot;
## [15] &amp;quot;Dislike&amp;quot; &amp;quot;Dislike&amp;quot; &amp;quot;Like&amp;quot;    &amp;quot;Neutral&amp;quot; &amp;quot;Dislike&amp;quot; &amp;quot;Neutral&amp;quot; &amp;quot;Like&amp;quot;   
## [22] &amp;quot;Neutral&amp;quot; &amp;quot;Dislike&amp;quot; &amp;quot;Like&amp;quot;    &amp;quot;Dislike&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It consists of three values Dislike, Neutral &amp;amp; Like in that order. You can see that there is an intrinsic order here. Like is better than neutral which in turn is better than dislike. While we can order them, we can’t quantify the difference between them. We can’t say neutral is so many times better than dislike.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Membership Testing&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;As we did earlier, let us check if the data is ordered using the membership function &lt;code&gt;is.ordered()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;is.ordered(rating)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;R returns &lt;code&gt;FALSE&lt;/code&gt; as the variable &lt;code&gt;rating&lt;/code&gt; is not ordered. Let us use &lt;code&gt;as.ordered()&lt;/code&gt; to coerce it into an ordered factor.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;as.ordered(rating)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] Like    Dislike Neutral Dislike Neutral Like    Neutral Dislike Dislike
## [10] Dislike Dislike Neutral Dislike Neutral Dislike Dislike Like    Neutral
## [19] Dislike Neutral Like    Neutral Dislike Like    Dislike
## Levels: Dislike &amp;lt; Like &amp;lt; Neutral&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Look at the last line where the levels are displayed. In case of ordered factors, you will see a &lt;code&gt;&amp;lt;&lt;/code&gt; between the labels. This is used to indicate the order of the levels. Now &lt;code&gt;rating&lt;/code&gt; is both an ordered but the order of the levels is not correct. It should be &lt;code&gt;Dislike &amp;lt; Neutral &amp;lt; Like&lt;/code&gt; but is displayed in order of appearance in the data. Let us use the &lt;code&gt;factor()&lt;/code&gt; function since we need more control over how the levels are ranked and set the &lt;code&gt;ordered&lt;/code&gt; argument to &lt;code&gt;TRUE&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;factor(rating, ordered = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] Like    Dislike Neutral Dislike Neutral Like    Neutral Dislike Dislike
## [10] Dislike Dislike Neutral Dislike Neutral Dislike Dislike Like    Neutral
## [19] Dislike Neutral Like    Neutral Dislike Like    Dislike
## Levels: Dislike &amp;lt; Like &amp;lt; Neutral&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The ranking of the levels has not changed and is still the same. Why is this happening? If you observe carefully, the ranking follows the alphabetical order (&lt;strong&gt;D&lt;/strong&gt;esktop, &lt;strong&gt;M&lt;/strong&gt;obile, &lt;strong&gt;T&lt;/strong&gt;able). The &lt;code&gt;factor()&lt;/code&gt; function uses the same order for the levels.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;modify-order-of-levels&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Modify Order of Levels&lt;/h3&gt;
&lt;p&gt;To change the order/ranking of the levels, we need to specify it using the &lt;code&gt;levels&lt;/code&gt; argument. Let us do that in the next example.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;factor(rating, levels = c(&amp;quot;Dislike&amp;quot;, &amp;quot;Neutral&amp;quot;, &amp;quot;Like&amp;quot;), ordered = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] Like    Dislike Neutral Dislike Neutral Like    Neutral Dislike Dislike
## [10] Dislike Dislike Neutral Dislike Neutral Dislike Dislike Like    Neutral
## [19] Dislike Neutral Like    Neutral Dislike Like    Dislike
## Levels: Dislike &amp;lt; Neutral &amp;lt; Like&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, you can see that the levels are ranked correctly. The &lt;code&gt;ordered()&lt;/code&gt; function can also be used to create ordered factors. Let us recreate the previous example using the &lt;code&gt;ordered()&lt;/code&gt; function.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ordered(rating, levels = c(&amp;quot;Dislike&amp;quot;, &amp;quot;Neutral&amp;quot;, &amp;quot;Like&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] Like    Dislike Neutral Dislike Neutral Like    Neutral Dislike Dislike
## [10] Dislike Dislike Neutral Dislike Neutral Dislike Dislike Like    Neutral
## [19] Dislike Neutral Like    Neutral Dislike Like    Dislike
## Levels: Dislike &amp;lt; Neutral &amp;lt; Like&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can specify levels, modify labels and handle missing values using the &lt;code&gt;ordered()&lt;/code&gt; function as well.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;key-functions&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Key Functions&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_module_3_functions.png&#34; width=&#34;70%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;R uses &lt;strong&gt;factor&lt;/strong&gt; to handle categorical data.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;as.factor()&lt;/code&gt; or &lt;code&gt;as_factor()&lt;/code&gt; to coerce other data types to &lt;strong&gt;factor&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;is.factor()&lt;/code&gt; or &lt;code&gt;is.ordered()&lt;/code&gt; to identify factor &amp;amp; ordered factor respectively.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;factor()&lt;/code&gt; to
&lt;ul&gt;
&lt;li&gt;specify labels&lt;/li&gt;
&lt;li&gt;modify labels&lt;/li&gt;
&lt;li&gt;handle missing data&lt;/li&gt;
&lt;li&gt;create ordered factors&lt;/li&gt;
&lt;li&gt;specify order of levels&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;ordered()&lt;/code&gt; to create ordered factors.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;your-turn&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Your Turn…&lt;/h3&gt;
&lt;p&gt;Use &lt;code&gt;analytics_raw.rds&lt;/code&gt; data set to answer the below questions.&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;p&gt;Check whether the below variables are factor&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;device&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;page_depth&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;landing_page&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Coerce the following variables to type factor&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;device&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;os&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;browser&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;user_type&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;channel&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;gender&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;landing_page&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;exit_page&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;city&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;country&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;user_type&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use only the following levels in the &lt;code&gt;gender&lt;/code&gt; column:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;male&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;female&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Include &lt;code&gt;NA&lt;/code&gt; as a level in the gender column.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Change label of &lt;code&gt;NA&lt;/code&gt; to &lt;code&gt;missing&lt;/code&gt; in the &lt;code&gt;gender&lt;/code&gt; column.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Change the labels of the levels in &lt;code&gt;user_type&lt;/code&gt; column to&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;New&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Returning&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Check if the &lt;code&gt;user_rating&lt;/code&gt; column is ordered. If not, coerce it to type ordered factor.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;*As the reader of this blog, you are our most important critic and commentator.
We value your opinion and want to know what we are doing right, what we could
do better, what areas you would like to see us publish in, and any other words
of wisdom you are willing to pass our way.&lt;/p&gt;
&lt;p&gt;We welcome your comments. You can email to let us know what you did or did not
like about our blog as well as what we can do to make our post better.*&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Email: &lt;a href=&#34;mailto:support@rsquaredacademy.com&#34; class=&#34;email&#34;&gt;support@rsquaredacademy.com&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>rfm 0.2.2</title>
      <link>https://blog.rsquaredacademy.com/rfm-0-2-2/</link>
      <pubDate>Fri, 31 Jul 2020 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/rfm-0-2-2/</guid>
      <description>&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/github_rfm.png&#34; width=&#34;70%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;We’re excited to announce the release of &lt;code&gt;rfm&lt;/code&gt; 0.2.2 on CRAN! &lt;code&gt;rfm&lt;/code&gt; provides tools for customer segmentation using &lt;strong&gt;R&lt;/strong&gt;ecency &lt;strong&gt;F&lt;/strong&gt;requency &lt;strong&gt;M&lt;/strong&gt;onetary value analysis. It includes a Shiny app for interactive segmentation. You can install rfm with:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;install.packages(&amp;quot;rfm&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In this blog post, we will summarize the changes implemented in the current (&lt;code&gt;0.2.2&lt;/code&gt;) and previous release (&lt;code&gt;0.2.1&lt;/code&gt;).&lt;/p&gt;
&lt;div id=&#34;segmentation&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Segmentation&lt;/h2&gt;
&lt;p&gt;In previous versions, &lt;code&gt;rfm_segment()&lt;/code&gt; would overwrite a segment if the intervals used to define the segment was a subset of another segment. It was expected that the end user would be careful to ensure that the intervals for each segment would be unique and not a subset of any other segment. You can see the example &lt;a href=&#34;https://github.com/rsquaredacademy/rfm/issues/67&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We are grateful to &lt;a href=&#34;https://github.com/leungi&#34; target=&#34;_blank&#34;&gt;&lt;span class=&#34;citation&#34;&gt;@leungi&lt;/span&gt;&lt;/a&gt; for bringing this to our attention and also for fixing it. Now, &lt;code&gt;rfm_segment()&lt;/code&gt; does not overwrite
the segments even if the intervals for one segment is a subset of another.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# analysis date
analysis_date &amp;lt;- lubridate::as_date(&amp;quot;2006-12-31&amp;quot;)

# rfm score
rfm_result &amp;lt;- rfm_table_order(rfm_data_orders, customer_id, order_date,
                              revenue, analysis_date)

rfm_result&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 995 x 9
##    customer_id date_most_recent recency_days transaction_cou~ amount
##    &amp;lt;chr&amp;gt;       &amp;lt;date&amp;gt;                  &amp;lt;dbl&amp;gt;            &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;
##  1 Abbey O&amp;#39;Re~ 2006-06-09                205                6    472
##  2 Add Senger  2006-08-13                140                3    340
##  3 Aden Lesch~ 2006-06-20                194                4    405
##  4 Admiral Se~ 2006-08-21                132                5    448
##  5 Agness O&amp;#39;K~ 2006-10-02                 90                9    843
##  6 Aileen Bar~ 2006-10-08                 84                9    763
##  7 Ailene Her~ 2006-03-25                281                8    699
##  8 Aiyanna Br~ 2006-04-29                246                4    157
##  9 Ala Schmid~ 2006-01-16                349                3    363
## 10 Alannah Bo~ 2005-04-21                619                4    196
## # ... with 985 more rows, and 4 more variables: recency_score &amp;lt;int&amp;gt;,
## #   frequency_score &amp;lt;int&amp;gt;, monetary_score &amp;lt;int&amp;gt;, rfm_score &amp;lt;dbl&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# segmentation
segment_names &amp;lt;- c(
  &amp;quot;Champions&amp;quot;, &amp;quot;Loyal Customers&amp;quot;, &amp;quot;Potential Loyalist&amp;quot;,
  &amp;quot;New Customers&amp;quot;, &amp;quot;Promising&amp;quot;, &amp;quot;Need Attention&amp;quot;, &amp;quot;About To Sleep&amp;quot;,
  &amp;quot;At Risk&amp;quot;, &amp;quot;Can&amp;#39;t Lose Them&amp;quot;, &amp;quot;Lost&amp;quot;
)

recency_lower &amp;lt;- c(4, 2, 3, 4, 3, 2, 2, 1, 1, 1)
recency_upper &amp;lt;- c(5, 5, 5, 5, 4, 3, 3, 2, 1, 2)
frequency_lower &amp;lt;- c(4, 3, 1, 1, 1, 2, 1, 2, 4, 1)
frequency_upper &amp;lt;- c(5, 5, 3, 1, 1, 3, 2, 5, 5, 2)
monetary_lower &amp;lt;- c(4, 3, 1, 1, 1, 2, 1, 2, 4, 1)
monetary_upper &amp;lt;- c(5, 5, 3, 1, 1, 3, 2, 5, 5, 2)

segments &amp;lt;-
  rfm_segment(
    rfm_result,
    segment_names,
    recency_lower,
    recency_upper,
    frequency_lower,
    frequency_upper,
    monetary_lower,
    monetary_upper
  )

# segment size
segments %&amp;gt;%
  count(segment) %&amp;gt;%
  arrange(desc(n)) %&amp;gt;%
  rename(Segment = segment, Count = n)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 8 x 2
##   Segment            Count
##   &amp;lt;chr&amp;gt;              &amp;lt;int&amp;gt;
## 1 Loyal Customers      278
## 2 Potential Loyalist   229
## 3 Champions            158
## 4 Lost                 111
## 5 At Risk               86
## 6 About To Sleep        50
## 7 Others                48
## 8 Need Attention        35&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the above example, the interval used to define the &lt;strong&gt;Champions&lt;/strong&gt; segment is a subset of &lt;strong&gt;Loyal Customers&lt;/strong&gt;. In the previous versions, those customers who
should have been assigned &lt;strong&gt;Champions&lt;/strong&gt; were reassigned as &lt;strong&gt;Loyal Customers&lt;/strong&gt; if the criteria for &lt;strong&gt;Champions&lt;/strong&gt; was evaluated before &lt;strong&gt;Loyal Customers&lt;/strong&gt;. From version 0.2.0, &lt;code&gt;rfm_segment()&lt;/code&gt; will avoid such overwriting.&lt;/p&gt;
&lt;p align=&#34;center&#34;&gt;
&lt;a href=&#34;https://rsquared-academy.thinkific.com/courses/&#34; target=&#34;_blank&#34;&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/rfm-course-ad.png&#34; width=&#34;100%&#34; alt=&#34;new courses ad&#34; style=&#34;text-decoration: none;&#34;&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;visualization&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Visualization&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;rfm&lt;/code&gt; used print all the plots by default instead of returning a plot object. This resulted in difficulties for some end users who wanted to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;further modify the plot&lt;/li&gt;
&lt;li&gt;include the plot in a panel of other plots&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;From version 0.2.1, all plotting functions use an additional argument &lt;code&gt;print_plot&lt;/code&gt;. It is set to &lt;code&gt;TRUE&lt;/code&gt; by default to avoid any disruption to current work flows. Those users who want a plot object to be returned can set the above argument to &lt;code&gt;FALSE&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# analysis date
analysis_date &amp;lt;- lubridate::as_date(&amp;#39;2007-01-01&amp;#39;)

# transactions data
rfm_order &amp;lt;- rfm_table_order(rfm_data_orders, customer_id, order_date,
                             revenue, analysis_date)

# customer data
rfm_customer &amp;lt;- rfm_table_customer(rfm_data_customer, customer_id,
                                   number_of_orders, recency_days, revenue,
                                   analysis_date)

# plots
p1 &amp;lt;- 
  rfm_heatmap(rfm_order, 
              plot_title = &amp;quot;Transaction Data&amp;quot;, 
              print_plot = FALSE)

p2 &amp;lt;- 
  rfm_heatmap(rfm_customer, 
              plot_title = &amp;quot;Customer Data&amp;quot;, 
              print_plot = FALSE)

# using patchwork
p1 + p2&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2020-07-31-rfm-0-2-2_files/figure-html/viz-1.png&#34; width=&#34;960&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;custom-threshold-for-rfm-scores&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Custom Threshold for RFM Scores&lt;/h2&gt;
&lt;p&gt;Lots of users wanted to know the threshold used for generating the RFM scores. From version 0.2.1, &lt;code&gt;rfm_table_*&lt;/code&gt; family of functions return the threshold.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;analysis_date &amp;lt;- lubridate::as_date(&amp;#39;2006-12-31&amp;#39;)
result &amp;lt;- rfm_table_order(rfm_data_orders, customer_id, order_date,
                          revenue, analysis_date)

# threshold
result$threshold&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 5 x 6
##   recency_lower recency_upper frequency_lower frequency_upper monetary_lower
##           &amp;lt;dbl&amp;gt;         &amp;lt;dbl&amp;gt;           &amp;lt;dbl&amp;gt;           &amp;lt;dbl&amp;gt;          &amp;lt;dbl&amp;gt;
## 1            1           115                1               4            12 
## 2          115           181                4               5           256.
## 3          181           297.               5               6           382 
## 4          297.          482                6               8           506.
## 5          482           977                8              15           666 
## # ... with 1 more variable: monetary_upper &amp;lt;dbl&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Another request (see &lt;a href=&#34;https://github.com/rsquaredacademy/rfm/issues/58&#34;&gt;here&lt;/a&gt;) was to be able to use custom or user specific threshold for generating RFM score. &lt;code&gt;rfm&lt;/code&gt; uses quantiles to generate the lower and upper thresholds used for generating the scores. Unfortunately, if the data is skewed, using quantiles is not effective. From version 0.2.1, users can specify custom threshold for generating the RFM score and we will learn how to do this using an example.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;analysis_date &amp;lt;- lubridate::as_date(&amp;#39;2006-12-31&amp;#39;)
result &amp;lt;- rfm_table_order(rfm_data_orders, customer_id, order_date, revenue,
                          analysis_date)
result$threshold&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 5 x 6
##   recency_lower recency_upper frequency_lower frequency_upper monetary_lower
##           &amp;lt;dbl&amp;gt;         &amp;lt;dbl&amp;gt;           &amp;lt;dbl&amp;gt;           &amp;lt;dbl&amp;gt;          &amp;lt;dbl&amp;gt;
## 1            1           115                1               4            12 
## 2          115           181                4               5           256.
## 3          181           297.               5               6           382 
## 4          297.          482                6               8           506.
## 5          482           977                8              15           666 
## # ... with 1 more variable: monetary_upper &amp;lt;dbl&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you look at the above output, we have 5 bins/scores and there are six different values. Let us focus on the &lt;code&gt;monetary_*&lt;/code&gt; columns in the threshold table. The lower threshold of the first bin and the upper threshold of the last bin are the &lt;code&gt;min&lt;/code&gt; and &lt;code&gt;max&lt;/code&gt; values form the &lt;code&gt;revenue&lt;/code&gt; column of &lt;code&gt;rfm_data_orders&lt;/code&gt; and the rest of the values are returned by the &lt;code&gt;quantile()&lt;/code&gt; function.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;revenue &amp;lt;- 
  rfm_data_orders %&amp;gt;% 
  group_by(customer_id) %&amp;gt;% 
  summarize(total = sum(revenue))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## `summarise()` ungrouping (override with `.groups` argument)&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# revenue at customer level
revenue&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 995 x 2
##    customer_id        total
##  * &amp;lt;chr&amp;gt;              &amp;lt;dbl&amp;gt;
##  1 Abbey O&amp;#39;Reilly DVM   472
##  2 Add Senger           340
##  3 Aden Lesch Sr.       405
##  4 Admiral Senger       448
##  5 Agness O&amp;#39;Keefe       843
##  6 Aileen Barton        763
##  7 Ailene Hermann       699
##  8 Aiyanna Bruen PhD    157
##  9 Ala Schmidt DDS      363
## 10 Alannah Borer        196
## # ... with 985 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# min and max
min(revenue$total)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 12&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;max(revenue$total)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1488&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us look at the quantiles used for generating the scores.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;quantile(revenue$total, probs = seq(0, 1, length.out = 6))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##     0%    20%    40%    60%    80%   100% 
##   12.0  254.8  381.0  505.4  665.0 1488.0&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The intervals are created in the below style:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;Left-closed, right-open: [ a , b ) = { x ∣ a ≤ x &amp;lt; b }&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Since rfm uses left closed intervals to generate the scores, we add &lt;code&gt;1&lt;/code&gt; to all values except the minimum value. Now, let us recreate the RFM scores using custom threshold instead of quantiles.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rfm_table_order(rfm_data_orders, 
                customer_id, 
                order_date, 
                revenue,
                analysis_date, 
                recency_bins = c(115, 181, 297, 482),
                frequency_bins = c(4, 5, 6, 8), 
                monetary_bins = c(256, 382, 506, 666))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 995 x 9
##    customer_id date_most_recent recency_days transaction_cou~ amount
##    &amp;lt;chr&amp;gt;       &amp;lt;date&amp;gt;                  &amp;lt;dbl&amp;gt;            &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;
##  1 Abbey O&amp;#39;Re~ 2006-06-09                205                6    472
##  2 Add Senger  2006-08-13                140                3    340
##  3 Aden Lesch~ 2006-06-20                194                4    405
##  4 Admiral Se~ 2006-08-21                132                5    448
##  5 Agness O&amp;#39;K~ 2006-10-02                 90                9    843
##  6 Aileen Bar~ 2006-10-08                 84                9    763
##  7 Ailene Her~ 2006-03-25                281                8    699
##  8 Aiyanna Br~ 2006-04-29                246                4    157
##  9 Ala Schmid~ 2006-01-16                349                3    363
## 10 Alannah Bo~ 2005-04-21                619                4    196
## # ... with 985 more rows, and 4 more variables: recency_score &amp;lt;int&amp;gt;,
## #   frequency_score &amp;lt;int&amp;gt;, monetary_score &amp;lt;int&amp;gt;, rfm_score &amp;lt;dbl&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We have used the values from the threshold table to reproduce the earlier result. If you observe carefully, we have specified &lt;code&gt;4&lt;/code&gt; values while generating &lt;code&gt;5&lt;/code&gt; bins/scores. Whenever using custom threshold, values supplied should be one less than the number of bins/scores generated as &lt;code&gt;rfm&lt;/code&gt; internally computes the &lt;code&gt;min&lt;/code&gt; and &lt;code&gt;max&lt;/code&gt; values. In general, if you have &lt;code&gt;n&lt;/code&gt; bins/scores, you only specify the upper threshold for &lt;code&gt;n - 1&lt;/code&gt; bins/scores.&lt;/p&gt;
&lt;p&gt;We have tried our best to explain how to use custom threshold but completely understand that it can be confusing to implement at beginning. If you have any questions about this method, feel free to write to us at &lt;strong&gt;&lt;a href=&#34;mailto:support@rsquaredacademy.com&#34; class=&#34;email&#34;&gt;support@rsquaredacademy.com&lt;/a&gt;&lt;/strong&gt; and our team will be happy to help you.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;acknowledgements&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Acknowledgements&lt;/h2&gt;
&lt;p&gt;We are grateful to &lt;a href=&#34;https://github.com/leungi&#34; target=&#34;_blank&#34;&gt;&lt;span class=&#34;citation&#34;&gt;@leungi&lt;/span&gt;&lt;/a&gt;, &lt;a href=&#34;https://github.com/gfagherazzi&#34; target=&#34;_blank&#34;&gt;&lt;span class=&#34;citation&#34;&gt;@gfagherazzi&lt;/span&gt;&lt;/a&gt; and &lt;a href=&#34;https://github.com/DavidGarciaEstaun&#34; target=&#34;_blank&#34;&gt;&lt;span class=&#34;citation&#34;&gt;@DavidGarciaEstaun&lt;/span&gt;&lt;/a&gt; for their inputs.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;learning-more&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Learning More&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://rfm.rsquaredacademy.com&#34;&gt;Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/rsquaredacademy/rfm&#34;&gt;GitHub&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;feedback&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Feedback&lt;/h2&gt;
&lt;p&gt;*As the reader of this blog, you are our most important critic and commentator.
We value your opinion and want to know what we are doing right, what we could
do better, what areas you would like to see us publish in, and any other words
of wisdom you are willing to pass our way.&lt;/p&gt;
&lt;p&gt;We welcome your comments. You can email to let us know what you did or did not
like about our blog as well as what we can do to make our post better.*&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Email: &lt;a href=&#34;mailto:support@rsquaredacademy.com&#34; class=&#34;email&#34;&gt;support@rsquaredacademy.com&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>A Comprehensive Introduction to Handling Date &amp; Time in R</title>
      <link>https://blog.rsquaredacademy.com/handling-date-and-time-in-r/</link>
      <pubDate>Fri, 17 Apr 2020 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/handling-date-and-time-in-r/</guid>
      <description>&lt;script src=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/kePrint/kePrint.js&#34;&gt;&lt;/script&gt;


&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/handling-date-and-time-in-r.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In this tutorial, we will learn to handle date &amp;amp; time in R. We will start off by learning how
to &lt;strong&gt;get current date &amp;amp; time&lt;/strong&gt; before moving on to understand &lt;strong&gt;how R handles date/time internally&lt;/strong&gt;
and the different classes such as &lt;code&gt;Date&lt;/code&gt; &amp;amp; &lt;code&gt;POSIXct/lt&lt;/code&gt;. We will spend some time
exploring &lt;strong&gt;time zones, daylight savings and ISO 8001 standard&lt;/strong&gt; for representing date/time.
We will look at all the &lt;strong&gt;weird formats in which date/time come in real world&lt;/strong&gt; and learn to
&lt;strong&gt;parse them using conversion specifications&lt;/strong&gt;. After this, we will also &lt;strong&gt;learn how to handle date/time
columns while reading external data into R&lt;/strong&gt;. We will learn to &lt;strong&gt;extract and update different date/time
components&lt;/strong&gt; such as year, month, day, hour, minute etc., &lt;strong&gt;create sequence of dates&lt;/strong&gt; in different ways
and explore intervals, durations and period. We will end the tutorial by learning how to &lt;strong&gt;round/rollback
dates&lt;/strong&gt;. Throughout the tutorial, we will also &lt;strong&gt;work through a case study&lt;/strong&gt; to better understand the
concepts we learn. Happy learning!&lt;/p&gt;
&lt;div id=&#34;table-of-contents&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Table of Contents&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#resources&#34;&gt;Resources&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#intro&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#casestudy&#34;&gt;Case Study&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#classes&#34;&gt;Date &amp;amp; Time Classes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#arithmetic&#34;&gt;Date Arithmetic&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#timezones&#34;&gt;Timezones &amp;amp; Daylight Savings&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#formats&#34;&gt;Date &amp;amp; Time Formats&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#parse&#34;&gt;Parse/Read Date &amp;amp; Time&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#components&#34;&gt;Date &amp;amp; Time Components&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#createupdate&#34;&gt;Create, Update &amp;amp; Verify&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#intervals&#34;&gt;Intervals, Durations &amp;amp; Period&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#others&#34;&gt;Round &amp;amp; Rollback&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#references&#34;&gt;References&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;resources&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Resources&lt;/h2&gt;
&lt;p&gt;Below are the links to all the resources related to this tutorial:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://slides.rsquaredacademy.com/handling-date-and-time-in-r.pdf&#34; target=&#34;_blank&#34;&gt;Slides&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/rsquaredacademy-education/online-courses/&#34; target=&#34;_blank&#34;&gt;Code &amp;amp; Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://rstudio.cloud/project/1072419&#34; target=&#34;_blank&#34;&gt;RStudio Cloud Project&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://wrangle-r.rsquaredacademy.com/lubridate.html&#34; target=&#34;_blank&#34;&gt;ebook&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p align=&#34;center&#34;&gt;
&lt;a href=&#34;https://rsquared-academy.thinkific.com/courses/handling-date-and-time-in-R&#34; target=&#34;_blank&#34;&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/lubirdate-blog-course-ad.png&#34; width=&#34;100%&#34; alt=&#34;new courses ad&#34; style=&#34;text-decoration: none;&#34;&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;intro&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/322IcnZiYx4&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;div id=&#34;date&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Date&lt;/h3&gt;
&lt;p&gt;Let us begin by looking at the current date and time. &lt;code&gt;Sys.Date()&lt;/code&gt; and &lt;code&gt;today()&lt;/code&gt; will return the current date.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;Sys.Date()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2020-06-10&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;lubridate::today()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2020-06-10&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;time&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Time&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;Sys.time()&lt;/code&gt; and &lt;code&gt;now()&lt;/code&gt; return the date, time and the timezone. In &lt;code&gt;now()&lt;/code&gt;, we can specify the timezone using the &lt;code&gt;tzone&lt;/code&gt; argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;Sys.time()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2020-06-10 22:47:50 IST&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;lubridate::now()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2020-06-10 22:47:50 IST&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;lubridate::now(tzone = &amp;quot;UTC&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2020-06-10 17:17:50 UTC&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;am-or-pm&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;AM or PM?&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;am()&lt;/code&gt; and &lt;code&gt;pm()&lt;/code&gt; allow us to check whether date/time occur in the &lt;code&gt;AM&lt;/code&gt; or &lt;code&gt;PM&lt;/code&gt;? They return a logical value i.e. &lt;code&gt;TRUE&lt;/code&gt; or &lt;code&gt;FALSE&lt;/code&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;lubridate::am(now())&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;lubridate::pm(now())&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;leap-year&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Leap Year&lt;/h3&gt;
&lt;p&gt;We can also check if the current year is a leap year using &lt;code&gt;leap_year()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;Sys.Date()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2020-06-10&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;lubridate::leap_year(Sys.Date())&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Function
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;Sys.Date()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Current Date
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;lubridate::today()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Current Date
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;Sys.time()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Current Time
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;lubridate::now()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Current Time
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;lubridate::am()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Whether time occurs in am?
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;lubridate::pm()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Whether time occurs in pm?
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;lubridate::leap_year()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Check if the year is a leap year?
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;div id=&#34;your-turn&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Your Turn&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;get current date&lt;/li&gt;
&lt;li&gt;get current time&lt;/li&gt;
&lt;li&gt;check whether the time occurs in am or pm?&lt;/li&gt;
&lt;li&gt;check whether the following years were leap years
&lt;ul&gt;
&lt;li&gt;2018&lt;/li&gt;
&lt;li&gt;2016&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;casestudy&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Case Study&lt;/h2&gt;
&lt;p&gt;Throughout the tutorial, we will work on a case study related to transactions of an imaginary trading company. The data set includes information about invoice and payment dates.&lt;/p&gt;
&lt;div id=&#34;data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;transact &amp;lt;- readr::read_csv(&amp;#39;https://raw.githubusercontent.com/rsquaredacademy/datasets/master/transact.csv&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 2,466 x 3
##    Invoice    Due        Payment   
##    &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;    
##  1 2013-01-02 2013-02-01 2013-01-15
##  2 2013-01-26 2013-02-25 2013-03-03
##  3 2013-07-03 2013-08-02 2013-07-08
##  4 2013-02-10 2013-03-12 2013-03-17
##  5 2012-10-25 2012-11-24 2012-11-28
##  6 2012-01-27 2012-02-26 2012-02-22
##  7 2013-08-13 2013-09-12 2013-09-09
##  8 2012-12-16 2013-01-15 2013-01-12
##  9 2012-05-14 2012-06-13 2012-07-01
## 10 2013-07-01 2013-07-31 2013-07-26
## # ... with 2,456 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We will explore more about reading data sets with date/time columns after learning how to
parse date/time. We have shared the code for reading the data sets used in the practice
questions both in the Learning Management System as well as in our GitHub repo.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data-dictionary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data Dictionary&lt;/h3&gt;
&lt;p&gt;The data set has 3 columns. All the dates are in the format (yyyy-mm-dd).&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Column
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Invoice
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Invoice Date
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Due
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Due Date
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Payment
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Payment Date
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;In the case study, we will try to answer a few questions we have about the &lt;code&gt;transact&lt;/code&gt; data.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;extract date, month and year from Due&lt;/li&gt;
&lt;li&gt;compute the number of days to settle invoice&lt;/li&gt;
&lt;li&gt;compute days over due&lt;/li&gt;
&lt;li&gt;check if due year is a leap year&lt;/li&gt;
&lt;li&gt;check when due day in february is 29, whether it is a leap year&lt;/li&gt;
&lt;li&gt;how many invoices were settled within due date&lt;/li&gt;
&lt;li&gt;how many invoices are due in each quarter&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;classes&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Date &amp;amp; Time Classes&lt;/h2&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/IEX49t8sSgw&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;p&gt;In this section, we will look at two things. First, how to create date/time
data in R, and second, how to convert other data types to date/time. Let us
begin by creating the release date of R 3.6.2.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;release_date &amp;lt;- 2019-12-12
release_date&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1995&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Okay! Why do we see &lt;code&gt;1995&lt;/code&gt; when we call the date? What is happening here? Let us
quickly check the data type of &lt;code&gt;release_date&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;class(release_date)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;numeric&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The data type is &lt;code&gt;numeric&lt;/code&gt; i.e. R has subtracted &lt;code&gt;12&lt;/code&gt; twice from &lt;code&gt;2019&lt;/code&gt; to
return &lt;code&gt;1995&lt;/code&gt;. Clearly, the above method is not the right way to store
date/time. Let us see if we can get some hints from the built-in R functions we
used in the previous section. If you observe the output, all of them returned
date/time wrapped in quotes. Hmmm… let us wrap our date in quotes and see what
happens.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;release_date &amp;lt;- &amp;quot;2019-12-12&amp;quot;
release_date&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2019-12-12&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Alright, now R does not do any arithmetic and returns the date as we specified.
Great! Is this the right format to store date/time then? No. Why? What is the problem
if date/time is saved as character/string? The problem is the nature or type of
operations done on date/time are different when compared to string/character,
number or logical values.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;how do we add/subtract dates?&lt;/li&gt;
&lt;li&gt;how do we extract components such as year, month, day etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To answer the above questions, we will first check the data type of &lt;code&gt;Sys.Date()&lt;/code&gt;
and &lt;code&gt;now()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;class(Sys.Date())&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Date&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;class(lubridate::now())&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;POSIXct&amp;quot; &amp;quot;POSIXt&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;class(release_date)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;character&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see from the above output, there are 3 different classes for storing
date/time in R&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Date&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;POSIXct&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;POSIXlt&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let us explore each of the above classes one by one.&lt;/p&gt;
&lt;div id=&#34;date-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Date&lt;/h3&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Introduction&lt;/h4&gt;
&lt;p&gt;The &lt;code&gt;Date&lt;/code&gt; class represents calendar dates. Let us go back to &lt;code&gt;Sys.Date()&lt;/code&gt;. If
you check the class of &lt;code&gt;Sys.Date()&lt;/code&gt;, it is &lt;code&gt;Date&lt;/code&gt;. Internally, this date is a
number i.e. an integer. The &lt;code&gt;unclass()&lt;/code&gt; function will show how dates are stored
internally.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;Sys.Date()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2020-06-10&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;unclass(Sys.Date())&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 18423&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What does this integer represent? Why has R stored the date as an integer?
In R, dates are represented as the number of days since &lt;code&gt;1970-01-01&lt;/code&gt;. All the dates in R are
internally stored in this way. Before we explore this concept further, let us
learn to create &lt;code&gt;Date&lt;/code&gt; objects in R. We will continue to use the release date
of R 3.6.2, &lt;code&gt;2019-12-12&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Until now, we have stored the above date as character/string but now we will use
&lt;code&gt;as.Date()&lt;/code&gt; to save it as a &lt;code&gt;Date&lt;/code&gt; object. &lt;code&gt;as.Date()&lt;/code&gt; is the easiest and
simplest way to create dates in R.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;release_date &amp;lt;- as.Date(&amp;quot;2019-12-12&amp;quot;)
release_date&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2019-12-12&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;as_date()&lt;/code&gt; function from the lubridate package is similar to &lt;code&gt;as.Date()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;release_date &amp;lt;- lubridate::as_date(&amp;quot;2019-12-12&amp;quot;)
release_date&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2019-12-12&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you look at the difference between &lt;code&gt;release_date&lt;/code&gt; and &lt;code&gt;1970-01-01&lt;/code&gt;, it will
be the same as &lt;code&gt;unclass(release_date)&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;release_date - as.Date(&amp;quot;1970-01-01&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Time difference of 18242 days&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;unclass(release_date)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 18242&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us come back to &lt;code&gt;1970-01-01&lt;/code&gt; i.e. the origin for dates in R.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;lubridate::origin&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;1970-01-01 UTC&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;From the previous examples, we know that dates are internally stored as number
of days since &lt;code&gt;1970-01-01&lt;/code&gt;. How about dates older than the origin? How are they
stored? Let us look at that briefly.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;unclass(as.Date(&amp;quot;1963-08-28&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] -2318&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Dates older than the origin are stored as negative integers. For those who are
not aware, Martin Luther King, Jr. delivered his famous &lt;strong&gt;I Have a Dream&lt;/strong&gt;
speech on &lt;code&gt;1963-08-28&lt;/code&gt;. Let us move on and learn how to convert numbers into
dates.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;convert-numeric&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Convert Numeric&lt;/h4&gt;
&lt;p&gt;The &lt;code&gt;as.Date()&lt;/code&gt; function can be used to convert any of the following to a &lt;code&gt;Date&lt;/code&gt;
object&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;character/string&lt;/li&gt;
&lt;li&gt;number&lt;/li&gt;
&lt;li&gt;factor (categorical/qualitative)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We have explored how to convert strings to date. How about converting numbers to
date? Sure, we can create date from numbers by specifying the origin and number
of days since it.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;as.Date(18242, origin = &amp;quot;1970-01-01&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2019-12-12&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The origin can be changed to another date (while changing the number as well.)&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;as.Date(7285, origin = &amp;quot;2000-01-01&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2019-12-12&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;iso-8601&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;ISO 8601&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/iso.png&#34; width=&#34;70%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;If you have carefully observed, the format in which we have been specifying the
dates as well as of those returned by functions such as &lt;code&gt;Sys.Date()&lt;/code&gt; or
&lt;code&gt;Sys.time()&lt;/code&gt; is the same i.e. &lt;code&gt;YYYY-MM-DD&lt;/code&gt;. It includes&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the year including the century&lt;/li&gt;
&lt;li&gt;the month&lt;/li&gt;
&lt;li&gt;the date&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The month and date separated by &lt;code&gt;-&lt;/code&gt;. This default format used in R is the ISO
8601 standard for date/time. ISO 8601 is the internationally accepted way to
represent dates and times and uses the 24 hour clock system. Let us create the
release date using another function &lt;code&gt;ISOdate()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ISOdate(year  = 2019,
        month = 12,
        day   = 12,
        hour  = 8,
        min   = 5, 
        sec   = 3,
        tz    = &amp;quot;UTC&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2019-12-12 08:05:03 UTC&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We will look at all the different weird ways in which date/time are specified in
the real world in the &lt;a href=&#34;#formats&#34;&gt;Date &amp;amp; Time Formats&lt;/a&gt; section. For the time being, let us
continue exploring date/time classes in R. The next class we are going to look
at is &lt;code&gt;POSIXct/POSIXlt&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;posix&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;POSIX&lt;/h3&gt;
&lt;p&gt;You might be wondering what is this POSIX thing? POSIX stands for &lt;strong&gt;P&lt;/strong&gt;ortable
&lt;strong&gt;O&lt;/strong&gt;perating &lt;strong&gt;S&lt;/strong&gt;ystem &lt;strong&gt;I&lt;/strong&gt;nterface. It is a family of standards specified for
maintaining compatibility between different operating systems. Before we
learn to create POSIX objects, let us look at &lt;code&gt;now()&lt;/code&gt; from lubridate.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;class(lubridate::now())&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;POSIXct&amp;quot; &amp;quot;POSIXt&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;now()&lt;/code&gt; returns current date/time as a POSIXct object. Let us look at its
internal representation using &lt;code&gt;unclass()&lt;/code&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;unclass(lubridate::now())&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1591809475
## attr(,&amp;quot;tzone&amp;quot;)
## [1] &amp;quot;&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The output you see is the number of seconds since January 1, 1970.&lt;/p&gt;
&lt;div id=&#34;posixct&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;POSIXct&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;POSIXct&lt;/code&gt; represents the number of seconds since the beginning of 1970 (UTC) and
&lt;code&gt;ct&lt;/code&gt; stands for calendar time. To store date/time as &lt;code&gt;POSIXct&lt;/code&gt; objects, use
&lt;code&gt;as.POSIXct()&lt;/code&gt;. Let us now store the release date of R 3.6.2 as &lt;code&gt;POSIXct&lt;/code&gt; as shown
below&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;release_date &amp;lt;- as.POSIXct(&amp;quot;2019-12-12 08:05:03&amp;quot;)
class(release_date)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;POSIXct&amp;quot; &amp;quot;POSIXt&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;unclass(release_date) &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1576118103
## attr(,&amp;quot;tzone&amp;quot;)
## [1] &amp;quot;&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;posixlt&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;POSIXlt&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;POSIXlt&lt;/code&gt; represents the following information in a list&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;seconds&lt;/li&gt;
&lt;li&gt;minutes&lt;/li&gt;
&lt;li&gt;hour&lt;/li&gt;
&lt;li&gt;day of the month&lt;/li&gt;
&lt;li&gt;month&lt;/li&gt;
&lt;li&gt;year&lt;/li&gt;
&lt;li&gt;day of week&lt;/li&gt;
&lt;li&gt;day of year&lt;/li&gt;
&lt;li&gt;daylight saving time flag&lt;/li&gt;
&lt;li&gt;time zone&lt;/li&gt;
&lt;li&gt;offset in seconds from GMT&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;code&gt;lt&lt;/code&gt; in &lt;code&gt;POSIXlt&lt;/code&gt; stands for local time. Use &lt;code&gt;as.POSIXlt()&lt;/code&gt; to store
date/time as &lt;code&gt;POSIXlt&lt;/code&gt; objects. Let us store the release date as a &lt;code&gt;POSIXlt&lt;/code&gt;
object as shown below&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;release_date &amp;lt;- as.POSIXlt(&amp;quot;2019-12-12 08:05:03&amp;quot;)
release_date&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2019-12-12 08:05:03 IST&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As we said earlier, &lt;code&gt;POSIXlt&lt;/code&gt; stores date/time components in a list and these
can be extracted. Let us look at the date/time components returned by &lt;code&gt;POSIXlt&lt;/code&gt;
using &lt;code&gt;unclass()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;release_date &amp;lt;- as.POSIXlt(&amp;quot;2019-12-12 08:05:03&amp;quot;)
unclass(release_date)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## $sec
## [1] 3
## 
## $min
## [1] 5
## 
## $hour
## [1] 8
## 
## $mday
## [1] 12
## 
## $mon
## [1] 11
## 
## $year
## [1] 119
## 
## $wday
## [1] 4
## 
## $yday
## [1] 345
## 
## $isdst
## [1] 0
## 
## $zone
## [1] &amp;quot;IST&amp;quot;
## 
## $gmtoff
## [1] NA&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Use &lt;code&gt;unlist()&lt;/code&gt; if you want the components returned as a &lt;code&gt;vector&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;release_date &amp;lt;- as.POSIXlt(&amp;quot;2019-12-12 08:05:03&amp;quot;)
unlist(release_date)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    sec    min   hour   mday    mon   year   wday   yday  isdst   zone gmtoff 
##    &amp;quot;3&amp;quot;    &amp;quot;5&amp;quot;    &amp;quot;8&amp;quot;   &amp;quot;12&amp;quot;   &amp;quot;11&amp;quot;  &amp;quot;119&amp;quot;    &amp;quot;4&amp;quot;  &amp;quot;345&amp;quot;    &amp;quot;0&amp;quot;  &amp;quot;IST&amp;quot;     NA&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To extract specific components, use &lt;code&gt;$&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;release_date &amp;lt;- as.POSIXlt(&amp;quot;2019-12-12 08:05:03&amp;quot;)
release_date$hour&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 8&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;release_date$mon&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 11&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;release_date$zone&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;IST&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, let us look at the components returned by &lt;code&gt;POSIXlt&lt;/code&gt;. Some of them are
intuitive&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Component
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;sec&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Second
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;min&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Minute
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;hour&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Hour of the day
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;mon&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Month of the year (0-11
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;zone&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Timezone
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;wday&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Day of week
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;mday&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Day of month
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;year&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Years since 1900
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;yday&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Day of year
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;isdst&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Daylight saving flag
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;gmtoff&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Offset is seconds from GMT
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Great! We will end this section with a few tips/suggestions on when to use
&lt;code&gt;Date&lt;/code&gt; or &lt;code&gt;POSIXct/POSIXlt&lt;/code&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;use &lt;code&gt;Date&lt;/code&gt; when there is no time component&lt;/li&gt;
&lt;li&gt;use &lt;code&gt;POSIX&lt;/code&gt; when dealing with time and timezones&lt;/li&gt;
&lt;li&gt;use &lt;code&gt;POSIXlt&lt;/code&gt; when you want to access/extract the different components&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;your-turn-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Your Turn&lt;/h3&gt;
&lt;p&gt;R 1.0.0 was released on &lt;code&gt;2000-02-29 08:55:23 UTC&lt;/code&gt;. Save it as&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Date&lt;/code&gt; using character&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Date&lt;/code&gt; using origin and number&lt;/li&gt;
&lt;li&gt;&lt;code&gt;POSIXct&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;POSIXlt&lt;/code&gt; and extract
&lt;ul&gt;
&lt;li&gt;month day&lt;/li&gt;
&lt;li&gt;day of year&lt;/li&gt;
&lt;li&gt;month&lt;/li&gt;
&lt;li&gt;zone&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;ISODate&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;arithmetic&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Date Arithmetic&lt;/h2&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/iNzv8Ezpjw0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;p&gt;Time to do some arithmetic with the dates. Let us calculate the length of a
course you have enrolled for (Become a Rock Star Data Scientist in 10 Days) by subtracting the course start date from the course end date.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/course_duration.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;course_start    &amp;lt;- as_date(&amp;#39;2017-04-12&amp;#39;)
course_end      &amp;lt;- as_date(&amp;#39;2017-04-21&amp;#39;)
course_duration &amp;lt;- course_end - course_start
course_duration
## Time difference of 9 days&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;shift-date&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Shift Date&lt;/h3&gt;
&lt;p&gt;Time to shift the course dates. We can shift a date by days, weeks or months. Let us shift the course start date by:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;2 days&lt;/li&gt;
&lt;li&gt;3 weeks&lt;/li&gt;
&lt;li&gt;1 year&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/shift_dates.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;course_start + days(2)
## [1] &amp;quot;2017-04-14&amp;quot;
course_start + weeks(3)
## [1] &amp;quot;2017-05-03&amp;quot;
course_start + years(1)
## [1] &amp;quot;2018-04-12&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;case-study&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Case Study&lt;/h3&gt;
&lt;div id=&#34;compute-days-to-settle-invoice&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Compute days to settle invoice&lt;/h4&gt;
&lt;p&gt;Let us estimate the number of days to settle the invoice by subtracting the
date of invoice from the date of payment.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;transact %&amp;gt;%
  mutate(
    days_to_pay = Payment - Invoice
  )&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 2,466 x 4
##    Invoice    Due        Payment    days_to_pay
##    &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;     &amp;lt;drtn&amp;gt;     
##  1 2013-01-02 2013-02-01 2013-01-15 13 days    
##  2 2013-01-26 2013-02-25 2013-03-03 36 days    
##  3 2013-07-03 2013-08-02 2013-07-08  5 days    
##  4 2013-02-10 2013-03-12 2013-03-17 35 days    
##  5 2012-10-25 2012-11-24 2012-11-28 34 days    
##  6 2012-01-27 2012-02-26 2012-02-22 26 days    
##  7 2013-08-13 2013-09-12 2013-09-09 27 days    
##  8 2012-12-16 2013-01-15 2013-01-12 27 days    
##  9 2012-05-14 2012-06-13 2012-07-01 48 days    
## 10 2013-07-01 2013-07-31 2013-07-26 25 days    
## # ... with 2,456 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;compute-days-over-due&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Compute days over due&lt;/h4&gt;
&lt;p&gt;How many of the invoices were settled post the due date? We can find this by:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;subtracting the due date from the payment date&lt;/li&gt;
&lt;li&gt;counting the number of rows where delay &amp;gt; 0&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;transact %&amp;gt;%
  mutate(
    delay = Payment - Due
  ) %&amp;gt;%
  filter(delay &amp;gt; 0) %&amp;gt;% 
  count(delay)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 36 x 2
##    delay       n
##  * &amp;lt;drtn&amp;gt;  &amp;lt;int&amp;gt;
##  1  1 days    61
##  2  2 days    65
##  3  3 days    51
##  4  4 days    62
##  5  5 days    69
##  6  6 days    56
##  7  7 days    55
##  8  8 days    49
##  9  9 days    38
## 10 10 days    33
## # ... with 26 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;your-turn-2&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Your Turn&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;compute the length of a vacation which begins on &lt;code&gt;2020-04-19&lt;/code&gt; and ends on &lt;code&gt;2020-04-25&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;recompute the length of the vacation after shifting the vacation start and end date by &lt;code&gt;10&lt;/code&gt; days and &lt;code&gt;2&lt;/code&gt; weeks&lt;/li&gt;
&lt;li&gt;compute the days to settle invoice and days overdue from the &lt;code&gt;receivables.csv&lt;/code&gt; data set&lt;/li&gt;
&lt;li&gt;compute the length of employment (only for those employees who have been terminated) from the &lt;code&gt;hr-data.csv&lt;/code&gt; data set (use date of hire and termination)&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;timezones&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Time Zones &amp;amp; Daylight Savings&lt;/h2&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/Sz-Zf0s9Ubg&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;div id=&#34;introduction-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/lub_timezones.jpg&#34; width=&#34;70%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In the previous section, &lt;code&gt;POSIXlt&lt;/code&gt; stored date/time components as a list. Among
the different components it returned were&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;gmtoff&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;zone&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;gmtoff&lt;/code&gt; is offset in seconds from GMT i.e. difference in hours and minutes from
UTC. Wait.. What do UTC and GMT stand for?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Coordinated Universal Time (UTC)&lt;/li&gt;
&lt;li&gt;Greenwich Meridian Time (GMT)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Since we are talking about UTC, GMT etc., let us spend a little time on
understanding the basics of time zones and daylight savings.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;time-zones&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Time Zones&lt;/h3&gt;
&lt;p&gt;Timezones exist because different parts of the Earth receive sun light at
different times. If there was a single timezone, noon or morning would mean
different things in different parts of the world. The timezones are based on
Earth’s rotation. The Earth moves ~15 degrees every 60 minutes i.e. 360 degrees
in 24 hours. The planet is divided into 24 timezones, each 15 degrees of
longitude width.&lt;/p&gt;
&lt;p&gt;Now, you have heard of Greenwich Meridian Time (GMT) right? We just saw GMT off
set in &lt;code&gt;POSIXlt&lt;/code&gt; and you would have come across it in other time formats as
well. For example, India timezone is given as GMT +5:30. Let us explore GMT in a
little more detail. Greenwich is a suburb of London and the time at Greenwich
is &lt;strong&gt;G&lt;/strong&gt;reenwich &lt;strong&gt;M&lt;/strong&gt;ean &lt;strong&gt;T&lt;/strong&gt;ime. As you move West from Greenwich, every 15
degree section is one hour earlier than GMT and every 15 degree section to the
East is an hour later.&lt;/p&gt;
&lt;p&gt;Alright! What is &lt;strong&gt;UTC&lt;/strong&gt; then? &lt;strong&gt;C&lt;/strong&gt;oordinated &lt;strong&gt;U&lt;/strong&gt;niversal &lt;strong&gt;T&lt;/strong&gt;ime (UTC) ,
on the other hand, is the time standard commonly used across the world. Even
though they share the same current time, &lt;strong&gt;GMT&lt;/strong&gt; is a &lt;strong&gt;timezone&lt;/strong&gt; while
&lt;strong&gt;UTC&lt;/strong&gt; is a &lt;strong&gt;time standard&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;So how do we check the timezone in R? When you run &lt;code&gt;Sys.timezone()&lt;/code&gt;, you should
be able to see the timezone you are in.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;Sys.timezone()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Asia/Calcutta&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you do not see the timezone, use &lt;code&gt;Sys.getenv()&lt;/code&gt; to get the value of the
&lt;strong&gt;TZ&lt;/strong&gt; environment variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;Sys.getenv(&amp;quot;TZ&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If nothing is returned, it means we have to set the timezone. Use &lt;code&gt;Sys.setenv()&lt;/code&gt;
to set the timezone as shown below. The author resides in India and hence the
timezone is set to &lt;code&gt;Asia/Calcutta&lt;/code&gt;. You need to set the timezone in which you
reside or work.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;Sys.setenv(TZ = &amp;quot;Asia/Calcutta&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Another way to get the timezone is through &lt;code&gt;tz()&lt;/code&gt; from the lubridate package.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;lubridate::tz(Sys.time())&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you want to view the time in a different timezone, use &lt;code&gt;with_tz()&lt;/code&gt;. Let us
look at the current time in &lt;strong&gt;UTC&lt;/strong&gt; instead of &lt;strong&gt;Indian Standard Time&lt;/strong&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;lubridate::with_tz(Sys.time(), &amp;quot;UTC&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2020-06-10 17:17:58 UTC&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;daylight-savings&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Daylight Savings&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/lub_daylight_savings.png&#34; width=&#34;70%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Daylight savings also known as&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;daylight saving time&lt;/li&gt;
&lt;li&gt;daylight savings time&lt;/li&gt;
&lt;li&gt;daylight time&lt;/li&gt;
&lt;li&gt;summer time&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;is the practice of advancing clocks during summer months so that darkness falls
later each day according to the clock. In other words&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;advance clock by one hour in spring (spring forward)&lt;/li&gt;
&lt;li&gt;retard clocks by one hour in autumn (fall back)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In R, the &lt;code&gt;dst()&lt;/code&gt; function is an indicator for daylight savings. It returns
&lt;code&gt;TRUE&lt;/code&gt; if daylight saving is in force, &lt;code&gt;FALSE&lt;/code&gt; if not and &lt;code&gt;NA&lt;/code&gt; if unknown.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;Sys.Date()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2020-06-10&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dst(Sys.Date()) &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;your-turn-3&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Your Turn&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;check the timezone you live in&lt;/li&gt;
&lt;li&gt;check if daylight savings in on&lt;/li&gt;
&lt;li&gt;check the current time in &lt;strong&gt;UTC&lt;/strong&gt; or a different time zone&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;formats&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Date &amp;amp; Time Formats&lt;/h2&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/BdHTrItYKJw&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;p&gt;After the timezones and daylight savings detour, let us get back on path and
explore another important aspect, date &amp;amp; time formats. Although it is a good
practice to adher to ISO 8601 format, not all date/time data will comply with
it. In real world, date/time data may come in all types of weird formats. Below
is a sample&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Format
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
December 12, 2019
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
12th Dec, 2019
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Dec 12th, 19
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
12-Dec-19
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2019 December
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
12.12.19
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;When the data is not in the default ISO 8601 format, we need to explicitly
specify the format in R. We do this using conversion specifications. A
conversion specification is introduced by %, usually followed by a single
letter or O or E and then a single letter.&lt;/p&gt;
&lt;div id=&#34;conversion-specifications&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Conversion Specifications&lt;/h3&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Specification
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Example
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%d&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Day of the month (decimal number)
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
12
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%m&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Month (decimal number)
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
12
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%b&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Month (abbreviated)
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Dec
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%B&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Month (full name)
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
December
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%y&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Year (2 digit)
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
19
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%Y&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Year (4 digit)
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2019
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
%H
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Hour
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
8
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
%M
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Minute
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
5
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
%S
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Second
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
3
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Time to work through a few examples. Let us say you are dealing with dates in
the format &lt;code&gt;19/12/12&lt;/code&gt;. In this format, the year comes first followed by month
and the date; each separated by a slash (&lt;code&gt;/&lt;/code&gt;). The year consists of only 2
digits i.e. it does not include the century. Let us now map each component of
the date to the conversion specification table shown at the beginning.&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Date
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Specification
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
19
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%y&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
12
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%m&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
12
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%d&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Using the format argument, we will specify the conversion specification as a character vector
i.e. enclosed in quotes.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;as.Date(&amp;quot;19/12/12&amp;quot;, format = &amp;quot;%y/%m/%d&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2019-12-12&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Another way in which the release data can be written is &lt;code&gt;2019-Dec-12&lt;/code&gt;. We still
have the year followed by the month and the date but there are a few changes
here:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the components are separated by a &lt;code&gt;-&lt;/code&gt; instead of &lt;code&gt;/&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;year has 4 digits i.e. includes the century&lt;/li&gt;
&lt;li&gt;the month is specified using abbreviation instead of digits&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let us map the components to the format table:&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Date
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Specification
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2019
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%Y&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Dec
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%b&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
12
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%d&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Let us specify the format for the date using the above mapping.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;as.Date(&amp;quot;2019-Dec-12&amp;quot;, format = &amp;quot;%Y-%b-%d&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2019-12-12&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In both the above examples, we have not dealt with time components. Let us
include the release time of R 3.6.2 in the next one i.e. 
&lt;code&gt;19/12/12 08:05:03&lt;/code&gt;.&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Date
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Specification
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
19
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%y&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
12
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%m&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
12
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%d&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
08
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%H&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
05
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%M&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
03
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%S&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Since we are dealing with time, we will use &lt;code&gt;as.POSIXct()&lt;/code&gt; instead of
&lt;code&gt;as.Date()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;as.POSIXct(&amp;quot;19/12/12 08:05:03&amp;quot;, tz = &amp;quot;UTC&amp;quot;, format = &amp;quot;%y/%m/%d %H:%M:%S&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2019-12-12 08:05:03 UTC&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the below table, we look at some of the most widely used conversion
specifications. You can learn more about these specifications by running
&lt;code&gt;?strptime&lt;/code&gt; or &lt;code&gt;help(strptime)&lt;/code&gt;.&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Specification
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%a&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Abbreviated weekday
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%A&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Full weekday
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%C&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Century (00-99)
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%D&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Same as &lt;code&gt;%m/%d/%y&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%e&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Day of month [1 - 31]
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%F&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Same as &lt;code&gt;%Y-%m-%d&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%h&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Same as &lt;code&gt;%b&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%I&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Hours as decimal [01 - 12]
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%j&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Day of year [001 - 366]
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%R&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Same as &lt;code&gt;%H:%M&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%t&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Tab
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%T&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Same as &lt;code&gt;%H:%M:%S&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%u&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Weekday &lt;a href=&#34;Monday%20is%201&#34;&gt;1 - 7&lt;/a&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%U&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Week of year [00 - 53]
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%V&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Week of year [01 - 53]
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%w&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Weekday &lt;a href=&#34;sunday%20is%200&#34;&gt;0 - 6&lt;/a&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;%W&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Week of year [00 - 53]
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;We have included a lot of practice questions for you to explore the different
date/time formats. The solutions are available in the Learning Management System
as well as in our GitHub repo. Try them and let us know if you have any doubts.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;guess-format&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Guess Format&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;guess_formats()&lt;/code&gt; from lubridate is a very useful function. It will guess the
date/time format if you specify the order in which year, month, date, hour,
minute and second appear.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;release_date_formats &amp;lt;- c(&amp;quot;December 12th 2019&amp;quot;,
                        &amp;quot;Dec 12th 19&amp;quot;,
                        &amp;quot;dec 12 2019&amp;quot;)

guess_formats(release_date_formats, 
              orders = &amp;quot;mdy&amp;quot;, 
              print_matches = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                           Omdy          mdy         
## [1,] &amp;quot;December 12th 2019&amp;quot; &amp;quot;%Om %dth %Y&amp;quot; &amp;quot;%B %dth %Y&amp;quot;
## [2,] &amp;quot;Dec 12th 19&amp;quot;        &amp;quot;%Om %dth %y&amp;quot; &amp;quot;%b %dth %y&amp;quot;
## [3,] &amp;quot;dec 12 2019&amp;quot;        &amp;quot;%Om %d %Y&amp;quot;   &amp;quot;%b %d %Y&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##          Omdy          Omdy          Omdy           mdy           mdy 
## &amp;quot;%Om %dth %Y&amp;quot; &amp;quot;%Om %dth %y&amp;quot;   &amp;quot;%Om %d %Y&amp;quot;  &amp;quot;%B %dth %Y&amp;quot;  &amp;quot;%b %dth %y&amp;quot; 
##           mdy 
##    &amp;quot;%b %d %Y&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;your-turn-4&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Your Turn&lt;/h3&gt;
&lt;p&gt;Below, we have specified &lt;code&gt;July 5th, 2019&lt;/code&gt; in different ways. Create the date using &lt;code&gt;as.Date()&lt;/code&gt; while specifying the correct format for each of them.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;05.07.19&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;5-July 2019&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;July 5th, 2019&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;July 05, 2019&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;2019-July- 05&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;05/07/2019&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;07/05/2019&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;7/5/2019&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;07/5/19&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;2019-07-05&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;parse&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Parse Date &amp;amp; Time&lt;/h2&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/FqWb-OS6wu4&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;p&gt;While creating date-time objects, we specified different formats using the
conversion specification but most often you will not create date/time and
instead deal with data that comes your way from a database or API or
colleague/collaborator. In such cases, we need to be able to parse date/time
from the data provided to us. In this section, we will focus on parsing
date/time from character data. Both base R and the lubridate package offer
functions to parse date and time and we will explore a few of them in this
section. We will initially use functions from base R and later on explore those
from lubridate which will give us an opportunity to compare and contrast. It
will also allow us to choose the functions based on the data we are dealing
with.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;strptime()&lt;/code&gt; will convert character data to &lt;code&gt;POSIXlt&lt;/code&gt;. You will use this when
converting from character data to date/time. On the other hand, if you want to
convert date/time to character data, use any of the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;strftime()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;format()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;as.character()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The above functions will convert &lt;code&gt;POSIXct/POSIXlt&lt;/code&gt; to character. Let us start
with a simple example. The data we have been supplied has date/time as
character data and in the format &lt;code&gt;YYYYMMDD&lt;/code&gt; i.e. nothing separates the year,
month and date from each other. We will use &lt;code&gt;strptime()&lt;/code&gt; to convert this to an
object of class &lt;code&gt;POSIXlt&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rel_date &amp;lt;- strptime(&amp;quot;20191212&amp;quot;, format = &amp;quot;%Y%m%d&amp;quot;)
class(rel_date)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;POSIXlt&amp;quot; &amp;quot;POSIXt&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you have a basic knowledge of conversion specifications, you can use
&lt;code&gt;strptime()&lt;/code&gt; to convert character data to &lt;code&gt;POSIXlt&lt;/code&gt;. Let us quickly explore the
functions to convert date/time to character data before moving on to the
functions from lubridate.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rel_date_strf &amp;lt;- strftime(rel_date)
class(rel_date_strf)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;character&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rel_date_format &amp;lt;- format(rel_date)
class(rel_date_format)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;character&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rel_date_char &amp;lt;- as.character(rel_date)
class(rel_date_char)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;character&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, all the 3 functions converted date/time to character. Time to
move on and explore the lubridate package. We will start with an example in
which the release date is formatted in 3 different ways but they have one thing
in common i.e. the order in which the components appear. In all the 3 formats,
the year is followed by the month and then the date.&lt;/p&gt;
&lt;p&gt;To parse the release date, we will use &lt;code&gt;parse_date_time()&lt;/code&gt; from lubridate which
parses the input into &lt;code&gt;POSIXct&lt;/code&gt; objects.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;release_date &amp;lt;- c(&amp;quot;19-12-12&amp;quot;, &amp;quot;20191212&amp;quot;, &amp;quot;19-12 12&amp;quot;)
parse_date_time(release_date, &amp;quot;ymd&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2019-12-12 UTC&amp;quot; &amp;quot;2019-12-12 UTC&amp;quot; &amp;quot;2019-12-12 UTC&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;parse_date_time(release_date, &amp;quot;y m d&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2019-12-12 UTC&amp;quot; &amp;quot;2019-12-12 UTC&amp;quot; &amp;quot;2019-12-12 UTC&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;parse_date_time(release_date, &amp;quot;%y%m%d&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2019-12-12 UTC&amp;quot; &amp;quot;2019-12-12 UTC&amp;quot; &amp;quot;2019-12-12 UTC&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Try to use &lt;code&gt;strptime()&lt;/code&gt; in the above example and see what happens. Now, let us
look at another data set.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;release_date &amp;lt;- c(&amp;quot;19-07-05&amp;quot;, &amp;quot;2019-07-05&amp;quot;, &amp;quot;05-07-2019&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What happens in the below case? The same date appears in multiple formats. How
do we parse them? &lt;code&gt;parse_date_time()&lt;/code&gt; allows us to specify mutiple date-time
formats. Let us first map the dates to their formats.&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Date
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Specification
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
19-07-05
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;ymd&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2019-07-05
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;ymd&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
05-07-2019
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;dmy&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The above specifications can be supplied as a character vector.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;parse_date_time(release_date, c(&amp;quot;ymd&amp;quot;, &amp;quot;ymd&amp;quot;, &amp;quot;dmy&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2019-07-05 UTC&amp;quot; &amp;quot;2019-07-05 UTC&amp;quot; &amp;quot;2019-07-05 UTC&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Great! We have used both &lt;code&gt;strptime()&lt;/code&gt; and &lt;code&gt;parse_date_time()&lt;/code&gt; now. Can you tell
what differentiates &lt;code&gt;parse_date_time()&lt;/code&gt; when compared to &lt;code&gt;strptime()&lt;/code&gt;? We
summarize it in the points below:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;no need to include &lt;code&gt;%&lt;/code&gt; prefix or separator&lt;/li&gt;
&lt;li&gt;specify several date/time formats&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There are other helper functions that can be used to&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;parse dates with only year, month, day components&lt;/li&gt;
&lt;li&gt;parse dates with year, month, day, hour, minute, seconds components&lt;/li&gt;
&lt;li&gt;parse dates with only hour, minute, second components&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;and are explored in the below examples.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# year/month/date
ymd(&amp;quot;2019-12-12&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2019-12-12&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# year/month/date
ymd(&amp;quot;19/12/12&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2019-12-12&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# date/month/year
dmy(121219)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2019-12-12&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# year/month/date/hour/minute/second
ymd_hms(191212080503)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2019-12-12 08:05:03 UTC&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# hour/minute/second
hms(&amp;quot;8, 5, 3&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;8H 5M 3S&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# hour/minute/second
hms(&amp;quot;08:05:03&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;8H 5M 3S&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# minute/second
ms(&amp;quot;5,3&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;5M 3S&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# hour/minute
hm(&amp;quot;8, 5&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;8H 5M 0S&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note, in a couple of cases where the components are not separated by &lt;code&gt;/&lt;/code&gt;, &lt;code&gt;-&lt;/code&gt; or
space, we have not enclosed the values in quotes.&lt;/p&gt;
&lt;div id=&#34;your-turn-5&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Your Turn&lt;/h3&gt;
&lt;p&gt;Below, we have specified &lt;code&gt;July 5th, 2019&lt;/code&gt; in different ways. Parse the dates using &lt;code&gt;strptime()&lt;/code&gt; or &lt;code&gt;parse_date_time()&lt;/code&gt; or any other helper function.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;July-05-19&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;JUL-05-19&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;05.07.19&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;5-July 2019&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;July 5th, 2019&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;July 05, 2019&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;2019-July- 05&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;05/07/2019&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;07/05/2019&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;7/5/2019&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;07/5/19&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;2019-07-05&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;components&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Date &amp;amp; Time Components&lt;/h2&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/88iUo0Z06ZI&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;p&gt;In the second section, we discussed the downside of saving date/time as
character/string in R. One of the points we discussed was that we can’t extract
components such as year, month, day etc. In this section, we will learn to
extract date/time components such as&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;year&lt;/li&gt;
&lt;li&gt;month&lt;/li&gt;
&lt;li&gt;date&lt;/li&gt;
&lt;li&gt;week&lt;/li&gt;
&lt;li&gt;day&lt;/li&gt;
&lt;li&gt;quarter&lt;/li&gt;
&lt;li&gt;semester&lt;/li&gt;
&lt;li&gt;hour&lt;/li&gt;
&lt;li&gt;minute&lt;/li&gt;
&lt;li&gt;second&lt;/li&gt;
&lt;li&gt;timezone&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/day_week_month.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The below table outlines the functions we will explore in the first part of this
section.&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Function
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;year()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Get year
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;month()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Get month (number)
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;month(label = TRUE)&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Get month (abbreviated name)
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;month(abbr = FALSE)&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Get month (full name)
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;months()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Get month
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;week()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Get week
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;div id=&#34;year&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Year&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;release_date &amp;lt;- ymd_hms(&amp;quot;2019-12-12 08:05:03&amp;quot;)
year(release_date) &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 2019&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;month&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Month&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;month()&lt;/code&gt; will return the month as a number i.e. &lt;code&gt;12&lt;/code&gt; for December.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;month(release_date)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 12&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Instead, if you want the name of the month , use the &lt;code&gt;label&lt;/code&gt; argument and set it
to &lt;code&gt;TRUE&lt;/code&gt;. Now it returns &lt;code&gt;Dec&lt;/code&gt; instead of &lt;code&gt;12&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;month(release_date, label = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] Dec
## 12 Levels: Jan &amp;lt; Feb &amp;lt; Mar &amp;lt; Apr &amp;lt; May &amp;lt; Jun &amp;lt; Jul &amp;lt; Aug &amp;lt; Sep &amp;lt; ... &amp;lt; Dec&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But this is the abbreviated name and not the full name. How do we get the full
name of the month? Set the &lt;code&gt;abbr&lt;/code&gt; argument to &lt;code&gt;FALSE&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;month(release_date, label = TRUE, abbr  = FALSE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] December
## 12 Levels: January &amp;lt; February &amp;lt; March &amp;lt; April &amp;lt; May &amp;lt; June &amp;lt; ... &amp;lt; December&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ah! now we can see the full name of the month. &lt;code&gt;months()&lt;/code&gt; from base R will
return the full name of the month by default. If you want the abbreviated name,
use the &lt;code&gt;abbreviate&lt;/code&gt; argument and set it to &lt;code&gt;TRUE&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;months(release_date)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;December&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;week&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Week&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;week()&lt;/code&gt; returns the number of complete 7 day periods between the date and 1st
January plus one.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;week(release_date)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 50&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;day&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Day&lt;/h3&gt;
&lt;p&gt;Use &lt;code&gt;day()&lt;/code&gt; to extract the date component. There are other variations such as&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Function
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;day&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Get day
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;mday()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Day of the month
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;wday()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Day of the week
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;qday()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Day of quarter
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;yday()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Day of year
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;weekdays()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Day of week
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;days_in_month()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Days in the month
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;day(release_date)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 12&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mday(release_date)                 &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 12&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;qday(release_date)                 &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 73&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;yday(release_date)                 &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 346&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;wday&lt;/code&gt; can return&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a number&lt;/li&gt;
&lt;li&gt;abbreviation of the weekday&lt;/li&gt;
&lt;li&gt;full name of the weekday&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;wday(release_date)  &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 5&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;wday(release_date, label = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] Thu
## Levels: Sun &amp;lt; Mon &amp;lt; Tue &amp;lt; Wed &amp;lt; Thu &amp;lt; Fri &amp;lt; Sat&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;wday(release_date, label = TRUE, abbr  = FALSE)  &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] Thursday
## 7 Levels: Sunday &amp;lt; Monday &amp;lt; Tuesday &amp;lt; Wednesday &amp;lt; Thursday &amp;lt; ... &amp;lt; Saturday&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;weekdays()&lt;/code&gt; from base R also returns the day of the week (the name and not
the number). If you want the abbreviated name, use the &lt;code&gt;abbreviate&lt;/code&gt; argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;weekdays(release_date)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Thursday&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;weekdays(release_date, abbreviate = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Thu&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;days-in-month&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Days in Month&lt;/h3&gt;
&lt;p&gt;If you want to know the number of days in the month, use &lt;code&gt;days_in_month()&lt;/code&gt;.
In our example, the month is December and it has 31 days.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;days_in_month(release_date)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Dec 
##  31&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;hour-minute-seconds&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Hour, Minute &amp;amp; Seconds&lt;/h3&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Function
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;hour()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Get hour
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;minute()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Get minute
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;second()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Get second
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;seconds()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Number of seconds since &lt;code&gt;1970-01-01&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;So far we have been looking at date components. Now, let us look at time
components.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;hour(release_date)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 8&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;minute(release_date)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 5&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;second(release_date)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;seconds()&lt;/code&gt; returns the number of seconds since &lt;code&gt;1970-01-01&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;seconds(release_date)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;1576137903S&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;quarter-semester&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Quarter &amp;amp; Semester&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/quarter_semester.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;quarter()&lt;/code&gt; will return the quarter from the date. December is in the 4th
quarter and hence it returns 4.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;quarter(release_date)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 4&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you want the year along with the quarter, set the &lt;code&gt;with_year&lt;/code&gt; argument to
&lt;code&gt;TRUE&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;quarter(release_date, with_year = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 2019.4&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In India, the fiscal starts in April and December falls in the 3rd quarter. How
can we accommodate this change? The &lt;code&gt;fiscal_start&lt;/code&gt; argument allows us to set the
month in which the fiscal begins. We will set it to 4 for April. Now it returns
3 instead of 4.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;quarter(release_date, fiscal_start = 4)    &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;quarters()&lt;/code&gt; from base R also returns the quarter.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;quarters(release_date)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Q4&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Function
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;quarter()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Get quarter
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;quarter(with_year = TRUE)&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Quarter with year
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;quarter(fiscal_start = 4)&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Fiscal starts in April
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;quarters()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Get quarter
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;semester()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Get semester
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;div id=&#34;case-study-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Case Study&lt;/h3&gt;
&lt;div id=&#34;extract-date-month-year-from-due-date&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Extract Date, Month &amp;amp; Year from Due Date&lt;/h4&gt;
&lt;p&gt;Let us now extract the date, month and year from the &lt;code&gt;Due&lt;/code&gt; column.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;transact %&amp;gt;%
  mutate(
    due_day   = day(Due),
    due_month = month(Due),
    due_year  = year(Due)
  )&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 2,466 x 6
##    Invoice    Due        Payment    due_day due_month due_year
##    &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;       &amp;lt;int&amp;gt;     &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt;
##  1 2013-01-02 2013-02-01 2013-01-15       1         2     2013
##  2 2013-01-26 2013-02-25 2013-03-03      25         2     2013
##  3 2013-07-03 2013-08-02 2013-07-08       2         8     2013
##  4 2013-02-10 2013-03-12 2013-03-17      12         3     2013
##  5 2012-10-25 2012-11-24 2012-11-28      24        11     2012
##  6 2012-01-27 2012-02-26 2012-02-22      26         2     2012
##  7 2013-08-13 2013-09-12 2013-09-09      12         9     2013
##  8 2012-12-16 2013-01-15 2013-01-12      15         1     2013
##  9 2012-05-14 2012-06-13 2012-07-01      13         6     2012
## 10 2013-07-01 2013-07-31 2013-07-26      31         7     2013
## # ... with 2,456 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;data-sanitization&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Data Sanitization&lt;/h4&gt;
&lt;p&gt;Let us do some data sanitization. If the due day happens to be February 29,
let us ensure that the due year is a leap year. Below are the steps to check
if the due year is a leap year:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;we will extract the following from the due date:
&lt;ul&gt;
&lt;li&gt;day&lt;/li&gt;
&lt;li&gt;month&lt;/li&gt;
&lt;li&gt;year&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;we will then create a new column &lt;code&gt;is_leap&lt;/code&gt; which will have be set to &lt;code&gt;TRUE&lt;/code&gt; if
the year is a leap year else it will be set to &lt;code&gt;FALSE&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;filter all the payments due on 29th Feb&lt;/li&gt;
&lt;li&gt;select the following columns:
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Due&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;is_leap&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;transact %&amp;gt;%
  mutate(
    due_day   = day(Due),
    due_month = month(Due),
    due_year  = year(Due),
    is_leap   = leap_year(due_year)
  ) %&amp;gt;%
  filter(due_month == 2 &amp;amp; due_day == 29) %&amp;gt;%
  select(Due, is_leap) &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 4 x 2
##   Due        is_leap
##   &amp;lt;date&amp;gt;     &amp;lt;lgl&amp;gt;  
## 1 2012-02-29 TRUE   
## 2 2012-02-29 TRUE   
## 3 2012-02-29 TRUE   
## 4 2012-02-29 TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;invoices-distribution-by-quarter&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Invoices Distribution by Quarter&lt;/h4&gt;
&lt;p&gt;Let us count the invoices due for each quarter.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;transact %&amp;gt;%
  mutate(
    quarter_due = quarter(Due)
  ) %&amp;gt;%
  count(quarter_due)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 4 x 2
##   quarter_due     n
## *       &amp;lt;int&amp;gt; &amp;lt;int&amp;gt;
## 1           1   521
## 2           2   661
## 3           3   618
## 4           4   666&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;your-turn-6&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Your Turn&lt;/h3&gt;
&lt;p&gt;Get the R release dates using &lt;code&gt;r_versions()&lt;/code&gt; from the &lt;strong&gt;rversions&lt;/strong&gt; package and
tabulate the following&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;year&lt;/li&gt;
&lt;li&gt;month with label&lt;/li&gt;
&lt;li&gt;weekday with label&lt;/li&gt;
&lt;li&gt;hour&lt;/li&gt;
&lt;li&gt;and quarter&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;createupdate&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Create, Update &amp;amp; Verify&lt;/h2&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/agGDD-xbtDo&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;p&gt;In the second section, we learnt to create date-time objects using &lt;code&gt;as.Date()&lt;/code&gt;,
&lt;code&gt;as.POSIXct()&lt;/code&gt; etc. In this section, we will explore a few other functions that
will allow us to do the same&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;make_date()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;make_datetime()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;create&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Create&lt;/h3&gt;
&lt;p&gt;To create date without time components, use &lt;code&gt;make_date()&lt;/code&gt; and specify the
following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;year&lt;/li&gt;
&lt;li&gt;month&lt;/li&gt;
&lt;li&gt;date&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We need to specify all the components in numbers i.e. we cannot use &lt;code&gt;Dec&lt;/code&gt; or
&lt;code&gt;December&lt;/code&gt; for the month. It has to be &lt;code&gt;12&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;make_date(year  = 2019,
          month = 12,
          day   = 12)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2019-12-12&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When you need to include time components, use &lt;code&gt;make_datetime()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;make_datetime(year  = 2019,
              month = 12,
              day   = 12,
              hour  = 08,
              min   = 05,
              sec   = 03,
              tz    = &amp;quot;UTC&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2019-12-12 08:05:03 UTC&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;update&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Update&lt;/h3&gt;
&lt;p&gt;Let us look at another scenario. You have a date-time object and want to change
one of its components i.e. any of the following&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;year&lt;/li&gt;
&lt;li&gt;month&lt;/li&gt;
&lt;li&gt;date&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Instead of creating another date-time object, you can change any of the
components using &lt;code&gt;update()&lt;/code&gt;. In the below example, we will start with the date
of release of R version 3.6.1 and using &lt;code&gt;update()&lt;/code&gt;, we will change it to
&lt;code&gt;2019-12-12&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;prev_release &amp;lt;- ymd(&amp;quot;2019-07-05&amp;quot;)
prev_release %&amp;gt;% 
  update(year  = 2019,
         month = 12,
         mday  = 12)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2019-12-12&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;date-sequence&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Date Sequence&lt;/h3&gt;
&lt;p&gt;So far we have created a single date-time instance. How about creating a
sequence of dates? We can do that using &lt;code&gt;seq.Date()&lt;/code&gt;. We need to specify the
from date as the bare minimum input. If the end date is not specified, it will
create the sequence uptil the current date.&lt;/p&gt;
&lt;p&gt;The interval of the sequence can be specified in any of the following units:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;day&lt;/li&gt;
&lt;li&gt;week&lt;/li&gt;
&lt;li&gt;month&lt;/li&gt;
&lt;li&gt;quarter&lt;/li&gt;
&lt;li&gt;year&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We can add the following to the interval units&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;integer&lt;/li&gt;
&lt;li&gt;&lt;code&gt;+&lt;/code&gt; / &lt;code&gt;-&lt;/code&gt; (increment or decrement)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Using the integer, we can specify multiples of the units mentioned and using the
sign, we can specify whether to increment or decrement.&lt;/p&gt;
&lt;p&gt;The below table displays the main arguments used in &lt;code&gt;seq.Date()&lt;/code&gt;:&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Function
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;from&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Starting date of the sequence
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;by&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
End date of the sequence
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;to&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Date increment of the sequence
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;length.out&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Length of the sequence
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;along.with&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Use length of this value as length of sequence
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;In the first example, we will create a sequence of dates from &lt;code&gt;2010-01-01&lt;/code&gt; to
&lt;code&gt;2019-12-31&lt;/code&gt;. The unit of increment should be a year i.e. the difference
between the dates in the sequence should be 1 year, specified using the &lt;code&gt;by&lt;/code&gt;
argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;seq.Date(from = as.Date(&amp;quot;2010-01-01&amp;quot;), to = as.Date(&amp;quot;2019-12-31&amp;quot;), by = &amp;quot;year&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;2010-01-01&amp;quot; &amp;quot;2011-01-01&amp;quot; &amp;quot;2012-01-01&amp;quot; &amp;quot;2013-01-01&amp;quot; &amp;quot;2014-01-01&amp;quot;
##  [6] &amp;quot;2015-01-01&amp;quot; &amp;quot;2016-01-01&amp;quot; &amp;quot;2017-01-01&amp;quot; &amp;quot;2018-01-01&amp;quot; &amp;quot;2019-01-01&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the next example, we change the unit of increment to a quarter i.e. the
difference between the dates in the sequence should be a quarter or 3 months.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;seq.Date(from = as.Date(&amp;quot;2009-12-12&amp;quot;), to = as.Date(&amp;quot;2019-12-12&amp;quot;), by = &amp;quot;quarter&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;2009-12-12&amp;quot; &amp;quot;2010-03-12&amp;quot; &amp;quot;2010-06-12&amp;quot; &amp;quot;2010-09-12&amp;quot; &amp;quot;2010-12-12&amp;quot;
##  [6] &amp;quot;2011-03-12&amp;quot; &amp;quot;2011-06-12&amp;quot; &amp;quot;2011-09-12&amp;quot; &amp;quot;2011-12-12&amp;quot; &amp;quot;2012-03-12&amp;quot;
## [11] &amp;quot;2012-06-12&amp;quot; &amp;quot;2012-09-12&amp;quot; &amp;quot;2012-12-12&amp;quot; &amp;quot;2013-03-12&amp;quot; &amp;quot;2013-06-12&amp;quot;
## [16] &amp;quot;2013-09-12&amp;quot; &amp;quot;2013-12-12&amp;quot; &amp;quot;2014-03-12&amp;quot; &amp;quot;2014-06-12&amp;quot; &amp;quot;2014-09-12&amp;quot;
## [21] &amp;quot;2014-12-12&amp;quot; &amp;quot;2015-03-12&amp;quot; &amp;quot;2015-06-12&amp;quot; &amp;quot;2015-09-12&amp;quot; &amp;quot;2015-12-12&amp;quot;
## [26] &amp;quot;2016-03-12&amp;quot; &amp;quot;2016-06-12&amp;quot; &amp;quot;2016-09-12&amp;quot; &amp;quot;2016-12-12&amp;quot; &amp;quot;2017-03-12&amp;quot;
## [31] &amp;quot;2017-06-12&amp;quot; &amp;quot;2017-09-12&amp;quot; &amp;quot;2017-12-12&amp;quot; &amp;quot;2018-03-12&amp;quot; &amp;quot;2018-06-12&amp;quot;
## [36] &amp;quot;2018-09-12&amp;quot; &amp;quot;2018-12-12&amp;quot; &amp;quot;2019-03-12&amp;quot; &amp;quot;2019-06-12&amp;quot; &amp;quot;2019-09-12&amp;quot;
## [41] &amp;quot;2019-12-12&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We will now create a sequence of dates but instead of specifying the unit of
increment, we specify the number of dates in the sequence i.e. the length of the
sequence. We do this using the &lt;code&gt;length.out&lt;/code&gt; argument which specifies the desired
length of the sequence. We want the sequence to have 10 dates including the
start and end date, and hence we supply the value &lt;code&gt;10&lt;/code&gt; for the &lt;code&gt;length.out&lt;/code&gt;
argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;seq.Date(from = as.Date(&amp;quot;2010-01-01&amp;quot;), to = as.Date(&amp;quot;2019-12-31&amp;quot;), length.out = 10)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;2010-01-01&amp;quot; &amp;quot;2011-02-10&amp;quot; &amp;quot;2012-03-22&amp;quot; &amp;quot;2013-05-02&amp;quot; &amp;quot;2014-06-11&amp;quot;
##  [6] &amp;quot;2015-07-22&amp;quot; &amp;quot;2016-08-31&amp;quot; &amp;quot;2017-10-10&amp;quot; &amp;quot;2018-11-20&amp;quot; &amp;quot;2019-12-31&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In all of the previous examples, we have specified both the start and the end
date. Let us look at a few examples where we create a sequence of dates where
we only specify the start date. In the below example, we want to create a
sequence of dates starting from &lt;code&gt;2010-01-01&lt;/code&gt;. The unit of increment should be 1
year i.e. the difference between the dates in the sequence should be 1 year and
the length of the sequence should be &lt;code&gt;10&lt;/code&gt; i.e. the number of dates including the
start date should be &lt;code&gt;10&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;seq.Date(from = as.Date(&amp;quot;2010-01-01&amp;quot;), by = &amp;quot;year&amp;quot;, length.out = 10)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;2010-01-01&amp;quot; &amp;quot;2011-01-01&amp;quot; &amp;quot;2012-01-01&amp;quot; &amp;quot;2013-01-01&amp;quot; &amp;quot;2014-01-01&amp;quot;
##  [6] &amp;quot;2015-01-01&amp;quot; &amp;quot;2016-01-01&amp;quot; &amp;quot;2017-01-01&amp;quot; &amp;quot;2018-01-01&amp;quot; &amp;quot;2019-01-01&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The unit of increment can include multiples and &lt;code&gt;+/-&lt;/code&gt; sign i.e. it can be an
unit of increment or decrement. In the next example, we can increment the dates
in the sequence by &lt;code&gt;2&lt;/code&gt; i.e. the difference between the dates should be &lt;code&gt;2&lt;/code&gt;
instead of &lt;code&gt;1&lt;/code&gt;. This is achieved by specifying the unit of increment (multiple)
first followed by a space and then the unit. In our example, it is &lt;code&gt;2 year&lt;/code&gt;. As
you can see, the sequence now goes all the way till &lt;code&gt;2028&lt;/code&gt; and the gap between
the dates is 2 years.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;seq.Date(from = as.Date(&amp;quot;2010-01-01&amp;quot;), by = &amp;quot;2 year&amp;quot;, length.out = 10)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;2010-01-01&amp;quot; &amp;quot;2012-01-01&amp;quot; &amp;quot;2014-01-01&amp;quot; &amp;quot;2016-01-01&amp;quot; &amp;quot;2018-01-01&amp;quot;
##  [6] &amp;quot;2020-01-01&amp;quot; &amp;quot;2022-01-01&amp;quot; &amp;quot;2024-01-01&amp;quot; &amp;quot;2026-01-01&amp;quot; &amp;quot;2028-01-01&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us say instead of increment we want to decrement the dates i.e. the sequence
of dates will go backwards as shown in the next example. We achieve this by
using the &lt;code&gt;-&lt;/code&gt; sign along with the unit of decrement. The sequence of dates in
next example starts from &lt;code&gt;2010&lt;/code&gt; and goes back upto &lt;code&gt;1992&lt;/code&gt; and the difference
between the dates in 2 years.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;seq.Date(from = as.Date(&amp;quot;2010-01-01&amp;quot;), by = &amp;quot;-2 year&amp;quot;, length.out = 10)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;2010-01-01&amp;quot; &amp;quot;2008-01-01&amp;quot; &amp;quot;2006-01-01&amp;quot; &amp;quot;2004-01-01&amp;quot; &amp;quot;2002-01-01&amp;quot;
##  [6] &amp;quot;2000-01-01&amp;quot; &amp;quot;1998-01-01&amp;quot; &amp;quot;1996-01-01&amp;quot; &amp;quot;1994-01-01&amp;quot; &amp;quot;1992-01-01&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the last example, we will explore the &lt;code&gt;along.with&lt;/code&gt; argument. Here we have
supplied a vector which is a sequence of numbers from 1 to 10. The length of
this vector is 10 and the same length is used as the length of the sequence i.e. 
the length of value supplied to &lt;code&gt;along.with&lt;/code&gt; is also the length of the sequence.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;seq.Date(from = as.Date(&amp;quot;2010-01-01&amp;quot;), by = &amp;quot;-2 year&amp;quot;, along.with = 1:10)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;2010-01-01&amp;quot; &amp;quot;2008-01-01&amp;quot; &amp;quot;2006-01-01&amp;quot; &amp;quot;2004-01-01&amp;quot; &amp;quot;2002-01-01&amp;quot;
##  [6] &amp;quot;2000-01-01&amp;quot; &amp;quot;1998-01-01&amp;quot; &amp;quot;1996-01-01&amp;quot; &amp;quot;1994-01-01&amp;quot; &amp;quot;1992-01-01&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;verify-type&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Verify Type&lt;/h3&gt;
&lt;p&gt;How do you check if the data is a date-time object? You can do that using any
of the following from the lubridate package.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;is.Date()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;is.POSIXct()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;is.POSIXlt()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;is.Date(release_date)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;is.POSIXct(release_date)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;is.POSIXlt(release_date)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;your-turn-7&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Your Turn&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;R 2.0.0 was released on &lt;code&gt;2004-10-04 14:24:38&lt;/code&gt;. Create this date using both
&lt;code&gt;make_date()&lt;/code&gt; and &lt;code&gt;make_datetime()&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;R 3.0.0 was released on &lt;code&gt;2013-04-03 07:12:36&lt;/code&gt;. Update the date created in the
previous step to the above using &lt;code&gt;update()&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;intervals-duration-period&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Intervals, Duration &amp;amp; Period&lt;/h2&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/8LW7vSx4cew&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;p&gt;In this section, we will learn about&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;intervals&lt;/li&gt;
&lt;li&gt;duration&lt;/li&gt;
&lt;li&gt;and period&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;intervals&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Interval&lt;/h3&gt;
&lt;p&gt;An interval is a timespan defined by two date-times. Let us represent the length
of the course using &lt;code&gt;interval&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/course_interval.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;course_start    &amp;lt;- as_date(&amp;#39;2017-04-12&amp;#39;)
course_end      &amp;lt;- as_date(&amp;#39;2017-04-21&amp;#39;)
interval(course_start, course_end)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 2017-04-12 UTC--2017-04-21 UTC&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you observe carefully, the interval is represented by the course start and
end dates. We will learn how to use intervals in the case study.&lt;/p&gt;
&lt;div id=&#34;overlapping-intervals&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Overlapping Intervals&lt;/h4&gt;
&lt;p&gt;Let us say you are planning a vacation and want to check if the vacation
dates overlap with the course dates. You can do this by:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;creating vacation and course intervals&lt;/li&gt;
&lt;li&gt;use &lt;code&gt;int_overlaps()&lt;/code&gt; to check if two intervals overlap. It returns &lt;code&gt;TRUE&lt;/code&gt;
if the intervals overlap else &lt;code&gt;FALSE&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let us use the vacation start and end dates to create &lt;code&gt;vacation_interval&lt;/code&gt;
and then check if it overlaps with &lt;code&gt;course_interval&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/interval_overlap.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vacation_start    &amp;lt;- as_date(&amp;#39;2017-04-19&amp;#39;)
vacation_end      &amp;lt;- as_date(&amp;#39;2017-04-25&amp;#39;)
course_interval   &amp;lt;- interval(course_start, course_end)
vacation_interval &amp;lt;- interval(vacation_start, vacation_end)
int_overlaps(course_interval, vacation_interval)
## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;how-many-invoices-were-settled-within-due-date&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;How many invoices were settled within due date?&lt;/h4&gt;
&lt;p&gt;Let us use intervals to count the number of invoices that were settled within
the due date. To do this, we will:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;create an interval for the invoice and due date&lt;/li&gt;
&lt;li&gt;create a new column &lt;code&gt;due_next&lt;/code&gt; by incrementing the due date by 1 day&lt;/li&gt;
&lt;li&gt;another interval for &lt;code&gt;due_next&lt;/code&gt; and the payment date&lt;/li&gt;
&lt;li&gt;if the intervals overlap, the payment was made within the due date&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;transact %&amp;gt;%
  mutate(
    inv_due_interval = interval(Invoice, Due),
    due_next         = Due + days(1),
    due_pay_interval = interval(due_next, Payment),
    overlaps         = int_overlaps(inv_due_interval, due_pay_interval)
  ) %&amp;gt;%
  select(Invoice, Due, Payment, overlaps)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 2,466 x 4
##    Invoice    Due        Payment    overlaps
##    &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;     &amp;lt;lgl&amp;gt;   
##  1 2013-01-02 2013-02-01 2013-01-15 TRUE    
##  2 2013-01-26 2013-02-25 2013-03-03 FALSE   
##  3 2013-07-03 2013-08-02 2013-07-08 TRUE    
##  4 2013-02-10 2013-03-12 2013-03-17 FALSE   
##  5 2012-10-25 2012-11-24 2012-11-28 FALSE   
##  6 2012-01-27 2012-02-26 2012-02-22 TRUE    
##  7 2013-08-13 2013-09-12 2013-09-09 TRUE    
##  8 2012-12-16 2013-01-15 2013-01-12 TRUE    
##  9 2012-05-14 2012-06-13 2012-07-01 FALSE   
## 10 2013-07-01 2013-07-31 2013-07-26 TRUE    
## # ... with 2,456 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Below we show another method to count the number of invoices paid within the
due date. Instead of using &lt;code&gt;days&lt;/code&gt; to change the due date, we use &lt;code&gt;int_shift&lt;/code&gt;
to shift it by 1 day.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;transact %&amp;gt;%
  mutate(
    inv_due_interval = interval(Invoice, Due),
    due_pay_interval = interval(Due, Payment),  
    due_pay_next     = int_shift(due_pay_interval, by = days(1)),
    overlaps         = int_overlaps(inv_due_interval, due_pay_next)
  ) %&amp;gt;%
  select(Invoice, Due, Payment, overlaps)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 2,466 x 4
##    Invoice    Due        Payment    overlaps
##    &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;     &amp;lt;lgl&amp;gt;   
##  1 2013-01-02 2013-02-01 2013-01-15 TRUE    
##  2 2013-01-26 2013-02-25 2013-03-03 FALSE   
##  3 2013-07-03 2013-08-02 2013-07-08 TRUE    
##  4 2013-02-10 2013-03-12 2013-03-17 FALSE   
##  5 2012-10-25 2012-11-24 2012-11-28 FALSE   
##  6 2012-01-27 2012-02-26 2012-02-22 TRUE    
##  7 2013-08-13 2013-09-12 2013-09-09 TRUE    
##  8 2012-12-16 2013-01-15 2013-01-12 TRUE    
##  9 2012-05-14 2012-06-13 2012-07-01 FALSE   
## 10 2013-07-01 2013-07-31 2013-07-26 TRUE    
## # ... with 2,456 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You might be thinking why we incremented the due date by a day before creating
the interval between the due day and the payment day. If we do not increment,
both the intervals will share a common date i.e. the due date and they will
always overlap as shown below:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;transact %&amp;gt;%
  mutate(
    inv_due_interval = interval(Invoice, Due),
    due_pay_interval = interval(Due, Payment),
    overlaps         = int_overlaps(inv_due_interval, due_pay_interval)
  ) %&amp;gt;%
  select(Invoice, Due, Payment, overlaps)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 2,466 x 4
##    Invoice    Due        Payment    overlaps
##    &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;     &amp;lt;lgl&amp;gt;   
##  1 2013-01-02 2013-02-01 2013-01-15 TRUE    
##  2 2013-01-26 2013-02-25 2013-03-03 TRUE    
##  3 2013-07-03 2013-08-02 2013-07-08 TRUE    
##  4 2013-02-10 2013-03-12 2013-03-17 TRUE    
##  5 2012-10-25 2012-11-24 2012-11-28 TRUE    
##  6 2012-01-27 2012-02-26 2012-02-22 TRUE    
##  7 2013-08-13 2013-09-12 2013-09-09 TRUE    
##  8 2012-12-16 2013-01-15 2013-01-12 TRUE    
##  9 2012-05-14 2012-06-13 2012-07-01 TRUE    
## 10 2013-07-01 2013-07-31 2013-07-26 TRUE    
## # ... with 2,456 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;shift-interval&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Shift Interval&lt;/h4&gt;
&lt;p&gt;Intervals can be shifted too. In the below example, we shift the course
interval by:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;1 day&lt;/li&gt;
&lt;li&gt;3 weeks&lt;/li&gt;
&lt;li&gt;1 year&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/shift_interval.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;course_interval &amp;lt;- interval(course_start, course_end)

# shift course_interval by 1 day 
int_shift(course_interval, by = days(1))
## [1] 2017-04-13 UTC--2017-04-22 UTC

# shift course_interval by 3 weeks
int_shift(course_interval, by = weeks(3))
## [1] 2017-05-03 UTC--2017-05-12 UTC

# shift course_interval by 1 year
int_shift(course_interval, by = years(1))
## [1] 2018-04-12 UTC--2018-04-21 UTC&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;within&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Within&lt;/h3&gt;
&lt;p&gt;Let us assume that we have to attend a conference in April 2017. Does it
clash with the course? We can answer this using &lt;code&gt;%within%&lt;/code&gt; which will
return &lt;code&gt;TRUE&lt;/code&gt; if a date falls within an interval.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/within.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;conference &amp;lt;- as_date(&amp;#39;2017-04-15&amp;#39;)
conference %within% course_interval
## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;how-many-invoices-were-settled-within-due-date-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;How many invoices were settled within due date?&lt;/h4&gt;
&lt;p&gt;Let us use &lt;code&gt;%within%&lt;/code&gt; to count the number of invoices that were settled within
the due date. We will do this by:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;creating an interval for the invoice and due date&lt;/li&gt;
&lt;li&gt;check if the payment date falls within the above interval&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;transact %&amp;gt;%
  mutate(
    inv_due_interval = interval(Invoice, Due),
    overlaps         = Payment %within% inv_due_interval
  ) %&amp;gt;%
  select(Due, Payment, overlaps)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 2,466 x 3
##    Due        Payment    overlaps
##    &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;     &amp;lt;lgl&amp;gt;   
##  1 2013-02-01 2013-01-15 TRUE    
##  2 2013-02-25 2013-03-03 FALSE   
##  3 2013-08-02 2013-07-08 TRUE    
##  4 2013-03-12 2013-03-17 FALSE   
##  5 2012-11-24 2012-11-28 FALSE   
##  6 2012-02-26 2012-02-22 TRUE    
##  7 2013-09-12 2013-09-09 TRUE    
##  8 2013-01-15 2013-01-12 TRUE    
##  9 2012-06-13 2012-07-01 FALSE   
## 10 2013-07-31 2013-07-26 TRUE    
## # ... with 2,456 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;duration&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Duration&lt;/h3&gt;
&lt;p&gt;Duration is timespan measured in seconds. To create a duration object, use
&lt;code&gt;duration()&lt;/code&gt;. The timespan can be anything from seconds to years but it will be
represented as seconds. Let us begin by creating a duration object where the timespan is in seconds.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;duration(50, &amp;quot;seconds&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;50s&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Another way to specify the above timespan is shown below:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;duration(second = 50)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;50s&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, the output is same in both the cases. Let us increase the timespan to 60 seconds and see what happens.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;duration(second = 60)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;60s (~1 minutes)&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Although the timespan is primarily measured in seconds, it also shows &lt;code&gt;~1 minutes&lt;/code&gt; in the brackets. As the length of the timespan increases i.e. the number becomes large, it is represented using larger units such as hours and days. In the below examples, as the number of seconds increases, you can observe larger units being used to represent the timespan.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# minutes
duration(minute = 50)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;3000s (~50 minutes)&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;duration(minute = 60)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;3600s (~1 hours)&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# hours
duration(hour = 23)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;82800s (~23 hours)&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;duration(hour = 24)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;86400s (~1 days)&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The following helper functions can be used to create duration objects as well.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# default
dseconds()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;1s&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dminutes()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;60s (~1 minutes)&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# seconds
duration(second = 59)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;59s&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dseconds(59)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;59s&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# minutes
duration(minute = 50)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;3000s (~50 minutes)&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dminutes(50)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;3000s (~50 minutes)&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# hours
duration(hour = 36)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;129600s (~1.5 days)&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dhours(36)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;129600s (~1.5 days)&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# weeks
duration(week = 56)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;33868800s (~1.07 years)&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dweeks(56)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;33868800s (~1.07 years)&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us use the above helper functions to get the course length in different units.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/convert.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# course length in seconds 
course_interval / dseconds()
## [1] 777600

# course length in minutes
course_interval / dminutes()
## [1] 12960

# course length in hours
course_interval / dhours()
## [1] 216

# course length in weeks
course_interval / dweeks()
## [1] 1.285714

# course length in years
course_interval / dyears()
## [1] 0.02464066&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;period&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Period&lt;/h3&gt;
&lt;p&gt;A &lt;code&gt;period&lt;/code&gt; is a timespan defined in units such as years, months, and days. In
the below examples, we use &lt;code&gt;period()&lt;/code&gt; to represent timespan using different
units.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# second
period(5, &amp;quot;second&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;5S&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;period(second = 5)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;5S&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# minute &amp;amp; second
period(c(3, 5), c(&amp;quot;minute&amp;quot;, &amp;quot;second&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;3M 5S&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;period(minute = 3, second = 5)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;3M 5S&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# hour, minte &amp;amp; second
period(c(1, 3, 5), c(&amp;quot;hour&amp;quot;, &amp;quot;minute&amp;quot;, &amp;quot;second&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;1H 3M 5S&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;period(hour = 1, minute = 3, second = 5)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;1H 3M 5S&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# day, hour, minute &amp;amp; second
period(c(3, 1, 3, 5), c(&amp;quot;day&amp;quot;, &amp;quot;hour&amp;quot;, &amp;quot;minute&amp;quot;, &amp;quot;second&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;3d 1H 3M 5S&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;period(day = 3, hour = 1, minute = 3, second = 5)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;3d 1H 3M 5S&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/as_period.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Let us get the course length in different units using &lt;code&gt;as.period()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# course length in second
as.period(course_interval, unit = &amp;quot;seconds&amp;quot;)
## [1] &amp;quot;777600S&amp;quot;

# course length in hours and minutes
as.period(course_interval, unit = &amp;quot;minutes&amp;quot;)
## [1] &amp;quot;12960M 0S&amp;quot;

# course length in hours, minutes and seconds
as.period(course_interval, unit = &amp;quot;hours&amp;quot;)
## [1] &amp;quot;216H 0M 0S&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;time_length()&lt;/code&gt; computes the exact length of a timespan i.e. &lt;code&gt;duration&lt;/code&gt;, &lt;code&gt;interval&lt;/code&gt; or &lt;code&gt;period&lt;/code&gt;. Let us use &lt;code&gt;time_length()&lt;/code&gt; to compute the length of the
course in different units.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/time_length.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# course length in seconds
time_length(course_interval, unit = &amp;quot;seconds&amp;quot;)
## [1] 777600

# course length in minutes
time_length(course_interval, unit = &amp;quot;minutes&amp;quot;)
## [1] 12960

# course length in hours
time_length(course_interval, unit = &amp;quot;hours&amp;quot;)
## [1] 216&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;others&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Round &amp;amp; Rollback&lt;/h2&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/ZI1s6XQgCbo&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;p&gt;In this section, we will learn to round date/time to the nearest unit and roll
back dates.&lt;/p&gt;
&lt;div id=&#34;rounding-dates&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Rounding Dates&lt;/h3&gt;
&lt;p&gt;We will explore functions for rounding dates&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;to the nearest value using &lt;code&gt;round_dates()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;down using &lt;code&gt;floor_date()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;up using &lt;code&gt;ceiling_date()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The unit for rounding can be any of the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;second&lt;/li&gt;
&lt;li&gt;minute&lt;/li&gt;
&lt;li&gt;hour&lt;/li&gt;
&lt;li&gt;day&lt;/li&gt;
&lt;li&gt;week&lt;/li&gt;
&lt;li&gt;month&lt;/li&gt;
&lt;li&gt;bimonth&lt;/li&gt;
&lt;li&gt;quarter&lt;/li&gt;
&lt;li&gt;season&lt;/li&gt;
&lt;li&gt;halfyear&lt;/li&gt;
&lt;li&gt;and year&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We will look at a few examples using &lt;code&gt;round_date()&lt;/code&gt; and you will then practice
using the other two functions.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# minute
round_date(release_date, unit = &amp;quot;minute&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2019-12-12 08:05:00 UTC&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;round_date(release_date, unit = &amp;quot;mins&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2019-12-12 08:05:00 UTC&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;round_date(release_date, unit = &amp;quot;5 mins&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2019-12-12 08:05:00 UTC&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# hour
round_date(release_date, unit = &amp;quot;hour&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2019-12-12 08:00:00 UTC&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# day
round_date(release_date, unit = &amp;quot;day&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2019-12-12 UTC&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;rollback&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Rollback&lt;/h3&gt;
&lt;p&gt;Use &lt;code&gt;rollback()&lt;/code&gt; if you want to change the date to the last day of the previous
month or the first day of the month.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rollback(release_date)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2019-11-30 08:05:03 UTC&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To change the date to the first day of the month, use the &lt;code&gt;roll_to_first&lt;/code&gt;
argument and set it to &lt;code&gt;TRUE&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rollback(release_date, roll_to_first = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2019-12-01 08:05:03 UTC&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;your-turn-8&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Your Turn&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;round up R release dates to hours&lt;/li&gt;
&lt;li&gt;round down R release dates to minutes&lt;/li&gt;
&lt;li&gt;rollback R release dates to the beginning of the month&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;references&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Readings &amp;amp; References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://lubridate.tidyverse.org/&#34; class=&#34;uri&#34;&gt;https://lubridate.tidyverse.org/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://r4ds.had.co.nz/dates-and-times.html&#34; class=&#34;uri&#34;&gt;https://r4ds.had.co.nz/dates-and-times.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://en.wikipedia.org/wiki/Daylight_saving_time&#34; class=&#34;uri&#34;&gt;https://en.wikipedia.org/wiki/Daylight_saving_time&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://en.wikipedia.org/wiki/Time_zone&#34; class=&#34;uri&#34;&gt;https://en.wikipedia.org/wiki/Time_zone&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.worldtimebuddy.com/&#34; class=&#34;uri&#34;&gt;https://www.worldtimebuddy.com/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://en.wikipedia.org/wiki/POSIX&#34; class=&#34;uri&#34;&gt;https://en.wikipedia.org/wiki/POSIX&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*As the reader of this blog, you are our most important critic and commentator.
We value your opinion and want to know what we are doing right, what we could
do better, what areas you would like to see us publish in, and any other words
of wisdom you are willing to pass our way.&lt;/p&gt;
&lt;p&gt;We welcome your comments. You can email to let us know what you did or did not
like about our blog as well as what we can do to make our post better.*&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Email: &lt;a href=&#34;mailto:support@rsquaredacademy.com&#34; class=&#34;email&#34;&gt;support@rsquaredacademy.com&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Date &amp; Time in R - Introduction</title>
      <link>https://blog.rsquaredacademy.com/handling-date-and-time-in-r-part-1/</link>
      <pubDate>Thu, 16 Apr 2020 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/handling-date-and-time-in-r-part-1/</guid>
      <description>&lt;script src=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/header-attrs/header-attrs.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/kePrint/kePrint.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/lightable/lightable.css&#34; rel=&#34;stylesheet&#34; /&gt;


&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/handling-date-and-time-in-r.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In this new series &lt;a href=&#34;https://tutorials.rsquaredacademy.com/date-time/index.html&#34;&gt;Handling Date &amp;amp; Time in R&lt;/a&gt;, we will learn to handle date &amp;amp; time in R. We will start off by learning how
to &lt;strong&gt;get current date &amp;amp; time&lt;/strong&gt; before moving on to understand &lt;strong&gt;how R handles date/time internally&lt;/strong&gt;
and the different classes such as &lt;code&gt;Date&lt;/code&gt; &amp;amp; &lt;code&gt;POSIXct/lt&lt;/code&gt;. We will spend some time
exploring &lt;strong&gt;time zones, daylight savings and ISO 8001 standard&lt;/strong&gt; for representing date/time.
We will look at all the &lt;strong&gt;weird formats in which date/time come in real world&lt;/strong&gt; and learn to
&lt;strong&gt;parse them using conversion specifications&lt;/strong&gt;. After this, we will also &lt;strong&gt;learn how to handle date/time
columns while reading external data into R&lt;/strong&gt;. We will learn to &lt;strong&gt;extract and update different date/time
components&lt;/strong&gt; such as year, month, day, hour, minute etc., &lt;strong&gt;create sequence of dates&lt;/strong&gt; in different ways
and explore intervals, durations and period. We will end the tutorial by learning how to &lt;strong&gt;round/rollback
dates&lt;/strong&gt;. Throughout the series, we will also &lt;strong&gt;work through a case study&lt;/strong&gt; to better understand the
concepts we learn. Happy learning!&lt;/p&gt;
&lt;div id=&#34;resources&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Resources&lt;/h2&gt;
&lt;p&gt;Below are the links to all the resources related to this tutorial:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://slides.rsquaredacademy.com/handling-date-and-time-in-r.pdf&#34; target=&#34;_blank&#34;&gt;Slides&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/rsquaredacademy-education/online-courses/&#34; target=&#34;_blank&#34;&gt;Code &amp;amp; Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://rstudio.cloud/project/1072419&#34; target=&#34;_blank&#34;&gt;RStudio Cloud Project&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://wrangle-r.rsquaredacademy.com/lubridate.html&#34; target=&#34;_blank&#34;&gt;ebook&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p align=&#34;center&#34;&gt;
&lt;a href=&#34;https://rsquared-academy.thinkific.com/courses/handling-date-and-time-in-R&#34; target=&#34;_blank&#34;&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/lubirdate-blog-course-ad.png&#34; width=&#34;100%&#34; alt=&#34;new courses ad&#34; style=&#34;text-decoration: none;&#34;&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;intro&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/322IcnZiYx4&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;div id=&#34;date&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Date&lt;/h3&gt;
&lt;p&gt;Let us begin by looking at the current date and time. &lt;code&gt;Sys.Date()&lt;/code&gt; and &lt;code&gt;today()&lt;/code&gt; will return the current date.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;Sys.Date()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2021-02-03&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;lubridate::today()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2021-02-03&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;time&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Time&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;Sys.time()&lt;/code&gt; and &lt;code&gt;now()&lt;/code&gt; return the date, time and the timezone. In &lt;code&gt;now()&lt;/code&gt;, we can specify the timezone using the &lt;code&gt;tzone&lt;/code&gt; argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;Sys.time()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2021-02-03 18:54:23 IST&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;lubridate::now()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2021-02-03 18:54:23 IST&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;lubridate::now(tzone = &amp;quot;UTC&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2021-02-03 13:24:23 UTC&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;am-or-pm&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;AM or PM?&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;am()&lt;/code&gt; and &lt;code&gt;pm()&lt;/code&gt; allow us to check whether date/time occur in the &lt;code&gt;AM&lt;/code&gt; or &lt;code&gt;PM&lt;/code&gt;? They return a logical value i.e. &lt;code&gt;TRUE&lt;/code&gt; or &lt;code&gt;FALSE&lt;/code&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;lubridate::am(now())&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;lubridate::pm(now())&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;leap-year&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Leap Year&lt;/h3&gt;
&lt;p&gt;We can also check if the current year is a leap year using &lt;code&gt;leap_year()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;Sys.Date()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2021-02-03&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;lubridate::leap_year(Sys.Date())&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Function
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;Sys.Date()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Current Date
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;lubridate::today()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Current Date
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;Sys.time()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Current Time
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;lubridate::now()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Current Time
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;lubridate::am()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Whether time occurs in am?
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;lubridate::pm()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Whether time occurs in pm?
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;lubridate::leap_year()&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Check if the year is a leap year?
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;div id=&#34;your-turn&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Your Turn&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;get current date&lt;/li&gt;
&lt;li&gt;get current time&lt;/li&gt;
&lt;li&gt;check whether the time occurs in am or pm?&lt;/li&gt;
&lt;li&gt;check whether the following years were leap years
&lt;ul&gt;
&lt;li&gt;2018&lt;/li&gt;
&lt;li&gt;2016&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;casestudy&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Case Study&lt;/h2&gt;
&lt;p&gt;Throughout the tutorial, we will work on a case study related to transactions of an imaginary trading company. The data set includes information about invoice and payment dates.&lt;/p&gt;
&lt;div id=&#34;data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;transact &amp;lt;- readr::read_csv(&amp;#39;https://raw.githubusercontent.com/rsquaredacademy/datasets/master/transact.csv&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 2,466 x 3
##    Invoice    Due        Payment   
##    &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;    
##  1 2013-01-02 2013-02-01 2013-01-15
##  2 2013-01-26 2013-02-25 2013-03-03
##  3 2013-07-03 2013-08-02 2013-07-08
##  4 2013-02-10 2013-03-12 2013-03-17
##  5 2012-10-25 2012-11-24 2012-11-28
##  6 2012-01-27 2012-02-26 2012-02-22
##  7 2013-08-13 2013-09-12 2013-09-09
##  8 2012-12-16 2013-01-15 2013-01-12
##  9 2012-05-14 2012-06-13 2012-07-01
## 10 2013-07-01 2013-07-31 2013-07-26
## # ... with 2,456 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We will explore more about reading data sets with date/time columns after learning how to
parse date/time. We have shared the code for reading the data sets used in the practice
questions both in the Learning Management System as well as in our GitHub repo.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data-dictionary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data Dictionary&lt;/h3&gt;
&lt;p&gt;The data set has 3 columns. All the dates are in the format (yyyy-mm-dd).&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Column
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Invoice
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Invoice Date
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Due
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Due Date
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Payment
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Payment Date
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;In the case study, we will try to answer a few questions we have about the &lt;code&gt;transact&lt;/code&gt; data.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;extract date, month and year from Due&lt;/li&gt;
&lt;li&gt;compute the number of days to settle invoice&lt;/li&gt;
&lt;li&gt;compute days over due&lt;/li&gt;
&lt;li&gt;check if due year is a leap year&lt;/li&gt;
&lt;li&gt;check when due day in february is 29, whether it is a leap year&lt;/li&gt;
&lt;li&gt;how many invoices were settled within due date&lt;/li&gt;
&lt;li&gt;how many invoices are due in each quarter&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*As the reader of this blog, you are our most important critic and commentator.
We value your opinion and want to know what we are doing right, what we could
do better, what areas you would like to see us publish in, and any other words
of wisdom you are willing to pass our way.&lt;/p&gt;
&lt;p&gt;We welcome your comments. You can email to let us know what you did or did not
like about our blog as well as what we can do to make our post better.*&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Email: &lt;a href=&#34;mailto:support@rsquaredacademy.com&#34; class=&#34;email&#34;&gt;support@rsquaredacademy.com&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Introducing nse2r</title>
      <link>https://blog.rsquaredacademy.com/nse2r-fetch-data-from-nse/</link>
      <pubDate>Fri, 17 Jan 2020 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/nse2r-fetch-data-from-nse/</guid>
      <description>&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/github_nse2r.png&#34; width=&#34;70%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;We are excited to announce the &lt;a href=&#34;https://nse2r.rsquaredacademy.com&#34;&gt;nse2r&lt;/a&gt; package. &lt;a href=&#34;https://www.nseindia.com/&#34;&gt;NSE&lt;/a&gt; (National Stock Exchange) is the leading stock exchange of India, located in the city of Mumbai. While users can manually download data from NSE through a browser, importing this data into R becomes cumbersome. The nse2r R package implements the retrieval of data from NSE and aims to reduce the pre-processing steps needed in analyzing such data.&lt;/p&gt;
&lt;p&gt;nse2r is inspired by and a port of the Python package &lt;a href=&#34;https://nsetools.readthedocs.io/en/latest/&#34;&gt;nsetools&lt;/a&gt;. The authors and contributors for this R package are not affiliated with NSE and NSE does not offer support for this R package.&lt;/p&gt;
&lt;p&gt;With nse2r, you can fetch the following data related to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;stocks
&lt;ul&gt;
&lt;li&gt;quote for a given stock&lt;/li&gt;
&lt;li&gt;stock description&lt;/li&gt;
&lt;li&gt;validate stock symbol/ticker&lt;/li&gt;
&lt;li&gt;most actively traded stocks in a month&lt;/li&gt;
&lt;li&gt;52 week high/low&lt;/li&gt;
&lt;li&gt;top gainers/losers for the last trading session&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;index
&lt;ul&gt;
&lt;li&gt;list of NSE indices&lt;/li&gt;
&lt;li&gt;validate index symbol/ticker&lt;/li&gt;
&lt;li&gt;quote for a given index&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;futures &amp;amp; options
&lt;ul&gt;
&lt;li&gt;top gainers/losers for the last trading session&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;pre open market data
&lt;ul&gt;
&lt;li&gt;nifty&lt;/li&gt;
&lt;li&gt;nifty bank&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;indices advances &amp;amp; declines&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;installation&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Installation&lt;/h2&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Install release version from CRAN
install.packages(&amp;quot;nse2r&amp;quot;)

# Install development version from GitHub
# install.packages(&amp;quot;devtools&amp;quot;)
devtools::install_github(&amp;quot;rsquaredacademy/nse2r&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;usage&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Usage&lt;/h2&gt;
&lt;p&gt;nse2r uses consistent prefix &lt;code&gt;nse_&lt;/code&gt; for easy tab completion.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;nse_index_&lt;/code&gt; for index&lt;/li&gt;
&lt;li&gt;&lt;code&gt;nse_stock_&lt;/code&gt; for stocks&lt;/li&gt;
&lt;li&gt;&lt;code&gt;nse_fo_&lt;/code&gt; for futures and options&lt;/li&gt;
&lt;li&gt;&lt;code&gt;nse_preopen_&lt;/code&gt; for preopen data&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;preprocessing&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Preprocessing&lt;/h2&gt;
&lt;p&gt;nse2r does basic data preprocessing which are listed below:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;modify column data types from &lt;code&gt;character&lt;/code&gt; to &lt;code&gt;numeric&lt;/code&gt; and &lt;code&gt;Date&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;modify column names
&lt;ul&gt;
&lt;li&gt;make them more descriptive&lt;/li&gt;
&lt;li&gt;to &lt;code&gt;snake_case&lt;/code&gt; from &lt;code&gt;camelCase&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Users can retain the names and format as returned by NSE using the &lt;code&gt;clean_names&lt;/code&gt; argument and setting it to &lt;code&gt;FALSE&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;quick-overview&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Quick Overview&lt;/h2&gt;
&lt;div id=&#34;fetch-indices-quote&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Fetch Indices Quote&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;nse_index_quote()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 55 x 4
##    index_name        last_traded_price change percent_change
##    &amp;lt;chr&amp;gt;                         &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;          &amp;lt;dbl&amp;gt;
##  1 NIFTY 50 Pre Open           10073.   26.0            0.26
##  2 NIFTY 50                    10116.   69.5            0.69
##  3 NIFTY NEXT 50               25154.   -8.9           -0.04
##  4 NIFTY100 LIQ 15              2587    17.3            0.67
##  5 NIFTY BANK                  21100.  375.             1.81
##  6 INDIA VIX                      29.4  -0.77          -2.54
##  7 NIFTY 100                   10292.   60.4            0.59
##  8 NIFTY 500                    8293.   55.2            0.67
##  9 NIFTY MIDCAP 100            14342   173.             1.22
## 10 NIFTY MIDCAP 50              3993.   52              1.32
## # ... with 45 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# retain original column names as returned by NSE
nse_index_quote(clean_names = FALSE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 55 x 4
##    name              lastPrice change pChange
##    &amp;lt;chr&amp;gt;                 &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;
##  1 NIFTY 50 Pre Open   10073.   26.0     0.26
##  2 NIFTY 50            10116.   69.5     0.69
##  3 NIFTY NEXT 50       25154.   -8.9    -0.04
##  4 NIFTY100 LIQ 15      2587    17.3     0.67
##  5 NIFTY BANK          21100.  375.      1.81
##  6 INDIA VIX              29.4  -0.77   -2.54
##  7 NIFTY 100           10292.   60.4     0.59
##  8 NIFTY 500            8293.   55.2     0.67
##  9 NIFTY MIDCAP 100    14342   173.      1.22
## 10 NIFTY MIDCAP 50      3993.   52       1.32
## # ... with 45 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;top-gainers-for-the-last-trading-session.&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Top gainers for the last trading session.&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;nse_stock_top_gainers()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 10 x 12
##    symbol series last_corp_annou~ last_corp_annou~ open_price high_price
##    &amp;lt;chr&amp;gt;  &amp;lt;chr&amp;gt;  &amp;lt;date&amp;gt;           &amp;lt;chr&amp;gt;                 &amp;lt;dbl&amp;gt;      &amp;lt;dbl&amp;gt;
##  1 INDUS~ EQ     2019-08-08       Annual General ~       464        510.
##  2 HINDA~ EQ     2019-08-14       Annual General ~       144.       148 
##  3 AXISB~ EQ     2019-07-04       Annual General ~       422.       433.
##  4 SHREE~ EQ     2020-02-24       Interim Dividen~     21171.     21611.
##  5 KOTAK~ EQ     2019-07-12       Annual General ~      1304.      1344.
##  6 RELIA~ EQ     2020-05-13       Rights 1:15 @ P~      1543.      1580.
##  7 SBIN   EQ     2018-06-15       Annual General ~       185.       189 
##  8 ICICI~ EQ     2019-07-22       Annual General ~       349.       357.
##  9 HDFC   EQ     2020-07-09       Annual General ~      1784       1820 
## 10 TCS    EQ     2020-06-03       Dividend - Rs 6~      2077.      2132 
## # ... with 6 more variables: low_price &amp;lt;dbl&amp;gt;, last_traded_price &amp;lt;dbl&amp;gt;,
## #   prev_close_price &amp;lt;dbl&amp;gt;, percent_change &amp;lt;dbl&amp;gt;, traded_quantity &amp;lt;dbl&amp;gt;,
## #   turnover_in_lakhs &amp;lt;dbl&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# retain original column names as returned by NSE
nse_stock_top_gainers(clean_names = FALSE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 10 x 12
##    symbol series lastCorpAnnounc~ lastCorpAnnounc~ openPrice highPrice lowPrice
##    &amp;lt;chr&amp;gt;  &amp;lt;chr&amp;gt;  &amp;lt;date&amp;gt;           &amp;lt;chr&amp;gt;                &amp;lt;dbl&amp;gt;     &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt;
##  1 INDUS~ EQ     2019-08-08       Annual General ~      464       510.     463.
##  2 HINDA~ EQ     2019-08-14       Annual General ~      144.      148      142.
##  3 AXISB~ EQ     2019-07-04       Annual General ~      422.      433.     415.
##  4 SHREE~ EQ     2020-02-24       Interim Dividen~    21171.    21611.   21150.
##  5 KOTAK~ EQ     2019-07-12       Annual General ~     1304.     1344.    1304.
##  6 RELIA~ EQ     2020-05-13       Rights 1:15 @ P~     1543.     1580.    1540.
##  7 SBIN   EQ     2018-06-15       Annual General ~      185.      189      184.
##  8 ICICI~ EQ     2019-07-22       Annual General ~      349.      357.     345.
##  9 HDFC   EQ     2020-07-09       Annual General ~     1784      1820     1782 
## 10 TCS    EQ     2020-06-03       Dividend - Rs 6~     2077.     2132     2074.
## # ... with 5 more variables: ltp &amp;lt;dbl&amp;gt;, previousPrice &amp;lt;dbl&amp;gt;, netPrice &amp;lt;dbl&amp;gt;,
## #   tradedQuantity &amp;lt;dbl&amp;gt;, turnoverInLakhs &amp;lt;dbl&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;stocks-that-have-touched-their-52-week-highs-during-the-day&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Stocks that have touched their 52 week highs during the day&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;nse_stock_year_high()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 34 x 10
##    symbol symbol_desc date       new_high   year last_traded_pri~ prev_high
##    &amp;lt;chr&amp;gt;  &amp;lt;chr&amp;gt;       &amp;lt;date&amp;gt;        &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;            &amp;lt;dbl&amp;gt;     &amp;lt;dbl&amp;gt;
##  1 ADANI~ Adani Gree~ 2020-06-09   328.   328.             328.      313.  
##  2 ALCHEM Alchemist ~ 2020-06-09     6.95   6.95             6.95      6.65
##  3 ALOKI~ Alok Indus~ 2020-06-09    25.8   25.8             25.8      24.6 
##  4 ANDHR~ Andhra Cem~ 2020-06-09     5.35   5.35             5.35      5.1 
##  5 AUROP~ Aurobindo ~ 2020-06-04   800.   800.             796.      791   
##  6 BCG    Brightcom ~ 2020-06-09     9.95   9.95             9.95      9.5 
##  7 BIRLA~ Birla Tyre~ 2020-06-09    23.5   23.5             23.5      22.4 
##  8 COMPU~ Compucom S~ 2020-06-09    10.8   10.8             10.8      10.6 
##  9 DAAWAT LT Foods L~ 2020-06-09    37.8   37.8             37.2      37   
## 10 DHANU~ Dhanuka Ag~ 2020-06-09   653.   653.             635.      620   
## # ... with 24 more rows, and 3 more variables: prev_close &amp;lt;dbl&amp;gt;, change &amp;lt;dbl&amp;gt;,
## #   percent_change &amp;lt;dbl&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# retain original column names as returned by NSE
nse_stock_year_high(clean_names = FALSE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 34 x 10
##    symbol symbolDesc dt          value   year    ltp value_old   prev change
##    &amp;lt;chr&amp;gt;  &amp;lt;chr&amp;gt;      &amp;lt;date&amp;gt;      &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;     &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;
##  1 ADANI~ Adani Gre~ 2020-06-09 328.   328.   328.      313.   313.    15.6 
##  2 ALCHEM Alchemist~ 2020-06-09   6.95   6.95   6.95      6.65   6.65   0.3 
##  3 ALOKI~ Alok Indu~ 2020-06-09  25.8   25.8   25.8      24.6   24.6    1.2 
##  4 ANDHR~ Andhra Ce~ 2020-06-09   5.35   5.35   5.35      5.1    5.1    0.25
##  5 AUROP~ Aurobindo~ 2020-06-04 800.   800.   796.      791    775.    21.1 
##  6 BCG    Brightcom~ 2020-06-09   9.95   9.95   9.95      9.5    9.5    0.45
##  7 BIRLA~ Birla Tyr~ 2020-06-09  23.5   23.5   23.5      22.4   22.4    1.1 
##  8 COMPU~ Compucom ~ 2020-06-09  10.8   10.8   10.8      10.6   10.3    0.5 
##  9 DAAWAT LT Foods ~ 2020-06-09  37.8   37.8   37.2      37     34.7    2.55
## 10 DHANU~ Dhanuka A~ 2020-06-09 653.   653.   635.      620    594.    41.4 
## # ... with 24 more rows, and 1 more variable: pChange &amp;lt;dbl&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;learning-more&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Learning More&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://nse2r.rsquaredacademy.com&#34;&gt;Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/rsquaredacademy/nse2r&#34;&gt;GitHub&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;feedback&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Feedback&lt;/h2&gt;
&lt;p&gt;All feedback is welcome. Issues (bugs and feature requests) can be posted to
&lt;a href=&#34;https://github.com/rsquaredacademy/nse2r/issues&#34;&gt;github tracker&lt;/a&gt;.
For help with code or other related questions, feel free to reach out to us
at &lt;a href=&#34;mailto:pkgs@rsquaredacademy.com&#34; class=&#34;email&#34;&gt;pkgs@rsquaredacademy.com&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>A Comprehensive Introduction to Command Line for R Users</title>
      <link>https://blog.rsquaredacademy.com/command-line-basics-for-r-users/</link>
      <pubDate>Sat, 26 Oct 2019 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/command-line-basics-for-r-users/</guid>
      <description>&lt;script src=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/kePrint/kePrint.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/bsTable/bootstrapTable.min.css&#34; rel=&#34;stylesheet&#34; /&gt;


&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/cline_cover_image.png&#34; width=&#34;70%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In this tutorial, you will be introduced to the command line. We have selected a set of commands we think will be useful in general to a wide range of audience.
We have created a &lt;a href=&#34;https://rstudio.cloud/project/518720&#34;&gt;RStudio Cloud Project&lt;/a&gt; to ensure that all readers are using the same environment while going through the tutorial. Our goal was to ensure that after completing this tutorial, readers should be able to use the shell for version control, managing cloud services (like deploying your own shiny server etc.), execute commands in R &amp;amp; RMarkdown and execute R scripts in the shell. Apart from learning shell commands, the tutorial will also focus on&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;exploring R release names&lt;/li&gt;
&lt;li&gt;mapping shell commands to R functions&lt;/li&gt;
&lt;li&gt;RStudio Terminal&lt;/li&gt;
&lt;li&gt;executing shell commands from R using &lt;code&gt;system2()&lt;/code&gt; or &lt;code&gt;processx::run()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;execute shell commands in RMarkdown&lt;/li&gt;
&lt;li&gt;execute R scripts in the shell&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you want a deeper understanding of using command line for data science, we suggest you read &lt;a href=&#34;https://www.datascienceatthecommandline.com/&#34;&gt;Data Science at the Command Line&lt;/a&gt;. &lt;a href=&#34;https://software-carpentry.org/&#34;&gt;Software Carpentry&lt;/a&gt; too has a lesson on &lt;a href=&#34;https://swcarpentry.github.io/shell-novice/&#34;&gt;shell&lt;/a&gt;. We have listed more references at the end of the tutorial for the benefit of the readers.&lt;/p&gt;
&lt;div id=&#34;table-of-contents&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Table of Contents&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#resources&#34;&gt;Resources&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#intro&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#navigate&#34;&gt;Navigating File System&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#filemanage&#34;&gt;File Management&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#inputoutput&#34;&gt;Input/Output&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#regex&#34;&gt;Search &amp;amp; Regular Expression&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#datatransfer&#34;&gt;Data Transfer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#compress&#34;&gt;File Compression&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#sysinfo&#34;&gt;System Info&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#system2&#34;&gt;Execute Shell Commands from R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#shellrstudio&#34;&gt;Execute Shell Commands in RStudio&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#shellrmarkdown&#34;&gt;Execute Shell Commands in RMarkdown&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#rinshell&#34;&gt;Execute R Commands in Shell&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#summary&#34;&gt;Summary&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#references&#34;&gt;References&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;resources&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Resources&lt;/h2&gt;
&lt;p&gt;Below are the links to all the resources related to this post:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://slides.rsquaredacademy.com/github/shell.pdf&#34; target=&#34;_blank&#34;&gt;Slides&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/rsquaredacademy-education/online-courses/&#34; target=&#34;_blank&#34;&gt;Code &amp;amp; Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://rstudio.cloud/project/518720&#34; target=&#34;_blank&#34;&gt;RStudio Cloud&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can try our &lt;strong&gt;free online course&lt;/strong&gt; &lt;a href=&#34;https://rsquared-academy.thinkific.com/courses/command-line-basics-for-r-users&#34;&gt;&lt;strong&gt;Command Line Basics for R Users&lt;/strong&gt;&lt;/a&gt; if you prefer to learn through self paced online courses or our &lt;a href=&#34;https://bash-intro.rsquaredacademy.com&#34;&gt;&lt;strong&gt;ebook&lt;/strong&gt;&lt;/a&gt; if you like to read the tutorial in a book format.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;intro&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/62hgg26RCC0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;div id=&#34;what-is-shellterminal&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;What is Shell/Terminal?&lt;/h3&gt;
&lt;p&gt;Shell is a text based application for viewing, handling &amp;amp; manipulating files. It
takes in commands and passes them on to the operating system. It is also known
as&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;CLI (Command Line Interface)&lt;/li&gt;
&lt;li&gt;Bash (Bourne Again Shell)&lt;/li&gt;
&lt;li&gt;Terminal&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It is sufficient to know a handful of commands to get started with the shell.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;launch-terminal&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Launch Terminal&lt;/h3&gt;
&lt;p&gt;Although we will use the terminal in RStudio on &lt;a href=&#34;https://rstudio.cloud/&#34;&gt;RStudio Cloud&lt;/a&gt;, we should still know how to launch the terminal in different operating systems.&lt;/p&gt;
&lt;div id=&#34;mac&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;mac&lt;/h4&gt;
&lt;p&gt;Applications -&amp;gt; Utility -&amp;gt; Terminal&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/cline_mac-terminal.png&#34; width=&#34;70%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;windows&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Windows&lt;/h4&gt;
&lt;div id=&#34;option-1&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Option 1&lt;/h5&gt;
&lt;p&gt;Go to the Start Menu or screen and enter &lt;code&gt;Command Prompt&lt;/code&gt; in the search field.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/cline_windows-terminal-1.png&#34; width=&#34;70%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;option-2&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Option 2&lt;/h5&gt;
&lt;p&gt;Start Menu -&amp;gt; Windows System -&amp;gt; Command Prompt&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/cline_windows-terminal-2.png&#34; width=&#34;70%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;option-3&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Option 3&lt;/h5&gt;
&lt;p&gt;Hold the Windows key and press the &lt;code&gt;R&lt;/code&gt; key to get a &lt;code&gt;Run&lt;/code&gt; window. Type &lt;code&gt;cmd&lt;/code&gt; in the box and click on the &lt;code&gt;OK&lt;/code&gt; button.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/cline_windows-terminal-3.png&#34; width=&#34;70%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;linux&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Linux&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Applications -&amp;gt; Accessories -&amp;gt; Terminal&lt;/li&gt;
&lt;li&gt;Applications -&amp;gt; System -&amp;gt; Terminal&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/cline_linux-terminal.png&#34; width=&#34;70%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;windows-subsystem-for-linux&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Windows Subsystem for Linux&lt;/h4&gt;
&lt;p&gt;If you want to use bash on Windows, try the Windows subsystem for Linux. It only works on 64 bit Windows 10. Below are the steps to enable Windows subsystem fro Linux:&lt;/p&gt;
&lt;div id=&#34;step-1---enable-developer-mode&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Step 1 - Enable Developer Mode&lt;/h5&gt;
&lt;p&gt;To enable Developer Mode open the Settings app and head to &lt;strong&gt;Update &amp;amp; Security &amp;gt; For Developers&lt;/strong&gt;. Press the &lt;strong&gt;Developer Mode&lt;/strong&gt; switch.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/cline_wsl-1.png&#34; width=&#34;70%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;step-2---enable-windows-subsystem-for-linux&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Step 2 - Enable Windows Subsystem for Linux&lt;/h5&gt;
&lt;p&gt;To enable the Windows Subsystem for Linux (Beta), open the &lt;strong&gt;Control Panel&lt;/strong&gt;, click &lt;strong&gt;Programs and Features&lt;/strong&gt;, and click &lt;strong&gt;Turn Windows Features On or Off&lt;/strong&gt; in left side bar under Programs and Features. Enable the &lt;strong&gt;Windows Subsystem for Linux (Beta)&lt;/strong&gt; option in the list here and click OK. After you do, you’ll be prompted to reboot your computer. Click &lt;strong&gt;Restart Now&lt;/strong&gt; to reboot your computer and Windows 10 will install the new feature.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/cline_wsl-2.png&#34; width=&#34;70%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;step-3---install-your-linux-distribution-of-choice&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Step 3 - Install your Linux Distribution of Choice&lt;/h5&gt;
&lt;p&gt;Open the Microsoft store and choose your favorite Linux distribution.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/cline_wsl-3.png&#34; width=&#34;70%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In the distro’s page, click on “Get”.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/cline_wsl-4.png&#34; width=&#34;70%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Launch the distro from the &lt;strong&gt;Start Menu&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/cline_wsl-5.png&#34; width=&#34;70%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;You can learn more about the Windows Subsystem for Linux &lt;a href=&#34;https://docs.microsoft.com/en-us/windows/wsl/about&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;rstudio-terminal&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;RStudio Terminal&lt;/h4&gt;
&lt;p&gt;RStudio introduced the terminal with version 1.1.383. The terminal tab is next to the console tab. If it is not visible, use any of the below methods to launch it&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Shift + Alt + T&lt;/li&gt;
&lt;li&gt;Tools -&amp;gt; Terminal -&amp;gt; New Terminal&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note, the terminal depends on the underlying operating system. To learn more about the RStudio terminal, read this &lt;a href=&#34;https://support.rstudio.com/hc/en-us/articles/115010737148-Using-the-RStudio-Terminal&#34;&gt;article&lt;/a&gt; or watch this &lt;a href=&#34;https://resources.rstudio.com/webinars/terminal-updates&#34;&gt;webinar&lt;/a&gt;. In this book, we will use the RStudio terminal on &lt;a href=&#34;https://rstudio.cloud/&#34;&gt;RStudio Cloud&lt;/a&gt; to ensure that all users have access to Linux bash. You can try all the commands used in this book on your local system as well except in case of Windows users.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/cline_rstudio-termina.png&#34; width=&#34;70%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;prompt&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Prompt&lt;/h3&gt;
&lt;p&gt;As soon as you launch the terminal, you will see the hostname, machine name and
the prompt. In case of mac &amp;amp; Linux users, the prompt is &lt;code&gt;$&lt;/code&gt;. For Windows users, it is &lt;code&gt;&amp;gt;&lt;/code&gt;.&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
OS
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Prompt
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
macOS
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
$
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Linux
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
$
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Windows
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&amp;gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/cline_prompt-canva.png&#34; width=&#34;70%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;get-started&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Get Started&lt;/h3&gt;
&lt;p&gt;To begin with, let us learn to display&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;basic information about the user&lt;/li&gt;
&lt;li&gt;the current date &amp;amp; time&lt;/li&gt;
&lt;li&gt;the calendar&lt;/li&gt;
&lt;li&gt;and clear the screen.&lt;/li&gt;
&lt;/ul&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;whoami&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Who is the user?
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;date&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Get date, time and timezone
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;cal&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Display calendar
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;clear&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Clear the screen
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;code&gt;whoami&lt;/code&gt; prints the effective user id i.e. the name of the user who runs the command. Use it to verify the user as which you are logged into the system.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;whoami&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## aravind&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;date&lt;/code&gt; will display or change the value of the system’s time and date information.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;date&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Wed Jun 10 22:45:47 IST 2020&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;cal&lt;/code&gt; will display a formatted calendar and &lt;code&gt;clear&lt;/code&gt; will clear all text on the screen and display a new prompt. You can clear the screen by pressing &lt;code&gt;Ctrl + L&lt;/code&gt; as well.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;cal&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In R, we can get the user information from &lt;code&gt;Sys.info()&lt;/code&gt; or &lt;code&gt;whoami()&lt;/code&gt; from the &lt;a href=&#34;https://cran.r-project.org/package=whoami&#34;&gt;whoami&lt;/a&gt; package. The current date &amp;amp; time are returned by &lt;code&gt;Sys.date()&lt;/code&gt; &amp;amp; &lt;code&gt;Sys.time()&lt;/code&gt;. To clear the R console, we use Ctrl + L.&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
R
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;whoami&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;Sys.info()&lt;/code&gt; / &lt;code&gt;whoami::whoami()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;date&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;Sys.date()&lt;/code&gt; / &lt;code&gt;Sys.time()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;cal&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;clear&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;Ctrl + L&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;div id=&#34;helpdocumentation&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Help/Documentation&lt;/h3&gt;
&lt;p&gt;Before we proceed further, let us learn to view the documentation/manual pages of the commands.&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;man&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Display manual pages for a command
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;whatis&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Single line description of a command
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;code&gt;man&lt;/code&gt; is used to view the system’s reference manual. Let us use it to view the documentation of the &lt;code&gt;whatis&lt;/code&gt; command which we will use next.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;man whatis&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## WHATIS(1)                     Manual pager utils                     WHATIS(1)
## 
## NAME
##        whatis - display one-line manual page descriptions
## 
## SYNOPSIS
##        whatis  [-dlv?V]  [-r|-w]  [-s  list]  [-m  system[,...]] [-M path] [-L
##        locale] [-C file] name ...
## 
## DESCRIPTION
##        Each manual page has a short description available within  it.   whatis
##        searches  the  manual  page names and displays the manual page descripâ€
##        tions of any name matched.
## 
##        name may contain wildcards (-w) or be a regular expression (-r).  Using
##        these  options, it may be necessary to quote the name or escape (\) the
##        special characters to stop the shell from interpreting them.
## 
##        index databases are used during the search,  and  are  updated  by  the
##        mandb  program.   Depending  on your installation, this may be run by a
##        periodic cron job, or may need to be  run  manually  after  new  manual
##        pages  have  been installed.  To produce an old style text whatis dataâ€
##        base from the relative index database, issue the command:
## 
##        whatis -M manpath -w &amp;#39;*&amp;#39; | sort &amp;gt; manpath/whatis
## 
##        where manpath is a manual page hierarchy such as /usr/man.
## 
## OPTIONS
##        -d, --debug
##               Print debugging information.
## 
##        -v, --verbose
##               Print verbose warning messages.
## 
##        -r, --regex
##               Interpret each name as a regular expression.  If a name  matches
##               any  part  of  a  page  name, a match will be made.  This option
##               causes whatis to be somewhat slower due to the nature  of  dataâ€
##               base searches.
## 
##        -w, --wildcard
##               Interpret  each  name  as a pattern containing shell style wildâ€
##               cards.  For a match to be made, an expanded name must match  the
##               entire  page  name.   This  option  causes whatis to be somewhat
##               slower due to the nature of database searches.
## 
##        -l, --long
##               Do not trim output to the terminal width.  Normally, output will
##               be  truncated  to  the terminal width to avoid ugly results from
##               poorly-written NAME sections.
## 
##        -s list, --sections list, --section list
##               Search only the given manual sections.   list  is  a  colon-  or
##               comma-separated list of sections.  If an entry in list is a simâ€
##               ple section,  for  example  &amp;quot;3&amp;quot;,  then  the  displayed  list  of
##               descriptions  will include pages in sections &amp;quot;3&amp;quot;, &amp;quot;3perl&amp;quot;, &amp;quot;3x&amp;quot;,
##               and so on; while if an entry in list has an extension, for examâ€
##               ple &amp;quot;3perl&amp;quot;, then the list will only include pages in that exact
##               part of the manual section.
## 
##        -m system[,...], --systems=system[,...]
##               If this system has access to  other  operating  system&amp;#39;s  manual
##               page  names,  they can be accessed using this option.  To search
##               NewOS&amp;#39;s manual page names, use the option -m NewOS.
## 
##               The system specified can be a  combination  of  comma  delimited
##               operating system names.  To include a search of the native operâ€
##               ating system&amp;#39;s manual page names, include the system name man in
##               the  argument  string.   This  option  will override the $SYSTEM
##               environment variable.
## 
##        -M path, --manpath=path
##               Specify an alternate set of colon-delimited manual page  hierarâ€
##               chies  to search.  By default, whatis uses the $MANPATH environâ€
##               ment variable, unless it is empty or unset,  in  which  case  it
##               will  determine an appropriate manpath based on your $PATH enviâ€
##               ronment variable.  This option overrides the contents  of  $MANâ€
##               PATH.
## 
##        -L locale, --locale=locale
##               whatis  will normally determine your current locale by a call to
##               the C function setlocale(3) which interrogates various  environâ€
##               ment  variables,  possibly including $LC_MESSAGES and $LA&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;whatis&lt;/code&gt; displays short manual page descriptions (each manual page has a short description available within it).&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;whatis ls&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## ls (1)               - list directory contents&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You will find &lt;a href=&#34;https://tldr.sh/&#34;&gt;tldr.sh&lt;/a&gt; very useful while exploring new commands and there is a related R package, &lt;a href=&#34;https://github.com/kirillseva/tldrrr&#34;&gt;tldrrr&lt;/a&gt; as well.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# devtools::install_github(&amp;quot;kirillseva/tldrrr&amp;quot;)
tldrrr::tldr(&amp;quot;pwd&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## pwd 
##  
## Print name of current/working directory. 
##  
## â€¢ Print the current directory: 
##  
##   pwd 
##  
## â€¢ Print the current directory, and resolve all symlinks (i.e. show the &amp;quot;physical&amp;quot; path): 
##  
##   pwd -P&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;p align=&#34;center&#34;&gt;
&lt;a href=&#34;https://rsquared-academy.thinkific.com/&#34; target=&#34;_blank&#34;&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/ad_courses.png&#34; width=&#34;100%&#34; alt=&#34;new courses ad&#34; style=&#34;text-decoration: none;&#34;&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;hr&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;navigate&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Navigating File System&lt;/h2&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/yn0sVrEM8AA&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;p&gt;In this section, we will learn commands that will help us&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;navigate between different folders/directories&lt;/li&gt;
&lt;li&gt;return current working directory&lt;/li&gt;
&lt;li&gt;list all the files &amp;amp; folders in a directory&lt;/li&gt;
&lt;li&gt;create and delete directories&lt;/li&gt;
&lt;/ul&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;pwd&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Print working directory
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;ls&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
List directory contents
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;cd&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Change current working directory
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;mkdir&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Create directory
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;rmdir&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Remove/delete directory
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;code&gt;pwd&lt;/code&gt; displays the name of the &lt;strong&gt;p&lt;/strong&gt;resent &lt;strong&gt;w&lt;/strong&gt;orking &lt;strong&gt;d&lt;/strong&gt;irectory.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;pwd&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## /mnt/j/R/Others/blogs/content/post/cline&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;ls&lt;/code&gt; displays information about files and directories in the current directory along with their associated metadata such as&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;size&lt;/li&gt;
&lt;li&gt;ownership&lt;/li&gt;
&lt;li&gt;modification date&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;With no options, it will list the files and directories in the current directory, sorted alphabetically.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;ls&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## analysis.R
## bash.R
## bash.sh
## imports_blorr.txt
## imports_olsrr.txt
## lorem-ipsum.txt
## main_project.zip
## myfiles
## mypackage
## myproject
## myproject1
## myproject2
## myproject3
## myproject4
## package_names.txt
## pkg_names.txt
## r
## release_names.tar
## release_names.tar.gz
## release_names.txt
## release_names_18.txt
## release_names_19.txt
## sept_15.csv.gz
## urls.txt
## zip_example.zip&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;cd&lt;/code&gt; (&lt;strong&gt;c&lt;/strong&gt;hange &lt;strong&gt;d&lt;/strong&gt;irectory) changes the current working directory. It is among the most used commands as it allows the user to move around the file system.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;cd r
pwd&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## /mnt/j/R/Others/blogs/content/post/cline/r&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;mkdir&lt;/code&gt; will create new directory. It will allow you to set file mode (permissions associated with the directory) i.e. who can open/modify/delete the directory.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;mkdir rfiles
ls&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## analysis.R
## bash.R
## bash.sh
## imports_blorr.txt
## imports_olsrr.txt
## lorem-ipsum.txt
## main_project.zip
## myfiles
## mypackage
## myproject
## myproject1
## myproject2
## myproject3
## myproject4
## package_names.txt
## pkg_names.txt
## r
## release_names.tar
## release_names.tar.gz
## release_names.txt
## release_names_18.txt
## release_names_19.txt
## rfiles
## sept_15.csv.gz
## urls.txt
## zip_example.zip&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;rmdir&lt;/code&gt; will remove empty directories from the file system. It can be used to remove multiple empty directories as well. If the directory is not empty, &lt;code&gt;rmdir&lt;/code&gt; will not remove it and instead display a warning that the directory is not empty.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;rmdir rfiles
ls&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## analysis.R
## bash.R
## bash.sh
## imports_blorr.txt
## imports_olsrr.txt
## lorem-ipsum.txt
## main_project.zip
## myfiles
## mypackage
## myproject
## myproject1
## myproject2
## myproject3
## myproject4
## package_names.txt
## pkg_names.txt
## r
## release_names.tar
## release_names.tar.gz
## release_names.txt
## release_names_18.txt
## release_names_19.txt
## sept_15.csv.gz
## urls.txt
## zip_example.zip&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;change-working-directory&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Change Working Directory&lt;/h3&gt;
&lt;p&gt;Let us focus a bit more on changing working directory. The below table shows commands for changing working directory to&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;up one level&lt;/li&gt;
&lt;li&gt;previous working directory&lt;/li&gt;
&lt;li&gt;home directory&lt;/li&gt;
&lt;li&gt;and root directory&lt;/li&gt;
&lt;/ul&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;cd .&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Navigate into directory
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;cd ..&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Go up one level
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;cd -&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Go to previous working directory
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;cd ~&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Change directory to home directory
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;cd /&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Change directory to root directory
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;All files and directories stem from one main directory, the root directory. All the other directories in the system are sub-directories of the root directory and the root directory has no parent directory. It is represented by a single slash (&lt;code&gt;/&lt;/code&gt;). &lt;code&gt;cd /&lt;/code&gt; will change the current working directory to the root directory. In RStudio Cloud, use &lt;code&gt;cd&lt;/code&gt; and &lt;code&gt;cd ..&lt;/code&gt; to navigate back to the current working directory. If you get confused, close the terminal and relaunch it.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;cd /
pwd&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## /&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The parent directory i.e. the directory one level up from the current directory which contains the directory we are in now is represented by two dots (&lt;code&gt;..&lt;/code&gt;). &lt;code&gt;cd ..&lt;/code&gt; will change us into the parent directory of the current directory.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;cd ..
pwd&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## /mnt/j/R/Others/blogs/content/post&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The home directory is the directory we are placed in, by default, when we launch a new terminal session. It is represented by the tilde (&lt;code&gt;~&lt;/code&gt;). In RStudio Cloud, use &lt;code&gt;cd&lt;/code&gt; and &lt;code&gt;cd ..&lt;/code&gt; to navigate back to the current working directory. If you get confused, close the terminal and relaunch it.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;cd ~
pwd&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## /home/aravind&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To change into the previous working directory, use &lt;code&gt;cd -&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;cd -
pwd&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## /mnt/j/R/Others/blogs/content/post
## /mnt/j/R/Others/blogs/content/post&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The current working directory is represented by a single dot (&lt;code&gt;.&lt;/code&gt;). &lt;code&gt;cd .&lt;/code&gt; will change us into the current directory i.e. it will do nothing.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;list-directory-contents&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;List Directory Contents&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;ls&lt;/code&gt; will list the contents of a directory. Using different arguments, we can&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;list hidden files&lt;/li&gt;
&lt;li&gt;view file permissions, ownership, size &amp;amp; modification date&lt;/li&gt;
&lt;li&gt;sort by size &amp;amp; modification date&lt;/li&gt;
&lt;/ul&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;ls&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
List directory contents
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;ls -l&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
List files one per line
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;ls -a&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
List all files including hidden files
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;ls -la&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Display file permissions, ownership, size &amp;amp; modification date
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;ls -lh&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Long format list with size displayed in human readable format
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;ls -lS&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Long format list sorted by size
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;ls -ltr&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Long format list sorted by modification date
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;div id=&#34;list-files-one-per-line&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;List files one per line&lt;/h4&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;ls -l&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## total 31108
## -rwxrwxrwx 1 aravind aravind       12 Jun  3 13:51 analysis.R
## -rwxrwxrwx 1 aravind aravind      430 Jun  3 13:51 bash.R
## -rwxrwxrwx 1 aravind aravind    16242 Jun  3 13:51 bash.sh
## -rwxrwxrwx 1 aravind aravind       35 Jun  3 13:51 imports_blorr.txt
## -rwxrwxrwx 1 aravind aravind       34 Jun  3 13:51 imports_olsrr.txt
## -rwxrwxrwx 1 aravind aravind    39501 Jun  3 13:51 lorem-ipsum.txt
## -rwxrwxrwx 1 aravind aravind     9291 Jun  3 13:51 main_project.zip
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 myfiles
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 mypackage
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 myproject
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 myproject1
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 myproject2
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 myproject3
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 myproject4
## -rwxrwxrwx 1 aravind aravind     1498 Jun  3 13:51 package_names.txt
## -rwxrwxrwx 1 aravind aravind     1082 Jun  3 13:51 pkg_names.txt
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 r
## -rwxrwxrwx 1 aravind aravind    10240 Jun  3 13:51 release_names.tar
## -rwxrwxrwx 1 aravind aravind      632 Jun  3 13:51 release_names.tar.gz
## -rwxrwxrwx 1 aravind aravind      546 Jun  3 13:51 release_names.txt
## -rwxrwxrwx 1 aravind aravind       65 Jun  3 13:51 release_names_18.txt
## -rwxrwxrwx 1 aravind aravind       53 Jun  3 13:51 release_names_19.txt
## -rwxrwxrwx 1 aravind aravind 31754998 Jun  3 13:51 sept_15.csv.gz
## -rwxrwxrwx 1 aravind aravind      157 Jun  3 13:51 urls.txt
## -rwxrwxrwx 1 aravind aravind     4398 Jun  3 13:51 zip_example.zip&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;list-all-files-including-hidden-files&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;List all files including hidden files&lt;/h4&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;ls -a&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## .
## ..
## analysis.R
## bash.R
## bash.sh
## imports_blorr.txt
## imports_olsrr.txt
## lorem-ipsum.txt
## main_project.zip
## myfiles
## mypackage
## myproject
## myproject1
## myproject2
## myproject3
## myproject4
## package_names.txt
## pkg_names.txt
## r
## release_names.tar
## release_names.tar.gz
## release_names.txt
## release_names_18.txt
## release_names_19.txt
## sept_15.csv.gz
## urls.txt
## zip_example.zip&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;display-file-permissions-ownership-size-modification-date&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Display file permissions, ownership, size &amp;amp; modification date&lt;/h4&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;ls -la&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## total 31108
## drwxrwxrwx 1 aravind aravind     4096 Jun 10 22:46 .
## drwxrwxrwx 1 aravind aravind     4096 Jun 10 22:45 ..
## -rwxrwxrwx 1 aravind aravind       12 Jun  3 13:51 analysis.R
## -rwxrwxrwx 1 aravind aravind      430 Jun  3 13:51 bash.R
## -rwxrwxrwx 1 aravind aravind    16242 Jun  3 13:51 bash.sh
## -rwxrwxrwx 1 aravind aravind       35 Jun  3 13:51 imports_blorr.txt
## -rwxrwxrwx 1 aravind aravind       34 Jun  3 13:51 imports_olsrr.txt
## -rwxrwxrwx 1 aravind aravind    39501 Jun  3 13:51 lorem-ipsum.txt
## -rwxrwxrwx 1 aravind aravind     9291 Jun  3 13:51 main_project.zip
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 myfiles
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 mypackage
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 myproject
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 myproject1
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 myproject2
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 myproject3
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 myproject4
## -rwxrwxrwx 1 aravind aravind     1498 Jun  3 13:51 package_names.txt
## -rwxrwxrwx 1 aravind aravind     1082 Jun  3 13:51 pkg_names.txt
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 r
## -rwxrwxrwx 1 aravind aravind    10240 Jun  3 13:51 release_names.tar
## -rwxrwxrwx 1 aravind aravind      632 Jun  3 13:51 release_names.tar.gz
## -rwxrwxrwx 1 aravind aravind      546 Jun  3 13:51 release_names.txt
## -rwxrwxrwx 1 aravind aravind       65 Jun  3 13:51 release_names_18.txt
## -rwxrwxrwx 1 aravind aravind       53 Jun  3 13:51 release_names_19.txt
## -rwxrwxrwx 1 aravind aravind 31754998 Jun  3 13:51 sept_15.csv.gz
## -rwxrwxrwx 1 aravind aravind      157 Jun  3 13:51 urls.txt
## -rwxrwxrwx 1 aravind aravind     4398 Jun  3 13:51 zip_example.zip&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;display-size-in-human-readable-format&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Display size in human readable format&lt;/h4&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;ls -lh&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## total 31M
## -rwxrwxrwx 1 aravind aravind   12 Jun  3 13:51 analysis.R
## -rwxrwxrwx 1 aravind aravind  430 Jun  3 13:51 bash.R
## -rwxrwxrwx 1 aravind aravind  16K Jun  3 13:51 bash.sh
## -rwxrwxrwx 1 aravind aravind   35 Jun  3 13:51 imports_blorr.txt
## -rwxrwxrwx 1 aravind aravind   34 Jun  3 13:51 imports_olsrr.txt
## -rwxrwxrwx 1 aravind aravind  39K Jun  3 13:51 lorem-ipsum.txt
## -rwxrwxrwx 1 aravind aravind 9.1K Jun  3 13:51 main_project.zip
## drwxrwxrwx 1 aravind aravind 4.0K Jun  3 13:51 myfiles
## drwxrwxrwx 1 aravind aravind 4.0K Jun  3 13:51 mypackage
## drwxrwxrwx 1 aravind aravind 4.0K Jun  3 13:51 myproject
## drwxrwxrwx 1 aravind aravind 4.0K Jun  3 13:51 myproject1
## drwxrwxrwx 1 aravind aravind 4.0K Jun  3 13:51 myproject2
## drwxrwxrwx 1 aravind aravind 4.0K Jun  3 13:51 myproject3
## drwxrwxrwx 1 aravind aravind 4.0K Jun  3 13:51 myproject4
## -rwxrwxrwx 1 aravind aravind 1.5K Jun  3 13:51 package_names.txt
## -rwxrwxrwx 1 aravind aravind 1.1K Jun  3 13:51 pkg_names.txt
## drwxrwxrwx 1 aravind aravind 4.0K Jun  3 13:51 r
## -rwxrwxrwx 1 aravind aravind  10K Jun  3 13:51 release_names.tar
## -rwxrwxrwx 1 aravind aravind  632 Jun  3 13:51 release_names.tar.gz
## -rwxrwxrwx 1 aravind aravind  546 Jun  3 13:51 release_names.txt
## -rwxrwxrwx 1 aravind aravind   65 Jun  3 13:51 release_names_18.txt
## -rwxrwxrwx 1 aravind aravind   53 Jun  3 13:51 release_names_19.txt
## -rwxrwxrwx 1 aravind aravind  31M Jun  3 13:51 sept_15.csv.gz
## -rwxrwxrwx 1 aravind aravind  157 Jun  3 13:51 urls.txt
## -rwxrwxrwx 1 aravind aravind 4.3K Jun  3 13:51 zip_example.zip&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;sort-list-by-size&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Sort list by size&lt;/h4&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;ls -lS&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## total 31108
## -rwxrwxrwx 1 aravind aravind 31754998 Jun  3 13:51 sept_15.csv.gz
## -rwxrwxrwx 1 aravind aravind    39501 Jun  3 13:51 lorem-ipsum.txt
## -rwxrwxrwx 1 aravind aravind    16242 Jun  3 13:51 bash.sh
## -rwxrwxrwx 1 aravind aravind    10240 Jun  3 13:51 release_names.tar
## -rwxrwxrwx 1 aravind aravind     9291 Jun  3 13:51 main_project.zip
## -rwxrwxrwx 1 aravind aravind     4398 Jun  3 13:51 zip_example.zip
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 myfiles
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 mypackage
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 myproject
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 myproject1
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 myproject2
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 myproject3
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 myproject4
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 r
## -rwxrwxrwx 1 aravind aravind     1498 Jun  3 13:51 package_names.txt
## -rwxrwxrwx 1 aravind aravind     1082 Jun  3 13:51 pkg_names.txt
## -rwxrwxrwx 1 aravind aravind      632 Jun  3 13:51 release_names.tar.gz
## -rwxrwxrwx 1 aravind aravind      546 Jun  3 13:51 release_names.txt
## -rwxrwxrwx 1 aravind aravind      430 Jun  3 13:51 bash.R
## -rwxrwxrwx 1 aravind aravind      157 Jun  3 13:51 urls.txt
## -rwxrwxrwx 1 aravind aravind       65 Jun  3 13:51 release_names_18.txt
## -rwxrwxrwx 1 aravind aravind       53 Jun  3 13:51 release_names_19.txt
## -rwxrwxrwx 1 aravind aravind       35 Jun  3 13:51 imports_blorr.txt
## -rwxrwxrwx 1 aravind aravind       34 Jun  3 13:51 imports_olsrr.txt
## -rwxrwxrwx 1 aravind aravind       12 Jun  3 13:51 analysis.R&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;sort-list-by-modification-date&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Sort list by modification date&lt;/h4&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;ls -ltr&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## total 31108
## -rwxrwxrwx 1 aravind aravind      546 Jun  3 13:51 release_names.txt
## -rwxrwxrwx 1 aravind aravind    10240 Jun  3 13:51 release_names.tar
## -rwxrwxrwx 1 aravind aravind     4398 Jun  3 13:51 zip_example.zip
## -rwxrwxrwx 1 aravind aravind     9291 Jun  3 13:51 main_project.zip
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 r
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 myfiles
## -rwxrwxrwx 1 aravind aravind      632 Jun  3 13:51 release_names.tar.gz
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 myproject3
## -rwxrwxrwx 1 aravind aravind       35 Jun  3 13:51 imports_blorr.txt
## -rwxrwxrwx 1 aravind aravind       65 Jun  3 13:51 release_names_18.txt
## -rwxrwxrwx 1 aravind aravind       53 Jun  3 13:51 release_names_19.txt
## -rwxrwxrwx 1 aravind aravind       34 Jun  3 13:51 imports_olsrr.txt
## -rwxrwxrwx 1 aravind aravind     1498 Jun  3 13:51 package_names.txt
## -rwxrwxrwx 1 aravind aravind      157 Jun  3 13:51 urls.txt
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 myproject1
## -rwxrwxrwx 1 aravind aravind     1082 Jun  3 13:51 pkg_names.txt
## -rwxrwxrwx 1 aravind aravind 31754998 Jun  3 13:51 sept_15.csv.gz
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 mypackage
## -rwxrwxrwx 1 aravind aravind    16242 Jun  3 13:51 bash.sh
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 myproject2
## -rwxrwxrwx 1 aravind aravind       12 Jun  3 13:51 analysis.R
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 myproject
## -rwxrwxrwx 1 aravind aravind      430 Jun  3 13:51 bash.R
## -rwxrwxrwx 1 aravind aravind    39501 Jun  3 13:51 lorem-ipsum.txt
## drwxrwxrwx 1 aravind aravind     4096 Jun  3 13:51 myproject4&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;r-functions&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;R Functions&lt;/h3&gt;
&lt;p&gt;In R, &lt;code&gt;getwd()&lt;/code&gt; will return the current working directory. You can use &lt;code&gt;here()&lt;/code&gt; from the &lt;a href=&#34;https://here.r-lib.org/&#34;&gt;here&lt;/a&gt; package as well. To change the current
working directory, use &lt;code&gt;setwd()&lt;/code&gt;. The &lt;a href=&#34;https://fs.r-lib.org/index.html&#34;&gt;fs&lt;/a&gt; package provides useful functions for file operations.&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
R
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;pwd&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;getwd()&lt;/code&gt; / &lt;code&gt;here::here()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;ls&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;dir()&lt;/code&gt; / &lt;code&gt;list.files()&lt;/code&gt; / &lt;code&gt;list.dirs()&lt;/code&gt; / &lt;code&gt;fs::dir_ls()&lt;/code&gt; / &lt;code&gt;dir_info()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;cd&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;setwd()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;mkdir&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;dir.create()&lt;/code&gt; / &lt;code&gt;fs::dir_create()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;rmdir&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;fs::dir_delete()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;filemanage&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;File Management&lt;/h2&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/Ahk7UoPrzcw&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;p&gt;In this section, we will explore commands for file management including:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;create new file/change timestamps&lt;/li&gt;
&lt;li&gt;copying files&lt;/li&gt;
&lt;li&gt;renaming/moving files&lt;/li&gt;
&lt;li&gt;deleting files&lt;/li&gt;
&lt;li&gt;comparing files&lt;/li&gt;
&lt;/ul&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;touch&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Create empty file(s)/change timestamp
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;cp&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Copy files &amp;amp; folders
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;mv&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Rename/move file
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;rm&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Remove/delete file
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;diff&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Compare files
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;div id=&#34;create-new-file&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Create new file&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;touch&lt;/code&gt; modifies file timestamps which is information associated with file modification. It can be any of the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;access time (the last time the file was read)&lt;/li&gt;
&lt;li&gt;modification time (the last time the contents of the file was changed)&lt;/li&gt;
&lt;li&gt;change time (the last time the file’s metadata was changed)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If the file does not exist, it will create an empty file of the same name. Let us use &lt;code&gt;touch&lt;/code&gt; to create a new file &lt;code&gt;myanalysis.R&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;touch myanalysis.R
ls&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## analysis.R
## bash.R
## bash.sh
## imports_blorr.txt
## imports_olsrr.txt
## lorem-ipsum.txt
## main_project.zip
## myanalysis.R
## myfiles
## mypackage
## myproject
## myproject1
## myproject2
## myproject3
## myproject4
## package_names.txt
## pkg_names.txt
## r
## release_names.tar
## release_names.tar.gz
## release_names.txt
## release_names_18.txt
## release_names_19.txt
## sept_15.csv.gz
## urls.txt
## zip_example.zip&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;copy-filesfolders&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Copy Files/Folders&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;cp&lt;/code&gt; makes copies of files and directories. The general form of the command is
&lt;strong&gt;cp source destination&lt;/strong&gt;. By default, it will overwrite files without prompting for confirmation so be cautious while copying files or folders.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;copy-files-in-same-folder&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Copy files in same folder&lt;/h3&gt;
&lt;p&gt;Let us create a copy of &lt;code&gt;release_names.txt&lt;/code&gt; file and name it as &lt;code&gt;release_names_2.txt&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;cp release_names.txt release_names_2.txt
ls&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## analysis.R
## bash.R
## bash.sh
## imports_blorr.txt
## imports_olsrr.txt
## lorem-ipsum.txt
## main_project.zip
## myanalysis.R
## myfiles
## mypackage
## myproject
## myproject1
## myproject2
## myproject3
## myproject4
## package_names.txt
## pkg_names.txt
## r
## release_names.tar
## release_names.tar.gz
## release_names.txt
## release_names_18.txt
## release_names_19.txt
## release_names_2.txt
## sept_15.csv.gz
## urls.txt
## zip_example.zip&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;copy-files-into-different-folder&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Copy files into different folder&lt;/h4&gt;
&lt;p&gt;To copy a file into a different directory/folder, we need to specify the name of the destination folder. If the copied file should have a different name, then we need to specify the new name of the file as well. Let us copy the &lt;code&gt;release_names.txt&lt;/code&gt; file into the &lt;code&gt;r_releases&lt;/code&gt; folder (we will retain the same name for the file as we are copying it into a different folder).&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;cp release_names.txt r_releases/release_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us check if the file has been copied by listing the files in the &lt;code&gt;r_releases&lt;/code&gt; folder using &lt;code&gt;ls&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;ls r_releases&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## release_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;copy-folders&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Copy folders&lt;/h4&gt;
&lt;p&gt;How about making copies of folders? Use the &lt;code&gt;-r&lt;/code&gt; option to copy entire folders. Let us create a copy of the &lt;code&gt;r&lt;/code&gt; folder and name it as &lt;code&gt;r2&lt;/code&gt;. The &lt;code&gt;-r&lt;/code&gt; option stands for &lt;code&gt;--recursive&lt;/code&gt; i.e. copy directories recursively.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;cp -r r r2
ls&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## analysis.R
## bash.R
## bash.sh
## imports_blorr.txt
## imports_olsrr.txt
## lorem-ipsum.txt
## main_project.zip
## myanalysis.R
## myfiles
## mypackage
## myproject
## myproject1
## myproject2
## myproject3
## myproject4
## package_names.txt
## pkg_names.txt
## r
## r2
## r_releases
## release_names.tar
## release_names.tar.gz
## release_names.txt
## release_names_18.txt
## release_names_19.txt
## release_names_2.txt
## release_names_3.txt
## sept_15.csv.gz
## urls.txt
## zip_example.zip&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;moverename-files&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Move/Rename Files&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;mv&lt;/code&gt; moves and renames files and directories. Using different options, we can ensure&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;files are not overwritten&lt;/li&gt;
&lt;li&gt;user is prompted for confirmation before overwriting files&lt;/li&gt;
&lt;li&gt;details of files being moved is displayed&lt;/li&gt;
&lt;/ul&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;mv&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Move or rename files/directories
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;mv -f&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Do not prompt for confirmation before overwriting files
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;mv -i&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Prompt for confirmation before overwriting files
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;mv -n&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Do not overwrite existing files
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;mv -v&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Move files in verbose mode
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Let us move the &lt;code&gt;release_names_2.txt&lt;/code&gt; file to the &lt;code&gt;r_releases&lt;/code&gt; folder.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;mv release_names_2.txt r_releases&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Use &lt;code&gt;ls&lt;/code&gt; to verfiy if the file has been moved. As you can see, &lt;code&gt;release_names_2.txt&lt;/code&gt; is not present in the current working directory.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;ls&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## analysis.R
## bash.R
## bash.sh
## imports_blorr.txt
## imports_olsrr.txt
## lorem-ipsum.txt
## main_project.zip
## myanalysis.R
## myfiles
## mypackage
## myproject
## myproject1
## myproject2
## myproject3
## myproject4
## package_names.txt
## pkg_names.txt
## r
## r2
## r_releases
## release_names.tar
## release_names.tar.gz
## release_names.txt
## release_names_18.txt
## release_names_19.txt
## release_names_3.txt
## sept_15.csv.gz
## urls.txt
## zip_example.zip&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us check if &lt;code&gt;release_names_2.txt&lt;/code&gt; is present in the &lt;code&gt;r_releases&lt;/code&gt; folder. Great! We have successfully moved the file into a different folder.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;ls r_releases&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## release_names.txt
## release_names_2.txt&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;move-files-in-verbose-mode&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Move files in verbose mode&lt;/h4&gt;
&lt;p&gt;To view the details of the files being moved/renamed, use the &lt;code&gt;-v&lt;/code&gt; option. In the below example, we move the &lt;code&gt;release_names_3.txt&lt;/code&gt; file into the &lt;code&gt;r_releases&lt;/code&gt; folder using &lt;code&gt;mv&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;mv -v release_names_3.txt r_releases&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## renamed &amp;#39;release_names_3.txt&amp;#39; -&amp;gt; &amp;#39;r_releases/release_names_3.txt&amp;#39;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;do-not-overwrite-existing-files&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Do not overwrite existing files&lt;/h4&gt;
&lt;p&gt;How do we ensure that files are not overwritten without prompting the user first? In the below example, we will try to overwrite the &lt;code&gt;release_names_2.txt&lt;/code&gt; in the &lt;code&gt;r_releases&lt;/code&gt; folder using &lt;code&gt;mv&lt;/code&gt; and see what happens. But first, let us look at the contents of the &lt;code&gt;release_names_2.txt&lt;/code&gt; file using the &lt;code&gt;cat&lt;/code&gt; command.&lt;/p&gt;
&lt;p&gt;We will look into the &lt;code&gt;cat&lt;/code&gt; command in more detail in the next chapter but for the time being it is sufficient to know that it prints contents of a file. The file contains release names of different R versions.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;cat r_releases/release_names_2.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Unsuffered Consequences
## Great Pumpkin
## December Snowflakes
## Gift-Getting Season
## Easter Beagle
## Roasted Marshmallows
## Trick or Treat
## Security Blanket
## Masked Marvel
## Good Sport
## Frisbee Sailing
## Warm Puppy
## Spring Dance
## Sock it to Me
## Pumpkin Helmet
## Smooth Sidewalk
## Full of Ingredients
## World-Famous Astronaut
## Fire Safety
## Wooden Christmas Tree
## Very Secure Dishes
## Very, Very Secure Dishes
## Supposedly Educational
## Bug in Your Hair
## Sincere Pumpkin Patch
## Another Canoe
## You Stupid Darkness
## Single Candle
## Short Summer
## Kite Eating Tree&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In our current working directory, we will create another file of the same name i.e. &lt;code&gt;release_names_2.txt&lt;/code&gt; but its contents are different from the file in the &lt;code&gt;r_releases&lt;/code&gt; folder. It contains the string &lt;code&gt;release_names&lt;/code&gt; and nothing else. We will now move this file into the &lt;code&gt;r_releases&lt;/code&gt; folder but use the option &lt;code&gt;-n&lt;/code&gt; to ensure that the file in the &lt;code&gt;r_releases&lt;/code&gt; folder is not overwritten. We can confirm this by printing the contents of the file in the &lt;code&gt;r_releases&lt;/code&gt; folder.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;echo&lt;/code&gt; command is used to print text to the terminal or to write to a file. We will explore it in more detail in the next chapter.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;echo &amp;quot;release_names&amp;quot; &amp;gt; release_names_2.txt 
mv -n release_names_2.txt r_releases
cat r_releases/release_names_2.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Unsuffered Consequences
## Great Pumpkin
## December Snowflakes
## Gift-Getting Season
## Easter Beagle
## Roasted Marshmallows
## Trick or Treat
## Security Blanket
## Masked Marvel
## Good Sport
## Frisbee Sailing
## Warm Puppy
## Spring Dance
## Sock it to Me
## Pumpkin Helmet
## Smooth Sidewalk
## Full of Ingredients
## World-Famous Astronaut
## Fire Safety
## Wooden Christmas Tree
## Very Secure Dishes
## Very, Very Secure Dishes
## Supposedly Educational
## Bug in Your Hair
## Sincere Pumpkin Patch
## Another Canoe
## You Stupid Darkness
## Single Candle
## Short Summer
## Kite Eating Tree&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can observe, the contents of the file in the &lt;code&gt;r_releases&lt;/code&gt; folder has not changed. In the next section, we will learn to overwrite the contents using the &lt;code&gt;-f&lt;/code&gt; option.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;do-not-prompt-for-confirmation-before-overwriting-files&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Do not prompt for confirmation before overwriting files&lt;/h3&gt;
&lt;p&gt;What if we actually intend to overwrite a file and do not want to be prompted for confirming the same. In this case, we can use the &lt;code&gt;-f&lt;/code&gt; option which stands for &lt;code&gt;--force&lt;/code&gt; i.e. do not prompt before overwriting. Let us first print the contents of the &lt;code&gt;release_names_2.txt&lt;/code&gt; file in the &lt;code&gt;r_releases&lt;/code&gt; folder.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;cat r_releases/release_names_2.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Unsuffered Consequences
## Great Pumpkin
## December Snowflakes
## Gift-Getting Season
## Easter Beagle
## Roasted Marshmallows
## Trick or Treat
## Security Blanket
## Masked Marvel
## Good Sport
## Frisbee Sailing
## Warm Puppy
## Spring Dance
## Sock it to Me
## Pumpkin Helmet
## Smooth Sidewalk
## Full of Ingredients
## World-Famous Astronaut
## Fire Safety
## Wooden Christmas Tree
## Very Secure Dishes
## Very, Very Secure Dishes
## Supposedly Educational
## Bug in Your Hair
## Sincere Pumpkin Patch
## Another Canoe
## You Stupid Darkness
## Single Candle
## Short Summer
## Kite Eating Tree&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we will create another file of the same name in the current working directory but with different content and use the &lt;code&gt;-f&lt;/code&gt; option to overwrite the file in the &lt;code&gt;r_releases&lt;/code&gt; folder. You can see that the contents of the file in the &lt;code&gt;r_releases&lt;/code&gt; folder has changed.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;echo &amp;quot;release_names&amp;quot; &amp;gt; release_names_2.txt 
mv -f release_names_2.txt r_releases
cat r_releases/release_names_2.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## release_names&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;removedelete-files&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Remove/Delete Files&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;rm&lt;/code&gt; command is used to delete/remove files &amp;amp; folders. Using additional options, we can&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;remove directories &amp;amp; sub-directories&lt;/li&gt;
&lt;li&gt;forcibly remove directories&lt;/li&gt;
&lt;li&gt;interactively remove multiple files&lt;/li&gt;
&lt;li&gt;display information about files removed/deleted&lt;/li&gt;
&lt;/ul&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;rm&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Remove files/directories
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;rm -r&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Recursively remove a directory &amp;amp; all its subdirectories
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;rm -rf&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Forcibly remove directory without prompting for confirmation or showing error messages
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;rm -i&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Interactively remove multiple files, with a prompt before every removal
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;rm -v&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Remove files in verbose mode, printing a message for each removed file
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;div id=&#34;remove-files&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Remove files&lt;/h4&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/aEDvqZvUESk&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;p&gt;Let us use &lt;code&gt;rm&lt;/code&gt; to remove the file &lt;code&gt;myanalysis.R&lt;/code&gt; (we created it earlier using the &lt;code&gt;touch&lt;/code&gt; command).&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;rm myanalysis.R
ls&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## analysis.R
## bash.R
## bash.sh
## imports_blorr.txt
## imports_olsrr.txt
## lorem-ipsum.txt
## main_project.zip
## myfiles
## mypackage
## myproject
## myproject1
## myproject2
## myproject3
## myproject4
## package_names.txt
## pkg_names.txt
## r
## r2
## r_releases
## release_names.tar
## release_names.tar.gz
## release_names.txt
## release_names_18.txt
## release_names_19.txt
## sept_15.csv.gz
## urls.txt
## zip_example.zip&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;recursive-deletion&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Recursive Deletion&lt;/h4&gt;
&lt;p&gt;How about folders or directories? We can remove a directory and all its contents including sub-directories using the option &lt;code&gt;-r&lt;/code&gt; which stands for &lt;code&gt;--recursive&lt;/code&gt; and removes directories and their contents recursively. Let us remove the &lt;code&gt;myproject1&lt;/code&gt; folder and all its contents.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;rm -r myproject1
ls&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## analysis.R
## bash.R
## bash.sh
## imports_blorr.txt
## imports_olsrr.txt
## lorem-ipsum.txt
## main_project.zip
## myfiles
## mypackage
## myproject
## myproject2
## myproject3
## myproject4
## package_names.txt
## pkg_names.txt
## r
## r2
## r_releases
## release_names.tar
## release_names.tar.gz
## release_names.txt
## release_names_18.txt
## release_names_19.txt
## sept_15.csv.gz
## urls.txt
## zip_example.zip&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;force-removal&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Force Removal&lt;/h4&gt;
&lt;p&gt;Use the &lt;code&gt;-f&lt;/code&gt; option which stands for &lt;code&gt;--force&lt;/code&gt; to forciby remove directory and all its contents without prompting for confirmation or showing error messages. Let us remove the &lt;code&gt;myproject2&lt;/code&gt; folder and all its contents.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;rm -rf myproject2
ls&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## analysis.R
## bash.R
## bash.sh
## imports_blorr.txt
## imports_olsrr.txt
## lorem-ipsum.txt
## main_project.zip
## myfiles
## mypackage
## myproject
## myproject3
## myproject4
## package_names.txt
## pkg_names.txt
## r
## r2
## r_releases
## release_names.tar
## release_names.tar.gz
## release_names.txt
## release_names_18.txt
## release_names_19.txt
## sept_15.csv.gz
## urls.txt
## zip_example.zip&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;verbose-mode&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Verbose Mode&lt;/h4&gt;
&lt;p&gt;Remove files in verbose mode, printing a message for each removed file. This is useful when you want to see the details of the files being removed. In the below example, we will remove all files with &lt;code&gt;.txt&lt;/code&gt; extension from the &lt;code&gt;myfiles&lt;/code&gt; folder. Instead of specifying the name of each text file, we use the wildcard &lt;code&gt;*&lt;/code&gt; along with &lt;code&gt;.txt&lt;/code&gt; i.e. any file with the extension &lt;code&gt;.txt&lt;/code&gt; will be removed.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;cd myfiles
rm -v *.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## removed &amp;#39;release_names.txt&amp;#39;
## removed &amp;#39;release_names_18.txt&amp;#39;
## removed &amp;#39;release_names_19.txt&amp;#39;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;compare-files&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Compare Files&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;diff&lt;/code&gt; stands for difference. It is used to compare files line by line and display differences. It also indicates which lines in one file must be changed to make the files identical. Using additional options, we can&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;ignore white spaces while comparing files&lt;/li&gt;
&lt;li&gt;show differences sidy by side&lt;/li&gt;
&lt;li&gt;show differences in unified format&lt;/li&gt;
&lt;li&gt;compare directories recursively&lt;/li&gt;
&lt;li&gt;display names of files that differ&lt;/li&gt;
&lt;/ul&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;diff&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Compare files &amp;amp; directories
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;diff -w&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Compare files; ignoring white spaces
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;diff -y&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Compare files; showing differences side by side
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;diff -u&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Compare files; show differences in unified format
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;diff -r&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Compare directories recursively
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;diff -rq&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Compare directories; show the names of files that differ
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;div id=&#34;compare-files-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Compare Files&lt;/h4&gt;
&lt;p&gt;Let us compare the contents of the following files&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;imports_olsrr.txt&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;imports_blorr.txt&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The files contain the names of R packages imported by the &lt;a href=&#34;https://olsrr.rsquaredacademy.com/&#34;&gt;olsrr&lt;/a&gt; and &lt;a href=&#34;https://blorr.rsquaredacademy.com/&#34;&gt;blorr&lt;/a&gt; packages respectively (&lt;strong&gt;Full disclosure: both the above R pakages are developed by Rsquared Academy.&lt;/strong&gt;).&lt;/p&gt;
&lt;p&gt;&lt;code&gt;diff&lt;/code&gt; uses certain special symbols and gives instructions to make the files identical. The instructions are on how to change the first file to make it identical to the second file. We list the symbols below&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;a&lt;/strong&gt; for add&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;c&lt;/strong&gt; for change&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;d&lt;/strong&gt; for delete&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We will use the &lt;code&gt;-w&lt;/code&gt; option to ignore white spaces while comparing the files.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;diff -w imports_olsrr.txt imports_blorr.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 1a2
## &amp;gt; caret
## 3d3
## &amp;lt; cli
## 4a5
## &amp;gt; cli&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us interpret the results. &lt;code&gt;4a5&lt;/code&gt; indicates &lt;strong&gt;after line 4 in file 1, add line 5 from file 2&lt;/strong&gt; to make both the files identical i.e. add &lt;code&gt;caret&lt;/code&gt; which is line 5 in &lt;code&gt;imports_blorr.txt&lt;/code&gt; after line 4 in &lt;code&gt;imports_olsrr.txt&lt;/code&gt; which will make both the files identical.&lt;/p&gt;
&lt;p&gt;Let us change the file order and see the instructions from &lt;code&gt;diff&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;diff -w imports_blorr.txt imports_olsrr.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 2d1
## &amp;lt; caret
## 4d2
## &amp;lt; clisymbols
## 5a4
## &amp;gt; clisymbols&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;5d4&lt;/code&gt; indicates &lt;strong&gt;delete line 5 from file 1 to match both the files at line4&lt;/strong&gt; i.e. delete &lt;code&gt;caret&lt;/code&gt; which is line 5 in &lt;code&gt;imports_blorr.txt&lt;/code&gt; to make both the files identical.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;side-by-side&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Side By Side&lt;/h4&gt;
&lt;p&gt;To view the differences between the files side by side, use the &lt;code&gt;-y&lt;/code&gt; option.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;diff -y imports_olsrr.txt imports_blorr.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## car 
                                  | car
## checkmate
                                  | caret
## cli
                                  | checkmate
## clisymbols
                                  | clisymbols
##                                &amp;gt; cli&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;unified-format&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Unified Format&lt;/h4&gt;
&lt;p&gt;To view the differences between the files in a unified format, use the &lt;code&gt;-u&lt;/code&gt; option.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;diff -u imports_olsrr.txt imports_blorr.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## --- imports_olsrr.txt    2019-09-20 13:36:03.000000000 +0530
## +++ imports_blorr.txt    2019-09-20 13:36:35.000000000 +0530
## @@ -1,4 +1,5 @@
## -car 
## -checkmate
## -cli
## -clisymbols
## +car
## +caret
## +checkmate
## +clisymbols
## +cli&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;compare-recursively&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Compare Recursively&lt;/h4&gt;
&lt;p&gt;To compare recursively, use the &lt;code&gt;-r&lt;/code&gt; option. Let us compare the &lt;code&gt;mypackage&lt;/code&gt; and &lt;code&gt;myproject&lt;/code&gt; folders.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;diff -r mypackage myproject&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Only in mypackage: .Rbuildignore
## Only in mypackage: DESCRIPTION
## Only in mypackage: LICENSE
## Only in mypackage: NAMESPACE
## Only in mypackage: NEWS.md
## Only in mypackage: R
## Only in myproject/data: processed
## Only in myproject/data: raw
## Only in mypackage: docs
## Only in mypackage: man
## Only in myproject: output
## Only in myproject: run_analysis.R
## Only in mypackage: tests
## Only in mypackage: vignettes&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;file-details&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;File Details&lt;/h4&gt;
&lt;p&gt;To compare directories and view the names of files that differ, use the &lt;code&gt;-rq&lt;/code&gt; option. In the below example, we look at the names of files that differ in &lt;code&gt;mypackage&lt;/code&gt; and &lt;code&gt;myproject&lt;/code&gt; folders.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;diff -rq mypackage myproject&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Only in mypackage: .Rbuildignore
## Only in mypackage: DESCRIPTION
## Only in mypackage: LICENSE
## Only in mypackage: NAMESPACE
## Only in mypackage: NEWS.md
## Only in mypackage: R
## Only in myproject/data: processed
## Only in myproject/data: raw
## Only in mypackage: docs
## Only in mypackage: man
## Only in myproject: output
## Only in myproject: run_analysis.R
## Only in mypackage: tests
## Only in mypackage: vignettes&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;r-functions-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;R Functions&lt;/h3&gt;
&lt;p&gt;In R, file operations can be performed using functions from both base R and the &lt;a href=&#34;https://fs.r-lib.org/index.html&#34;&gt;fs&lt;/a&gt; package.&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
R
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;touch&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;file.create()&lt;/code&gt; / &lt;code&gt;fs::file_create()&lt;/code&gt; / &lt;code&gt;fs::file_touch()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;cp&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;file.copy()&lt;/code&gt; / &lt;code&gt;fs::file_copy()&lt;/code&gt; / &lt;code&gt;fs::dir_copy()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;mv&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;file.rename()&lt;/code&gt; / &lt;code&gt;fs::file_move()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;rm&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;file.remove()&lt;/code&gt; / &lt;code&gt;fs::file_delete()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;diff&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;inputoutput&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Input/Output&lt;/h2&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/tfoW1uluD2w&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;p&gt;In this section, we will explore commands that will&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;display messages&lt;/li&gt;
&lt;li&gt;print file contents&lt;/li&gt;
&lt;li&gt;sort file contents&lt;/li&gt;
&lt;/ul&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;echo&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Display messages
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;cat&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Print contents of a file
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;head&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Prints first ten lines of a file by default
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;tail&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Prints last ten lines of a file by default
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;more&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Open a file for interactive reading, scrolling &amp;amp; searching
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;less&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Open a file for interactive reading, scrolling &amp;amp; searching
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;sort&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Sort a file in ascending order
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;div id=&#34;display-messages&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Display Messages&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;echo&lt;/code&gt; command prints text to the terminal. It can be used for writing or appending messages to a file as well.&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;echo&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Display messages
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;echo -n&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Print message without trailing new line
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;echo &amp;amp;gt; file&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Write message to a file
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;echo &amp;amp;gt;&amp;amp;gt; file&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Append message to a file
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;echo -e&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Enable interpretation of special characters
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;div id=&#34;print-message&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Print Message&lt;/h4&gt;
&lt;p&gt;Let us start with a simple example. We will print the text &lt;code&gt;Action of the Toes&lt;/code&gt; to the terminal. It is the release name for R version 3.6.1.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;echo Action of the Toes&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;redirect-output&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Redirect Output&lt;/h4&gt;
&lt;p&gt;What if we want to redirect the output? Instead of printing the text to the terminal, we want to write it to a file. In such cases, use &lt;code&gt;&amp;gt;&lt;/code&gt; along with the file name to redirect the output to the file. Keep in mind that &lt;code&gt;&amp;gt;&lt;/code&gt; will overwrite files. If you want to append to files instead of overwriting, use &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;echo Great Truth &amp;gt; release.txt&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;print-concatenate-files&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Print &amp;amp; Concatenate Files&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;cat&lt;/code&gt; command reads data from files, and outputs their contents. It is the simplest way to display the contents of a file at the command line. It can be used to overwrite or append new content to files as well. &lt;code&gt;cat&lt;/code&gt; stands for &lt;strong&gt;catenate&lt;/strong&gt; and can be used to&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;display text files&lt;/li&gt;
&lt;li&gt;copy text files into a new document&lt;/li&gt;
&lt;li&gt;append the contents of a text file to the end of another text file, combining them&lt;/li&gt;
&lt;/ul&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;cat&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Print &amp;amp; concatenate files
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;cat &amp;amp;gt;&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Concatenate several files into the target file
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;cat &amp;amp;gt;&amp;amp;gt;&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Append several files into the target file
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;cat -n&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Number all output lines
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;div id=&#34;print-content&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Print Content&lt;/h4&gt;
&lt;p&gt;Let us print the content of the &lt;code&gt;release_names.txt&lt;/code&gt; file (it contains R release names).&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;cat release_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Unsuffered Consequences
## Great Pumpkin
## December Snowflakes
## Gift-Getting Season
## Easter Beagle
## Roasted Marshmallows
## Trick or Treat
## Security Blanket
## Masked Marvel
## Good Sport
## Frisbee Sailing
## Warm Puppy
## Spring Dance
## Sock it to Me
## Pumpkin Helmet
## Smooth Sidewalk
## Full of Ingredients
## World-Famous Astronaut
## Fire Safety
## Wooden Christmas Tree
## Very Secure Dishes
## Very, Very Secure Dishes
## Supposedly Educational
## Bug in Your Hair
## Sincere Pumpkin Patch
## Another Canoe
## You Stupid Darkness
## Single Candle
## Short Summer
## Kite Eating Tree&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;number-all-output-lines&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Number All Output Lines&lt;/h4&gt;
&lt;p&gt;If you want to number the output line, use the &lt;code&gt;-n&lt;/code&gt; option.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;cat -n release_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      1   Unsuffered Consequences
##      2   Great Pumpkin
##      3   December Snowflakes
##      4   Gift-Getting Season
##      5   Easter Beagle
##      6   Roasted Marshmallows
##      7   Trick or Treat
##      8   Security Blanket
##      9   Masked Marvel
##     10   Good Sport
##     11   Frisbee Sailing
##     12   Warm Puppy
##     13   Spring Dance
##     14   Sock it to Me
##     15   Pumpkin Helmet
##     16   Smooth Sidewalk
##     17   Full of Ingredients
##     18   World-Famous Astronaut
##     19   Fire Safety
##     20   Wooden Christmas Tree
##     21   Very Secure Dishes
##     22   Very, Very Secure Dishes
##     23   Supposedly Educational
##     24   Bug in Your Hair
##     25   Sincere Pumpkin Patch
##     26   Another Canoe
##     27   You Stupid Darkness
##     28   Single Candle
##     29   Short Summer
##     30   Kite Eating Tree&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;concatenate-several-files&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Concatenate Several Files&lt;/h4&gt;
&lt;p&gt;To concatenate the contents of several files into a target file, use &lt;code&gt;&amp;gt;&lt;/code&gt;. In the below example, we concatenate the contents of the files &lt;code&gt;release_names_18.txt&lt;/code&gt; and &lt;code&gt;release_names_19.txt&lt;/code&gt; into a single file &lt;code&gt;release_names_18_19.txt&lt;/code&gt;. In this case we are not printing the contents of the file to the terminal and instead we concatenate the contents from both the files and redirect the output to the target file.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;cat release_names_18.txt release_names_19.txt &amp;gt; release_names_18_19.txt
cat release_names_18_19.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Someone to Lean On
## Joy in Playing
## Feather Spray
## Eggshell IglooGreat Truth
## Planting of a Tree
## Action of the Toes&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;head&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Head&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;head&lt;/code&gt; command will display the firt 10 lines of a file(s) by default. It can be used to display the first few lines or bytes of a file as well.&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;head&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Output the first parts of a file
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;head -n&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Output the first n lines of a file
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;head -c&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Output the first c bytes of a file
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;head -n -x&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Output everything but the last x lines of a file
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;head -c -x&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Output everything but the last x bytes of a file
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;div id=&#34;output-the-first-parts-of-a-file&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Output the first parts of a file&lt;/h4&gt;
&lt;p&gt;Let us use &lt;code&gt;head&lt;/code&gt; to display the first 10 lines of the &lt;code&gt;release_names.txt&lt;/code&gt; file.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;head release_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Unsuffered Consequences
## Great Pumpkin
## December Snowflakes
## Gift-Getting Season
## Easter Beagle
## Roasted Marshmallows
## Trick or Treat
## Security Blanket
## Masked Marvel
## Good Sport&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;output-the-first-n-lines-of-a-file&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Output the first n lines of a file&lt;/h4&gt;
&lt;p&gt;Using the &lt;code&gt;n&lt;/code&gt; option, we can specify the number of lines to be displayed. In the below example, we display the first 5 lines.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;head -n 5 release_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Unsuffered Consequences
## Great Pumpkin
## December Snowflakes
## Gift-Getting Season
## Easter Beagle&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;output-the-first-c-bytes-of-a-file&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Output the first c bytes of a file&lt;/h4&gt;
&lt;p&gt;The &lt;code&gt;c&lt;/code&gt; option can be used to display characters or bytes instead of lines. Let us display the first 5 bytes of the &lt;code&gt;release_names.txt&lt;/code&gt; file.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;head -c 5 release_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Unsuf&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;output-everything-but-the-last-5-lines-of-a-file&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Output everything but the last 5 lines of a file&lt;/h4&gt;
&lt;p&gt;To display the last parts of a file, use &lt;code&gt;-&lt;/code&gt; while specifying the number of lines. In the below example, we display the last 5 lines of the file.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;head -n -5 release_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Unsuffered Consequences
## Great Pumpkin
## December Snowflakes
## Gift-Getting Season
## Easter Beagle
## Roasted Marshmallows
## Trick or Treat
## Security Blanket
## Masked Marvel
## Good Sport
## Frisbee Sailing
## Warm Puppy
## Spring Dance
## Sock it to Me
## Pumpkin Helmet
## Smooth Sidewalk
## Full of Ingredients
## World-Famous Astronaut
## Fire Safety
## Wooden Christmas Tree
## Very Secure Dishes
## Very, Very Secure Dishes
## Supposedly Educational
## Bug in Your Hair
## Sincere Pumpkin Patch&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;output-everything-but-the-last-3-bytes-of-a-file&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Output everything but the last 3 bytes of a file&lt;/h4&gt;
&lt;p&gt;In this example, we display the last 3 bytes of the file using the &lt;code&gt;c&lt;/code&gt; option and &lt;code&gt;-&lt;/code&gt; while specifying the number of bytes.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;head -c -3 release_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Unsuffered Consequences
## Great Pumpkin
## December Snowflakes
## Gift-Getting Season
## Easter Beagle
## Roasted Marshmallows
## Trick or Treat
## Security Blanket
## Masked Marvel
## Good Sport
## Frisbee Sailing
## Warm Puppy
## Spring Dance
## Sock it to Me
## Pumpkin Helmet
## Smooth Sidewalk
## Full of Ingredients
## World-Famous Astronaut
## Fire Safety
## Wooden Christmas Tree
## Very Secure Dishes
## Very, Very Secure Dishes
## Supposedly Educational
## Bug in Your Hair
## Sincere Pumpkin Patch
## Another Canoe
## You Stupid Darkness
## Single Candle
## Short Summer
## Kite Eating Tre&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;tail&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Tail&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;tail&lt;/code&gt; command displays the last 10 lines of a file(s) by default. It can be used to display the last few lines or bytes of a file as well.&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;tail&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Display the last part of a file
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;tail -n num&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Show the last num lines of a file
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;tail -n +num&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Show all contents of the file starting from num line
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;tail -c num&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Show last num bytes of a file
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;tail -f&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Keep reading file until Ctrl + C
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;tail -F&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Keep reading file until Ctrl + C; even if the file is rotated
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;div id=&#34;display-the-last-parts-of-a-file&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Display the last parts of a file&lt;/h4&gt;
&lt;p&gt;Let us use &lt;code&gt;tail&lt;/code&gt; to display the last 10 lines of the file.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;tail release_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Very Secure Dishes
## Very, Very Secure Dishes
## Supposedly Educational
## Bug in Your Hair
## Sincere Pumpkin Patch
## Another Canoe
## You Stupid Darkness
## Single Candle
## Short Summer
## Kite Eating Tree&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;display-the-last-5-lines-of-a-file&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Display the last 5 lines of a file&lt;/h4&gt;
&lt;p&gt;As we did in the previous section, use &lt;code&gt;n&lt;/code&gt; to specify the number of lines to be displayed.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;tail -n 5 release_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Another Canoe
## You Stupid Darkness
## Single Candle
## Short Summer
## Kite Eating Tree&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;display-all-contents-from-line-10&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Display all contents from line 10&lt;/h4&gt;
&lt;p&gt;We can use &lt;code&gt;tail&lt;/code&gt; to display all contents of a file starting from a specific line. In the below example, we display all contents of the file starting from the 10th line using the &lt;code&gt;n&lt;/code&gt; option and &lt;code&gt;+&lt;/code&gt; prefix while specifying the number of lines.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;tail -n +10 release_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Good Sport
## Frisbee Sailing
## Warm Puppy
## Spring Dance
## Sock it to Me
## Pumpkin Helmet
## Smooth Sidewalk
## Full of Ingredients
## World-Famous Astronaut
## Fire Safety
## Wooden Christmas Tree
## Very Secure Dishes
## Very, Very Secure Dishes
## Supposedly Educational
## Bug in Your Hair
## Sincere Pumpkin Patch
## Another Canoe
## You Stupid Darkness
## Single Candle
## Short Summer
## Kite Eating Tree&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;display-the-last-10-bytes-of-a-file&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Display the last 10 bytes of a file&lt;/h4&gt;
&lt;p&gt;Use the &lt;code&gt;c&lt;/code&gt; option to display the last 7 bytes of a file.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;tail -c 7 release_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  Tree&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;more&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;More&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;more&lt;/code&gt; command displays text, one screen at a time. It opens a file for&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;interactive reading&lt;/li&gt;
&lt;li&gt;scrolling&lt;/li&gt;
&lt;li&gt;and searching&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Press &lt;code&gt;space&lt;/code&gt; to scroll down the page, the forward slash (&lt;code&gt;/&lt;/code&gt;) for searching strings, &lt;code&gt;n&lt;/code&gt; to go to the next match and &lt;code&gt;q&lt;/code&gt; to quit.&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;more&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Open a file for interactive reading, scrolling &amp;amp; searching
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;space&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Page down
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;/&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Search for a string; press &lt;code&gt;n&lt;/code&gt; to go the next match
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;q&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Quit
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;div id=&#34;less&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Less&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;less&lt;/code&gt; command is similar to &lt;code&gt;more&lt;/code&gt; but offers more features. It allows the
user to scroll up and down, go to the beggining and end of the file, forward and backward search and the ability to go the next and previous match while searching the file.&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;less&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Open a file for interactive reading, scrolling &amp;amp; searching
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;space&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Page down
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;b&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Page up
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;G&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Go to the end of file
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;g&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Go to the start of file
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;/&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Forward search
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;?&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Backward search
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;n&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Go to next match
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;N&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Go to previous match
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;q&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Quit
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;div id=&#34;sort&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Sort&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;sort&lt;/code&gt; command will sort the contents of text file, line by line. Using additional options, we can&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;sort a file in ascending/descending order&lt;/li&gt;
&lt;li&gt;ignore case while sorting&lt;/li&gt;
&lt;li&gt;use numeric order for sorting&lt;/li&gt;
&lt;li&gt;preserve only unique lines while sorting&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Using the &lt;code&gt;sort&lt;/code&gt; command, the contents can be sorted numerically and alphabetically. By default, the rules for sorting are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;lines starting with a number will appear before lines starting with a letter.&lt;/li&gt;
&lt;li&gt;lines starting with a letter that appears earlier in the alphabet will appear
before lines starting with a letter that appears later in the alphabet.&lt;/li&gt;
&lt;li&gt;lines starting with a lowercase letter will appear before lines starting with the same letter in uppercase.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Using additional options, the rules for sorting can be changed. We list the options in the below table.&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;sort&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Sort lines of text files
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;sort -r&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Sort a file in descending order
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;sort --ignore-case&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Ignore case while sorting
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;sort -n&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Use numeric order for sorting
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;sort -u&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Preserve only unique lines while sorting
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;div id=&#34;sort-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Sort&lt;/h4&gt;
&lt;p&gt;Let us sort the contents of the &lt;code&gt;pkg_names.txt&lt;/code&gt; file. It contains names R packages randomly selected from CRAN.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;sort pkg_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## ASIP
## AdMit
## AnalyzeTS
## AzureStor
## AzureStor
## BIGDAWG
## BIOMASS
## BIOMASS
## BenfordTests
## BinOrdNonNor
## BioCircos
## ClimMobTools
## CombinePValue
## Eagle
## FField
## ICAOD
## MARSS
## MIAmaxent
## MIAmaxent
## MIAmaxent
## MVB
## MVTests
## MaXact
## MaxentVariableSelection
## OptimaRegion
## OxyBS
## PathSelectMP
## PropScrRand
## RJDBC
## RPyGeo
## SCRT
## SMARTp
## SPEDInstabR
## SemiParSampleSel
## SetMethods
## SmallCountRounding
## SpatioTemporal
## SphericalK
## SuppDists
## Survgini
## TIMP
## TSeriesMMA
## VineCopula
## WGScan
## WPKDE
## accept
## accept
## addhaz
## alfr
## aweek
## aweek
## bayesbio
## blink
## breakfast
## cbsem
## corclass
## crsra
## cyclocomp
## dagitty
## disparityfilter
## edfReader
## errorlocate
## expstudies
## fermicatsR
## foretell
## gLRTH
## gazepath
## generalhoslem
## geoknife
## hdnom
## hindexcalculator
## ibd
## interplot
## kfigr
## logNormReg
## ltxsparklines
## lue
## mbir
## mcmcabn
## mev
## mgcViz
## mined
## mlflow
## mongolite
## mongolite
## mvShapiroTest
## odk
## overlapping
## pAnalysis
## pls
## pmdplyr
## poisbinom
## randtests
## redcapAPI
## rgw
## rless
## rsed
## rstudioapi
## solitude
## splithalfr
## sspline
## sybilccFBA
## tailr
## tailr
## tictactoe
## viridisLite
## vqtl
## widyr
## widyr&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;descending-order&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Descending Order&lt;/h4&gt;
&lt;p&gt;Using the &lt;code&gt;-r&lt;/code&gt; option which stands for &lt;code&gt;--reverse&lt;/code&gt; the contents of the file can be sorted in descending/reverse order. Let us now sort the contents of the &lt;code&gt;pkg_names.txt&lt;/code&gt; file in reverse order.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;sort -r pkg_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## widyr
## widyr
## vqtl
## viridisLite
## tictactoe
## tailr
## tailr
## sybilccFBA
## sspline
## splithalfr
## solitude
## rstudioapi
## rsed
## rless
## rgw
## redcapAPI
## randtests
## poisbinom
## pmdplyr
## pls
## pAnalysis
## overlapping
## odk
## mvShapiroTest
## mongolite
## mongolite
## mlflow
## mined
## mgcViz
## mev
## mcmcabn
## mbir
## lue
## ltxsparklines
## logNormReg
## kfigr
## interplot
## ibd
## hindexcalculator
## hdnom
## geoknife
## generalhoslem
## gazepath
## gLRTH
## foretell
## fermicatsR
## expstudies
## errorlocate
## edfReader
## disparityfilter
## dagitty
## cyclocomp
## crsra
## corclass
## cbsem
## breakfast
## blink
## bayesbio
## aweek
## aweek
## alfr
## addhaz
## accept
## accept
## WPKDE
## WGScan
## VineCopula
## TSeriesMMA
## TIMP
## Survgini
## SuppDists
## SphericalK
## SpatioTemporal
## SmallCountRounding
## SetMethods
## SemiParSampleSel
## SPEDInstabR
## SMARTp
## SCRT
## RPyGeo
## RJDBC
## PropScrRand
## PathSelectMP
## OxyBS
## OptimaRegion
## MaxentVariableSelection
## MaXact
## MVTests
## MVB
## MIAmaxent
## MIAmaxent
## MIAmaxent
## MARSS
## ICAOD
## FField
## Eagle
## CombinePValue
## ClimMobTools
## BioCircos
## BinOrdNonNor
## BenfordTests
## BIOMASS
## BIOMASS
## BIGDAWG
## AzureStor
## AzureStor
## AnalyzeTS
## AdMit
## ASIP&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;ignore-case&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Ignore case&lt;/h4&gt;
&lt;p&gt;To ignore case while sorting contents, use the &lt;code&gt;--ignore-case&lt;/code&gt; option. Time to sort the &lt;code&gt;pkg_names.txt&lt;/code&gt; file while ignoring case.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;sort --ignore-case pkg_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## accept
## accept
## addhaz
## AdMit
## alfr
## AnalyzeTS
## ASIP
## aweek
## aweek
## AzureStor
## AzureStor
## bayesbio
## BenfordTests
## BIGDAWG
## BinOrdNonNor
## BioCircos
## BIOMASS
## BIOMASS
## blink
## breakfast
## cbsem
## ClimMobTools
## CombinePValue
## corclass
## crsra
## cyclocomp
## dagitty
## disparityfilter
## Eagle
## edfReader
## errorlocate
## expstudies
## fermicatsR
## FField
## foretell
## gazepath
## generalhoslem
## geoknife
## gLRTH
## hdnom
## hindexcalculator
## ibd
## ICAOD
## interplot
## kfigr
## logNormReg
## ltxsparklines
## lue
## MARSS
## MaXact
## MaxentVariableSelection
## mbir
## mcmcabn
## mev
## mgcViz
## MIAmaxent
## MIAmaxent
## MIAmaxent
## mined
## mlflow
## mongolite
## mongolite
## MVB
## mvShapiroTest
## MVTests
## odk
## OptimaRegion
## overlapping
## OxyBS
## pAnalysis
## PathSelectMP
## pls
## pmdplyr
## poisbinom
## PropScrRand
## randtests
## redcapAPI
## rgw
## RJDBC
## rless
## RPyGeo
## rsed
## rstudioapi
## SCRT
## SemiParSampleSel
## SetMethods
## SmallCountRounding
## SMARTp
## solitude
## SpatioTemporal
## SPEDInstabR
## SphericalK
## splithalfr
## sspline
## SuppDists
## Survgini
## sybilccFBA
## tailr
## tailr
## tictactoe
## TIMP
## TSeriesMMA
## VineCopula
## viridisLite
## vqtl
## WGScan
## widyr
## widyr
## WPKDE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;numeric-order&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Numeric Order&lt;/h4&gt;
&lt;p&gt;To sort numerically, use the &lt;code&gt;-n&lt;/code&gt; option which stands for &lt;code&gt;--numeric-sort&lt;/code&gt;. In this example, we will use a different file, &lt;code&gt;package_names.txt&lt;/code&gt; where the package names are prefixed by random numbers between 1 and 100.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;sort -n package_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 1. cyclocomp
## 2. odk
## 3. redcapAPI
## 4. TIMP
## 5. pls
## 6. BinOrdNonNor
## 7. bayesbio
## 8. MVTests
## 9. pAnalysis
## 10. aweek
## 11. hdnom
## 12. ltxsparklines
## 13. MaXact
## 14. RJDBC
## 15. MIAmaxent
## 16. randtests
## 17. ASIP
## 18. gazepath
## 19. mcmcabn
## 20. rless
## 21. corclass
## 22. vqtl
## 23. disparityfilter
## 24. SCRT
## 25. RPyGeo
## 26. blink
## 27. gLRTH
## 28. splithalfr
## 29. sspline
## 29. sspline
## 30. logNormReg
## 31. BIGDAWG
## 31. BIGDAWG
## 32. SPEDInstabR
## 33. tailr
## 33. tailr
## 34. ibd
## 35. fermicatsR
## 36. mlflow
## 37. CombinePValue
## 38. BenfordTests
## 39. mev
## 40. MaxentVariableSelection
## 41. rstudioapi
## 42. OptimaRegion
## 43. accept
## 44. expstudies
## 45. solitude
## 45. solitude
## 46. cbsem
## 47. SMARTp
## 48. geoknife
## 49. SemiParSampleSel
## 50. mbir
## 51. interplot
## 52. ClimMobTools
## 53. MVB
## 54. OxyBS
## 55. hindexcalculator
## 56. MARSS
## 57. generalhoslem
## 58. alfr
## 59. AdMit
## 60. Eagle
## 61. PropScrRand
## 62. lue
## 63. dagitty
## 64. viridisLite
## 65. mined
## 65. mined
## 66. SuppDists
## 67. tictactoe
## 68. AzureStor
## 68. AzureStor
## 69. FField
## 70. rsed
## 70. rsed
## 71. kfigr
## 72. overlapping
## 72. overlapping
## 73. VineCopula
## 74. crsra
## 75. pmdplyr
## 76. errorlocate
## 77. SetMethods
## 78. sybilccFBA
## 79. mvShapiroTest
## 80. SpatioTemporal
## 81. mgcViz
## 82. breakfast
## 83. WPKDE
## 84. BIOMASS
## 85. edfReader
## 86. mongolite
## 87. WGScan
## 88. SphericalK
## 89. foretell
## 90. widyr
## 91. rgw
## 92. BioCircos
## 93. PathSelectMP
## 94. ICAOD
## 95. TSeriesMMA
## 96. poisbinom
## 97. AnalyzeTS
## 98. SmallCountRounding
## 99. Survgini
## 100. addhaz&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;preserve-only-unique-lines&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Preserve Only Unique Lines&lt;/h4&gt;
&lt;p&gt;The &lt;code&gt;-u&lt;/code&gt; option which stands for &lt;code&gt;--unique&lt;/code&gt; will preserve only unique lines while sorting the contents of the file. In the below example, we remove all duplicate lines from the &lt;code&gt;pkg_names.txt&lt;/code&gt; while sorting.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;sort -u pkg_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## ASIP
## AdMit
## AnalyzeTS
## AzureStor
## BIGDAWG
## BIOMASS
## BenfordTests
## BinOrdNonNor
## BioCircos
## ClimMobTools
## CombinePValue
## Eagle
## FField
## ICAOD
## MARSS
## MIAmaxent
## MVB
## MVTests
## MaXact
## MaxentVariableSelection
## OptimaRegion
## OxyBS
## PathSelectMP
## PropScrRand
## RJDBC
## RPyGeo
## SCRT
## SMARTp
## SPEDInstabR
## SemiParSampleSel
## SetMethods
## SmallCountRounding
## SpatioTemporal
## SphericalK
## SuppDists
## Survgini
## TIMP
## TSeriesMMA
## VineCopula
## WGScan
## WPKDE
## accept
## accept
## addhaz
## alfr
## aweek
## bayesbio
## blink
## breakfast
## cbsem
## corclass
## crsra
## cyclocomp
## dagitty
## disparityfilter
## edfReader
## errorlocate
## expstudies
## fermicatsR
## foretell
## gLRTH
## gazepath
## generalhoslem
## geoknife
## hdnom
## hindexcalculator
## ibd
## interplot
## kfigr
## logNormReg
## ltxsparklines
## lue
## mbir
## mcmcabn
## mev
## mgcViz
## mined
## mlflow
## mongolite
## mvShapiroTest
## odk
## overlapping
## pAnalysis
## pls
## pmdplyr
## poisbinom
## randtests
## redcapAPI
## rgw
## rless
## rsed
## rstudioapi
## solitude
## splithalfr
## sspline
## sybilccFBA
## tailr
## tictactoe
## viridisLite
## vqtl
## widyr&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;word-count&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Word Count&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;wc&lt;/code&gt; will print newline, word, and byte counts for file(s). If more than one file is specified, it will also print total line.&lt;/p&gt;
&lt;div id=&#34;count-words-bytes-and-lines&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Count words, bytes and lines&lt;/h4&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;wc release_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  30  73 546 release_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;count-lines-in-a-file&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Count lines in a file&lt;/h4&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;wc -l release_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 30 release_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;count-words-in-a-file&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Count words in a file&lt;/h4&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;wc -w release_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 73 release_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;count-charactersbytes-in-a-file&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Count characters(bytes) in a file&lt;/h4&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;wc -c release_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 546 release_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;p&gt;
&lt;a href=&#34;https://www.youtube.com/user/rsquaredin/&#34; target=&#34;_blank&#34;&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/ad_youtube.png&#34; width=&#34;100%&#34; alt=&#34;youtube ad&#34; style=&#34;text-decoration: none;&#34;&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;hr&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;regex&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Search &amp;amp; Regular Expressions&lt;/h2&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/8BkandsUpeI&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;p&gt;In this section, we will explore commands that will&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;search for a given string in a file&lt;/li&gt;
&lt;li&gt;find files using names&lt;/li&gt;
&lt;li&gt;and search for binary executable files&lt;/li&gt;
&lt;/ul&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;grep&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Search for a given string in a file
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;find&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Find files using filenames
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;which&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Search for binary executable files
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;div id=&#34;grep&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;grep&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;grep&lt;/code&gt; command is used for pattern matching. Along with additional options, it can be used to&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;match pattern in input text&lt;/li&gt;
&lt;li&gt;ignore case&lt;/li&gt;
&lt;li&gt;search recursively for an exact string&lt;/li&gt;
&lt;li&gt;print filename and line number for each match&lt;/li&gt;
&lt;li&gt;invert match for excluding specific strings&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;grep&lt;/code&gt; processes text line by line, and prints any lines which match a specified pattern. &lt;code&gt;grep&lt;/code&gt;, which stands for &lt;strong&gt;g&lt;/strong&gt;lobal &lt;strong&gt;r&lt;/strong&gt;egular &lt;strong&gt;e&lt;/strong&gt;xpression &lt;strong&gt;p&lt;/strong&gt;rint is a powerful tool for matching a regular expression against text in a file, multiple files, or a stream of input.&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;grep&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Matches pattern in input text
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;grep -i&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Ignore case
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;grep -RI&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Search recursively for an exact string
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;grep -E&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Use extended regular expression
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;grep -Hn&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Print file name &amp;amp; corresponding line number for each match
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;grep -v&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Invert match for excluding specific strings
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;div id=&#34;match-pattern-in-input-text&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Match Pattern in Input Text&lt;/h4&gt;
&lt;p&gt;Using &lt;code&gt;grep&lt;/code&gt; let us search for packages that inlcude the letter &lt;code&gt;R&lt;/code&gt; in their names.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;grep R package_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 14. RJDBC
## 30. logNormReg
## 27. gLRTH
## 35. fermicatsR
## 42. OptimaRegion
## 61. PropScrRand
## 25. RPyGeo
## 47. SMARTp
## 24. SCRT
## 56. MARSS
## 85. edfReader
## 32. SPEDInstabR
## 98. SmallCountRounding&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;ignore-case-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Ignore Case&lt;/h4&gt;
&lt;p&gt;In the previous case, &lt;code&gt;grep&lt;/code&gt; returned only those packages whose name included &lt;code&gt;R&lt;/code&gt; but not &lt;code&gt;r&lt;/code&gt; i.e. it did not ignore the case of the letter. Using the &lt;code&gt;-i&lt;/code&gt; option, we will now search while ignoring the case of the letter.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;grep -i R package_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 14. RJDBC
## 58. alfr
## 64. viridisLite
## 99. Survgini
## 30. logNormReg
## 27. gLRTH
## 71. kfigr
## 72. overlapping
## 90. widyr
## 33. tailr
## 40. MaxentVariableSelection
## 33. tailr
## 72. overlapping
## 16. randtests
## 12. ltxsparklines
## 91. rgw
## 35. fermicatsR
## 21. corclass
## 68. AzureStor
## 42. OptimaRegion
## 61. PropScrRand
## 74. crsra
## 80. SpatioTemporal
## 23. disparityfilter
## 49. SemiParSampleSel
## 76. errorlocate
## 88. SphericalK
## 28. splithalfr
## 89. foretell
## 25. RPyGeo
## 50. mbir
## 51. interplot
## 6. BinOrdNonNor
## 47. SMARTp
## 38. BenfordTests
## 79. mvShapiroTest
## 92. BioCircos
## 55. hindexcalculator
## 41. rstudioapi
## 57. generalhoslem
## 24. SCRT
## 95. TSeriesMMA
## 82. breakfast
## 56. MARSS
## 70. rsed
## 68. AzureStor
## 85. edfReader
## 20. rless
## 75. pmdplyr
## 32. SPEDInstabR
## 3. redcapAPI
## 70. rsed
## 98. SmallCountRounding&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;highlight&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Highlight&lt;/h4&gt;
&lt;p&gt;The &lt;code&gt;--color&lt;/code&gt; option will highlight the matched strings.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;grep -i --color R package_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 14. RJDBC
## 58. alfr
## 64. viridisLite
## 99. Survgini
## 30. logNormReg
## 27. gLRTH
## 71. kfigr
## 72. overlapping
## 90. widyr
## 33. tailr
## 40. MaxentVariableSelection
## 33. tailr
## 72. overlapping
## 16. randtests
## 12. ltxsparklines
## 91. rgw
## 35. fermicatsR
## 21. corclass
## 68. AzureStor
## 42. OptimaRegion
## 61. PropScrRand
## 74. crsra
## 80. SpatioTemporal
## 23. disparityfilter
## 49. SemiParSampleSel
## 76. errorlocate
## 88. SphericalK
## 28. splithalfr
## 89. foretell
## 25. RPyGeo
## 50. mbir
## 51. interplot
## 6. BinOrdNonNor
## 47. SMARTp
## 38. BenfordTests
## 79. mvShapiroTest
## 92. BioCircos
## 55. hindexcalculator
## 41. rstudioapi
## 57. generalhoslem
## 24. SCRT
## 95. TSeriesMMA
## 82. breakfast
## 56. MARSS
## 70. rsed
## 68. AzureStor
## 85. edfReader
## 20. rless
## 75. pmdplyr
## 32. SPEDInstabR
## 3. redcapAPI
## 70. rsed
## 98. SmallCountRounding&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;print-filename&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Print Filename&lt;/h4&gt;
&lt;p&gt;If there is more than one file to search, use the &lt;code&gt;-H&lt;/code&gt; option to print the filename for each match.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;grep -i --color -H bio package_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## package_names.txt:84. BIOMASS
## package_names.txt:92. BioCircos
## package_names.txt:7. bayesbio&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;print-corresponding-line-number&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Print Corresponding Line Number&lt;/h4&gt;
&lt;p&gt;The &lt;code&gt;-n&lt;/code&gt; option will print the corresponding line number of the match in the file.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;grep -i --color -n bio package_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 59:84. BIOMASS
## 71:92. BioCircos
## 88:7. bayesbio&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;print-filename-line-number&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Print Filename &amp;amp; Line Number&lt;/h4&gt;
&lt;p&gt;Let us print both the file name and the line number for each match.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;grep -i --color -Hn R package_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## package_names.txt:1:14. RJDBC
## package_names.txt:3:58. alfr
## package_names.txt:8:64. viridisLite
## package_names.txt:14:99. Survgini
## package_names.txt:15:30. logNormReg
## package_names.txt:16:27. gLRTH
## package_names.txt:18:71. kfigr
## package_names.txt:20:72. overlapping
## package_names.txt:21:90. widyr
## package_names.txt:22:33. tailr
## package_names.txt:23:40. MaxentVariableSelection
## package_names.txt:26:33. tailr
## package_names.txt:27:72. overlapping
## package_names.txt:30:16. randtests
## package_names.txt:31:12. ltxsparklines
## package_names.txt:32:91. rgw
## package_names.txt:33:35. fermicatsR
## package_names.txt:37:21. corclass
## package_names.txt:38:68. AzureStor
## package_names.txt:41:42. OptimaRegion
## package_names.txt:42:61. PropScrRand
## package_names.txt:43:74. crsra
## package_names.txt:51:80. SpatioTemporal
## package_names.txt:52:23. disparityfilter
## package_names.txt:54:49. SemiParSampleSel
## package_names.txt:55:76. errorlocate
## package_names.txt:57:88. SphericalK
## package_names.txt:61:28. splithalfr
## package_names.txt:62:89. foretell
## package_names.txt:63:25. RPyGeo
## package_names.txt:64:50. mbir
## package_names.txt:65:51. interplot
## package_names.txt:66:6. BinOrdNonNor
## package_names.txt:67:47. SMARTp
## package_names.txt:68:38. BenfordTests
## package_names.txt:69:79. mvShapiroTest
## package_names.txt:71:92. BioCircos
## package_names.txt:75:55. hindexcalculator
## package_names.txt:78:41. rstudioapi
## package_names.txt:80:57. generalhoslem
## package_names.txt:84:24. SCRT
## package_names.txt:85:95. TSeriesMMA
## package_names.txt:87:82. breakfast
## package_names.txt:96:56. MARSS
## package_names.txt:97:70. rsed
## package_names.txt:98:68. AzureStor
## package_names.txt:100:85. edfReader
## package_names.txt:101:20. rless
## package_names.txt:102:75. pmdplyr
## package_names.txt:103:32. SPEDInstabR
## package_names.txt:104:3. redcapAPI
## package_names.txt:106:70. rsed
## package_names.txt:107:98. SmallCountRounding&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;invert-match&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Invert Match&lt;/h4&gt;
&lt;p&gt;Use the &lt;code&gt;-v&lt;/code&gt; option to select non-matching lines. In the below example, we search for packages whose name does not include &lt;code&gt;R&lt;/code&gt; while ignoring the case.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;grep -v -i R package_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 36. mlflow
## 10. aweek
## 31. BIGDAWG
## 22. vqtl
## 29. sspline
## 39. mev
## 66. SuppDists
## 15. MIAmaxent
## 31. BIGDAWG
## 29. sspline
## 60. Eagle
## 83. WPKDE
## 11. hdnom
## 26. blink
## 18. gazepath
## 52. ClimMobTools
## 44. expstudies
## 65. mined
## 81. mgcViz
## 45. solitude
## 9. pAnalysis
## 65. mined
## 94. ICAOD
## 48. geoknife
## 45. solitude
## 67. tictactoe
## 46. cbsem
## 93. PathSelectMP
## 96. poisbinom
## 17. ASIP
## 5. pls
## 84. BIOMASS
## 59. AdMit
## 77. SetMethods
## 53. MVB
## 2. odk
## 86. mongolite
## 4. TIMP
## 97. AnalyzeTS
## 87. WGScan
## 63. dagitty
## 69. FField
## 13. MaXact
## 73. VineCopula
## 7. bayesbio
## 34. ibd
## 8. MVTests
## 19. mcmcabn
## 43. accept
## 78. sybilccFBA
## 62. lue
## 100. addhaz
## 37. CombinePValue
## 1. cyclocomp
## 54. OxyBS&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;recursive-search&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Recursive Search&lt;/h4&gt;
&lt;p&gt;Use the &lt;code&gt;-r&lt;/code&gt; option to search recursively. In the below example, we search all files with the &lt;code&gt;.txt&lt;/code&gt; extension for the string &lt;code&gt;bio&lt;/code&gt; while ignoring the case.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;grep -i --color -r bio *.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## package_names.txt:84. BIOMASS
## package_names.txt:92. BioCircos
## package_names.txt:7. bayesbio
## pkg_names.txt:BIOMASS
## pkg_names.txt:BioCircos
## pkg_names.txt:BIOMASS
## pkg_names.txt:bayesbio&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;find&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;find&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;find&lt;/code&gt; command can be used for searching files and directories. Using additional options, we can&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;search files by extension type&lt;/li&gt;
&lt;li&gt;ignore case while searching files/directories&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;find&lt;/code&gt; is a powerful tool for working with the files. It can be used on its own to locate files, or in conjunction with other programs to perform operations on those files.&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;find&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Find files or directories under the given directory; recursively
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;find -name &#39;*.txt&#39;&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Find files by extension
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;find -type d -iname&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Find directories matching a given name, in case-insensitive mode
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;find -type d -name&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Find directories matching a given name, in case-sensitive mode
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;div id=&#34;search-recursively&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Search Recursively&lt;/h4&gt;
&lt;p&gt;Let us use &lt;code&gt;find&lt;/code&gt; to search for the file &lt;code&gt;release_names.txt&lt;/code&gt; recursively. The &lt;code&gt;-name&lt;/code&gt; option is used to specify the name of the file we are searching.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;find -name release_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## ./release_names.txt
## ./r_releases/release_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There are two files with the name &lt;code&gt;release_names.txt&lt;/code&gt; present in the current working directory and in &lt;code&gt;r_releases&lt;/code&gt; directory.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;search-by-extension&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Search by Extension&lt;/h4&gt;
&lt;p&gt;Let us search for all files with &lt;code&gt;.txt&lt;/code&gt; extension in the &lt;code&gt;r_releases&lt;/code&gt; folder.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;find r_releases -name &amp;#39;*.txt&amp;#39;&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## r_releases/release_names.txt
## r_releases/release_names_2.txt
## r_releases/release_names_3.txt&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There are 3 files with the &lt;code&gt;.txt&lt;/code&gt; extension in &lt;code&gt;r_releases&lt;/code&gt; folder.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;case-insensitive-mode&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Case-insensitive Mode&lt;/h4&gt;
&lt;p&gt;Search for all folders with the name &lt;code&gt;R&lt;/code&gt; or &lt;code&gt;r&lt;/code&gt;. Here we use the &lt;code&gt;-iname&lt;/code&gt; option to ignore case while searching. The &lt;code&gt;-type&lt;/code&gt; option is used to specify whether we are searching for files or folders. Since we are searching for folder/directory, we use it along with &lt;code&gt;d&lt;/code&gt; i.e. directory to indicate that we are searching for directories and not files.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;find -type d -iname R&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## ./mypackage/R
## ./r&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;case-sensitive-mode&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Case-sensitive Mode&lt;/h4&gt;
&lt;p&gt;Search for all folders with the name &lt;code&gt;r&lt;/code&gt;. It should exclude any folder with the name &lt;code&gt;R&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;find -type d -name r&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## ./r&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;datatransfer&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data Transfer &amp;amp; Network&lt;/h2&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/06QPodqmAO0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;p&gt;In this section, we will explore commands that will allow us to download files
from the internet.&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;wget&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Download files from the web
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;curl&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Transfer data from or to a server
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;hostname&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Name of the current host
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;ping&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Ping a remote host
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;nslookup&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Name server details
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;We have not executed the commands in this ebook as downloading multiple files from the internet will take a lot of time or result in errors but we have checked all the commands offline to ensure that they work.&lt;/p&gt;
&lt;div id=&#34;wget&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;wget&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;wget&lt;/code&gt; command will download contents of a URL and files from the internet.
Using additional options, we can&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;download contents/files to a file&lt;/li&gt;
&lt;li&gt;continue incomplete downloads&lt;/li&gt;
&lt;li&gt;download multiple files&lt;/li&gt;
&lt;li&gt;limit download speed and number of retries&lt;/li&gt;
&lt;/ul&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;wget url&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Download contents of a url
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;wget -o file url&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Download contents of url to a file
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;wget -c&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Continue an incomplete download
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;wget -P folder_name -i urls.txt&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Download all urls stored in a text file to a specific directory
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;wget --limit-rate&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Limit download speed
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;wget --tries&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Limit number of retries
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;wget --quiet&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Turn off output
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;wget --no-verbose&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Print basic information
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;wget --progress-dot&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Change progress bar type to dot
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;wget --timestamping&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Check if the timestamp of the file has changed before downloading
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;wget --wait&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Wait between retrievals
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;div id=&#34;download-url&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Download URL&lt;/h4&gt;
&lt;p&gt;Let us first use &lt;code&gt;wget&lt;/code&gt; to download contents of a URL. Note, we are not downloading file as such but just the content of the URL. We will use the URL of the home page of &lt;a href=&#34;https://www.r-project.org/&#34;&gt;R&lt;/a&gt; project.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;wget https://www.r-project.org/&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you look at the list of files, you can see a new file, &lt;code&gt;index.html&lt;/code&gt; which we just downloaded using &lt;code&gt;wget&lt;/code&gt;. Downloading contents this way will lead to confusion if we are dealing with multiple URLs. Let us learn to save the contents to a file (we can specify the name of the file which should help avoid confusion.)&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;specify-filename&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Specify Filename&lt;/h4&gt;
&lt;p&gt;In this example, we download contents from the same URL and in addition specify the name of the file in which the content must be saved. Here we save it in a new file, &lt;code&gt;rhomepage.html&lt;/code&gt; using the &lt;code&gt;-o&lt;/code&gt; option followed by the filename.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;wget -o rhomepage.html https://www.r-project.org/&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;download-file&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Download File&lt;/h4&gt;
&lt;p&gt;How about downloading a file instead of a URL? In this example, we will download a logfile from the &lt;a href=&#34;http://cran-logs.rstudio.com/&#34;&gt;RStudio CRAN&lt;/a&gt; mirror. It contains the details of R downloads and individual package downloads. If you are a package developer and would want to know the countries in which your packages are downloaded, you will find this useful. We will download the file for 29th September and save it as &lt;code&gt;sep_29.csv.gz&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;wget -o sep_29.csv.gz http://cran-logs.rstudio.com/2019/2019-09-29.csv.gz&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;download-multiple-urls&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Download Multiple URLs&lt;/h4&gt;
&lt;p&gt;How do we download multiple URLs? One way is to specify the URLs one after the other separated by a space or save all URLs in a file and read them one by one. In the below example, we have saved multiple URLs in the file &lt;code&gt;urls.txt&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;cat urls.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## http://cran-logs.rstudio.com/2019/2019-09-26.csv.gz
## http://cran-logs.rstudio.com/2019/2019-09-27.csv.gz
## http://cran-logs.rstudio.com/2019/2019-09-28.csv.gz&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We will download all the above URLs and save them in a new folder &lt;code&gt;downloads&lt;/code&gt;. The &lt;code&gt;-i&lt;/code&gt; indicates that the URLs must be read from a file (local or external). The &lt;code&gt;-P&lt;/code&gt; option allows us to specify the directory into which all the files will be downloaded.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;wget -P downloads -i urls.txt     &lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;quiet&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Quiet&lt;/h4&gt;
&lt;p&gt;The &lt;code&gt;--quiet&lt;/code&gt; option will turn off &lt;code&gt;wget&lt;/code&gt; output. It will not show any of the following details:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;name of the file being saved&lt;/li&gt;
&lt;li&gt;file size&lt;/li&gt;
&lt;li&gt;download speed&lt;/li&gt;
&lt;li&gt;eta etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;wget –-quiet http://cran-logs.rstudio.com/2019/2019-10-06.csv.gz&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;no-verbose&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;No Verbose&lt;/h4&gt;
&lt;p&gt;Using the &lt;code&gt;-nv&lt;/code&gt; or &lt;code&gt;--no-verbose&lt;/code&gt; option, we can turn off verbose without being completely quiet (as we did in the previous example). Any error messages and basic information will still be printed.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;wget –-no-verbose http://cran-logs.rstudio.com/2019/2019-10-13.csv.gz    &lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;check-timestamp&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Check Timestamp&lt;/h4&gt;
&lt;p&gt;Let us say we have already downloaded a file from a URL. The file is updated from time to time and we intend to keep the local copy updated as well. Using the &lt;code&gt;--timestamping&lt;/code&gt; option, the local file will have timestamp matching the remote file; if the remote file is not newer (not updated), no download will occur i.e. if the timestamp of the remote file has not changed it will not be downloaded. This is very useful in case of large files where you do not want to download them unless they have been updated.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;wget –-timestamping http://cran-logs.rstudio.com/2019/2019-10-13.csv.gz&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;curl&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;curl&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;curl&lt;/code&gt; command will transfer data from or to a server. We will only look at
downloading files from the internet.&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;curl url&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Download contents of a url
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;curl url -o file&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Download contents of url to a file
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;curl url &amp;amp;gt; file&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Download contents of url to a file
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;curl -s&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Download in silent or quiet mode
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;div id=&#34;download-url-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Download URL&lt;/h4&gt;
&lt;p&gt;Let us download the home page of the &lt;a href=&#34;https://www.r-project.org/&#34;&gt;R&lt;/a&gt; project using &lt;code&gt;curl&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;curl https://www.r-project.org/&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;specify-file&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Specify File&lt;/h4&gt;
&lt;p&gt;Let us download another log file from the &lt;a href=&#34;http://cran-logs.rstudio.com/&#34;&gt;RStudio CRAN&lt;/a&gt; mirror and save it into a file using the &lt;code&gt;-o&lt;/code&gt; option.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;curl http://cran-logs.rstudio.com/2019/2019-09-08.csv.gz -o sept_08.csv.gz &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Another way to save a downloaded file is to use &lt;code&gt;&amp;gt;&lt;/code&gt; followed by the name of the file as shown in the below example.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;curl http://cran-logs.rstudio.com/2019/2019-09-01.csv.gz &amp;gt; sep_01.csv.gz&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;download-silently&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Download Silently&lt;/h4&gt;
&lt;p&gt;The &lt;code&gt;-s&lt;/code&gt; option will allow you to download files silently. It will mute &lt;code&gt;curl&lt;/code&gt; and will not display progress meter or error messages.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;curl http://cran-logs.rstudio.com/2019/2019-09-01.csv.gz -o sept_01.csv.gz -s&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;r-functions-2&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;R Functions&lt;/h3&gt;
&lt;p&gt;In R, we can use &lt;code&gt;download.file()&lt;/code&gt; to download files from the internet. The following packages offer functionalities that you will find useful.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://cran.r-project.org/package=curl&#34;&gt;curl&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://cran.r-project.org/package=R.utils&#34;&gt;R.utils&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://cran.r-project.org/package=pingr&#34;&gt;pingr&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
R
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;wget&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;download.file()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;curl&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;curl::curl_download()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;hostname&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;R.utils::getHostname.System()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;ping&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;pingr::ping()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;nslookup&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;curl::nslookup()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;sudo&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;sudo&lt;/h2&gt;
&lt;p&gt;sudo &lt;strong&gt;S&lt;/strong&gt;uper &lt;strong&gt;U&lt;/strong&gt;ser &lt;strong&gt;DO&lt;/strong&gt; is a prefix of commands that only superuser or root users are allowed to run. It is similar to &lt;strong&gt;run as administrator&lt;/strong&gt; option in Windows. It is used to install, update and remove software. We will use it in the next section to install &amp;amp; update packages. If you are using RStudio Cloud, you will not be able to run &lt;strong&gt;sudo&lt;/strong&gt; (users do not have root privileges).&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;dpkg --list&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
List installed packages
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;sudo apt-get update&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Update packages
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;sudo apt-get install&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Install packages
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;sudo apt-get remove&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Remove packages (retain configuration, plugins and settings
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;sudo apt-get purge&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Remove packages including personalized settings
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;sudo apt-get autoremove&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Remove any dependencies no longer in use
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;div id=&#34;compress&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;File Compression&lt;/h2&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/ucF-wwfmAwM&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;div id=&#34;tar&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;tar&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;tar&lt;/code&gt; command is used for file compression. It works with both &lt;code&gt;tar&lt;/code&gt; and
&lt;code&gt;tar.gz&lt;/code&gt; extensions. It is used to&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;list files&lt;/li&gt;
&lt;li&gt;extract files&lt;/li&gt;
&lt;li&gt;create archives&lt;/li&gt;
&lt;li&gt;append file to existing archives&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;tar&lt;/code&gt; creates, maintains, modifies, and extracts files that are archived in the tar format. Tar stands for &lt;strong&gt;t&lt;/strong&gt;ape &lt;strong&gt;ar&lt;/strong&gt;chive and is an archiving file format.&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;tar tvf&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
List an archive
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;tar tvfz&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
List a gzipped archive
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;tar xvf&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Extract an archive
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;tar xvfz&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Extract a gzipped archive
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;tar cvf&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Create an uncompressed tar archive
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;tar cvfz&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Create a tar gzipped archive
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;tar rvf&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Add a file to an existing archive
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;tar rvfz&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Add a file to an existing gzipped archive
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;We will use different options along with the &lt;code&gt;tar&lt;/code&gt; command for listing, extracting, creating and adding files. The &lt;code&gt;vf&lt;/code&gt; (&lt;strong&gt;v&lt;/strong&gt; stands for verbosely show .tar file progress and &lt;strong&gt;f&lt;/strong&gt; stands for file name type of the archive file) option is common for all the above operations while the following are specific.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;t&lt;/code&gt; for listing&lt;/li&gt;
&lt;li&gt;&lt;code&gt;x&lt;/code&gt; for extracting&lt;/li&gt;
&lt;li&gt;&lt;code&gt;c&lt;/code&gt; for creating&lt;/li&gt;
&lt;li&gt;&lt;code&gt;r&lt;/code&gt; for adding files&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;While dealing with &lt;code&gt;tar.gz&lt;/code&gt; archives we will use &lt;code&gt;z&lt;/code&gt; in addition to &lt;code&gt;vf&lt;/code&gt; and the above options.&lt;/p&gt;
&lt;div id=&#34;list&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;List&lt;/h4&gt;
&lt;p&gt;Let us list all the files &amp;amp; folders in &lt;code&gt;release_names.tar&lt;/code&gt;. As mentioned above. to list the files in the archive, we use the &lt;code&gt;t&lt;/code&gt; option.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;tar -tvf release_names.tar &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## -rwxrwxrwx aravind/aravind 546 2019-09-16 15:59 release_names.txt
## -rwxrwxrwx aravind/aravind  65 2019-09-16 15:58 release_names_18.txt
## -rwxrwxrwx aravind/aravind  53 2019-09-16 15:59 release_names_19.txt&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;extract&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Extract&lt;/h4&gt;
&lt;p&gt;Let us extract files from &lt;code&gt;release_names.tar&lt;/code&gt; using the &lt;code&gt;x&lt;/code&gt; option in addition to &lt;code&gt;vf&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;tar -xvf release_names.tar 
ls&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## release_names.txt
## release_names_18.txt
## release_names_19.txt
## analysis.R
## bash.R
## bash.sh
## imports_blorr.txt
## imports_olsrr.txt
## lorem-ipsum.txt
## main_project.zip
## myfiles
## mypackage
## myproject
## myproject3
## myproject4
## package_names.txt
## pkg_names.txt
## r
## r2
## r_releases
## release_names.tar
## release_names.tar.gz
## release_names.txt
## release_names_18.txt
## release_names_18_19.txt
## release_names_19.txt
## sept_15.csv.gz
## urls.txt
## zip_example.zip&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;add&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Add&lt;/h4&gt;
&lt;p&gt;To add a file to an existing archive, use the &lt;code&gt;r&lt;/code&gt; option. Let us add &lt;code&gt;release_names_18.txt&lt;/code&gt; and &lt;code&gt;release_names_19.txt&lt;/code&gt; to the archive we created in the previous step.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;tar -rvf release_names.tar release_names_18.txt release_names_19.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## release_names_18.txt
## release_names_19.txt&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;create&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Create&lt;/h4&gt;
&lt;p&gt;Using the &lt;code&gt;c&lt;/code&gt; option we can create tar archives. In the below example, we are using a single file but you can specify multiple files and folders as well.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;tar -cvf pkg_names.tar pkg_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## pkg_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;gzip&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;gzip&lt;/h3&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;gzip&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Compress a file
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;gzip -d&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Decompress a file
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;gzip -c&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Compress a file and specify the output file name
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;zip -r&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Compress a directory
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;zip&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Add files to an existing zip file
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;unzip&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Extract files from a zip files
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;unzip -d&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Extract files from a zip file and specify the output file name
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;unzip -l&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
List contents of a zip file
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;code&gt;gzip&lt;/code&gt;, &lt;code&gt;gunzip&lt;/code&gt;, and &lt;code&gt;zcat&lt;/code&gt; commands are used to compress or expand files in the GNU GZIP format i.e. files with &lt;code&gt;.gz&lt;/code&gt; extension&lt;/p&gt;
&lt;div id=&#34;compress-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Compress&lt;/h4&gt;
&lt;p&gt;Let us compress &lt;code&gt;release_names.txt&lt;/code&gt; file using &lt;code&gt;gzip&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;gzip release_names.txt
ls&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## analysis.R
## bash.R
## bash.sh
## imports_blorr.txt
## imports_olsrr.txt
## lorem-ipsum.txt
## main_project.zip
## myfiles
## mypackage
## myproject
## myproject3
## myproject4
## package_names.txt
## pkg_names.tar
## pkg_names.txt
## r
## r2
## r_releases
## release_names.tar
## release_names.tar.gz
## release_names.txt.gz
## release_names_18.txt
## release_names_18_19.txt
## release_names_19.txt
## sept_15.csv.gz
## urls.txt
## zip_example.zip&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;decompress&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Decompress&lt;/h4&gt;
&lt;p&gt;Use the &lt;code&gt;-d&lt;/code&gt; option with &lt;code&gt;gzip&lt;/code&gt; to decompress a file. In the below example, we decompress the &lt;code&gt;sept_15.csv.gz&lt;/code&gt; file (downloaded using &lt;code&gt;wget&lt;/code&gt; or &lt;code&gt;curl&lt;/code&gt; earlier). You can also use &lt;code&gt;gunzip&lt;/code&gt; for the same result.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;gzip -d sept_15.csv.gz
ls&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## analysis.R
## bash.R
## bash.sh
## imports_blorr.txt
## imports_olsrr.txt
## lorem-ipsum.txt
## main_project.zip
## myfiles
## mypackage
## myproject
## myproject3
## myproject4
## package_names.txt
## pkg_names.tar
## pkg_names.txt
## r
## r2
## r_releases
## release_names.tar
## release_names.tar.gz
## release_names.txt
## release_names_18.txt
## release_names_18_19.txt
## release_names_19.txt
## sept_15.csv
## urls.txt
## zip_example.zip&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;specify-filename-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Specify Filename&lt;/h4&gt;
&lt;p&gt;Use &lt;code&gt;-c&lt;/code&gt; and &lt;code&gt;&amp;gt;&lt;/code&gt; to specify a different file name while compressing using &lt;code&gt;gzip&lt;/code&gt;. In the below example, &lt;code&gt;gzip&lt;/code&gt; will create &lt;code&gt;releases.txt.gz&lt;/code&gt; instead of &lt;code&gt;release_names.txt.gz&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;gzip -c release_names.txt &amp;gt; releases.txt.gz
ls&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## analysis.R
## bash.R
## bash.sh
## imports_blorr.txt
## imports_olsrr.txt
## lorem-ipsum.txt
## main_project.zip
## myfiles
## mypackage
## myproject
## myproject3
## myproject4
## package_names.txt
## pkg_names.tar
## pkg_names.txt
## r
## r2
## r_releases
## release_names.tar
## release_names.tar.gz
## release_names.txt
## release_names_18.txt
## release_names_18_19.txt
## release_names_19.txt
## releases.txt.gz
## sept_15.csv
## urls.txt
## zip_example.zip&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;zip-unzip&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;zip &amp;amp; unzip&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;zip&lt;/code&gt; creates ZIP archives while &lt;code&gt;unzip&lt;/code&gt; lists and extracts compressed files in a ZIP archive.&lt;/p&gt;
&lt;div id=&#34;list-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;List&lt;/h4&gt;
&lt;p&gt;Let us list all the files and folders in &lt;code&gt;main_project.zip()&lt;/code&gt; using &lt;code&gt;unzip&lt;/code&gt; and the &lt;code&gt;-l&lt;/code&gt; option.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;unzip -l main_project.zip&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Archive:  main_project.zip
##   Length      Date    Time    Name
## ---------  ---------- -----   ----
##         0  2019-09-23 18:07   myproject/
##         0  2019-09-20 14:02   myproject/.gitignore
##         0  2019-09-23 18:07   myproject/data/
##         0  2019-09-20 14:02   myproject/data/processed/
##         0  2019-09-20 14:02   myproject/data/raw/
##         0  2019-09-20 14:02   myproject/output/
##         0  2019-09-20 14:02   myproject/README.md
##        13  2019-09-20 14:02   myproject/run_analysis.R
##         0  2019-09-20 14:02   myproject/src/
##         0  2019-09-23 18:07   mypackage/
##         0  2019-09-20 14:11   mypackage/.gitignore
##         0  2019-09-20 14:11   mypackage/.Rbuildignore
##         0  2019-09-20 14:10   mypackage/data/
##         0  2019-09-20 14:11   mypackage/DESCRIPTION
##         0  2019-09-20 14:10   mypackage/docs/
##         0  2019-09-20 14:11   mypackage/LICENSE
##         0  2019-09-20 14:10   mypackage/man/
##         0  2019-09-20 14:11   mypackage/NAMESPACE
##         0  2019-09-20 14:11   mypackage/NEWS.md
##         0  2019-09-20 14:10   mypackage/R/
##         0  2019-09-20 14:11   mypackage/README.md
##         0  2019-09-20 14:11   mypackage/src/
##         0  2019-09-20 14:10   mypackage/tests/
##         0  2019-09-20 14:10   mypackage/vignettes/
##         0  2019-09-23 18:07   myfiles/
##        12  2019-09-20 15:30   myfiles/analysis.R
##         7  2019-09-20 15:31   myfiles/NEWS.md
##         9  2019-09-20 15:31   myfiles/README.md
##       546  2019-09-20 15:29   myfiles/release_names.txt
##        65  2019-09-20 15:29   myfiles/release_names_18.txt
##        53  2019-09-20 15:30   myfiles/release_names_19.txt
##        12  2019-09-20 15:30   myfiles/visualization.R
##     15333  2019-10-01 16:58   bash.sh
##         0  2019-09-16 12:42   r/
## ---------                     -------
##     16050                     34 files&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;extract-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Extract&lt;/h4&gt;
&lt;p&gt;Using &lt;code&gt;unzip&lt;/code&gt;, let us now extract files and folders from &lt;code&gt;zip_example.zip&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;unzip zip_example.zip&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Archive:  zip_example.zip
##    creating: zip_example/
##   inflating: zip_example/bash.sh     
##   inflating: zip_example/pkg_names.txt&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Using the &lt;code&gt;-d&lt;/code&gt; option, we can extract the contents of &lt;code&gt;zip_example.zip&lt;/code&gt; to a specific folder. In the below example, we extract it to a new folder &lt;code&gt;examples&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;unzip zip_example.zip –d myexamples&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Archive:  zip_example.zip&amp;quot;                        
## [2] &amp;quot;   creating: examples/zip_example/&amp;quot;               
## [3] &amp;quot;  inflating: examples/zip_example/bash.sh  &amp;quot;      
## [4] &amp;quot;  inflating: examples/zip_example/pkg_names.txt  &amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;compress-2&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Compress&lt;/h4&gt;
&lt;p&gt;Use the &lt;code&gt;-r&lt;/code&gt; option along with &lt;code&gt;zip&lt;/code&gt; to create a ZIP archive. In the below example, we create a ZIP archive of &lt;code&gt;myproject&lt;/code&gt; folder.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;zip -r myproject.zip myproject
ls&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   adding: myproject/ (stored 0%)
##   adding: myproject/.gitignore (stored 0%)
##   adding: myproject/data/ (stored 0%)
##   adding: myproject/data/processed/ (stored 0%)
##   adding: myproject/data/raw/ (stored 0%)
##   adding: myproject/output/ (stored 0%)
##   adding: myproject/README.md (stored 0%)
##   adding: myproject/run_analysis.R (stored 0%)
##   adding: myproject/src/ (stored 0%)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can compress multiple directories using &lt;code&gt;zip&lt;/code&gt;. The names of the directories must be separated by a space as shown in the below example where we compress &lt;code&gt;myproject&lt;/code&gt; and &lt;code&gt;mypackage&lt;/code&gt; into a single ZIP archive.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;zip -r packproj.zip myproject mypackage
ls&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   adding: myproject/ (stored 0%)
##   adding: myproject/.gitignore (stored 0%)
##   adding: myproject/data/ (stored 0%)
##   adding: myproject/data/processed/ (stored 0%)
##   adding: myproject/data/raw/ (stored 0%)
##   adding: myproject/output/ (stored 0%)
##   adding: myproject/README.md (stored 0%)
##   adding: myproject/run_analysis.R (stored 0%)
##   adding: myproject/src/ (stored 0%)
##   adding: mypackage/ (stored 0%)
##   adding: mypackage/.gitignore (stored 0%)
##   adding: mypackage/.Rbuildignore (stored 0%)
##   adding: mypackage/data/ (stored 0%)
##   adding: mypackage/DESCRIPTION (stored 0%)
##   adding: mypackage/docs/ (stored 0%)
##   adding: mypackage/LICENSE (stored 0%)
##   adding: mypackage/man/ (stored 0%)
##   adding: mypackage/NAMESPACE (stored 0%)
##   adding: mypackage/NEWS.md (stored 0%)
##   adding: mypackage/R/ (stored 0%)
##   adding: mypackage/README.md (stored 0%)
##   adding: mypackage/src/ (stored 0%)
##   adding: mypackage/tests/ (stored 0%)
##   adding: mypackage/vignettes/ (stored 0%)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;add-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Add&lt;/h4&gt;
&lt;p&gt;To add a new file/folder to an existing archive, specify the name of the archive followed by the name of the file or the folder. In the below example, we add the &lt;code&gt;bash.sh&lt;/code&gt; file to the &lt;code&gt;myproject.zip&lt;/code&gt; archive created in a previous step.&lt;/p&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;zip myproject.zip bash.sh&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   adding: bash.sh (deflated 78%)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;r-functions-3&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;R Functions&lt;/h3&gt;
&lt;div id=&#34;tar-tar.gz&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;tar &amp;amp; tar.gz&lt;/h4&gt;
&lt;p&gt;In R, we can use the &lt;code&gt;tar()&lt;/code&gt; and &lt;code&gt;untar()&lt;/code&gt; functions from the &lt;code&gt;utils&lt;/code&gt; package to handle &lt;code&gt;.tar&lt;/code&gt; and &lt;code&gt;.tar.gz&lt;/code&gt; archives.&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
R
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;tar tvf&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;utils::untar(&#39;archive.tar&#39;, list = TRUE)&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;tar tvfz&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;utils::untar(&#39;archive.tar.gz&#39;, list = TRUE)&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;tar xvf&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;utils::untar(&#39;archive.tar&#39;)&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;tar xvfz&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;utils::untar(&#39;archive.tar.gz&#39;)&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;tar cvf&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;utils::tar(&#39;archive.tar&#39;)&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;tar cvfz&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;utils::tar(&#39;archive.tar&#39;, compression = &#39;gzip&#39;)&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;div id=&#34;zip-gzip&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;zip &amp;amp; gzip&lt;/h4&gt;
&lt;p&gt;The &lt;a href=&#34;https://cran.r-project.org/package=zip&#34;&gt;zip&lt;/a&gt; package has the functionalities to handle ZIP archives. The &lt;code&gt;tar()&lt;/code&gt; and &lt;code&gt;untar()&lt;/code&gt; functions from the &lt;code&gt;utils&lt;/code&gt; package can handle GZIP archives.&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
R
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;gzip&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;utils::tar(compression = &#39;gzip&#39;&lt;/code&gt; / &lt;code&gt;R.utils::gzip()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;gzip -d&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;utils::untar()&lt;/code&gt; / &lt;code&gt;R.utils::gunzip()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;gzip -c&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;utils::untar(exdir = filename)&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;zip -r&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;zip::zip()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;zip&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;zip::zipr_append()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;unzip&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;zip::unzip()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;unzip -d&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;zip::unzip(exdir = dir_name)&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;unzip -l&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;zip::zip_list()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;sysinfo&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;System Info&lt;/h2&gt;
&lt;p&gt;In this section, we will explore commands that will allow us to&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;display information about the system&lt;/li&gt;
&lt;li&gt;display memory usage information&lt;/li&gt;
&lt;li&gt;display file system disk space usage&lt;/li&gt;
&lt;li&gt;exit the terminal&lt;/li&gt;
&lt;li&gt;run commands a superuser&lt;/li&gt;
&lt;li&gt;shutdown the system&lt;/li&gt;
&lt;/ul&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;uname&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Display important information about the system
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;free&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Display free, used, swap memory in the system
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;df&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Display file system disk space usage
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;exit&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Exit the terminal
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;sudo&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Run command as super user
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;shutdown&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Shutdown the system
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;div id=&#34;uname&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;uname&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;uname&lt;/code&gt; command is used to view important information about the system. Using additional options, we can&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;print details about operating system&lt;/li&gt;
&lt;li&gt;hardware &amp;amp; software related information&lt;/li&gt;
&lt;/ul&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;uname&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Print details about the current machine and the operating system running on it
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;uname -mp&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Hardware related information; machine &amp;amp; processor
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;uname -srv&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Software related information; operating system, release number and version
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;uname -n&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Nodename of the system
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;uname -a&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Print all available information system
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;div id=&#34;print-all-available-information-about-the-system&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Print all available information about the system&lt;/h4&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;uname -a&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Linux Aravind 4.4.0-18362-Microsoft #836-Microsoft Mon May 05 16:04:00 PST 2020 x86_64 x86_64 x86_64 GNU/Linux&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;display-free-used-swap-memory-in-the-system&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Display free, used, swap memory in the system&lt;/h4&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;free&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##               total        used        free      shared  buff/cache   available
## Mem:        3621900     1815864     1576684       17720      229352     1672304
## Swap:      11010048      260640    10749408&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;display-file-system-disk-space-usage&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Display file system disk space usage&lt;/h4&gt;
&lt;pre class=&#34;bash&#34;&gt;&lt;code&gt;df&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Filesystem     1K-blocks      Used Available Use% Mounted on
## rootfs         188482144 142470276  46011868  76% /
## none           188482144 142470276  46011868  76% /dev
## none           188482144 142470276  46011868  76% /run
## none           188482144 142470276  46011868  76% /run/lock
## none           188482144 142470276  46011868  76% /run/shm
## none           188482144 142470276  46011868  76% /run/user
## cgroup         188482144 142470276  46011868  76% /sys/fs/cgroup
## C:\            188482144 142470276  46011868  76% /mnt/c
## D:\             18660348  17154308   1506040  92% /mnt/d
## F:\              3196924    231756   2965168   8% /mnt/f
## G:\             86383612  24561220  61822392  29% /mnt/g
## H:\             86383612  14755988  71627624  18% /mnt/h
## J:\             83185660  18797916  64387744  23% /mnt/j&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;others&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Others&lt;/h3&gt;
&lt;p&gt;In this section, let us look at a few other useful commands that will allow us
to&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;see how long a command takes to execute&lt;/li&gt;
&lt;li&gt;delay activity&lt;/li&gt;
&lt;li&gt;display and clear command history list&lt;/li&gt;
&lt;/ul&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;time&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
See how long a command takes to execute
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;sleep&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Delay activity in seconds
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;sleep 1m&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Delay activity in minutes
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;sleep 1h&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Delay activity in hours
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;history&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Display command history list with line numbers
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;history -c&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Clear the command history list
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;div id=&#34;funny-commands&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Funny Commands&lt;/h3&gt;
&lt;p&gt;Below are a few funny commands for you to try out. Use &lt;code&gt;sudo apt-get install&lt;/code&gt; to install fortune and banner before trying them.&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;fortune&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Poignant, inspirational &amp;amp; silly phrases
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;yes&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Output a string repeatedly until killed
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;banner&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
ASCII banner
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;rev&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Reverse each character
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;div id=&#34;r-functions-4&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;R Functions&lt;/h3&gt;
&lt;p&gt;In R, we can use &lt;code&gt;Sys.sleep()&lt;/code&gt; to delay activity and &lt;code&gt;history()&lt;/code&gt; to view command history.&lt;/p&gt;
&lt;table class=&#34;table table-striped table-hover table-condensed table-responsive&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Command
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
R
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;sleep&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;Sys.sleep()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;history&lt;/code&gt;
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&lt;code&gt;history()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;hr&gt;
&lt;p&gt;&lt;a href=&#34;https://pkgs.rsquaredacademy.com/&#34; target=&#34;_blank&#34;&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/ad_packages.png&#34; width=&#34;100%&#34; alt=&#34;packages ad&#34; style=&#34;text-decoration: none;&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;system2&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Execute Commands from R&lt;/h2&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/r7N5HNtmKIc&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;p&gt;Now, let us turn our attention to executing commands from R using &lt;code&gt;system2()&lt;/code&gt;.
Here we will focus on the following&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;execute a command without arguments&lt;/li&gt;
&lt;li&gt;execute commands with arguments&lt;/li&gt;
&lt;li&gt;redirect output&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let us try to execute a command without any additional arguments. We will execute the &lt;code&gt;ls&lt;/code&gt; command to list all files and directories. Use &lt;code&gt;system2()&lt;/code&gt; and specify the command using the &lt;code&gt;command&lt;/code&gt; argument. Whenever you are trying to execute a command from R, the first argument or input should be the command and it must be enclosed in quotes.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;system2(command = &amp;quot;ls&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   [1] &amp;quot;2017-02-05-variables.Rmd&amp;quot;                                       
##   [2] &amp;quot;2017-02-05-variables.html&amp;quot;                                      
##   [3] &amp;quot;2017-02-17-data-types-in-r.Rmd&amp;quot;                                 
##   [4] &amp;quot;2017-02-17-data-types-in-r.html&amp;quot;                                
##   [5] &amp;quot;2017-03-01-getting-help-in-r.html&amp;quot;                              
##   [6] &amp;quot;2017-03-13-beginners-guide-to-r-package-ecosystem.Rmd&amp;quot;          
##   [7] &amp;quot;2017-03-13-beginners-guide-to-r-package-ecosystem.html&amp;quot;         
##   [8] &amp;quot;2017-03-25-vectors.Rmd&amp;quot;                                         
##   [9] &amp;quot;2017-03-25-vectors.html&amp;quot;                                        
##  [10] &amp;quot;2017-03-29-vectors-part-2.Rmd&amp;quot;                                  
##  [11] &amp;quot;2017-03-29-vectors-part-2.html&amp;quot;                                 
##  [12] &amp;quot;2017-04-03-vectors-part-3.Rmd&amp;quot;                                  
##  [13] &amp;quot;2017-04-03-vectors-part-3.html&amp;quot;                                 
##  [14] &amp;quot;2017-04-06-matrix.Rmd&amp;quot;                                          
##  [15] &amp;quot;2017-04-06-matrix.html&amp;quot;                                         
##  [16] &amp;quot;2017-04-12-matrix-part-2.Rmd&amp;quot;                                   
##  [17] &amp;quot;2017-04-12-matrix-part-2.html&amp;quot;                                  
##  [18] &amp;quot;2017-04-18-lists.Rmd&amp;quot;                                           
##  [19] &amp;quot;2017-04-18-lists.html&amp;quot;                                          
##  [20] &amp;quot;2017-04-30-factors.Rmd&amp;quot;                                         
##  [21] &amp;quot;2017-04-30-factors.html&amp;quot;                                        
##  [22] &amp;quot;2017-05-12-dataframes.Rmd&amp;quot;                                      
##  [23] &amp;quot;2017-05-12-dataframes.html&amp;quot;                                     
##  [24] &amp;quot;2017-05-24-data-visualization-with-r-introduction.Rmd&amp;quot;          
##  [25] &amp;quot;2017-05-24-data-visualization-with-r-introduction.html&amp;quot;         
##  [26] &amp;quot;2017-06-05-data-visualization-with-r-title-and-axis-labels.Rmd&amp;quot; 
##  [27] &amp;quot;2017-06-05-data-visualization-with-r-title-and-axis-labels.html&amp;quot;
##  [28] &amp;quot;2017-06-17-data-visualization-with-r-scatter-plots.Rmd&amp;quot;         
##  [29] &amp;quot;2017-06-17-data-visualization-with-r-scatter-plots.html&amp;quot;        
##  [30] &amp;quot;2017-06-29-data-visualization-with-r-line-graphs.Rmd&amp;quot;           
##  [31] &amp;quot;2017-06-29-data-visualization-with-r-line-graphs.html&amp;quot;          
##  [32] &amp;quot;2017-07-11-data-visualization-with-r-bar-plots.Rmd&amp;quot;             
##  [33] &amp;quot;2017-07-11-data-visualization-with-r-bar-plots.html&amp;quot;            
##  [34] &amp;quot;2017-07-23-data-visualization-with-r-box-plots.Rmd&amp;quot;             
##  [35] &amp;quot;2017-07-23-data-visualization-with-r-box-plots.html&amp;quot;            
##  [36] &amp;quot;2017-08-04-data-visualization-with-r-histogram.Rmd&amp;quot;             
##  [37] &amp;quot;2017-08-04-data-visualization-with-r-histogram.html&amp;quot;            
##  [38] &amp;quot;2017-08-16-data-visualization-with-r-legends.Rmd&amp;quot;               
##  [39] &amp;quot;2017-08-16-data-visualization-with-r-legends.html&amp;quot;              
##  [40] &amp;quot;2017-08-28-data-visualization-with-r-text-annotations.Rmd&amp;quot;      
##  [41] &amp;quot;2017-08-28-data-visualization-with-r-text-annotations.html&amp;quot;     
##  [42] &amp;quot;2017-09-09-data-visualization-with-r-combining-plots.Rmd&amp;quot;       
##  [43] &amp;quot;2017-09-09-data-visualization-with-r-combining-plots.html&amp;quot;      
##  [44] &amp;quot;2017-10-03-ggplot2-quick-tour.Rmd&amp;quot;                              
##  [45] &amp;quot;2017-10-03-ggplot2-quick-tour.html&amp;quot;                             
##  [46] &amp;quot;2017-10-15-ggplot2-introduction-to-geoms.Rmd&amp;quot;                   
##  [47] &amp;quot;2017-10-15-ggplot2-introduction-to-geoms.html&amp;quot;                  
##  [48] &amp;quot;2017-10-27-ggplot2-introduction-to-aesthetics.Rmd&amp;quot;              
##  [49] &amp;quot;2017-10-27-ggplot2-introduction-to-aesthetics.html&amp;quot;             
##  [50] &amp;quot;2017-11-08-ggplot2-axis-plot-labels.Rmd&amp;quot;                        
##  [51] &amp;quot;2017-11-08-ggplot2-axis-plot-labels.html&amp;quot;                       
##  [52] &amp;quot;2017-11-20-ggplot2-text-annotations.Rmd&amp;quot;                        
##  [53] &amp;quot;2017-11-20-ggplot2-text-annotations.html&amp;quot;                       
##  [54] &amp;quot;2017-12-02-ggplot2-scatter-plots.Rmd&amp;quot;                           
##  [55] &amp;quot;2017-12-02-ggplot2-scatter-plots.html&amp;quot;                          
##  [56] &amp;quot;2017-12-14-ggplot2-line-graphs.Rmd&amp;quot;                             
##  [57] &amp;quot;2017-12-14-ggplot2-line-graphs.html&amp;quot;                            
##  [58] &amp;quot;2017-12-26-ggplot2-bar-plots.Rmd&amp;quot;                               
##  [59] &amp;quot;2017-12-26-ggplot2-bar-plots.html&amp;quot;                              
##  [60] &amp;quot;2018-01-07-ggplot2-box-plots.Rmd&amp;quot;                               
##  [61] &amp;quot;2018-01-07-ggplot2-box-plots.html&amp;quot;                              
##  [62] &amp;quot;2018-01-19-ggplot2-histogram.Rmd&amp;quot;                               
##  [63] &amp;quot;2018-01-19-ggplot2-histogram.html&amp;quot;                              
##  [64] &amp;quot;2018-01-31-ggplot2-guides-axes.Rmd&amp;quot;                             
##  [65] &amp;quot;2018-01-31-ggplot2-guides-axes.html&amp;quot;                            
##  [66] &amp;quot;2018-02-12-ggplot2-guides-legends.Rmd&amp;quot;                          
##  [67] &amp;quot;2018-02-12-ggplot2-guides-legends.html&amp;quot;                         
##  [68] &amp;quot;2018-02-24-guides-legends-part-2.Rmd&amp;quot;                           
##  [69] &amp;quot;2018-02-24-guides-legends-part-2.html&amp;quot;                          
##  [70] &amp;quot;2018-03-08-legend-part-3.Rmd&amp;quot;                                   
##  [71] &amp;quot;2018-03-08-legend-part-3.html&amp;quot;                                  
##  [72] &amp;quot;2018-03-20-legend-part-4.Rmd&amp;quot;                                   
##  [73] &amp;quot;2018-03-20-legend-part-4.html&amp;quot;                                  
##  [74] &amp;quot;2018-04-01-legend-part-5.Rmd&amp;quot;                                   
##  [75] &amp;quot;2018-04-01-legend-part-5.html&amp;quot;                                  
##  [76] &amp;quot;2018-04-13-legend-part-6.Rmd&amp;quot;                                   
##  [77] &amp;quot;2018-04-13-legend-part-6.html&amp;quot;                                  
##  [78] &amp;quot;2018-04-25-ggplot2-facets-combine-multiple-plots.Rmd&amp;quot;           
##  [79] &amp;quot;2018-04-25-ggplot2-facets-combine-multiple-plots.html&amp;quot;          
##  [80] &amp;quot;2018-05-07-ggplot2-themes.Rmd&amp;quot;                                  
##  [81] &amp;quot;2018-05-07-ggplot2-themes.html&amp;quot;                                 
##  [82] &amp;quot;2018-07-30-importing-data-into-r-part-1.Rmd&amp;quot;                    
##  [83] &amp;quot;2018-07-30-importing-data-into-r-part-1.html&amp;quot;                   
##  [84] &amp;quot;2018-08-11-importing-data-into-r-part-2.Rmd&amp;quot;                    
##  [85] &amp;quot;2018-08-11-importing-data-into-r-part-2.html&amp;quot;                   
##  [86] &amp;quot;2018-08-23-data-wrangling-with-dplyr-part-1.Rmd&amp;quot;                
##  [87] &amp;quot;2018-08-23-data-wrangling-with-dplyr-part-1.html&amp;quot;               
##  [88] &amp;quot;2018-09-04-data-wrangling-with-dplyr-part-2.Rmd&amp;quot;                
##  [89] &amp;quot;2018-09-04-data-wrangling-with-dplyr-part-2.html&amp;quot;               
##  [90] &amp;quot;2018-09-16-data-wrangling-with-dplyr-part-3.Rmd&amp;quot;                
##  [91] &amp;quot;2018-09-16-data-wrangling-with-dplyr-part-3.html&amp;quot;               
##  [92] &amp;quot;2018-09-28-introduction-to-tibbles.Rmd&amp;quot;                         
##  [93] &amp;quot;2018-09-28-introduction-to-tibbles.html&amp;quot;                        
##  [94] &amp;quot;2018-10-10-readable-code-with-pipes.Rmd&amp;quot;                        
##  [95] &amp;quot;2018-10-10-readable-code-with-pipes.html&amp;quot;                       
##  [96] &amp;quot;2018-10-22-hacking-strings-with-stringr.Rmd&amp;quot;                    
##  [97] &amp;quot;2018-10-22-hacking-strings-with-stringr.html&amp;quot;                   
##  [98] &amp;quot;2018-11-03-working-with-dates-in-r.Rmd&amp;quot;                         
##  [99] &amp;quot;2018-11-03-working-with-dates-in-r.html&amp;quot;                        
## [100] &amp;quot;2018-11-15-working-with-categorical-data-using-forcats.Rmd&amp;quot;     
## [101] &amp;quot;2018-11-15-working-with-categorical-data-using-forcats.html&amp;quot;    
## [102] &amp;quot;2018-11-27-quick-guide-r-sqlite.Rmd&amp;quot;                            
## [103] &amp;quot;2018-11-27-quick-guide-r-sqlite.html&amp;quot;                           
## [104] &amp;quot;2018-12-09-data-wrangling-with-dbplyr.Rmd&amp;quot;                      
## [105] &amp;quot;2018-12-09-data-wrangling-with-dbplyr.html&amp;quot;                     
## [106] &amp;quot;2018-12-21-sql-for-data-science.Rmd&amp;quot;                            
## [107] &amp;quot;2018-12-21-sql-for-data-science.html&amp;quot;                           
## [108] &amp;quot;2019-01-02-sql-for-data-science-part-2.Rmd&amp;quot;                     
## [109] &amp;quot;2019-01-02-sql-for-data-science-part-2.html&amp;quot;                    
## [110] &amp;quot;2019-02-08-introducing-olsrr.Rmd&amp;quot;                               
## [111] &amp;quot;2019-02-08-introducing-olsrr.html&amp;quot;                              
## [112] &amp;quot;2019-02-12-introducing-rfm.Rmd&amp;quot;                                 
## [113] &amp;quot;2019-02-12-introducing-rfm.html&amp;quot;                                
## [114] &amp;quot;2019-02-19-introducing-descriptr.Rmd&amp;quot;                           
## [115] &amp;quot;2019-02-19-introducing-descriptr.html&amp;quot;                          
## [116] &amp;quot;2019-02-20-introducing-descriptr.Rmd&amp;quot;                           
## [117] &amp;quot;2019-02-20-introducing-descriptr.html&amp;quot;                          
## [118] &amp;quot;2019-02-26-introducing-blorr.Rmd&amp;quot;                               
## [119] &amp;quot;2019-02-26-introducing-blorr.html&amp;quot;                              
## [120] &amp;quot;2019-03-05-getting-help-in-r.Rmd&amp;quot;                               
## [121] &amp;quot;2019-03-05-getting-help-in-r.html&amp;quot;                              
## [122] &amp;quot;2019-03-12-introducing-rbin.Rmd&amp;quot;                                
## [123] &amp;quot;2019-03-12-introducing-rbin.html&amp;quot;                               
## [124] &amp;quot;2019-03-14-introducing-vistributions.Rmd&amp;quot;                       
## [125] &amp;quot;2019-03-14-introducing-vistributions.html&amp;quot;                      
## [126] &amp;quot;2019-04-01-shiny-apps.Rmd&amp;quot;                                      
## [127] &amp;quot;2019-04-01-shiny-apps.html&amp;quot;                                     
## [128] &amp;quot;2019-04-11-web-scraping.Rmd&amp;quot;                                    
## [129] &amp;quot;2019-04-11-web-scraping.html&amp;quot;                                   
## [130] &amp;quot;2019-04-13-web-scraping-note.Rmd&amp;quot;                               
## [131] &amp;quot;2019-04-13-web-scraping-note.html&amp;quot;                              
## [132] &amp;quot;2019-05-02-mba.Rmd&amp;quot;                                             
## [133] &amp;quot;2019-05-02-mba.html&amp;quot;                                            
## [134] &amp;quot;2019-05-02-mba_files&amp;quot;                                           
## [135] &amp;quot;2019-05-27-regex.Rmd&amp;quot;                                           
## [136] &amp;quot;2019-05-27-regex.html&amp;quot;                                          
## [137] &amp;quot;2019-07-05-pkginfo.Rmd&amp;quot;                                         
## [138] &amp;quot;2019-07-05-pkginfo.html&amp;quot;                                        
## [139] &amp;quot;2019-07-22-customer-segmentation-using-rfm-analysis.Rmd&amp;quot;        
## [140] &amp;quot;2019-07-22-customer-segmentation-using-rfm-analysis.html&amp;quot;       
## [141] &amp;quot;2019-07-22-customer-segmentation-using-rfm-analysis_files&amp;quot;      
## [142] &amp;quot;2019-08-08-working-with-databases-using-r.Rmd&amp;quot;                  
## [143] &amp;quot;2019-08-08-working-with-databases-using-r.html&amp;quot;                 
## [144] &amp;quot;2019-08-08-working-with-databases-using-r_files&amp;quot;                
## [145] &amp;quot;2019-10-26-command-line-crash-course.Rmd&amp;quot;                       
## [146] &amp;quot;2019-10-26-command-line-crash-course_files&amp;quot;                     
## [147] &amp;quot;2020-01-17-nse2r-intro.Rmd&amp;quot;                                     
## [148] &amp;quot;2020-04-17-handling-date-and-time-in-r.Rmd&amp;quot;                     
## [149] &amp;quot;2020-04-17-handling-date-and-time-in-r_files&amp;quot;                   
## [150] &amp;quot;airline.dta&amp;quot;                                                    
## [151] &amp;quot;airline.sas7bdat&amp;quot;                                               
## [152] &amp;quot;analysis.R&amp;quot;                                                     
## [153] &amp;quot;cline&amp;quot;                                                          
## [154] &amp;quot;config.yml&amp;quot;                                                     
## [155] &amp;quot;employee.sav&amp;quot;                                                   
## [156] &amp;quot;examples&amp;quot;                                                       
## [157] &amp;quot;hsb2.csv&amp;quot;                                                       
## [158] &amp;quot;hsb3.csv&amp;quot;                                                       
## [159] &amp;quot;hsb4.csv&amp;quot;                                                       
## [160] &amp;quot;imports_blorr.txt&amp;quot;                                              
## [161] &amp;quot;imports_olsrr.txt&amp;quot;                                              
## [162] &amp;quot;mydatabase.db&amp;quot;                                                  
## [163] &amp;quot;mypackage&amp;quot;                                                      
## [164] &amp;quot;myproject&amp;quot;                                                      
## [165] &amp;quot;online-retail.xlsx&amp;quot;                                             
## [166] &amp;quot;options.R&amp;quot;                                                      
## [167] &amp;quot;package_names.csv&amp;quot;                                              
## [168] &amp;quot;release.txt&amp;quot;                                                    
## [169] &amp;quot;sample.xls&amp;quot;                                                     
## [170] &amp;quot;transaction_data.csv&amp;quot;                                           
## [171] &amp;quot;zip_example.zip&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Great! Now, how do we specify the options? The additional options of a
command must be stored as a character vector and specified using the &lt;code&gt;args&lt;/code&gt;
argument. In the below example, we delete the &lt;code&gt;examples&lt;/code&gt; folder we created earlier while decompressing the &lt;code&gt;zip_example.zip&lt;/code&gt; file.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;system2(command = &amp;quot;rm&amp;quot;,
        args    = c(&amp;quot;-r&amp;quot;, &amp;quot;examples&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## character(0)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In some cases, we might want to redirect the output. Let us say we are writing
message to a file using the &lt;code&gt;echo&lt;/code&gt; command. In this cases, we want the output
to be redirected to the &lt;code&gt;release.txt&lt;/code&gt; file. The &lt;code&gt;stdout&lt;/code&gt; argument can be used to redirect output to a file or the R console. In the below example, we redirect the output to a file.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;system2(command = &amp;quot;echo&amp;quot;, 
        args    = c(&amp;quot;Great Truth&amp;quot;), 
        stdout  = &amp;quot;release.txt&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the next example, we redirect the output to the R console by setting the value of the &lt;code&gt;stdout&lt;/code&gt; argument to &lt;code&gt;TRUE&lt;/code&gt;. If you are curious, set the value to &lt;code&gt;FALSE&lt;/code&gt; and see what happens.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;system2(command = &amp;quot;diff&amp;quot;, 
        args    = c(&amp;quot;imports_olsrr.txt&amp;quot;, &amp;quot;imports_blorr.txt&amp;quot;),  
        stdout  = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning in system2(command = &amp;quot;diff&amp;quot;, args = c(&amp;quot;imports_olsrr.txt&amp;quot;,
## &amp;quot;imports_blorr.txt&amp;quot;), : running command &amp;#39;&amp;quot;diff&amp;quot; imports_olsrr.txt
## imports_blorr.txt&amp;#39; had status 1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;1,4c1,5&amp;quot;      &amp;quot;&amp;lt; car &amp;quot;       &amp;quot;&amp;lt; checkmate&amp;quot;  &amp;quot;&amp;lt; cli&amp;quot;        &amp;quot;&amp;lt; clisymbols&amp;quot;
##  [6] &amp;quot;---&amp;quot;          &amp;quot;&amp;gt; car&amp;quot;        &amp;quot;&amp;gt; caret&amp;quot;      &amp;quot;&amp;gt; checkmate&amp;quot;  &amp;quot;&amp;gt; clisymbols&amp;quot;
## [11] &amp;quot;&amp;gt; cli&amp;quot;       
## attr(,&amp;quot;status&amp;quot;)
## [1] 1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;run()&lt;/code&gt; command from the &lt;a href=&#34;https://processx.r-lib.org/&#34;&gt;processx&lt;/a&gt; package can be used to execute shell commands as well.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;shellrstudio&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Execute Shell Commands in RStudio&lt;/h2&gt;
&lt;p&gt;In RStudio, commands can be executed from shell scripts by pressing &lt;code&gt;Ctrl + Enter&lt;/code&gt;. Instead of sending the command to the R console, it is redirected to
the terminal where it is executed as shown below.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/cline_rstudio_shell.gif&#34; width=&#34;90%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;shellrmarkdown&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;RMarkdown&lt;/h2&gt;
&lt;p&gt;RMarkdown supports &lt;code&gt;bash&lt;/code&gt;, &lt;code&gt;sh&lt;/code&gt; and &lt;code&gt;awk&lt;/code&gt;. This post was initially created using &lt;code&gt;sh&lt;/code&gt; as the underlying operating system is Windows. Later, we used &lt;code&gt;bash&lt;/code&gt; after installing the Windows subsystem for Linux. Click &lt;a href=&#34;https://bookdown.org/yihui/rmarkdown/language-engines.html#shell-scripts&#34;&gt;here&lt;/a&gt; to learn more.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/cline_shell_markdown.png&#34; width=&#34;90%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;rinshell&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;R in the Shell&lt;/h2&gt;
&lt;p&gt;In this section, we will learn to execute R commands and scripts in the command line using:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;R -e&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Rscript -e&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;R CMD BATCH&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;code&gt;-e&lt;/code&gt; option allows us to specify R expression(s). &lt;code&gt;R -e&lt;/code&gt; will launch R and then execute the code specified within quotes. Use semi-colon to execute multiple expressions as shown below. You will be able to run the below commands only if you are able to launch R from the command line. Windows users need to ensure that R is added to the path environment.&lt;/p&gt;
&lt;pre class=&#34;sh&#34;&gt;&lt;code&gt;R -e &amp;quot;head(mtcars); tail(mtcars)&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## R version 4.0.0 (2020-04-24) -- &amp;quot;Arbor Day&amp;quot;
## Copyright (C) 2020 The R Foundation for Statistical Computing
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## 
## R is free software and comes with ABSOLUTELY NO WARRANTY.
## You are welcome to redistribute it under certain conditions.
## Type &amp;#39;license()&amp;#39; or &amp;#39;licence()&amp;#39; for distribution details.
## 
##   Natural language support but running in an English locale
## 
## R is a collaborative project with many contributors.
## Type &amp;#39;contributors()&amp;#39; for more information and
## &amp;#39;citation()&amp;#39; on how to cite R or R packages in publications.
## 
## Type &amp;#39;demo()&amp;#39; for some demos, &amp;#39;help()&amp;#39; for on-line help, or
## &amp;#39;help.start()&amp;#39; for an HTML browser interface to help.
## Type &amp;#39;q()&amp;#39; to quit R.
## 
## &amp;gt; head(mtcars); tail(mtcars)
##                    mpg cyl disp  hp drat    wt  qsec vs am gear carb
## Mazda RX4         21.0   6  160 110 3.90 2.620 16.46  0  1    4    4
## Mazda RX4 Wag     21.0   6  160 110 3.90 2.875 17.02  0  1    4    4
## Datsun 710        22.8   4  108  93 3.85 2.320 18.61  1  1    4    1
## Hornet 4 Drive    21.4   6  258 110 3.08 3.215 19.44  1  0    3    1
## Hornet Sportabout 18.7   8  360 175 3.15 3.440 17.02  0  0    3    2
## Valiant           18.1   6  225 105 2.76 3.460 20.22  1  0    3    1
##                 mpg cyl  disp  hp drat    wt qsec vs am gear carb
## Porsche 914-2  26.0   4 120.3  91 4.43 2.140 16.7  0  1    5    2
## Lotus Europa   30.4   4  95.1 113 3.77 1.513 16.9  1  1    5    2
## Ford Pantera L 15.8   8 351.0 264 4.22 3.170 14.5  0  1    5    4
## Ferrari Dino   19.7   6 145.0 175 3.62 2.770 15.5  0  1    5    6
## Maserati Bora  15.0   8 301.0 335 3.54 3.570 14.6  0  1    5    8
## Volvo 142E     21.4   4 121.0 109 4.11 2.780 18.6  1  1    4    2
## &amp;gt; 
## &amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;Rscript -e&lt;/code&gt; will run code without launching R.&lt;/p&gt;
&lt;pre class=&#34;sh&#34;&gt;&lt;code&gt;Rscript -e &amp;quot;head(mtcars)&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                    mpg cyl disp  hp drat    wt  qsec vs am gear carb
## Mazda RX4         21.0   6  160 110 3.90 2.620 16.46  0  1    4    4
## Mazda RX4 Wag     21.0   6  160 110 3.90 2.875 17.02  0  1    4    4
## Datsun 710        22.8   4  108  93 3.85 2.320 18.61  1  1    4    1
## Hornet 4 Drive    21.4   6  258 110 3.08 3.215 19.44  1  0    3    1
## Hornet Sportabout 18.7   8  360 175 3.15 3.440 17.02  0  0    3    2
## Valiant           18.1   6  225 105 2.76 3.460 20.22  1  0    3    1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can use &lt;code&gt;Rscript&lt;/code&gt; to execute a R script as well. In the below example, we execute the code in &lt;code&gt;analysis.R&lt;/code&gt; file.&lt;/p&gt;
&lt;pre class=&#34;sh&#34;&gt;&lt;code&gt;Rscript analysis.R&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                    mpg cyl disp  hp drat    wt  qsec vs am gear carb
## Mazda RX4         21.0   6  160 110 3.90 2.620 16.46  0  1    4    4
## Mazda RX4 Wag     21.0   6  160 110 3.90 2.875 17.02  0  1    4    4
## Datsun 710        22.8   4  108  93 3.85 2.320 18.61  1  1    4    1
## Hornet 4 Drive    21.4   6  258 110 3.08 3.215 19.44  1  0    3    1
## Hornet Sportabout 18.7   8  360 175 3.15 3.440 17.02  0  0    3    2
## Valiant           18.1   6  225 105 2.76 3.460 20.22  1  0    3    1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you are more interested, try the &lt;a href=&#34;https://cran.r-project.org/package=littler&#34;&gt;littler&lt;/a&gt; package as well.&lt;/p&gt;
&lt;div id=&#34;what-we-have-not-covered&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;What we have not covered…&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;shell scripting&lt;/li&gt;
&lt;li&gt;editing files&lt;/li&gt;
&lt;li&gt;file permissions&lt;/li&gt;
&lt;li&gt;user information&lt;/li&gt;
&lt;li&gt;pipes&lt;/li&gt;
&lt;li&gt;awk&lt;/li&gt;
&lt;li&gt;sed&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Summary&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Shell is a text based application for viewing, handling and manipulating files&lt;/li&gt;
&lt;li&gt;It is also known by the following names
&lt;ul&gt;
&lt;li&gt;CLI (Command Line Inteface)&lt;/li&gt;
&lt;li&gt;Terminal&lt;/li&gt;
&lt;li&gt;Bash (Bourne Again Shell)&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;system2()&lt;/code&gt; and &lt;code&gt;processx::run()&lt;/code&gt; in R to execute shell commands&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;Rscript -e&lt;/code&gt; or &lt;code&gt;R -e&lt;/code&gt; to execute R scripts from the command line&lt;/li&gt;
&lt;li&gt;RStudio includes a Terminal (from version 1.1.383)&lt;/li&gt;
&lt;li&gt;Execute commands from shell script in RStudio using Ctrl + Enter&lt;/li&gt;
&lt;li&gt;RMarkdown supports &lt;code&gt;bash&lt;/code&gt;, &lt;code&gt;sh&lt;/code&gt; and &lt;code&gt;awk&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;references&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;References &amp;amp; Further Readings&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://tldr.sh/&#34; class=&#34;uri&#34;&gt;https://tldr.sh/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://blog.rstudio.com/2017/08/11/rstudio-v1-1-preview-terminal/&#34; class=&#34;uri&#34;&gt;https://blog.rstudio.com/2017/08/11/rstudio-v1-1-preview-terminal/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://support.rstudio.com/hc/en-us/articles/115010737148-Using-the-RStudio-Terminal&#34; class=&#34;uri&#34;&gt;https://support.rstudio.com/hc/en-us/articles/115010737148-Using-the-RStudio-Terminal&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://bookdown.org/yihui/rmarkdown/language-engines.html#shell-scripts&#34; class=&#34;uri&#34;&gt;https://bookdown.org/yihui/rmarkdown/language-engines.html#shell-scripts&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/kirillseva/tldrrr&#34; class=&#34;uri&#34;&gt;https://github.com/kirillseva/tldrrr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://fs.r-lib.org/articles/function-comparisons.html&#34; class=&#34;uri&#34;&gt;https://fs.r-lib.org/articles/function-comparisons.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://livefreeordichotomize.com/2017/09/28/r-release-names/&#34; class=&#34;uri&#34;&gt;https://livefreeordichotomize.com/2017/09/28/r-release-names/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stackoverflow.com/questions/13478375/is-there-any-authoritative-documentation-on-r-release-nicknames&#34; class=&#34;uri&#34;&gt;https://stackoverflow.com/questions/13478375/is-there-any-authoritative-documentation-on-r-release-nicknames&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://www2.imm.dtu.dk/courses/02333/cygwin_tutorial/index.html&#34; class=&#34;uri&#34;&gt;http://www2.imm.dtu.dk/courses/02333/cygwin_tutorial/index.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://tutorial.djangogirls.org/en/intro_to_command_line/&#34; class=&#34;uri&#34;&gt;https://tutorial.djangogirls.org/en/intro_to_command_line/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://ss64.com/&#34; class=&#34;uri&#34;&gt;https://ss64.com/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.learnenough.com/command-line-tutorial&#34; class=&#34;uri&#34;&gt;https://www.learnenough.com/command-line-tutorial&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;feedback&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Feedback&lt;/h2&gt;
&lt;p&gt;If you see mistakes or want to suggest changes, please create an issue on the
&lt;a href=&#34;https://github.com/rsquaredacademy-infra/blog&#34; target=&#34;_blank&#34;&gt;source
repository&lt;/a&gt; or reach out to us at &lt;a href=&#34;mailto:support@rsquaredacademy.com&#34; class=&#34;email&#34;&gt;support@rsquaredacademy.com&lt;/a&gt;.&lt;/p&gt;
&lt;!-- clean up folder structure --&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>A Comprehensive Introduction to Working with Databases using R</title>
      <link>https://blog.rsquaredacademy.com/working-with-databases-using-r/</link>
      <pubDate>Thu, 08 Aug 2019 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/working-with-databases-using-r/</guid>
      <description>&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/dbi_cover_image.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In a previous &lt;a href=&#34;https://blog.rsquaredacademy.com/quick-guide-r-sqlite/&#34; target=&#34;_blank&#34;&gt;post&lt;/a&gt;, we had briefly looked at connecting to databases from R and using dplyr for querying data. In this new expanded post, we will focus on the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;connect to &amp;amp; explore database&lt;/li&gt;
&lt;li&gt;read &amp;amp; write data&lt;/li&gt;
&lt;li&gt;use RStudio SQL script &amp;amp; knitr SQL engine&lt;/li&gt;
&lt;li&gt;query data using dplyr&lt;/li&gt;
&lt;li&gt;visualize data with dbplot&lt;/li&gt;
&lt;li&gt;modeling data with modeldb &amp;amp; tidypredict&lt;/li&gt;
&lt;li&gt;explore RStudio connections pane&lt;/li&gt;
&lt;li&gt;handling credentials&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;resources&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Resources&lt;/h2&gt;
&lt;p&gt;Below are the links to all the resources related to this post:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://slides.rsquaredacademy.com/sql/sqlite.html#/section&#34; target=&#34;_blank&#34;&gt;Slides&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/rsquaredacademy-education/online-courses/&#34; target=&#34;_blank&#34;&gt;Code &amp;amp; Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://rstudio.cloud/project/430439&#34; target=&#34;_blank&#34;&gt;RStudio Cloud&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can try our &lt;strong&gt;free online course&lt;/strong&gt; &lt;a href=&#34;https://rsquared-academy.thinkific.com/courses/working-with-databases-using-r&#34;&gt;&lt;strong&gt;Working with Databases using R&lt;/strong&gt;&lt;/a&gt; if you prefer to learn through self paced online courses.&lt;/p&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/bPlGPmjPFeU&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;/div&gt;
&lt;div id=&#34;libraries&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Libraries&lt;/h2&gt;
&lt;p&gt;Before we connect to and explore the local SQLite database, let us take a look at the R packages we will use in this post.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://r-dbi.github.io/DBI/&#34;&gt;DBI&lt;/a&gt; a database interface for R&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://dbplyr.tidyverse.org/&#34;&gt;dbplyr&lt;/a&gt; a dplyr backend for databases&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://dplyr.tidyverse.org/&#34;&gt;dplyr&lt;/a&gt; for querying data&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://edgararuiz.github.io/dbplot/&#34;&gt;dbplot&lt;/a&gt; &amp;amp; &lt;a href=&#34;https://ggplot2.tidyverse.org/&#34;&gt;ggplot2&lt;/a&gt; for data visualization&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://tidymodels.github.io/modeldb/&#34;&gt;modeldb&lt;/a&gt; &amp;amp; &lt;a href=&#34;https://tidymodels.github.io/tidypredict/&#34;&gt;tidypredict&lt;/a&gt; for modeling &amp;amp; prediction inside database&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://cran.r-project.org/package=config&#34;&gt;config&lt;/a&gt; for handling credentials&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# install.packages(c(&amp;quot;DBI&amp;quot;, &amp;quot;dbplyr&amp;quot;, &amp;quot;dplyr&amp;quot;, &amp;quot;dbplot&amp;quot;, &amp;quot;ggplot2&amp;quot;, &amp;quot;modeldb&amp;quot;,
# &amp;quot;tidypredict&amp;quot;, &amp;quot;config&amp;quot;))
library(DBI)
library(dbplyr)
library(dplyr)
library(dbplot)
library(ggplot2)
library(modeldb)
library(tidypredict)
library(config)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you do not have all the above packages installed, go ahead and install them. In the R script we are sharing with you, we have commented out the code for installing the packages. If you are using the RStudio Cloud project, we have already installed the packages in the project and you can just load them into the R session using &lt;code&gt;library()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;As and when we come to the specific sections where we are using these packages, they will be reintroduced and we will look at their documentation and explore the functions we will use.&lt;/p&gt;
&lt;hr&gt;
&lt;p align=&#34;center&#34;&gt;
&lt;a href=&#34;https://rsquared-academy.thinkific.com/&#34; target=&#34;_blank&#34;&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/ad_courses.png&#34; width=&#34;100%&#34; alt=&#34;new courses ad&#34; style=&#34;text-decoration: none;&#34;&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;hr&gt;
&lt;/div&gt;
&lt;div id=&#34;connect-explore&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Connect &amp;amp; Explore&lt;/h2&gt;
&lt;p&gt;The first step is to successfully connect to a database. To begin with, we will keep things simple and connect to a local &lt;strong&gt;SQLite&lt;/strong&gt; database, &lt;code&gt;mydatabase.db&lt;/code&gt;. We will explore the database, list the tables present and the fields/columns in those tables. In the last section of this post, we will connect to a &lt;strong&gt;MySQL&lt;/strong&gt; database hosted on AWS using RStudio connections tab and learn how to specify the host, port, username, password etc.&lt;/p&gt;
&lt;div id=&#34;connect&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Connect&lt;/h4&gt;
&lt;p&gt;To connect to the database, we will use &lt;code&gt;dbConnect()&lt;/code&gt; from the &lt;a href=&#34;http://r-dbi.github.io/DBI/&#34;&gt;DBI&lt;/a&gt; package which defines a common interface between R and database management systems. The first input is the database driver which in our case is &lt;code&gt;SQLite&lt;/code&gt; and the second input is the name and location of the database. Since we are connecting to a local database, it is sufficient to specify the name and location of the database. The database connection is saved in &lt;code&gt;con&lt;/code&gt; for further use in exploring and querying data.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;con &amp;lt;- DBI::dbConnect(RSQLite::SQLite(), dbname = &amp;quot;mydatabase.db&amp;quot;)
con&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## &amp;lt;SQLiteConnection&amp;gt;
##   Path: J:\R\Others\blogs\content\post\mydatabase.db
##   Extensions: TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If the database is present and the correct path to the database has been specified, R will not return any error.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;connection-summary&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Connection Summary&lt;/h4&gt;
&lt;p&gt;Next, let us get a quick summary of the database connection using &lt;code&gt;summary()&lt;/code&gt;. It shows &lt;code&gt;SQLiteConnection&lt;/code&gt; under class and we can ignore the other details for the time being. Great! We have successfully connected to the database and now it is time to list the tables present in the database.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;summary(con)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##           Length            Class             Mode 
##                1 SQLiteConnection               S4&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;list-tables&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;List Tables&lt;/h4&gt;
&lt;p&gt;Now that we are connected to a database, let us list all the tables present in it using &lt;code&gt;dbListTables()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;DBI::dbListTables(con)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;COMPANY&amp;quot;    &amp;quot;DEPARTMENT&amp;quot; &amp;quot;ecom&amp;quot;       &amp;quot;trade&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There are 4 tables in the database and we will be using only the &lt;code&gt;ecom&lt;/code&gt; and &lt;code&gt;trade&lt;/code&gt; tables in our examples and practice questions.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;list-fields&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;List Fields&lt;/h4&gt;
&lt;p&gt;Let us go ahead and list all the fields/colums in the &lt;code&gt;ecom&lt;/code&gt; table since we will be using it in the following sections. To list all the fields (columns) in a table, use &lt;code&gt;dbListFields()&lt;/code&gt;. It takes 2 inputs:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the database connection name (&lt;code&gt;con&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;name of the table (&lt;code&gt;ecom&lt;/code&gt;) enclosed in single/double quotes&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;DBI::dbListFields(con, &amp;quot;ecom&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;id&amp;quot;          &amp;quot;referrer&amp;quot;    &amp;quot;device&amp;quot;      &amp;quot;bouncers&amp;quot;    &amp;quot;n_visit&amp;quot;    
##  [6] &amp;quot;n_pages&amp;quot;     &amp;quot;duration&amp;quot;    &amp;quot;country&amp;quot;     &amp;quot;purchase&amp;quot;    &amp;quot;order_items&amp;quot;
## [11] &amp;quot;order_value&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There are 11 columns in the &lt;code&gt;ecom&lt;/code&gt; table. Let us take a look at the data dictionary to understand what these columns stand for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;id: row id&lt;/li&gt;
&lt;li&gt;referrer: referrer website/search engine&lt;/li&gt;
&lt;li&gt;os: operating system&lt;/li&gt;
&lt;li&gt;browser: browser&lt;/li&gt;
&lt;li&gt;device: device used to visit the website&lt;/li&gt;
&lt;li&gt;n_pages: number of pages visited&lt;/li&gt;
&lt;li&gt;duration: time spent on the website (in seconds)&lt;/li&gt;
&lt;li&gt;repeat: frequency of visits&lt;/li&gt;
&lt;li&gt;country: country of origin&lt;/li&gt;
&lt;li&gt;purchase: whether visitor purchased&lt;/li&gt;
&lt;li&gt;order_value: order value of visitor (in dollars)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now that we know how to connect to a database and list the fields/columns, let us move on to the next section where we will learn how to query data from the tables present in the database.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;querying-data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Querying Data&lt;/h2&gt;
&lt;p&gt;Now that we have successfully connected to the database and explored the tables, let us look at querying data from the &lt;code&gt;ecom&lt;/code&gt; table. In this section,
we will learn to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;read entire table&lt;/li&gt;
&lt;li&gt;read few rows&lt;/li&gt;
&lt;li&gt;read data in batches&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;entire-table&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Entire Table&lt;/h4&gt;
&lt;p&gt;We can read an entire table from a database using &lt;code&gt;dbReadTable()&lt;/code&gt; provided the table is not very large. We will read data from the &lt;code&gt;COMPANY&lt;/code&gt; table as it has few rows and will not fill the whole page. The first input is the database connection name and the second input is the name of the table in quotes.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;DBI::dbReadTable(con, &amp;#39;COMPANY&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   ID  NAME AGE    ADDRESS SALARY
## 1  1  Paul  32 California  20000
## 2  2 Allen  25      Texas  15000
## 3  3 Teddy  23     Norway  20000
## 4  4  Mark  25 Rich-Mond   65000
## 5  5 David  27      Texas  85000
## 6  6   Kim  22 South-Hall  45000&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In some cases, we may not need the entire table but only a specific number of rows. Use &lt;code&gt;dbGetQuery()&lt;/code&gt; and supply a SQL statement specifying the number of rows of data to be read from the table. In the below example, we read ten rows of data from the &lt;code&gt;ecom&lt;/code&gt; table.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;few-rows&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Few Rows&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;DBI::dbGetQuery(con, &amp;quot;select * from ecom limit 10&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    id referrer device bouncers n_visit n_pages duration        country purchase
## 1   1   google laptop     true      10       1      693 Czech Republic    false
## 2   2    yahoo tablet     true       9       1      459          Yemen    false
## 3   3   direct laptop     true       0       1      996         Brazil    false
## 4   4     bing tablet    false       3      18      468          China     true
## 5   5    yahoo mobile     true       9       1      955         Poland    false
## 6   6    yahoo laptop    false       5       5      135   South Africa    false
## 7   7    yahoo mobile     true      10       1       75     Bangladesh    false
## 8   8   direct mobile     true      10       1      908      Indonesia    false
## 9   9     bing mobile    false       3      19      209    Netherlands    false
## 10 10   google mobile     true       6       1      208 Czech Republic    false
##    order_items order_value
## 1            0           0
## 2            0           0
## 3            0           0
## 4            6         434
## 5            0           0
## 6            0           0
## 7            0           0
## 8            0           0
## 9            0           0
## 10           0           0&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In case of very large table, we can read data in batches using &lt;code&gt;dbSendQuery()&lt;/code&gt; and &lt;code&gt;dbFetch()&lt;/code&gt;. We can mention the number of rows of data to be read while fetching the data using the query generated by &lt;code&gt;dbSendQuery()&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;read-data-in-batches&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Read Data in Batches&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;query  &amp;lt;- DBI::dbSendQuery(con, &amp;#39;select * from ecom&amp;#39;)

# first batch of 10 rows
DBI::dbFetch(query, n = 10)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    id referrer device bouncers n_visit n_pages duration        country purchase
## 1   1   google laptop     true      10       1      693 Czech Republic    false
## 2   2    yahoo tablet     true       9       1      459          Yemen    false
## 3   3   direct laptop     true       0       1      996         Brazil    false
## 4   4     bing tablet    false       3      18      468          China     true
## 5   5    yahoo mobile     true       9       1      955         Poland    false
## 6   6    yahoo laptop    false       5       5      135   South Africa    false
## 7   7    yahoo mobile     true      10       1       75     Bangladesh    false
## 8   8   direct mobile     true      10       1      908      Indonesia    false
## 9   9     bing mobile    false       3      19      209    Netherlands    false
## 10 10   google mobile     true       6       1      208 Czech Republic    false
##    order_items order_value
## 1            0           0
## 2            0           0
## 3            0           0
## 4            6         434
## 5            0           0
## 6            0           0
## 7            0           0
## 8            0           0
## 9            0           0
## 10           0           0&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# second batch of 10 rows
DBI::dbFetch(query, n = 10)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    id referrer device bouncers n_visit n_pages duration       country purchase
## 1  11   direct laptop     true       9       1      738       Jamaica    false
## 2  12   direct tablet    false       6      12      132       Estonia    false
## 3  13   direct mobile    false       9      14      406       Ireland     true
## 4  14    yahoo tablet    false       5       8       80   Philippines    false
## 5  15    yahoo mobile    false       7       1       19        France    false
## 6  16     bing laptop     true       1       1      995 United States    false
## 7  17     bing tablet    false       5      16      368          Peru     true
## 8  18   google tablet     true       7       1      406         China    false
## 9  19   social tablet    false       7      10      290      Colombia     true
## 10 20   social tablet    false       2       1       28       Namibia    false
##    order_items order_value
## 1            0           0
## 2            0           0
## 3            3         651
## 4            2         362
## 5            7        2423
## 6            0           0
## 7            6        1049
## 8            0           0
## 9            9        1304
## 10           7        2077&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;your-turn&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Your Turn&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;list fields in the &lt;code&gt;trade&lt;/code&gt; table&lt;/li&gt;
&lt;li&gt;read all rows &amp;amp; columns from the &lt;code&gt;trade&lt;/code&gt; table&lt;/li&gt;
&lt;li&gt;read first 30 rows from the &lt;code&gt;trade&lt;/code&gt; table&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;query&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Query&lt;/h2&gt;
&lt;p&gt;In this section, we will look at a bunch of functions that will allow us to get information about the query we sent to the database in the previous section to fetch data in batches. Before we start, let us look at the output from &lt;code&gt;query&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;query&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## &amp;lt;SQLiteResult&amp;gt;
##   SQL  select * from ecom
##   ROWS Fetched: 20 [incomplete]
##        Changed: 0&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can see the follwing:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;SQL statement&lt;/li&gt;
&lt;li&gt;number of rows fetched (15)&lt;/li&gt;
&lt;li&gt;status of the query (incomplete)&lt;/li&gt;
&lt;li&gt;and number of rows changed in the table (0)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The status is incomplete as we are querying data in batches and the number of rows changed is &lt;code&gt;0&lt;/code&gt; since ran a &lt;code&gt;SELECT&lt;/code&gt; SQL statement which does not modify the table.&lt;/p&gt;
&lt;div id=&#34;query-status&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Query Status&lt;/h4&gt;
&lt;p&gt;To know the status of a query, use &lt;code&gt;dbHasCompleted()&lt;/code&gt;. It is very useful in
cases of queries that might take a long time to complete. It will return a logical value i.e. &lt;code&gt;TRUE&lt;/code&gt; or &lt;code&gt;FALSE&lt;/code&gt;. In our example, since we are querying data in batches, the output will be &lt;code&gt;FALSE&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;DBI::dbHasCompleted(query)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;query-info&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Query Info&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;dbGetInfo()&lt;/code&gt; will display the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;SQL statement being executed&lt;/li&gt;
&lt;li&gt;the count of rows fetched/affected&lt;/li&gt;
&lt;li&gt;and the status of the query&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;DBI::dbGetInfo(query)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## $statement
## [1] &amp;quot;select * from ecom&amp;quot;
## 
## $row.count
## [1] 20
## 
## $rows.affected
## [1] 0
## 
## $has.completed
## [1] FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The output is similar to what we saw when we printed &lt;code&gt;query&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;latest-query&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Latest Query&lt;/h4&gt;
&lt;p&gt;To view the query used in &lt;code&gt;dbSendQuery()&lt;/code&gt; or &lt;code&gt;dbSendStatement()&lt;/code&gt;, use &lt;code&gt;dbGetStatement()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;DBI::dbGetStatement(query)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;select * from ecom&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;rows-fetched&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Rows Fetched&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;dbGetRowCount()&lt;/code&gt; will return the total number of rows actually fetched from the table in the database.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;DBI::dbGetRowCount(query)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 20&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;rows-affected&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Rows Affected&lt;/h4&gt;
&lt;p&gt;The total number of rows added, deleted or updated by a data manipulation statement is returned by &lt;code&gt;dbGetRowsAffected()&lt;/code&gt;. In our example, the SQL statemet did not modify the table in any way and hence the output will be &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;DBI::dbGetRowsAffected(query)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;column-info&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Column Info&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;dbColumnInfo()&lt;/code&gt; returns a &lt;code&gt;data.frame&lt;/code&gt; that describes the output of a query. In the below example, it returns the column name and data type of the output from the query.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;DBI::dbColumnInfo(query)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##           name      type
## 1           id   integer
## 2     referrer character
## 3       device character
## 4     bouncers character
## 5      n_visit   integer
## 6      n_pages    double
## 7     duration    double
## 8      country character
## 9     purchase character
## 10 order_items    double
## 11 order_value    double&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;clear-results&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Clear Results&lt;/h4&gt;
&lt;p&gt;To free all resources associated with a result set, use &lt;code&gt;dbClearResult()&lt;/code&gt;. After running the below code, we will not be able to retrieve any information about &lt;code&gt;query&lt;/code&gt; i.e. try running &lt;code&gt;dbGetInfo(query)&lt;/code&gt; or &lt;code&gt;dbGetStatement(query)&lt;/code&gt; and R will return an error.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;DBI::dbClearResult(query)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;tables&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Tables&lt;/h2&gt;
&lt;p&gt;In this section, we will learn to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;check if a table exists&lt;/li&gt;
&lt;li&gt;create table&lt;/li&gt;
&lt;li&gt;overwrite table&lt;/li&gt;
&lt;li&gt;append data to a table&lt;/li&gt;
&lt;li&gt;insert rows into a table&lt;/li&gt;
&lt;li&gt;append one table to another&lt;/li&gt;
&lt;li&gt;remove a table&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;check-table-name&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Check Table Name&lt;/h4&gt;
&lt;p&gt;It is a good practice to check whether a table of the same name exists before trying to create a new one in the database. In the below example, we use &lt;code&gt;dbExistsTable()&lt;/code&gt; to check if the database already has a table by the name &lt;code&gt;trial_db&lt;/code&gt;. &lt;code&gt;dbExistsTable()&lt;/code&gt; always returns a logical value.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;DBI::dbExistsTable(con, &amp;quot;trial_db&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Since there is no table by the name &lt;code&gt;trial_db&lt;/code&gt;, let us go ahead and create a new table of the same name.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;create-table&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Create Table&lt;/h4&gt;
&lt;p&gt;To create a new table, use &lt;code&gt;dbWriteTable()&lt;/code&gt;. It takes the following 3 arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;connection name&lt;/li&gt;
&lt;li&gt;name of the new table&lt;/li&gt;
&lt;li&gt;data for the new table&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let us first create a new dataset &lt;code&gt;trial_db&lt;/code&gt;. It has 2 columns, &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt;, and 10 rows of data. Next, we create a new table of the same name in the database. In &lt;code&gt;dbWriteTable()&lt;/code&gt;, we specify the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;con&lt;/code&gt;: database connection&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&#34;trial_db&#34;&lt;/code&gt;: name of the table in database&lt;/li&gt;
&lt;li&gt;&lt;code&gt;trial_data&lt;/code&gt;: name of the dataset used to create the table in the database&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Ensure that the name of the table in the database is always enclosed in single/double quotes.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# sample data
x          &amp;lt;- 1:10
y          &amp;lt;- letters[1:10]
trial_data &amp;lt;- tibble::tibble(x, y)

# write table to database
DBI::dbWriteTable(con, &amp;quot;trial_db&amp;quot;, trial_data)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us check if the table has been created.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;DBI::dbListTables(con)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;COMPANY&amp;quot;    &amp;quot;DEPARTMENT&amp;quot; &amp;quot;ecom&amp;quot;       &amp;quot;trade&amp;quot;      &amp;quot;trial_db&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;DBI::dbExistsTable(con, &amp;quot;trial_db&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;overwrite-table&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Overwrite Table&lt;/h4&gt;
&lt;p&gt;Sometimes instead of creating a new table, you may want to overwrite the data in an existing table. In such cases, use the &lt;code&gt;overwrite&lt;/code&gt; argument in &lt;code&gt;dbWriteTable()&lt;/code&gt; and set it to &lt;code&gt;TRUE&lt;/code&gt;. In the below example, we overwrite the &lt;code&gt;trial_db&lt;/code&gt; table in the database using the data set &lt;code&gt;trial2_data&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# sample data
x      &amp;lt;- sample(100, 10)
y      &amp;lt;- letters[11:20]
trial2_data &amp;lt;- tibble::tibble(x, y)

# overwrite table trial
DBI::dbWriteTable(con, &amp;quot;trial_db&amp;quot;, trial2_data, overwrite = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us query sone data from &lt;code&gt;trial_db&lt;/code&gt; table to ensure that it has been overwritten.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;DBI::dbGetQuery(con, &amp;quot;select * from trial_db&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##     x y
## 1  18 k
## 2  88 l
## 3  96 m
## 4  24 n
## 5  85 o
## 6  62 p
## 7  67 q
## 8  57 r
## 9  98 s
## 10 13 t&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;append-data&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Append Data&lt;/h4&gt;
&lt;p&gt;Alright! Now let us say instead of overwriting the data in the table, you want to append the data. In such cases, you can append data to an existing table by setting the &lt;code&gt;append&lt;/code&gt; argument in &lt;code&gt;dbWriteTable()&lt;/code&gt; to &lt;code&gt;TRUE&lt;/code&gt;. In the below example, we append the data set &lt;code&gt;trial3_data&lt;/code&gt; to the &lt;code&gt;trial_db&lt;/code&gt; table in the database.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# sample data
x      &amp;lt;- sample(100, 10)
y      &amp;lt;- letters[5:14]
trial3_data &amp;lt;- tibble::tibble(x, y)

# append data
DBI::dbWriteTable(con, &amp;quot;trial_db&amp;quot;, trial3_data, append = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us check if the data has been appended successfully by querying data from the &lt;code&gt;trial_db&lt;/code&gt; table.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;DBI::dbGetQuery(con, &amp;quot;select * from trial_db&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##     x y
## 1  18 k
## 2  88 l
## 3  96 m
## 4  24 n
## 5  85 o
## 6  62 p
## 7  67 q
## 8  57 r
## 9  98 s
## 10 13 t
## 11 14 e
## 12 57 f
## 13  5 g
## 14 53 h
## 15 72 i
## 16 85 j
## 17 47 k
## 18 45 l
## 19  6 m
## 20 18 n&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;insert-rows&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Insert Rows&lt;/h4&gt;
&lt;p&gt;We can insert new rows into existing tables using:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;dbExecute()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;dbSendStatement()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Both the function take 2 arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;connection name&lt;/li&gt;
&lt;li&gt;sql statement&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the below example, we insert a new row of data into the &lt;code&gt;trial-db&lt;/code&gt; table in the database using `dbExecute().&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;DBI::dbExecute(con,
  &amp;quot;INSERT into trial_db (x, y) VALUES (32, &amp;#39;c&amp;#39;), (45, &amp;#39;k&amp;#39;), (61, &amp;#39;h&amp;#39;)&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us check if the new row of data has been inserted into the &lt;code&gt;trial_db&lt;/code&gt; table by querying data from the same table.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;DBI::dbGetQuery(con, &amp;quot;select * from trial_db&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##     x y
## 1  18 k
## 2  88 l
## 3  96 m
## 4  24 n
## 5  85 o
## 6  62 p
## 7  67 q
## 8  57 r
## 9  98 s
## 10 13 t
## 11 14 e
## 12 57 f
## 13  5 g
## 14 53 h
## 15 72 i
## 16 85 j
## 17 47 k
## 18 45 l
## 19  6 m
## 20 18 n
## 21 32 c
## 22 45 k
## 23 61 h&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the next example, we insert another row of data into the &lt;code&gt;trial_db&lt;/code&gt; table in the database using &lt;code&gt;dbSendStatement()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;DBI::dbSendStatement(con,
  &amp;quot;INSERT into trial_db (x, y) VALUES (25, &amp;#39;m&amp;#39;), (54, &amp;#39;l&amp;#39;), (16, &amp;#39;y&amp;#39;)&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## &amp;lt;SQLiteResult&amp;gt;
##   SQL  INSERT into trial_db (x, y) VALUES (25, &amp;#39;m&amp;#39;), (54, &amp;#39;l&amp;#39;), (16, &amp;#39;y&amp;#39;)
##   ROWS Fetched: 0 [complete]
##        Changed: 3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us check if the new row of data has been inserted into the &lt;code&gt;trial_db&lt;/code&gt; table by querying data from the same table.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;DBI::dbGetQuery(con, &amp;quot;select * from trial_db&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: Closing open result set, pending rows&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##     x y
## 1  18 k
## 2  88 l
## 3  96 m
## 4  24 n
## 5  85 o
## 6  62 p
## 7  67 q
## 8  57 r
## 9  98 s
## 10 13 t
## 11 14 e
## 12 57 f
## 13  5 g
## 14 53 h
## 15 72 i
## 16 85 j
## 17 47 k
## 18 45 l
## 19  6 m
## 20 18 n
## 21 32 c
## 22 45 k
## 23 61 h
## 24 25 m
## 25 54 l
## 26 16 y&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;remove-table&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Remove Table&lt;/h4&gt;
&lt;p&gt;To delete/remove a table from the database, use &lt;code&gt;dbRemoveTable()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;DBI::dbRemoveTable(con, &amp;quot;trial_db&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;your-turn-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Your Turn&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;check if &lt;code&gt;mytable&lt;/code&gt; exists in the database&lt;/li&gt;
&lt;li&gt;create new table &lt;code&gt;mytable&lt;/code&gt; using the first 3 rows of &lt;code&gt;mtcars&lt;/code&gt; data set&lt;/li&gt;
&lt;li&gt;list all tables to check if the new table has been created&lt;/li&gt;
&lt;li&gt;overwrite &lt;code&gt;mytable&lt;/code&gt; with the first 10 rows of &lt;code&gt;mtcars&lt;/code&gt; data set&lt;/li&gt;
&lt;li&gt;append the 20th row of &lt;code&gt;mtcars&lt;/code&gt; data set to &lt;code&gt;mytable&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;create a new table using the last 5 rows of &lt;code&gt;mtcars&lt;/code&gt; and append it to &lt;code&gt;mytable&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;remove &lt;code&gt;mytable&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;data-type&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data Type&lt;/h2&gt;
&lt;p&gt;We know of the different data types in R such as integer, numeric/double, logical, factor etc. How do databases treat these data types? To know the data type of a particular value in a database, use &lt;code&gt;dbDataType()&lt;/code&gt;. The first input is the database driver and the next is the value whose data type we are seeking. In the below example, we look at the data type of 3 different values in SQLite.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;DBI::dbDataType(RSQLite::SQLite(), &amp;quot;a&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;TEXT&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;DBI::dbDataType(RSQLite::SQLite(), 1:5)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;INTEGER&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;DBI::dbDataType(RSQLite::SQLite(), 1.5)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;REAL&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;generate-sql-query&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Generate SQL Query&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;sqlCreateTable()&lt;/code&gt; will generate the SQL statement for simple &lt;code&gt;CREATE TABLE&lt;/code&gt; operations. In the below example, it generates the SQL statement for creating table &lt;code&gt;new&lt;/code&gt; with two fields &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;DBI::sqlCreateTable(con, &amp;quot;new&amp;quot;, c(x = &amp;quot;integer&amp;quot;, y = &amp;quot;text&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: Do not rely on the default value of the row.names argument for
## sqlCreateTable(), it will change in the future.&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## &amp;lt;SQL&amp;gt; CREATE TABLE `new` (
##   `x` integer,
##   `y` text
## )&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;sqlAppendTable()&lt;/code&gt; will generate the SQL statement for simple &lt;code&gt;INSERT&lt;/code&gt; operations. In the below example, it generates the SQL statement for inserting a new row of data into the &lt;code&gt;trial_db&lt;/code&gt; table.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;trial_new &amp;lt;- data.frame(x = 30, y = &amp;#39;k&amp;#39;)
DBI::sqlAppendTable(con, &amp;quot;trial_db&amp;quot;, trial_new)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: Do not rely on the default value of the row.names argument for
## sqlAppendTable(), it will change in the future.&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## &amp;lt;SQL&amp;gt; INSERT INTO `trial_db`
##   (`x`, `y`)
## VALUES
##   (30, &amp;#39;k&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;p&gt;
&lt;a href=&#34;https://www.youtube.com/user/rsquaredin/&#34; target=&#34;_blank&#34;&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/ad_youtube.png&#34; width=&#34;100%&#34; alt=&#34;youtube ad&#34; style=&#34;text-decoration: none;&#34;&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;hr&gt;
&lt;/div&gt;
&lt;div id=&#34;running-sql-scripts&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Running SQL Scripts&lt;/h2&gt;
&lt;p&gt;Once you are connected to a database, you may want to run some SQL queries. So far, we have run the SQL queries in R using function from the DBI package. Using RStudio SQL scripts, we can execute plain SQL queries as shown below. In the first line, we specify the database connection &lt;code&gt;-- !preview conn=con&lt;/code&gt; followed by SQL queries. The output can be viewed by clicking on the preview button. We have included a sample SQL script (dbi.sql) which you can open and execute in RStudio.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/dbi_running_sql_scripts.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;knitr-sql-engine&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;knitr SQL Engine&lt;/h2&gt;
&lt;p&gt;In addition to R, the knitr package can execute code chunks in a variety of languages including SQL. In the below image, we show how to execute SQL queries. First, we establish a DBIconnection to a database in a R code chunk which is then used in a SQL chunk via the &lt;code&gt;connection&lt;/code&gt; option (&lt;code&gt;connection = con&lt;/code&gt;). Check out the &lt;code&gt;dbi.Rmd&lt;/code&gt; file in the resources section.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/dbi_knitr_sql_engine.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;your-turn-2&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Your Turn&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;check the data type of &lt;code&gt;&#34;NULL&#34;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;use SQL script to select &lt;code&gt;duration&lt;/code&gt;, &lt;code&gt;n_visit&lt;/code&gt; from &lt;code&gt;trade&lt;/code&gt; table
where &lt;code&gt;device&lt;/code&gt; has the value &lt;code&gt;tablet&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;create a html report for the above sql query using the knitr SQL engine&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;data-transformation&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data Transformation&lt;/h2&gt;
&lt;p&gt;In this section, we will learn to query data from a database using dplyr. We will learn to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;reference data&lt;/li&gt;
&lt;li&gt;query data using dplyr&lt;/li&gt;
&lt;li&gt;display query&lt;/li&gt;
&lt;li&gt;collect data&lt;/li&gt;
&lt;li&gt;simulate&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;reference-data&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Reference Data&lt;/h4&gt;
&lt;p&gt;The first step is to reference the table in the database using &lt;code&gt;tbl()&lt;/code&gt;. Since we want to use the &lt;code&gt;ecom&lt;/code&gt; table from the database, we reference it as &lt;code&gt;ecom2&lt;/code&gt; using &lt;code&gt;tbl()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom2 &amp;lt;- dplyr::tbl(con, &amp;quot;ecom&amp;quot;)
ecom2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # Source:   table&amp;lt;ecom&amp;gt; [?? x 11]
## # Database: sqlite 3.30.1 [J:\R\Others\blogs\content\post\mydatabase.db]
##       id referrer device bouncers n_visit n_pages duration country purchase
##    &amp;lt;int&amp;gt; &amp;lt;chr&amp;gt;    &amp;lt;chr&amp;gt;  &amp;lt;chr&amp;gt;      &amp;lt;int&amp;gt;   &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;chr&amp;gt;   &amp;lt;chr&amp;gt;   
##  1     1 google   laptop true          10       1      693 Czech ~ false   
##  2     2 yahoo    tablet true           9       1      459 Yemen   false   
##  3     3 direct   laptop true           0       1      996 Brazil  false   
##  4     4 bing     tablet false          3      18      468 China   true    
##  5     5 yahoo    mobile true           9       1      955 Poland  false   
##  6     6 yahoo    laptop false          5       5      135 South ~ false   
##  7     7 yahoo    mobile true          10       1       75 Bangla~ false   
##  8     8 direct   mobile true          10       1      908 Indone~ false   
##  9     9 bing     mobile false          3      19      209 Nether~ false   
## 10    10 google   mobile true           6       1      208 Czech ~ false   
## # ... with more rows, and 2 more variables: order_items &amp;lt;dbl&amp;gt;,
## #   order_value &amp;lt;dbl&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you look at the output, &lt;code&gt;ecom2&lt;/code&gt; displays a tibble but in the second line it also shows the database information as well. Let us now move on and calculate the average time on site by device type.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;query-data&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Query Data&lt;/h4&gt;
&lt;p&gt;Let us compute the average time on site for different referrer groups when the visitor browses the site using a laptop. Now, instead of using SQL statement to extract the above information, we will use dplyr. This is especially useful if the user is not well versed in SQL. While dplyr can be used to query data, it is still advisable to learn the basics of SQL.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom2 %&amp;gt;% 
  dplyr::select(referrer, device, duration) %&amp;gt;% 
  dplyr::filter(device == &amp;quot;laptop&amp;quot;) %&amp;gt;% 
  dplyr::group_by(referrer) %&amp;gt;% 
  dplyr::summarise(avg_tos = mean(duration)) %&amp;gt;% 
  dplyr::arrange(avg_tos)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: Missing values are always removed in SQL.
## Use `mean(x, na.rm = TRUE)` to silence this warning
## This warning is displayed only once per session.&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # Source:     lazy query [?? x 2]
## # Database:   sqlite 3.30.1 [J:\R\Others\blogs\content\post\mydatabase.db]
## # Ordered by: avg_tos
##   referrer avg_tos
##   &amp;lt;chr&amp;gt;      &amp;lt;dbl&amp;gt;
## 1 direct      326.
## 2 yahoo       331.
## 3 social      362.
## 4 bing        434.
## 5 google      439.&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;display-query&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Display Query&lt;/h4&gt;
&lt;p&gt;If you want to view the SQL translation of the dplyr code used in the previous example, use &lt;code&gt;show_query()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tos_query &amp;lt;- 
  ecom2 %&amp;gt;% 
  dplyr::select(referrer, device, duration) %&amp;gt;% 
  dplyr::filter(device == &amp;quot;laptop&amp;quot;) %&amp;gt;% 
  dplyr::group_by(referrer) %&amp;gt;% 
  dplyr::summarise(avg_tos = mean(duration)) %&amp;gt;% 
  dplyr::arrange(avg_tos)

dplyr::show_query(tos_query)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## &amp;lt;SQL&amp;gt;
## SELECT `referrer`, AVG(`duration`) AS `avg_tos`
## FROM (SELECT `referrer`, `device`, `duration`
## FROM `ecom`)
## WHERE (`device` = &amp;#39;laptop&amp;#39;)
## GROUP BY `referrer`
## ORDER BY `avg_tos`&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;collect-data&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Collect Data&lt;/h4&gt;
&lt;p&gt;Now, some interesting facts. We will understand this using a different simple example. Let us read the &lt;code&gt;referrer&lt;/code&gt; and &lt;code&gt;device&lt;/code&gt; column from the &lt;code&gt;ecom&lt;/code&gt; table in the database and store it in &lt;code&gt;result&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;result &amp;lt;- 
  ecom2 %&amp;gt;%
  dplyr::select(referrer, device) 

result&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # Source:   lazy query [?? x 2]
## # Database: sqlite 3.30.1 [J:\R\Others\blogs\content\post\mydatabase.db]
##    referrer device
##    &amp;lt;chr&amp;gt;    &amp;lt;chr&amp;gt; 
##  1 google   laptop
##  2 yahoo    tablet
##  3 direct   laptop
##  4 bing     tablet
##  5 yahoo    mobile
##  6 yahoo    laptop
##  7 yahoo    mobile
##  8 direct   mobile
##  9 bing     mobile
## 10 google   mobile
## # ... with more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When we print &lt;code&gt;result&lt;/code&gt;, it displays the first 10 rows. In addition it shows the database information at the beginning as well as &lt;code&gt;... with more rows&lt;/code&gt; at the bottom of the table but it does not exactly say how many more rows are there.
Let us use &lt;code&gt;nrow()&lt;/code&gt; to find the total number of rows in &lt;code&gt;result&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;nrow(result)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] NA&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;No luck with &lt;code&gt;nrow()&lt;/code&gt; either as it returns &lt;code&gt;NA&lt;/code&gt; instead of the number of rows in &lt;code&gt;result&lt;/code&gt;. Now, why does this happen? When working with databases, &lt;strong&gt;dplyr&lt;/strong&gt; never pulls data into R unless you explicitly ask for it. In the previous example, it just displays the first 10 rows and has not read the entire table. The &lt;code&gt;ecom&lt;/code&gt; table in the database has 1000 rows of data and ideally dplyr should have read all the rows of data. But it does not work like that and the reason is this statement at the beginning of the output: &lt;code&gt;Source:   lazy query [?? x 2]&lt;/code&gt;. It does display the number of columns, &lt;code&gt;2&lt;/code&gt;. In place of the number of columns there is &lt;code&gt;??&lt;/code&gt;because it has not read the entire data from the &lt;code&gt;ecom&lt;/code&gt; table.&lt;/p&gt;
&lt;p&gt;What do we do if we need the entire data? In such cases, we can use &lt;code&gt;collect()&lt;/code&gt; as shown in the below example.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;result %&amp;gt;% 
  dplyr::collect() &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1,000 x 2
##    referrer device
##    &amp;lt;chr&amp;gt;    &amp;lt;chr&amp;gt; 
##  1 google   laptop
##  2 yahoo    tablet
##  3 direct   laptop
##  4 bing     tablet
##  5 yahoo    mobile
##  6 yahoo    laptop
##  7 yahoo    mobile
##  8 direct   mobile
##  9 bing     mobile
## 10 google   mobile
## # ... with 990 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the above output, dplyr has read the entire data from &lt;code&gt;ecom&lt;/code&gt;. It show the number of rows and columns at the top and the number of rows not displayed (990) at the bottom. More importantly, it does not show any information about the database as the entire data from &lt;code&gt;ecom&lt;/code&gt; has been read and is available in the R session.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;result %&amp;gt;% 
  dplyr::collect() %&amp;gt;% 
  nrow()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1000&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Even &lt;code&gt;nrow()&lt;/code&gt; returns 1000 as the entire data has been read from the database. Unless and until required or explicitly asked for, the data is not pulled from the database. When you are playing around with or iterating or experimenting with R code, do not use &lt;code&gt;collect()&lt;/code&gt;. Only when you have finalized the code for the information being extracted from the database, use &lt;code&gt;collect()&lt;/code&gt; to read the complete output into the R session.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;simulate&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Simulate&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;simulate_*()&lt;/code&gt; functions from &lt;a href=&#34;https://dbplyr.tidyverse.org/&#34;&gt;dbplyr&lt;/a&gt; are useful for testing SQL generation. In the below example, we want to generate the SQL for computing average time on site by referrer type for a MySQL database connection. The SQL generated is rendered to a SQL string by &lt;code&gt;sql_render()&lt;/code&gt;. You can test SQL generation for a wide variety of databases using dbplyr.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom2 %&amp;gt;% 
  dplyr::group_by(referrer) %&amp;gt;% 
  dplyr::summarise(avg_tos = mean(duration))  %&amp;gt;% 
  dbplyr::sql_render(dbplyr::simulate_mysql())&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## &amp;lt;SQL&amp;gt; SELECT `referrer`, AVG(`duration`) AS `avg_tos`
## FROM `ecom`
## GROUP BY `referrer`&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;your-turn-3&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Your Turn&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;use &lt;code&gt;tbl()&lt;/code&gt; to reference &lt;code&gt;trade&lt;/code&gt; table as &lt;code&gt;trade2&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;use dplyr verbs to compute average duration for &lt;code&gt;device&lt;/code&gt; from the &lt;code&gt;trade&lt;/code&gt; table&lt;/li&gt;
&lt;li&gt;store the above query in a variable &lt;code&gt;tos_device&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;use &lt;code&gt;show_query()&lt;/code&gt; to display the underlying SQL query of &lt;code&gt;tos_device&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;use &lt;code&gt;collect()&lt;/code&gt; to retrieve data from &lt;code&gt;tos_device&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;use &lt;code&gt;explain()&lt;/code&gt; to display the underlying computation logic of &lt;code&gt;tos_device&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;data-visualization&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data Visualization&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;https://edgararuiz.github.io/dbplot/index.html&#34;&gt;dbplot&lt;/a&gt; leverages dplyr to process the underlying data computations of a plot inside a database. It uses ggplot2 to generate the following plots:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;box plot&lt;/li&gt;
&lt;li&gt;bar plot&lt;/li&gt;
&lt;li&gt;histogram&lt;/li&gt;
&lt;li&gt;line chart&lt;/li&gt;
&lt;li&gt;raster plot&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Some of the plots work with only Hive or Sparklyr connections. You can refere to the documentation for more details. Since we are dealing with a SQLite database, we will be able to generate the following plots.&lt;/p&gt;
&lt;div id=&#34;bar-plot&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Bar Plot&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom2 %&amp;gt;% 
  dbplot::dbplot_bar(device) + 
  ggplot2::xlab(&amp;quot;Device&amp;quot;) + 
  ggplot2::ylab(&amp;quot;Count&amp;quot;) + 
  ggplot2::ggtitle(&amp;quot;Device Distribution&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-08-08-working-with-databases-using-r_files/figure-html/dbplot1-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;line-chart&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Line Chart&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom2 %&amp;gt;% 
  dbplot::dbplot_line(n_visit) + 
  ggplot2::xlab(&amp;quot;Visits&amp;quot;) + 
  ggplot2::ylab(&amp;quot;Count&amp;quot;) &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-08-08-working-with-databases-using-r_files/figure-html/dbplot2-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;your-turn-4&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Your Turn&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;create bar plot of &lt;code&gt;referrer&lt;/code&gt; column from the &lt;code&gt;trade&lt;/code&gt; table&lt;/li&gt;
&lt;li&gt;create line chart of &lt;code&gt;n_visit&lt;/code&gt; column from the &lt;code&gt;trade&lt;/code&gt; table&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;data-modeling&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data Modeling&lt;/h2&gt;
&lt;p&gt;In this section, we will explore fitting models and running predictions inside the database using the following packages:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://tidymodels.github.io/modeldb/index.html&#34;&gt;modeldb&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://tidymodels.github.io/tidypredict/index.html&#34;&gt;tidypredict&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let us start with fitting models inside database. The &lt;a href=&#34;https://tidymodels.github.io/modeldb/index.html&#34;&gt;modeldb&lt;/a&gt; package fits models inside database by using dplyr and dbplyr for SQL translation of the algorithms and currently supports linear regression and k-means clustering.&lt;/p&gt;
&lt;div id=&#34;simple-regression&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Simple Regression&lt;/h4&gt;
&lt;p&gt;Let us begin with a simple linear regression model. From the &lt;code&gt;ecom&lt;/code&gt; table in the database, we want to regress &lt;code&gt;duration&lt;/code&gt; on &lt;code&gt;n_visit&lt;/code&gt;. As shown below, we first select the required fields using &lt;code&gt;select()&lt;/code&gt; and pass the resulting data to &lt;code&gt;linear_regression_db()&lt;/code&gt; from modeldb. We need to specify the dependent variable which in our case is &lt;code&gt;duration&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom2 %&amp;gt;% 
  dplyr::select(duration, n_visit) %&amp;gt;% 
  modeldb::linear_regression_db(duration)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1 x 2
##   `(Intercept)` n_visit
##           &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;
## 1          364.   -1.72&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us move on to a multiple regression example. In the below example, we want to regress &lt;code&gt;duration&lt;/code&gt; on &lt;code&gt;n_visit&lt;/code&gt; (number of visit) and &lt;code&gt;n_pages&lt;/code&gt; (number of pages browsed).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;multiple-regression&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Multiple Regression&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom2 %&amp;gt;% 
  dplyr::select(duration, n_visit, n_pages) %&amp;gt;%
  modeldb::linear_regression_db(duration)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1 x 3
##   `(Intercept)` n_visit n_pages
##           &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;
## 1          415.   -2.02   -8.37&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;categorical-variables&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Categorical Variables&lt;/h4&gt;
&lt;p&gt;So how do we handle categorical variables? To handle categorical variables, use &lt;code&gt;add_dummy_variables()&lt;/code&gt;. We need to specify the categorical variable and its values. It will create the dummy variables.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom2 %&amp;gt;% 
  dplyr::select(duration, device) %&amp;gt;%
  modeldb::add_dummy_variables(device, values = c(&amp;quot;laptop&amp;quot;, &amp;quot;mobile&amp;quot;, &amp;quot;tablet&amp;quot;)) %&amp;gt;%
  modeldb::linear_regression_db(duration)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1 x 3
##   `(Intercept)` device_mobile device_tablet
##           &amp;lt;dbl&amp;gt;         &amp;lt;dbl&amp;gt;         &amp;lt;dbl&amp;gt;
## 1          376.         -39.2         -22.1&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;full-example&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Full Example&lt;/h4&gt;
&lt;p&gt;Below is a full example, where we have both continuous and categorical predictors. Whenever you have 3 or more predictors, use the &lt;code&gt;sample_size&lt;/code&gt; or &lt;code&gt;auto_count&lt;/code&gt; arguments. To know why, click &lt;a href=&#34;https://tidymodels.github.io/modeldb/reference/linear_regression_db.html&#34;&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# use sample size
ecom2 %&amp;gt;% 
  dplyr::select(duration, n_visit, n_pages, device) %&amp;gt;%
  modeldb::add_dummy_variables(device, values = c(&amp;quot;laptop&amp;quot;, &amp;quot;mobile&amp;quot;, &amp;quot;tablet&amp;quot;)) %&amp;gt;%
  modeldb::linear_regression_db(duration, sample_size = 1000)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1 x 5
##   `(Intercept)` n_visit n_pages device_mobile device_tablet
##           &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;         &amp;lt;dbl&amp;gt;         &amp;lt;dbl&amp;gt;
## 1          427.   -1.52   -8.27         -31.1         -14.4&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# use auto_count
ecom2 %&amp;gt;% 
  dplyr::select(duration, n_visit, n_pages, device) %&amp;gt;%
  modeldb::add_dummy_variables(device, values = c(&amp;quot;laptop&amp;quot;, &amp;quot;mobile&amp;quot;, &amp;quot;tablet&amp;quot;)) %&amp;gt;%
  modeldb::linear_regression_db(duration, auto_count = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1 x 5
##   `(Intercept)` n_visit n_pages device_mobile device_tablet
##           &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;         &amp;lt;dbl&amp;gt;         &amp;lt;dbl&amp;gt;
## 1          427.   -1.52   -8.27         -31.1         -14.4&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;your-turn-5&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Your Turn&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;regress &lt;code&gt;duration&lt;/code&gt; on &lt;code&gt;n_pages&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;regress &lt;code&gt;duration&lt;/code&gt; on &lt;code&gt;referrer&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;and finally regress &lt;code&gt;duration&lt;/code&gt; on &lt;code&gt;n_pages&lt;/code&gt;, &lt;code&gt;n_visit&lt;/code&gt; and &lt;code&gt;referrer&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;predict-inside-database&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Predict Inside Database&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;https://tidymodels.github.io/tidypredict/index.html&#34;&gt;tidypredict&lt;/a&gt; can return SQL statement that can be run inside the database. Let us first create a linear model in R using &lt;code&gt;lm()&lt;/code&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;model &amp;lt;- lm(duration ~ device + referrer + n_visit + n_pages, data = ecom2)
model&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Call:
## lm(formula = duration ~ device + referrer + n_visit + n_pages, 
##     data = ecom2)
## 
## Coefficients:
##    (Intercept)    devicemobile    devicetablet  referrerdirect  referrergoogle  
##        441.450         -30.952         -14.497          -8.980         -10.038  
## referrersocial   referreryahoo         n_visit         n_pages  
##        -19.841         -32.097          -1.433          -8.298&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;fit&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Fit&lt;/h4&gt;
&lt;p&gt;To add the fitted values in a new column, use &lt;code&gt;tidypredict_to_column()&lt;/code&gt;. In the below example, we use &lt;code&gt;model&lt;/code&gt; to compute the fitted values and add it as a new column.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom2 %&amp;gt;% 
  tidypredict::tidypredict_to_column(model) %&amp;gt;% 
  dplyr::select(duration, fit)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # Source:   lazy query [?? x 2]
## # Database: sqlite 3.30.1 [J:\R\Others\blogs\content\post\mydatabase.db]
##    duration   fit
##       &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;
##  1      693  409.
##  2      459  374.
##  3      996  424.
##  4      468  273.
##  5      955  357.
##  6      135  361.
##  7       75  356.
##  8      908  379.
##  9      209  249.
## 10      208  384.
## # ... with more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;tidypredict_fit()&lt;/code&gt; returns a Tidy Eval formula that can be used inside a dplyr command.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tidypredict::tidypredict_fit(model)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 441.450192491919 + (ifelse(device == &amp;quot;mobile&amp;quot;, 1, 0) * -30.9522074131866) + 
##     (ifelse(device == &amp;quot;tablet&amp;quot;, 1, 0) * -14.4972018107797) + 
##     (ifelse(referrer == &amp;quot;direct&amp;quot;, 1, 0) * -8.98035001912995) + 
##     (ifelse(referrer == &amp;quot;google&amp;quot;, 1, 0) * -10.038005625893) + 
##     (ifelse(referrer == &amp;quot;social&amp;quot;, 1, 0) * -19.8411767075006) + 
##     (ifelse(referrer == &amp;quot;yahoo&amp;quot;, 1, 0) * -32.0969778768984) + 
##     (n_visit * -1.4325653130794) + (n_pages * -8.29825840984566)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us use the above R code to calculate fitted values using &lt;code&gt;mutate()&lt;/code&gt; from dplyr.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom2 %&amp;gt;%
  dplyr::mutate(
    fit = 441.450192491919 + (ifelse(device == &amp;quot;mobile&amp;quot;, 1, 0) *
      -30.9522074131866) + (ifelse(device == &amp;quot;tablet&amp;quot;, 1,
      0) * -14.4972018107797) + (ifelse(referrer == &amp;quot;direct&amp;quot;,
      1, 0) * -8.98035001912995) + (ifelse(referrer == &amp;quot;google&amp;quot;,
      1, 0) * -10.038005625893) + (ifelse(referrer == &amp;quot;social&amp;quot;,
      1, 0) * -19.8411767075006) + (ifelse(referrer == &amp;quot;yahoo&amp;quot;,
      1, 0) * -32.0969778768984) + (n_visit * -1.4325653130794) +
      (n_pages * -8.29825840984566)
    ) %&amp;gt;%
  dplyr::select(duration, fit)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # Source:   lazy query [?? x 2]
## # Database: sqlite 3.30.1 [J:\R\Others\blogs\content\post\mydatabase.db]
##    duration   fit
##       &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;
##  1      693  409.
##  2      459  374.
##  3      996  424.
##  4      468  273.
##  5      955  357.
##  6      135  361.
##  7       75  356.
##  8      908  379.
##  9      209  249.
## 10      208  384.
## # ... with more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The SQL translation of the above step can be viewed using &lt;code&gt;tidypredict_sql()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tidypredict::tidypredict_sql(model, con)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## &amp;lt;SQL&amp;gt; 441.450192491919 + (CASE WHEN (`device` = &amp;#39;mobile&amp;#39;) THEN (1.0) WHEN NOT(`device` = &amp;#39;mobile&amp;#39;) THEN (0.0) END * -30.9522074131866) + (CASE WHEN (`device` = &amp;#39;tablet&amp;#39;) THEN (1.0) WHEN NOT(`device` = &amp;#39;tablet&amp;#39;) THEN (0.0) END * -14.4972018107797) + (CASE WHEN (`referrer` = &amp;#39;direct&amp;#39;) THEN (1.0) WHEN NOT(`referrer` = &amp;#39;direct&amp;#39;) THEN (0.0) END * -8.98035001912995) + (CASE WHEN (`referrer` = &amp;#39;google&amp;#39;) THEN (1.0) WHEN NOT(`referrer` = &amp;#39;google&amp;#39;) THEN (0.0) END * -10.038005625893) + (CASE WHEN (`referrer` = &amp;#39;social&amp;#39;) THEN (1.0) WHEN NOT(`referrer` = &amp;#39;social&amp;#39;) THEN (0.0) END * -19.8411767075006) + (CASE WHEN (`referrer` = &amp;#39;yahoo&amp;#39;) THEN (1.0) WHEN NOT(`referrer` = &amp;#39;yahoo&amp;#39;) THEN (0.0) END * -32.0969778768984) + (`n_visit` * -1.4325653130794) + (`n_pages` * -8.29825840984566)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;close-connection&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Close Connection&lt;/h2&gt;
&lt;p&gt;It is a good practice to close connection to a database when you no longer need to read/write data from/to it. Use &lt;code&gt;dbDisconnect()&lt;/code&gt; to close the database connection.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;DBI::dbDisconnect(con)&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;p&gt;&lt;a href=&#34;https://pkgs.rsquaredacademy.com/&#34; target=&#34;_blank&#34;&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/ad_packages.png&#34; width=&#34;100%&#34; alt=&#34;packages ad&#34; style=&#34;text-decoration: none;&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;/div&gt;
&lt;div id=&#34;rstudio-connections-pane&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;RStudio Connections Pane&lt;/h2&gt;
&lt;p&gt;In this section, we will learn to connect and explore databases using RStudio connections pane. We will connect to a MySQL database hosted on AWS. For security reasons, the database will be deleted after this post has been published and you will not be able to reproduce the results from this section onwards. Now, in the below images we show how to add and explore a new connection. &lt;strong&gt;The Connections Pane is available only in RStudio 1.1 and later.&lt;/strong&gt;&lt;/p&gt;
&lt;div id=&#34;step-1-click-on-new-connection&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step 1: Click on New Connection&lt;/h4&gt;
&lt;p&gt;In the Connections Pane, click on the &lt;code&gt;New Connection&lt;/code&gt; button.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/dbi_connection_edited_1.png&#34; width=&#34;60%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;step-2-connect-to-a-data-source&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step 2: Connect to a Data Source&lt;/h4&gt;
&lt;p&gt;Once you click on &lt;code&gt;New Connection&lt;/code&gt;, RStudio will display the exisiting data sources. If you do not see the driver for the database you want to connect to, install the driver and check again. Visit &lt;a href=&#34;https://db.rstudio.com/best-practices/drivers/&#34; class=&#34;uri&#34;&gt;https://db.rstudio.com/best-practices/drivers/&lt;/a&gt; for more information about setting up ODBC drivers.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/dbi_connection_edited_2.png&#34; width=&#34;60%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;step-3-supply-database-connection-parameters&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step 3: Supply Database Connection Parameters&lt;/h4&gt;
&lt;p&gt;If the database driver is already present, click on it to create a new
connection. Specify the database parameters in the text box as shown in the below image. Visit &lt;a href=&#34;https://www.connectionstrings.com/&#34; class=&#34;uri&#34;&gt;https://www.connectionstrings.com/&lt;/a&gt; to learn how to specify the connection strings for different databases.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/dbi_connection_edited_3.png&#34; width=&#34;60%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Once you specify the database parameters, the R code will be automatically updated by RStudio as shown below.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/dbi_connection_edited_4.png&#34; width=&#34;60%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;step-4-test-connection&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step 4: Test Connection&lt;/h4&gt;
&lt;p&gt;After specifying the database connection parameters, we can test if the connection works by clicking on &lt;code&gt;Test&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/dbi_connection_edited_5.png&#34; width=&#34;60%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;If RStudio is able to connect to the database, it will show a success message as shown below.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/dbi_connection_pane_5.png&#34; width=&#34;60%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;step-5-connect-options&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step 5: Connect Options&lt;/h4&gt;
&lt;p&gt;After testing the connection, you can choose to connect from&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the console&lt;/li&gt;
&lt;li&gt;R script&lt;/li&gt;
&lt;li&gt;or a notebook.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can copy the R code to the clipboard as well. Depending on where you intend to use the connection i.e. interactive session, R script or notebook, choose the appropriate option.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/dbi_connection_edited_6.png&#34; width=&#34;60%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;step-6-open-new-connection&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step 6: Open New Connection&lt;/h4&gt;
&lt;p&gt;Click on &lt;code&gt;OK&lt;/code&gt; button to open a new connection to the database.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/dbi_connection_edited_7.png&#34; width=&#34;60%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;step-7-explore-database&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Step 7: Explore Database&lt;/h5&gt;
&lt;p&gt;You can explore the database from the &lt;code&gt;Connections&lt;/code&gt; tab. View the tables in the database, explore the fields in a table, open a SQL script to run queries or close the connection if you don’t need it any longer.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/dbi_connection_edited_8.png&#34; width=&#34;50%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;handling-credentials&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Handling Credentials&lt;/h2&gt;
&lt;p&gt;Handling database credentials is one of the most important part of working with
databases in R. In this section, we will look at the different options for
securely storing and accessing credentials. After connecting to the database, we
will list the tables in the database (just to check that the connection is
working) and then disconnect.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;rstudioapi&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;rstudioapi&lt;/h2&gt;
&lt;p&gt;You can prompt the user to enter the database credentials using RStudio IDE. &lt;code&gt;askForPassword()&lt;/code&gt; will show a popup box that masks what is typed.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;db_con &amp;lt;- DBI::dbConnect(drv      = RMySQL::MySQL(), 
                         username = rstudioapi::askForPassword(&amp;quot;Database Username&amp;quot;),
                         password = rstudioapi::askForPassword(&amp;quot;Database Password&amp;quot;),
                         host     = &amp;quot;mysql-ecom.cowqoftkc0gy.us-east-2.rds.amazonaws.com&amp;quot;, 
                         port     = 3306, 
                         dbname   = &amp;quot;mysql_test&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/dbi_ask_credentials.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;renviron&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;.Renviron&lt;/h4&gt;
&lt;p&gt;The second method is store the credentials as environment variables. This can
be achieved using &lt;code&gt;Sys.setenv()&lt;/code&gt; or using .Renviron file. The credentials can then be retrieved using &lt;code&gt;Sys.getenv()&lt;/code&gt; as shown in the below example:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;db_con &amp;lt;- DBI::dbConnect(drv      = RMySQL::MySQL(), 
                         username = Sys.getenv(&amp;quot;db_uid&amp;quot;), 
                         password = Sys.getenv(&amp;quot;db_pwd&amp;quot;), 
                         host     = &amp;quot;mysql-ecom.cowqoftkc0gy.us-east-2.rds.amazonaws.com&amp;quot;, 
                         port     = 3306, 
                         dbname   = &amp;quot;mysql_test&amp;quot;)

# list tables in the database
DBI::dbListTables(db_con)
DBI::dbDisconnect(db_con)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In RStudio, create a new file and save it as .Renviron. In this file, define the
credentials as shown below:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;userid = &amp;quot;username&amp;quot;
pwd    = &amp;quot;password&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Save the file in the home directory of your project and restart R. Why should you restart R? .Renviron is processed only at the beginning of an R session. If you try to access the credentials using &lt;code&gt;Sys.getenv()&lt;/code&gt; without restarting R, the credentials will not be retrieved and you will see an error if you try to connect to the database. After restarting R, use &lt;code&gt;Sys.getenv()&lt;/code&gt; to retrieve the
credentials while opening a new connection to the database. We have added the &lt;code&gt;.Renviron&lt;/code&gt; file used to store credentials in the resources section of the learning management system as well as in the GitHub repo.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;options&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;options&lt;/h4&gt;
&lt;p&gt;The database credentials can be recorded as a global option in R. There are two ways to do this:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;use &lt;code&gt;options()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;use an R file&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Below is the code that records credentials using &lt;code&gt;options()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;options(db_userid   = &amp;quot;user_id&amp;quot;)
options(db_password = &amp;quot;pass_word&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The above code can be stored in a R file which can then be sourced before opening a new connection to the database. The credentials can be retrieved using &lt;code&gt;getOptions()&lt;/code&gt;. We have added the &lt;code&gt;options.R&lt;/code&gt; file used to store credentials to the database in the resources section of the learning management system as well as in the GitHub repo.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;source(&amp;quot;options.R&amp;quot;)
db_con &amp;lt;- DBI::dbConnect(drv      = RMySQL::MySQL(), 
                         username = getOption(&amp;quot;db_userid&amp;quot;), 
                         password = getOption(&amp;quot;db_password&amp;quot;), 
                         host     = &amp;quot;mysql-ecom.cowqoftkc0gy.us-east-2.rds.amazonaws.com&amp;quot;, 
                         port     = 3306, 
                         dbname   = &amp;quot;mysql_test&amp;quot;)

# list tables in the database
DBI::dbListTables(db_con)
DBI::dbDisconnect(db_con)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;config&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;config&lt;/h4&gt;
&lt;p&gt;The &lt;a href=&#34;https://github.com/rstudio/config&#34;&gt;config&lt;/a&gt; package allows you to manage environment specific configuration values. Configurations are defined using a YAML text file and are read by default from a file named config.yml in the current working directory. Store the database connection details such as driver, username, password, host, port, database name etc. in a YAML file and read it using &lt;code&gt;get()&lt;/code&gt;. We have added the &lt;code&gt;config.yml&lt;/code&gt; file used to store the credentials in the resources section of the learning management system as well as in the GitHub repo.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# read configurations
md &amp;lt;- config::get(&amp;quot;mysql-dev&amp;quot;)

# test
md$port
md$dbname

# connect
db_con &amp;lt;- DBI::dbConnect(drv      = RMySQL::MySQL(), 
                         username = md$username,
                         password = md$password,
                         host     = md$host, 
                         port     = md$port, 
                         dbname   = md$dbname)

# list tables in the database
DBI::dbListTables(db_con)
DBI::dbDisconnect(db_con)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;keyring&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;keyring&lt;/h4&gt;
&lt;p&gt;The &lt;a href=&#34;https://github.com/r-lib/keyring#readme&#34;&gt;keyring&lt;/a&gt; package provides platform independent API to access the operating systems credential store. We leave it to the reader to explore the keyring package for storing and accessing credentials safely.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;dbx&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;dbx&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;https://github.com/ankane/dbx&#34;&gt;dbx&lt;/a&gt; is another interesting package built on top
of DBI for both research and production environments and we hope to explore it
in a separate post in the coming days.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Summary&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://r-dbi.github.io/DBI/&#34;&gt;DBI&lt;/a&gt; to connect and interact with databases&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://dplyr.tidyverse.org/index.html&#34;&gt;dplyr&lt;/a&gt; and &lt;a href=&#34;https://dbplyr.tidyverse.org/index.html&#34;&gt;dbplyr&lt;/a&gt; for data transformation&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://edgararuiz.github.io/dbplot/index.html&#34;&gt;dbplot&lt;/a&gt; for data visualization&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://tidymodels.github.io/modeldb/&#34;&gt;modeldb&lt;/a&gt; and &lt;a href=&#34;https://tidymodels.github.io/tidypredict/&#34;&gt;tidypredict&lt;/a&gt; for data modeling&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/rstudio/config&#34;&gt;config&lt;/a&gt;, &lt;a href=&#34;https://github.com/r-lib/keyring&#34;&gt;keyring&lt;/a&gt;, .Renviron and &lt;code&gt;options()&lt;/code&gt; to handle credentials&lt;/li&gt;
&lt;li&gt;always close the database connection&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;feedback&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Feedback&lt;/h2&gt;
&lt;p&gt;If you see mistakes or want to suggest changes, please create an issue on the
&lt;a href=&#34;https://github.com/rsquaredacademy-infra/blog&#34; target=&#34;_blank&#34;&gt;source
repository&lt;/a&gt; or reach out to us at &lt;a href=&#34;mailto:support@rsquaredacademy.com&#34; class=&#34;email&#34;&gt;support@rsquaredacademy.com&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Customer Segmentation using RFM Analysis</title>
      <link>https://blog.rsquaredacademy.com/customer-segmentation-using-rfm-analysis/</link>
      <pubDate>Mon, 22 Jul 2019 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/customer-segmentation-using-rfm-analysis/</guid>
      <description>&lt;script src=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/kePrint/kePrint.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/bsTable/bootstrapTable.min.css&#34; rel=&#34;stylesheet&#34; /&gt;


&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/rfm_cover_image.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In a previous &lt;a href=&#34;https://blog.rsquaredacademy.com/introducing-rfm/&#34; target=&#34;_blank&#34;&gt;post&lt;/a&gt;,
we had introduced our R package &lt;a href=&#34;https://rfm.rsquaredacademy.com&#34; target=&#34;_blank&#34;&gt;rfm&lt;/a&gt;
but did not go into the conceptual details of RFM analysis. In this post, we
will explore RFM in much more depth and work through a case study as well.
&lt;strong&gt;RFM&lt;/strong&gt; (Recency, Frequency &amp;amp; Monetary) analysis is a behavior based technique
used to segment customers by examining their transaction history such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;how recently a customer has purchased?&lt;/li&gt;
&lt;li&gt;how often do they purchase?&lt;/li&gt;
&lt;li&gt;how much the customer spends?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It is based on the marketing axiom that &lt;strong&gt;80% of your business comes from 20%
of your customers&lt;/strong&gt;. RFM helps to identify customers who are more likely to
respond to promotions by segmenting them into various categories.&lt;/p&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/275X7yaSsoQ&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;/div&gt;
&lt;div id=&#34;resources&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Resources&lt;/h2&gt;
&lt;p&gt;Below are the links to all resources related to this post:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://slides.rsquaredacademy.com/rfm/rfm.html&#34; target=&#34;_blank&#34;&gt;Slides&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/rsquaredacademy-education/online-courses/&#34; target=&#34;_blank&#34;&gt;Code &amp;amp; Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://rstudio.cloud/project/416146&#34; target=&#34;_blank&#34;&gt;RStudio Cloud&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can try our free online course
&lt;a href=&#34;https://rsquared-academy.thinkific.com/courses/customer-segmentation-using-rfm-analysis&#34; target=&#34;_blank&#34;&gt;Customer Segmentation using RFM Analysis&lt;/a&gt;
if you like to learn through self paced online courses.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;case-study&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Case Study&lt;/h2&gt;
&lt;p&gt;We will work through a case study to better understand the underlying concepts
of RFM analysis. To pique your curiosity, we will start with the results or
the final outcome of the case study as shown below:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/rfm_segments.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The table has the following details:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;name or id of the customer&lt;/li&gt;
&lt;li&gt;number of days since the last transaction of the customer&lt;/li&gt;
&lt;li&gt;number of transactions of the customer&lt;/li&gt;
&lt;li&gt;total value of the all the transactions of the customer&lt;/li&gt;
&lt;li&gt;RFM score&lt;/li&gt;
&lt;li&gt;customer segment&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The rest of this post will focus on generating a similar result for our case
study and along the way we will learn to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;structure data for RFM analysis&lt;/li&gt;
&lt;li&gt;generate RFM score&lt;/li&gt;
&lt;li&gt;and segment customers using RFM score&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;applications&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Applications&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/rfm_applications.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Let us talk about applications. Though largely identified with retail or
ecommerce, RFM analysis can be applied in a lot of other domains or industry as
well. In social media and apps, RFM can be used to segment users as well. The
only difference is instead of using monetary value as the third metric, we will
use the amount of time spent (or some other metric based on it) on the site/app.
The more time we spend on the platform and consume the content, the more ads
can be displayed by the platform. So in those cases, the amount of time we
spend will be the third metric.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;rfm-workflow&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;RFM Workflow&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/rfm_work_flow.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The typical workflow for RFM analysis is shown above. It can be broadly divided
into the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;In the first step of the workflow, we &lt;strong&gt;collect transaction data&lt;/strong&gt;. This
should include a unique customer id, transaction date and transaction amount. In
case of ecommerce, we need to decide how to treat visits that did not result in
a transaction. If data is aggregated and made available at the customer level,
it must include a unique customer id, last transaction date and total revenue
from the customer. The last transaction date may be replaced by days since last
visit as well. The details available in data supplied depends on the data
pipeline and the &lt;code&gt;rfm&lt;/code&gt; package can handle any of the above 3 scenarios.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the second step, we &lt;strong&gt;generate RFM table&lt;/strong&gt; from the raw data available. The
RFM table aggregates data at the customer level. It includes the unique customer
id, days since last transaction/visit, frequency of transactions/visits and the
total revenue from all the transactions of the customer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the third step, we &lt;strong&gt;generate scores&lt;/strong&gt; for recency, frequency and monetary
value, and use them to create the RFM score for each customer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the final step, we use the recency, frequency and monetary scores to
&lt;strong&gt;define customer segments&lt;/strong&gt; and design customised campaigns, promotions,
offers &amp;amp; discounts to retain and reactivate customers.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;rfm-table&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;RFM Table&lt;/h2&gt;
&lt;p&gt;Let us assume we have completed the first step in RFM analysis by collecting
transaction data. Now, we have to generate the RFM table from the transaction
data. In the transaction data, each row represents a transaction and we may get
the transaction details in any of the following ways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;according to transaction date&lt;/li&gt;
&lt;li&gt;sorted by customer id&lt;/li&gt;
&lt;li&gt;or in a random order&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The first two cases are more likely but if we get the transaction data in a
random order, the first order of business is to sort them by customer id. In
the below example, we have transaction details for 3 customers Lionel, Jaineel
and Taj but they are not sorted by transaction date or customer id. Since we
want to create the RFM table from this data, we sort it by customer id.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/rfm_raw_sorted.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;From the sorted data, we aggregate the transaction details at the customer level
as shown below.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/rfm_raw_sorted_aggregate.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;From the above step, we have created the RFM table which contains recency (days
since last visit), frequency (frequency of visits) and monetary (total revenue
from the customer) data for each customer.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/rfm_table.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;metrics&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Metrics&lt;/h2&gt;
&lt;p&gt;Time to talk about the key metrics &lt;strong&gt;R&lt;/strong&gt;ecency, &lt;strong&gt;F&lt;/strong&gt;requency and &lt;strong&gt;M&lt;/strong&gt;onetary
in more detail. In this section, we will understand how they are calculated,
and in the next section, we will learn how they are used for generating the
RFM score.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/rfm_segment_4.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;recency&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Recency&lt;/h3&gt;
&lt;p&gt;Let us begin with recency. Earlier, we defined it as the number of days since
the last transaction of the customer. How do we calculate this metric? Apart
from the date of the last transaction of the customer, what other information
do we need? In all the discussions till now, we have missed out on a key point
i.e. the time frame of the analysis.&lt;/p&gt;
&lt;p&gt;The most crucial step in RFM analysis is to select a time frame from which
we use the transaction data. How do we decide on this time frame? It depends
on the domain to which we are applying this analysis. Customers visit a grocery
store more often than they visit a consumer durables store. Similarly, people
consume content from news &amp;amp; blogs more frequently while they may visit an
e-commerce website only when they have to purchase something. Keeping in mind
the domain to which the analysis is being applied, select an appropriate time
frame. To calculate recency, compute the difference between the last transaction
date and the analysis date i.e. the last date of the selected time frame.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/rfm_recency_computation.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In the above example, the analysis date is &lt;code&gt;2016-12-31&lt;/code&gt;. To compute recency,
we first extract all the transaction date of customer Taj and then select the
last transaction date, &lt;code&gt;2015-04-21&lt;/code&gt;, and subtract if from the analysis
date to get the number of days since the last transaction date, &lt;code&gt;620&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;frequency&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Frequency&lt;/h3&gt;
&lt;p&gt;Frequency is the count of transactions. In the online/digital world, we need to
decide whether we will consider all the visits to a website or app as the
frequency or only those which resulted in a transaction/conversion. In the
below example, we count the transactions for each customer and use it as
frequency. Lionel has 6 transactions, Jaineel has 9 transactions and Taj has
4 transactions.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/rfm_frequency_computation.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;monetary-value&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Monetary Value&lt;/h3&gt;
&lt;p&gt;Monetary value is the total revenue from each customer in the selected time
frame. It is computed by summing up the transaction amount. In our case study,
Jaineel has spent the highest amount of &lt;code&gt;$843&lt;/code&gt;, followed by Lionel who has
spent &lt;code&gt;$472&lt;/code&gt; and Taj has spent the lowest, &lt;code&gt;$196&lt;/code&gt;. As you can observe, we have
arrived at these figures by summing the values in the third column of the
second table, &lt;code&gt;Order Amount&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If we are applying this analysis to the digital world, we may think of using
a metric such as time spent on the website/app instead of transaction/order
amount.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/rfm_monetary_computation.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;rfm-score&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;RFM Score&lt;/h2&gt;
&lt;p&gt;As shown in the workflow, the third step in RFM analysis is to generate the
individual score for each metric and then use them to generate the RFM score. In
this section, we will explain in detail how the scores are computed for recency,
frequency and monetary. This section is slightly complex (we received a lot of
mails from readers after we published the previous post) and we have tried our
best to break down the complexity as much as possible. Still, if you have any
questions feel free to write to us at &lt;a href=&#34;mailto:support@rsquaredacademy.com&#34; class=&#34;email&#34;&gt;support@rsquaredacademy.com&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We follow the below steps to create the score:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;use quantiles to generate cut off points&lt;/li&gt;
&lt;li&gt;create intervals based on the cut off points&lt;/li&gt;
&lt;li&gt;use the intervals to assign score&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;monetary-score&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Monetary Score&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/rfm_monetary_score_interval.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Let us generate the monetary score in our case study. The first step is to
compute the quantiles using the &lt;code&gt;quantile()&lt;/code&gt; function. We use the revenue
column from the RFM table to compute the quantiles. If you look at the example,
it gives us the cut off below which a certain percentage of customers are
present.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the bottom 20% of customers spend below &lt;code&gt;$254.8&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;the next 20% of customers spend between &lt;code&gt;$254.8&lt;/code&gt; and &lt;code&gt;$381.0&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;the top 20% of customers spend above &lt;code&gt;$665.0&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Using these cut off points we have created intervals which can then be converted
to &lt;code&gt;if else&lt;/code&gt; statements. The intervals are then used to assign scores. For
example, Lionel falls in the interval &lt;code&gt;&amp;gt; 381.0 &amp;amp; &amp;lt;= 505.4&lt;/code&gt; and hence is assigned
the score &lt;code&gt;3&lt;/code&gt;. Similarly, Jaineel and Taj are assigned the scores &lt;code&gt;5&lt;/code&gt; and &lt;code&gt;1&lt;/code&gt;.
How do we interpret the scores? The score is more like a rank. A customer with
a score of 3 is ranked higher than a customer with score of 1 as his transaction
amount is higher. In the &lt;code&gt;rfm&lt;/code&gt; package, we use the above method to assign the
scores.&lt;/p&gt;
&lt;p&gt;Some users reverse the order of the score i.e. top 20% customers by transaction
amountare assigned the score 1 and the bottom 20% are assigned the score 5.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;frequency-score&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Frequency Score&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/rfm_frequency_score_interval.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The frequency score is computed in the same way as the monetary score. Instead
of using the revenue column from the RFM table, we use the frequency column.
Using quantiles, we arrive at the cut off points below which a certain
percentage of customer are present. If you observe the example, the first table
shows the quantiles and the associated cut off points.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the bottom 20% of customers visit/transact less than 3 times.&lt;/li&gt;
&lt;li&gt;the next 20% of customers visit/transact around 4 times.&lt;/li&gt;
&lt;li&gt;the top 20% of customers visit/transact more than 7 times.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The cut off points are then used to create the intervals and assign the scores
as shown in the second table. We assign a higher score to those who visit more
frequently and a lower score to those who visit less frequently.&lt;/p&gt;
&lt;p&gt;In our case study, Jaineel has visited 9 times and hence assigned the score 5
where as Taj has visited only 4 times and hence the score 2.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;recency-score&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Recency Score&lt;/h3&gt;
&lt;p&gt;The recency score follows the same methodology but uses a slightly different
concept while assigning the score. If you look at the metrics, the higher the
values of frequency and monetary, the better as we want customers to transact
frequently and spend higher amount but it is not the case with recency. Since
recency represents the number of days since the last transaction, the lower its
value the better i.e. customers who visited in the recent past are more likely
to visit again whereas customers who visited long back may be as good as lost.
Hence in the case of recency, higher score is assigned to those with lower
recency value and vice versa.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/rfm_recency_score_interval.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In the above example, we have used quantiles to compute the cut off point for
recency. The first table shows the quantiles and the associated cut off points:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the bottom 20% of customers visited more than &lt;code&gt;481&lt;/code&gt; days back.&lt;/li&gt;
&lt;li&gt;the next 20% of customers visited between &lt;code&gt;296.4&lt;/code&gt; and &lt;code&gt;481&lt;/code&gt; days back.&lt;/li&gt;
&lt;li&gt;the top 20% of customers visited less than 114 days back.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The above statements will become clear if you study the second table which
includes the interval and the score. We have assigned a higher score to those
who visited in the recent past (&amp;lt; 114 days) compared to those who visited way
back (&amp;gt; 481 days). In our case study, Jaineel visited in the past 3 months and
hence the score of 5 where as Taj visited almost 20 months back and has been
assigned the score 1.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;rfm-score-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;RFM Score&lt;/h3&gt;
&lt;p&gt;Now that we have calculated the individual scores, let us compute the RFM score
using the below formula:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;RFM Score = Recency Score * 100 + Frequency Score * 10 + Monetary Score&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The below table shows the individal scores of recency, frequency and monetary as
well as the RFM score. All of them are computed from the RFM table which in
itself is based on the transaction data.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/rfm_score_table.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;segments&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Segments&lt;/h2&gt;
&lt;p&gt;Great! We have finally computed the RFM score. Now what? How do we define the
segments using this score? In this section, we will learn how to define customer
segments using the RFM score. The below table is an example of how segments are
defined. It has the following details:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the name of the segment&lt;/li&gt;
&lt;li&gt;the definition of the segment&lt;/li&gt;
&lt;li&gt;the intervals for the recency, frequency &amp;amp; monetary scores&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We should be careful while creating the intervals for the scores in the
segments table. Look at &lt;a href=&#34;https://en.wikipedia.org/wiki/Interval_(mathematics)#Classification_of_intervals&#34; target=&#34;_blank&#34;&gt;this&lt;/a&gt; Wkipedia article to understand how intervals work.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/rfm_segments_table.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Let us apply the above rules to our case study.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/rfm_segments.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Defining segments is another crucial step in RFM analysis. We need to ensure
that there is no duplication or large number of customers get classified into
&lt;code&gt;Others&lt;/code&gt; segment. In the case study, we will show you some of the mistakes
that can happen while defining the segments.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;case-study-1&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Case Study&lt;/h2&gt;
&lt;p&gt;It is time to work through the case study. Let us first load all the libraries we
will use as shown below:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(rfm)
library(dplyr)
library(magrittr)
library(lubridate)&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data&lt;/h3&gt;
&lt;p&gt;To calculate the RFM score for each customer we need transaction data which should include the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a unique customer id&lt;/li&gt;
&lt;li&gt;date of transaction/order&lt;/li&gt;
&lt;li&gt;transaction/order amount&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;rfm&lt;/code&gt; includes a sample data set &lt;code&gt;rfm_data_orders&lt;/code&gt; which includes the above
details:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rfm_data_orders&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 4,906 x 3
##    customer_id         order_date revenue
##    &amp;lt;chr&amp;gt;               &amp;lt;date&amp;gt;       &amp;lt;dbl&amp;gt;
##  1 Mr. Brion Stark Sr. 2004-12-20      32
##  2 Ethyl Botsford      2005-05-02      36
##  3 Hosteen Jacobi      2004-03-06     116
##  4 Mr. Edw Frami       2006-03-15      99
##  5 Josef Lemke         2006-08-14      76
##  6 Julisa Halvorson    2005-05-28      56
##  7 Judyth Lueilwitz    2005-03-09     108
##  8 Mr. Mekhi Goyette   2005-09-23     183
##  9 Hansford Moen PhD   2005-09-07      30
## 10 Fount Flatley       2006-04-12      13
## # ... with 4,896 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;rfm-score-2&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;RFM Score&lt;/h3&gt;
&lt;p&gt;Use &lt;code&gt;rfm_table_order()&lt;/code&gt; to generate the score for each customer from the sample
data set &lt;code&gt;rfm_data_orders&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;rfm_table_order()&lt;/code&gt; takes 8 inputs:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;data&lt;/code&gt;: a data set with
&lt;ul&gt;
&lt;li&gt;unique customer id&lt;/li&gt;
&lt;li&gt;date of transaction&lt;/li&gt;
&lt;li&gt;and amount&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;customer_id&lt;/code&gt;: name of the customer id column&lt;/li&gt;
&lt;li&gt;&lt;code&gt;order_date&lt;/code&gt;: name of the transaction date column&lt;/li&gt;
&lt;li&gt;&lt;code&gt;revenue&lt;/code&gt;: name of the transaction amount column&lt;/li&gt;
&lt;li&gt;&lt;code&gt;analysis_date&lt;/code&gt;: date of analysis&lt;/li&gt;
&lt;li&gt;&lt;code&gt;recency_bins&lt;/code&gt;: number of rankings for recency score (default is 5)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;frequency_bins&lt;/code&gt;: number of rankings for frequency score (default is 5)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;monetary_bins&lt;/code&gt;: number of rankings for monetary score (default is 5)&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;rfm-table-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;RFM Table&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;analysis_date &amp;lt;- lubridate::as_date(&amp;quot;2006-12-31&amp;quot;, tz = &amp;quot;UTC&amp;quot;)
rfm_result &amp;lt;- rfm_table_order(rfm_data_orders, customer_id, order_date, revenue, analysis_date)
rfm_result&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: `tz` argument is ignored by `as_date()`&lt;/code&gt;&lt;/pre&gt;
&lt;table class=&#34;table&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
customer_id
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
date_most_recent
&lt;/th&gt;
&lt;th style=&#34;text-align:right;&#34;&gt;
recency_days
&lt;/th&gt;
&lt;th style=&#34;text-align:right;&#34;&gt;
transaction_count
&lt;/th&gt;
&lt;th style=&#34;text-align:right;&#34;&gt;
amount
&lt;/th&gt;
&lt;th style=&#34;text-align:right;&#34;&gt;
recency_score
&lt;/th&gt;
&lt;th style=&#34;text-align:right;&#34;&gt;
frequency_score
&lt;/th&gt;
&lt;th style=&#34;text-align:right;&#34;&gt;
monetary_score
&lt;/th&gt;
&lt;th style=&#34;text-align:right;&#34;&gt;
rfm_score
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Abbey O’Reilly DVM
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2006-06-09
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
205
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
6
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
472
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
3
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
4
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
3
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
343
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Add Senger
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2006-08-13
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
140
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
3
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
340
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
4
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
1
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
2
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
412
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Aden Lesch Sr. 
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2006-06-20
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
194
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
4
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
405
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
3
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
2
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
3
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
323
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Admiral Senger
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2006-08-21
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
132
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
5
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
448
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
4
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
3
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
3
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
433
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Agness O’Keefe
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2006-10-02
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
90
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
9
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
843
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
5
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
5
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
5
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
555
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Aileen Barton
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2006-10-08
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
84
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
9
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
763
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
5
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
5
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
5
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
555
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Ailene Hermann
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2006-03-25
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
281
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
8
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
699
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
3
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
5
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
5
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
355
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Aiyanna Bruen PhD
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2006-04-29
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
246
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
4
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
157
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
3
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
2
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
1
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
321
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Ala Schmidt DDS
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2006-01-16
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
349
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
3
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
363
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
2
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
1
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
2
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
212
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Alannah Borer
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2005-04-21
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
619
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
4
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
196
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
1
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
2
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
1
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
121
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;code&gt;rfm_table_order()&lt;/code&gt; will return the following columns as seen in the above table:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;customer_id&lt;/code&gt;: unique customer id&lt;/li&gt;
&lt;li&gt;&lt;code&gt;date_most_recent&lt;/code&gt;: date of most recent visit&lt;/li&gt;
&lt;li&gt;&lt;code&gt;recency_days&lt;/code&gt;: days since the most recent visit&lt;/li&gt;
&lt;li&gt;&lt;code&gt;transaction_count&lt;/code&gt;: number of transactions of the customer&lt;/li&gt;
&lt;li&gt;&lt;code&gt;amount&lt;/code&gt;: total revenue generated by the customer&lt;/li&gt;
&lt;li&gt;&lt;code&gt;recency_score&lt;/code&gt;: recency score of the customer&lt;/li&gt;
&lt;li&gt;&lt;code&gt;frequency_score&lt;/code&gt;: frequency score of the customer&lt;/li&gt;
&lt;li&gt;&lt;code&gt;monetary_score&lt;/code&gt;: monetary score of the customer&lt;/li&gt;
&lt;li&gt;&lt;code&gt;rfm_score&lt;/code&gt;: RFM score of the customer&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;segments-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Segments&lt;/h3&gt;
&lt;p&gt;Let us classify our customers based on the individual recency, frequency and
monetary scores.&lt;/p&gt;
&lt;table class=&#34;table&#34; style=&#34;font-size: 12px; margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Segment
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
R
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
F
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
M
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Champions
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Bought recently, buy often and spend the most
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
4 - 5
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
4 - 5
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
4 - 5
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Loyal Customers
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Spend good money. Responsive to promotions
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2 - 4
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
3 - 4
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
4 - 5
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Potential Loyalist
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Recent customers, spent good amount, bought more than once
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
3 - 5
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
1 - 3
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
1 - 3
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
New Customers
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Bought more recently, but not often
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
4 - 5
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&amp;lt; 2
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&amp;lt; 2
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Promising
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Recent shoppers, but haven’t spent much
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
3 - 4
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&amp;lt; 2
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&amp;lt; 2
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Need Attention
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Above average recency, frequency &amp;amp; monetary values
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
3 - 4
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
3 - 4
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
3 - 4
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
About To Sleep
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Below average recency, frequency &amp;amp; monetary values
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2 - 3
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&amp;lt; 3
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&amp;lt; 3
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
At Risk
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Spent big money, purchased often but long time ago
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&amp;lt; 3
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2 - 5
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2 - 5
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Can’t Lose Them
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Made big purchases and often, but long time ago
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&amp;lt; 2
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
4 - 5
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
4 - 5
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Hibernating
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Low spenders, low frequency, purchased long time ago
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2 - 3
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2 - 3
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2 - 3
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Lost
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Lowest recency, frequency &amp;amp; monetary scores
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&amp;lt; 2
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&amp;lt; 2
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&amp;lt; 2
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;div id=&#34;segmented-customer-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Segmented Customer Data&lt;/h3&gt;
&lt;p&gt;We can use the segmented data to identify&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;champion customers&lt;/li&gt;
&lt;li&gt;loyal customers&lt;/li&gt;
&lt;li&gt;at risk customers&lt;/li&gt;
&lt;li&gt;and lost customers&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Once we have classified a customer into a particular segment, we can take
appropriate action to increase his/her lifetime value.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;segment_names &amp;lt;- 
  c(&amp;quot;Champions&amp;quot;, &amp;quot;Loyal Customers&amp;quot;, &amp;quot;Potential Loyalist&amp;quot;,
    &amp;quot;New Customers&amp;quot;, &amp;quot;Promising&amp;quot;, &amp;quot;Need Attention&amp;quot;, 
    &amp;quot;About To Sleep&amp;quot;, &amp;quot;At Risk&amp;quot;, &amp;quot;Can&amp;#39;t Lose Them&amp;quot;, 
    &amp;quot;Hibernating&amp;quot;, &amp;quot;Lost&amp;quot;)

recency_lower   &amp;lt;- c(4, 2, 3, 4, 3, 3, 2, 1, 1, 2, 1)
recency_upper   &amp;lt;- c(5, 4, 5, 5, 4, 4, 3, 2, 1, 3, 1)
frequency_lower &amp;lt;- c(4, 3, 1, 1, 1, 3, 1, 2, 4, 2, 1)
frequency_upper &amp;lt;- c(5, 4, 3, 1, 1, 4, 2, 5, 5, 3, 1)
monetary_lower  &amp;lt;- c(4, 4, 1, 1, 1, 3, 1, 2, 4, 2, 1)
monetary_upper  &amp;lt;- c(5, 5, 3, 1, 1, 4, 2, 5, 5, 3, 1)

segments &amp;lt;- 
  rfm_segment(rfm_result, segment_names, recency_lower, 
              recency_upper, frequency_lower, frequency_upper, 
              monetary_lower, monetary_upper)

segments %&amp;gt;% 
  select(customer_id, segment, rfm_score)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 995 x 3
##    customer_id        segment            rfm_score
##    &amp;lt;chr&amp;gt;              &amp;lt;chr&amp;gt;                  &amp;lt;dbl&amp;gt;
##  1 Abbey O&amp;#39;Reilly DVM Need Attention           343
##  2 Add Senger         Potential Loyalist       412
##  3 Aden Lesch Sr.     Hibernating              323
##  4 Admiral Senger     Need Attention           433
##  5 Agness O&amp;#39;Keefe     Champions                555
##  6 Aileen Barton      Champions                555
##  7 Ailene Hermann     Others                   355
##  8 Aiyanna Bruen PhD  About To Sleep           321
##  9 Ala Schmidt DDS    About To Sleep           212
## 10 Alannah Borer      Others                   121
## # ... with 985 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;segment-size&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Segment Size&lt;/h3&gt;
&lt;p&gt;Now that we have defined and segmented our customers, let us examine the
distribution of customers across the segments. If our segmentation logic is
good, few or no customer should be categorized as &lt;code&gt;Others&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;segments %&amp;gt;%
  count(segment) %&amp;gt;%
  arrange(desc(n)) %&amp;gt;%
  rename(Segment = segment, Count = n)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 12 x 2
##    Segment            Count
##    &amp;lt;chr&amp;gt;              &amp;lt;int&amp;gt;
##  1 At Risk              157
##  2 Potential Loyalist   132
##  3 Others               128
##  4 Champions            116
##  5 Need Attention       100
##  6 Hibernating           97
##  7 About To Sleep        92
##  8 Lost                  75
##  9 Loyal Customers       43
## 10 Promising             21
## 11 Can&amp;#39;t Lose Them       17
## 12 New Customers         17&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can also examine the median recency, frequency and monetary value across
segments to ensure that the logic used for customer classification is sound and
practical.&lt;/p&gt;
&lt;div id=&#34;median-recency&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Median Recency&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rfm_plot_median_recency(segments)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-07-22-customer-segmentation-using-rfm-analysis_files/figure-html/avg_recency-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;median-frequency&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Median Frequency&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rfm_plot_median_frequency(segments)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-07-22-customer-segmentation-using-rfm-analysis_files/figure-html/avg_frequency-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;median-monetary-value&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Median Monetary Value&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rfm_plot_median_monetary(segments)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-07-22-customer-segmentation-using-rfm-analysis_files/figure-html/avg_monetary-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;heat-map&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Heat Map&lt;/h3&gt;
&lt;p&gt;The heat map shows the average monetary value for different categories of
recency and frequency scores. Higher scores of frequency and recency are
characterized by higher average monetary value as indicated by the darker areas
in the heatmap.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rfm_heatmap(rfm_result)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-07-22-customer-segmentation-using-rfm-analysis_files/figure-html/heatmap-1.png&#34; width=&#34;768&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;bar-chart&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Bar Chart&lt;/h3&gt;
&lt;p&gt;Use &lt;code&gt;rfm_bar_chart()&lt;/code&gt; to generate the distribution of monetary scores for the
different combinations of frequency and recency scores.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rfm_bar_chart(rfm_result)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-07-22-customer-segmentation-using-rfm-analysis_files/figure-html/barchart-1.png&#34; width=&#34;768&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;histogram&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Histogram&lt;/h3&gt;
&lt;p&gt;Use &lt;code&gt;rfm_histograms()&lt;/code&gt; to examine the relative distribution of&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;monetary value (total revenue generated by each customer)&lt;/li&gt;
&lt;li&gt;recency days (days since the most recent visit for each customer)&lt;/li&gt;
&lt;li&gt;frequency (transaction count for each customer)&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rfm_histograms(rfm_result)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-07-22-customer-segmentation-using-rfm-analysis_files/figure-html/rfmhist-1.png&#34; width=&#34;768&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;customers-by-orders&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Customers by Orders&lt;/h3&gt;
&lt;p&gt;Visualize the distribution of customers across orders.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rfm_order_dist(rfm_result)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-07-22-customer-segmentation-using-rfm-analysis_files/figure-html/rfmorders-1.png&#34; width=&#34;768&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;scatter-plots&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Scatter Plots&lt;/h3&gt;
&lt;p&gt;The best customers are those who:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;bought most recently&lt;/li&gt;
&lt;li&gt;most often&lt;/li&gt;
&lt;li&gt;and spend the most&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now let us examine the relationship between the above.&lt;/p&gt;
&lt;div id=&#34;recency-vs-monetary-value&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Recency vs Monetary Value&lt;/h4&gt;
&lt;p&gt;Customers who visited more recently generated more revenue compared to those
who visited in the distant past. The customers who visited in the recent past
are more likely to return compared to those who visited long time ago as most
of those would be lost customers. As such, higher revenue would be associated
with most recent visits.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rfm_rm_plot(rfm_result)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-07-22-customer-segmentation-using-rfm-analysis_files/figure-html/mr-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;frequency-vs-monetary-value&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Frequency vs Monetary Value&lt;/h4&gt;
&lt;p&gt;As the frequency of visits increases, the revenue generated also increases.
Customers who visit more frquently are your champion customers, loyal customers
or potential loyalists and they drive higher revenue.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rfm_fm_plot(rfm_result)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-07-22-customer-segmentation-using-rfm-analysis_files/figure-html/fm-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;recency-vs-frequency&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Recency vs Frequency&lt;/h4&gt;
&lt;p&gt;Customers with low frequency visited in the distant past while those with high
frequency have visited in the recent past. Again, the customers who visited in
the recent past are more likely to return compared to those who visited long
time ago. As such, higher frequency would be associated with the most recent
visits.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rfm_rf_plot(rfm_result)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-07-22-customer-segmentation-using-rfm-analysis_files/figure-html/fr-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;your-turn&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Your Turn…&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;if you look at the distribution of segments, around 13% of the customers
are in the &lt;code&gt;Others&lt;/code&gt; segment For segmentation to be effective and optimal, the
&lt;code&gt;Others&lt;/code&gt; segment should be eliminated or should have few customers only.
Redefine the segments and try to reduce the number of customers in the &lt;code&gt;Others&lt;/code&gt;
segment.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;we have defined 11 segments. Try to combine some of the existing segments
and bring down the total segments to around 6 or 8.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;the RFM score we generated uses score between 1 and 5. Try to create segments
by using a score between 1 and 3 i.e. the lowest RFM should be 111 and the
highest should be 333 instead of 555.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;reverse the scores i.e. so far we have assigned a score of 5 to customers who
visited recently, frequently and had higher transaction amount and 1 to
customers who visited way back, rarely and have low transaction amount. Reverse
this score pattern and create the segments.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;learning-more&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Learning More&lt;/h2&gt;
&lt;p&gt;The &lt;a href=&#34;https://rfm.rsquaredacademy.com/index.html&#34; target=&#34;_blank&#34;&gt;rfm website&lt;/a&gt;
includes comprehensive documentation on using the package, including the following
articles that cover various aspects of using rfm:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href=&#34;https://rfm.rsquaredacademy.com/articles/rfm-customer-level-data.html&#34; target=&#34;_blank&#34;&gt;RFM Customer Level Data&lt;/a&gt; - shows you how to handle customer level data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href=&#34;https://rfm.rsquaredacademy.com/articles/rfm-transaction-level-data.html&#34; target=&#34;_blank&#34;&gt;RFM Transaction Level Data&lt;/a&gt; - shows you how to handle transaction level data.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;feedback&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Feedback&lt;/h2&gt;
&lt;p&gt;If you see mistakes or want to suggest changes, please create an issue on the
&lt;a href=&#34;https://github.com/rsquaredacademy-infra/blog&#34; target=&#34;_blank&#34;&gt;source
repository&lt;/a&gt; or reach out to us at &lt;a href=&#34;mailto:support@rsquaredacademy.com&#34; class=&#34;email&#34;&gt;support@rsquaredacademy.com&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>pkginfo: Tools for Retrieving R Package Information</title>
      <link>https://blog.rsquaredacademy.com/introducing-pkginfo/</link>
      <pubDate>Fri, 05 Jul 2019 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/introducing-pkginfo/</guid>
      <description>&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/github_pkginfo.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;motivation&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Motivation&lt;/h2&gt;
&lt;p&gt;There are several wonderful tools for retrieving information about R packages, some of which are listed below:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;https://github.com/r-hub/cranlogs&#34;&gt;cranlogs&lt;/a&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;a href=&#34;https://github.com/GuangchuangYu/dlstats&#34;&gt;dlstats&lt;/a&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;a href=&#34;https://github.com/lindbrook/packageRank&#34;&gt;packageRank&lt;/a&gt;&lt;/strong&gt; for R package download stats&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;https://github.com/r-hub/pkgsearch&#34;&gt;pkgsearch&lt;/a&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;a href=&#34;https://github.com/jsugarelli/packagefinder/&#34;&gt;packagefinder&lt;/a&gt;&lt;/strong&gt; for searching CRAN R packages&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;https://github.com/r-hub/crandb&#34;&gt;crandb&lt;/a&gt;&lt;/strong&gt; provides API for programatically accessing meta-data&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;https://github.com/ropenscilabs/cchecks&#34;&gt;cchecks&lt;/a&gt;&lt;/strong&gt; for CRAN check results&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We have used some or all of these to track/monitor our own &lt;a href=&#34;https://pkgs.rsquaredacademy.com&#34;&gt;R packages&lt;/a&gt; available on CRAN. Over time, we wanted to have a single interface which would retrieve information from different places including:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;check results from &lt;a href=&#34;https://cran.r-project.org/&#34;&gt;CRAN&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;issues &amp;amp; pull requests from &lt;a href=&#34;https://github.com/&#34;&gt;GitHub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;build status from &lt;a href=&#34;https://travis-ci.org/&#34;&gt;Travis&lt;/a&gt; and &lt;a href=&#34;https://ci.appveyor.com/&#34;&gt;Appveyor&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;code coverage from &lt;a href=&#34;https://codecov.io/&#34;&gt;Codecov&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;questions tagged with the package name in &lt;a href=&#34;https://stackoverflow.com/&#34;&gt;Stack Overflow&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And below is a demo of what we came up with…&lt;/p&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/g7Lcmgiyzmo&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;p&gt;The above shiny app can be launched with:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;pkginfo::pkginfo_dashboard()&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;https://github.com/rsquaredacademy/pkginfo&#34;&gt;pkginfo&lt;/a&gt; will allow you to retrieve information from multiple places. The shiny app is especially useful if you are looking for information about multiple R packages. &lt;a href=&#34;https://github.com/rsquaredacademy/pkginfo&#34;&gt;pkginfo&lt;/a&gt; provides two APIs, one is object oriented, the other one is procedural, and in this post, we will show you how to use them.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;installation&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Installation&lt;/h2&gt;
&lt;p&gt;You can install the development version from &lt;a href=&#34;https://github.com/rsquaredacademy/pkginfo&#34;&gt;GitHub&lt;/a&gt; with:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;devtools::install_github(&amp;quot;rsquaredacademy/pkginfo&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;p&gt;&lt;a href=&#34;https://www.rsquaredacademy.com/&#34; target=&#34;_blank&#34;&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/ad.png&#34; width=&#34;100%&#34; alt=&#34;course ad&#34; style=&#34;text-decoration: none;&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;/div&gt;
&lt;div id=&#34;object-oriented-api&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Object Oriented API&lt;/h2&gt;
&lt;p&gt;The object oriented API uses &lt;a href=&#34;https://github.com/r-lib/R6&#34;&gt;R6&lt;/a&gt; classes.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(pkginfo)&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;github&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;GitHub&lt;/h3&gt;
&lt;div id=&#34;creating-a-new-githubrepo-object&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Creating a new GitHubRepo object&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;myRepo &amp;lt;- GitHubRepo$new(&amp;quot;olsrr&amp;quot;, &amp;quot;rsquaredacademy&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;stars-forks-issues&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Stars, Forks &amp;amp; Issues&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;get_stats()&lt;/code&gt; will report the number of stars, forks and open issues.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;myRepo$get_stats()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1 x 3
##   stars issues forks
##   &amp;lt;int&amp;gt;  &amp;lt;int&amp;gt; &amp;lt;int&amp;gt;
## 1    84     13    14&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;issues&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Issues&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;get_issues()&lt;/code&gt; will report the date, number, author and title of all the open issues.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;myRepo$get_issues()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 13 x 4
##    date       number author      title                                          
##    &amp;lt;date&amp;gt;      &amp;lt;int&amp;gt; &amp;lt;chr&amp;gt;       &amp;lt;chr&amp;gt;                                          
##  1 2020-06-06    163 AminHP      &amp;quot;Stepwise selection based on Adjusted R-Square~
##  2 2020-05-05    162 Fernal73    &amp;quot;User must be able to specify different best s~
##  3 2020-05-04    161 Fernal73    &amp;quot;ggplot (or grob) object must be printed when ~
##  4 2020-05-04    160 Fernal73    &amp;quot;Methods returning data.frame of decision crit~
##  5 2020-04-28    159 aravindheb~ &amp;quot;Extracting model data&amp;quot;                        
##  6 2020-04-28    158 Fernal73    &amp;quot;Cannot coerce class ‘\&amp;quot;function\&amp;quot;’ to a data.~
##  7 2020-04-17    157 aravindheb~ &amp;quot;Best subset regression options&amp;quot;               
##  8 2019-12-10    146 sblanco74   &amp;quot;Hi @aravindhebbali&amp;quot;                           
##  9 2019-11-18    138 vasili111   &amp;quot;Linear mixed model support?&amp;quot;                  
## 10 2019-10-04    137 aravindheb~ &amp;quot;Automated report&amp;quot;                             
## 11 2019-10-04    136 aravindheb~ &amp;quot;Import shiny app from xplorerr &amp;quot;              
## 12 2019-06-20    133 aravindheb~ &amp;quot;Cook&amp;#39;s distance chart threshold&amp;quot;              
## 13 2018-09-21     92 cccfran     &amp;quot;categorical variable&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;branches&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Branches&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;get_branches()&lt;/code&gt; will report the name of the branches.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;myRepo$get_branches()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 2 x 1
##   branches
##   &amp;lt;chr&amp;gt;   
## 1 develop 
## 2 master&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;build-status-code-coverage&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Build Status &amp;amp; Code Coverage&lt;/h4&gt;
&lt;p&gt;The build status is reported from &lt;a href=&#34;https://travis-ci.org/&#34;&gt;Travis CI&lt;/a&gt; and &lt;a href=&#34;https://ci.appveyor.com/&#34;&gt;Appveyor&lt;/a&gt; while code coverage is reported from &lt;a href=&#34;https://codecov.io/&#34;&gt;Codecov&lt;/a&gt;&lt;/p&gt;
&lt;div id=&#34;travis-ci&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Travis CI&lt;/h5&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;myRepo$get_travis_status()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Error&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;codecov&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Codecov&lt;/h5&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;myRepo$get_coverage()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;92.81957&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;p&gt;
&lt;a href=&#34;https://www.youtube.com/user/rsquaredin/&#34; target=&#34;_blank&#34;&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/ad_youtube.png&#34; width=&#34;100%&#34; alt=&#34;youtube ad&#34; style=&#34;text-decoration: none;&#34;&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;hr&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;procedural-api&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Procedural API&lt;/h2&gt;
&lt;div id=&#34;github-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;GitHub&lt;/h3&gt;
&lt;p&gt;To use the procedural API for retrieving GitHub information, you need to provide the following inputs:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;package/repo name&lt;/li&gt;
&lt;li&gt;GitHUb user/organization name (optional)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you do not know the GitHub user/org name, leave it empty. &lt;a href=&#34;https://github.com/rsquaredacademy/pkginfo&#34;&gt;pkginfo&lt;/a&gt; will look for the user/org name in the &lt;strong&gt;URLS&lt;/strong&gt; available on the CRAN page of the package.&lt;/p&gt;
&lt;div id=&#34;stars-forks-issues-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Stars, Forks &amp;amp; Issues&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;get_gh_stats(&amp;quot;olsrr&amp;quot;, &amp;quot;rsquaredacademy&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1 x 3
##   stars issues forks
##   &amp;lt;int&amp;gt;  &amp;lt;int&amp;gt; &amp;lt;int&amp;gt;
## 1    84     13    14&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;issues-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Issues&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;get_gh_issues(&amp;quot;olsrr&amp;quot;, &amp;quot;rsquaredacademy&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 13 x 4
##    date       number author      title                                          
##    &amp;lt;date&amp;gt;      &amp;lt;int&amp;gt; &amp;lt;chr&amp;gt;       &amp;lt;chr&amp;gt;                                          
##  1 2020-06-06    163 AminHP      &amp;quot;Stepwise selection based on Adjusted R-Square~
##  2 2020-05-05    162 Fernal73    &amp;quot;User must be able to specify different best s~
##  3 2020-05-04    161 Fernal73    &amp;quot;ggplot (or grob) object must be printed when ~
##  4 2020-05-04    160 Fernal73    &amp;quot;Methods returning data.frame of decision crit~
##  5 2020-04-28    159 aravindheb~ &amp;quot;Extracting model data&amp;quot;                        
##  6 2020-04-28    158 Fernal73    &amp;quot;Cannot coerce class ‘\&amp;quot;function\&amp;quot;’ to a data.~
##  7 2020-04-17    157 aravindheb~ &amp;quot;Best subset regression options&amp;quot;               
##  8 2019-12-10    146 sblanco74   &amp;quot;Hi @aravindhebbali&amp;quot;                           
##  9 2019-11-18    138 vasili111   &amp;quot;Linear mixed model support?&amp;quot;                  
## 10 2019-10-04    137 aravindheb~ &amp;quot;Automated report&amp;quot;                             
## 11 2019-10-04    136 aravindheb~ &amp;quot;Import shiny app from xplorerr &amp;quot;              
## 12 2019-06-20    133 aravindheb~ &amp;quot;Cook&amp;#39;s distance chart threshold&amp;quot;              
## 13 2018-09-21     92 cccfran     &amp;quot;categorical variable&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;p&gt;&lt;a href=&#34;https://pkgs.rsquaredacademy.com/&#34; target=&#34;_blank&#34;&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/ad_packages.png&#34; width=&#34;100%&#34; alt=&#34;packages ad&#34; style=&#34;text-decoration: none;&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;cran-check-results&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;CRAN Check Results&lt;/h3&gt;
&lt;p&gt;The CRAN check results is reported using the &lt;a href=&#34;https://github.com/ropenscilabs/cchecksapi&#34;&gt;cchecksapi&lt;/a&gt; API.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;get_pkg_cran_check_results(&amp;quot;olsrr&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 12 x 4
##    os                r      status url                                          
##    &amp;lt;chr&amp;gt;             &amp;lt;chr&amp;gt;  &amp;lt;chr&amp;gt;  &amp;lt;chr&amp;gt;                                        
##  1 linux-x86_64-deb~ devel  OK     https://www.R-project.org/nosvn/R.check/r-de~
##  2 linux-x86_64-deb~ devel  OK     https://www.R-project.org/nosvn/R.check/r-de~
##  3 linux-x86_64-fed~ devel  OK     https://www.R-project.org/nosvn/R.check/r-de~
##  4 linux-x86_64-fed~ devel  OK     https://www.R-project.org/nosvn/R.check/r-de~
##  5 windows-ix86+x86~ devel  OK     https://www.R-project.org/nosvn/R.check/r-de~
##  6 linux-x86_64      patch~ OK     https://www.R-project.org/nosvn/R.check/r-pa~
##  7 solaris-x86       patch~ OK     https://www.R-project.org/nosvn/R.check/r-pa~
##  8 linux-x86_64      relea~ OK     https://www.R-project.org/nosvn/R.check/r-re~
##  9 osx-x86_64        relea~ OK     https://www.R-project.org/nosvn/R.check/r-re~
## 10 windows-ix86+x86~ relea~ OK     https://www.R-project.org/nosvn/R.check/r-re~
## 11 osx-x86_64        oldrel OK     https://www.R-project.org/nosvn/R.check/r-ol~
## 12 windows-ix86+x86~ oldrel OK     https://www.R-project.org/nosvn/R.check/r-ol~&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;build-status&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Build Status&lt;/h3&gt;
&lt;p&gt;You can check the build status of a package from both &lt;a href=&#34;https://travis-ci.org/&#34;&gt;Travis CI&lt;/a&gt; and &lt;a href=&#34;https://ci.appveyor.com/&#34;&gt;Appveyor&lt;/a&gt;.&lt;/p&gt;
&lt;div id=&#34;travis-ci-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Travis CI&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;get_status_travis(&amp;quot;olsrr&amp;quot;, &amp;quot;rsquaredacademy&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Error&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;appveyor&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Appveyor&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;get_status_appveyor(&amp;quot;olsrr&amp;quot;, &amp;quot;rsquaredacademy&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;failed&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;code-coverage&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Code Coverage&lt;/h3&gt;
&lt;p&gt;Report code coverage for the package from the coverage service &lt;a href=&#34;https://codecov.io/&#34;&gt;Codecov&lt;/a&gt;. We hope to add coverage from &lt;a href=&#34;https://coveralls.io/&#34;&gt;Coveralls&lt;/a&gt; in the near future.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;get_code_coverage(&amp;quot;olsrr&amp;quot;, &amp;quot;rsquaredacademy&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;92.81957&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;stack-overflow&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Stack Overflow&lt;/h3&gt;
&lt;p&gt;Questions tagged with the package name will be displayed from &lt;a href=&#34;https://stackoverflow.com/&#34;&gt;Stack Overflow&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;get_so_questions(&amp;quot;dplyr&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 30 x 6
##    date       title                 owner    answered views link                
##    &amp;lt;date&amp;gt;     &amp;lt;chr&amp;gt;                 &amp;lt;chr&amp;gt;    &amp;lt;lgl&amp;gt;    &amp;lt;int&amp;gt; &amp;lt;chr&amp;gt;               
##  1 2020-06-09 Combining 2 data fra~ Les      FALSE       22 https://stackoverfl~
##  2 2020-06-10 Summarizing one way,~ David T  FALSE       11 https://stackoverfl~
##  3 2020-06-10 Identifying and modi~ Parselt~ TRUE        17 https://stackoverfl~
##  4 2020-06-10 R: How do I append d~ Gordon ~ FALSE       14 https://stackoverfl~
##  5 2020-06-10 customising title of~ smicaela FALSE       10 https://stackoverfl~
##  6 2020-06-10 Aggregate rows withi~ Christo~ FALSE       10 https://stackoverfl~
##  7 2020-06-10 %within% in case_whe~ Rasmus   FALSE       22 https://stackoverfl~
##  8 2020-06-10 R/dplyr: How do I in~ questio~ FALSE       20 https://stackoverfl~
##  9 2020-06-10 Filter rows of one c~ mvanaman FALSE       12 https://stackoverfl~
## 10 2020-06-10 Groupby and keep onl~ chippyc~ FALSE       24 https://stackoverfl~
## # ... with 20 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;to-do..&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;To Do..&lt;/h2&gt;
&lt;p&gt;In the near future, &lt;a href=&#34;https://github.com/rsquaredacademy/pkginfo&#34;&gt;pkginfo&lt;/a&gt; will retrieve information:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;about packages that are available on GitHub/GitLab but not on CRAN&lt;/li&gt;
&lt;li&gt;packages that are available on &lt;a href=&#34;https://about.gitlab.com/&#34;&gt;GitLab&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;about code coverage from &lt;a href=&#34;https://coveralls.io/&#34;&gt;Coveralls&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;about Twitter mentions&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We did not have any specific end user in mind while developing but believe it will be more useful to package developers/maintainers. Suggestions/feedbacks and pull requests are always welcome.&lt;/p&gt;
&lt;p&gt;If you see mistakes or want to suggest changes, please create an issue on the
&lt;a href=&#34;https://github.com/rsquaredacademy-infra/blog&#34; target=&#34;_blank&#34;&gt;source repository&lt;/a&gt;
or reach out to us at &lt;a href=&#34;mailto:feedback@rsquaredacademy.com&#34; class=&#34;email&#34;&gt;feedback@rsquaredacademy.com&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Demystifying Regular Expressions in R</title>
      <link>https://blog.rsquaredacademy.com/regular-expression-in-r/</link>
      <pubDate>Mon, 27 May 2019 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/regular-expression-in-r/</guid>
      <description>&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_cover_image.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In this post, we will learn about using regular expressions in R. While it is
aimed at absolute beginners, we hope experienced users will find it useful as
well. The post is broadly divided into 3 sections. In the first section, we
will introduce the pattern matching functions such as &lt;code&gt;grep&lt;/code&gt;, &lt;code&gt;grepl&lt;/code&gt; etc. in
base R as we will be using them in the rest of the post. Once the reader is
comfortable with the above mentioned pattern matching functions, we will
learn about regular expressions while exploring the names of R packages by
probing the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;how many package names include the letter &lt;code&gt;r&lt;/code&gt;?&lt;/li&gt;
&lt;li&gt;how many package names begin or end with the letter &lt;code&gt;r&lt;/code&gt;?&lt;/li&gt;
&lt;li&gt;how many package names include the words &lt;code&gt;data&lt;/code&gt; or &lt;code&gt;plot&lt;/code&gt;?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the final section, we will go through 4 case studies including simple email
validation. If you plan to try the case studies, please do not skip any of the
topics in the second section.&lt;/p&gt;
&lt;div id=&#34;what&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;What&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_what.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;why&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Why&lt;/h3&gt;
&lt;p&gt;Regular expressions can be used for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;search&lt;/li&gt;
&lt;li&gt;replace&lt;/li&gt;
&lt;li&gt;validation&lt;/li&gt;
&lt;li&gt;extraction&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_why.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;use-cases&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Use Cases&lt;/h3&gt;
&lt;p&gt;Regular expressions have applications in a wide range of areas. We list some of
the most popular ones below:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;email validation&lt;/li&gt;
&lt;li&gt;password validation&lt;/li&gt;
&lt;li&gt;date validation&lt;/li&gt;
&lt;li&gt;phone number validation&lt;/li&gt;
&lt;li&gt;search and replace in text editors&lt;/li&gt;
&lt;li&gt;web scraping&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_use_case_blog.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;learning&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Learning&lt;/h2&gt;
&lt;p&gt;The below steps offer advice on the best way to learn or use regular expressions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;describe the pattern in layman terms&lt;/li&gt;
&lt;li&gt;break down the pattern into individual components&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;match each component to a regular expression&lt;/li&gt;
&lt;li&gt;build incrementally&lt;/li&gt;
&lt;li&gt;test&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;resources&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Resources&lt;/h2&gt;
&lt;p&gt;Below are the links to all the resources related to this post:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://slides.rsquaredacademy.com/regex/regex.html&#34; target=&#34;_blank&#34;&gt;Slides&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/rsquaredacademy-education/online-courses/tree/master/regular-expressions-in-r&#34; target=&#34;_blank&#34;&gt;Code &amp;amp; Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://rstudio.cloud/project/356612&#34; target=&#34;_blank&#34;&gt;RStudio Cloud&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Libraries&lt;/h2&gt;
&lt;p&gt;We will use the following libraries in this post:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(dplyr)
library(readr)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data&lt;/h2&gt;
&lt;p&gt;We will use two data sets in this post. The first one is a list of all R
packages on CRAN and is present in the &lt;code&gt;package_names.csv&lt;/code&gt; file, and the
second one, &lt;code&gt;top_downloads&lt;/code&gt;, is the most downloaded packages from the
&lt;a href=&#34;https://cran.rstudio.com/&#34; target=&#34;_blank&#34;&gt;RStudio CRAN mirror&lt;/a&gt;
in the first week of May 2019, and extracted using the
&lt;a href=&#34;https://cranlogs.r-pkg.org/#rpackage&#34; target=&#34;_blank&#34;&gt;cranlogs&lt;/a&gt; pacakge.&lt;/p&gt;
&lt;div id=&#34;r-packages-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;R Packages Data&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;read_csv(&amp;quot;package_names.csv&amp;quot;) %&amp;gt;%
  pull(1) -&amp;gt; r_packages &lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;top-r-packages&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Top R Packages&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;top_downloads &amp;lt;- c(&amp;quot;devtools&amp;quot;, &amp;quot;rlang&amp;quot;, &amp;quot;dplyr&amp;quot;, &amp;quot;Rcpp&amp;quot;, &amp;quot;tibble&amp;quot;,    
                   &amp;quot;ggplot2&amp;quot;, &amp;quot;glue&amp;quot;, &amp;quot;pillar&amp;quot;, &amp;quot;cli&amp;quot;, &amp;quot;data.table&amp;quot;)

top_downloads&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;devtools&amp;quot;   &amp;quot;rlang&amp;quot;      &amp;quot;dplyr&amp;quot;      &amp;quot;Rcpp&amp;quot;       &amp;quot;tibble&amp;quot;    
##  [6] &amp;quot;ggplot2&amp;quot;    &amp;quot;glue&amp;quot;       &amp;quot;pillar&amp;quot;     &amp;quot;cli&amp;quot;        &amp;quot;data.table&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;pattern-matching-functions&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Pattern Matching Functions&lt;/h2&gt;
&lt;p&gt;Before we get into the nitty gritty of regular expressions, let us explore a
few functions from base R for pattern matching. We will learn about using
regular expressions with the stringr package in an upcoming post.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_base_functions.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;grep&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;grep&lt;/h2&gt;
&lt;p&gt;The first function we will learn is &lt;code&gt;grep()&lt;/code&gt;. It can be used to find elements
that match a given pattern in a character vector. It will return the elements
or the index of the elements based on your specification. In the below example,
&lt;code&gt;grep()&lt;/code&gt; returns the index of the elements that match the given pattern.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_grep_index_canva.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = top_downloads, pattern = &amp;quot;r&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 2 3 8&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now let us look at the inputs:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;pattern&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;x&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ignore.case&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;value&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;invert&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;grep---value&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;grep - Value&lt;/h2&gt;
&lt;p&gt;If you want &lt;code&gt;grep()&lt;/code&gt; to return the element instead of the index, set the
&lt;code&gt;value&lt;/code&gt; argument to &lt;code&gt;TRUE&lt;/code&gt;. The default is &lt;code&gt;FALSE&lt;/code&gt;. In the below example,
&lt;code&gt;grep()&lt;/code&gt; returns the elements and not their index.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_grep_value_canva.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = top_downloads, pattern = &amp;quot;r&amp;quot;, value = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;rlang&amp;quot;  &amp;quot;dplyr&amp;quot;  &amp;quot;pillar&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;grep---ignore-case&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;grep - Ignore Case&lt;/h2&gt;
&lt;p&gt;If you have carefully observed the previous examples, have you noticed that
the pattern &lt;code&gt;r&lt;/code&gt; did not match the element &lt;code&gt;Rcpp&lt;/code&gt; i.e. regular expressions are
case sensitive. The &lt;code&gt;ignore.case&lt;/code&gt; argument will ignore case while matching the
pattern as shown below.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_grep_ignore_case_canva.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = top_downloads, pattern = &amp;quot;r&amp;quot;, value = TRUE, ignore.case = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;rlang&amp;quot;  &amp;quot;dplyr&amp;quot;  &amp;quot;Rcpp&amp;quot;   &amp;quot;pillar&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = top_downloads, pattern = &amp;quot;R&amp;quot;, value = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Rcpp&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = top_downloads, pattern = &amp;quot;R&amp;quot;, value = TRUE, ignore.case = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;rlang&amp;quot;  &amp;quot;dplyr&amp;quot;  &amp;quot;Rcpp&amp;quot;   &amp;quot;pillar&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;grep---invert&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;grep - Invert&lt;/h2&gt;
&lt;p&gt;In some cases, you may want to retrieve elements that do not match the pattern
specified. The &lt;code&gt;invert&lt;/code&gt; argument will return the elements that do not match
the pattern. In the below example, the elements returned do not match the
pattern specified by us.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_grep_invert_canva.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = top_downloads, pattern = &amp;quot;r&amp;quot;, value = TRUE, invert = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;devtools&amp;quot;   &amp;quot;Rcpp&amp;quot;       &amp;quot;tibble&amp;quot;     &amp;quot;ggplot2&amp;quot;    &amp;quot;glue&amp;quot;      
## [6] &amp;quot;cli&amp;quot;        &amp;quot;data.table&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = top_downloads, pattern = &amp;quot;r&amp;quot;, value = TRUE, 
     invert = TRUE, ignore.case = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;devtools&amp;quot;   &amp;quot;tibble&amp;quot;     &amp;quot;ggplot2&amp;quot;    &amp;quot;glue&amp;quot;       &amp;quot;cli&amp;quot;       
## [6] &amp;quot;data.table&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;grepl&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;grepl&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;grepl()&lt;/code&gt; will return only logical values. If the elements match the pattern
specified, it will return &lt;code&gt;TRUE&lt;/code&gt; else &lt;code&gt;FALSE&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_grepl_canva.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grepl(x = top_downloads, pattern = &amp;quot;r&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] FALSE  TRUE  TRUE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;ignore-case&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Ignore Case&lt;/h3&gt;
&lt;p&gt;To ignore the case, use the &lt;code&gt;ignore.case&lt;/code&gt; argument and set it to &lt;code&gt;TRUE&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_grepl_ignore_case_canva.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grepl(x = top_downloads, pattern = &amp;quot;r&amp;quot;, ignore.case = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] FALSE  TRUE  TRUE  TRUE FALSE FALSE FALSE  TRUE FALSE FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The next 3 functions that we explore differ from the above 2 in the format of
and amount of details in the results. They all return the following additional
details:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the starting position of the first match&lt;/li&gt;
&lt;li&gt;the length of the matched text&lt;/li&gt;
&lt;li&gt;whether the match position and length are in chracter or bytes&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;regexpr&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;regexpr&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rr_pkgs &amp;lt;- c(&amp;quot;purrr&amp;quot;, &amp;quot;olsrr&amp;quot;, &amp;quot;blorr&amp;quot;)
regexpr(&amp;quot;r&amp;quot;, rr_pkgs)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 3 4 4
## attr(,&amp;quot;match.length&amp;quot;)
## [1] 1 1 1
## attr(,&amp;quot;index.type&amp;quot;)
## [1] &amp;quot;chars&amp;quot;
## attr(,&amp;quot;useBytes&amp;quot;)
## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;gregexpr&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;gregexpr&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;gregexpr(&amp;quot;r&amp;quot;, rr_pkgs)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [[1]]
## [1] 3 4 5
## attr(,&amp;quot;match.length&amp;quot;)
## [1] 1 1 1
## attr(,&amp;quot;index.type&amp;quot;)
## [1] &amp;quot;chars&amp;quot;
## attr(,&amp;quot;useBytes&amp;quot;)
## [1] TRUE
## 
## [[2]]
## [1] 4 5
## attr(,&amp;quot;match.length&amp;quot;)
## [1] 1 1
## attr(,&amp;quot;index.type&amp;quot;)
## [1] &amp;quot;chars&amp;quot;
## attr(,&amp;quot;useBytes&amp;quot;)
## [1] TRUE
## 
## [[3]]
## [1] 4 5
## attr(,&amp;quot;match.length&amp;quot;)
## [1] 1 1
## attr(,&amp;quot;index.type&amp;quot;)
## [1] &amp;quot;chars&amp;quot;
## attr(,&amp;quot;useBytes&amp;quot;)
## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;regexec&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;regexec&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;regexec(&amp;quot;r&amp;quot;, rr_pkgs)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [[1]]
## [1] 3
## attr(,&amp;quot;match.length&amp;quot;)
## [1] 1
## attr(,&amp;quot;index.type&amp;quot;)
## [1] &amp;quot;chars&amp;quot;
## attr(,&amp;quot;useBytes&amp;quot;)
## [1] TRUE
## 
## [[2]]
## [1] 4
## attr(,&amp;quot;match.length&amp;quot;)
## [1] 1
## attr(,&amp;quot;index.type&amp;quot;)
## [1] &amp;quot;chars&amp;quot;
## attr(,&amp;quot;useBytes&amp;quot;)
## [1] TRUE
## 
## [[3]]
## [1] 4
## attr(,&amp;quot;match.length&amp;quot;)
## [1] 1
## attr(,&amp;quot;index.type&amp;quot;)
## [1] &amp;quot;chars&amp;quot;
## attr(,&amp;quot;useBytes&amp;quot;)
## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;p&gt;
&lt;a href=&#34;https://www.youtube.com/user/rsquaredin/&#34; target=&#34;_blank&#34;&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/ad_youtube.png&#34; width=&#34;100%&#34; alt=&#34;youtube ad&#34; style=&#34;text-decoration: none;&#34;&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;hr&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;sub&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;sub&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;sub()&lt;/code&gt; will perform replacement of the first match. In the below example,
you can observe that only the first match of &lt;code&gt;r&lt;/code&gt; is replaced by &lt;code&gt;s&lt;/code&gt; while
the rest remain the same.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_sub_canva.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rr_pkgs &amp;lt;- c(&amp;quot;purrr&amp;quot;, &amp;quot;olsrr&amp;quot;, &amp;quot;blorr&amp;quot;)
sub(x = rr_pkgs, pattern = &amp;quot;r&amp;quot;, replacement = &amp;quot;s&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;pusrr&amp;quot; &amp;quot;olssr&amp;quot; &amp;quot;blosr&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;gsub&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;gsub&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;gsub()&lt;/code&gt; will perform replacement of all the matches. In the below example,
all the &lt;code&gt;s&lt;/code&gt; are replaced by &lt;code&gt;r&lt;/code&gt;. Compare the below output with the output from
&lt;code&gt;sub()&lt;/code&gt; to understand the difference between them.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_gsub_canva.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;gsub(x = rr_pkgs, pattern = &amp;quot;r&amp;quot;, replacement = &amp;quot;s&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;pusss&amp;quot; &amp;quot;olsss&amp;quot; &amp;quot;bloss&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;regular-expressions&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Regular Expressions&lt;/h2&gt;
&lt;p&gt;So far we have been exploring R functions for pattern matching with a very
simple pattern i.e. a single character. From this section, we will start
exploring different scenarios and the corresponding regular expressions. This
section is further divided into 5 sub sections:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;anchors&lt;/li&gt;
&lt;li&gt;metacharacters&lt;/li&gt;
&lt;li&gt;quantifiers&lt;/li&gt;
&lt;li&gt;sequences&lt;/li&gt;
&lt;li&gt;and character classes&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;anchors&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Anchors&lt;/h2&gt;
&lt;p&gt;Anchors do not match any character. Instead, they match the pattern supplied to
a position before, after or between characters i.e. they are used to anchor the
regex or pattern at a certain position. Anchors are useful when we are searching
for a pattern at the beggining or end of a string.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_anchors.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;caret-symbol&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Caret Symbol (^)&lt;/h3&gt;
&lt;p&gt;The caret &lt;strong&gt;^&lt;/strong&gt; matches the position before the first character in the string.
In the below example, we want to know the R packages whose names begin with
the letter &lt;code&gt;r&lt;/code&gt;. To achieve this, we use &lt;code&gt;^&lt;/code&gt;, the caret symbol, which specifies
that the pattern must be present at the beginning of the string.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_anchor_start_canva.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = top_downloads, pattern = &amp;quot;^r&amp;quot;, value = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;rlang&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It has returned only one package, &lt;code&gt;rlang&lt;/code&gt; but if you look at the package names
even &lt;code&gt;Rcpp&lt;/code&gt; begins with &lt;code&gt;r&lt;/code&gt; but has been ignored. Let us ignore the case of the
pattern and see if the results change.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_anchor_start_ignore_case_canva.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = top_downloads, pattern = &amp;quot;^r&amp;quot;, value = TRUE, ignore.case = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;rlang&amp;quot; &amp;quot;Rcpp&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;dollar-symbol&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Dollar Symbol ($)&lt;/h3&gt;
&lt;p&gt;The dollar $ matches right after the last character in the string. Let us
now look at packages whose names end with the letter &lt;code&gt;r&lt;/code&gt;. To achieve this, we
use &lt;code&gt;$&lt;/code&gt;, the dollar symbol. As you can see in the below example, the &lt;code&gt;$&lt;/code&gt; is
specified at the end of the pattern we are looking for.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_anchor_end_canva.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;From our sample data set, we can see that there are 2 packages that end with
the letter &lt;code&gt;r&lt;/code&gt;, dplyr and pillar.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = top_downloads, pattern = &amp;quot;r$&amp;quot;, value = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;dplyr&amp;quot;  &amp;quot;pillar&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;meta-characters&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Meta Characters&lt;/h2&gt;
&lt;p&gt;Meta characters are a special set of characters not captured by regular
expressions i.e. if these special characters are present in a string, regular
expressions will not detect them. In order to be detected, they must be
prefixed by double backslash (\). The below table displays the metacharacters:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_meta_characters.png&#34; width=&#34;50%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Now that we know the meta characters, let us look at some examples. In the first
example, we want to detect package names separated by a dot.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = r_packages, pattern = &amp;quot;.&amp;quot;, value = TRUE)[1:60]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;A3&amp;quot;                 &amp;quot;abbyyR&amp;quot;             &amp;quot;abc&amp;quot;               
##  [4] &amp;quot;abc.data&amp;quot;           &amp;quot;ABC.RAP&amp;quot;            &amp;quot;ABCanalysis&amp;quot;       
##  [7] &amp;quot;abcdeFBA&amp;quot;           &amp;quot;ABCoptim&amp;quot;           &amp;quot;ABCp2&amp;quot;             
## [10] &amp;quot;abcrf&amp;quot;              &amp;quot;abctools&amp;quot;           &amp;quot;abd&amp;quot;               
## [13] &amp;quot;abe&amp;quot;                &amp;quot;abf2&amp;quot;               &amp;quot;ABHgenotypeR&amp;quot;      
## [16] &amp;quot;abind&amp;quot;              &amp;quot;abjutils&amp;quot;           &amp;quot;abn&amp;quot;               
## [19] &amp;quot;abnormality&amp;quot;        &amp;quot;abodOutlier&amp;quot;        &amp;quot;ABPS&amp;quot;              
## [22] &amp;quot;AbsFilterGSEA&amp;quot;      &amp;quot;AbSim&amp;quot;              &amp;quot;abstractr&amp;quot;         
## [25] &amp;quot;abtest&amp;quot;             &amp;quot;abundant&amp;quot;           &amp;quot;Ac3net&amp;quot;            
## [28] &amp;quot;ACA&amp;quot;                &amp;quot;acc&amp;quot;                &amp;quot;accelerometry&amp;quot;     
## [31] &amp;quot;accelmissing&amp;quot;       &amp;quot;AcceptanceSampling&amp;quot; &amp;quot;ACCLMA&amp;quot;            
## [34] &amp;quot;accrual&amp;quot;            &amp;quot;accrued&amp;quot;            &amp;quot;accSDA&amp;quot;            
## [37] &amp;quot;ACD&amp;quot;                &amp;quot;ACDm&amp;quot;               &amp;quot;acebayes&amp;quot;          
## [40] &amp;quot;acepack&amp;quot;            &amp;quot;ACEt&amp;quot;               &amp;quot;acid&amp;quot;              
## [43] &amp;quot;acm4r&amp;quot;              &amp;quot;ACMEeqtl&amp;quot;           &amp;quot;acmeR&amp;quot;             
## [46] &amp;quot;ACNE&amp;quot;               &amp;quot;acnr&amp;quot;               &amp;quot;acopula&amp;quot;           
## [49] &amp;quot;AcousticNDLCodeR&amp;quot;   &amp;quot;acp&amp;quot;                &amp;quot;aCRM&amp;quot;              
## [52] &amp;quot;AcrossTic&amp;quot;          &amp;quot;acrt&amp;quot;               &amp;quot;acs&amp;quot;               
## [55] &amp;quot;ACSNMineR&amp;quot;          &amp;quot;acss&amp;quot;               &amp;quot;acss.data&amp;quot;         
## [58] &amp;quot;ACSWR&amp;quot;              &amp;quot;ACTCD&amp;quot;              &amp;quot;Actigraphy&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you look at the output, it includes names of even those package names which
are not separated by dot. Why is this happening? A dot is special character in
regular expressions. It is also known as wildcard character i.e. it is used to
match any character other than &lt;code&gt;\n&lt;/code&gt; (new line). Now let us try to escape it
using the double backslash (&lt;code&gt;\\&lt;/code&gt;).&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = r_packages, pattern = &amp;quot;\\.&amp;quot;, value = TRUE)[1:50]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;abc.data&amp;quot;             &amp;quot;ABC.RAP&amp;quot;              &amp;quot;acss.data&amp;quot;           
##  [4] &amp;quot;aire.zmvm&amp;quot;            &amp;quot;AMAP.Seq&amp;quot;             &amp;quot;anim.plots&amp;quot;          
##  [7] &amp;quot;ANOVA.TFNs&amp;quot;           &amp;quot;ar.matrix&amp;quot;            &amp;quot;archivist.github&amp;quot;    
## [10] &amp;quot;aroma.affymetrix&amp;quot;     &amp;quot;aroma.apd&amp;quot;            &amp;quot;aroma.cn&amp;quot;            
## [13] &amp;quot;aroma.core&amp;quot;           &amp;quot;ASGS.foyer&amp;quot;           &amp;quot;assertive.base&amp;quot;      
## [16] &amp;quot;assertive.code&amp;quot;       &amp;quot;assertive.data&amp;quot;       &amp;quot;assertive.data.uk&amp;quot;   
## [19] &amp;quot;assertive.data.us&amp;quot;    &amp;quot;assertive.datetimes&amp;quot;  &amp;quot;assertive.files&amp;quot;     
## [22] &amp;quot;assertive.matrices&amp;quot;   &amp;quot;assertive.models&amp;quot;     &amp;quot;assertive.numbers&amp;quot;   
## [25] &amp;quot;assertive.properties&amp;quot; &amp;quot;assertive.reflection&amp;quot; &amp;quot;assertive.sets&amp;quot;      
## [28] &amp;quot;assertive.strings&amp;quot;    &amp;quot;assertive.types&amp;quot;      &amp;quot;auto.pca&amp;quot;            
## [31] &amp;quot;AWR.Athena&amp;quot;           &amp;quot;AWR.Kinesis&amp;quot;          &amp;quot;AWR.KMS&amp;quot;             
## [34] &amp;quot;aws.alexa&amp;quot;            &amp;quot;aws.cloudtrail&amp;quot;       &amp;quot;aws.comprehend&amp;quot;      
## [37] &amp;quot;aws.ec2metadata&amp;quot;      &amp;quot;aws.iam&amp;quot;              &amp;quot;aws.kms&amp;quot;             
## [40] &amp;quot;aws.lambda&amp;quot;           &amp;quot;aws.polly&amp;quot;            &amp;quot;aws.s3&amp;quot;              
## [43] &amp;quot;aws.ses&amp;quot;              &amp;quot;aws.signature&amp;quot;        &amp;quot;aws.sns&amp;quot;             
## [46] &amp;quot;aws.sqs&amp;quot;              &amp;quot;aws.transcribe&amp;quot;       &amp;quot;aws.translate&amp;quot;       
## [49] &amp;quot;bea.R&amp;quot;                &amp;quot;benford.analysis&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When we use &lt;code&gt;\\.&lt;/code&gt;, it matches the dot. Feel free to play around with other
special characters mentioned in the table but ensure that you use a different
data set.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;a href=&#34;https://apps.rsquaredacademy.com/&#34; target=&#34;_blank&#34;&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/ad_apps.png&#34; width=&#34;100%&#34; alt=&#34;apps ad&#34; style=&#34;text-decoration: none;&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;/div&gt;
&lt;div id=&#34;quantifiers&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Quantifiers&lt;/h2&gt;
&lt;p&gt;Quantifiers are very powerful and we need to be careful while using them. They
always act on items to the immediate left and are used to specify the number of
times a pattern must appear or be matched. The below table shows the different
quantifiers and their description:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_quantifiers.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;dot&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Dot&lt;/h4&gt;
&lt;p&gt;The &lt;code&gt;.&lt;/code&gt; (dot) is a wildcard character as it will match any character except a
new line (). Keep in mind that it will match only 1 character and if you want
to match more than 1 character, you need to specify as many dots. Let us look
at a few examples.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_quantifier_dot_canva.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# extract package names that include the string data 
data_pkgs &amp;lt;- grep(x = r_packages, pattern = &amp;quot;data&amp;quot;, value = TRUE)
head(data_pkgs)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;abc.data&amp;quot;       &amp;quot;acss.data&amp;quot;      &amp;quot;adeptdata&amp;quot;      &amp;quot;adklakedata&amp;quot;   
## [5] &amp;quot;archdata&amp;quot;       &amp;quot;assertive.data&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# package name includes the string data followed by any character and then the letter r
grep(x = data_pkgs, pattern = &amp;quot;data.r&amp;quot;, value = TRUE, ignore.case = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;datadr&amp;quot;          &amp;quot;dataframes2xls&amp;quot;  &amp;quot;dataPreparation&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# package name includes the string data followed by any 3 characters and then the letter r
grep(x = data_pkgs, pattern = &amp;quot;data...r&amp;quot;, value = TRUE, ignore.case = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;data.world&amp;quot;            &amp;quot;datadogr&amp;quot;              &amp;quot;dataRetrieval&amp;quot;        
## [4] &amp;quot;datasauRus&amp;quot;            &amp;quot;rdataretriever&amp;quot;        &amp;quot;WikidataQueryServiceR&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# package name includes the string data followed by any 3 characters and then the letter r
grep(x = r_packages, pattern = &amp;quot;data(.){3}r&amp;quot;, value = TRUE, ignore.case = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;data.world&amp;quot;            &amp;quot;datadogr&amp;quot;              &amp;quot;DataEntry&amp;quot;            
## [4] &amp;quot;dataRetrieval&amp;quot;         &amp;quot;datasauRus&amp;quot;            &amp;quot;rdataretriever&amp;quot;       
## [7] &amp;quot;RWDataPlyr&amp;quot;            &amp;quot;WikidataQueryServiceR&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# package name includes the string stat followed by any 2 characters and then the letter r
grep(x = r_packages, pattern = &amp;quot;stat..r&amp;quot;, value = TRUE, ignore.case = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;DistatisR&amp;quot;      &amp;quot;snpStatsWriter&amp;quot; &amp;quot;StatPerMeCo&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;optional-character&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Optional Character&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;?&lt;/code&gt;, the optional character is used when the item to its left is optional and
is matched at most once.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_optional.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In this first example, we are looking for package names that include the
following pattern:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;includes the letter &lt;code&gt;r&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;includes the string &lt;code&gt;data&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;there may be zero or one character between &lt;code&gt;r&lt;/code&gt; and &lt;code&gt;data&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_quantifier_question_mark.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = data_pkgs, pattern = &amp;quot;r(.)?data&amp;quot;, value = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;cluster.datasets&amp;quot; &amp;quot;ctrdata&amp;quot;          &amp;quot;dplyr.teradata&amp;quot;   &amp;quot;engsoccerdata&amp;quot;   
##  [5] &amp;quot;historydata&amp;quot;      &amp;quot;icpsrdata&amp;quot;        &amp;quot;mldr.datasets&amp;quot;    &amp;quot;prioritizrdata&amp;quot;  
##  [9] &amp;quot;qrmdata&amp;quot;          &amp;quot;rdatacite&amp;quot;        &amp;quot;rdataretriever&amp;quot;   &amp;quot;rqdatatable&amp;quot;     
## [13] &amp;quot;smartdata&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the below example, we are looking for package names that include the
following pattern:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;includes the letter &lt;code&gt;r&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;includes the string &lt;code&gt;data&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;there may be zero or one dot between &lt;code&gt;r&lt;/code&gt; and &lt;code&gt;data&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_quantifier_question_mark_2.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = data_pkgs, pattern = &amp;quot;r(\\.)?data&amp;quot;, value = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;cluster.datasets&amp;quot; &amp;quot;ctrdata&amp;quot;          &amp;quot;engsoccerdata&amp;quot;    &amp;quot;icpsrdata&amp;quot;       
## [5] &amp;quot;mldr.datasets&amp;quot;    &amp;quot;prioritizrdata&amp;quot;   &amp;quot;rdatacite&amp;quot;        &amp;quot;rdataretriever&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the next example, we are looking for package names that include the
following pattern:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;includes the letter &lt;code&gt;r&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;includes the string &lt;code&gt;data&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;there may be zero or one character between &lt;code&gt;r&lt;/code&gt; and &lt;code&gt;data&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;and the character must be any of the following:
&lt;ul&gt;
&lt;li&gt;m&lt;/li&gt;
&lt;li&gt;y&lt;/li&gt;
&lt;li&gt;q&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_quantifier_question_mark_3.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = data_pkgs, pattern = &amp;quot;r(m|y|q)?data&amp;quot;, value = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;ctrdata&amp;quot;        &amp;quot;engsoccerdata&amp;quot;  &amp;quot;historydata&amp;quot;    &amp;quot;icpsrdata&amp;quot;     
## [5] &amp;quot;prioritizrdata&amp;quot; &amp;quot;qrmdata&amp;quot;        &amp;quot;rdatacite&amp;quot;      &amp;quot;rdataretriever&amp;quot;
## [9] &amp;quot;rqdatatable&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the last example, we are looking for package names that include the
following pattern:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;includes the letter &lt;code&gt;r&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;includes the string &lt;code&gt;data&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;there may be zero or one character between &lt;code&gt;r&lt;/code&gt; and &lt;code&gt;data&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;and the character must be any of the following:
&lt;ul&gt;
&lt;li&gt;m&lt;/li&gt;
&lt;li&gt;y&lt;/li&gt;
&lt;li&gt;q&lt;/li&gt;
&lt;li&gt;dot&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_quantifier_question_mark_4.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = data_pkgs, pattern = &amp;quot;r(\\.|m|y|q)?data&amp;quot;, value = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;cluster.datasets&amp;quot; &amp;quot;ctrdata&amp;quot;          &amp;quot;engsoccerdata&amp;quot;    &amp;quot;historydata&amp;quot;     
##  [5] &amp;quot;icpsrdata&amp;quot;        &amp;quot;mldr.datasets&amp;quot;    &amp;quot;prioritizrdata&amp;quot;   &amp;quot;qrmdata&amp;quot;         
##  [9] &amp;quot;rdatacite&amp;quot;        &amp;quot;rdataretriever&amp;quot;   &amp;quot;rqdatatable&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;asterik-symbol&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Asterik Symbol&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;*&lt;/code&gt;, the asterik symbol is used when the item to its left will be matched zero
or more times.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_asterik.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In the below example, we are looking for package names that include the
following pattern:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;includes the letter &lt;code&gt;r&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;includes the string &lt;code&gt;data&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;there may be zero or more character(s) between &lt;code&gt;r&lt;/code&gt; and &lt;code&gt;data&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_quantifier_star.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = data_pkgs, pattern = &amp;quot;r(.)*data&amp;quot;, value = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;archdata&amp;quot;           &amp;quot;assertive.data&amp;quot;     &amp;quot;assertive.data.uk&amp;quot; 
##  [4] &amp;quot;assertive.data.us&amp;quot;  &amp;quot;cluster.datasets&amp;quot;   &amp;quot;crimedata&amp;quot;         
##  [7] &amp;quot;cropdatape&amp;quot;         &amp;quot;ctrdata&amp;quot;            &amp;quot;dplyr.teradata&amp;quot;    
## [10] &amp;quot;engsoccerdata&amp;quot;      &amp;quot;groupdata2&amp;quot;         &amp;quot;historydata&amp;quot;       
## [13] &amp;quot;icpsrdata&amp;quot;          &amp;quot;igraphdata&amp;quot;         &amp;quot;mldr.datasets&amp;quot;     
## [16] &amp;quot;nordklimdata1&amp;quot;      &amp;quot;prioritizrdata&amp;quot;     &amp;quot;qrmdata&amp;quot;           
## [19] &amp;quot;radiant.data&amp;quot;       &amp;quot;rangeModelMetadata&amp;quot; &amp;quot;rattle.data&amp;quot;       
## [22] &amp;quot;rbefdata&amp;quot;           &amp;quot;rdatacite&amp;quot;          &amp;quot;rdataretriever&amp;quot;    
## [25] &amp;quot;rehh.data&amp;quot;          &amp;quot;resampledata&amp;quot;       &amp;quot;rnaturalearthdata&amp;quot; 
## [28] &amp;quot;ropendata&amp;quot;          &amp;quot;rqdatatable&amp;quot;        &amp;quot;rtsdata&amp;quot;           
## [31] &amp;quot;smartdata&amp;quot;          &amp;quot;surveydata&amp;quot;         &amp;quot;survJamda.data&amp;quot;    
## [34] &amp;quot;traitdataform&amp;quot;      &amp;quot;vortexRdata&amp;quot;        &amp;quot;xmlparsedata&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;plus-symbol&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Plus Symbol&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;+&lt;/code&gt;, the plus symbol is used when the item to its left is matched one or more
times.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_plus.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In the below example, we are looking for package names that include the
following pattern:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;includes the string &lt;code&gt;plot&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;plot&lt;/code&gt; is preceded by one or more &lt;code&gt;g&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_quantifier_plus.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot_pkgs &amp;lt;- grep(x = r_packages, pattern = &amp;quot;plot&amp;quot;, value = TRUE)
grep(x = plot_pkgs, pattern = &amp;quot;(g)+plot&amp;quot;, value = TRUE, ignore.case = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;ggplot2&amp;quot;               &amp;quot;ggplot2movies&amp;quot;         &amp;quot;ggplotAssist&amp;quot;         
## [4] &amp;quot;ggplotgui&amp;quot;             &amp;quot;ggplotify&amp;quot;             &amp;quot;gplots&amp;quot;               
## [7] &amp;quot;RcmdrPlugin.KMggplot2&amp;quot; &amp;quot;regplot&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;brackets&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Brackets&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_brackets.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;n&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;{n}&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;{n}&lt;/code&gt; is used when the item to its left is matched exactly n times. In the
below example, we are looking for package names that include the following
pattern:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;includes the string &lt;code&gt;plot&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;plot&lt;/code&gt; is preceded by exactly one &lt;code&gt;g&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_quantifier_exact_n_match_canva.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = plot_pkgs, pattern = &amp;quot;(g){2}plot&amp;quot;, value = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;ggplot2&amp;quot;               &amp;quot;ggplot2movies&amp;quot;         &amp;quot;ggplotAssist&amp;quot;         
## [4] &amp;quot;ggplotgui&amp;quot;             &amp;quot;ggplotify&amp;quot;             &amp;quot;RcmdrPlugin.KMggplot2&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;n-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;{n,}&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;{n, }&lt;/code&gt; is used when the item to its left is matched n or more times. In the
below example, we are looking for package names that include the following
pattern:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;includes the string &lt;code&gt;plot&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;plot&lt;/code&gt; is preceded by one or more &lt;code&gt;g&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_quantifier_match_one_or_more_canva.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = plot_pkgs, pattern = &amp;quot;(g){1, }plot&amp;quot;, value = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;ggplot2&amp;quot;               &amp;quot;ggplot2movies&amp;quot;         &amp;quot;ggplotAssist&amp;quot;         
## [4] &amp;quot;ggplotgui&amp;quot;             &amp;quot;ggplotify&amp;quot;             &amp;quot;gplots&amp;quot;               
## [7] &amp;quot;RcmdrPlugin.KMggplot2&amp;quot; &amp;quot;regplot&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;nm&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;{n,m}&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;{n, m}&lt;/code&gt; is used when the item to its left is matched at least n times but not
more than m times. In the below example, we are looking for package names that
include the following pattern:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;includes the string &lt;code&gt;plot&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;plot&lt;/code&gt; is preceded by 1 or 3 &lt;code&gt;t&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_quantifier_match_between_canva.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = plot_pkgs, pattern = &amp;quot;(t){1,3}plot&amp;quot;, value = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;forestplot&amp;quot;   &amp;quot;limitplot&amp;quot;    &amp;quot;nhstplot&amp;quot;     &amp;quot;productplots&amp;quot; &amp;quot;tttplot&amp;quot;     
## [6] &amp;quot;txtplot&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;or&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;OR&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_or.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;|&lt;/code&gt; (OR) operator is useful when you want to match one amongst the given
options. For example, let us say we are looking for package names that begin
with &lt;code&gt;g&lt;/code&gt; and is followed by either another &lt;code&gt;g&lt;/code&gt; or &lt;code&gt;l&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_or_round_bracket_canva.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = top_downloads, pattern = &amp;quot;g(g|l)&amp;quot;, value = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;ggplot2&amp;quot; &amp;quot;glue&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The square brackets (&lt;code&gt;[]&lt;/code&gt;) can be used in place of &lt;code&gt;|&lt;/code&gt; as shown in the below
example where we are looking for package names that begin with the letter
&lt;code&gt;d&lt;/code&gt; and is followed by either &lt;code&gt;e&lt;/code&gt; or &lt;code&gt;p&lt;/code&gt; or &lt;code&gt;a&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_or_square_bracket_canva.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = top_downloads, pattern = &amp;quot;d[epa]&amp;quot;, value = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;devtools&amp;quot;   &amp;quot;dplyr&amp;quot;      &amp;quot;data.table&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;p&gt;&lt;a href=&#34;https://pkgs.rsquaredacademy.com/&#34; target=&#34;_blank&#34;&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/ad_packages.png&#34; width=&#34;100%&#34; alt=&#34;packages ad&#34; style=&#34;text-decoration: none;&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;/div&gt;
&lt;div id=&#34;sequences&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Sequences&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_sequences.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;digit-character&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Digit Character&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;\\d&lt;/code&gt; matches any digit character. Let us use it to find package names that
include a digit.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_match_digit.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = r_packages, pattern = &amp;quot;\\d&amp;quot;, value = TRUE)[1:50]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;A3&amp;quot;              &amp;quot;ABCp2&amp;quot;           &amp;quot;abf2&amp;quot;            &amp;quot;Ac3net&amp;quot;         
##  [5] &amp;quot;acm4r&amp;quot;           &amp;quot;ade4&amp;quot;            &amp;quot;ade4TkGUI&amp;quot;       &amp;quot;AdvDif4&amp;quot;        
##  [9] &amp;quot;ALA4R&amp;quot;           &amp;quot;alphashape3d&amp;quot;    &amp;quot;alr3&amp;quot;            &amp;quot;alr4&amp;quot;           
## [13] &amp;quot;ANN2&amp;quot;            &amp;quot;aods3&amp;quot;           &amp;quot;aplore3&amp;quot;         &amp;quot;APML0&amp;quot;          
## [17] &amp;quot;aprean3&amp;quot;         &amp;quot;AR1seg&amp;quot;          &amp;quot;arena2r&amp;quot;         &amp;quot;arf3DS4&amp;quot;        
## [21] &amp;quot;argon2&amp;quot;          &amp;quot;ARTP2&amp;quot;           &amp;quot;aster2&amp;quot;          &amp;quot;auth0&amp;quot;          
## [25] &amp;quot;aws.ec2metadata&amp;quot; &amp;quot;aws.s3&amp;quot;          &amp;quot;B2Z&amp;quot;             &amp;quot;b6e6rl&amp;quot;         
## [29] &amp;quot;base2grob&amp;quot;       &amp;quot;base64&amp;quot;          &amp;quot;base64enc&amp;quot;       &amp;quot;base64url&amp;quot;      
## [33] &amp;quot;BaTFLED3D&amp;quot;       &amp;quot;BayClone2&amp;quot;       &amp;quot;BayesS5&amp;quot;         &amp;quot;bc3net&amp;quot;         
## [37] &amp;quot;BCC1997&amp;quot;         &amp;quot;BDP2&amp;quot;            &amp;quot;BEQI2&amp;quot;           &amp;quot;BHH2&amp;quot;           
## [41] &amp;quot;bikeshare14&amp;quot;     &amp;quot;bio3d&amp;quot;           &amp;quot;biomod2&amp;quot;         &amp;quot;Bios2cor&amp;quot;       
## [45] &amp;quot;bios2mds&amp;quot;        &amp;quot;biostat3&amp;quot;        &amp;quot;bipartiteD3&amp;quot;     &amp;quot;bit64&amp;quot;          
## [49] &amp;quot;Bolstad2&amp;quot;        &amp;quot;BradleyTerry2&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# invert
grep(x = r_packages, pattern = &amp;quot;\\d&amp;quot;, value = TRUE, invert = TRUE)[1:50]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;abbyyR&amp;quot;             &amp;quot;abc&amp;quot;                &amp;quot;abc.data&amp;quot;          
##  [4] &amp;quot;ABC.RAP&amp;quot;            &amp;quot;ABCanalysis&amp;quot;        &amp;quot;abcdeFBA&amp;quot;          
##  [7] &amp;quot;ABCoptim&amp;quot;           &amp;quot;abcrf&amp;quot;              &amp;quot;abctools&amp;quot;          
## [10] &amp;quot;abd&amp;quot;                &amp;quot;abe&amp;quot;                &amp;quot;ABHgenotypeR&amp;quot;      
## [13] &amp;quot;abind&amp;quot;              &amp;quot;abjutils&amp;quot;           &amp;quot;abn&amp;quot;               
## [16] &amp;quot;abnormality&amp;quot;        &amp;quot;abodOutlier&amp;quot;        &amp;quot;ABPS&amp;quot;              
## [19] &amp;quot;AbsFilterGSEA&amp;quot;      &amp;quot;AbSim&amp;quot;              &amp;quot;abstractr&amp;quot;         
## [22] &amp;quot;abtest&amp;quot;             &amp;quot;abundant&amp;quot;           &amp;quot;ACA&amp;quot;               
## [25] &amp;quot;acc&amp;quot;                &amp;quot;accelerometry&amp;quot;      &amp;quot;accelmissing&amp;quot;      
## [28] &amp;quot;AcceptanceSampling&amp;quot; &amp;quot;ACCLMA&amp;quot;             &amp;quot;accrual&amp;quot;           
## [31] &amp;quot;accrued&amp;quot;            &amp;quot;accSDA&amp;quot;             &amp;quot;ACD&amp;quot;               
## [34] &amp;quot;ACDm&amp;quot;               &amp;quot;acebayes&amp;quot;           &amp;quot;acepack&amp;quot;           
## [37] &amp;quot;ACEt&amp;quot;               &amp;quot;acid&amp;quot;               &amp;quot;ACMEeqtl&amp;quot;          
## [40] &amp;quot;acmeR&amp;quot;              &amp;quot;ACNE&amp;quot;               &amp;quot;acnr&amp;quot;              
## [43] &amp;quot;acopula&amp;quot;            &amp;quot;AcousticNDLCodeR&amp;quot;   &amp;quot;acp&amp;quot;               
## [46] &amp;quot;aCRM&amp;quot;               &amp;quot;AcrossTic&amp;quot;          &amp;quot;acrt&amp;quot;              
## [49] &amp;quot;acs&amp;quot;                &amp;quot;ACSNMineR&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the next few examples, we will not use R package names data, instead we will
use dummy data of Invoice IDs and see if they conform to certain rules such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;they should include letters and numbers&lt;/li&gt;
&lt;li&gt;they should not include symbols&lt;/li&gt;
&lt;li&gt;they should not include space or tab&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;non-digit-character&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Non Digit Character&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;\\D&lt;/code&gt; matches any non-digit character. Let us use it to remove invoice ids that
include only numbers and no letters.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_match_non_digit.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As you can see below, thre are 3 invoice ids that did not conform to the rules
and have been removed. Only those invoice ids that have both letter and numbers
have been returned.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;invoice_id &amp;lt;- c(&amp;quot;R536365&amp;quot;, &amp;quot;R536472&amp;quot;, &amp;quot;R536671&amp;quot;, &amp;quot;536915&amp;quot;, &amp;quot;R536125&amp;quot;, &amp;quot;R536287&amp;quot;,
                &amp;quot;536741&amp;quot;, &amp;quot;R536893&amp;quot;, &amp;quot;R536521&amp;quot;, &amp;quot;536999&amp;quot;)
grep(x = invoice_id, pattern = &amp;quot;\\D&amp;quot;, value = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;R536365&amp;quot; &amp;quot;R536472&amp;quot; &amp;quot;R536671&amp;quot; &amp;quot;R536125&amp;quot; &amp;quot;R536287&amp;quot; &amp;quot;R536893&amp;quot; &amp;quot;R536521&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# invert
grep(x = invoice_id, pattern = &amp;quot;\\D&amp;quot;, value = TRUE, invert = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;536915&amp;quot; &amp;quot;536741&amp;quot; &amp;quot;536999&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;white-space-character&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;White Space Character&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;\\s&lt;/code&gt; matches any white space character such as space or tab. Let us use it to
detect invoice ids that include any white space (space or tab).&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_match_space.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As you can see below, there are 4 invoice ids that include white space
character.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = c(&amp;quot;R536365&amp;quot;, &amp;quot;R 536472&amp;quot;, &amp;quot;R536671&amp;quot;, &amp;quot;R536915&amp;quot;, &amp;quot;R53 6125&amp;quot;, &amp;quot;R536287&amp;quot;,
           &amp;quot;536741&amp;quot;, &amp;quot;R5368  93&amp;quot;, &amp;quot;R536521&amp;quot;, &amp;quot;536 999&amp;quot;), 
     pattern = &amp;quot;\\s&amp;quot;, value = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;R 536472&amp;quot;  &amp;quot;R53 6125&amp;quot;  &amp;quot;R5368  93&amp;quot; &amp;quot;536 999&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = c(&amp;quot;R536365&amp;quot;, &amp;quot;R 536472&amp;quot;, &amp;quot;R536671&amp;quot;, &amp;quot;R536915&amp;quot;, &amp;quot;R53 6125&amp;quot;, &amp;quot;R536287&amp;quot;,
           &amp;quot;536741&amp;quot;, &amp;quot;R5368  93&amp;quot;, &amp;quot;R536521&amp;quot;, &amp;quot;536 999&amp;quot;), 
     pattern = &amp;quot;\\s&amp;quot;, value = TRUE, invert = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;R536365&amp;quot; &amp;quot;R536671&amp;quot; &amp;quot;R536915&amp;quot; &amp;quot;R536287&amp;quot; &amp;quot;536741&amp;quot;  &amp;quot;R536521&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;non-white-space-character&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Non White Space Character&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;\\S&lt;/code&gt; matches any non white space character. Let us use it to remove any
invoice ids which are blank or missing.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_match_non_space.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As you can see below, two invoice ids which were blank have been removed. If you
observe carefully, it does not remove any invoice ids which have a white space
character present, it only removes those which are completely blank i.e. those
which include only space or tab.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = c(&amp;quot;R536365&amp;quot;, &amp;quot;R 536472&amp;quot;, &amp;quot; &amp;quot;, &amp;quot;R536915&amp;quot;, &amp;quot;R53 6125&amp;quot;, &amp;quot;R536287&amp;quot;,
           &amp;quot; &amp;quot;, &amp;quot;R5368  93&amp;quot;, &amp;quot;R536521&amp;quot;, &amp;quot;536 999&amp;quot;), 
     pattern = &amp;quot;\\S&amp;quot;, value = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;R536365&amp;quot;   &amp;quot;R 536472&amp;quot;  &amp;quot;R536915&amp;quot;   &amp;quot;R53 6125&amp;quot;  &amp;quot;R536287&amp;quot;   &amp;quot;R5368  93&amp;quot;
## [7] &amp;quot;R536521&amp;quot;   &amp;quot;536 999&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# invert
grep(x = c(&amp;quot;R536365&amp;quot;, &amp;quot;R 536472&amp;quot;, &amp;quot; &amp;quot;, &amp;quot;R536915&amp;quot;, &amp;quot;R53 6125&amp;quot;, &amp;quot;R536287&amp;quot;,
           &amp;quot; &amp;quot;, &amp;quot;R5368  93&amp;quot;, &amp;quot;R536521&amp;quot;, &amp;quot;536 999&amp;quot;), 
     pattern = &amp;quot;\\S&amp;quot;, value = TRUE, invert = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot; &amp;quot; &amp;quot; &amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;word-character&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Word Character&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;\\w&lt;/code&gt; matches any word character i.e. alphanumeric. It includes the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a to z&lt;/li&gt;
&lt;li&gt;A to Z&lt;/li&gt;
&lt;li&gt;0 to 9&lt;/li&gt;
&lt;li&gt;underscore(_)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_match_word.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Let us use it to remove those invoice ids which include only symbols or special
characters. Again, you can see that it does not remove those ids which include
both word characters and symbols as it will match any string that includes
word characters.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = c(&amp;quot;R536365&amp;quot;, &amp;quot;%+$!#@?&amp;quot;, &amp;quot;R536671&amp;quot;, &amp;quot;R536915&amp;quot;, &amp;quot;$%+#!@?&amp;quot;, &amp;quot;R5362@87&amp;quot;,
           &amp;quot;53+67$41&amp;quot;, &amp;quot;R536893&amp;quot;, &amp;quot;@$+%#!&amp;quot;, &amp;quot;536#999&amp;quot;), 
     pattern = &amp;quot;\\w&amp;quot;, value = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;R536365&amp;quot;  &amp;quot;R536671&amp;quot;  &amp;quot;R536915&amp;quot;  &amp;quot;R5362@87&amp;quot; &amp;quot;53+67$41&amp;quot; &amp;quot;R536893&amp;quot;  &amp;quot;536#999&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# invert
grep(x = c(&amp;quot;R536365&amp;quot;, &amp;quot;%+$!#@?&amp;quot;, &amp;quot;R536671&amp;quot;, &amp;quot;R536915&amp;quot;, &amp;quot;$%+#!@?&amp;quot;, &amp;quot;R5362@87&amp;quot;,
           &amp;quot;53+67$41&amp;quot;, &amp;quot;R536893&amp;quot;, &amp;quot;@$+%#!&amp;quot;, &amp;quot;536#999&amp;quot;), 
     pattern = &amp;quot;\\w&amp;quot;, value = TRUE, invert = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;%+$!#@?&amp;quot; &amp;quot;$%+#!@?&amp;quot; &amp;quot;@$+%#!&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;non-word-character&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Non Word Character&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;\\W&lt;/code&gt; matches any non-word character i.e. symbols. It includes everything that
is not a word character.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_match_non_word.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Let us use it to detect invoice ids that include any non-word character. As you
can see only 4 ids do not include non-word characters.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = c(&amp;quot;R536365&amp;quot;, &amp;quot;%+$!#@?&amp;quot;, &amp;quot;R536671&amp;quot;, &amp;quot;R536915&amp;quot;, &amp;quot;$%+#!@?&amp;quot;, &amp;quot;R5362@87&amp;quot;,
           &amp;quot;53+67$41&amp;quot;, &amp;quot;R536893&amp;quot;, &amp;quot;@$+%#!&amp;quot;, &amp;quot;536#999&amp;quot;), 
     pattern = &amp;quot;\\W&amp;quot;, value = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;%+$!#@?&amp;quot;  &amp;quot;$%+#!@?&amp;quot;  &amp;quot;R5362@87&amp;quot; &amp;quot;53+67$41&amp;quot; &amp;quot;@$+%#!&amp;quot;   &amp;quot;536#999&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# invert
grep(x = c(&amp;quot;R536365&amp;quot;, &amp;quot;%+$!#@?&amp;quot;, &amp;quot;R536671&amp;quot;, &amp;quot;R536915&amp;quot;, &amp;quot;$%+#!@?&amp;quot;, &amp;quot;R5362@87&amp;quot;,
           &amp;quot;53+67$41&amp;quot;, &amp;quot;R536893&amp;quot;, &amp;quot;@$+%#!&amp;quot;, &amp;quot;536#999&amp;quot;), 
     pattern = &amp;quot;\\W&amp;quot;, value = TRUE, invert = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;R536365&amp;quot; &amp;quot;R536671&amp;quot; &amp;quot;R536915&amp;quot; &amp;quot;R536893&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;word-boundary&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Word Boundary&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;\\b&lt;/code&gt; and &lt;code&gt;\\B&lt;/code&gt; are similar to caret and dollar symbol. They match at a position
called word boundary. Now, what is a word boundary? The following 3 positions
qualify as word boundaries:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;before the first character in the string&lt;/li&gt;
&lt;li&gt;after the last character in the string&lt;/li&gt;
&lt;li&gt;between two characters in the string&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the first 2 cases, the character must be a word character whereas in the
last case, one should be a word character and another non-word character. Sounds
confusing? It will be clear once we go through a few examples.&lt;/p&gt;
&lt;p&gt;Let us say we are looking for package names beginning with the string &lt;code&gt;stat&lt;/code&gt;.
In this case, we can prefix &lt;code&gt;stat&lt;/code&gt; with &lt;code&gt;\\b&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_word_boundary_1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = r_packages, pattern = &amp;quot;\\bstat&amp;quot;, value = TRUE) &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;haplo.stats&amp;quot;    &amp;quot;statar&amp;quot;         &amp;quot;statcheck&amp;quot;      &amp;quot;statebins&amp;quot;     
##  [5] &amp;quot;states&amp;quot;         &amp;quot;statGraph&amp;quot;      &amp;quot;stationery&amp;quot;     &amp;quot;statip&amp;quot;        
##  [9] &amp;quot;statmod&amp;quot;        &amp;quot;statnet&amp;quot;        &amp;quot;statnet.common&amp;quot; &amp;quot;statnetWeb&amp;quot;    
## [13] &amp;quot;statprograms&amp;quot;   &amp;quot;statquotes&amp;quot;     &amp;quot;stats19&amp;quot;        &amp;quot;statsDK&amp;quot;       
## [17] &amp;quot;statsr&amp;quot;         &amp;quot;statVisual&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Suffix &lt;code&gt;\\b&lt;/code&gt; to &lt;code&gt;stat&lt;/code&gt; to look at all package names that end with the string
&lt;code&gt;stat&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_word_boundary_2.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;If you observe the output, you can find package names that do not end with
the string &lt;code&gt;stat&lt;/code&gt;. &lt;code&gt;spatstat.data&lt;/code&gt;, &lt;code&gt;spatstat.local&lt;/code&gt; and &lt;code&gt;spatstat.utils&lt;/code&gt; do not
end with &lt;code&gt;stat&lt;/code&gt; but satisfy the third condition mentioned aboved for word
boundaries. They are between 2 characters where &lt;code&gt;t&lt;/code&gt; is a word character and dot
is a non-word character.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = r_packages, pattern = &amp;quot;stat\\b&amp;quot;, value = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;Blendstat&amp;quot;          &amp;quot;costat&amp;quot;             &amp;quot;dstat&amp;quot;             
##  [4] &amp;quot;eurostat&amp;quot;           &amp;quot;gstat&amp;quot;              &amp;quot;hierfstat&amp;quot;         
##  [7] &amp;quot;jsonstat&amp;quot;           &amp;quot;lawstat&amp;quot;            &amp;quot;lestat&amp;quot;            
## [10] &amp;quot;lfstat&amp;quot;             &amp;quot;LS2Wstat&amp;quot;           &amp;quot;maxstat&amp;quot;           
## [13] &amp;quot;mdsstat&amp;quot;            &amp;quot;mistat&amp;quot;             &amp;quot;poolfstat&amp;quot;         
## [16] &amp;quot;Pstat&amp;quot;              &amp;quot;RcmdrPlugin.lfstat&amp;quot; &amp;quot;rfacebookstat&amp;quot;     
## [19] &amp;quot;Rilostat&amp;quot;           &amp;quot;rjstat&amp;quot;             &amp;quot;RMTstat&amp;quot;           
## [22] &amp;quot;sgeostat&amp;quot;           &amp;quot;spatstat&amp;quot;           &amp;quot;spatstat.data&amp;quot;     
## [25] &amp;quot;spatstat.local&amp;quot;     &amp;quot;spatstat.utils&amp;quot;     &amp;quot;volleystat&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Do package names include the string &lt;code&gt;stat&lt;/code&gt; either at the end or in the middle
but not at the beginning? Prefix &lt;code&gt;stat&lt;/code&gt; with &lt;code&gt;\\B&lt;/code&gt; to find the answer.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_word_boundary_3.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = r_packages, pattern = &amp;quot;\\Bstat&amp;quot;, value = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;bigstatsr&amp;quot;          &amp;quot;biostat3&amp;quot;           &amp;quot;Blendstat&amp;quot;         
##  [4] &amp;quot;compstatr&amp;quot;          &amp;quot;costat&amp;quot;             &amp;quot;cumstats&amp;quot;          
##  [7] &amp;quot;curstatCI&amp;quot;          &amp;quot;CytobankAPIstats&amp;quot;   &amp;quot;dbstats&amp;quot;           
## [10] &amp;quot;descstatsr&amp;quot;         &amp;quot;DistatisR&amp;quot;          &amp;quot;dlstats&amp;quot;           
## [13] &amp;quot;dostats&amp;quot;            &amp;quot;dstat&amp;quot;              &amp;quot;estatapi&amp;quot;          
## [16] &amp;quot;eurostat&amp;quot;           &amp;quot;freestats&amp;quot;          &amp;quot;geostatsp&amp;quot;         
## [19] &amp;quot;gestate&amp;quot;            &amp;quot;getmstatistic&amp;quot;      &amp;quot;ggstatsplot&amp;quot;       
## [22] &amp;quot;groupedstats&amp;quot;       &amp;quot;gstat&amp;quot;              &amp;quot;hierfstat&amp;quot;         
## [25] &amp;quot;hydrostats&amp;quot;         &amp;quot;jsonstat&amp;quot;           &amp;quot;labstatR&amp;quot;          
## [28] &amp;quot;labstats&amp;quot;           &amp;quot;lawstat&amp;quot;            &amp;quot;learnstats&amp;quot;        
## [31] &amp;quot;lestat&amp;quot;             &amp;quot;lfstat&amp;quot;             &amp;quot;LS2Wstat&amp;quot;          
## [34] &amp;quot;maxstat&amp;quot;            &amp;quot;mdsstat&amp;quot;            &amp;quot;mistat&amp;quot;            
## [37] &amp;quot;mlbstats&amp;quot;           &amp;quot;mstate&amp;quot;             &amp;quot;multistate&amp;quot;        
## [40] &amp;quot;multistateutils&amp;quot;    &amp;quot;ohtadstats&amp;quot;         &amp;quot;orderstats&amp;quot;        
## [43] &amp;quot;p3state.msm&amp;quot;        &amp;quot;poolfstat&amp;quot;          &amp;quot;PRISMAstatement&amp;quot;   
## [46] &amp;quot;Pstat&amp;quot;              &amp;quot;raustats&amp;quot;           &amp;quot;RcmdrPlugin.lfstat&amp;quot;
## [49] &amp;quot;readstata13&amp;quot;        &amp;quot;realestateDK&amp;quot;       &amp;quot;restatapi&amp;quot;         
## [52] &amp;quot;rfacebookstat&amp;quot;      &amp;quot;Rilostat&amp;quot;           &amp;quot;rjstat&amp;quot;            
## [55] &amp;quot;RMTstat&amp;quot;            &amp;quot;rstatscn&amp;quot;           &amp;quot;runstats&amp;quot;          
## [58] &amp;quot;scanstatistics&amp;quot;     &amp;quot;sgeostat&amp;quot;           &amp;quot;sjstats&amp;quot;           
## [61] &amp;quot;spatstat&amp;quot;           &amp;quot;spatstat.data&amp;quot;      &amp;quot;spatstat.local&amp;quot;    
## [64] &amp;quot;spatstat.utils&amp;quot;     &amp;quot;TDAstats&amp;quot;           &amp;quot;tidystats&amp;quot;         
## [67] &amp;quot;tigerstats&amp;quot;         &amp;quot;tradestatistics&amp;quot;    &amp;quot;unsystation&amp;quot;       
## [70] &amp;quot;USGSstates2k&amp;quot;       &amp;quot;volleystat&amp;quot;         &amp;quot;wbstats&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Are there packages whose names include the string &lt;code&gt;stat&lt;/code&gt; either at the
beginning or in the middle but not at the end. Suffix &lt;code&gt;\\B&lt;/code&gt; to &lt;code&gt;stat&lt;/code&gt; to
answer this question.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_word_boundary_4.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = r_packages, pattern = &amp;quot;stat\\B&amp;quot;, value = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;bigstatsr&amp;quot;        &amp;quot;biostat3&amp;quot;         &amp;quot;compstatr&amp;quot;        &amp;quot;cumstats&amp;quot;        
##  [5] &amp;quot;curstatCI&amp;quot;        &amp;quot;CytobankAPIstats&amp;quot; &amp;quot;dbstats&amp;quot;          &amp;quot;descstatsr&amp;quot;      
##  [9] &amp;quot;DistatisR&amp;quot;        &amp;quot;dlstats&amp;quot;          &amp;quot;dostats&amp;quot;          &amp;quot;estatapi&amp;quot;        
## [13] &amp;quot;freestats&amp;quot;        &amp;quot;geostatsp&amp;quot;        &amp;quot;gestate&amp;quot;          &amp;quot;getmstatistic&amp;quot;   
## [17] &amp;quot;ggstatsplot&amp;quot;      &amp;quot;groupedstats&amp;quot;     &amp;quot;haplo.stats&amp;quot;      &amp;quot;hydrostats&amp;quot;      
## [21] &amp;quot;labstatR&amp;quot;         &amp;quot;labstats&amp;quot;         &amp;quot;learnstats&amp;quot;       &amp;quot;mlbstats&amp;quot;        
## [25] &amp;quot;mstate&amp;quot;           &amp;quot;multistate&amp;quot;       &amp;quot;multistateutils&amp;quot;  &amp;quot;ohtadstats&amp;quot;      
## [29] &amp;quot;orderstats&amp;quot;       &amp;quot;p3state.msm&amp;quot;      &amp;quot;PRISMAstatement&amp;quot;  &amp;quot;raustats&amp;quot;        
## [33] &amp;quot;readstata13&amp;quot;      &amp;quot;realestateDK&amp;quot;     &amp;quot;restatapi&amp;quot;        &amp;quot;rstatscn&amp;quot;        
## [37] &amp;quot;runstats&amp;quot;         &amp;quot;scanstatistics&amp;quot;   &amp;quot;sjstats&amp;quot;          &amp;quot;statar&amp;quot;          
## [41] &amp;quot;statcheck&amp;quot;        &amp;quot;statebins&amp;quot;        &amp;quot;states&amp;quot;           &amp;quot;statGraph&amp;quot;       
## [45] &amp;quot;stationery&amp;quot;       &amp;quot;statip&amp;quot;           &amp;quot;statmod&amp;quot;          &amp;quot;statnet&amp;quot;         
## [49] &amp;quot;statnet.common&amp;quot;   &amp;quot;statnetWeb&amp;quot;       &amp;quot;statprograms&amp;quot;     &amp;quot;statquotes&amp;quot;      
## [53] &amp;quot;stats19&amp;quot;          &amp;quot;statsDK&amp;quot;          &amp;quot;statsr&amp;quot;           &amp;quot;statVisual&amp;quot;      
## [57] &amp;quot;TDAstats&amp;quot;         &amp;quot;tidystats&amp;quot;        &amp;quot;tigerstats&amp;quot;       &amp;quot;tradestatistics&amp;quot; 
## [61] &amp;quot;unsystation&amp;quot;      &amp;quot;USGSstates2k&amp;quot;     &amp;quot;wbstats&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Prefix and suffix &lt;code&gt;\\B&lt;/code&gt; to &lt;code&gt;stat&lt;/code&gt; to look at package names that include the
string &lt;code&gt;stat&lt;/code&gt; but neither in the beginning nor in the end.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_word_boundary_5.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In the below output, you can observe that the string &lt;code&gt;stat&lt;/code&gt; must be between
two word characters. Those examples we showed in the case of &lt;code&gt;\\b&lt;/code&gt; where it
was surrounded by a dot do not hold here.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grep(x = r_packages, pattern = &amp;quot;\\Bstat\\B&amp;quot;, value = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;bigstatsr&amp;quot;        &amp;quot;biostat3&amp;quot;         &amp;quot;compstatr&amp;quot;        &amp;quot;cumstats&amp;quot;        
##  [5] &amp;quot;curstatCI&amp;quot;        &amp;quot;CytobankAPIstats&amp;quot; &amp;quot;dbstats&amp;quot;          &amp;quot;descstatsr&amp;quot;      
##  [9] &amp;quot;DistatisR&amp;quot;        &amp;quot;dlstats&amp;quot;          &amp;quot;dostats&amp;quot;          &amp;quot;estatapi&amp;quot;        
## [13] &amp;quot;freestats&amp;quot;        &amp;quot;geostatsp&amp;quot;        &amp;quot;gestate&amp;quot;          &amp;quot;getmstatistic&amp;quot;   
## [17] &amp;quot;ggstatsplot&amp;quot;      &amp;quot;groupedstats&amp;quot;     &amp;quot;hydrostats&amp;quot;       &amp;quot;labstatR&amp;quot;        
## [21] &amp;quot;labstats&amp;quot;         &amp;quot;learnstats&amp;quot;       &amp;quot;mlbstats&amp;quot;         &amp;quot;mstate&amp;quot;          
## [25] &amp;quot;multistate&amp;quot;       &amp;quot;multistateutils&amp;quot;  &amp;quot;ohtadstats&amp;quot;       &amp;quot;orderstats&amp;quot;      
## [29] &amp;quot;p3state.msm&amp;quot;      &amp;quot;PRISMAstatement&amp;quot;  &amp;quot;raustats&amp;quot;         &amp;quot;readstata13&amp;quot;     
## [33] &amp;quot;realestateDK&amp;quot;     &amp;quot;restatapi&amp;quot;        &amp;quot;rstatscn&amp;quot;         &amp;quot;runstats&amp;quot;        
## [37] &amp;quot;scanstatistics&amp;quot;   &amp;quot;sjstats&amp;quot;          &amp;quot;TDAstats&amp;quot;         &amp;quot;tidystats&amp;quot;       
## [41] &amp;quot;tigerstats&amp;quot;       &amp;quot;tradestatistics&amp;quot;  &amp;quot;unsystation&amp;quot;      &amp;quot;USGSstates2k&amp;quot;    
## [45] &amp;quot;wbstats&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;character-classes&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Character Classes&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_character_classes.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;A set of characters enclosed in a square bracket (&lt;code&gt;[]&lt;/code&gt;). The regular expression
will match only those characters enclosed in the brackets and it matches only a
single character. The order of the characters inside the brackets do not matter
and a hyphen can be used to specify a range of charcters. For example, [0-9]
will match a single digit between 0 and 9. Similarly, [a-z] will match a single
letter between a to z. You can specify more than one range as well. [a-z0-9A-Z]
will match a alphanumeric character while ignoring the case. A caret &lt;strong&gt;^&lt;/strong&gt; after
the opening bracket negates the character class. For example, [^0-9] will match
a single character that is not a digit.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_character_class_numbers.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;
Let us go through a few examples to understand character classes in more detail.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# package names that include vowels
grep(x = top_downloads, pattern = &amp;quot;[aeiou]&amp;quot;, value = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;devtools&amp;quot;   &amp;quot;rlang&amp;quot;      &amp;quot;tibble&amp;quot;     &amp;quot;ggplot2&amp;quot;    &amp;quot;glue&amp;quot;      
## [6] &amp;quot;pillar&amp;quot;     &amp;quot;cli&amp;quot;        &amp;quot;data.table&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# package names that include a number
grep(x = r_packages, pattern = &amp;quot;[0-9]&amp;quot;, value = TRUE)[1:50]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;A3&amp;quot;              &amp;quot;ABCp2&amp;quot;           &amp;quot;abf2&amp;quot;            &amp;quot;Ac3net&amp;quot;         
##  [5] &amp;quot;acm4r&amp;quot;           &amp;quot;ade4&amp;quot;            &amp;quot;ade4TkGUI&amp;quot;       &amp;quot;AdvDif4&amp;quot;        
##  [9] &amp;quot;ALA4R&amp;quot;           &amp;quot;alphashape3d&amp;quot;    &amp;quot;alr3&amp;quot;            &amp;quot;alr4&amp;quot;           
## [13] &amp;quot;ANN2&amp;quot;            &amp;quot;aods3&amp;quot;           &amp;quot;aplore3&amp;quot;         &amp;quot;APML0&amp;quot;          
## [17] &amp;quot;aprean3&amp;quot;         &amp;quot;AR1seg&amp;quot;          &amp;quot;arena2r&amp;quot;         &amp;quot;arf3DS4&amp;quot;        
## [21] &amp;quot;argon2&amp;quot;          &amp;quot;ARTP2&amp;quot;           &amp;quot;aster2&amp;quot;          &amp;quot;auth0&amp;quot;          
## [25] &amp;quot;aws.ec2metadata&amp;quot; &amp;quot;aws.s3&amp;quot;          &amp;quot;B2Z&amp;quot;             &amp;quot;b6e6rl&amp;quot;         
## [29] &amp;quot;base2grob&amp;quot;       &amp;quot;base64&amp;quot;          &amp;quot;base64enc&amp;quot;       &amp;quot;base64url&amp;quot;      
## [33] &amp;quot;BaTFLED3D&amp;quot;       &amp;quot;BayClone2&amp;quot;       &amp;quot;BayesS5&amp;quot;         &amp;quot;bc3net&amp;quot;         
## [37] &amp;quot;BCC1997&amp;quot;         &amp;quot;BDP2&amp;quot;            &amp;quot;BEQI2&amp;quot;           &amp;quot;BHH2&amp;quot;           
## [41] &amp;quot;bikeshare14&amp;quot;     &amp;quot;bio3d&amp;quot;           &amp;quot;biomod2&amp;quot;         &amp;quot;Bios2cor&amp;quot;       
## [45] &amp;quot;bios2mds&amp;quot;        &amp;quot;biostat3&amp;quot;        &amp;quot;bipartiteD3&amp;quot;     &amp;quot;bit64&amp;quot;          
## [49] &amp;quot;Bolstad2&amp;quot;        &amp;quot;BradleyTerry2&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# package names that begin with a number
grep(x = r_packages, pattern = &amp;quot;^[0-9]&amp;quot;, value = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## character(0)&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# package names that end with a number
grep(x = r_packages, pattern = &amp;quot;[0-9]$&amp;quot;, value = TRUE)[1:50]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;A3&amp;quot;                &amp;quot;ABCp2&amp;quot;             &amp;quot;abf2&amp;quot;             
##  [4] &amp;quot;ade4&amp;quot;              &amp;quot;AdvDif4&amp;quot;           &amp;quot;alr3&amp;quot;             
##  [7] &amp;quot;alr4&amp;quot;              &amp;quot;ANN2&amp;quot;              &amp;quot;aods3&amp;quot;            
## [10] &amp;quot;aplore3&amp;quot;           &amp;quot;APML0&amp;quot;             &amp;quot;aprean3&amp;quot;          
## [13] &amp;quot;arf3DS4&amp;quot;           &amp;quot;argon2&amp;quot;            &amp;quot;ARTP2&amp;quot;            
## [16] &amp;quot;aster2&amp;quot;            &amp;quot;auth0&amp;quot;             &amp;quot;aws.s3&amp;quot;           
## [19] &amp;quot;base64&amp;quot;            &amp;quot;BayClone2&amp;quot;         &amp;quot;BayesS5&amp;quot;          
## [22] &amp;quot;BCC1997&amp;quot;           &amp;quot;BDP2&amp;quot;              &amp;quot;BEQI2&amp;quot;            
## [25] &amp;quot;BHH2&amp;quot;              &amp;quot;bikeshare14&amp;quot;       &amp;quot;biomod2&amp;quot;          
## [28] &amp;quot;biostat3&amp;quot;          &amp;quot;bipartiteD3&amp;quot;       &amp;quot;bit64&amp;quot;            
## [31] &amp;quot;Bolstad2&amp;quot;          &amp;quot;BradleyTerry2&amp;quot;     &amp;quot;brglm2&amp;quot;           
## [34] &amp;quot;bridger2&amp;quot;          &amp;quot;c060&amp;quot;              &amp;quot;c212&amp;quot;             
## [37] &amp;quot;c3&amp;quot;                &amp;quot;C443&amp;quot;              &amp;quot;C50&amp;quot;              
## [40] &amp;quot;cAIC4&amp;quot;             &amp;quot;CARE1&amp;quot;             &amp;quot;CB2&amp;quot;              
## [43] &amp;quot;cec2013&amp;quot;           &amp;quot;Census2016&amp;quot;        &amp;quot;Chaos01&amp;quot;          
## [46] &amp;quot;choroplethrAdmin1&amp;quot; &amp;quot;cld2&amp;quot;              &amp;quot;cld3&amp;quot;             
## [49] &amp;quot;clogitL1&amp;quot;          &amp;quot;CLONETv2&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# package names with only upper case letters
grep(x = r_packages, pattern = &amp;quot;^[A-Z][A-Z]{1, }[A-Z]$&amp;quot;, value = TRUE)[1:50]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;ABPS&amp;quot;    &amp;quot;ACA&amp;quot;     &amp;quot;ACCLMA&amp;quot;  &amp;quot;ACD&amp;quot;     &amp;quot;ACNE&amp;quot;    &amp;quot;ACSWR&amp;quot;   &amp;quot;ACTCD&amp;quot;  
##  [8] &amp;quot;ADCT&amp;quot;    &amp;quot;ADDT&amp;quot;    &amp;quot;ADMM&amp;quot;    &amp;quot;ADPF&amp;quot;    &amp;quot;AER&amp;quot;     &amp;quot;AFM&amp;quot;     &amp;quot;AGD&amp;quot;    
## [15] &amp;quot;AHR&amp;quot;     &amp;quot;AID&amp;quot;     &amp;quot;AIG&amp;quot;     &amp;quot;AIM&amp;quot;     &amp;quot;ALS&amp;quot;     &amp;quot;ALSCPC&amp;quot;  &amp;quot;ALSM&amp;quot;   
## [22] &amp;quot;AMCP&amp;quot;    &amp;quot;AMGET&amp;quot;   &amp;quot;AMIAS&amp;quot;   &amp;quot;AMOEBA&amp;quot;  &amp;quot;AMORE&amp;quot;   &amp;quot;AMR&amp;quot;     &amp;quot;ANOM&amp;quot;   
## [29] &amp;quot;APSIM&amp;quot;   &amp;quot;ARHT&amp;quot;    &amp;quot;AROC&amp;quot;    &amp;quot;ART&amp;quot;     &amp;quot;ARTIVA&amp;quot;  &amp;quot;ARTP&amp;quot;    &amp;quot;ASIP&amp;quot;   
## [36] &amp;quot;ASSA&amp;quot;    &amp;quot;AST&amp;quot;     &amp;quot;ATE&amp;quot;     &amp;quot;ATR&amp;quot;     &amp;quot;AUC&amp;quot;     &amp;quot;AUCRF&amp;quot;   &amp;quot;AWR&amp;quot;    
## [43] &amp;quot;BACA&amp;quot;    &amp;quot;BACCO&amp;quot;   &amp;quot;BACCT&amp;quot;   &amp;quot;BALCONY&amp;quot; &amp;quot;BALD&amp;quot;    &amp;quot;BALLI&amp;quot;   &amp;quot;BAMBI&amp;quot;  
## [50] &amp;quot;BANOVA&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;case-studies&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Case Studies&lt;/h2&gt;
&lt;p&gt;Now that we have understood the basics of regular expressions, it is time for
some practical application. The case studies in this section include validating
the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;blood group&lt;/li&gt;
&lt;li&gt;email id&lt;/li&gt;
&lt;li&gt;PAN number&lt;/li&gt;
&lt;li&gt;GST number&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note, the regular expressions used here are not robust as compared to those
used in real world applications. Our aim is to demonstrate a general strategy
to used while dealing with regular expressions.&lt;/p&gt;
&lt;div id=&#34;blood-group&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Blood Group&lt;/h3&gt;
&lt;p&gt;According to Wikipedia, a blood group or type is a classification of blood based
on the presence and absence of antibodies and inherited antigenic substances on
the surface of red blood cells (RBCs).&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_cs_blood_groups.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The below table defines the matching pattern for blood group and maps them to
regular expressions.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;it must begin with &lt;code&gt;A&lt;/code&gt;, &lt;code&gt;B&lt;/code&gt;, &lt;code&gt;AB&lt;/code&gt; or &lt;code&gt;O&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;it must end with &lt;code&gt;+&lt;/code&gt; or &lt;code&gt;-&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_cs_bg_table.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Let us test the regular expression with some examples.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;blood_pattern &amp;lt;- &amp;quot;^(A|B|AB|O)[-|+]$&amp;quot;
blood_sample &amp;lt;- c(&amp;quot;A+&amp;quot;, &amp;quot;C-&amp;quot;, &amp;quot;AB+&amp;quot;)
grep(x = blood_sample, pattern = blood_pattern, value = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;A+&amp;quot;  &amp;quot;AB+&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;email-id&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;email id&lt;/h3&gt;
&lt;p&gt;Nowadays email is ubiquitous. We use it for everything from communication to
registration for online services. Wherever you go, you will be asked for email
id. You might even be denied a few services if you do not use email. At the same
time, it is important to validate a email address. You might have seen a message
similar to the below one when you misspell or enter a wrong email id. Regular
expressions are used to validate email address and in this case study we will
attempt to do the same.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_cs_email.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;First, we will create some basic rules for simple email validation:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;it must begin with a letter&lt;/li&gt;
&lt;li&gt;the id may include letters, numbers and special characters&lt;/li&gt;
&lt;li&gt;must include only one @ and dot&lt;/li&gt;
&lt;li&gt;the id must be to the left of @&lt;/li&gt;
&lt;li&gt;the domain name should be between @ and dot&lt;/li&gt;
&lt;li&gt;the domain extension should be after dot and must include only letters&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the below table, we map the above rules to general expression.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_cs_email_table.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Let us now test the regular expression with some dummy email ids.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;email_pattern &amp;lt;- &amp;quot;^[a-zA-Z0-9\\!#$%&amp;amp;&amp;#39;*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+\\.[a-z]&amp;quot;
emails &amp;lt;- c(&amp;quot;test9+_A@test.com&amp;quot;, &amp;quot;test@test..com&amp;quot;, &amp;quot;test-test.com&amp;quot;)
grep(x = emails, pattern = email_pattern, value = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;test9+_A@test.com&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;pan-number-validation&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;PAN Number Validation&lt;/h3&gt;
&lt;p&gt;PAN (Permanent Account Number) is an identification number assigned to all
taxpayers in India. PAN is an electronic system through which, all tax related
information for a person/company is recorded against a single PAN number.&lt;/p&gt;
&lt;div id=&#34;structure&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Structure&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;must include only 10 characters&lt;/li&gt;
&lt;li&gt;the first 5 characters are letters&lt;/li&gt;
&lt;li&gt;the next 4 characters are numerals&lt;/li&gt;
&lt;li&gt;the last character is a letter&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_cs_pan_1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the first 3 characters are a sequence from AAA to ZZZ&lt;/li&gt;
&lt;li&gt;the 4th character indicates the status of the tax payer and shold be one of
A, B, C, F, G, H, L, J, P, T or E&lt;/li&gt;
&lt;li&gt;the 5th character is the first character of the last/surname of the card holder&lt;/li&gt;
&lt;li&gt;the 6th to 10th character is a sequnce from 0001 to 9999&lt;/li&gt;
&lt;li&gt;the last character is a letter&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_cs_pan_2.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In the below table, we map the pattern to regular expression.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_cs_pan_table.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Let us test the regular expression with some dummy PAN numbers.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;pan_pattern &amp;lt;- &amp;quot;^[A-Z]{3}(A|B|C|F|G|H|L|J|P|T|E)[A-Z][0-9]{4}[A-Z]&amp;quot;
my_pan &amp;lt;- c(&amp;quot;AJKNT3865H&amp;quot;, &amp;quot;AJKNT38655&amp;quot;, &amp;quot;A2KNT3865H&amp;quot;, &amp;quot;AJKDT3865H&amp;quot;)
grep(x = my_pan, pattern = pan_pattern, value = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## character(0)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;gst-number-validation&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;GST Number Validation&lt;/h3&gt;
&lt;p&gt;In simple words, Goods and Service Tax (GST) is an indirect tax levied on the
supply of goods and services. This law has replaced many indirect tax laws that
previously existed in India. GST identification number is assigned to every
GST registed dealer.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_cs_gst.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;structure-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Structure&lt;/h4&gt;
&lt;p&gt;Below is the format break down of GST identification number:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;it must include 15 characters only&lt;/li&gt;
&lt;li&gt;the first 2 characters represent the state code and is a sequence from 01 to 35&lt;/li&gt;
&lt;li&gt;the next 10 characters are the PAN number of the entity&lt;/li&gt;
&lt;li&gt;the 13th character is the entity code and is between 1 and 9&lt;/li&gt;
&lt;li&gt;the 14th character is a default alphabet, &lt;strong&gt;Z&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;the 15th character is a random single number or alphabet&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the below table, we map the pattern to regular expression.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/regex_cs_gst_table.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Let us test the regular expression with some dummy GST numbers.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;gst_pattern &amp;lt;- &amp;quot;[0-3][1-5][A-Z]{3}(A|B|C|F|G|H|L|J|P|T|E)[A-Z][0-9]{4}[A-Z][1-9]Z[0-9A-Z]&amp;quot;
sample_gst &amp;lt;- c(&amp;quot;22AAAAA0000A1Z5&amp;quot;, &amp;quot;22AAAAA0000A1Z&amp;quot;, &amp;quot;42AAAAA0000A1Z5&amp;quot;,
                &amp;quot;38AAAAA0000A1Z5&amp;quot;, &amp;quot;22AAAAA0000A0Z5&amp;quot;, &amp;quot;22AAAAA0000A1X5&amp;quot;,
                &amp;quot;22AAAAA0000A1Z$&amp;quot;)
grep(x = sample_gst, pattern = gst_pattern, value = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;22AAAAA0000A1Z5&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;rstudio-addin&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;RStudio Addin&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;https://www.garrickadenbuie.com/&#34; target=&#34;_blank&#34;&gt;Garrick Aden-Buie&lt;/a&gt;
has created a wonderful RStudio addin, &lt;a href=&#34;https://www.garrickadenbuie.com/project/regexplain/&#34; target=&#34;_blank&#34;&gt;RegExplain&lt;/a&gt;
and you will find it very useful while learning and building regular expressions.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;other-applications&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Other Applications&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;R variable names&lt;/li&gt;
&lt;li&gt;R file names and extensions&lt;/li&gt;
&lt;li&gt;password validation&lt;/li&gt;
&lt;li&gt;camelcase&lt;/li&gt;
&lt;li&gt;currency format&lt;/li&gt;
&lt;li&gt;date of birth&lt;/li&gt;
&lt;li&gt;date validation&lt;/li&gt;
&lt;li&gt;decimal number&lt;/li&gt;
&lt;li&gt;full name / first name&lt;/li&gt;
&lt;li&gt;html tags&lt;/li&gt;
&lt;li&gt;https url&lt;/li&gt;
&lt;li&gt;phone number&lt;/li&gt;
&lt;li&gt;ip address&lt;/li&gt;
&lt;li&gt;month name&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;what-we-have-not-covered&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;What we have not covered?&lt;/h2&gt;
&lt;p&gt;While we have covered a lot, the below topics have been left out:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;flags&lt;/li&gt;
&lt;li&gt;grouping and capturing&lt;/li&gt;
&lt;li&gt;back references&lt;/li&gt;
&lt;li&gt;look ahead and look behind&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You may want to explore them to up your regular expressions game.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Summary&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;a regular expression is a special text for identifying a pattern&lt;/li&gt;
&lt;li&gt;it can be used to search, replace, validate and extract strings matching a
given pattern&lt;/li&gt;
&lt;li&gt;use cases include email and password validation, search and replace in text
editors, html tags validation, web scraping etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;references&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://www.rstudio.com/wp-content/uploads/2016/09/RegExCheatsheet.pdf&#34; class=&#34;uri&#34;&gt;https://www.rstudio.com/wp-content/uploads/2016/09/RegExCheatsheet.pdf&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stringr.tidyverse.org/articles/regular-expressions.html&#34; class=&#34;uri&#34;&gt;https://stringr.tidyverse.org/articles/regular-expressions.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://r4ds.had.co.nz/strings.html&#34; class=&#34;uri&#34;&gt;https://r4ds.had.co.nz/strings.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/rstudio/cheatsheets/blob/master/strings.pdf&#34; class=&#34;uri&#34;&gt;https://github.com/rstudio/cheatsheets/blob/master/strings.pdf&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.garrickadenbuie.com/project/regexplain/&#34; class=&#34;uri&#34;&gt;https://www.garrickadenbuie.com/project/regexplain/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you see mistakes or want to suggest changes, please create an issue on the
&lt;a href=&#34;https://github.com/rsquaredacademy-infra/blog&#34; target=&#34;_blank&#34;&gt;source repository&lt;/a&gt;
or reach out to us at &lt;a href=&#34;mailto:feedback@rsquaredacademy.com&#34; class=&#34;email&#34;&gt;feedback@rsquaredacademy.com&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Practical Introduction to Market Basket Analysis - Asociation Rules</title>
      <link>https://blog.rsquaredacademy.com/market-basket-analysis-in-r/</link>
      <pubDate>Thu, 02 May 2019 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/market-basket-analysis-in-r/</guid>
      <description>&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/cover_image.jpg&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/mba_intro.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Ever wondered why items are displayed in a particular way in retail/online
stores. Why certain items are suggested to you based on what you have added to
the cart? Blame it on market basket analysis or association rule mining.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;resources&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Resources&lt;/h2&gt;
&lt;p&gt;Below are the links to all the resources related to this post:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://slides.rsquaredacademy.com/mba/mba.html&#34; target=&#34;_blank&#34;&gt;Slides&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/rsquaredacademy-education/online-courses/tree/master/association-rule-mining-in-r&#34; target=&#34;_blank&#34;&gt;Code &amp;amp; Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://rstudio.cloud/project/335377&#34; target=&#34;_blank&#34;&gt;RStudio Cloud&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;what&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;What?&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/mba_what.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Market basket analysis uses association rule mining under the hood to identify
products frequently bought together. Before we get into the nitty gritty of
market basket analysis, let us get a basic understanding of association rule
mining. It finds association between different objects in a set. In the case
of market basket analysis, the objects are the products purchased by a cusomter
and the set is the transaction. In short, market basket analysis&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;is a unsupervised data mining technique&lt;/li&gt;
&lt;li&gt;that uncovers products frequently bought together&lt;/li&gt;
&lt;li&gt;and creates if-then scenario rules&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;why&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Why ?&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/mba_why.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Market basket analysis creates actionable insights for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;designing store layout&lt;/li&gt;
&lt;li&gt;online recommendation engines&lt;/li&gt;
&lt;li&gt;targeted marketing campaign/sales promotion/email campaign&lt;/li&gt;
&lt;li&gt;cross/up selling&lt;/li&gt;
&lt;li&gt;catalogue design&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;advantages&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Advantages&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/mba_advantages.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Market basket analysisis is &lt;strong&gt;cost effective&lt;/strong&gt; as data required is readily
available through electronic point of sale systems. It generates
&lt;strong&gt;actionable insights&lt;/strong&gt; for product placement, cross/up selling strategies,
targeted marketing campaigns, catalogue design, pricing strategies,
inventory control etc.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;use-cases&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Use Cases&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/mba_use_cases.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Association rule mining has applications in several industries including
retail, telecommunications, banking, insurance, manufacturing and medical.
Let us look at its applications in more detail in the following industries:&lt;/p&gt;
&lt;div id=&#34;retail&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Retail&lt;/h3&gt;
&lt;p&gt;The introduction of electronic point of sale systems have allowed the
collection of immense amounts of data and retail organizations make prolifc
use of market basket analysis for&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;designing store layout so that consumers can more easily find items that are
frequently purchased together&lt;/li&gt;
&lt;li&gt;recommending associated products that are frequently bought together,
&lt;strong&gt;“Customers who purchased this product also viewed this product…”&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;emailing customers who bought products specific products with other products
and offers on those products that are likely to be interesting to them.&lt;/li&gt;
&lt;li&gt;grouping products that customers purchase frequently together in the store’s
product placement&lt;/li&gt;
&lt;li&gt;designing special promotions that combine or discount certain products&lt;/li&gt;
&lt;li&gt;optimizing the layout of the catalog of an eCommerce site&lt;/li&gt;
&lt;li&gt;controlling inventory based on product demands and what products sell better
together&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;banks&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Banks&lt;/h3&gt;
&lt;p&gt;Banks and financial institutions use market basket analysis to analyze credit
card purchases for fraud detection and cross sell insurance products,
investment products (mutual funds etc.), tax preparation, retirement planning,
wealth management etc. It can also be used for next best offer, sequence and
seasonal offers.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;telecommunications&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Telecommunications&lt;/h3&gt;
&lt;p&gt;The telecommunications industry is characterized by high volatility and low
customer loyalty due to lucrative offers for new customers from other service
providers. The more services a customer uses from a particular operator, the
harder it gets for him/her to switch to another operator. Market basket
analysis is used to bundle mobile, landline, TV and internet services to
customers to increase stickiness and reduce churn.&lt;/p&gt;
&lt;hr&gt;
&lt;a href=&#34;https://www.rsquaredacademy.com/&#34; target=&#34;_blank&#34;&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/ad.png&#34; width=&#34;100%&#34; alt=&#34;course ad&#34; style=&#34;text-decoration: none;&#34;&gt;&lt;/a&gt;
&lt;hr&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;simple-example&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Simple Example&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/mba_items_description.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Before we move on to the case study, let us use a simple example to understand
the important terminologies that we will come across in the rest of the
tutorial. In the example, the transactions include the following products:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;mobile phones&lt;/li&gt;
&lt;li&gt;ear phones&lt;/li&gt;
&lt;li&gt;USB cable&lt;/li&gt;
&lt;li&gt;power bank&lt;/li&gt;
&lt;li&gt;screen guard&lt;/li&gt;
&lt;li&gt;mobile case cover&lt;/li&gt;
&lt;li&gt;modem/router&lt;/li&gt;
&lt;li&gt;mouse&lt;/li&gt;
&lt;li&gt;external hard drive&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;steps&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Steps&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/mba_steps.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The two important steps in market basket analysis are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;frequent itemset generation&lt;/li&gt;
&lt;li&gt;rules generation&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We will discuss these steps in more detail in the case study.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;itemset&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Itemset&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/mba_itemset.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Itemset is the collection of items purchased by a customer. In our example,
mobile phone and screen guard are a frequent intemset. They are present in
3 out of 5 transactions.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;antecedent-consequent&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Antecedent &amp;amp; Consequent&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/mba_antecedent_consequent.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Antecedent is the items of the left hand side of the rule and consequent is
the right hand side of the rule. In our example, mobile phone is the antecedent
and screen guard is the consequent.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;support&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Support&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/mba_support.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Support is the probability of the antecedent event occuring. It is the relative
frequency of the itemset. If it is less than 50% then the association is
considered less fruitful. In our example, support is the relative frequency of
transactions that include both mobile phone and screen guard.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;confidence&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Confidence&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/mba_confidence.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Confidence is the probability the consequent will co-occur with the antecedent.
It expresses the operational efficiency of the rule. In our example, it is the
probability that a customer will purchase screen guard provided that he has
already bought the mobile phone.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;lift&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Lift&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/mba_lift.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The lift ratio calculates the efficiency of the rule in finding consequences,
compared to a random selection of transactions. Generally, a Lift ratio of
greater than one suggests some applicability of the rule.To compute the lift
for a rule, divide the support of the itemset by the product of the support
for antecedent and consequent. Now, let us understand how to interpret lift.&lt;/p&gt;
&lt;div id=&#34;interpretation&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Interpretation&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Lift = 1&lt;/strong&gt;: implies no relationship between mobile phone and screen guard
(i.e., mobile phone and screen guard occur together only by chance)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Lift &amp;gt; 1&lt;/strong&gt;: implies that there is a positive relationship between mobile
phone and screen guard (i.e., mobile phone and screen guard occur together
more often than random)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Lift &amp;lt; 1&lt;/strong&gt;: implies that there is a negative relationship between mobile
phone and screen guard (i.e., mobile phone and screen guard occur together
less often than random)&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;p&gt;
&lt;a href=&#34;https://www.youtube.com/user/rsquaredin/&#34; target=&#34;_blank&#34;&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/ad_youtube.png&#34; width=&#34;100%&#34; alt=&#34;youtube ad&#34; style=&#34;text-decoration: none;&#34;&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;hr&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data&lt;/h2&gt;
&lt;p&gt;Two public data sets are available for users to explore and learn market basket
analysis:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://archive.ics.uci.edu/ml/datasets/online+retail#&#34; target=&#34;_blank&#34;&gt;UCI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://data.world/datasets/market-basket-analysis&#34; target=&#34;_blank&#34;&gt;data.world&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The groceries data set is available in the &lt;strong&gt;arules&lt;/strong&gt; package as well. In this
tutorial, we will use the UCI data set as it closely resembles real world data
sets giving us a chance to reshape the data and restructure it in format
required by the &lt;strong&gt;arules&lt;/strong&gt; package.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data-dictionary&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data Dictionary&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;invoice number&lt;/li&gt;
&lt;li&gt;stock code&lt;/li&gt;
&lt;li&gt;description&lt;/li&gt;
&lt;li&gt;quantity&lt;/li&gt;
&lt;li&gt;invoice date&lt;/li&gt;
&lt;li&gt;unit price&lt;/li&gt;
&lt;li&gt;customer id&lt;/li&gt;
&lt;li&gt;country&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Libraries&lt;/h2&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(readxl)
library(readr)
library(arules)
library(arulesViz)
library(magrittr)
library(dplyr)
library(lubridate)
library(forcats)
library(ggplot2)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;preprocessing&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Preprocessing&lt;/h2&gt;
&lt;p&gt;This section is optional. You can skip to the &lt;strong&gt;Read Data&lt;/strong&gt; section without
any loss of continuity.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/mba_pre_process.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As shown above, the data set has one row per item. We have created a tiny R
package &lt;a href=&#34;https://github.com/rsquaredacademy/mbar&#34; target=&#34;_blank&#34;&gt;mbar&lt;/a&gt;,&lt;br /&gt;
for data pre-processing. It can be installed from GitHub as shown below:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# install.packages(&amp;quot;devtools&amp;quot;)
devtools::install_github(&amp;quot;rsquaredacademy/mbar&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We will use &lt;code&gt;mbar_prep_data()&lt;/code&gt; from the mbar package to reshape the data so
that there is one row per transaction with items across columns excluding
the column names.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(mbar)
mba_data     &amp;lt;- read_excel(&amp;quot;online-retail.xlsx&amp;quot;)
transactions &amp;lt;- mbar_prep_data(mba_data, InvoiceNo, Description)
head(transactions)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 6 x 1,114
##   item_1 item_2 item_3 item_4 item_5 item_6 item_7 item_8 item_9 item_10 item_11
##   &amp;lt;chr&amp;gt;  &amp;lt;chr&amp;gt;  &amp;lt;chr&amp;gt;  &amp;lt;chr&amp;gt;  &amp;lt;chr&amp;gt;  &amp;lt;chr&amp;gt;  &amp;lt;chr&amp;gt;  &amp;lt;chr&amp;gt;  &amp;lt;chr&amp;gt;  &amp;lt;chr&amp;gt;   &amp;lt;chr&amp;gt;  
## 1 WHITE~ &amp;quot;WHIT~ &amp;quot;CREA~ &amp;quot;KNIT~ &amp;quot;RED ~ &amp;quot;SET ~ &amp;quot;GLAS~ &amp;quot;&amp;quot;     &amp;quot;&amp;quot;     &amp;quot;&amp;quot;      &amp;quot;&amp;quot;     
## 2 HAND ~ &amp;quot;HAND~ &amp;quot;&amp;quot;     &amp;quot;&amp;quot;     &amp;quot;&amp;quot;     &amp;quot;&amp;quot;     &amp;quot;&amp;quot;     &amp;quot;&amp;quot;     &amp;quot;&amp;quot;     &amp;quot;&amp;quot;      &amp;quot;&amp;quot;     
## 3 ASSOR~ &amp;quot;POPP~ &amp;quot;POPP~ &amp;quot;FELT~ &amp;quot;IVOR~ &amp;quot;BOX ~ &amp;quot;BOX ~ &amp;quot;BOX ~ &amp;quot;HOME~ &amp;quot;LOVE ~ &amp;quot;RECIP~
## 4 JAM M~ &amp;quot;RED ~ &amp;quot;YELL~ &amp;quot;BLUE~ &amp;quot;&amp;quot;     &amp;quot;&amp;quot;     &amp;quot;&amp;quot;     &amp;quot;&amp;quot;     &amp;quot;&amp;quot;     &amp;quot;&amp;quot;      &amp;quot;&amp;quot;     
## 5 BATH ~ &amp;quot;&amp;quot;     &amp;quot;&amp;quot;     &amp;quot;&amp;quot;     &amp;quot;&amp;quot;     &amp;quot;&amp;quot;     &amp;quot;&amp;quot;     &amp;quot;&amp;quot;     &amp;quot;&amp;quot;     &amp;quot;&amp;quot;      &amp;quot;&amp;quot;     
## 6 ALARM~ &amp;quot;ALAR~ &amp;quot;ALAR~ &amp;quot;PAND~ &amp;quot;STAR~ &amp;quot;INFL~ &amp;quot;VINT~ &amp;quot;SET/~ &amp;quot;ROUN~ &amp;quot;SPACE~ &amp;quot;LUNCH~
## # ... with 1,103 more variables: item_12 &amp;lt;chr&amp;gt;, item_13 &amp;lt;chr&amp;gt;, item_14 &amp;lt;chr&amp;gt;,
## #   item_15 &amp;lt;chr&amp;gt;, item_16 &amp;lt;chr&amp;gt;, item_17 &amp;lt;chr&amp;gt;, item_18 &amp;lt;chr&amp;gt;, item_19 &amp;lt;chr&amp;gt;,
## #   item_20 &amp;lt;chr&amp;gt;, item_21 &amp;lt;chr&amp;gt;, item_22 &amp;lt;chr&amp;gt;, item_23 &amp;lt;chr&amp;gt;, item_24 &amp;lt;chr&amp;gt;,
## #   item_25 &amp;lt;chr&amp;gt;, item_26 &amp;lt;chr&amp;gt;, item_27 &amp;lt;chr&amp;gt;, item_28 &amp;lt;chr&amp;gt;, item_29 &amp;lt;chr&amp;gt;,
## #   item_30 &amp;lt;chr&amp;gt;, item_31 &amp;lt;chr&amp;gt;, item_32 &amp;lt;chr&amp;gt;, item_33 &amp;lt;chr&amp;gt;, item_34 &amp;lt;chr&amp;gt;,
## #   item_35 &amp;lt;chr&amp;gt;, item_36 &amp;lt;chr&amp;gt;, item_37 &amp;lt;chr&amp;gt;, item_38 &amp;lt;chr&amp;gt;, item_39 &amp;lt;chr&amp;gt;,
## #   item_40 &amp;lt;chr&amp;gt;, item_41 &amp;lt;chr&amp;gt;, item_42 &amp;lt;chr&amp;gt;, item_43 &amp;lt;chr&amp;gt;, item_44 &amp;lt;chr&amp;gt;,
## #   item_45 &amp;lt;chr&amp;gt;, item_46 &amp;lt;chr&amp;gt;, item_47 &amp;lt;chr&amp;gt;, item_48 &amp;lt;chr&amp;gt;, item_49 &amp;lt;chr&amp;gt;,
## #   item_50 &amp;lt;chr&amp;gt;, item_51 &amp;lt;chr&amp;gt;, item_52 &amp;lt;chr&amp;gt;, item_53 &amp;lt;chr&amp;gt;, item_54 &amp;lt;chr&amp;gt;,
## #   item_55 &amp;lt;chr&amp;gt;, item_56 &amp;lt;chr&amp;gt;, item_57 &amp;lt;chr&amp;gt;, item_58 &amp;lt;chr&amp;gt;, item_59 &amp;lt;chr&amp;gt;,
## #   item_60 &amp;lt;chr&amp;gt;, item_61 &amp;lt;chr&amp;gt;, item_62 &amp;lt;chr&amp;gt;, item_63 &amp;lt;chr&amp;gt;, item_64 &amp;lt;chr&amp;gt;,
## #   item_65 &amp;lt;chr&amp;gt;, item_66 &amp;lt;chr&amp;gt;, item_67 &amp;lt;chr&amp;gt;, item_68 &amp;lt;chr&amp;gt;, item_69 &amp;lt;chr&amp;gt;,
## #   item_70 &amp;lt;chr&amp;gt;, item_71 &amp;lt;chr&amp;gt;, item_72 &amp;lt;chr&amp;gt;, item_73 &amp;lt;chr&amp;gt;, item_74 &amp;lt;chr&amp;gt;,
## #   item_75 &amp;lt;chr&amp;gt;, item_76 &amp;lt;chr&amp;gt;, item_77 &amp;lt;chr&amp;gt;, item_78 &amp;lt;chr&amp;gt;, item_79 &amp;lt;chr&amp;gt;,
## #   item_80 &amp;lt;chr&amp;gt;, item_81 &amp;lt;chr&amp;gt;, item_82 &amp;lt;chr&amp;gt;, item_83 &amp;lt;chr&amp;gt;, item_84 &amp;lt;chr&amp;gt;,
## #   item_85 &amp;lt;chr&amp;gt;, item_86 &amp;lt;chr&amp;gt;, item_87 &amp;lt;chr&amp;gt;, item_88 &amp;lt;chr&amp;gt;, item_89 &amp;lt;chr&amp;gt;,
## #   item_90 &amp;lt;chr&amp;gt;, item_91 &amp;lt;chr&amp;gt;, item_92 &amp;lt;chr&amp;gt;, item_93 &amp;lt;chr&amp;gt;, item_94 &amp;lt;chr&amp;gt;,
## #   item_95 &amp;lt;chr&amp;gt;, item_96 &amp;lt;chr&amp;gt;, item_97 &amp;lt;chr&amp;gt;, item_98 &amp;lt;chr&amp;gt;, item_99 &amp;lt;chr&amp;gt;,
## #   item_100 &amp;lt;chr&amp;gt;, item_101 &amp;lt;chr&amp;gt;, item_102 &amp;lt;chr&amp;gt;, item_103 &amp;lt;chr&amp;gt;,
## #   item_104 &amp;lt;chr&amp;gt;, item_105 &amp;lt;chr&amp;gt;, item_106 &amp;lt;chr&amp;gt;, item_107 &amp;lt;chr&amp;gt;,
## #   item_108 &amp;lt;chr&amp;gt;, item_109 &amp;lt;chr&amp;gt;, item_110 &amp;lt;chr&amp;gt;, item_111 &amp;lt;chr&amp;gt;, ...&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;eda&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;EDA&lt;/h2&gt;
&lt;p&gt;Before we generate the rules using the &lt;strong&gt;arules&lt;/strong&gt; package, let us explore
the data set a bit.&lt;/p&gt;
&lt;div id=&#34;what-time-of-day-do-people-purchase&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;What time of day do people purchase?&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;purchase_time &amp;lt;-
  mba_data %&amp;gt;%
  group_by(InvoiceDate) %&amp;gt;%
  slice(1) %&amp;gt;%
  mutate(time_of_day = hour(InvoiceDate)) %&amp;gt;%
  pull(time_of_day) %&amp;gt;%
  as.factor() %&amp;gt;%
  fct_count()

purchase_time %&amp;gt;%
  ggplot() +
  geom_col(aes(x = f, y = n), fill = &amp;quot;blue&amp;quot;) +
  xlab(&amp;quot;Hour of Day&amp;quot;) + ylab(&amp;quot;Transactions&amp;quot;) +
  ggtitle(&amp;quot;Hourly Transaction Distribution&amp;quot;)  &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-05-02-mba_files/figure-html/eda_1-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;how-many-items-are-purchased-on-an-average&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;How many items are purchased on an average?&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;items &amp;lt;- 
  mba_data %&amp;gt;%
  group_by(InvoiceNo) %&amp;gt;%
  summarize(count = n()) %&amp;gt;%
  pull(count) &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## `summarise()` ungrouping (override with `.groups` argument)&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mean(items)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 20.92313&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;median(items)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 10&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;most-purchased-items&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Most Purchased Items&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mba_data %&amp;gt;%
  group_by(Description) %&amp;gt;%
  summarize(count = n()) %&amp;gt;%
  arrange(desc(count))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## `summarise()` ungrouping (override with `.groups` argument)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 4,212 x 2
##    Description                        count
##    &amp;lt;chr&amp;gt;                              &amp;lt;int&amp;gt;
##  1 WHITE HANGING HEART T-LIGHT HOLDER  2369
##  2 REGENCY CAKESTAND 3 TIER            2200
##  3 JUMBO BAG RED RETROSPOT             2159
##  4 PARTY BUNTING                       1727
##  5 LUNCH BAG RED RETROSPOT             1638
##  6 ASSORTED COLOUR BIRD ORNAMENT       1501
##  7 SET OF 3 CAKE TINS PANTRY DESIGN    1473
##  8 &amp;lt;NA&amp;gt;                                1454
##  9 PACK OF 72 RETROSPOT CAKE CASES     1385
## 10 LUNCH BAG  BLACK SKULL.             1350
## # ... with 4,202 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;average-order-value&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Average Order Value&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;total_revenue &amp;lt;- 
  mba_data %&amp;gt;%
  group_by(InvoiceNo) %&amp;gt;%
  summarize(order_sum = sum(UnitPrice)) %&amp;gt;%
  pull(order_sum) %&amp;gt;%
  sum()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## `summarise()` ungrouping (override with `.groups` argument)&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;total_transactions &amp;lt;- 
  mba_data %&amp;gt;%
  group_by(InvoiceNo) %&amp;gt;%
  summarize(n()) %&amp;gt;%
  nrow()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## `summarise()` ungrouping (override with `.groups` argument)&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;total_revenue / total_transactions&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 96.47892&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;read-data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Read Data&lt;/h2&gt;
&lt;p&gt;It is now time to read data into R. We will use &lt;code&gt;read.transactions()&lt;/code&gt;
from &lt;strong&gt;arules&lt;/strong&gt; package. The data cannot be read using &lt;code&gt;read.csv()&lt;/code&gt; or
&lt;code&gt;read_csv()&lt;/code&gt; owing to the way it is structured. We will read the
&lt;code&gt;transaction_data.csv&lt;/code&gt; file as it contains the data we had modified
in the previous step. We need to specify the following in order to
read the data set:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;name of the data set within quotes (single or double)&lt;/li&gt;
&lt;li&gt;the format of the data, if each line represnts a transaction, use &lt;code&gt;basket&lt;/code&gt;,
and if each line represents an item in the transaction, use &lt;code&gt;single&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;the separator used to separate the items in a transaction&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In our data set, each line represents a transaction and the items in the
transaction are separated by a &lt;code&gt;,&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;basket_data &amp;lt;- read.transactions(&amp;quot;transaction_data.csv&amp;quot;, format = &amp;quot;basket&amp;quot;, 
  sep = &amp;quot;,&amp;quot;)
basket_data&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## transactions in sparse format with
##  25901 transactions (rows) and
##  10085 items (columns)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;read.transactions()&lt;/code&gt; function allows you to read data where each row
represents a item and not a transaction. In that case, the &lt;code&gt;format&lt;/code&gt; argument
should be set to the value &lt;code&gt;single&lt;/code&gt; and the &lt;code&gt;cols&lt;/code&gt; argument should specify
the names or positions of the columns that represent the &lt;strong&gt;transaction id&lt;/strong&gt; and
&lt;strong&gt;item id&lt;/strong&gt;. We tried to read data in this way as well but failed to do so.
However, the code is available below for other users to try and let us know if
you find a way to get it to work or spot any mistakes we may have made.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;get_data &amp;lt;- read.transactions(&amp;quot;retail.csv&amp;quot;, 
  format = &amp;quot;single&amp;quot;,
  sep = &amp;quot;,&amp;quot;,
  cols = c(&amp;quot;InvoiceNo&amp;quot;, &amp;quot;item&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We were able to read the data when we removed the &lt;code&gt;sep&lt;/code&gt; argument from the above
code, but the result from the &lt;code&gt;summary()&lt;/code&gt; function was way different than what
we see in the next section i.e. it showed higher number of transactions and
items.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data-summary&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data Summary&lt;/h2&gt;
&lt;p&gt;To get a quick overview of the data, use &lt;code&gt;summary()&lt;/code&gt;. It will return the
following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;number of transactions&lt;/li&gt;
&lt;li&gt;number of items&lt;/li&gt;
&lt;li&gt;most frequent items&lt;/li&gt;
&lt;li&gt;distribution of items&lt;/li&gt;
&lt;li&gt;five number summary&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;summary(basket_data)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## transactions as itemMatrix in sparse format with
##  25901 rows (elements/itemsets/transactions) and
##  10085 columns (items) and a density of 0.001660018 
## 
## most frequent items:
## WHITE HANGING HEART T-LIGHT HOLDER           REGENCY CAKESTAND 3 TIER 
##                               1999                               1914 
##            JUMBO BAG RED RETROSPOT                      PARTY BUNTING 
##                               1806                               1488 
##            LUNCH BAG RED RETROSPOT                            (Other) 
##                               1404                             425005 
## 
## element (itemset/transaction) length distribution:
## sizes
##    0    1    2    3    4    5    6    7    8    9   10   11   12   13   14   15 
## 1454 4578 1727 1208  942  891  781  715  696  683  612  642  547  530  543  555 
##   16   17   18   19   20   21   22   23   24   25   26   27   28   29   30   31 
##  537  479  459  491  428  405  328  311  280  248  261  235  221  233  224  175 
##   32   33   34   35   36   37   38   39   40   41   42   43   44   45   46   47 
##  174  145  149  139  122  119  100  117   98   94  102   93   72   73   74   71 
##   48   49   50   51   52   53   54   55   56   57   58   59   60   61   62   63 
##   69   68   59   70   49   49   54   57   42   32   42   39   34   40   22   27 
##   64   65   66   67   68   69   70   71   72   73   74   75   76   77   78   79 
##   30   24   34   28   25   21   23   26   14   17   24   11   18   14   13   10 
##   80   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95 
##   16   18   15   10    9   16   13   16   13    7    8   12   12    8    7    7 
##   96   97   98   99  100  101  102  103  104  105  106  107  108  109  110  111 
##    4    7    9    5    8    8    4    5    7    2    3    7    9    4    7    4 
##  112  113  114  115  116  117  118  119  120  121  122  123  124  125  126  127 
##    2    7    1    1    4    7    6    2    3    5    4    4    2    5    6    2 
##  129  130  131  132  133  134  135  136  137  138  139  140  141  142  143  144 
##    1    4    3    6    6    3    4    3    2    1    1    3    8    5    3    4 
##  145  146  147  148  149  150  151  152  153  154  155  156  157  158  159  160 
##    4    6    2    3    1    4    3    2    4    7    3    3    5    2    4    5 
##  162  163  164  167  168  169  170  171  172  173  174  175  176  177  178  179 
##    1    2    1    3    5    2    2    4    3    1    3    5    1    2    2    2 
##  180  181  182  183  184  185  186  187  189  190  192  193  194  196  197  198 
##    2    1    2    1    2    1    1    2    2    1    1    5    1    2    3    2 
##  201  202  204  205  206  207  208  209  212  213  215  219  220  224  226  227 
##    1    1    2    2    1    3    3    2    1    2    2    7    1    3    3    1 
##  228  230  232  234  236  238  240  241  244  248  249  250  252  256  257  258 
##    1    2    1    2    1    2    2    2    1    1    2    2    1    1    1    1 
##  260  261  263  265  266  270  272  281  284  285  298  299  301  303  304  305 
##    2    1    2    1    1    1    1    1    1    2    1    2    1    1    1    3 
##  312  314  316  320  321  326  327  329  332  333  338  339  341  344  348  350 
##    2    1    1    2    1    1    1    1    1    1    1    1    1    2    1    1 
##  360  365  367  375  391  394  398  400  402  405  411  419  422  429  431  442 
##    2    1    1    3    1    1    1    1    1    1    1    2    1    1    2    1 
##  447  460  468  471  477  509  514  530  587  627 1114 
##    1    1    1    1    1    1    1    1    1    1    1 
## 
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    2.00    8.00   16.74   20.00 1114.00 
## 
## includes extended item information - examples:
##                    labels
## 1   *Boombox Ipod Classic
## 2 *USB Office Mirror Ball
## 3                       ?&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;item-frequency-plot&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Item Frequency Plot&lt;/h2&gt;
&lt;p&gt;The most frequent items in the data set can be plotted using
&lt;code&gt;itemFrequencyPlot()&lt;/code&gt;. We can specify the number of items to be plotted and
whether the &lt;code&gt;Y&lt;/code&gt; axis should represent the absolute or relative number of transactions
that include the item.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;topN&lt;/code&gt; argument can be used to specify the number of items to be plotted
and the &lt;code&gt;type&lt;/code&gt; argument can be used to specify whether the &lt;code&gt;Y&lt;/code&gt; axis represents
absolute/relative frequency of the items.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;itemFrequencyPlot(basket_data, topN = 10, type = &amp;#39;absolute&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-05-02-mba_files/figure-html/plot_freq-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In the below plot, the &lt;code&gt;Y&lt;/code&gt; axis represents the relative frequency of the items
plotted.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;itemFrequencyPlot(basket_data, topN = 10, type = &amp;#39;relative&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-05-02-mba_files/figure-html/plot_freq_relative-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;a href=&#34;https://apps.rsquaredacademy.com/&#34; target=&#34;_blank&#34;&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/ad_apps.png&#34; width=&#34;100%&#34; alt=&#34;apps ad&#34; style=&#34;text-decoration: none;&#34;&gt;&lt;/a&gt;
&lt;hr&gt;
&lt;/div&gt;
&lt;div id=&#34;generate-rules&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Generate Rules&lt;/h2&gt;
&lt;p&gt;Finally, to the part you all have been waiting for, rules generation. The
&lt;code&gt;apriori()&lt;/code&gt; function is used for generating the rules. We will first learn the
different inputs that must be specified and later on play around with them and
see how the rules generated change.&lt;/p&gt;
&lt;p&gt;The first input is the data set, which in our case is &lt;code&gt;basket_data&lt;/code&gt;. Next, we
will supply the mining parameters using the &lt;code&gt;parameter&lt;/code&gt; argument:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;supp&lt;/code&gt;: minimum &lt;strong&gt;support&lt;/strong&gt; for an itemset&lt;/li&gt;
&lt;li&gt;&lt;code&gt;conf&lt;/code&gt;: minimum &lt;strong&gt;confidence&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;maxlen&lt;/code&gt;: maximum number of items the antecedent may include&lt;/li&gt;
&lt;li&gt;&lt;code&gt;target&lt;/code&gt;: the type of association mined i.e. &lt;strong&gt;rules&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;code&gt;parameter&lt;/code&gt; argument takes several additional inputs but to get started, it
is sufficient to know those mentioned above. All the inputs are supplied using
a &lt;code&gt;list()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;For our case study, we will specify the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;support: 0.009&lt;/li&gt;
&lt;li&gt;confidence: 0.8&lt;/li&gt;
&lt;li&gt;maxlen: 4&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Keep in mind, mining association rules with very low values for &lt;code&gt;support&lt;/code&gt; will
result in a large number of rules being generated, resulting in long execution
time and the process will eventually run out of memory.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rules &amp;lt;- apriori(basket_data, parameter = list(supp=0.009, conf=0.8, 
    target = &amp;quot;rules&amp;quot;, maxlen = 4))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Apriori
## 
## Parameter specification:
##  confidence minval smax arem  aval originalSupport maxtime support minlen
##         0.8    0.1    1 none FALSE            TRUE       5   0.009      1
##  maxlen target  ext
##       4  rules TRUE
## 
## Algorithmic control:
##  filter tree heap memopt load sort verbose
##     0.1 TRUE TRUE  FALSE TRUE    2    TRUE
## 
## Absolute minimum support count: 233 
## 
## set item appearances ...[0 item(s)] done [0.00s].
## set transactions ...[10085 item(s), 25901 transaction(s)] done [1.08s].
## sorting and recoding items ... [508 item(s)] done [0.02s].
## creating transaction tree ... done [0.06s].
## checking subsets of size 1 2 3 4&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning in apriori(basket_data, parameter = list(supp = 0.009, conf = 0.8, :
## Mining stopped (maxlen reached). Only patterns up to a length of 4 returned!&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  done [0.07s].
## writing ... [22 rule(s)] done [0.00s].
## creating S4 object  ... done [0.02s].&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Change the values of &lt;code&gt;supp&lt;/code&gt;, &lt;code&gt;conf&lt;/code&gt; and &lt;code&gt;maxlen&lt;/code&gt;, and observe how the rules
generated change.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;rules-summary&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Rules Summary&lt;/h2&gt;
&lt;p&gt;Once the rules have been generated by &lt;code&gt;apriori()&lt;/code&gt;, we can use &lt;code&gt;summary()&lt;/code&gt; to
get some basic information such as rule length distribution.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;summary(rules)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## set of 22 rules
## 
## rule length distribution (lhs + rhs):sizes
##  2  3  4 
## 11  9  2 
## 
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   2.000   2.000   2.500   2.591   3.000   4.000 
## 
## summary of quality measures:
##     support           confidence        coverage             lift      
##  Min.   :0.009034   Min.   :0.8035   Min.   :0.009614   Min.   :22.59  
##  1st Qu.:0.010453   1st Qu.:0.8530   1st Qu.:0.011592   1st Qu.:25.02  
##  Median :0.013223   Median :0.8868   Median :0.014362   Median :55.94  
##  Mean   :0.012760   Mean   :0.9120   Mean   :0.014061   Mean   :48.55  
##  3rd Qu.:0.014362   3rd Qu.:1.0000   3rd Qu.:0.014362   3rd Qu.:61.23  
##  Max.   :0.018339   Max.   :1.0000   Max.   :0.021544   Max.   :71.30  
##      count      
##  Min.   :234.0  
##  1st Qu.:270.8  
##  Median :342.5  
##  Mean   :330.5  
##  3rd Qu.:372.0  
##  Max.   :475.0  
## 
## mining info:
##         data ntransactions support confidence
##  basket_data         25901   0.009        0.8&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The output from &lt;code&gt;summary()&lt;/code&gt; does not display the rules though. To view the
rules, we have to use &lt;code&gt;inspect()&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;inspect-rules&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Inspect Rules&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;inspect()&lt;/code&gt; function will display the rules along with:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;support&lt;/li&gt;
&lt;li&gt;confidence&lt;/li&gt;
&lt;li&gt;lift&lt;/li&gt;
&lt;li&gt;count&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Before you inspect the rules, you can sort it by support, confidence or
lift. In the below, output, we sort the rules by confidence in descending order
before inspecting them.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;basket_rules &amp;lt;- sort(rules, by = &amp;#39;confidence&amp;#39;, decreasing = TRUE)
inspect(basket_rules[1:10])&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      lhs                                  rhs                                   support confidence    coverage     lift count
## [1]  {BACK DOOR}                       =&amp;gt; {KEY FOB}                         0.009613528  1.0000000 0.009613528 61.23168   249
## [2]  {SET 3 RETROSPOT TEA}             =&amp;gt; {SUGAR}                           0.014362380  1.0000000 0.014362380 69.62634   372
## [3]  {SUGAR}                           =&amp;gt; {SET 3 RETROSPOT TEA}             0.014362380  1.0000000 0.014362380 69.62634   372
## [4]  {SET 3 RETROSPOT TEA}             =&amp;gt; {COFFEE}                          0.014362380  1.0000000 0.014362380 55.94168   372
## [5]  {SUGAR}                           =&amp;gt; {COFFEE}                          0.014362380  1.0000000 0.014362380 55.94168   372
## [6]  {SHED}                            =&amp;gt; {KEY FOB}                         0.011273696  1.0000000 0.011273696 61.23168   292
## [7]  {SET 3 RETROSPOT TEA,                                                                                                   
##       SUGAR}                           =&amp;gt; {COFFEE}                          0.014362380  1.0000000 0.014362380 55.94168   372
## [8]  {COFFEE,                                                                                                                
##       SET 3 RETROSPOT TEA}             =&amp;gt; {SUGAR}                           0.014362380  1.0000000 0.014362380 69.62634   372
## [9]  {COFFEE,                                                                                                                
##       SUGAR}                           =&amp;gt; {SET 3 RETROSPOT TEA}             0.014362380  1.0000000 0.014362380 69.62634   372
## [10] {PINK REGENCY TEACUP AND SAUCER,                                                                                        
##       REGENCY CAKESTAND 3 TIER,                                                                                              
##       ROSES REGENCY TEACUP AND SAUCER} =&amp;gt; {GREEN REGENCY TEACUP AND SAUCER} 0.009999614  0.8900344 0.011235087 25.16679   259&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;redundant-non-redundant-rules&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Redundant &amp;amp; Non Redundant Rules&lt;/h2&gt;
&lt;div id=&#34;redundant-rules&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Redundant Rules&lt;/h3&gt;
&lt;p&gt;A rule is redundant if a more general rules with the same or a higher
confidence exists. That is, a more specific rule is redundant if it is only
equally or even less predictive than a more general rule. A rule is more
general if it has the same RHS but one or more items removed from the LHS.&lt;/p&gt;
&lt;div id=&#34;example-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Example 1&lt;/h4&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/mba_redundant_rule_1.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In the above example, the first rule has the same support, condifence and lift
as the next two rules. The second item in the left hand side of the rule is not
adding any value and as such makes the rule redundant.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;example-2&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Example 2&lt;/h4&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/mba_redundant_rule_2.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In the above example, the first two rules have the same support, condifence and
lift. The third rule differs only with respect to lift.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;example-3&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Example 3&lt;/h4&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/mba_redundant_rule_3.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In the above example, the first and third rule have the same support,
condifence and lift. The second rule is different with respect to confidence
and lift.&lt;/p&gt;
&lt;p&gt;Now that we have understood what redundant rules are and how to identify them,
let us use the below R code to inspect them.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;inspect(rules[is.redundant(rules)])&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##     lhs                             rhs                   support    confidence
## [1] {SET 3 RETROSPOT TEA,SUGAR}  =&amp;gt; {COFFEE}              0.01436238 1         
## [2] {COFFEE,SET 3 RETROSPOT TEA} =&amp;gt; {SUGAR}               0.01436238 1         
## [3] {COFFEE,SUGAR}               =&amp;gt; {SET 3 RETROSPOT TEA} 0.01436238 1         
##     coverage   lift     count
## [1] 0.01436238 55.94168 372  
## [2] 0.01436238 69.62634 372  
## [3] 0.01436238 69.62634 372&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;non-redundant-rules&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Non-redundant Rules&lt;/h3&gt;
&lt;p&gt;Now let us look at the non-redundant rules.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;inspect(rules[!is.redundant(rules)])&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      lhs                                     rhs                                   support confidence    coverage     lift count
## [1]  {REGENCY TEA PLATE PINK}             =&amp;gt; {REGENCY TEA PLATE GREEN}         0.009034400  0.8863636 0.010192657 71.29722   234
## [2]  {BACK DOOR}                          =&amp;gt; {KEY FOB}                         0.009613528  1.0000000 0.009613528 61.23168   249
## [3]  {SET 3 RETROSPOT TEA}                =&amp;gt; {SUGAR}                           0.014362380  1.0000000 0.014362380 69.62634   372
## [4]  {SUGAR}                              =&amp;gt; {SET 3 RETROSPOT TEA}             0.014362380  1.0000000 0.014362380 69.62634   372
## [5]  {SET 3 RETROSPOT TEA}                =&amp;gt; {COFFEE}                          0.014362380  1.0000000 0.014362380 55.94168   372
## [6]  {COFFEE}                             =&amp;gt; {SET 3 RETROSPOT TEA}             0.014362380  0.8034557 0.017875758 55.94168   372
## [7]  {SUGAR}                              =&amp;gt; {COFFEE}                          0.014362380  1.0000000 0.014362380 55.94168   372
## [8]  {COFFEE}                             =&amp;gt; {SUGAR}                           0.014362380  0.8034557 0.017875758 55.94168   372
## [9]  {REGENCY TEA PLATE GREEN}            =&amp;gt; {REGENCY TEA PLATE ROSES}         0.010347091  0.8322981 0.012431952 55.99313   268
## [10] {SHED}                               =&amp;gt; {KEY FOB}                         0.011273696  1.0000000 0.011273696 61.23168   292
## [11] {SET/6 RED SPOTTY PAPER CUPS}        =&amp;gt; {SET/6 RED SPOTTY PAPER PLATES}   0.012084476  0.8087855 0.014941508 44.38211   313
## [12] {SET/20 RED RETROSPOT PAPER NAPKINS,                                                                                       
##       SET/6 RED SPOTTY PAPER CUPS}        =&amp;gt; {SET/6 RED SPOTTY PAPER PLATES}   0.009111617  0.8872180 0.010269874 48.68609   236
## [13] {PINK REGENCY TEACUP AND SAUCER,                                                                                           
##       ROSES REGENCY TEACUP AND SAUCER}    =&amp;gt; {GREEN REGENCY TEACUP AND SAUCER} 0.018339060  0.8828996 0.020771399 24.96505   475
## [14] {GREEN REGENCY TEACUP AND SAUCER,                                                                                          
##       PINK REGENCY TEACUP AND SAUCER}     =&amp;gt; {ROSES REGENCY TEACUP AND SAUCER} 0.018339060  0.8512545 0.021543570 22.59051   475
## [15] {PINK REGENCY TEACUP AND SAUCER,                                                                                           
##       REGENCY CAKESTAND 3 TIER}           =&amp;gt; {ROSES REGENCY TEACUP AND SAUCER} 0.011235087  0.8584071 0.013088298 22.78033   291
## [16] {PINK REGENCY TEACUP AND SAUCER,                                                                                           
##       REGENCY CAKESTAND 3 TIER}           =&amp;gt; {GREEN REGENCY TEACUP AND SAUCER} 0.011312305  0.8643068 0.013088298 24.43931   293
## [17] {STRAWBERRY CHARLOTTE BAG,                                                                                                 
##       WOODLAND CHARLOTTE BAG}             =&amp;gt; {RED RETROSPOT CHARLOTTE BAG}     0.010771785  0.8110465 0.013281340 23.65644   279
## [18] {PINK REGENCY TEACUP AND SAUCER,                                                                                           
##       REGENCY CAKESTAND 3 TIER,                                                                                                 
##       ROSES REGENCY TEACUP AND SAUCER}    =&amp;gt; {GREEN REGENCY TEACUP AND SAUCER} 0.009999614  0.8900344 0.011235087 25.16679   259
## [19] {GREEN REGENCY TEACUP AND SAUCER,                                                                                          
##       PINK REGENCY TEACUP AND SAUCER,                                                                                           
##       REGENCY CAKESTAND 3 TIER}           =&amp;gt; {ROSES REGENCY TEACUP AND SAUCER} 0.009999614  0.8839590 0.011312305 23.45843   259&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;what-influenced-purchase-of-product-x&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;What influenced purchase of product X?&lt;/h2&gt;
&lt;p&gt;So far, we have learnt how to generate, inspect and prune rules. Now, how do
we use these rules? To make business sense, we need to come up with a set of
rules that can be used either for product placement in physical stores or
as recommendations in an online store or for targeted marketing via email
campaigns etc. To achieve that, we need to know 2 things:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;what products influenced the purchase of product X?&lt;/li&gt;
&lt;li&gt;what purchases did product X influence?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For our case study, we can modify the above questions as:&lt;/p&gt;
&lt;div id=&#34;what-influenced-the-purchase-of-sugar&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;What influenced the purchase of &lt;strong&gt;sugar&lt;/strong&gt;?&lt;/h4&gt;
&lt;p&gt;To view the products which influenced the purchase of &lt;strong&gt;sugar&lt;/strong&gt;, we will
continue to use the &lt;code&gt;apriori()&lt;/code&gt; function but add one more argument, &lt;code&gt;appearance&lt;/code&gt;.
It restricts the appearance of the items. Since we want the right hand side of
the rules to have only one value, &lt;strong&gt;sugar&lt;/strong&gt;, we will set the &lt;code&gt;rhs&lt;/code&gt; argument to
&lt;strong&gt;sugar&lt;/strong&gt;. The left hand side of the rules should include all the products that
influenced the purchase of sugar i.e. it will exclude &lt;strong&gt;sugar&lt;/strong&gt;. We will use
the &lt;code&gt;default&lt;/code&gt; argument and supply it the value &lt;code&gt;lhs&lt;/code&gt; i.e. all items excluding
sugar can appear on the left hand side of the rule by default.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;default&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;rhs&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;sugar_rules &amp;lt;- apriori(basket_data, parameter = list(supp = 0.009, conf = 0.8), 
  appearance = list(default = &amp;quot;lhs&amp;quot;, rhs = &amp;quot;SUGAR&amp;quot;)) &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Apriori
## 
## Parameter specification:
##  confidence minval smax arem  aval originalSupport maxtime support minlen
##         0.8    0.1    1 none FALSE            TRUE       5   0.009      1
##  maxlen target  ext
##      10  rules TRUE
## 
## Algorithmic control:
##  filter tree heap memopt load sort verbose
##     0.1 TRUE TRUE  FALSE TRUE    2    TRUE
## 
## Absolute minimum support count: 233 
## 
## set item appearances ...[1 item(s)] done [0.00s].
## set transactions ...[10085 item(s), 25901 transaction(s)] done [0.86s].
## sorting and recoding items ... [508 item(s)] done [0.02s].
## creating transaction tree ... done [0.04s].
## checking subsets of size 1 2 3 4 done [0.07s].
## writing ... [3 rule(s)] done [0.00s].
## creating S4 object  ... done [0.02s].&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rules_sugar &amp;lt;- sort(sugar_rules, by = &amp;quot;confidence&amp;quot;, decreasing = TRUE)
inspect(rules_sugar)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##     lhs                             rhs     support    confidence coverage  
## [1] {SET 3 RETROSPOT TEA}        =&amp;gt; {SUGAR} 0.01436238 1.0000000  0.01436238
## [2] {COFFEE,SET 3 RETROSPOT TEA} =&amp;gt; {SUGAR} 0.01436238 1.0000000  0.01436238
## [3] {COFFEE}                     =&amp;gt; {SUGAR} 0.01436238 0.8034557  0.01787576
##     lift     count
## [1] 69.62634 372  
## [2] 69.62634 372  
## [3] 55.94168 372&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For the support and confidence we have mentioned, we know the following
products influenced the purchase of &lt;strong&gt;sugar&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;COFFEE&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SET 3 RETROSPOT TEA&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;what-purchases-did-product-x-influence&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;What purchases did product X influence?&lt;/h2&gt;
&lt;p&gt;Now that we know what products influenced the purchase of &lt;strong&gt;sugar&lt;/strong&gt;, let us
answer the second question.&lt;/p&gt;
&lt;div id=&#34;what-purchases-did-sugar-influence&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;What purchases did &lt;strong&gt;sugar&lt;/strong&gt; influence?&lt;/h4&gt;
&lt;p&gt;In this case, we want &lt;strong&gt;sugar&lt;/strong&gt; to be on the left hand side of the rule and all
the products it influenced to be on the right hand side. We set the &lt;code&gt;lhs&lt;/code&gt;
argument to &lt;strong&gt;sugar&lt;/strong&gt; and the &lt;code&gt;default&lt;/code&gt; argument to &lt;code&gt;rhs&lt;/code&gt; as all the products,
the purchase of which was influenced by &lt;strong&gt;sugar&lt;/strong&gt; should appear on the left
hand side of the rule by default.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;sugar_rules &amp;lt;- apriori(basket_data, parameter = list(supp = 0.009, conf = 0.8), 
  appearance = list(default = &amp;quot;rhs&amp;quot;, lhs = &amp;quot;SUGAR&amp;quot;)) &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Apriori
## 
## Parameter specification:
##  confidence minval smax arem  aval originalSupport maxtime support minlen
##         0.8    0.1    1 none FALSE            TRUE       5   0.009      1
##  maxlen target  ext
##      10  rules TRUE
## 
## Algorithmic control:
##  filter tree heap memopt load sort verbose
##     0.1 TRUE TRUE  FALSE TRUE    2    TRUE
## 
## Absolute minimum support count: 233 
## 
## set item appearances ...[1 item(s)] done [0.00s].
## set transactions ...[10085 item(s), 25901 transaction(s)] done [0.76s].
## sorting and recoding items ... [508 item(s)] done [0.02s].
## creating transaction tree ... done [0.03s].
## checking subsets of size 1 2 done [0.01s].
## writing ... [2 rule(s)] done [0.00s].
## creating S4 object  ... done [0.01s].&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rules_sugar &amp;lt;- sort(sugar_rules, by = &amp;quot;confidence&amp;quot;, decreasing = TRUE)
inspect(rules_sugar)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##     lhs        rhs                   support    confidence coverage   lift    
## [1] {SUGAR} =&amp;gt; {SET 3 RETROSPOT TEA} 0.01436238 1          0.01436238 69.62634
## [2] {SUGAR} =&amp;gt; {COFFEE}              0.01436238 1          0.01436238 55.94168
##     count
## [1] 372  
## [2] 372&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For the support and confidence we have mentioned, we know the purchase of
the following products were influenced by &lt;strong&gt;sugar&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;COFFEE&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SET 3 RETROSPOT TEA&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;top-rules&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Top Rules&lt;/h2&gt;
&lt;p&gt;Let us take a look at the top rules by&lt;/p&gt;
&lt;div id=&#34;support-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Support&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;supp_rules &amp;lt;- sort(rules, by = &amp;#39;support&amp;#39;, decreasing = TRUE)
top_rules &amp;lt;- supp_rules[1:10]
inspect(top_rules)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      lhs                                  rhs                                  support confidence   coverage     lift count
## [1]  {PINK REGENCY TEACUP AND SAUCER,                                                                                      
##       ROSES REGENCY TEACUP AND SAUCER} =&amp;gt; {GREEN REGENCY TEACUP AND SAUCER} 0.01833906  0.8828996 0.02077140 24.96505   475
## [2]  {GREEN REGENCY TEACUP AND SAUCER,                                                                                     
##       PINK REGENCY TEACUP AND SAUCER}  =&amp;gt; {ROSES REGENCY TEACUP AND SAUCER} 0.01833906  0.8512545 0.02154357 22.59051   475
## [3]  {SET 3 RETROSPOT TEA}             =&amp;gt; {SUGAR}                           0.01436238  1.0000000 0.01436238 69.62634   372
## [4]  {SUGAR}                           =&amp;gt; {SET 3 RETROSPOT TEA}             0.01436238  1.0000000 0.01436238 69.62634   372
## [5]  {SET 3 RETROSPOT TEA}             =&amp;gt; {COFFEE}                          0.01436238  1.0000000 0.01436238 55.94168   372
## [6]  {COFFEE}                          =&amp;gt; {SET 3 RETROSPOT TEA}             0.01436238  0.8034557 0.01787576 55.94168   372
## [7]  {SUGAR}                           =&amp;gt; {COFFEE}                          0.01436238  1.0000000 0.01436238 55.94168   372
## [8]  {COFFEE}                          =&amp;gt; {SUGAR}                           0.01436238  0.8034557 0.01787576 55.94168   372
## [9]  {SET 3 RETROSPOT TEA,                                                                                                 
##       SUGAR}                           =&amp;gt; {COFFEE}                          0.01436238  1.0000000 0.01436238 55.94168   372
## [10] {COFFEE,                                                                                                              
##       SET 3 RETROSPOT TEA}             =&amp;gt; {SUGAR}                           0.01436238  1.0000000 0.01436238 69.62634   372&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;confidence-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Confidence&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;conf_rules &amp;lt;- sort(rules, by = &amp;#39;confidence&amp;#39;, decreasing = TRUE)
top_rules &amp;lt;- conf_rules[1:10]
inspect(top_rules)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      lhs                                  rhs                                   support confidence    coverage     lift count
## [1]  {BACK DOOR}                       =&amp;gt; {KEY FOB}                         0.009613528  1.0000000 0.009613528 61.23168   249
## [2]  {SET 3 RETROSPOT TEA}             =&amp;gt; {SUGAR}                           0.014362380  1.0000000 0.014362380 69.62634   372
## [3]  {SUGAR}                           =&amp;gt; {SET 3 RETROSPOT TEA}             0.014362380  1.0000000 0.014362380 69.62634   372
## [4]  {SET 3 RETROSPOT TEA}             =&amp;gt; {COFFEE}                          0.014362380  1.0000000 0.014362380 55.94168   372
## [5]  {SUGAR}                           =&amp;gt; {COFFEE}                          0.014362380  1.0000000 0.014362380 55.94168   372
## [6]  {SHED}                            =&amp;gt; {KEY FOB}                         0.011273696  1.0000000 0.011273696 61.23168   292
## [7]  {SET 3 RETROSPOT TEA,                                                                                                   
##       SUGAR}                           =&amp;gt; {COFFEE}                          0.014362380  1.0000000 0.014362380 55.94168   372
## [8]  {COFFEE,                                                                                                                
##       SET 3 RETROSPOT TEA}             =&amp;gt; {SUGAR}                           0.014362380  1.0000000 0.014362380 69.62634   372
## [9]  {COFFEE,                                                                                                                
##       SUGAR}                           =&amp;gt; {SET 3 RETROSPOT TEA}             0.014362380  1.0000000 0.014362380 69.62634   372
## [10] {PINK REGENCY TEACUP AND SAUCER,                                                                                        
##       REGENCY CAKESTAND 3 TIER,                                                                                              
##       ROSES REGENCY TEACUP AND SAUCER} =&amp;gt; {GREEN REGENCY TEACUP AND SAUCER} 0.009999614  0.8900344 0.011235087 25.16679   259&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;lift-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Lift&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;lift_rules &amp;lt;- sort(rules, by = &amp;#39;lift&amp;#39;, decreasing = TRUE)
top_rules &amp;lt;- lift_rules[1:10]
inspect(top_rules)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      lhs                             rhs                       support    
## [1]  {REGENCY TEA PLATE PINK}     =&amp;gt; {REGENCY TEA PLATE GREEN} 0.009034400
## [2]  {SET 3 RETROSPOT TEA}        =&amp;gt; {SUGAR}                   0.014362380
## [3]  {SUGAR}                      =&amp;gt; {SET 3 RETROSPOT TEA}     0.014362380
## [4]  {COFFEE,SET 3 RETROSPOT TEA} =&amp;gt; {SUGAR}                   0.014362380
## [5]  {COFFEE,SUGAR}               =&amp;gt; {SET 3 RETROSPOT TEA}     0.014362380
## [6]  {BACK DOOR}                  =&amp;gt; {KEY FOB}                 0.009613528
## [7]  {SHED}                       =&amp;gt; {KEY FOB}                 0.011273696
## [8]  {REGENCY TEA PLATE GREEN}    =&amp;gt; {REGENCY TEA PLATE ROSES} 0.010347091
## [9]  {SET 3 RETROSPOT TEA}        =&amp;gt; {COFFEE}                  0.014362380
## [10] {COFFEE}                     =&amp;gt; {SET 3 RETROSPOT TEA}     0.014362380
##      confidence coverage    lift     count
## [1]  0.8863636  0.010192657 71.29722 234  
## [2]  1.0000000  0.014362380 69.62634 372  
## [3]  1.0000000  0.014362380 69.62634 372  
## [4]  1.0000000  0.014362380 69.62634 372  
## [5]  1.0000000  0.014362380 69.62634 372  
## [6]  1.0000000  0.009613528 61.23168 249  
## [7]  1.0000000  0.011273696 61.23168 292  
## [8]  0.8322981  0.012431952 55.99313 268  
## [9]  1.0000000  0.014362380 55.94168 372  
## [10] 0.8034557  0.017875758 55.94168 372&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;a href=&#34;https://pkgs.rsquaredacademy.com/&#34; target=&#34;_blank&#34;&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/ad_packages.png&#34; width=&#34;100%&#34; alt=&#34;packages ad&#34; style=&#34;text-decoration: none;&#34;&gt;&lt;/a&gt;
&lt;hr&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;visualization&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Visualization&lt;/h2&gt;
&lt;p&gt;To visualize the rules, the authors of &lt;strong&gt;arules&lt;/strong&gt; have created a companion
package, &lt;strong&gt;arulesViz&lt;/strong&gt;. It offers several options for visualizing the rules
generated by &lt;code&gt;apriori()&lt;/code&gt;.&lt;/p&gt;
&lt;div id=&#34;scatter-plot&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Scatter Plot&lt;/h3&gt;
&lt;p&gt;We can use the default &lt;code&gt;plot()&lt;/code&gt; method to create a scatter plot. It will plot
the support on the &lt;code&gt;X&lt;/code&gt; axis, the confidence on the &lt;code&gt;Y&lt;/code&gt; axis and the lift is
represented by the opaqueness/alpha of the color of the points.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(basket_rules)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-05-02-mba_files/figure-html/plot_scatter-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;network-plot&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Network Plot&lt;/h3&gt;
&lt;p&gt;We can create a network plot using the &lt;code&gt;method&lt;/code&gt; argument and supplying it the
value &lt;code&gt;graph&lt;/code&gt;. You can see the directionality of the rule in the below plot.
For example, people who buy &lt;strong&gt;shed&lt;/strong&gt; also buy &lt;strong&gt;key fob&lt;/strong&gt; and similarly, people
who buy &lt;strong&gt;back door&lt;/strong&gt; also buy &lt;strong&gt;key fob&lt;/strong&gt;. It will be difficult to identify
the directionality of the rules when we are trying to plot too many rules.
The &lt;code&gt;method&lt;/code&gt; argument takes several other values as well.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(top_rules, method = &amp;#39;graph&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-05-02-mba_files/figure-html/plot_network-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;things-to-keep-in-mind..&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Things to keep in mind..&lt;/h2&gt;
&lt;div id=&#34;directionality-of-rule-is-lost-while-using-lift&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Directionality of rule is lost while using lift&lt;/h4&gt;
&lt;p&gt;The directionality of a rule is lost while using lift. In the below example,
the lift is same for both the following rules:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;{Mobile Phone} =&amp;gt; {Screen Guard}&lt;/li&gt;
&lt;li&gt;{Screen Guard} =&amp;gt; {Mobile Phone}&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It is clear that the lift is the same irrespective of the direction of the rule.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/mba_lift_warning_final.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;confidence-as-a-measure-can-be-misleading&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Confidence as a measure can be misleading&lt;/h4&gt;
&lt;p&gt;If you look at the below example, the confidence for the second rule,
&lt;strong&gt;{Screen Guard} =&amp;gt; {Mobile Phone}&lt;/strong&gt;, is greater than the first rule,
&lt;strong&gt;{Mobile Phone} =&amp;gt; {Screen Guard}&lt;/strong&gt;. It does not mean that we can recommend
a mobile phone to a customer who is purchasing a screen guard. It is important
to ensure that we do not use rules just because they have high confidence
associated with them.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/mba_conf_warn_final.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Summary&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;market basket analysis is an unsupervised data mining technique&lt;/li&gt;
&lt;li&gt;uncovers products frequently bought together&lt;/li&gt;
&lt;li&gt;creates if-then scenario rules&lt;/li&gt;
&lt;li&gt;cost-effective, insightful and actionable&lt;/li&gt;
&lt;li&gt;association rule mining has applications in several industries&lt;/li&gt;
&lt;li&gt;directionality of rule is lost while using lift&lt;/li&gt;
&lt;li&gt;confidence as a measure can be misleading&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Your knowledge of the domain/business matters a lot when you are trying to
use market basket analysis. Especially, when you are trying to select or
shortlist rules and use them for product placement in a store or for
recommending products online. It is a good practice to critically review the
rules before implementing them.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>A follow up note on our web scraping tutorial</title>
      <link>https://blog.rsquaredacademy.com/web-scraping-note/</link>
      <pubDate>Sat, 13 Apr 2019 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/web-scraping-note/</guid>
      <description>&lt;p&gt;
  We had published a web scraping
  &lt;a href=&#34;https://blog.rsquaredacademy.com/web-scraping/&#34; target=&#34;_blank&#34;
    &gt;tutorial&lt;/a
  &gt;
  a couple of days back and it had received a good response from the #rstats
  community. While we thank you for that, we made a mistake in choosing one of
  the case study as pointed out by
  &lt;a href=&#34;https://twitter.com/hrbrmstr&#34; target=&#34;_blank&#34;
    &gt;&lt;span class=&#34;citation&#34;&gt;@hrbrmstr&lt;/span&gt;&lt;/a
  &gt;
  in this tweet:
&lt;/p&gt;

&lt;p&gt;
  We choose the case study to appeal to a wide audience but in doing so we set a
  bad example. We have removed the case study from our post and apologize to the
  #rstats community for our oversight and promise to be more responsible in the
  future.
&lt;/p&gt;
&lt;p&gt;
  &lt;strong
    &gt;We reiterate it is very important to read the terms and conditions before
    scraping data from a website and checking the robots.txt file is not
    sufficient&lt;/strong
  &gt;.
&lt;/p&gt;
&lt;p&gt;Team Rsquared Academy&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Practical Introduction to Web Scraping in R</title>
      <link>https://blog.rsquaredacademy.com/web-scraping/</link>
      <pubDate>Thu, 11 Apr 2019 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/web-scraping/</guid>
      <description>&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/ws_meme.jpg&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;Are you trying to compare price of products across websites? Are you trying to
monitor price changes every hour? Or planning to do some text mining or
sentiment analysis on reviews of products or services? If yes, how would you do
that? How do you get the details available on the website into a format in
which you can analyse it?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Can you copy/paste the data from their website?&lt;/li&gt;
&lt;li&gt;Can you see some save button?&lt;/li&gt;
&lt;li&gt;Can you download the data?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Hmmm.. If you have these or similar questions on your mind, you have come to
the right place. In this post, we will learn about web scraping using R. Below
is a video tutorial which covers the intial part of this post.&lt;/p&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/l37n_HDD1qs&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;p&gt;The slides used in the above video tutorial can be found
&lt;a href=&#34;https://slides.rsquaredacademy.com/web-scraping/web-scraping.html#/section&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;the-what&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;The What?&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/blog_ws_what_border.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;What exactly is web scraping or web mining or web harvesting? It is a
technique for extracting data from websites. Remember, websites contain wealth
of useful data but designed for human consumption and not data analysis. The
goal of web scraping is to take advantage of the pattern or structure of web
pages to extract and store data in a format suitable for data analysis.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;the-why&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;The Why?&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/blog_ws_why_border.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Now, let us understand why we may have to scrape data from the web.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Data Format&lt;/strong&gt;: As we said earlier, there is a wealth of data on websites
but designed for human consumption. As such, we cannot use it for data analysis
as it is not in a suitable format/shape/structure.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No copy/paste&lt;/strong&gt;: We cannot copy &amp;amp; paste the data into a local file. Even if
we do it, it will not be in the required format for data analysis.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No save/download&lt;/strong&gt;: There are no options to save/download the required data
from the websites. We cannot right click and save or click on a download button
to extract the required data.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Automation&lt;/strong&gt;: With web scraping, we can automate the process of data
extraction/harvesting.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;the-how&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;The How?&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/blog_ws_how_border.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;robots.txt&lt;/strong&gt;: One of the most important and overlooked step is to check the
&lt;strong&gt;robots.txt&lt;/strong&gt; file to ensure that we have the permission to access the web
page without violating any terms or conditions. In R, we can do this using the
&lt;a href=&#34;https://cran.r-project.org/package=robotstxt&#34; target=&#34;_blank&#34;&gt;robotstxt&lt;/a&gt;
by &lt;a href=&#34;https://ropensci.org/&#34; target=&#34;_blank&#34;&gt;rOpenSci&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Fetch&lt;/strong&gt;: The next step is to fetch the web page using the
&lt;a href=&#34;https://cran.r-project.org/package=xml2&#34; target=&#34;_blank&#34;&gt;xml2&lt;/a&gt;
package and store it so that we can extract the required data. Remember, you
fetch the page once and store it to avoid fetching multiple times as it may
lead to your IP address being blocked by the owners of the website.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Extract/Store/Analyze&lt;/strong&gt;: Now that we have fetched the web page, we will use
&lt;a href=&#34;https://rvest.tidyverse.org/&#34; target=&#34;_blank&#34;&gt;rvest&lt;/a&gt; to extract the
data and store it for further analysis.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;use-cases&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Use Cases&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/blog_ws_use_cases_border.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Below are few use cases of web scraping:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Contact Scraping&lt;/strong&gt;: Locate contact information including email addresses,
phone numbers etc.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Monitoring/Comparing Prices&lt;/strong&gt;: How your competitors price their products,
how your prices fit within your industry, and whether there are any
fluctuations that you can take advantage of.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Scraping Reviews/Ratings&lt;/strong&gt;: Scrape reviews of product/services and use it
for text mining/sentiment analysis etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;things-to-keep-in-mind&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Things to keep in mind…&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/blog_ws_keep_in_mind_border.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Static &amp;amp; Well Structured&lt;/strong&gt;: Web scraping is best suited for static &amp;amp; well
structured web pages. In one of our case studies, we demonstrate how badly
structured web pages can hamper data extraction.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Code Changes&lt;/strong&gt;: The underling HTML code of a web page can change anytime
due to changes in design or for updating details. In such case, your script
will stop working. It is important to identify changes to the web page and
modify the web scraping script accordingly.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;API Availability&lt;/strong&gt;: In many cases, an API (application programming interface)
is made available by the service provider or organization. It is always
advisable to use the API and avoid web scraping. The
&lt;a href=&#34;https://httr.r-lib.org/&#34; target=&#34;_blank&#34;&gt;httr&lt;/a&gt; package has a
nice introduction on interacting with APIs.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;IP Blocking&lt;/strong&gt;: Do not flood websites with requests as you run the risk of
getting blocked. Have some time gap between request so that your IP address in
not blocked from accessing the website.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;robots.txt&lt;/strong&gt;: We cannot emphasize this enough, always review the
&lt;strong&gt;robots.txt&lt;/strong&gt; file to ensure you are not violating any terms and conditions.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;case-studies&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Case Studies&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/blog_ws_case_studies_border.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;IMDB top 50 movies&lt;/strong&gt;: In this case study we will scrape the IMDB website
to extract the title, year of release, certificate, runtime, genre, rating,
votes and revenue of the top 50 movies.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Most visited websites&lt;/strong&gt;: In this case study, we will look at the 50 most
visited websites in the world including the category to which they belong,
average time on site, average pages browsed per vist and bounce rate.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;List of RBI governors&lt;/strong&gt; : In this final case study, we will scrape the list
of RBI Governors from Wikipedia, and analyze the background from which they
came i.e whether there were more economists or bureaucrats?&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;p&gt;&lt;a href=&#34;https://www.rsquaredacademy.com/&#34; target=&#34;_blank&#34;&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/ad.png&#34; width=&#34;100%&#34; alt=&#34;course ad&#34; style=&#34;text-decoration: none;&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;/div&gt;
&lt;div id=&#34;html-basics&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;HTML Basics&lt;/h2&gt;
&lt;p&gt;To be able to scrape data from websites, we need to understand how the web
pages are structured. In this section, we will learn just enough HTML to be
able to start scraping data from websites.&lt;/p&gt;
&lt;div id=&#34;html-css-javascript&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;HTML, CSS &amp;amp; JAVASCRIPT&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/html_css_js_2.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;A web page typically is made up of the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;HTML&lt;/strong&gt; (Hyper Text Markup Language) takes care of the content. You need to
have a basic knowledge of HTML tags as the content is located with these tags.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CSS&lt;/strong&gt; (Cascading Style Sheets) takes care of the appearance of the content.
While you don’t need to look into the CSS of a web page, you should be able to
identify the &lt;strong&gt;id&lt;/strong&gt; or &lt;strong&gt;class&lt;/strong&gt; that manage the appearance of content.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;JS&lt;/strong&gt; (Javascript) takes care of the behavior of the web page.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;html-element&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;HTML Element&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/blog_ws_html_tags_2_border.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;HTML element consists of a start tag and end tag with content inserted in
between. They can be nested and are case insensitive. The tags can have
attributes as shown in the above image. The attributes usually come as
name/value pairs. In the above image, &lt;strong&gt;class&lt;/strong&gt; is the attribute name while
&lt;strong&gt;primary&lt;/strong&gt; is the attribute value. While scraping data from websites in the
case study, we will use a combination of HTML tags and attributes to locate
the content we want to extract. Below is a list of basic and important HTML
tags you should know before you get started with web scraping.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/html_tags.jpg&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;dom&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;DOM&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/blog_ws_html_dom_border.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;DOM&lt;/strong&gt; (Document Object Model) defines the logical structure of a document
and the way it is accessed and manipulated. In the above image, you can see
that HTML is structured as a tree and you trace path to any node or tag. We
will use a similar approach in our case studies. We will try to trace the
content we intend to extract using HTML tags and attributes. If the web page
is well structured, we should be able to locate the content using a unique
combination of tags and attributes.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;html-attributes&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;HTML Attributes&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/blog_ws_html_attributes_crop.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;all HTML elements can have attributes&lt;/li&gt;
&lt;li&gt;they provide additional information about an element&lt;/li&gt;
&lt;li&gt;they are always specified in the start tag&lt;/li&gt;
&lt;li&gt;usually come in name/value pairs&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The class attribute is used to define equal styles for elements with same
class name. HTML elements with same class name will have the same format and
style. The &lt;code&gt;id&lt;/code&gt; attribute specifies a unique id for an HTML element. It can be
used on any HTML element and is case sensitive. The &lt;code&gt;style&lt;/code&gt; attribute sets the
style of an HTML element.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;
&lt;a href=&#34;https://www.youtube.com/user/rsquaredin/&#34; target=&#34;_blank&#34;&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/ad_youtube.png&#34; width=&#34;100%&#34; alt=&#34;youtube ad&#34; style=&#34;text-decoration: none;&#34;&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;hr&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Libraries&lt;/h2&gt;
&lt;p&gt;We will use the following R packages in this tutorial.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(robotstxt)
library(rvest)
library(selectr)
library(xml2)
library(dplyr)
library(stringr)
library(forcats)
library(magrittr)
library(tidyr)
library(ggplot2)
library(lubridate)
library(tibble)
library(purrr)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;imdb-top-50&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;IMDB Top 50&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/blog_ws_cs_imdb_top_50_border.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In this case study, we will extract the following details of the top 50 movies
from the IMDB website:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;title&lt;/li&gt;
&lt;li&gt;year of release&lt;/li&gt;
&lt;li&gt;certificate&lt;/li&gt;
&lt;li&gt;runtime&lt;/li&gt;
&lt;li&gt;genre&lt;/li&gt;
&lt;li&gt;rating&lt;/li&gt;
&lt;li&gt;votes&lt;/li&gt;
&lt;li&gt;revenue&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;robotstxt&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;robotstxt&lt;/h3&gt;
&lt;p&gt;Let us check if we can scrape the data from the website using &lt;code&gt;paths_allowed()&lt;/code&gt;
from &lt;strong&gt;robotstxt&lt;/strong&gt; package.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;paths_allowed(
  paths = c(&amp;quot;https://www.imdb.com/search/title?groups=top_250&amp;amp;sort=user_rating&amp;quot;)
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
 www.imdb.com&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Since it has returned &lt;code&gt;TRUE&lt;/code&gt;, we will go ahead and download the web page using
&lt;code&gt;read_html()&lt;/code&gt; from &lt;strong&gt;xml2&lt;/strong&gt; package.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;imdb &amp;lt;- read_html(&amp;quot;https://www.imdb.com/search/title?groups=top_250&amp;amp;sort=user_rating&amp;quot;)
imdb&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## {html_document}
## &amp;lt;html xmlns:og=&amp;quot;http://ogp.me/ns#&amp;quot; xmlns:fb=&amp;quot;http://www.facebook.com/2008/fbml&amp;quot;&amp;gt;
## [1] &amp;lt;head&amp;gt;\n&amp;lt;meta http-equiv=&amp;quot;Content-Type&amp;quot; content=&amp;quot;text/html; charset=UTF-8 ...
## [2] &amp;lt;body id=&amp;quot;styleguide-v2&amp;quot; class=&amp;quot;fixed&amp;quot;&amp;gt;\n            &amp;lt;img height=&amp;quot;1&amp;quot; widt ...&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;title&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Title&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/blog_ws_imdb_movie_name_border.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As we did in the previous case study, we will look at the HTML code of the IMDB
web page and locate the title of the movies in the following way:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;hyperlink inside &lt;code&gt;&amp;lt;h3&amp;gt;&lt;/code&gt; tag&lt;/li&gt;
&lt;li&gt;section identified with the class &lt;code&gt;.lister-item-content&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In other words, the title of the movie is inside a hyperlink (&lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt;) which
is inside a level 3 heading (&lt;code&gt;&amp;lt;h3&amp;gt;&lt;/code&gt;) within a section identified by the class
&lt;code&gt;.lister-item-content&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;imdb %&amp;gt;%
  html_nodes(&amp;quot;.lister-item-content h3 a&amp;quot;) %&amp;gt;%
  html_text() -&amp;gt; movie_title

movie_title&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;The Shawshank Redemption&amp;quot;                         
##  [2] &amp;quot;The Godfather&amp;quot;                                    
##  [3] &amp;quot;The Dark Knight&amp;quot;                                  
##  [4] &amp;quot;The Godfather: Part II&amp;quot;                           
##  [5] &amp;quot;The Lord of the Rings: The Return of the King&amp;quot;    
##  [6] &amp;quot;Pulp Fiction&amp;quot;                                     
##  [7] &amp;quot;Schindler&amp;#39;s List&amp;quot;                                 
##  [8] &amp;quot;12 Angry Men&amp;quot;                                     
##  [9] &amp;quot;Inception&amp;quot;                                        
## [10] &amp;quot;Fight Club&amp;quot;                                       
## [11] &amp;quot;The Lord of the Rings: The Fellowship of the Ring&amp;quot;
## [12] &amp;quot;Forrest Gump&amp;quot;                                     
## [13] &amp;quot;Il buono, il brutto, il cattivo&amp;quot;                  
## [14] &amp;quot;The Lord of the Rings: The Two Towers&amp;quot;            
## [15] &amp;quot;The Matrix&amp;quot;                                       
## [16] &amp;quot;Goodfellas&amp;quot;                                       
## [17] &amp;quot;Star Wars: Episode V - The Empire Strikes Back&amp;quot;   
## [18] &amp;quot;One Flew Over the Cuckoo&amp;#39;s Nest&amp;quot;                  
## [19] &amp;quot;Seppuku&amp;quot;                                          
## [20] &amp;quot;Gisaengchung&amp;quot;                                     
## [21] &amp;quot;Interstellar&amp;quot;                                     
## [22] &amp;quot;Cidade de Deus&amp;quot;                                   
## [23] &amp;quot;Sen to Chihiro no kamikakushi&amp;quot;                    
## [24] &amp;quot;Saving Private Ryan&amp;quot;                              
## [25] &amp;quot;The Green Mile&amp;quot;                                   
## [26] &amp;quot;La vita è bella&amp;quot;                                  
## [27] &amp;quot;Se7en&amp;quot;                                            
## [28] &amp;quot;The Silence of the Lambs&amp;quot;                         
## [29] &amp;quot;Star Wars&amp;quot;                                        
## [30] &amp;quot;Anand&amp;quot;                                            
## [31] &amp;quot;Shichinin no samurai&amp;quot;                             
## [32] &amp;quot;It&amp;#39;s a Wonderful Life&amp;quot;                            
## [33] &amp;quot;Joker&amp;quot;                                            
## [34] &amp;quot;Avengers: Infinity War&amp;quot;                           
## [35] &amp;quot;Whiplash&amp;quot;                                         
## [36] &amp;quot;The Intouchables&amp;quot;                                 
## [37] &amp;quot;The Prestige&amp;quot;                                     
## [38] &amp;quot;The Departed&amp;quot;                                     
## [39] &amp;quot;The Pianist&amp;quot;                                      
## [40] &amp;quot;Gladiator&amp;quot;                                        
## [41] &amp;quot;American History X&amp;quot;                               
## [42] &amp;quot;The Usual Suspects&amp;quot;                               
## [43] &amp;quot;Léon&amp;quot;                                             
## [44] &amp;quot;The Lion King&amp;quot;                                    
## [45] &amp;quot;Terminator 2: Judgment Day&amp;quot;                       
## [46] &amp;quot;Nuovo Cinema Paradiso&amp;quot;                            
## [47] &amp;quot;Hotaru no haka&amp;quot;                                   
## [48] &amp;quot;Back to the Future&amp;quot;                               
## [49] &amp;quot;Once Upon a Time in the West&amp;quot;                     
## [50] &amp;quot;Tengoku to jigoku&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;year-of-release&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Year of Release&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/blog_ws_imdb_movie_year_border.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The year in which a movie was released can be located in the following way:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt; tag identified by the class &lt;code&gt;.lister-item-year&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;nested inside a level 3 heading (&lt;code&gt;&amp;lt;h3&amp;gt;&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;part of section identified by the class &lt;code&gt;.lister-item-content&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;imdb %&amp;gt;%
  html_nodes(&amp;quot;.lister-item-content h3 .lister-item-year&amp;quot;) %&amp;gt;%
  html_text() &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;(1994)&amp;quot; &amp;quot;(1972)&amp;quot; &amp;quot;(2008)&amp;quot; &amp;quot;(1974)&amp;quot; &amp;quot;(2003)&amp;quot; &amp;quot;(1994)&amp;quot; &amp;quot;(1993)&amp;quot; &amp;quot;(1957)&amp;quot;
##  [9] &amp;quot;(2010)&amp;quot; &amp;quot;(1999)&amp;quot; &amp;quot;(2001)&amp;quot; &amp;quot;(1994)&amp;quot; &amp;quot;(1966)&amp;quot; &amp;quot;(2002)&amp;quot; &amp;quot;(1999)&amp;quot; &amp;quot;(1990)&amp;quot;
## [17] &amp;quot;(1980)&amp;quot; &amp;quot;(1975)&amp;quot; &amp;quot;(1962)&amp;quot; &amp;quot;(2019)&amp;quot; &amp;quot;(2014)&amp;quot; &amp;quot;(2002)&amp;quot; &amp;quot;(2001)&amp;quot; &amp;quot;(1998)&amp;quot;
## [25] &amp;quot;(1999)&amp;quot; &amp;quot;(1997)&amp;quot; &amp;quot;(1995)&amp;quot; &amp;quot;(1991)&amp;quot; &amp;quot;(1977)&amp;quot; &amp;quot;(1971)&amp;quot; &amp;quot;(1954)&amp;quot; &amp;quot;(1946)&amp;quot;
## [33] &amp;quot;(2019)&amp;quot; &amp;quot;(2018)&amp;quot; &amp;quot;(2014)&amp;quot; &amp;quot;(2011)&amp;quot; &amp;quot;(2006)&amp;quot; &amp;quot;(2006)&amp;quot; &amp;quot;(2002)&amp;quot; &amp;quot;(2000)&amp;quot;
## [41] &amp;quot;(1998)&amp;quot; &amp;quot;(1995)&amp;quot; &amp;quot;(1994)&amp;quot; &amp;quot;(1994)&amp;quot; &amp;quot;(1991)&amp;quot; &amp;quot;(1988)&amp;quot; &amp;quot;(1988)&amp;quot; &amp;quot;(1985)&amp;quot;
## [49] &amp;quot;(1968)&amp;quot; &amp;quot;(1963)&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you look at the output, the year is enclosed in round brackets and is a
character vector. We need to do 2 things now:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;remove the round bracket&lt;/li&gt;
&lt;li&gt;convert year to class &lt;code&gt;Date&lt;/code&gt; instead of character&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We will use &lt;code&gt;str_sub()&lt;/code&gt; to extract the year and convert it to &lt;code&gt;Date&lt;/code&gt; using
&lt;code&gt;as.Date()&lt;/code&gt; with the format &lt;code&gt;%Y&lt;/code&gt;. Finally, we use &lt;code&gt;year()&lt;/code&gt; from &lt;strong&gt;lubridate&lt;/strong&gt;
package to extract the year from the previous step.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;imdb %&amp;gt;%
  html_nodes(&amp;quot;.lister-item-content h3 .lister-item-year&amp;quot;) %&amp;gt;%
  html_text() %&amp;gt;%
  str_sub(start = 2, end = 5) %&amp;gt;%
  as.Date(format = &amp;quot;%Y&amp;quot;) %&amp;gt;%
  year() -&amp;gt; movie_year

movie_year&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] 1994 1972 2008 1974 2003 1994 1993 1957 2010 1999 2001 1994 1966 2002 1999
## [16] 1990 1980 1975 1962 2019 2014 2002 2001 1998 1999 1997 1995 1991 1977 1971
## [31] 1954 1946 2019 2018 2014 2011 2006 2006 2002 2000 1998 1995 1994 1994 1991
## [46] 1988 1988 1985 1968 1963&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;certificate&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Certificate&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/blog_ws_imdb_movie_certificate_border.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The certificate given to the movie can be located in the following way:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt; tag identified by the class &lt;code&gt;.certificate&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;nested inside a paragraph (&lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;part of section identified by the class &lt;code&gt;.lister-item-content&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;imdb %&amp;gt;%
  html_nodes(&amp;quot;.lister-item-content p .certificate&amp;quot;) %&amp;gt;%
  html_text() -&amp;gt; movie_certificate

movie_certificate&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;A&amp;quot;     &amp;quot;A&amp;quot;     &amp;quot;UA&amp;quot;    &amp;quot;A&amp;quot;     &amp;quot;16&amp;quot;    &amp;quot;A&amp;quot;     &amp;quot;A&amp;quot;     &amp;quot;UA&amp;quot;    &amp;quot;A&amp;quot;    
## [10] &amp;quot;U&amp;quot;     &amp;quot;UA&amp;quot;    &amp;quot;A&amp;quot;     &amp;quot;U&amp;quot;     &amp;quot;UA&amp;quot;    &amp;quot;A&amp;quot;     &amp;quot;U&amp;quot;     &amp;quot;A&amp;quot;     &amp;quot;A&amp;quot;    
## [19] &amp;quot;UA&amp;quot;    &amp;quot;A&amp;quot;     &amp;quot;U&amp;quot;     &amp;quot;A&amp;quot;     &amp;quot;UA&amp;quot;    &amp;quot;U&amp;quot;     &amp;quot;A&amp;quot;     &amp;quot;A&amp;quot;     &amp;quot;U&amp;quot;    
## [28] &amp;quot;U&amp;quot;     &amp;quot;U&amp;quot;     &amp;quot;A&amp;quot;     &amp;quot;UA&amp;quot;    &amp;quot;A&amp;quot;     &amp;quot;UA&amp;quot;    &amp;quot;PG-13&amp;quot; &amp;quot;A&amp;quot;     &amp;quot;13&amp;quot;   
## [37] &amp;quot;UA&amp;quot;    &amp;quot;R&amp;quot;     &amp;quot;A&amp;quot;     &amp;quot;A&amp;quot;     &amp;quot;U&amp;quot;     &amp;quot;U&amp;quot;     &amp;quot;R&amp;quot;     &amp;quot;UA&amp;quot;    &amp;quot;U&amp;quot;    
## [46] &amp;quot;U&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;runtime&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Runtime&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/blog_ws_imdb_movie_runtime_border.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The runtime of the movie can be located in the following way:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt; tag identified by the class &lt;code&gt;.runtime&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;nested inside a paragraph (&lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;part of section identified by the class &lt;code&gt;.lister-item-content&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;imdb %&amp;gt;%
  html_nodes(&amp;quot;.lister-item-content p .runtime&amp;quot;) %&amp;gt;%
  html_text() &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;142 min&amp;quot; &amp;quot;175 min&amp;quot; &amp;quot;152 min&amp;quot; &amp;quot;202 min&amp;quot; &amp;quot;201 min&amp;quot; &amp;quot;154 min&amp;quot; &amp;quot;195 min&amp;quot;
##  [8] &amp;quot;96 min&amp;quot;  &amp;quot;148 min&amp;quot; &amp;quot;139 min&amp;quot; &amp;quot;178 min&amp;quot; &amp;quot;142 min&amp;quot; &amp;quot;161 min&amp;quot; &amp;quot;179 min&amp;quot;
## [15] &amp;quot;136 min&amp;quot; &amp;quot;146 min&amp;quot; &amp;quot;124 min&amp;quot; &amp;quot;133 min&amp;quot; &amp;quot;133 min&amp;quot; &amp;quot;132 min&amp;quot; &amp;quot;169 min&amp;quot;
## [22] &amp;quot;130 min&amp;quot; &amp;quot;125 min&amp;quot; &amp;quot;169 min&amp;quot; &amp;quot;189 min&amp;quot; &amp;quot;116 min&amp;quot; &amp;quot;127 min&amp;quot; &amp;quot;118 min&amp;quot;
## [29] &amp;quot;121 min&amp;quot; &amp;quot;122 min&amp;quot; &amp;quot;207 min&amp;quot; &amp;quot;130 min&amp;quot; &amp;quot;122 min&amp;quot; &amp;quot;149 min&amp;quot; &amp;quot;106 min&amp;quot;
## [36] &amp;quot;112 min&amp;quot; &amp;quot;130 min&amp;quot; &amp;quot;151 min&amp;quot; &amp;quot;150 min&amp;quot; &amp;quot;155 min&amp;quot; &amp;quot;119 min&amp;quot; &amp;quot;106 min&amp;quot;
## [43] &amp;quot;110 min&amp;quot; &amp;quot;88 min&amp;quot;  &amp;quot;137 min&amp;quot; &amp;quot;155 min&amp;quot; &amp;quot;89 min&amp;quot;  &amp;quot;116 min&amp;quot; &amp;quot;165 min&amp;quot;
## [50] &amp;quot;143 min&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you look at the output, it includes the text &lt;strong&gt;min&lt;/strong&gt; and is of type
&lt;code&gt;character&lt;/code&gt;. We need to do 2 things here:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;remove the text &lt;strong&gt;min&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;convert to type &lt;code&gt;numeric&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We will try the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;use &lt;code&gt;str_split()&lt;/code&gt; to split the result using space as a separator&lt;/li&gt;
&lt;li&gt;extract the first element from the resulting list using &lt;code&gt;map_chr()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;use &lt;code&gt;as.numeric()&lt;/code&gt; to convert to a number&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;imdb %&amp;gt;%
  html_nodes(&amp;quot;.lister-item-content p .runtime&amp;quot;) %&amp;gt;%
  html_text() %&amp;gt;%
  str_split(&amp;quot; &amp;quot;) %&amp;gt;%
  map_chr(1) %&amp;gt;%
  as.numeric() -&amp;gt; movie_runtime

movie_runtime&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] 142 175 152 202 201 154 195  96 148 139 178 142 161 179 136 146 124 133 133
## [20] 132 169 130 125 169 189 116 127 118 121 122 207 130 122 149 106 112 130 151
## [39] 150 155 119 106 110  88 137 155  89 116 165 143&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;genre&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Genre&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/blog_ws_imdb_movie_genre_border.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The genre of the movie can be located in the following way:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt; tag identified by the class &lt;code&gt;.genre&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;nested inside a paragraph (&lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;part of section identified by the class &lt;code&gt;.lister-item-content&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;imdb %&amp;gt;%
  html_nodes(&amp;quot;.lister-item-content p .genre&amp;quot;) %&amp;gt;%
  html_text() &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;\nDrama            &amp;quot;                       
##  [2] &amp;quot;\nCrime, Drama            &amp;quot;                
##  [3] &amp;quot;\nAction, Crime, Drama            &amp;quot;        
##  [4] &amp;quot;\nCrime, Drama            &amp;quot;                
##  [5] &amp;quot;\nAdventure, Drama, Fantasy            &amp;quot;   
##  [6] &amp;quot;\nCrime, Drama            &amp;quot;                
##  [7] &amp;quot;\nBiography, Drama, History            &amp;quot;   
##  [8] &amp;quot;\nCrime, Drama            &amp;quot;                
##  [9] &amp;quot;\nAction, Adventure, Sci-Fi            &amp;quot;   
## [10] &amp;quot;\nDrama            &amp;quot;                       
## [11] &amp;quot;\nAction, Adventure, Drama            &amp;quot;    
## [12] &amp;quot;\nDrama, Romance            &amp;quot;              
## [13] &amp;quot;\nWestern            &amp;quot;                     
## [14] &amp;quot;\nAdventure, Drama, Fantasy            &amp;quot;   
## [15] &amp;quot;\nAction, Sci-Fi            &amp;quot;              
## [16] &amp;quot;\nBiography, Crime, Drama            &amp;quot;     
## [17] &amp;quot;\nAction, Adventure, Fantasy            &amp;quot;  
## [18] &amp;quot;\nDrama            &amp;quot;                       
## [19] &amp;quot;\nAction, Drama, History            &amp;quot;      
## [20] &amp;quot;\nComedy, Drama, Thriller            &amp;quot;     
## [21] &amp;quot;\nAdventure, Drama, Sci-Fi            &amp;quot;    
## [22] &amp;quot;\nCrime, Drama            &amp;quot;                
## [23] &amp;quot;\nAnimation, Adventure, Family            &amp;quot;
## [24] &amp;quot;\nDrama, War            &amp;quot;                  
## [25] &amp;quot;\nCrime, Drama, Fantasy            &amp;quot;       
## [26] &amp;quot;\nComedy, Drama, Romance            &amp;quot;      
## [27] &amp;quot;\nCrime, Drama, Mystery            &amp;quot;       
## [28] &amp;quot;\nCrime, Drama, Thriller            &amp;quot;      
## [29] &amp;quot;\nAction, Adventure, Fantasy            &amp;quot;  
## [30] &amp;quot;\nDrama, Musical            &amp;quot;              
## [31] &amp;quot;\nAction, Adventure, Drama            &amp;quot;    
## [32] &amp;quot;\nDrama, Family, Fantasy            &amp;quot;      
## [33] &amp;quot;\nCrime, Drama, Thriller            &amp;quot;      
## [34] &amp;quot;\nAction, Adventure, Sci-Fi            &amp;quot;   
## [35] &amp;quot;\nDrama, Music            &amp;quot;                
## [36] &amp;quot;\nBiography, Comedy, Drama            &amp;quot;    
## [37] &amp;quot;\nDrama, Mystery, Sci-Fi            &amp;quot;      
## [38] &amp;quot;\nCrime, Drama, Thriller            &amp;quot;      
## [39] &amp;quot;\nBiography, Drama, Music            &amp;quot;     
## [40] &amp;quot;\nAction, Adventure, Drama            &amp;quot;    
## [41] &amp;quot;\nDrama            &amp;quot;                       
## [42] &amp;quot;\nCrime, Mystery, Thriller            &amp;quot;    
## [43] &amp;quot;\nAction, Crime, Drama            &amp;quot;        
## [44] &amp;quot;\nAnimation, Adventure, Drama            &amp;quot; 
## [45] &amp;quot;\nAction, Sci-Fi            &amp;quot;              
## [46] &amp;quot;\nDrama            &amp;quot;                       
## [47] &amp;quot;\nAnimation, Drama, War            &amp;quot;       
## [48] &amp;quot;\nAdventure, Comedy, Sci-Fi            &amp;quot;   
## [49] &amp;quot;\nWestern            &amp;quot;                     
## [50] &amp;quot;\nCrime, Drama, Mystery            &amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The output includes &lt;code&gt;\n&lt;/code&gt; and white space, both of which will be removed using
&lt;code&gt;str_trim()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;imdb %&amp;gt;%
  html_nodes(&amp;quot;.lister-item-content p .genre&amp;quot;) %&amp;gt;%
  html_text() %&amp;gt;%
  str_trim() -&amp;gt; movie_genre

movie_genre&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;Drama&amp;quot;                        &amp;quot;Crime, Drama&amp;quot;                
##  [3] &amp;quot;Action, Crime, Drama&amp;quot;         &amp;quot;Crime, Drama&amp;quot;                
##  [5] &amp;quot;Adventure, Drama, Fantasy&amp;quot;    &amp;quot;Crime, Drama&amp;quot;                
##  [7] &amp;quot;Biography, Drama, History&amp;quot;    &amp;quot;Crime, Drama&amp;quot;                
##  [9] &amp;quot;Action, Adventure, Sci-Fi&amp;quot;    &amp;quot;Drama&amp;quot;                       
## [11] &amp;quot;Action, Adventure, Drama&amp;quot;     &amp;quot;Drama, Romance&amp;quot;              
## [13] &amp;quot;Western&amp;quot;                      &amp;quot;Adventure, Drama, Fantasy&amp;quot;   
## [15] &amp;quot;Action, Sci-Fi&amp;quot;               &amp;quot;Biography, Crime, Drama&amp;quot;     
## [17] &amp;quot;Action, Adventure, Fantasy&amp;quot;   &amp;quot;Drama&amp;quot;                       
## [19] &amp;quot;Action, Drama, History&amp;quot;       &amp;quot;Comedy, Drama, Thriller&amp;quot;     
## [21] &amp;quot;Adventure, Drama, Sci-Fi&amp;quot;     &amp;quot;Crime, Drama&amp;quot;                
## [23] &amp;quot;Animation, Adventure, Family&amp;quot; &amp;quot;Drama, War&amp;quot;                  
## [25] &amp;quot;Crime, Drama, Fantasy&amp;quot;        &amp;quot;Comedy, Drama, Romance&amp;quot;      
## [27] &amp;quot;Crime, Drama, Mystery&amp;quot;        &amp;quot;Crime, Drama, Thriller&amp;quot;      
## [29] &amp;quot;Action, Adventure, Fantasy&amp;quot;   &amp;quot;Drama, Musical&amp;quot;              
## [31] &amp;quot;Action, Adventure, Drama&amp;quot;     &amp;quot;Drama, Family, Fantasy&amp;quot;      
## [33] &amp;quot;Crime, Drama, Thriller&amp;quot;       &amp;quot;Action, Adventure, Sci-Fi&amp;quot;   
## [35] &amp;quot;Drama, Music&amp;quot;                 &amp;quot;Biography, Comedy, Drama&amp;quot;    
## [37] &amp;quot;Drama, Mystery, Sci-Fi&amp;quot;       &amp;quot;Crime, Drama, Thriller&amp;quot;      
## [39] &amp;quot;Biography, Drama, Music&amp;quot;      &amp;quot;Action, Adventure, Drama&amp;quot;    
## [41] &amp;quot;Drama&amp;quot;                        &amp;quot;Crime, Mystery, Thriller&amp;quot;    
## [43] &amp;quot;Action, Crime, Drama&amp;quot;         &amp;quot;Animation, Adventure, Drama&amp;quot; 
## [45] &amp;quot;Action, Sci-Fi&amp;quot;               &amp;quot;Drama&amp;quot;                       
## [47] &amp;quot;Animation, Drama, War&amp;quot;        &amp;quot;Adventure, Comedy, Sci-Fi&amp;quot;   
## [49] &amp;quot;Western&amp;quot;                      &amp;quot;Crime, Drama, Mystery&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;rating&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Rating&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/blog_ws_imdb_movie_rating_border.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The rating of the movie can be located in the following way:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;part of the section identified by the class &lt;code&gt;.ratings-imdb-rating&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;nested within the section identified by the class &lt;code&gt;.ratings-bar&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;the rating is present within the &lt;code&gt;&amp;lt;strong&amp;gt;&lt;/code&gt; tag as well as in the
&lt;code&gt;data-value&lt;/code&gt; attribute&lt;/li&gt;
&lt;li&gt;instead of using &lt;code&gt;html_text()&lt;/code&gt;, we will use &lt;code&gt;html_attr()&lt;/code&gt; to extract the
value of the attribute &lt;code&gt;data-value&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Try using &lt;code&gt;html_text()&lt;/code&gt; and see what happens! You may include the &lt;code&gt;&amp;lt;strong&amp;gt;&lt;/code&gt; tag
or the classes associated with &lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt; tag as well.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;imdb %&amp;gt;%
  html_nodes(&amp;quot;.ratings-bar .ratings-imdb-rating&amp;quot;) %&amp;gt;%
  html_attr(&amp;quot;data-value&amp;quot;) &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;9.3&amp;quot; &amp;quot;9.2&amp;quot; &amp;quot;9&amp;quot;   &amp;quot;9&amp;quot;   &amp;quot;8.9&amp;quot; &amp;quot;8.9&amp;quot; &amp;quot;8.9&amp;quot; &amp;quot;8.9&amp;quot; &amp;quot;8.8&amp;quot; &amp;quot;8.8&amp;quot; &amp;quot;8.8&amp;quot; &amp;quot;8.8&amp;quot;
## [13] &amp;quot;8.8&amp;quot; &amp;quot;8.7&amp;quot; &amp;quot;8.7&amp;quot; &amp;quot;8.7&amp;quot; &amp;quot;8.7&amp;quot; &amp;quot;8.7&amp;quot; &amp;quot;8.7&amp;quot; &amp;quot;8.6&amp;quot; &amp;quot;8.6&amp;quot; &amp;quot;8.6&amp;quot; &amp;quot;8.6&amp;quot; &amp;quot;8.6&amp;quot;
## [25] &amp;quot;8.6&amp;quot; &amp;quot;8.6&amp;quot; &amp;quot;8.6&amp;quot; &amp;quot;8.6&amp;quot; &amp;quot;8.6&amp;quot; &amp;quot;8.6&amp;quot; &amp;quot;8.6&amp;quot; &amp;quot;8.6&amp;quot; &amp;quot;8.5&amp;quot; &amp;quot;8.5&amp;quot; &amp;quot;8.5&amp;quot; &amp;quot;8.5&amp;quot;
## [37] &amp;quot;8.5&amp;quot; &amp;quot;8.5&amp;quot; &amp;quot;8.5&amp;quot; &amp;quot;8.5&amp;quot; &amp;quot;8.5&amp;quot; &amp;quot;8.5&amp;quot; &amp;quot;8.5&amp;quot; &amp;quot;8.5&amp;quot; &amp;quot;8.5&amp;quot; &amp;quot;8.5&amp;quot; &amp;quot;8.5&amp;quot; &amp;quot;8.5&amp;quot;
## [49] &amp;quot;8.5&amp;quot; &amp;quot;8.5&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Since rating is returned as a character vector, we will use &lt;code&gt;as.numeric()&lt;/code&gt; to
convert it into a number.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;imdb %&amp;gt;%
  html_nodes(&amp;quot;.ratings-bar .ratings-imdb-rating&amp;quot;) %&amp;gt;%
  html_attr(&amp;quot;data-value&amp;quot;) %&amp;gt;% 
  as.numeric() -&amp;gt; movie_rating

movie_rating&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] 9.3 9.2 9.0 9.0 8.9 8.9 8.9 8.9 8.8 8.8 8.8 8.8 8.8 8.7 8.7 8.7 8.7 8.7 8.7
## [20] 8.6 8.6 8.6 8.6 8.6 8.6 8.6 8.6 8.6 8.6 8.6 8.6 8.6 8.5 8.5 8.5 8.5 8.5 8.5
## [39] 8.5 8.5 8.5 8.5 8.5 8.5 8.5 8.5 8.5 8.5 8.5 8.5&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;p&gt;&lt;a href=&#34;https://apps.rsquaredacademy.com/&#34; target=&#34;_blank&#34;&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/ad_apps.png&#34; width=&#34;100%&#34; alt=&#34;apps ad&#34; style=&#34;text-decoration: none;&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;/div&gt;
&lt;div id=&#34;xpath&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;XPATH&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/blog_ws_html_xpath_border.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;To extract votes from the web page, we will use a different technique. In this
case, we will use &lt;strong&gt;xpath&lt;/strong&gt; and &lt;strong&gt;attributes&lt;/strong&gt; to locate the total number of
votes received by the top 50 movies.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;xpath&lt;/strong&gt; is specified using the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;tab&lt;/li&gt;
&lt;li&gt;attribute name&lt;/li&gt;
&lt;li&gt;attribute value&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;votes&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Votes&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/blog_ws_imdb_movie_votes_border.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;
In case of votes, they are the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;meta&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;itemprop&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ratingCount&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Next, we are not looking to extract text value as we did in the previous examples
using &lt;code&gt;html_text()&lt;/code&gt;. Here, we need to extract the value assigned to the
&lt;code&gt;content&lt;/code&gt; attribute within the &lt;code&gt;&amp;lt;meta&amp;gt;&lt;/code&gt; tag using &lt;code&gt;html_attr()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;imdb %&amp;gt;%
  html_nodes(xpath = &amp;#39;//meta[@itemprop=&amp;quot;ratingCount&amp;quot;]&amp;#39;) %&amp;gt;% 
  html_attr(&amp;#39;content&amp;#39;) &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;2249246&amp;quot; &amp;quot;1552001&amp;quot; &amp;quot;2217242&amp;quot; &amp;quot;1084778&amp;quot; &amp;quot;1588695&amp;quot; &amp;quot;1761054&amp;quot; &amp;quot;1168838&amp;quot;
##  [8] &amp;quot;658477&amp;quot;  &amp;quot;1972065&amp;quot; &amp;quot;1788415&amp;quot; &amp;quot;1602475&amp;quot; &amp;quot;1734160&amp;quot; &amp;quot;664323&amp;quot;  &amp;quot;1435345&amp;quot;
## [15] &amp;quot;1613462&amp;quot; &amp;quot;978543&amp;quot;  &amp;quot;1121218&amp;quot; &amp;quot;881910&amp;quot;  &amp;quot;34773&amp;quot;   &amp;quot;424531&amp;quot;  &amp;quot;1422868&amp;quot;
## [22] &amp;quot;679953&amp;quot;  &amp;quot;614374&amp;quot;  &amp;quot;1189533&amp;quot; &amp;quot;1096715&amp;quot; &amp;quot;598021&amp;quot;  &amp;quot;1384558&amp;quot; &amp;quot;1217882&amp;quot;
## [29] &amp;quot;1193648&amp;quot; &amp;quot;26469&amp;quot;   &amp;quot;303892&amp;quot;  &amp;quot;383949&amp;quot;  &amp;quot;806007&amp;quot;  &amp;quot;779460&amp;quot;  &amp;quot;679324&amp;quot; 
## [36] &amp;quot;728348&amp;quot;  &amp;quot;1139520&amp;quot; &amp;quot;1146357&amp;quot; &amp;quot;698328&amp;quot;  &amp;quot;1293047&amp;quot; &amp;quot;1004432&amp;quot; &amp;quot;958513&amp;quot; 
## [43] &amp;quot;995573&amp;quot;  &amp;quot;906648&amp;quot;  &amp;quot;965426&amp;quot;  &amp;quot;218874&amp;quot;  &amp;quot;220345&amp;quot;  &amp;quot;1008251&amp;quot; &amp;quot;290832&amp;quot; 
## [50] &amp;quot;29464&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally, we convert the votes to a number using &lt;code&gt;as.numeric()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;imdb %&amp;gt;%
  html_nodes(xpath = &amp;#39;//meta[@itemprop=&amp;quot;ratingCount&amp;quot;]&amp;#39;) %&amp;gt;% 
  html_attr(&amp;#39;content&amp;#39;) %&amp;gt;% 
  as.numeric() -&amp;gt; movie_votes

movie_votes&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] 2249246 1552001 2217242 1084778 1588695 1761054 1168838  658477 1972065
## [10] 1788415 1602475 1734160  664323 1435345 1613462  978543 1121218  881910
## [19]   34773  424531 1422868  679953  614374 1189533 1096715  598021 1384558
## [28] 1217882 1193648   26469  303892  383949  806007  779460  679324  728348
## [37] 1139520 1146357  698328 1293047 1004432  958513  995573  906648  965426
## [46]  218874  220345 1008251  290832   29464&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;revenue&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Revenue&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/blog_ws_imdb_movie_revenue_border.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;We wanted to extract both revenue and votes without using &lt;strong&gt;xpath&lt;/strong&gt; but the way
in which they are structured in the HTML code forced us to use &lt;strong&gt;xpath&lt;/strong&gt; to
extract votes. If you look at the HTML code, both votes and revenue are located
inside the same tag with the same attribute name and value i.e. there is no
distinct way to identify either of them.&lt;/p&gt;
&lt;p&gt;In case of revenue, the &lt;strong&gt;xpath&lt;/strong&gt; details are as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;name&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;nv&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Next, we will use &lt;code&gt;html_text()&lt;/code&gt; to extract the revenue.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;imdb %&amp;gt;%
  html_nodes(xpath = &amp;#39;//span[@name=&amp;quot;nv&amp;quot;]&amp;#39;) %&amp;gt;%
  html_text() &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;2,249,246&amp;quot; &amp;quot;$28.34M&amp;quot;   &amp;quot;1,552,001&amp;quot; &amp;quot;$134.97M&amp;quot;  &amp;quot;2,217,242&amp;quot; &amp;quot;$534.86M&amp;quot; 
##  [7] &amp;quot;1,084,778&amp;quot; &amp;quot;$57.30M&amp;quot;   &amp;quot;1,588,695&amp;quot; &amp;quot;$377.85M&amp;quot;  &amp;quot;1,761,054&amp;quot; &amp;quot;$107.93M&amp;quot; 
## [13] &amp;quot;1,168,838&amp;quot; &amp;quot;$96.90M&amp;quot;   &amp;quot;658,477&amp;quot;   &amp;quot;$4.36M&amp;quot;    &amp;quot;1,972,065&amp;quot; &amp;quot;$292.58M&amp;quot; 
## [19] &amp;quot;1,788,415&amp;quot; &amp;quot;$37.03M&amp;quot;   &amp;quot;1,602,475&amp;quot; &amp;quot;$315.54M&amp;quot;  &amp;quot;1,734,160&amp;quot; &amp;quot;$330.25M&amp;quot; 
## [25] &amp;quot;664,323&amp;quot;   &amp;quot;$6.10M&amp;quot;    &amp;quot;1,435,345&amp;quot; &amp;quot;$342.55M&amp;quot;  &amp;quot;1,613,462&amp;quot; &amp;quot;$171.48M&amp;quot; 
## [31] &amp;quot;978,543&amp;quot;   &amp;quot;$46.84M&amp;quot;   &amp;quot;1,121,218&amp;quot; &amp;quot;$290.48M&amp;quot;  &amp;quot;881,910&amp;quot;   &amp;quot;$112.00M&amp;quot; 
## [37] &amp;quot;34,773&amp;quot;    &amp;quot;424,531&amp;quot;   &amp;quot;$53.37M&amp;quot;   &amp;quot;1,422,868&amp;quot; &amp;quot;$188.02M&amp;quot;  &amp;quot;679,953&amp;quot;  
## [43] &amp;quot;$7.56M&amp;quot;    &amp;quot;614,374&amp;quot;   &amp;quot;$10.06M&amp;quot;   &amp;quot;1,189,533&amp;quot; &amp;quot;$216.54M&amp;quot;  &amp;quot;1,096,715&amp;quot;
## [49] &amp;quot;$136.80M&amp;quot;  &amp;quot;598,021&amp;quot;   &amp;quot;$57.60M&amp;quot;   &amp;quot;1,384,558&amp;quot; &amp;quot;$100.13M&amp;quot;  &amp;quot;1,217,882&amp;quot;
## [55] &amp;quot;$130.74M&amp;quot;  &amp;quot;1,193,648&amp;quot; &amp;quot;$322.74M&amp;quot;  &amp;quot;26,469&amp;quot;    &amp;quot;303,892&amp;quot;   &amp;quot;$0.27M&amp;quot;   
## [61] &amp;quot;383,949&amp;quot;   &amp;quot;806,007&amp;quot;   &amp;quot;$335.45M&amp;quot;  &amp;quot;779,460&amp;quot;   &amp;quot;$678.82M&amp;quot;  &amp;quot;679,324&amp;quot;  
## [67] &amp;quot;$13.09M&amp;quot;   &amp;quot;728,348&amp;quot;   &amp;quot;$13.18M&amp;quot;   &amp;quot;1,139,520&amp;quot; &amp;quot;$53.09M&amp;quot;   &amp;quot;1,146,357&amp;quot;
## [73] &amp;quot;$132.38M&amp;quot;  &amp;quot;698,328&amp;quot;   &amp;quot;$32.57M&amp;quot;   &amp;quot;1,293,047&amp;quot; &amp;quot;$187.71M&amp;quot;  &amp;quot;1,004,432&amp;quot;
## [79] &amp;quot;$6.72M&amp;quot;    &amp;quot;958,513&amp;quot;   &amp;quot;$23.34M&amp;quot;   &amp;quot;995,573&amp;quot;   &amp;quot;$19.50M&amp;quot;   &amp;quot;906,648&amp;quot;  
## [85] &amp;quot;$422.78M&amp;quot;  &amp;quot;965,426&amp;quot;   &amp;quot;$204.84M&amp;quot;  &amp;quot;218,874&amp;quot;   &amp;quot;$11.99M&amp;quot;   &amp;quot;220,345&amp;quot;  
## [91] &amp;quot;1,008,251&amp;quot; &amp;quot;$210.61M&amp;quot;  &amp;quot;290,832&amp;quot;   &amp;quot;$5.32M&amp;quot;    &amp;quot;29,464&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To extract the revenue as a number, we need to do some string hacking as
follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;extract values that begin with &lt;code&gt;$&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;omit missing values&lt;/li&gt;
&lt;li&gt;convert values to character using &lt;code&gt;as.character()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;append NA where revenue is missing (rank 31 and 47)&lt;/li&gt;
&lt;li&gt;remove &lt;code&gt;$&lt;/code&gt; and &lt;code&gt;M&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;convert to number using &lt;code&gt;as.numeric()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;imdb %&amp;gt;%
  html_nodes(xpath = &amp;#39;//span[@name=&amp;quot;nv&amp;quot;]&amp;#39;) %&amp;gt;%
  html_text() %&amp;gt;%
  str_extract(pattern = &amp;quot;^\\$.*&amp;quot;) %&amp;gt;%
  na.omit() %&amp;gt;%
  as.character() %&amp;gt;%
  append(values = NA, after = 18) %&amp;gt;%
  append(values = NA, after = 29) %&amp;gt;%
  append(values = NA, after = 31) %&amp;gt;%
  append(values = NA, after = 46) %&amp;gt;%
  append(values = NA, after = 49) %&amp;gt;%
  str_sub(start = 2, end = nchar(.) - 1) %&amp;gt;%
  as.numeric() -&amp;gt; movie_revenue

movie_revenue&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  28.34 134.97 534.86  57.30 377.85 107.93  96.90   4.36 292.58  37.03
## [11] 315.54 330.25   6.10 342.55 171.48  46.84 290.48 112.00     NA  53.37
## [21] 188.02   7.56  10.06 216.54 136.80  57.60 100.13 130.74 322.74     NA
## [31]   0.27     NA 335.45 678.82  13.09  13.18  53.09 132.38  32.57 187.71
## [41]   6.72  23.34  19.50 422.78 204.84  11.99     NA 210.61   5.32     NA&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;putting-it-all-together&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Putting it all together…&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;top_50 &amp;lt;- tibble(title = movie_title, release = movie_year, 
    `runtime (mins)` = movie_runtime, genre = movie_genre, rating = movie_rating, 
    votes = movie_votes, `revenue ($ millions)` = movie_revenue)

top_50&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 50 x 7
##    title       release `runtime (mins)` genre    rating   votes `revenue ($ mil~
##    &amp;lt;chr&amp;gt;         &amp;lt;dbl&amp;gt;            &amp;lt;dbl&amp;gt; &amp;lt;chr&amp;gt;     &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;            &amp;lt;dbl&amp;gt;
##  1 The Shawsh~    1994              142 Drama       9.3 2249246            28.3 
##  2 The Godfat~    1972              175 Crime, ~    9.2 1552001           135.  
##  3 The Dark K~    2008              152 Action,~    9   2217242           535.  
##  4 The Godfat~    1974              202 Crime, ~    9   1084778            57.3 
##  5 The Lord o~    2003              201 Adventu~    8.9 1588695           378.  
##  6 Pulp Ficti~    1994              154 Crime, ~    8.9 1761054           108.  
##  7 Schindler&amp;#39;~    1993              195 Biograp~    8.9 1168838            96.9 
##  8 12 Angry M~    1957               96 Crime, ~    8.9  658477             4.36
##  9 Inception      2010              148 Action,~    8.8 1972065           293.  
## 10 Fight Club     1999              139 Drama       8.8 1788415            37.0 
## # ... with 40 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;p&gt;&lt;a href=&#34;https://pkgs.rsquaredacademy.com/&#34; target=&#34;_blank&#34;&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/ad_packages.png&#34; width=&#34;100%&#34; alt=&#34;packages ad&#34; style=&#34;text-decoration: none;&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;top-websites&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Top Websites&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Unfortunately, we had to drop this case study as the HTML code changed while we
were working on this blog post. Remember, the third point we mentioned in the
things to keep in mind, where we had warned that the design or underlying HTML
code of the website may change. It just happened as we were finalizing this
post.&lt;/strong&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;rbi-governors&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;RBI Governors&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/blog_ws_rbi_governors_border.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In this case study, we are going to extract the list of
RBI (Reserve Bank of India) Governors. The author of this blog post comes from
an Economics background and as such was intereseted in knowing the professional
background of the Governors prior to their taking charge at India’s central
bank. We will extact the following details:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;name&lt;/li&gt;
&lt;li&gt;start of term&lt;/li&gt;
&lt;li&gt;end of term&lt;/li&gt;
&lt;li&gt;term (in days)&lt;/li&gt;
&lt;li&gt;background&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;robotstxt-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;robotstxt&lt;/h3&gt;
&lt;p&gt;Let us check if we can scrape the data from Wikipedia website using
&lt;code&gt;paths_allowed()&lt;/code&gt; from &lt;strong&gt;robotstxt&lt;/strong&gt; package.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;paths_allowed(
  paths = c(&amp;quot;https://en.wikipedia.org/wiki/List_of_Governors_of_Reserve_Bank_of_India&amp;quot;)
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
 en.wikipedia.org&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Since it has returned &lt;code&gt;TRUE&lt;/code&gt;, we will go ahead and download the web page using
&lt;code&gt;read_html()&lt;/code&gt; from &lt;strong&gt;xml2&lt;/strong&gt; package.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rbi_guv &amp;lt;- read_html(&amp;quot;https://en.wikipedia.org/wiki/List_of_Governors_of_Reserve_Bank_of_India&amp;quot;)
rbi_guv&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## {html_document}
## &amp;lt;html class=&amp;quot;client-nojs&amp;quot; lang=&amp;quot;en&amp;quot; dir=&amp;quot;ltr&amp;quot;&amp;gt;
## [1] &amp;lt;head&amp;gt;\n&amp;lt;meta http-equiv=&amp;quot;Content-Type&amp;quot; content=&amp;quot;text/html; charset=UTF-8 ...
## [2] &amp;lt;body class=&amp;quot;mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject  ...&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;list-of-governors&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;List of Governors&lt;/h3&gt;
&lt;p&gt;The data in the Wikipedia page is luckily structured as a table and we can
extract it using &lt;code&gt;html_table()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rbi_guv %&amp;gt;%
  html_nodes(&amp;quot;table&amp;quot;) %&amp;gt;%
  html_table() &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [[1]]
##                                             Governor of the Reserve Bank of India
## 1 IncumbentShaktikanta Das, IASsince 12 December 2018; 17 months ago (2018-12-12)
## 2                                                                       Appointer
## 3                                                                     Term length
## 4                                                         Constituting instrument
## 5                                                                Inaugural holder
## 6                                                                       Formation
## 7                                                                          Deputy
## 8                                                                          Salary
## 9                                                                         Website
##                                             Governor of the Reserve Bank of India
## 1 IncumbentShaktikanta Das, IASsince 12 December 2018; 17 months ago (2018-12-12)
## 2                                                              President of India
## 3                                                                     Three years
## 4                                                 Reserve Bank of India Act, 1934
## 5                                                       Osborne Smith (1935–1937)
## 6                                         1 April 1935; 85 years ago (1935-04-01)
## 7                                   Deputy Governors of the Reserve Bank of India
## 8                                                               &amp;lt;U+20B9&amp;gt; 2,50,000
## 9                                                                      rbi.org.in
## 
## [[2]]
##    No.         Officeholder Portrait        Term start          Term end
## 1    1        Osborne Smith       NA      1 April 1935      30 June 1937
## 2    2   James Braid Taylor       NA       1 July 1937  17 February 1943
## 3    3       C. D. Deshmukh       NA    11 August 1943      30 June 1949
## 4    4     Benegal Rama Rau       NA       1 July 1949   14 January 1957
## 5    5    K. G. Ambegaonkar       NA   14 January 1957  28 February 1957
## 6    6     H. V. R. Iyengar       NA      1 March 1957  28 February 1962
## 7    7   P. C. Bhattacharya       NA      1 March 1962      30 June 1967
## 8    8     Lakshmi Kant Jha       NA       1 July 1967        3 May 1970
## 9    9        B. N. Adarkar       NA        4 May 1970      15 June 1970
## 10  10 Sarukkai Jagannathan       NA      16 June 1970       19 May 1975
## 11  11      N. C. Sen Gupta       NA       19 May 1975    19 August 1975
## 12  12           K. R. Puri       NA    20 August 1975        2 May 1977
## 13  13        M. Narasimham       NA        3 May 1977  30 November 1977
## 14  14          I. G. Patel       NA   1 December 1977 15 September 1982
## 15  15       Manmohan Singh       NA 16 September 1982   14 January 1985
## 16  16         Amitav Ghosh       NA   15 January 1985   4 February 1985
## 17  17       R. N. Malhotra       NA   4 February 1985  22 December 1990
## 18  18    S. Venkitaramanan       NA  22 December 1990  21 December 1992
## 19  19        C. Rangarajan       NA  22 December 1992  21 November 1997
## 20  20          Bimal Jalan       NA  22 November 1997  6 September 2003
## 21  21   Y. Venugopal Reddy       NA  6 September 2003  5 September 2008
## 22  22          D. Subbarao       NA  5 September 2008  4 September 2013
## 23  23       Raghuram Rajan       NA  4 September 2013  4 September 2016
## 24  24          Urjit Patel       NA  4 September 2016  11 December 2018
## 25  25      Shaktikanta Das       NA  12 December 2018         Incumbent
##    Term in office                                  Background
## 1        821 days                                      Banker
## 2       2057 days          Indian Civil Service (ICS) officer
## 3       2150 days                                 ICS officer
## 4       2754 days                                 ICS officer
## 5         45 days                                 ICS officer
## 6       1825 days                                 ICS officer
## 7       1947 days   Indian Audit and Accounts Service officer
## 8       1037 days                                 ICS officer
## 9         42 days                                   Economist
## 10      1798 days                                 ICS officer
## 11        92 days                                 ICS officer
## 12       621 days                                            
## 13       211 days        Career Reserve Bank of India officer
## 14      1749 days                                   Economist
## 15       851 days                                   Economist
## 16        20 days                                      Banker
## 17      2147 days Indian Administrative Service (IAS) officer
## 18       730 days                                 IAS officer
## 19      1795 days                                   Economist
## 20      2114 days                                   Economist
## 21      1826 days                                 IAS officer
## 22      1825 days                                 IAS officer
## 23      1096 days                                   Economist
## 24       828 days                                   Economist
## 25       540 days                                 IAS officer
##                                                                                                                                                      Prior office(s)
## 1                                                                                                                    Managing Governor of the Imperial Bank of India
## 2                                                                                             Deputy Governor of the Reserve Bank of India\n\nController of Currency
## 3                                                                                          Deputy Governor of the Reserve Bank of India\nCustodian of Enemy Property
## 4                                                          Ambassador of India to the United States\n\nAmbassador of India to Japan\n\nChairman of Bombay Port Trust
## 5                                                                                                                                                  Finance Secretary
## 6                                                                                                                                Chairman of the State Bank of India
## 7                                                                                          Chairman of the State Bank of India\nSecretary in the Ministry of Finance
## 8                                                                                                                           Secretary to the Prime Minister of India
## 9                                                                                                              Executive Director at the International Monetary Fund
## 10                                                                                                                              Executive Director at the World Bank
## 11                                                                                                                                                 Banking Secretary
## 12                                                                                                  Chairman and Managing Director of the Life Insurance Corporation
## 13                                                                                                                      Deputy Governor of the Reserve Bank of India
## 14 Director of the London School of Economics\n\nDeputy Administrator of the United Nations Development Programme\nChief Economic Adviser to the Government of India
## 15                                                                         Secretary in the Ministry of Finance\n\nChief Economic Adviser to the Government of India
## 16                                                                                    Deputy Governor of the Reserve Bank of India\n\nChairman of the Allahabad Bank
## 17                                                                                        Finance Secretary\n\nExecutive Director at the International Monetary Fund
## 18                                                                                                                                                 Finance Secretary
## 19                                                                                                                      Deputy Governor of the Reserve Bank of India
## 20                                                                       Finance Secretary\n\nBanking Secretary\n\nChief Economic Adviser to the Government of India
## 21                                                             Executive Director at the International Monetary Fund\n\nDeputy Governor of the Reserve Bank of India
## 22                                                                           Finance Secretary\n\nMember-Secretary of the Prime Minister&amp;#39;s Economic Advisory Council
## 23                                                                 Chief Economic Adviser to the Government of India\nChief Economist of International Monetary Fund
## 24                                                                                                                               Deputy Governor of the Reserve Bank
## 25                                             Member of the Fifteenth Finance Commission\nSherpa of India to the G20\nEconomic Affairs Secretary\nRevenue Secretary
##    Reference(s)
## 1           [2]
## 2           [3]
## 3              
## 4              
## 5              
## 6              
## 7              
## 8              
## 9              
## 10             
## 11             
## 12             
## 13             
## 14             
## 15             
## 16             
## 17             
## 18             
## 19             
## 20             
## 21             
## 22             
## 23             
## 24             
## 25    [4][5][6]
## 
## [[3]]
##   vte Governors of the Reserve Bank of India
## 1                                         NA
##                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      vte Governors of the Reserve Bank of India
## 1 Osborne Smith (1935–37)\nJames Braid Taylor (1937–43)\nC. D. Deshmukh (1943–49)\nBenegal Rama Rau (1949–57)\nK. G. Ambegaonkar (1957)\nH. V. R. Iyengar (1957–62)\nP. C. Bhattacharya (1962–67)\nLakshmi Kant Jha (1967–70)\nB. N. Adarkar (1970)\nS. Jagannathan (1970–75)\nN. C. Sen Gupta (1975)\nK. R. Puri (1975–77)\nM. Narasimham (1977)\nI. G. Patel (1977–82)\nManmohan Singh (1982–85)\nAmitav Ghosh (1985)\nR. N. Malhotra (1985–90)\nS. Venkitaramanan (1990–92)\nC. Rangarajan (1992–97)\nBimal Jalan (1997–2003)\nY. Venugopal Reddy (2003–08)\nDuvvuri Subbarao (2008–13)\nRaghuram Rajan (2013–16)\nUrjit Patel (2016–2018)\nShaktikanta Das (2018–Incumbent)
##                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      vte Governors of the Reserve Bank of India
## 1 Osborne Smith (1935–37)\nJames Braid Taylor (1937–43)\nC. D. Deshmukh (1943–49)\nBenegal Rama Rau (1949–57)\nK. G. Ambegaonkar (1957)\nH. V. R. Iyengar (1957–62)\nP. C. Bhattacharya (1962–67)\nLakshmi Kant Jha (1967–70)\nB. N. Adarkar (1970)\nS. Jagannathan (1970–75)\nN. C. Sen Gupta (1975)\nK. R. Puri (1975–77)\nM. Narasimham (1977)\nI. G. Patel (1977–82)\nManmohan Singh (1982–85)\nAmitav Ghosh (1985)\nR. N. Malhotra (1985–90)\nS. Venkitaramanan (1990–92)\nC. Rangarajan (1992–97)\nBimal Jalan (1997–2003)\nY. Venugopal Reddy (2003–08)\nDuvvuri Subbarao (2008–13)\nRaghuram Rajan (2013–16)\nUrjit Patel (2016–2018)\nShaktikanta Das (2018–Incumbent)
##   vte Governors of the Reserve Bank of India
## 1                                         NA&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There are 2 tables in the web page and we are interested in the second table.
Using &lt;code&gt;extract2()&lt;/code&gt; from the &lt;strong&gt;magrittr&lt;/strong&gt; package, we will extract the table
containing the details of the Governors.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rbi_guv %&amp;gt;%
  html_nodes(&amp;quot;table&amp;quot;) %&amp;gt;%
  html_table() %&amp;gt;%
  extract2(2) -&amp;gt; profile&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;sort&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Sort&lt;/h3&gt;
&lt;p&gt;Let us arrange the data by number of days served. The &lt;code&gt;Term in office&lt;/code&gt; column
contains this information but it also includes the text days. Let us split this
column into two columns, &lt;code&gt;term&lt;/code&gt; and &lt;code&gt;days&lt;/code&gt;, using &lt;code&gt;separate()&lt;/code&gt; from tidyr and
then select the columns &lt;code&gt;Officeholder&lt;/code&gt; and &lt;code&gt;term&lt;/code&gt; and arrange it in descending
order using &lt;code&gt;desc()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;profile %&amp;gt;%
  separate(`Term in office`, into = c(&amp;quot;term&amp;quot;, &amp;quot;days&amp;quot;)) %&amp;gt;%
  select(Officeholder, term) %&amp;gt;%
  arrange(desc(as.numeric(term)))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##            Officeholder term
## 1      Benegal Rama Rau 2754
## 2        C. D. Deshmukh 2150
## 3        R. N. Malhotra 2147
## 4           Bimal Jalan 2114
## 5    James Braid Taylor 2057
## 6    P. C. Bhattacharya 1947
## 7    Y. Venugopal Reddy 1826
## 8      H. V. R. Iyengar 1825
## 9           D. Subbarao 1825
## 10 Sarukkai Jagannathan 1798
## 11        C. Rangarajan 1795
## 12          I. G. Patel 1749
## 13       Raghuram Rajan 1096
## 14     Lakshmi Kant Jha 1037
## 15       Manmohan Singh  851
## 16          Urjit Patel  828
## 17        Osborne Smith  821
## 18    S. Venkitaramanan  730
## 19           K. R. Puri  621
## 20      Shaktikanta Das  540
## 21        M. Narasimham  211
## 22      N. C. Sen Gupta   92
## 23    K. G. Ambegaonkar   45
## 24        B. N. Adarkar   42
## 25         Amitav Ghosh   20&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;backgrounds&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Backgrounds&lt;/h3&gt;
&lt;p&gt;What we are interested is in the background of the Governors? Use &lt;code&gt;count()&lt;/code&gt;
from &lt;strong&gt;dplyr&lt;/strong&gt; to look at the backgound of the Governors and the respective
counts.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;profile %&amp;gt;%
  count(Background) &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                                    Background n
## 1                                             1
## 2                                      Banker 2
## 3        Career Reserve Bank of India officer 1
## 4                                   Economist 7
## 5                                 IAS officer 4
## 6                                 ICS officer 7
## 7 Indian Administrative Service (IAS) officer 1
## 8   Indian Audit and Accounts Service officer 1
## 9          Indian Civil Service (ICS) officer 1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us club some of the categories into &lt;strong&gt;Bureaucrats&lt;/strong&gt; as they belong to the
Indian Administrative/Civil Services. The missing data will be renamed as &lt;code&gt;No Info&lt;/code&gt;.
The category &lt;code&gt;Career Reserve Bank of India officer&lt;/code&gt; is renamed as &lt;code&gt;RBI Officer&lt;/code&gt;
to make it more concise.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;profile %&amp;gt;%
  pull(Background) %&amp;gt;%
  fct_collapse(
    Bureaucrats = c(&amp;quot;IAS officer&amp;quot;, &amp;quot;ICS officer&amp;quot;,
    &amp;quot;Indian Administrative Service (IAS) officer&amp;quot;,
    &amp;quot;Indian Audit and Accounts Service officer&amp;quot;,
    &amp;quot;Indian Civil Service (ICS) officer&amp;quot;),
    `No Info` = c(&amp;quot;&amp;quot;),
    `RBI Officer` = c(&amp;quot;Career Reserve Bank of India officer&amp;quot;)
  ) %&amp;gt;%
  fct_count() %&amp;gt;%
  rename(background = f, count = n) -&amp;gt; backgrounds

backgrounds&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 5 x 2
##   background  count
##   &amp;lt;fct&amp;gt;       &amp;lt;int&amp;gt;
## 1 No Info         1
## 2 Banker          2
## 3 RBI Officer     1
## 4 Economist       7
## 5 Bureaucrats    14&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Hmmm.. So there were more bureaucrats than economists.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;backgrounds %&amp;gt;%
  ggplot() +
  geom_col(aes(background, count), fill = &amp;quot;blue&amp;quot;) +
  xlab(&amp;quot;Background&amp;quot;) + ylab(&amp;quot;Count&amp;quot;) +
  ggtitle(&amp;quot;Background of RBI Governors&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-04-11-web-scraping_files/figure-html/rbi9-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Summary&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;web scraping is the extraction of data from web sites&lt;/li&gt;
&lt;li&gt;best for static &amp;amp; well structured HTML pages&lt;/li&gt;
&lt;li&gt;review robots.txt file&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;HTML code can change any time&lt;/li&gt;
&lt;li&gt;if API is available, please use it&lt;/li&gt;
&lt;li&gt;do not overwhelm websites with requests&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;To get in depth knowledge of R &amp;amp; data science, you can
&lt;a href=&#34;https://rsquared-academy.thinkific.com/&#34;&gt;enroll here&lt;/a&gt; for our free
online R courses.&lt;/strong&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Shiny Apps for Interactive Data Analysis</title>
      <link>https://blog.rsquaredacademy.com/shiny-apps/</link>
      <pubDate>Mon, 01 Apr 2019 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/shiny-apps/</guid>
      <description>&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/apps_banner.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;We are excited and happy to share a set of &lt;a href=&#34;https://shiny.rstudio.com/&#34; target=&#34;_blank&#34;&gt;shiny&lt;/a&gt;
apps built for interactive data analysis and teaching at &lt;a href=&#34;https://www.rsquaredacademy.com&#34; target=&#34;_blank&#34;&gt;Rsquared Academy&lt;/a&gt;. The apps are part of our &lt;a href=&#34;https://pkgs.rsquaredacademy.com&#34; target=&#34;_blank&#34;&gt;R packages&lt;/a&gt; and presently cover the following topics:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Descriptive Statistics&lt;/li&gt;
&lt;li&gt;Probability Distributions&lt;/li&gt;
&lt;li&gt;Hypothesis Testing&lt;/li&gt;
&lt;li&gt;Linear Regression&lt;/li&gt;
&lt;li&gt;Logistic Regression&lt;/li&gt;
&lt;li&gt;RFM Analysis&lt;/li&gt;
&lt;li&gt;Data Visualization&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We would suggest that you explore the apps using sample data sets available
within the app before using your own data set so that you get comfortable
with the user interface.&lt;/p&gt;
&lt;div id=&#34;demo&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Demo&lt;/h2&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/7lBEqrZLUOU&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;/div&gt;
&lt;div id=&#34;details&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Details&lt;/h2&gt;
&lt;p&gt;You can try the live version of the apps
&lt;a href=&#34;https://apps.rsquaredacademy.com&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt; or
locally launch these apps from the R packages mentioned in the below table.
&lt;strong&gt;It will be easier to use the apps if you refer to the documentation of
the respective packages.&lt;/strong&gt;&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th&gt;Topic&lt;/th&gt;
&lt;th&gt;Try App&lt;/th&gt;
&lt;th&gt;R Package&lt;/th&gt;
&lt;th&gt;API&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td&gt;Descriptive Statistics&lt;/td&gt;
&lt;td&gt;&lt;a href=&#34;https://www.rsquaredcomputing.com/shiny/olsrr/&#34; target=&#34;_blank&#34;&gt;Launch&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href=&#34;https://descriptr.rsquaredacademy.com/&#34; target=&#34;_blank&#34;&gt;descritpr&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ds_launch_shiny_app()&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td&gt;Visualize Distributions&lt;/td&gt;
&lt;td&gt;&lt;a href=&#34;https://www.rsquaredcomputing.com/shiny/vistributions/&#34; target=&#34;_blank&#34;&gt;Launch&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href=&#34;https://vistributions.rsquaredacademy.com/&#34; target=&#34;_blank&#34;&gt;vistributions&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;vdist_launch_app()&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td&gt;Hypothesis Testing&lt;/td&gt;
&lt;td&gt;&lt;a href=&#34;https://www.rsquaredcomputing.com/shiny/inferr/&#34; target=&#34;_blank&#34;&gt;Launch&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href=&#34;https://inferr.rsquaredacademy.com/&#34; target=&#34;_blank&#34;&gt;inferr&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;infer_launch_shiny_app()&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td&gt;Linear Regression&lt;/td&gt;
&lt;td&gt;&lt;a href=&#34;https://www.rsquaredcomputing.com/shiny/olsrr/&#34; target=&#34;_blank&#34;&gt;Launch&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href=&#34;https://olsrr.rsquaredacademy.com/&#34; target=&#34;_blank&#34;&gt;olsrr&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ols_launch_app()&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td&gt;Logistic Regression&lt;/td&gt;
&lt;td&gt;&lt;a href=&#34;https://www.rsquaredcomputing.com/shiny/blorr/&#34; target=&#34;_blank&#34;&gt;Launch&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href=&#34;https://blorr.rsquaredacademy.com/&#34; target=&#34;_blank&#34;&gt;blorr&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;blr_launch_app()&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td&gt;RFM Analysis&lt;/td&gt;
&lt;td&gt;&lt;a href=&#34;https://www.rsquaredcomputing.com/shiny/rfm/&#34; target=&#34;_blank&#34;&gt;Launch&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href=&#34;https://rfm.rsquaredacademy.com/&#34; target=&#34;_blank&#34;&gt;rfm&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;rfm_launch_app()&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td&gt;Data Visualization&lt;/td&gt;
&lt;td&gt;&lt;a href=&#34;https://www.rsquaredcomputing.com/shiny/xplorerr/&#34; target=&#34;_blank&#34;&gt;Launch&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href=&#34;https://xplorerr.rsquaredacademy.com/&#34; target=&#34;_blank&#34;&gt;xplorerr&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;app_visualizer()&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;div id=&#34;feedback&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Feedback&lt;/h2&gt;
&lt;p&gt;All feedback is welcome. Issues (bugs and feature requests) can be posted to
&lt;a href=&#34;https://github.com/rsquaredacademy/xplorerr/issues&#34;&gt;github tracker&lt;/a&gt;. For help
with code or other related questions, feel free to reach out to us
at &lt;a href=&#34;mailto:pkgs@rsquaredacademy.com&#34; class=&#34;email&#34;&gt;pkgs@rsquaredacademy.com&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Visually explore Probability Distributions with vistributions</title>
      <link>https://blog.rsquaredacademy.com/introducting-vistributions/</link>
      <pubDate>Thu, 14 Mar 2019 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/introducting-vistributions/</guid>
      <description>&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/vistributions_banner.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;We are happy to introduce the &lt;strong&gt;vistributions&lt;/strong&gt; package, a set of tools for
visually exploring probability distributions.&lt;/p&gt;
&lt;div id=&#34;installation&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Installation&lt;/h2&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Install release version from CRAN
install.packages(&amp;quot;vistributions&amp;quot;)

# Install development version from GitHub
# install.packages(&amp;quot;devtools&amp;quot;)
devtools::install_github(&amp;quot;rsquaredacademy/vistributions&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;shiny-app&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Shiny App&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;vistributions&lt;/strong&gt; includes a shiny app which can be launched using&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_launch_app()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or try the live version &lt;a href=&#34;https://www.rsquaredcomputing.com/shiny/vistributions/&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/Wa44jxAJvTE&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;p&gt;Read on to learn more about the features of &lt;strong&gt;vistributions&lt;/strong&gt;, or see the
&lt;a href=&#34;https://vistributions.rsquaredacademy.com/&#34;&gt;vistributions website&lt;/a&gt; for
detailed documentation on using the package.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;tab-completion&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Tab Completion&lt;/h2&gt;
&lt;p&gt;The common &lt;code&gt;vdist_&lt;/code&gt; prefix will trigger autocomplete, allowing you to see all
&lt;strong&gt;vistributions&lt;/strong&gt; functions:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/tab_gif.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In exploring statistical distributions, we focus on the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;what influences the shape of a distribution&lt;/li&gt;
&lt;li&gt;calculate probability from a given quantile&lt;/li&gt;
&lt;li&gt;calculate quantiles out of given probability&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;for the following distributions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Normal&lt;/li&gt;
&lt;li&gt;Binomial&lt;/li&gt;
&lt;li&gt;Chi Square&lt;/li&gt;
&lt;li&gt;F&lt;/li&gt;
&lt;li&gt;t&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;normal-distribution&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Normal Distribution&lt;/h2&gt;
&lt;div id=&#34;distribution-shape&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Distribution Shape&lt;/h3&gt;
&lt;p&gt;Visualize how changes in mean and standard deviation affect the shape of the
normal distribution.&lt;/p&gt;
&lt;div id=&#34;input&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Input&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;mean: mean of the normal distribution&lt;/li&gt;
&lt;li&gt;sd: standard deviation of the normal distribution&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_normal_plot(mean = 2, sd = 0.6)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/norm_plot-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;percentiles&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Percentiles&lt;/h3&gt;
&lt;div id=&#34;calculate-and-visualize-quantiles-out-of-given-probability.&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Calculate and visualize quantiles out of given probability.&lt;/h4&gt;
&lt;div id=&#34;input-1&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Input&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;probs: a probability value&lt;/li&gt;
&lt;li&gt;mean: mean of the normal distribution&lt;/li&gt;
&lt;li&gt;sd: standard deviation of the normal distribution&lt;/li&gt;
&lt;li&gt;type: lower/upper tail&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Suppose X, the grade on a exam, is normally distributed with mean 60
and standard deviation 3. The teacher wants to give 10% of the class an A.
What should be the cutoff to determine who gets an A?&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_normal_perc(0.10, 60, 3, &amp;#39;upper&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/norm_per1-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The teacher wants to give lower 15% of the class a D. What cutoff should the
teacher use to determine who gets an D?&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_normal_perc(0.85, 60, 3, &amp;#39;lower&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/norm_per2-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The teacher wants to give middle 50% of the class a B. What cutoff should the
teacher use to determine who gets an B?&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_normal_perc(0.5, 60, 3, &amp;#39;both&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/norm_per3-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;probabilities&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Probabilities&lt;/h3&gt;
&lt;div id=&#34;calculate-and-visualize-probability-from-a-given-quantile&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Calculate and visualize probability from a given quantile&lt;/h4&gt;
&lt;div id=&#34;input-2&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Input&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;perc: a quantile value&lt;/li&gt;
&lt;li&gt;mean: mean of the normal distribution&lt;/li&gt;
&lt;li&gt;sd: standard deviation of the normal distribution&lt;/li&gt;
&lt;li&gt;type: lower/upper/both tail&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let X be the IQ of a randomly selected student of a school. Assume X ~ N(90, 4).
What is the probability that a randomly selected student has an IQ below 80?&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_normal_prob(80, mean = 90, sd = 4)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/norm_prob1-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;What is the probability that a randomly selected student has an IQ above 100?&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_normal_prob(100, mean = 90, sd = 4, type = &amp;#39;upper&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/norm_prob2-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;What is the probability that a randomly selected student has an IQ
between 85 and 100?&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_normal_prob(c(85, 100), mean = 90, sd = 4, type = &amp;#39;both&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/norm_prob3-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;binomial-distribution&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Binomial Distribution&lt;/h2&gt;
&lt;div id=&#34;distribution-shape-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Distribution Shape&lt;/h3&gt;
&lt;p&gt;Visualize how changes in number of trials and the probability of success affect
the shape of the binomial distribution.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_binom_plot(10, 0.3)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/binom_plot-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;percentiles-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Percentiles&lt;/h3&gt;
&lt;div id=&#34;calculate-and-visualize-quantiles-out-of-given-probability&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Calculate and visualize quantiles out of given probability&lt;/h4&gt;
&lt;div id=&#34;input-3&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Input&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;p: a single aggregated probability of multiple trials&lt;/li&gt;
&lt;li&gt;n: the number of trials&lt;/li&gt;
&lt;li&gt;tp: the probability of success in a trial&lt;/li&gt;
&lt;li&gt;type: lower/upper tail&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_binom_perc(10, 0.5, 0.05)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/binom_per1-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_binom_perc(10, 0.5, 0.05, &amp;#39;upper&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/binom_per2-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;probabilities-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Probabilities&lt;/h3&gt;
&lt;div id=&#34;calculate-and-visualize-probability-from-a-given-quantile-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Calculate and visualize probability from a given quantile&lt;/h4&gt;
&lt;div id=&#34;input-4&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Input&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;p: probability of success&lt;/li&gt;
&lt;li&gt;n: the number of trials&lt;/li&gt;
&lt;li&gt;s: number of success in a trial&lt;/li&gt;
&lt;li&gt;type: lower/upper/interval/exact tail&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Assume twenty-percent (20%) of Magemill have no health insurance. Randomly
sample n = 12 Magemillians. Let X denote the number in the sample with no
health insurance. What is the probability that exactly 4 of the 15 sampled
have no health insurance?&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_binom_prob(12, 0.2, 4, type = &amp;#39;exact&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/binom_prob1-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;What is the probability that at most one of those sampled has no health
insurance?&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_binom_prob(12, 0.2, 1, &amp;#39;lower&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/binom_prob2-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;What is the probability that more than seven have no health insurance?&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_binom_prob(12, 0.2, 8, &amp;#39;upper&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/binom_prob3-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;What is the probability that fewer than 5 have no health insurance?&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_binom_prob(12, 0.2, c(0, 4), &amp;#39;interval&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/binom_prob4-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;chi-square-distribution&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Chi Square Distribution&lt;/h2&gt;
&lt;div id=&#34;distribution-shape-2&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Distribution Shape&lt;/h3&gt;
&lt;p&gt;Visualize how changes in degrees of freedom affect the shape of the chi square
distribution.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_chisquare_plot(df = 5)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/chi_plot-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_chisquare_plot(df = 5, normal = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/chi_plot-2.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;percentiles-2&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Percentiles&lt;/h3&gt;
&lt;div id=&#34;calculate-quantiles-out-of-given-probability&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Calculate quantiles out of given probability&lt;/h4&gt;
&lt;div id=&#34;input-5&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Input&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;probs: a probability value&lt;/li&gt;
&lt;li&gt;df: degrees of freedom&lt;/li&gt;
&lt;li&gt;type: lower/upper tail&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let X be a chi-square random variable with 8 degrees of freedom. What is the
upper fifth percentile?&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_chisquare_perc(0.05, 8, &amp;#39;upper&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/chi_per1-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;What is the tenth percentile?&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_chisquare_perc(0.10, 8, &amp;#39;lower&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/chi_per2-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;probability&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Probability&lt;/h3&gt;
&lt;div id=&#34;calculate-probability-from-a-given-quantile.&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Calculate probability from a given quantile.&lt;/h4&gt;
&lt;div id=&#34;input-6&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Input&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;perc: a quantile value&lt;/li&gt;
&lt;li&gt;df: degrees of freedom&lt;/li&gt;
&lt;li&gt;type: lower/upper tail&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;What is the probability that a chi-square random variable with 12 degrees of
freedom is greater than 8.79?&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_chisquare_prob(8.79, 12, &amp;#39;upper&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/chi_prob1-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;What is the probability that a chi-square random variable with 12 degrees of
freedom is greater than 8.62?&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_chisquare_prob(8.62, 12, &amp;#39;lower&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/chi_prob2-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;f-distribution&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;F Distribution&lt;/h2&gt;
&lt;div id=&#34;distribution-shape-3&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Distribution Shape&lt;/h3&gt;
&lt;p&gt;Visualize how changes in degrees of freedom affect the shape of the F
distribution.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_f_plot()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/f_plot-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_f_plot(6, 10, normal = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/f_plot-2.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;percentiles-3&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Percentiles&lt;/h3&gt;
&lt;div id=&#34;calculate-quantiles-out-of-given-probability-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Calculate quantiles out of given probability&lt;/h4&gt;
&lt;div id=&#34;input-7&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Input&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;probs: a probability value&lt;/li&gt;
&lt;li&gt;num_df: nmerator degrees of freedom&lt;/li&gt;
&lt;li&gt;den_df: denominator degrees of freedom&lt;/li&gt;
&lt;li&gt;type: lower/upper tail&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let X be an F random variable with 4 numerator degrees of freedom and 5
denominator degrees of freedom. What is the upper twenth percentile?&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_f_perc(0.20, 4, 5, &amp;#39;upper&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/f_per1-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;What is the 35th percentile?&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_f_perc(0.35, 4, 5, &amp;#39;lower&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/f_per2-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;probabilities-2&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Probabilities&lt;/h3&gt;
&lt;div id=&#34;calculate-probability-from-a-given-quantile.-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Calculate probability from a given quantile.&lt;/h4&gt;
&lt;div id=&#34;input-8&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Input&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;perc: a quantile value&lt;/li&gt;
&lt;li&gt;num_df: nmerator degrees of freedom&lt;/li&gt;
&lt;li&gt;den_df: denominator degrees of freedom&lt;/li&gt;
&lt;li&gt;type: lower/upper tail&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;What is the probability that an F random variable with 4 numerator degrees of
freedom and 5 denominator degrees of freedom is greater than 3.89?&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_f_prob(3.89, 4, 5, &amp;#39;upper&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/f_prob1-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;What is the probability that an F random variable with 4 numerator degrees of
freedom and 5 denominator degrees of freedom is less than 2.63?&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_f_prob(2.63, 4, 5, &amp;#39;lower&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/f_prob2-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;t-distribution&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;t Distribution&lt;/h2&gt;
&lt;div id=&#34;distribution-shape-4&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Distribution Shape&lt;/h3&gt;
&lt;p&gt;Visualize how degrees of freedom affect the shape of t distribution.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_t_plot(df = 8)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/t_plot-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;percentiles-4&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Percentiles&lt;/h3&gt;
&lt;div id=&#34;calculate-quantiles-out-of-given-probability-2&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Calculate quantiles out of given probability&lt;/h4&gt;
&lt;div id=&#34;input-9&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Input&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;probs: a probability value&lt;/li&gt;
&lt;li&gt;df: degrees of freedom&lt;/li&gt;
&lt;li&gt;type: lower/upper/both tail&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;What is the upper fifteenth percentile?&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_t_perc(0.15, 8, &amp;#39;upper&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/t_per1-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;What is the eleventh percentile?&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_t_perc(0.11, 8, &amp;#39;lower&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/t_per2-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;What is the area of the curve that has 95% of the t values?&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_t_perc(0.8, 8, &amp;#39;both&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/t_per3-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;probabilities-3&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Probabilities&lt;/h3&gt;
&lt;div id=&#34;calculate-probability-from-a-given-quantile.-2&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Calculate probability from a given quantile.&lt;/h4&gt;
&lt;div id=&#34;input-10&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Input&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;perc: a quantile value&lt;/li&gt;
&lt;li&gt;df: degrees of freedom&lt;/li&gt;
&lt;li&gt;type: lower/upper/interval/both tail&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let T follow a t-distribution with r = 6 df.&lt;/p&gt;
&lt;p&gt;What is the probability that the value of T is less than 2?&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_t_prob(2, 6, &amp;#39;lower&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/t_prob1-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;What is the probability that the value of T is greater than 2?&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_t_prob(2, 6, &amp;#39;upper&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/t_prob2-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;What is the probability that the value of T is between -2 and 2?&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_t_prob(2, 6, &amp;#39;both&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/t_prob3-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;What is the probability that the absolute value of T is greater than 2?&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vdist_t_prob(2, 6, &amp;#39;interval&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-14-introducing-vistributions_files/figure-html/t_prob4-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;learning-more&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Learning More&lt;/h2&gt;
&lt;p&gt;The &lt;a href=&#34;https://vistributions.rsquaredacademy.com/&#34;&gt;vistributions website&lt;/a&gt; includes
comprehensive documentation on using the package, including the following
article that gives a brief introduction to vistributions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://vistributions.rsquaredacademy.com/articles/introduction-to-vistributions.html&#34;&gt;Introduction to vistributions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;feedback&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Feedback&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;vistributions&lt;/strong&gt; has been on CRAN for a few months now while we were fixing bugs and
making the API stable. All feedback is welcome. Issues (bugs and feature
requests) can be posted to &lt;a href=&#34;https://github.com/rsquaredacademy/vistributions/issues&#34;&gt;github tracker&lt;/a&gt;.
For help with code or other related questions, feel free to reach out to us
at &lt;a href=&#34;mailto:pkgs@rsquaredacademy.com&#34; class=&#34;email&#34;&gt;pkgs@rsquaredacademy.com&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Binning Data with rbin</title>
      <link>https://blog.rsquaredacademy.com/binning-data-with-rbin/</link>
      <pubDate>Tue, 12 Mar 2019 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/binning-data-with-rbin/</guid>
      <description>&lt;p&gt;We are happy to introduce the &lt;strong&gt;rbin&lt;/strong&gt; package, a set of tools for binning/discretization
of data, designed keeping in mind beginner/intermediate R users. It comes with
two RStudio addins for interactive binning.&lt;/p&gt;
&lt;div id=&#34;installation&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Installation&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Install release version from CRAN
install.packages(&amp;quot;rbin&amp;quot;)

# Install development version from GitHub
# install.packages(&amp;quot;devtools&amp;quot;)
devtools::install_github(&amp;quot;rsquaredacademy/rbin&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;rstudio-addins&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;RStudio Addins&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;rbin&lt;/strong&gt; includes two RStudio addins for manually binning data. Below
is a demo:&lt;/p&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/KQGPB1sL7R8&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;p&gt;Read on to learn more about the features of &lt;strong&gt;rbin&lt;/strong&gt;, or see the
&lt;a href=&#34;https://rbin.rsquaredacademy.com/&#34;&gt;rbin website&lt;/a&gt; for
detailed documentation on using the package.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;Binning is the process of transforming numerical or continuous data into
categorical data. It is a common data pre-processing step of the model building
process. &lt;strong&gt;rbin&lt;/strong&gt; has the following features:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;manual binning using shiny app&lt;/li&gt;
&lt;li&gt;equal length binning method&lt;/li&gt;
&lt;li&gt;winsorized binning method&lt;/li&gt;
&lt;li&gt;quantile binning method&lt;/li&gt;
&lt;li&gt;combine levels of categorical data&lt;/li&gt;
&lt;li&gt;create dummy variables based on binning method&lt;/li&gt;
&lt;li&gt;calculates weight of evidence (WOE), entropy and information value (IV)&lt;/li&gt;
&lt;li&gt;provides summary information about binning process&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;manual-binning&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Manual Binning&lt;/h3&gt;
&lt;p&gt;For manual binning, you need to specify the cut points for the bins. &lt;strong&gt;rbin&lt;/strong&gt;
follows the left closed and right open interval (&lt;code&gt;[0,1) = {x | 0 ≤ x &amp;lt; 1}&lt;/code&gt;) for
creating bins. The number of cut points you specify is one less than the number
of bins you want to create i.e. if you want to create 10 bins, you need to
specify only 9 cut points as shown in the below example. The accompanying
RStudio addin, &lt;code&gt;rbinAddin()&lt;/code&gt; can be used to iteratively bin the data and to
enforce monotonic increasing/decreasing trend.&lt;/p&gt;
&lt;p&gt;After finalizing the bins, you can use &lt;code&gt;rbin_create()&lt;/code&gt; to create the dummy
variables.&lt;/p&gt;
&lt;div id=&#34;bins&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Bins&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;bins &amp;lt;- rbin_manual(mbank, y, age, c(29, 31, 34, 36, 39, 42, 46, 51, 56))
bins&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Binning Summary
## ---------------------------
## Method               Manual 
## Response             y 
## Predictor            age 
## Bins                 10 
## Count                4521 
## Goods                517 
## Bads                 4004 
## Entropy              0.5 
## Information Value    0.12 
## 
## 
##    cut_point bin_count good bad          woe           iv   entropy
## 1       &amp;lt; 29       410   71 339 -0.483686036 2.547353e-02 0.6649069
## 2       &amp;lt; 31       313   41 272 -0.154776266 1.760055e-03 0.5601482
## 3       &amp;lt; 34       567   55 512  0.183985174 3.953685e-03 0.4594187
## 4       &amp;lt; 36       396   45 351  0.007117468 4.425063e-06 0.5107878
## 5       &amp;lt; 39       519   47 472  0.259825118 7.008270e-03 0.4383322
## 6       &amp;lt; 42       431   33 398  0.442938178 1.575567e-02 0.3899626
## 7       &amp;lt; 46       449   47 402  0.099298221 9.423907e-04 0.4836486
## 8       &amp;lt; 51       521   40 481  0.439981550 1.881380e-02 0.3907140
## 9       &amp;lt; 56       445   49 396  0.042587647 1.756117e-04 0.5002548
## 10     &amp;gt;= 56       470   89 381 -0.592843261 4.564428e-02 0.7001343&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;plot&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Plot&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(bins)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-12-introducing-rbin_files/figure-html/manual_plot-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;dummy-variables&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Dummy Variables&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;bins &amp;lt;- rbin_manual(mbank, y, age, c(29, 31, 34, 36, 39, 42, 46, 51, 56))
rbin_create(mbank, age, bins)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      age           job  marital education default balance housing loan
## 1     34    technician  married  tertiary      no     297     yes   no
## 2     49      services  married secondary      no     180     yes  yes
## 3     38        admin.   single secondary      no     262      no   no
## 4     47      services  married secondary      no     367     yes   no
## 5     51 self-employed   single secondary      no    1640     yes   no
## 6     40    unemployed  married secondary      no    3382     yes   no
## 7     58       retired  married secondary      no    1227      no   no
## 8     32    unemployed  married   primary      no     309     yes   no
## 9     46   blue-collar  married secondary      no     922     yes   no
## 10    32      services  married  tertiary      no       0      no   no
## 11    32      services  married secondary      no     414     yes   no
## 12    50   blue-collar  married   primary      no       0      no   no
## 13    41    management  married  tertiary      no    2226      no   no
## 14    38      services divorced   primary      no       0     yes   no
## 15    31 self-employed  married  tertiary     yes     147     yes   no
## 16    42        admin.   single secondary      no     283     yes   no
## 17    56       retired  married   primary      no      -1      no   no
## 18    54    management divorced   unknown      no     901      no   no
## 19    42    management  married secondary      no     372     yes   no
## 20    58      services  married secondary      no     627      no   no
## 21    51        admin.  married  tertiary      no      26     yes   no
## 22    44    management  married secondary      no     438     yes   no
## 23    51    management   single   unknown      no    -461     yes   no
## 24    41    management  married  tertiary      no    -195      no  yes
## 25    57    technician  married secondary      no   16063     yes   no
## 26    32    management   single  tertiary      no    3097     yes   no
## 27    32    management  married  tertiary      no    1232      no   no
## 28    45    management  married  tertiary      no    4693      no  yes
## 29    56  entrepreneur  married secondary      no     196      no   no
## 30    38    technician  married secondary      no       0     yes   no
## 31    54 self-employed  married  tertiary      no     990      no   no
## 32    53    unemployed   single   primary      no     183      no   no
## 33    36    management   single  tertiary      no     219      no   no
## 34    37   blue-collar  married secondary      no     -97     yes   no
## 35    31      services   single secondary      no     222     yes   no
## 36    42    technician  married secondary      no     234      no   no
## 37    34      services   single   primary      no      25     yes  yes
## 38    37    technician  married secondary      no    1762      no   no
## 39    59   blue-collar  married   primary      no      80     yes   no
## 40    54    management  married   primary     yes       0     yes  yes
## 41    54   blue-collar  married   primary      no    1357     yes  yes
## 42    59        admin.  married secondary      no    -198     yes  yes
## 43    33    management   single  tertiary      no    2059      no   no
## 44    24      services   single secondary      no     258     yes   no
## 45    29    technician   single  tertiary      no    2269     yes   no
## 46    49   blue-collar  married secondary      no       0      no   no
## 47    37    technician  married secondary      no      77     yes  yes
## 48    28   blue-collar  married   primary      no     254     yes   no
## 49    82       retired  married   primary      no     103      no   no
## 50    57   blue-collar  married   primary      no     452     yes   no
## 51    39    technician   single   unknown      no   45248     yes   no
## 52    39    management   single  tertiary      no       0      no   no
## 53    33    technician  married secondary      no     620      no   no
## 54    32   blue-collar  married secondary      no    2263      no   no
## 55    24   blue-collar   single secondary      no    8594     yes   no
## 56    52    technician  married secondary      no     306      no   no
## 57    32    management   single  tertiary      no   10281      no   no
## 58    33    technician   single  tertiary      no     469      no   no
## 59    31    management   single  tertiary      no      86      no   no
## 60    42    management  married  tertiary      no     477     yes   no
## 61    27   blue-collar  married   primary      no       1     yes   no
## 62    32    technician  married secondary      no       0     yes  yes
## 63    30    management   single  tertiary      no       0     yes   no
## 64    42        admin. divorced secondary      no    -172     yes  yes
## 65    43   blue-collar  married secondary      no    2706     yes  yes
## 66    27    technician   single  tertiary      no     808     yes   no
## 67    57    technician divorced secondary      no     164      no   no
## 68    32    unemployed   single secondary      no     331     yes   no
## 69    31        admin.   single secondary      no    1374     yes   no
## 70    36   blue-collar  married   primary      no       0     yes   no
## 71    31    management  married secondary      no     625     yes   no
## 72    39   blue-collar  married secondary      no     747     yes  yes
## 73    42      services  married   primary      no     124     yes   no
## 74    68       retired  married   primary      no       0      no   no
## 75    56    technician  married  tertiary      no     787      no  yes
## 76    46    technician divorced  tertiary      no     405     yes   no
## 77    35        admin.  married  tertiary      no    -272      no  yes
## 78    50      services  married secondary      no   57435     yes   no
## 79    50   blue-collar  married   primary      no     167      no   no
## 80    60     housemaid divorced secondary      no    2063      no   no
## 81    32    technician  married  tertiary      no       0     yes   no
## 82    30        admin.   single secondary      no     255      no   no
## 83    48      services   single   primary      no     204     yes   no
## 84    30        admin.   single secondary      no     648      no   no
## 85    31   blue-collar  married   primary      no      33     yes   no
## 86    45   blue-collar  married secondary      no     430      no  yes
## 87    35   blue-collar  married secondary      no     260     yes   no
## 88    26        admin.   single secondary      no       0     yes   no
## 89    32        admin.  married secondary      no    1604      no  yes
## 90    50    technician  married secondary      no    -568     yes  yes
## 91    34    technician  married secondary      no     966     yes   no
## 92    29   blue-collar  married   unknown      no     356     yes   no
## 93    29   blue-collar  married secondary      no    2378     yes  yes
## 94    75       retired divorced   primary      no     852      no   no
## 95    72       retired  married   primary      no    1388      no   no
## 96    48   blue-collar  married secondary      no    1230     yes  yes
## 97    37    management  married  tertiary      no    9895     yes   no
## 98    34    technician   single secondary      no   27446     yes   no
## 99    44    management  married   primary      no    1880     yes   no
## 100   35      services  married secondary      no       0     yes   no
## 101   28       student  married  tertiary      no     803     yes   no
## 102   25   blue-collar   single secondary      no     158     yes  yes
## 103   51   blue-collar  married secondary      no     328      no   no
## 104   44    unemployed divorced secondary      no     522      no   no
## 105   47   blue-collar  married   primary      no     550     yes   no
## 106   59       retired divorced secondary      no     602      no   no
## 107   38   blue-collar  married   primary      no     467     yes   no
## 108   39    management   single  tertiary      no    1682     yes   no
## 109   43    technician divorced secondary      no     305     yes   no
## 110   45    management divorced  tertiary      no   24598     yes   no
## 111   24   blue-collar   single   primary      no    2129     yes  yes
## 112   24 self-employed   single  tertiary      no     931     yes   no
## 113   69    technician  married secondary      no    9064      no   no
## 114   37   blue-collar   single   unknown      no    2188      no   no
## 115   29    technician   single  tertiary      no    -803     yes  yes
## 116   51   blue-collar  married   primary      no     -11      no   no
## 117   26       student   single secondary      no    5296      no   no
## 118   53        admin. divorced  tertiary      no     122      no   no
## 119   41      services  married secondary      no    6687     yes   no
## 120   42   blue-collar  married secondary      no     902     yes   no
## 121   25  entrepreneur  married  tertiary      no      30     yes   no
## 122   39    technician   single secondary      no    1048     yes  yes
## 123   50      services  married secondary      no    1687      no   no
## 124   55   blue-collar  married   primary      no     771      no   no
## 125   34        admin.   single secondary      no     663     yes   no
## 126   31    technician divorced  tertiary      no    2287     yes   no
## 127   32    technician   single secondary     yes      -1      no   no
## 128   56   blue-collar  married secondary      no    1686      no   no
## 129   51   blue-collar  married secondary      no    1779     yes   no
## 130   25   blue-collar  married secondary      no     316     yes  yes
## 131   33    management divorced  tertiary      no     312     yes  yes
## 132   54    management  married secondary     yes    5249     yes   no
## 133   34  entrepreneur  married secondary      no       2     yes  yes
## 134   39    technician   single secondary      no     175      no  yes
## 135   45    technician  married secondary      no     406     yes   no
## 136   43   blue-collar  married   primary      no    -454     yes   no
## 137   54    technician divorced secondary      no     -11     yes   no
## 138   34      services divorced secondary      no      27     yes   no
## 139   45    technician  married secondary      no    3395     yes   no
## 140   38      services divorced secondary      no      49     yes   no
## 141   33   blue-collar divorced secondary      no       1      no   no
## 142   27       student   single  tertiary      no      24     yes   no
## 143   53    management divorced  tertiary      no    2894     yes   no
## 144   32        admin.   single secondary      no    6042     yes   no
## 145   37   blue-collar   single  tertiary      no     481      no   no
## 146   51   blue-collar  married   primary      no    7098      no   no
## 147   55       retired  married secondary      no     123      no   no
## 148   61       retired  married secondary      no     280     yes   no
## 149   41    technician  married  tertiary      no     139      no   no
## 150   39   blue-collar  married secondary      no    1042     yes   no
## 151   34   blue-collar   single secondary      no    1423     yes   no
## 152   37    management  married  tertiary      no     591     yes   no
## 153   30    management  married  tertiary      no    1235      no   no
## 154   54    unemployed divorced secondary      no    3721     yes   no
## 155   47    technician divorced secondary      no    1851     yes   no
## 156   32    unemployed  married  tertiary      no     283     yes   no
## 157   42        admin.   single secondary      no    2095     yes   no
## 158   52   blue-collar divorced   primary      no     -97     yes  yes
## 159   83       retired   single   primary      no    3349      no   no
## 160   42    technician   single secondary      no       0     yes   no
## 161   38    management   single  tertiary      no    3141      no   no
## 162   56    unemployed  married secondary      no    -246      no  yes
## 163   52    management divorced  tertiary      no       0      no   no
## 164   56      services divorced   unknown      no    1877     yes   no
## 165   55    technician  married secondary      no       0     yes  yes
## 166   56    technician divorced secondary      no    3450      no   no
## 167   29    technician   single  tertiary      no     673     yes   no
## 168   73       retired  married   primary      no     542      no   no
## 169   62     housemaid  married secondary      no       2      no   no
## 170   56    management  married  tertiary      no    -762     yes  yes
## 171   36    technician  married   primary      no    1653     yes  yes
## 172   32   blue-collar  married   primary      no      50     yes   no
## 173   48    management  married  tertiary      no   14530     yes  yes
## 174   31        admin.   single secondary      no     358     yes   no
## 175   26   blue-collar   single secondary      no    3145      no   no
## 176   27   blue-collar   single secondary      no    1311     yes   no
## 177   56      services  married   primary      no     486      no  yes
## 178   31    management   single  tertiary      no      34      no   no
## 179   36   blue-collar  married secondary      no       0      no   no
## 180   53    technician  married   unknown      no    6921     yes   no
## 181   39   blue-collar  married secondary      no      98      no   no
## 182   82       retired divorced   primary      no     928      no   no
## 183   30    technician  married secondary      no     671      no   no
## 184   31    technician  married secondary      no     535      no   no
## 185   47 self-employed  married  tertiary      no     -80     yes   no
## 186   58    unemployed  married   primary      no    3884      no   no
## 187   55    management  married  tertiary      no    1402     yes   no
## 188   25        admin.   single secondary      no     425      no   no
## 189   31   blue-collar   single secondary      no    -161      no   no
## 190   53    technician  married secondary      no    2647     yes   no
## 191   43   blue-collar  married   primary      no     517     yes   no
## 192   56  entrepreneur  married  tertiary      no      40      no  yes
## 193   51    technician  married secondary      no    8758      no   no
## 194   34        admin.  married secondary      no     764      no   no
## 195   45    management  married secondary      no     446      no   no
## 196   60   blue-collar  married   primary      no       5      no   no
## 197   46    management   single  tertiary      no    6651      no   no
## 198   40  entrepreneur  married secondary      no       0     yes   no
## 199   53    management  married  tertiary      no     913     yes   no
## 200   57        admin.  married   unknown      no     596      no   no
## 201   25   blue-collar   single   primary      no    -221     yes   no
## 202   31    unemployed divorced  tertiary      no     756      no   no
## 203   64       retired  married secondary      no    1612      no   no
## 204   37        admin.  married secondary      no    1314     yes   no
## 205   30        admin.   single secondary      no    1009     yes   no
## 206   37        admin.   single secondary      no     781      no   no
## 207   48   blue-collar  married secondary      no    5078     yes   no
## 208   48   blue-collar  married   primary      no       8      no   no
## 209   50      services  married secondary      no    1134      no   no
## 210   38        admin.  married secondary      no     689     yes   no
## 211   43 self-employed  married secondary      no     634     yes   no
## 212   31    technician   single secondary      no       9      no   no
## 213   48    management  married  tertiary      no    1147      no   no
## 214   40        admin.   single secondary      no     963     yes   no
## 215   63  entrepreneur  married secondary      no    3904      no   no
## 216   41    management  married  tertiary      no      23      no   no
## 217   23      services   single secondary      no     665     yes   no
## 218   29    management   single  tertiary      no     536      no   no
## 219   52   blue-collar   single  tertiary     yes    -517      no  yes
## 220   44  entrepreneur  married secondary     yes    -848     yes   no
## 221   39    technician  married secondary      no     375     yes  yes
## 222   49   blue-collar  married   primary      no     371     yes   no
## 223   34        admin.  married secondary      no      95     yes   no
## 224   33    technician  married  tertiary      no     148      no   no
## 225   51   blue-collar divorced   primary      no     886      no   no
## 226   24    management   single  tertiary      no       1      no   no
## 227   34      services  married secondary      no     142     yes   no
## 228   50   blue-collar  married   primary      no     506     yes   no
## 229   44   blue-collar  married secondary      no     129     yes  yes
## 230   57   blue-collar divorced   primary      no    1299      no   no
## 231   26       student   single   unknown      no      19      no   no
## 232   29   blue-collar  married   primary      no     163     yes  yes
## 233   50   blue-collar  married   primary      no       0      no   no
## 234   52    management  married secondary      no    4096     yes   no
## 235   31        admin.  married secondary      no       0     yes  yes
## 236   32   blue-collar   single   primary      no      33      no   no
## 237   33    technician   single secondary      no       0      no   no
## 238   33        admin.   single secondary      no    1779     yes   no
## 239   41    unemployed divorced  tertiary      no    -198     yes   no
## 240   28    technician  married  tertiary      no     107     yes   no
## 241   41  entrepreneur   single   primary      no    7264      no  yes
## 242   32   blue-collar  married   primary      no     289     yes   no
## 243   48      services  married   unknown      no    1155     yes   no
## 244   45 self-employed divorced  tertiary      no     963     yes   no
## 245   39   blue-collar  married secondary      no       0     yes   no
## 246   36        admin. divorced secondary      no     -37     yes   no
## 247   60       retired  married secondary      no    3932     yes   no
## 248   42        admin.   single secondary      no    -247     yes  yes
## 249   34   blue-collar   single   primary      no     505     yes   no
## 250   40    management divorced  tertiary      no     205      no   no
## 251   26     housemaid   single secondary      no      93      no   no
## 252   42      services  married secondary      no    1545     yes   no
## 253   47    management  married  tertiary      no    1147      no   no
## 254   35   blue-collar  married secondary      no     765     yes   no
## 255   24       student   single secondary      no     822      no   no
## 256   42    management divorced  tertiary      no     461     yes   no
## 257   53      services  married secondary      no      76     yes   no
## 258   44    technician divorced secondary      no     316     yes   no
## 259   44 self-employed   single  tertiary      no      97     yes   no
## 260   43   blue-collar  married   primary      no     -41      no   no
## 261   28   blue-collar   single   primary      no    2340     yes   no
## 262   53      services  married   primary      no    2618     yes   no
## 263   23       student   single secondary      no    1062      no   no
## 264   32      services  married secondary      no     206     yes  yes
## 265   27   blue-collar  married secondary      no     191     yes   no
## 266   55    technician   single secondary      no      11      no   no
## 267   48        admin.  married   unknown      no       0     yes   no
## 268   32   blue-collar  married   primary      no     827     yes   no
## 269   45   blue-collar  married   primary      no     351     yes   no
## 270   38    technician  married secondary      no      54     yes  yes
## 271   53   blue-collar divorced   primary      no      -1     yes   no
## 272   26    technician   single secondary      no     941      no  yes
## 273   34  entrepreneur  married secondary      no     223      no  yes
## 274   31    management   single  tertiary      no      53     yes   no
## 275   45  entrepreneur divorced  tertiary      no       0     yes   no
## 276   56    management divorced  tertiary      no     310      no   no
## 277   38   blue-collar  married   primary      no     635     yes   no
## 278   39    management   single  tertiary      no     668      no   no
## 279   26      services   single secondary      no    1700     yes   no
## 280   35       student divorced   primary      no    2755     yes   no
## 281   30    management   single  tertiary      no       0      no   no
## 282   41      services divorced secondary      no      83      no   no
## 283   47  entrepreneur  married secondary      no       0      no   no
## 284   38      services  married   unknown      no   10189     yes   no
## 285   61    management  married  tertiary      no    5157      no   no
## 286   35   blue-collar  married   primary      no    4366     yes   no
## 287   30   blue-collar  married secondary     yes     -18      no   no
## 288   35    technician  married secondary      no     561     yes   no
## 289   35    technician  married secondary      no    -255     yes   no
## 290   32   blue-collar  married   primary      no     391     yes   no
## 291   40      services  married secondary      no    9374     yes   no
## 292   30      services   single secondary      no     695     yes   no
## 293   21       student   single secondary      no      71      no   no
## 294   38    technician  married secondary      no       0      no   no
## 295   54  entrepreneur divorced  tertiary      no   20527      no   no
## 296   35   blue-collar   single secondary      no     219     yes  yes
## 297   45   blue-collar  married   primary      no     491     yes  yes
## 298   37    technician   single secondary      no    -272      no  yes
## 299   42  entrepreneur  married  tertiary      no     859      no   no
## 300   34        admin.  married secondary      no     -33     yes  yes
## 301   38     housemaid  married secondary      no    1508      no  yes
## 302   36    management  married  tertiary      no     918      no   no
## 303   30    technician  married  tertiary      no     606     yes   no
## 304   44    technician divorced secondary      no     414     yes  yes
## 305   50   blue-collar  married secondary      no     325     yes   no
## 306   42        admin.   single secondary      no     734     yes   no
## 307   64       retired  married   primary      no      43      no   no
## 308   31  entrepreneur  married  tertiary      no       0     yes   no
## 309   35  entrepreneur  married  tertiary      no       0      no   no
## 310   58    management divorced  tertiary      no    4256      no   no
## 311   44    management  married  tertiary      no     474     yes  yes
## 312   79       retired divorced   primary      no     336      no   no
## 313   37        admin. divorced secondary      no       0     yes  yes
## 314   36      services   single secondary      no    9713     yes   no
## 315   57       retired  married  tertiary      no    4451      no  yes
## 316   32    technician   single secondary      no    -138      no   no
## 317   26    unemployed   single secondary      no     771      no   no
## 318   25      services   single secondary      no     333      no  yes
## 319   39        admin.  married secondary      no     563     yes   no
## 320   40   blue-collar  married secondary      no    4795     yes   no
## 321   50   blue-collar  married   primary      no     157      no   no
## 322   38    technician   single  tertiary      no     178     yes   no
## 323   31    management   single  tertiary      no       0      no   no
## 324   45   blue-collar  married   primary      no       0     yes   no
## 325   57    management divorced  tertiary      no     236      no   no
## 326   30    management   single  tertiary      no     536      no   no
## 327   36        admin.  married secondary      no    3308      no  yes
## 328   32   blue-collar   single secondary      no    1211     yes   no
## 329   41        admin.  married secondary      no    1705      no   no
## 330   59     housemaid  married   primary      no       5      no  yes
## 331   58    unemployed  married   primary      no    4967      no   no
## 332   26        admin.  married secondary      no     284      no   no
## 333   50   blue-collar divorced   primary      no     -19     yes   no
## 334   38   blue-collar  married   primary      no     168     yes  yes
## 335   36        admin.   single secondary      no     148     yes   no
## 336   28    technician   single  tertiary      no     386      no   no
## 337   52  entrepreneur  married secondary      no    3332     yes  yes
## 338   35     housemaid  married   primary      no       0      no   no
## 339   35   blue-collar  married   primary      no       0     yes   no
## 340   39    technician  married secondary      no    2765     yes  yes
## 341   53    technician  married secondary      no    3398      no  yes
## 342   52  entrepreneur  married secondary      no     330      no  yes
## 343   41   blue-collar  married secondary      no    2152     yes   no
## 344   50    technician  married secondary      no    8001      no   no
## 345   57 self-employed  married secondary      no    2109      no   no
## 346   56    management  married  tertiary      no      79      no   no
## 347   34    management   single  tertiary      no    -578     yes   no
## 348   41   blue-collar  married secondary      no     449     yes  yes
## 349   54    management divorced  tertiary      no    5253     yes  yes
## 350   66     housemaid divorced   primary      no    3701      no   no
## 351   28    management  married  tertiary      no     395      no   no
## 352   22       student   single secondary      no     722     yes   no
## 353   50    technician  married secondary      no       4      no   no
## 354   35    management   single  tertiary      no       0     yes   no
## 355   37  entrepreneur  married  tertiary      no    7944      no   no
## 356   30    management   single  tertiary      no      59     yes  yes
## 357   38        admin.   single secondary      no     221     yes   no
## 358   36   blue-collar  married secondary      no     330     yes   no
## 359   43    management   single  tertiary      no    3872     yes   no
## 360   42   blue-collar  married secondary      no    3052     yes   no
## 361   28   blue-collar   single secondary      no     362     yes   no
## 362   37    management  married  tertiary      no    5355      no   no
## 363   39    management  married  tertiary      no     285     yes   no
## 364   34      services   single   primary      no    3648     yes   no
## 365   55    unemployed  married  tertiary      no    4809     yes   no
## 366   37  entrepreneur  married  tertiary      no     298      no   no
## 367   29    technician   single  tertiary      no    1185     yes   no
## 368   34    technician  married secondary      no       2     yes   no
## 369   42      services   single secondary      no     838     yes   no
## 370   32        admin.  married secondary      no     552     yes   no
## 371   32   blue-collar  married secondary      no    2561     yes   no
## 372   34   blue-collar  married   primary      no     351      no  yes
## 373   39   blue-collar  married secondary      no     161     yes   no
## 374   35   blue-collar  married   primary      no    -167     yes   no
## 375   55       retired  married secondary      no    3948      no   no
## 376   31        admin.  married secondary      no     -36     yes  yes
## 377   59       retired  married secondary      no     374      no   no
## 378   34    management  married  tertiary      no     362     yes   no
## 379   53      services   single secondary      no    1162     yes   no
## 380   38   blue-collar  married secondary      no       0      no   no
## 381   41    management  married  tertiary      no    5936      no   no
## 382   46   blue-collar  married secondary      no     853      no   no
## 383   31        admin.  married secondary      no       2     yes  yes
## 384   27      services   single secondary      no     814     yes   no
## 385   51   blue-collar  married   primary      no       0      no   no
## 386   40    technician divorced secondary      no      16     yes   no
## 387   49    management  married  tertiary      no     865      no   no
## 388   39     housemaid  married secondary      no    1444      no   no
## 389   50   blue-collar  married secondary      no     278      no   no
## 390   45    management  married  tertiary      no      77     yes   no
## 391   46   blue-collar  married secondary      no     265     yes   no
## 392   39   blue-collar  married   primary      no     541     yes   no
## 393   61 self-employed divorced  tertiary      no   52587      no   no
## 394   37    technician   single secondary      no     -59     yes   no
## 395   38    technician  married   unknown      no      90     yes  yes
## 396   32    management  married  tertiary      no    1660     yes   no
## 397   51        admin.  married secondary      no     924     yes   no
## 398   38    technician   single secondary      no     553     yes   no
## 399   39     housemaid  married secondary      no       0     yes   no
## 400   42    management  married  tertiary      no      36      no   no
## 401   43 self-employed  married secondary      no    5317      no   no
## 402   38    technician   single secondary      no      61     yes   no
## 403   49    management divorced secondary      no    1598     yes   no
## 404   58       retired  married   primary      no    4007      no   no
## 405   39   blue-collar   single   primary      no    1537      no  yes
## 406   50    management  married  tertiary      no     782      no   no
## 407   28    management  married  tertiary      no      12     yes   no
## 408   51   blue-collar  married secondary      no      51      no  yes
## 409   47    technician  married secondary      no      72      no   no
## 410   30        admin.   single  tertiary      no       5      no  yes
## 411   55    technician divorced secondary      no     852      no   no
## 412   40    management   single  tertiary      no    -222     yes   no
## 413   33    technician   single  tertiary      no     129     yes   no
## 414   31    technician   single   unknown      no     694     yes   no
## 415   33    technician  married  tertiary      no     145     yes   no
## 416   58       retired  married   unknown      no     928      no   no
## 417   48  entrepreneur  married secondary      no      86     yes   no
## 418   28        admin.   single   unknown      no     731     yes   no
## 419   38    unemployed   single secondary      no    7159      no   no
## 420   44   blue-collar  married secondary      no     294     yes   no
## 421   31    management  married  tertiary      no    1126      no   no
## 422   46       unknown  married   unknown      no    2911      no   no
## 423   32    management   single  tertiary      no    1804     yes   no
## 424   36    management   single   unknown      no     601      no   no
## 425   47     housemaid  married  tertiary      no    1692     yes   no
## 426   29    unemployed   single  tertiary      no    1311      no   no
## 427   35    management   single   unknown      no     342      no  yes
## 428   43  entrepreneur  married  tertiary      no     210      no   no
## 429   34    management  married  tertiary      no    1770     yes   no
## 430   30    technician   single secondary      no    1416      no   no
## 431   59      services  married   primary      no     196     yes   no
## 432   50    management divorced  tertiary      no     405      no   no
## 433   35   blue-collar  married secondary      no     463     yes   no
## 434   37        admin.   single secondary      no     192     yes   no
## 435   45   blue-collar  married   primary      no     487     yes   no
## 436   54        admin. divorced secondary      no    -288     yes   no
## 437   64    management  married  tertiary      no    3951      no   no
## 438   48    management  married  tertiary      no       0      no  yes
## 439   62    unemployed  married   primary      no     532      no   no
## 440   53   blue-collar  married   primary      no    1388      no   no
## 441   59   blue-collar  married secondary      no       0      no   no
## 442   43        admin.   single secondary      no     445     yes   no
## 443   48    management  married  tertiary      no       2      no   no
## 444   40    management  married  tertiary      no   -1212     yes   no
## 445   46   blue-collar  married   primary      no    5164     yes   no
## 446   36      services   single secondary      no     616     yes  yes
## 447   36    technician  married  tertiary      no     571     yes  yes
## 448   29      services  married secondary      no     182     yes   no
## 449   29       student   single secondary      no    1093     yes   no
## 450   39   blue-collar divorced  tertiary      no     382      no   no
## 451   38 self-employed  married secondary      no     173      no   no
## 452   55   blue-collar  married secondary      no     176      no  yes
## 453   30    management  married  tertiary      no     367      no   no
## 454   33    technician   single  tertiary      no     231     yes   no
## 455   42    technician  married secondary      no     233      no   no
## 456   29    management  married  tertiary      no     318     yes   no
## 457   43    unemployed  married   primary      no       9     yes  yes
## 458   46    management   single  tertiary      no     502      no   no
## 459   32   blue-collar   single secondary      no     259     yes   no
## 460   33      services  married secondary      no    1631     yes   no
## 461   55    technician  married   primary      no     284      no   no
## 462   36    management  married  tertiary      no       0     yes   no
## 463   47  entrepreneur  married   unknown      no    1481     yes   no
## 464   45 self-employed  married secondary      no    3080      no   no
## 465   30    management   single secondary      no     135      no   no
## 466   41    management  married  tertiary      no    5883      no   no
## 467   75       retired divorced   primary      no    3881     yes   no
## 468   43    technician divorced secondary      no    1648      no   no
## 469   46     housemaid  married secondary      no     271     yes   no
## 470   23      services   single secondary      no      75     yes   no
## 471   35    technician   single  tertiary      no     354     yes   no
## 472   30        admin.  married   primary      no      40     yes  yes
## 473   48    unemployed   single   primary      no      63      no   no
## 474   32      services   single secondary      no     459     yes   no
## 475   49      services  married secondary      no       0      no   no
## 476   37   blue-collar  married secondary      no     223     yes   no
## 477   35      services  married secondary      no      74     yes   no
## 478   58    management  married   primary      no    2769     yes   no
## 479   53    technician  married  tertiary      no    4323     yes   no
## 480   44    technician  married  tertiary      no    4580     yes   no
## 481   42        admin.  married   primary      no    -306     yes   no
## 482   43    technician  married  tertiary      no    2643      no   no
## 483   53  entrepreneur  married   primary      no    -257     yes  yes
## 484   28    technician   single secondary      no     441      no  yes
## 485   27   blue-collar   single secondary     yes      -2     yes  yes
## 486   54    technician  married secondary      no   10185      no   no
## 487   33        admin.  married secondary      no    2374     yes   no
## 488   69       retired  married  tertiary      no     473      no   no
## 489   39    management   single  tertiary      no    3281      no   no
## 490   50    technician  married secondary      no     423      no   no
## 491   52    technician  married secondary      no    1373      no   no
## 492   60       retired  married  tertiary      no    2557     yes   no
## 493   57    technician  married secondary      no    3858      no   no
## 494   42    technician  married secondary      no     334     yes   no
## 495   52   blue-collar divorced   primary      no    1250      no   no
## 496   40    technician  married secondary      no     657     yes   no
## 497   32    technician  married secondary      no    1951     yes   no
## 498   37        admin.   single secondary      no     515     yes   no
## 499   36    management   single  tertiary      no     181     yes   no
## 500   60       retired  married secondary      no    -222      no   no
## 501   31      services   single secondary     yes      68     yes   no
## 502   39   blue-collar   single secondary      no       0     yes   no
## 503   49      services   single secondary      no    3061     yes   no
## 504   39    management  married  tertiary      no     691     yes  yes
## 505   45     housemaid divorced   primary      no     544      no   no
## 506   34   blue-collar  married secondary      no     355     yes   no
## 507   53        admin.  married   primary      no    6280      no   no
## 508   38    technician   single secondary      no     227      no   no
## 509   28        admin.   single secondary      no     419     yes   no
## 510   53     housemaid  married   primary     yes     945      no   no
## 511   27   blue-collar   single secondary      no     940     yes   no
## 512   30    technician   single secondary      no    2567      no   no
## 513   33    management  married secondary      no      56     yes   no
## 514   37    technician   single  tertiary      no    1609      no  yes
## 515   30    management   single  tertiary      no     364      no   no
## 516   53   blue-collar  married   primary      no    -864     yes   no
## 517   27    management   single  tertiary      no    1137     yes   no
## 518   37   blue-collar  married secondary      no     374     yes   no
## 519   27    management   single  tertiary      no    2786      no   no
## 520   40   blue-collar   single   primary      no     366     yes  yes
## 521   76     housemaid  married   primary      no    1483      no   no
## 522   32   blue-collar  married secondary      no    1779     yes   no
## 523   52        admin.  married secondary      no     722      no   no
## 524   45        admin.   single secondary      no     341     yes  yes
## 525   34    management divorced  tertiary      no     157     yes   no
## 526   43    management   single  tertiary      no     776      no   no
## 527   38        admin.  married secondary      no     505     yes  yes
## 528   60     housemaid  married   primary      no     182      no   no
## 529   33   blue-collar   single secondary      no     498      no   no
## 530   29    management  married  tertiary      no     991      no   no
## 531   41    technician  married secondary      no    2851      no   no
## 532   38   blue-collar  married   primary      no    1807      no   no
## 533   40   blue-collar  married   primary      no    -310     yes  yes
## 534   41  entrepreneur divorced  tertiary      no    -413     yes   no
## 535   45        admin.  married secondary      no    -405      no   no
## 536   31    unemployed   single secondary      no     315      no   no
## 537   33    technician  married secondary      no     575      no  yes
## 538   30      services  married secondary      no       0     yes   no
## 539   40     housemaid  married secondary      no     116      no   no
## 540   49        admin.  married secondary      no     635      no   no
## 541   31      services  married secondary      no    2050     yes   no
## 542   33      services   single   unknown      no     523     yes   no
## 543   47    technician divorced secondary      no      84      no   no
## 544   35        admin. divorced secondary      no    3636      no  yes
## 545   42      services  married secondary      no    3465     yes  yes
## 546   47     housemaid  married secondary      no    1765      no   no
## 547   30 self-employed   single secondary      no     635      no  yes
## 548   51   blue-collar  married   primary      no     653     yes  yes
## 549   30      services   single secondary      no     631     yes   no
## 550   56    management  married  tertiary      no     586      no   no
## 551   37   blue-collar  married secondary      no    1407     yes   no
## 552   55        admin. divorced secondary      no    3524     yes   no
## 553   32    management   single  tertiary      no     112     yes   no
## 554   52    management  married  tertiary      no    6873     yes   no
## 555   43     housemaid divorced   primary      no       0      no   no
## 556   47        admin.   single secondary      no    3696      no   no
## 557   58  entrepreneur  married secondary      no     670     yes   no
## 558   37    unemployed  married  tertiary      no    7620      no   no
## 559   32    unemployed   single secondary      no    2706      no   no
## 560   50    management  married secondary      no       5      no   no
## 561   42        admin. divorced secondary      no     936      no   no
## 562   32    technician   single  tertiary      no    1454     yes   no
## 563   33    technician   single secondary      no    1500      no   no
## 564   30        admin.   single  tertiary      no     305      no   no
## 565   38  entrepreneur   single secondary      no    2543      no   no
## 566   32    technician  married secondary      no    1242     yes   no
## 567   28    management   single  tertiary      no     492      no   no
## 568   50    unemployed  married secondary      no    3357      no   no
## 569   27       student   single  tertiary      no    1390      no   no
## 570   41        admin.  married secondary      no   16517      no   no
## 571   54      services divorced secondary      no    2398     yes   no
## 572   39    technician  married secondary     yes    -183     yes   no
## 573   34        admin.  married secondary      no     635     yes   no
## 574   37      services  married secondary      no    1616     yes   no
## 575   20       student   single secondary      no     602     yes   no
## 576   53       retired divorced secondary      no     797      no   no
## 577   30      services   single secondary      no     677     yes   no
## 578   29  entrepreneur   single  tertiary      no     430      no  yes
## 579   47    technician  married   primary      no     434     yes  yes
## 580   44    management  married  tertiary      no   12392     yes   no
## 581   26     housemaid  married secondary      no    -759     yes   no
## 582   31   blue-collar  married   primary      no     295     yes   no
## 583   37    management  married  tertiary      no       0      no   no
## 584   63       retired  married   primary      no   12067      no   no
## 585   37    management   single  tertiary      no    8066      no   no
## 586   27        admin.  married secondary      no     249     yes   no
## 587   26    management   single  tertiary      no      55      no  yes
## 588   30    technician  married  tertiary      no       0      no   no
## 589   50   blue-collar  married   primary      no      65     yes   no
## 590   34   blue-collar divorced secondary      no    1614     yes   no
## 591   39   blue-collar divorced secondary      no     412      no   no
## 592   54    management divorced  tertiary      no    5475      no   no
## 593   32   blue-collar   single secondary      no    2137      no   no
## 594   50   blue-collar  married   primary      no      89     yes   no
## 595   27       student   single  tertiary      no    1134      no   no
## 596   32    technician  married secondary      no     221     yes   no
## 597   29       student   single secondary      no      48      no   no
## 598   58       unknown  married secondary      no     208      no   no
## 599   34      services   single  tertiary      no      88      no   no
## 600   50    technician  married secondary      no    1616     yes  yes
## 601   31    technician   single  tertiary      no    -167     yes   no
## 602   58    management divorced  tertiary      no   26254     yes   no
## 603   34   blue-collar  married secondary      no    1298     yes   no
## 604   58   blue-collar divorced   primary      no     820     yes   no
## 605   38  entrepreneur divorced secondary      no      36      no   no
## 606   59    technician  married secondary      no    2342      no  yes
## 607   40    unemployed  married secondary      no    1872      no   no
## 608   35      services  married secondary      no     528      no   no
## 609   32    technician  married secondary      no      79     yes   no
## 610   32     housemaid divorced secondary      no    -613     yes   no
## 611   29        admin.   single secondary      no     260     yes   no
## 612   53    management divorced  tertiary      no    6388     yes   no
## 613   44    technician  married secondary      no     398     yes   no
## 614   36        admin.  married secondary      no     313     yes   no
## 615   38    technician  married secondary      no    5115     yes   no
## 616   46   blue-collar  married   primary      no     -29     yes   no
## 617   62       retired  married secondary      no    3340      no   no
## 618   36   blue-collar divorced   primary      no    3202     yes   no
## 619   35 self-employed  married secondary      no      -3      no   no
## 620   35   blue-collar   single secondary      no     218     yes   no
## 621   35    technician divorced secondary      no    2823     yes   no
## 622   33    unemployed   single  tertiary      no    4874      no   no
## 623   49    technician  married secondary      no     905      no   no
## 624   46    management  married secondary      no    3570      no   no
## 625   57  entrepreneur  married   unknown      no     975     yes  yes
## 626   58    technician  married  tertiary      no     289      no   no
## 627   51  entrepreneur  married  tertiary      no   36935     yes   no
## 628   31    unemployed  married secondary      no      24     yes   no
## 629   26        admin.   single secondary      no     140     yes   no
## 630   42    management  married  tertiary      no       4     yes   no
## 631   46   blue-collar  married secondary      no     536     yes   no
## 632   25    technician  married secondary      no    -559     yes   no
## 633   58       retired  married secondary      no    1227      no   no
## 634   35    technician   single secondary      no    2471     yes  yes
## 635   54    management divorced secondary      no     300     yes   no
## 636   33    technician  married secondary      no    6419      no   no
## 637   31        admin.  married secondary      no     454     yes   no
## 638   45    technician  married   primary      no    3388      no   no
## 639   50        admin.  married secondary      no     176      no   no
## 640   28 self-employed  married  tertiary      no       0     yes   no
## 641   51    management  married  tertiary      no    1421     yes   no
## 642   37      services  married secondary      no       0      no   no
## 643   40        admin.  married  tertiary      no       0     yes   no
## 644   36    unemployed  married  tertiary      no    7222     yes   no
## 645   36    technician   single secondary      no    5436     yes   no
## 646   35    technician   single secondary      no      27     yes   no
## 647   29     housemaid   single  tertiary      no      19      no   no
## 648   36   blue-collar  married secondary      no     723     yes   no
## 649   50    unemployed  married secondary      no     525     yes   no
## 650   52      services divorced secondary      no    2455      no   no
## 651   34 self-employed  married secondary      no      47      no   no
## 652   53    management  married  tertiary      no    4928     yes   no
## 653   29      services   single secondary      no    -158     yes   no
## 654   36    management  married  tertiary      no     105      no   no
## 655   31    technician  married secondary      no      28      no   no
## 656   33    technician   single secondary      no    6325      no   no
## 657   39    management  married  tertiary      no       0      no   no
## 658   45 self-employed divorced secondary      no    -139     yes   no
## 659   46    unemployed  married secondary      no    1040      no   no
## 660   52      services  married   unknown      no     337     yes   no
## 661   38   blue-collar  married secondary      no     171     yes  yes
## 662   25       student   single secondary      no    2354      no   no
## 663   60    management   single  tertiary      no       0      no  yes
## 664   49    management  married  tertiary      no     412      no   no
## 665   65       retired  married  tertiary      no    1973      no   no
## 666   43    technician   single secondary      no     293     yes   no
## 667   33      services  married secondary      no     210     yes  yes
## 668   43 self-employed  married  tertiary      no     819      no   no
## 669   26    management   single  tertiary      no     948     yes   no
## 670   36        admin.  married secondary      no     957     yes   no
## 671   53   blue-collar  married secondary      no       0      no   no
## 672   47   blue-collar  married secondary      no    3696     yes   no
## 673   57    management  married  tertiary      no    4547      no   no
## 674   37    management   single secondary      no    8311     yes   no
## 675   23   blue-collar   single secondary     yes    -207     yes   no
## 676   38    technician   single secondary      no       0     yes   no
## 677   39  entrepreneur  married  tertiary      no    1654      no   no
## 678   61       retired  married  tertiary      no    2557     yes   no
## 679   60       retired  married   primary      no    1720      no   no
## 680   55        admin.  married secondary      no     859      no   no
## 681   50      services  married   primary      no    2603      no   no
## 682   38   blue-collar  married secondary      no     702      no   no
## 683   38    management   single  tertiary      no     574     yes   no
## 684   52   blue-collar  married secondary      no    -164      no   no
## 685   32        admin.  married secondary      no    1974     yes   no
## 686   33        admin.   single secondary      no    2557     yes   no
## 687   19       student   single   unknown      no     108      no   no
## 688   47        admin.  married secondary      no     175     yes   no
## 689   44    management divorced  tertiary      no     388     yes   no
## 690   47    management   single  tertiary      no       0      no   no
## 691   41        admin.  married secondary      no       2     yes   no
## 692   37    technician  married secondary      no    1707     yes   no
## 693   34    technician   single secondary      no     666      no   no
## 694   38    technician  married  tertiary      no    -267      no   no
## 695   30       student  married  tertiary      no     324      no   no
## 696   22        admin.   single secondary      no     118     yes   no
## 697   29   blue-collar   single   primary      no     161      no  yes
## 698   54 self-employed  married  tertiary      no     542      no   no
## 699   31    technician  married secondary      no    -292     yes  yes
## 700   36        admin.  married secondary      no     421     yes   no
## 701   39   blue-collar  married secondary      no    1360     yes   no
## 702   46    management  married secondary      no     700      no  yes
## 703   56 self-employed  married secondary      no    1539      no   no
## 704   22      services   single secondary      no     395     yes   no
## 705   35        admin.   single secondary      no    1537     yes   no
## 706   46        admin.  married secondary      no     526      no  yes
## 707   27      services  married secondary      no     100      no   no
## 708   50    management  married  tertiary      no     619     yes   no
## 709   30    management  married  tertiary      no    1825     yes   no
## 710   39    management divorced   unknown      no     401      no   no
## 711   47        admin.  married secondary      no    1156      no  yes
## 712   35   blue-collar   single secondary      no     142     yes   no
## 713   28    management   single secondary      no     265     yes   no
## 714   48   blue-collar  married   primary      no     762     yes   no
## 715   33    technician  married secondary      no       0     yes   no
## 716   36      services  married secondary      no     812     yes  yes
## 717   38      services  married secondary      no     611     yes  yes
## 718   41    technician  married secondary      no     130      no   no
## 719   57        admin.  married secondary      no    -967     yes   no
## 720   35        admin.   single secondary      no     148     yes   no
## 721   41        admin. divorced secondary      no       4     yes   no
## 722   41     housemaid   single   primary      no      21      no   no
## 723   31      services   single secondary      no   11386     yes   no
## 724   34    management   single  tertiary      no     673     yes  yes
## 725   34      services  married secondary      no    1553     yes   no
## 726   43      services   single   unknown      no     193     yes   no
## 727   52      services  married secondary      no     992     yes   no
## 728   31 self-employed   single secondary      no     762      no   no
## 729   31    technician   single secondary      no     335     yes   no
## 730   41    management   single  tertiary      no    3371     yes  yes
## 731   38   blue-collar  married secondary      no      49     yes   no
## 732   70       retired divorced   primary      no     482      no   no
## 733   19       student   single secondary      no    1803      no   no
## 734   38   blue-collar  married   primary      no     132     yes   no
## 735   39       retired   single   primary      no     -79      no   no
## 736   36    management  married  tertiary      no    1352      no   no
## 737   56    technician  married secondary      no     147      no   no
## 738   29    management   single  tertiary      no     308      no   no
## 739   33    management  married secondary      no     -14     yes   no
## 740   48   blue-collar  married secondary      no     794      no   no
## 741   43   blue-collar  married   primary      no     794     yes   no
## 742   44    technician  married secondary      no     331     yes   no
## 743   31    management   single  tertiary      no     347     yes   no
## 744   54   blue-collar  married secondary      no    2255      no   no
## 745   37 self-employed  married  tertiary      no     129      no   no
## 746   28 self-employed   single  tertiary      no     442      no   no
## 747   39        admin.  married secondary     yes       0      no   no
## 748   29    unemployed  married secondary      no     596      no   no
## 749   44   blue-collar  married secondary      no    -431     yes   no
## 750   46   blue-collar  married   primary      no    9083     yes   no
## 751   37    management   single secondary      no      24     yes  yes
## 752   42   blue-collar  married secondary      no    -150     yes   no
## 753   18       student   single secondary      no     156      no   no
## 754   39        admin.  married secondary      no    -982     yes  yes
## 755   58 self-employed  married secondary      no    1407     yes   no
## 756   30   blue-collar   single secondary      no     155     yes  yes
## 757   31       student   single  tertiary      no    4951      no   no
## 758   30       student   single  tertiary      no       0      no   no
## 759   44    management  married  tertiary      no    7454      no   no
## 760   30    technician   single  tertiary      no    6683      no   no
## 761   27       student   single secondary      no       0      no   no
## 762   43    management  married  tertiary      no     248      no   no
## 763   33    management   single  tertiary      no    3161     yes   no
## 764   40   blue-collar  married secondary      no     252     yes  yes
## 765   35    technician   single  tertiary      no    1529      no   no
## 766   41     housemaid  married secondary      no     304      no   no
## 767   31   blue-collar  married secondary      no      42     yes   no
## 768   50   blue-collar  married   primary      no     480     yes   no
## 769   59   blue-collar  married secondary      no       0      no   no
## 770   57       retired  married   unknown      no    -157      no   no
## 771   46        admin.  married secondary      no       0     yes  yes
## 772   52   blue-collar  married secondary      no    1860      no   no
## 773   47   blue-collar  married   primary      no      85      no   no
## 774   46      services   single   unknown      no     454      no   no
## 775   40    management  married  tertiary      no     229     yes   no
## 776   34      services divorced secondary      no     202     yes   no
## 777   38   blue-collar   single secondary      no    1137      no   no
## 778   52   blue-collar  married secondary      no     568     yes   no
## 779   50        admin.  married secondary      no    -221      no  yes
## 780   50   blue-collar  married secondary      no      37     yes  yes
## 781   27   blue-collar  married   primary      no      52      no  yes
## 782   35    management  married  tertiary      no    1650      no   no
## 783   30      services   single  tertiary      no     542     yes   no
## 784   53    management  married secondary      no    2693      no   no
## 785   19       student   single   primary      no     134      no   no
## 786   36        admin.  married secondary      no     194     yes  yes
## 787   53      services  married secondary      no    2719     yes   no
## 788   30   blue-collar  married secondary      no     364     yes  yes
## 789   53    technician divorced secondary      no      45      no   no
## 790   30        admin.   single secondary     yes    -242      no   no
## 791   27      services   single secondary      no       1     yes  yes
## 792   51   blue-collar  married secondary      no    -286     yes   no
## 793   27        admin.   single secondary      no     261     yes  yes
## 794   46    management   single secondary      no    5993      no   no
## 795   44    technician  married secondary      no     358      no   no
## 796   39    management  married  tertiary      no    1112      no   no
## 797   47    technician  married secondary      no    -401     yes   no
## 798   35    technician divorced secondary      no     515     yes  yes
## 799   37   blue-collar  married secondary      no       6     yes   no
## 800   40 self-employed  married  tertiary      no     355     yes   no
## 801   50   blue-collar  married   primary      no      40     yes   no
## 802   24       student   single secondary      no       0      no   no
## 803   34     housemaid  married secondary      no     -97     yes  yes
## 804   55    management divorced  tertiary      no    2625     yes   no
## 805   39        admin.  married secondary      no     260     yes   no
## 806   34       unknown  married   unknown      no    4535      no   no
## 807   51    management  married  tertiary      no     346      no   no
## 808   44 self-employed  married secondary      no     335      no   no
## 809   48    technician  married secondary      no     101     yes   no
## 810   45  entrepreneur  married secondary      no     245     yes   no
## 811   37        admin. divorced secondary      no       0      no   no
## 812   35        admin.  married secondary      no     147     yes  yes
## 813   47   blue-collar  married secondary      no     863     yes   no
## 814   35   blue-collar  married secondary      no     270     yes  yes
## 815   32    unemployed  married secondary      no      10     yes   no
## 816   39      services  married secondary      no    1116     yes   no
## 817   41   blue-collar  married secondary      no    1165      no   no
## 818   43    technician  married secondary      no     533     yes   no
## 819   61    management  married  tertiary      no    6016      no   no
## 820   50    management  married  tertiary      no      85      no  yes
## 821   42   blue-collar  married secondary      no     505     yes   no
## 822   47    management  married secondary      no      -1      no   no
## 823   34    management  married  tertiary      no      63      no   no
## 824   32    management  married  tertiary      no    3517     yes   no
## 825   31      services  married secondary      no    1670      no   no
## 826   44       retired  married   primary      no     779     yes   no
## 827   45        admin.  married secondary      no     142     yes  yes
## 828   39        admin.   single secondary      no       0     yes   no
## 829   57       retired  married secondary      no     211     yes   no
## 830   37   blue-collar  married secondary      no      14     yes   no
## 831   39    management  married secondary      no    1034     yes   no
## 832   69       retired divorced secondary      no    4572      no   no
## 833   46    technician  married secondary      no       0     yes   no
## 834   33    technician  married secondary      no       0     yes   no
## 835   42     housemaid  married secondary      no     341      no   no
## 836   32    management   single  tertiary      no     593     yes   no
## 837   53    management  married  tertiary      no     694      no   no
## 838   54      services   single secondary      no     492      no   no
## 839   37 self-employed   single secondary      no     125      no   no
## 840   43    management  married   unknown      no     587     yes   no
## 841   32   blue-collar  married secondary      no     335     yes   no
## 842   40   blue-collar  married   primary      no     104     yes   no
## 843   44    technician  married secondary      no    7863      no   no
## 844   31   blue-collar   single secondary      no    1124     yes   no
## 845   45   blue-collar  married   primary      no     803     yes   no
## 846   26        admin.   single secondary      no     483     yes   no
## 847   46    management  married  tertiary      no    9678     yes   no
## 848   46    technician  married secondary      no     591      no   no
## 849   59      services  married secondary      no     -22     yes   no
## 850   32   blue-collar  married   primary      no     -94     yes  yes
## 851   37    management   single  tertiary      no   22125      no  yes
## 852   54    technician  married   unknown      no       0      no   no
## 853   53      services  married secondary      no      -2     yes  yes
## 854   47        admin.  married secondary      no    3676      no   no
## 855   52      services divorced secondary      no      36     yes  yes
## 856   46   blue-collar   single secondary      no       0     yes   no
## 857   24       student   single secondary      no   23878      no   no
## 858   47   blue-collar  married   primary      no     259      no   no
## 859   33 self-employed  married  tertiary      no    1676     yes   no
## 860   30    management  married  tertiary      no      24     yes   no
## 861   51 self-employed divorced secondary      no     154     yes   no
## 862   46      services  married secondary     yes     130      no   no
## 863   56    technician   single   primary      no     145     yes   no
## 864   42    unemployed  married  tertiary      no     576      no   no
## 865   39        admin.  married secondary      no      15      no   no
## 866   46     housemaid  married   primary      no     269      no   no
## 867   26    management   single  tertiary      no    1623      no   no
## 868   36        admin.   single secondary      no     449     yes   no
## 869   35    management divorced  tertiary      no    6997     yes   no
## 870   40    unemployed   single  tertiary      no      97     yes  yes
## 871   60      services  married secondary      no    8837     yes   no
## 872   41   blue-collar divorced   primary      no    2195     yes   no
## 873   37 self-employed  married secondary      no    8230     yes   no
## 874   48   blue-collar   single secondary      no    -269      no   no
## 875   44    technician  married secondary      no    1226     yes  yes
## 876   32   blue-collar  married   primary     yes    -148     yes   no
## 877   52      services divorced secondary      no     238     yes   no
## 878   19       student   single secondary      no     526      no   no
## 879   62    technician  married   unknown      no     635      no   no
## 880   34   blue-collar  married secondary      no       7     yes  yes
## 881   45    technician  married secondary      no    -847      no  yes
## 882   47    technician  married secondary      no    1059     yes   no
## 883   41    technician  married secondary      no     902      no   no
## 884   80       retired  married   primary      no    1468      no   no
## 885   32    technician   single secondary      no      82      no   no
## 886   31    management  married  tertiary      no     877      no   no
## 887   39    management   single  tertiary      no    2258     yes   no
## 888   27    management   single  tertiary      no    6791      no   no
## 889   42  entrepreneur  married secondary      no    -480     yes  yes
## 890   40      services divorced secondary      no     160      no   no
## 891   30    technician   single  tertiary      no       0      no   no
## 892   35   blue-collar   single secondary      no     546     yes   no
## 893   30    management   single  tertiary      no    1761     yes   no
## 894   44      services divorced secondary      no     396     yes  yes
## 895   45   blue-collar  married   primary      no    1335     yes   no
## 896   36      services   single secondary      no     174     yes   no
## 897   27  entrepreneur  married secondary      no      97     yes  yes
## 898   25   blue-collar   single secondary      no       0     yes   no
## 899   32   blue-collar   single   primary      no    1137     yes  yes
## 900   34    technician  married  tertiary      no     555     yes   no
## 901   45   blue-collar  married secondary      no      42     yes   no
## 902   38   blue-collar   single secondary      no     522     yes   no
## 903   37 self-employed   single  tertiary      no     281     yes   no
## 904   57    technician  married  tertiary      no   27069      no  yes
## 905   25      services   single   unknown      no    2022      no   no
## 906   38    management   single  tertiary      no    1495     yes   no
## 907   25    technician   single  tertiary      no    1693      no   no
## 908   41     housemaid  married   primary      no    1529      no   no
## 909   27    management   single  tertiary      no     148     yes   no
## 910   57   blue-collar  married   primary      no      24      no   no
## 911   33 self-employed  married  tertiary      no     483     yes   no
## 912   46   blue-collar  married secondary      no     877      no   no
## 913   30    technician  married  tertiary      no    3418      no   no
## 914   43      services  married   primary      no    2557     yes   no
## 915   32    technician divorced secondary      no       2     yes   no
## 916   51   blue-collar  married   primary      no    2832     yes   no
## 917   43    management  married  tertiary      no       0     yes   no
## 918   28   blue-collar  married secondary      no      86     yes  yes
## 919   34        admin.  married secondary      no    1406     yes   no
## 920   30    management  married secondary      no   11391     yes   no
## 921   27    management  married  tertiary      no    1918      no   no
## 922   42        admin. divorced secondary      no    2129      no   no
## 923   38        admin.   single secondary      no    -327      no   no
## 924   36   blue-collar   single   primary      no     736     yes   no
## 925   50    management   single  tertiary      no     297     yes   no
## 926   34   blue-collar  married secondary      no    2308     yes   no
## 927   49    management  married secondary      no      99     yes   no
## 928   24       student   single secondary      no     382      no   no
## 929   57    management divorced   unknown      no       0      no   no
## 930   29        admin.  married secondary      no     535      no   no
## 931   29   blue-collar   single secondary      no     770     yes   no
## 932   79       retired  married secondary      no    2661      no   no
## 933   31   blue-collar  married secondary      no    3659      no   no
## 934   31        admin.   single secondary      no    3323     yes   no
## 935   41    management  married  tertiary      no      20     yes   no
## 936   56       retired divorced secondary      no     275     yes  yes
## 937   38    technician  married   primary      no   -1038      no  yes
## 938   37   blue-collar   single secondary      no     690     yes   no
## 939   41    technician  married secondary      no     994      no   no
## 940   31    management   single  tertiary      no     775     yes   no
## 941   27       student   single secondary      no     279      no   no
## 942   52  entrepreneur divorced secondary      no     105      no  yes
## 943   27   blue-collar   single secondary      no     484     yes   no
## 944   40   blue-collar  married secondary      no       0     yes   no
## 945   23      services   single secondary      no     870      no   no
## 946   43    management  married  tertiary      no      -8     yes   no
## 947   41      services  married   primary      no     124     yes   no
## 948   46        admin. divorced secondary      no    1203      no   no
## 949   31        admin.   single  tertiary      no     355     yes   no
## 950   48   blue-collar  married   primary      no     448     yes   no
## 951   46    technician  married secondary      no    2501      no   no
## 952   33   blue-collar  married secondary      no      53      no   no
## 953   65       retired  married secondary      no   23421      no   no
## 954   65       retired  married   primary      no    3713      no   no
## 955   27       student   single secondary      no   16173     yes   no
## 956   27        admin.  married secondary      no      53     yes   no
## 957   39    management  married  tertiary      no     271     yes   no
## 958   30        admin.   single  tertiary      no     732      no   no
## 959   55    management  married   primary      no     338     yes   no
## 960   58       retired  married   unknown      no     662     yes   no
## 961   35        admin.  married   primary      no    1994      no   no
## 962   52    unemployed  married secondary      no      94      no   no
## 963   34        admin. divorced secondary      no     -75      no   no
## 964   37    technician  married  tertiary      no     732      no   no
## 965   29    technician  married secondary      no     767     yes   no
## 966   28    management   single  tertiary      no    1335      no  yes
## 967   60       unknown  married   primary      no    4722      no   no
## 968   44    unemployed  married   primary      no     280     yes   no
## 969   36   blue-collar  married secondary      no      29     yes  yes
## 970   27   blue-collar   single secondary      no    1049      no   no
## 971   42   blue-collar divorced   primary      no     299     yes   no
## 972   35   blue-collar  married secondary      no    2643     yes   no
## 973   61       unknown   single   primary      no      50      no   no
## 974   31    technician   single  tertiary      no    1214      no   no
## 975   29    management  married  tertiary      no     103     yes   no
## 976   40   blue-collar  married secondary      no     326     yes  yes
## 977   53   blue-collar  married   primary      no    4793     yes   no
## 978   35    management  married  tertiary      no     272     yes  yes
## 979   26    management   single  tertiary      no     962     yes   no
## 980   51       retired  married secondary      no     965     yes   no
## 981   55       retired  married   primary      no     -90     yes  yes
## 982   47    management  married  tertiary      no    6637     yes   no
## 983   46   blue-collar  married secondary      no     431     yes   no
## 984   28    management   single  tertiary      no    4937     yes   no
## 985   47      services  married secondary      no     216     yes   no
## 986   29        admin.  married secondary      no     943     yes   no
## 987   45  entrepreneur  married  tertiary      no       1      no   no
## 988   41    management  married secondary      no    5585      no   no
## 989   33 self-employed  married  tertiary      no    -103     yes   no
## 990   32    management  married  tertiary      no    4733      no   no
## 991   55     housemaid  married secondary      no     139      no   no
## 992   29    management  married  tertiary      no      16     yes   no
## 993   35    management  married secondary      no     616      no  yes
## 994   55    management  married  tertiary      no    1433      no   no
## 995   31 self-employed   single  tertiary      no    2589      no   no
## 996   56    management  married  tertiary      no    5282      no   no
## 997   43   blue-collar  married   primary      no     232      no  yes
## 998   33    management divorced  tertiary      no     893     yes   no
## 999   48       retired divorced   primary      no     666     yes   no
## 1000  45        admin.  married secondary      no     180     yes   no
## 1001  31      services  married   primary      no    -732     yes   no
## 1002  56    management  married  tertiary      no    1390     yes   no
## 1003  57     housemaid  married   primary      no     501     yes  yes
## 1004  30        admin.   single secondary      no     382     yes   no
## 1005  51   blue-collar divorced   primary      no     -28      no  yes
## 1006  33 self-employed  married  tertiary      no     666     yes   no
## 1007  43    management  married  tertiary      no    1800      no   no
## 1008  55    technician   single secondary      no    3339     yes   no
## 1009  30    technician  married  tertiary      no     526     yes  yes
## 1010  36    unemployed  married secondary     yes    -318     yes   no
## 1011  50    management  married secondary      no    2910      no   no
## 1012  31   blue-collar   single secondary      no     411      no   no
## 1013  55    technician  married  tertiary      no       0      no   no
## 1014  31    management   single  tertiary      no     471      no   no
## 1015  54       retired divorced secondary      no    2761      no   no
## 1016  59    technician  married   primary      no    4243     yes   no
## 1017  38  entrepreneur  married secondary      no     197      no   no
## 1018  46    management divorced  tertiary      no     225     yes   no
## 1019  54   blue-collar  married secondary      no    1765     yes   no
## 1020  58       retired divorced secondary      no     312      no   no
## 1021  71       retired divorced secondary      no    3104      no   no
## 1022  45       unknown  married   unknown      no    2834      no   no
## 1023  32    unemployed  married secondary      no    2400     yes  yes
## 1024  46      services  married   unknown      no      72     yes   no
## 1025  48    management divorced  tertiary      no     148      no   no
## 1026  53      services divorced secondary      no     765     yes   no
## 1027  40   blue-collar   single secondary      no    3571     yes   no
## 1028  55    management divorced  tertiary      no     608     yes   no
## 1029  32      services   single secondary      no    -408     yes   no
## 1030  38    management divorced  tertiary      no    5455     yes   no
## 1031  35   blue-collar   single secondary      no     907     yes  yes
## 1032  39 self-employed  married secondary      no     266      no   no
## 1033  43   blue-collar  married secondary      no      30      no   no
## 1034  48   blue-collar  married   primary      no     554      no   no
## 1035  35 self-employed  married  tertiary      no    1340      no  yes
## 1036  58        admin.  married secondary      no    2777     yes   no
## 1037  28   blue-collar  married secondary      no     -26      no  yes
## 1038  36   blue-collar  married   unknown      no    -742     yes  yes
## 1039  44    management  married  tertiary      no    1242     yes   no
## 1040  36    technician  married secondary      no     361      no   no
## 1041  37    technician divorced secondary      no    1176      no  yes
## 1042  52    technician  married  tertiary      no     876      no   no
## 1043  33    management  married  tertiary      no     876      no   no
## 1044  52    management divorced  tertiary      no      12     yes   no
## 1045  50    management  married secondary      no    1165      no   no
## 1046  36    management   single  tertiary      no    4788     yes   no
## 1047  34    technician   single secondary      no    2660     yes   no
## 1048  54    management divorced secondary      no     155     yes   no
## 1049  32      services  married secondary      no    2578      no   no
## 1050  48    management   single  tertiary      no    -295      no  yes
## 1051  34    technician   single secondary      no       0      no   no
## 1052  32   blue-collar   single   primary      no     181     yes   no
## 1053  53   blue-collar  married   primary      no    1311      no   no
## 1054  52    technician  married   unknown      no    2709     yes   no
## 1055  36   blue-collar  married secondary      no     537      no  yes
## 1056  42      services  married secondary      no     146     yes  yes
## 1057  38  entrepreneur  married   unknown      no    1134     yes   no
## 1058  48  entrepreneur   single secondary      no       0     yes   no
## 1059  30      services   single secondary      no     732     yes   no
## 1060  36    technician divorced secondary      no     556     yes   no
## 1061  48    management divorced  tertiary     yes    -625     yes   no
## 1062  38    management   single  tertiary      no    3813      no   no
## 1063  27    management  married  tertiary      no      33     yes   no
## 1064  48        admin. divorced secondary      no    -480      no   no
## 1065  36   blue-collar  married   primary      no    -453     yes   no
## 1066  41  entrepreneur  married secondary      no     187      no  yes
## 1067  46    technician   single secondary      no       0      no   no
## 1068  60   blue-collar divorced secondary      no       0     yes   no
## 1069  40   blue-collar  married   primary      no      98     yes   no
## 1070  46   blue-collar  married  tertiary     yes    -388      no   no
## 1071  45    management  married  tertiary      no    9711      no   no
## 1072  30    management  married  tertiary      no     168     yes   no
## 1073  60        admin.  married secondary      no      39     yes  yes
## 1074  34    management   single  tertiary      no     382      no   no
## 1075  37   blue-collar   single secondary      no    2032     yes   no
## 1076  28    management  married  tertiary      no    3694      no  yes
## 1077  43      services divorced secondary      no     957      no  yes
## 1078  56   blue-collar  married   primary      no     690     yes   no
## 1079  30    management  married  tertiary      no     859     yes   no
## 1080  49   blue-collar divorced   primary      no     235      no   no
## 1081  41    management  married  tertiary      no   27696      no   no
## 1082  28    technician  married  tertiary      no     858     yes   no
## 1083  36    management   single  tertiary      no    3875     yes   no
## 1084  35      services divorced secondary      no     440     yes   no
## 1085  39    technician  married secondary      no     192     yes  yes
## 1086  32    technician  married secondary      no     344     yes   no
## 1087  50   blue-collar  married   primary      no   12519     yes   no
## 1088  49 self-employed  married secondary      no     294     yes   no
## 1089  40   blue-collar  married   primary      no    4608     yes   no
## 1090  41        admin. divorced secondary      no    1634     yes  yes
## 1091  26        admin.   single secondary      no    1327      no   no
## 1092  37    management  married  tertiary      no     238      no   no
## 1093  50    technician  married secondary      no    -353     yes  yes
## 1094  57       retired   single secondary      no     976     yes   no
## 1095  33    technician divorced secondary      no    1480     yes   no
## 1096  55    management  married   unknown      no    1185      no   no
## 1097  39    management   single  tertiary      no     139      no   no
## 1098  51        admin.  married secondary      no     531     yes   no
## 1099  27 self-employed   single  tertiary      no     168      no   no
## 1100  80       retired  married secondary      no    8304      no   no
## 1101  36    management   single  tertiary      no     811      no   no
## 1102  44      services  married secondary      no    4786     yes  yes
## 1103  46    technician  married secondary      no    1465     yes   no
## 1104  39   blue-collar  married   primary      no     579     yes  yes
## 1105  31   blue-collar  married   primary      no     591     yes   no
## 1106  59     housemaid  married   primary      no     352      no   no
## 1107  59    management  married  tertiary      no    7049      no   no
## 1108  30    management   single secondary      no    8101     yes   no
## 1109  31    management   single  tertiary      no       3      no   no
## 1110  66     housemaid  married   primary      no      40      no   no
## 1111  53   blue-collar  married secondary      no    4380      no   no
## 1112  59 self-employed  married  tertiary      no    3800      no  yes
## 1113  26   blue-collar  married   primary      no    -219     yes  yes
## 1114  35   blue-collar  married secondary      no    4723     yes   no
## 1115  36    management  married  tertiary      no    2326     yes   no
## 1116  31    technician   single  tertiary      no    1166     yes   no
## 1117  30        admin.  married secondary      no     874     yes   no
## 1118  33    management  married  tertiary      no     307      no   no
## 1119  57    technician  married   primary      no       0      no   no
## 1120  27        admin.   single secondary      no     110     yes   no
## 1121  37     housemaid   single secondary      no    1358      no   no
## 1122  47    management   single  tertiary      no      86      no   no
## 1123  39    management  married  tertiary      no    1423     yes   no
## 1124  32    technician divorced secondary      no    2870      no   no
## 1125  33     housemaid  married   primary      no       0      no   no
## 1126  51  entrepreneur   single secondary      no     440      no   no
## 1127  45    technician   single  tertiary      no       0      no   no
## 1128  43    technician divorced secondary      no    1413     yes   no
## 1129  53     housemaid divorced secondary      no     292      no   no
## 1130  55    technician  married secondary      no     273     yes   no
## 1131  36 self-employed  married secondary      no    1245     yes   no
## 1132  34   blue-collar  married   primary      no    -480     yes  yes
## 1133  37     housemaid   single   primary      no       0      no   no
## 1134  46   blue-collar  married secondary      no     572     yes   no
## 1135  37    management  married   unknown      no     247      no   no
## 1136  29    technician  married secondary      no     428      no   no
## 1137  40    management   single  tertiary      no    1247     yes   no
## 1138  34   blue-collar divorced secondary      no    1125     yes  yes
## 1139  59   blue-collar  married secondary      no    -162     yes  yes
## 1140  41      services  married secondary      no     803     yes   no
## 1141  27        admin.  married secondary      no    4144     yes   no
## 1142  33    management   single  tertiary      no     372     yes  yes
## 1143  36   blue-collar  married   primary      no     199     yes   no
## 1144  37      services  married secondary      no     -24     yes   no
## 1145  52        admin.  married secondary      no       0      no   no
## 1146  51    management divorced  tertiary      no     119      no   no
## 1147  32    technician   single secondary      no      28     yes   no
## 1148  45    management  married  tertiary      no    -191     yes   no
## 1149  38    management  married  tertiary      no    2656      no   no
## 1150  57       retired divorced   primary     yes       0      no  yes
## 1151  24    management   single  tertiary      no      66     yes   no
## 1152  46    management  married secondary      no      10     yes   no
## 1153  46    management  married  tertiary      no     477     yes   no
## 1154  51    management  married  tertiary      no    -714      no   no
## 1155  48    management  married secondary     yes    -998     yes   no
## 1156  44    management  married  tertiary      no    6203     yes  yes
## 1157  37   blue-collar   single secondary      no    2390     yes   no
## 1158  35    management   single  tertiary      no     714     yes   no
## 1159  40  entrepreneur  married secondary      no    2252      no   no
## 1160  35    management   single  tertiary      no     244     yes   no
## 1161  34        admin.  married secondary      no     445      no   no
## 1162  32   blue-collar  married secondary      no      25     yes   no
## 1163  37    management   single   unknown      no     242      no  yes
## 1164  53   blue-collar  married   primary      no     252      no   no
## 1165  56       retired  married  tertiary      no       5      no   no
## 1166  37        admin.   single secondary      no    1113     yes   no
## 1167  52        admin.  married secondary      no       0      no  yes
## 1168  29      services  married secondary      no       3     yes   no
## 1169  56    unemployed  married secondary      no     216      no   no
## 1170  41   blue-collar  married secondary      no    4910     yes   no
## 1171  56    management  married   primary      no    -155     yes   no
## 1172  37     housemaid divorced secondary      no    1040     yes   no
## 1173  55       retired  married secondary      no     991      no   no
## 1174  53    management divorced  tertiary      no    3158      no   no
## 1175  47      services  married secondary      no     665     yes   no
## 1176  48   blue-collar   single secondary      no     339      no  yes
## 1177  79       retired divorced   primary      no    1910      no   no
## 1178  58    technician  married   unknown      no    -205     yes   no
## 1179  32        admin.   single secondary      no     212      no   no
## 1180  59    management   single secondary      no     181     yes   no
## 1181  34    management   single  tertiary      no     681      no   no
## 1182  44        admin.  married  tertiary      no     348     yes  yes
## 1183  48    management  married  tertiary      no    1167     yes  yes
## 1184  50    management  married   unknown      no    8345      no   no
## 1185  43    management  married   primary      no    8167     yes   no
## 1186  34   blue-collar  married   primary      no       0     yes  yes
## 1187  36    technician   single secondary      no    1044     yes   no
## 1188  53    technician  married   unknown      no    2242      no   no
## 1189  29        admin.   single secondary      no     345     yes  yes
## 1190  52    technician  married   unknown      no     668     yes   no
## 1191  39    management  married  tertiary      no     151     yes   no
## 1192  45    management  married secondary      no    2897      no   no
## 1193  41    technician   single  tertiary      no    5365     yes   no
## 1194  39    management  married  tertiary      no     763     yes   no
## 1195  27       student   single secondary      no     672      no   no
## 1196  37    management  married  tertiary      no    3723      no   no
## 1197  46   blue-collar  married secondary      no      -3     yes   no
## 1198  40      services  married secondary      no    3164     yes   no
## 1199  57    management divorced  tertiary      no     429     yes   no
## 1200  26   blue-collar   single secondary      no     474     yes   no
## 1201  28      services   single secondary      no     341     yes   no
## 1202  34   blue-collar  married secondary      no     800      no   no
## 1203  29        admin.   single secondary      no     788     yes   no
## 1204  35   blue-collar  married   primary      no    2708     yes   no
## 1205  59   blue-collar  married secondary      no     202     yes   no
## 1206  54   blue-collar   single   unknown      no    1555     yes   no
## 1207  32    management  married  tertiary      no     905      no   no
## 1208  57       retired  married secondary      no    5313      no   no
## 1209  39    unemployed   single secondary      no    -114     yes   no
## 1210  41        admin.   single secondary      no    5219     yes   no
## 1211  31    management   single  tertiary      no     357     yes   no
## 1212  37    unemployed  married secondary      no      86      no   no
## 1213  52        admin.  married secondary      no    3703     yes   no
## 1214  39    management   single  tertiary      no     416      no   no
## 1215  23        admin.   single secondary      no       0     yes   no
## 1216  46    management divorced  tertiary      no     507     yes   no
## 1217  34        admin.   single  tertiary      no     458     yes   no
## 1218  31   blue-collar divorced secondary      no    -209     yes   no
## 1219  38    technician  married secondary      no    2000     yes   no
## 1220  28    management  married  tertiary      no      82     yes  yes
## 1221  41        admin.   single secondary      no     882     yes  yes
## 1222  30   blue-collar  married secondary      no     -71     yes   no
## 1223  34    management   single  tertiary      no    1494     yes   no
## 1224  56        admin. divorced secondary      no     985      no  yes
## 1225  32     housemaid  married   primary      no       7      no  yes
## 1226  39        admin.  married secondary      no     260     yes   no
## 1227  26   blue-collar   single   primary      no      52     yes   no
## 1228  35   blue-collar divorced  tertiary      no    3547     yes   no
## 1229  30      services   single secondary      no    3485      no   no
## 1230  44   blue-collar  married secondary      no     701      no  yes
## 1231  57       retired  married   primary      no      70     yes  yes
## 1232  52    management  married  tertiary      no    1392      no   no
## 1233  30    management  married  tertiary      no     151      no   no
## 1234  41   blue-collar  married secondary      no     946     yes   no
## 1235  61    management  married secondary      no    1471      no   no
## 1236  52    management  married  tertiary      no    1545      no   no
## 1237  60        admin. divorced   unknown      no     791     yes   no
## 1238  50    management  married secondary      no    2130      no   no
## 1239  45   blue-collar  married   primary      no     900     yes   no
## 1240  51    management  married  tertiary      no    1612     yes   no
## 1241  38    management  married  tertiary      no    5432     yes  yes
## 1242  47   blue-collar  married   primary      no    1092      no  yes
## 1243  43    management  married  tertiary      no    1050     yes  yes
## 1244  36    technician  married secondary      no      -8     yes   no
## 1245  54   blue-collar  married   primary      no     781     yes   no
## 1246  38       unknown   single  tertiary      no       0      no   no
## 1247  56    technician  married secondary      no     203     yes   no
## 1248  31    technician   single secondary      no     102     yes   no
## 1249  33    management   single  tertiary      no       0      no   no
## 1250  57    unemployed  married   unknown      no     381      no   no
## 1251  44    management  married  tertiary      no    -600     yes   no
## 1252  32    management   single  tertiary      no       0     yes   no
## 1253  35    technician  married  tertiary      no     944      no   no
## 1254  49      services  married secondary      no     725      no  yes
## 1255  23    management   single  tertiary      no    2143      no   no
## 1256  49        admin.  married  tertiary      no     255     yes   no
## 1257  53   blue-collar  married secondary      no      70     yes   no
## 1258  34  entrepreneur  married   unknown      no    -506      no   no
## 1259  57   blue-collar  married   primary      no    3109      no   no
## 1260  37      services  married secondary      no      78     yes   no
## 1261  27        admin.  married secondary      no     941     yes   no
## 1262  40      services  married   primary      no      33      no   no
## 1263  38    management  married  tertiary      no       0     yes   no
## 1264  40   blue-collar  married   primary      no     105     yes   no
## 1265  28   blue-collar   single secondary      no      56     yes   no
## 1266  36 self-employed  married secondary      no    1006     yes   no
## 1267  39   blue-collar  married   primary      no    2366     yes   no
## 1268  40    technician   single  tertiary      no    1646     yes   no
## 1269  34   blue-collar divorced secondary      no     368      no  yes
## 1270  29       student   single  tertiary      no     652     yes   no
## 1271  43        admin.   single secondary      no    -247     yes  yes
## 1272  35   blue-collar  married secondary      no       0     yes  yes
## 1273  37    management  married  tertiary      no    3794      no   no
## 1274  31        admin.  married secondary      no      62      no   no
## 1275  41    management   single secondary      no    1286     yes   no
## 1276  36    management  married  tertiary      no    2309     yes   no
## 1277  33   blue-collar  married secondary      no     249     yes   no
## 1278  30    management   single  tertiary      no   19358      no   no
## 1279  52   blue-collar  married secondary      no     289     yes   no
## 1280  40    management  married  tertiary      no       0     yes  yes
## 1281  38      services  married secondary      no      53      no   no
## 1282  60       retired  married  tertiary      no    2868      no   no
## 1283  32 self-employed  married secondary      no     514     yes   no
## 1284  44    technician  married secondary      no     135     yes   no
## 1285  31 self-employed  married  tertiary      no      94      no   no
## 1286  29    unemployed   single   primary      no     550      no   no
## 1287  37    management  married  tertiary      no    5205     yes   no
## 1288  33    technician  married secondary      no    2362     yes   no
## 1289  34    technician   single secondary      no    1313      no   no
## 1290  30    management  married  tertiary      no    8623      no   no
## 1291  47      services  married secondary      no     543     yes   no
## 1292  41    management divorced  tertiary      no      47     yes   no
## 1293  58    management  married   unknown      no    3658      no   no
## 1294  42 self-employed  married  tertiary      no     596     yes   no
## 1295  46   blue-collar  married   primary      no     174     yes  yes
## 1296  29    management   single   unknown      no     345      no   no
## 1297  32    technician   single  tertiary      no     723      no   no
## 1298  24        admin.   single secondary      no     507     yes   no
## 1299  28        admin.  married secondary      no     576     yes  yes
## 1300  36    technician divorced secondary      no     515     yes  yes
## 1301  32      services   single secondary      no     406     yes   no
## 1302  40   blue-collar   single secondary      no     322     yes   no
## 1303  48    technician  married secondary      no    2688      no  yes
## 1304  52    management  married  tertiary      no     193      no   no
## 1305  39    technician divorced secondary      no     394     yes   no
## 1306  32      services   single secondary      no     101     yes   no
## 1307  42 self-employed  married  tertiary      no    6383      no   no
## 1308  27      services   single secondary      no    1636     yes   no
## 1309  60    management divorced secondary      no       0      no   no
## 1310  24    unemployed  married secondary      no       6      no   no
## 1311  57      services  married secondary      no     668     yes  yes
## 1312  39 self-employed  married  tertiary      no    1492     yes   no
## 1313  30      services   single secondary      no     438     yes   no
## 1314  50    technician  married  tertiary      no    2313      no   no
## 1315  49    management  married  tertiary      no       1      no   no
## 1316  54   blue-collar  married secondary      no    1223     yes   no
## 1317  49  entrepreneur  married  tertiary      no     388     yes   no
## 1318  42      services  married secondary      no     120     yes   no
## 1319  42      services  married   primary      no     473     yes   no
## 1320  35   blue-collar  married secondary      no      26     yes   no
## 1321  49        admin.  married  tertiary      no    -962     yes   no
## 1322  42   blue-collar   single secondary      no     382     yes   no
## 1323  29       student   single   unknown      no    2929      no   no
## 1324  42    management divorced secondary      no     764      no  yes
## 1325  35 self-employed   single  tertiary      no       0     yes  yes
## 1326  52      services  married secondary      no    2257     yes   no
## 1327  48       retired  married   primary     yes    -285      no  yes
## 1328  42      services  married secondary      no     199      no   no
## 1329  51       unknown   single   unknown      no       0      no   no
## 1330  48   blue-collar   single secondary      no     574      no   no
## 1331  31    technician   single secondary      no     538     yes   no
## 1332  33   blue-collar divorced secondary      no     176     yes   no
## 1333  62  entrepreneur  married secondary      no    3904      no   no
## 1334  29   blue-collar  married secondary      no       1     yes   no
## 1335  28   blue-collar   single   primary      no     431     yes   no
## 1336  37    management  married  tertiary      no     789     yes  yes
## 1337  34    technician  married secondary      no       1      no  yes
## 1338  42       retired  married   primary      no     127      no  yes
## 1339  32    technician   single  tertiary      no     502     yes   no
## 1340  42    technician  married  tertiary      no     849      no   no
## 1341  30   blue-collar  married secondary      no    1780     yes   no
## 1342  31   blue-collar  married secondary      no     822     yes   no
## 1343  45   blue-collar  married secondary      no     146     yes  yes
## 1344  54    management  married  tertiary      no      11      no   no
## 1345  38        admin.  married secondary      no    3632     yes  yes
## 1346  36      services  married secondary      no       0      no   no
## 1347  28        admin.   single secondary      no     230      no   no
## 1348  49    technician  married   unknown      no      15      no   no
## 1349  34      services   single secondary      no    3080      no   no
## 1350  52  entrepreneur divorced secondary      no     302      no   no
## 1351  39   blue-collar  married   unknown      no       0     yes   no
## 1352  39    management  married   primary      no     197     yes   no
## 1353  71       retired   single  tertiary      no    1285      no   no
## 1354  48   blue-collar  married secondary      no    1143     yes   no
## 1355  27    management   single  tertiary      no     406      no   no
## 1356  66 self-employed  married  tertiary      no     147      no   no
## 1357  36    management divorced  tertiary      no      59      no   no
## 1358  49 self-employed  married  tertiary      no      99     yes  yes
## 1359  51   blue-collar  married secondary      no     814     yes   no
## 1360  46 self-employed  married  tertiary      no     -80     yes   no
## 1361  54   blue-collar  married secondary      no     175     yes   no
## 1362  57  entrepreneur divorced  tertiary      no     873      no   no
## 1363  56 self-employed  married  tertiary      no     350      no   no
## 1364  39   blue-collar  married   primary      no    2805     yes   no
## 1365  61     housemaid  married   primary      no     368      no   no
## 1366  50   blue-collar  married secondary      no    1329     yes  yes
## 1367  53   blue-collar divorced   primary      no     235      no   no
## 1368  30   blue-collar  married secondary      no    -166     yes  yes
## 1369  49     housemaid  married   primary      no     360      no   no
## 1370  44      services  married secondary      no   29312      no   no
## 1371  24   blue-collar   single secondary      no    1857     yes   no
## 1372  30        admin.   single secondary      no     110      no   no
## 1373  34   blue-collar  married secondary      no     187     yes   no
## 1374  33      services  married secondary      no      28      no   no
## 1375  27   blue-collar   single secondary      no     100     yes   no
## 1376  42   blue-collar divorced   primary      no      28     yes   no
## 1377  45    unemployed   single secondary      no     382     yes  yes
## 1378  34        admin.  married secondary      no    1183     yes   no
## 1379  36  entrepreneur  married secondary      no     229     yes   no
## 1380  51    management  married  tertiary      no     346      no   no
## 1381  27    management   single  tertiary      no     102      no   no
## 1382  45    management  married secondary      no    5888     yes   no
## 1383  34   blue-collar  married secondary      no    3990     yes   no
## 1384  38    management  married  tertiary      no    7124      no   no
## 1385  53    technician divorced secondary      no     447     yes  yes
## 1386  59       retired divorced secondary      no     914      no   no
## 1387  36   blue-collar  married secondary      no     801     yes  yes
## 1388  33        admin.   single secondary      no     572     yes   no
## 1389  33        admin.   single secondary      no    -371     yes  yes
## 1390  37        admin. divorced secondary      no    -165     yes   no
## 1391  34    technician   single secondary      no     649      no   no
## 1392  35   blue-collar   single secondary      no       0     yes   no
## 1393  27      services  married secondary      no     199      no   no
## 1394  57    unemployed  married secondary      no    7357      no   no
## 1395  33    technician  married  tertiary      no      48      no   no
## 1396  53       retired  married  tertiary      no    2269      no   no
## 1397  36   blue-collar   single secondary      no     103     yes   no
## 1398  52    management  married  tertiary      no    1065     yes  yes
## 1399  31   blue-collar  married   primary      no      99     yes   no
## 1400  30    management   single  tertiary      no      61     yes   no
## 1401  60    management  married  tertiary      no      79      no   no
## 1402  40      services  married secondary      no    1116     yes   no
## 1403  53    technician  married secondary      no       0      no   no
## 1404  30        admin.   single secondary      no    1018     yes   no
## 1405  26    technician  married secondary      no      47     yes   no
## 1406  30    management   single  tertiary      no    2995     yes   no
## 1407  24       student   single secondary      no     486      no   no
## 1408  34    management   single  tertiary      no     127      no   no
## 1409  41        admin.  married secondary      no    4178      no   no
## 1410  31   blue-collar  married secondary      no     360     yes   no
## 1411  39   blue-collar  married secondary      no    1386     yes  yes
## 1412  40 self-employed  married  tertiary      no    1498      no   no
## 1413  39        admin. divorced secondary      no     458      no   no
## 1414  41    technician divorced secondary      no     258      no   no
## 1415  35    management  married  tertiary      no    2123     yes   no
## 1416  34    management  married  tertiary      no      11     yes   no
## 1417  29        admin.  married secondary      no   22171     yes   no
## 1418  58    management  married  tertiary      no    2729      no   no
## 1419  36    management  married  tertiary      no      86     yes   no
## 1420  40      services  married secondary      no     771     yes   no
## 1421  35      services  married secondary      no     586     yes  yes
## 1422  34    management  married  tertiary      no      53     yes  yes
## 1423  45  entrepreneur divorced  tertiary      no       0     yes   no
## 1424  34   blue-collar  married secondary      no    2137      no   no
## 1425  33        admin.   single secondary      no    1221     yes   no
## 1426  48   blue-collar  married secondary      no     729     yes   no
## 1427  34   blue-collar  married   primary      no     -78     yes   no
## 1428  35    technician   single secondary      no     103     yes   no
## 1429  35   blue-collar  married   primary      no       0     yes   no
## 1430  39   blue-collar  married   primary      no     521      no  yes
## 1431  27    management   single  tertiary      no    2489      no   no
## 1432  36  entrepreneur  married   primary      no     177     yes   no
## 1433  38   blue-collar  married secondary      no    1731     yes  yes
## 1434  51        admin.  married secondary      no     227      no   no
## 1435  35    technician  married secondary      no     128      no  yes
## 1436  37   blue-collar   single  tertiary      no    1222      no   no
## 1437  59    technician  married secondary      no    4263      no  yes
## 1438  38    technician  married  tertiary      no    1004     yes   no
## 1439  46   blue-collar  married secondary      no     942      no   no
## 1440  73       retired  married   unknown      no    3443      no   no
## 1441  24    technician  married secondary      no     691     yes   no
## 1442  51    technician  married secondary      no     180     yes   no
## 1443  50    management  married  tertiary      no     830      no   no
## 1444  39    technician  married secondary      no     130      no   no
## 1445  52   blue-collar  married secondary      no      33      no  yes
## 1446  46    technician  married secondary      no     179      no  yes
## 1447  34      services   single secondary      no     194     yes  yes
## 1448  36    management   single  tertiary      no       0     yes  yes
## 1449  46   blue-collar  married secondary      no     624     yes   no
## 1450  32   blue-collar   single secondary      no    3662      no   no
## 1451  62   blue-collar  married secondary      no     272      no   no
## 1452  36    management  married  tertiary      no     190     yes   no
## 1453  51 self-employed  married  tertiary      no     126     yes   no
## 1454  31  entrepreneur divorced  tertiary      no    1767      no   no
## 1455  45    technician  married secondary      no    1003     yes   no
## 1456  43    technician  married secondary      no    -330     yes  yes
## 1457  49   blue-collar  married secondary      no     457     yes  yes
## 1458  60       retired  married  tertiary      no    3461      no   no
## 1459  50    technician  married secondary      no    1518      no  yes
## 1460  30      services  married secondary      no      33      no   no
## 1461  46   blue-collar  married secondary      no     310     yes   no
## 1462  44    management  married  tertiary      no     -68      no  yes
## 1463  45    technician  married secondary      no    2776     yes   no
## 1464  46   blue-collar  married secondary      no     243     yes   no
## 1465  42       unknown   single   unknown     yes      61      no   no
## 1466  43   blue-collar   single   primary      no       0      no   no
## 1467  46    management divorced  tertiary      no       3     yes  yes
## 1468  33   blue-collar  married secondary      no     983      no   no
## 1469  32        admin.   single secondary      no     739     yes   no
## 1470  50   blue-collar  married   primary      no     280     yes   no
## 1471  46      services  married secondary      no     311     yes  yes
## 1472  28     housemaid  married   primary      no       5      no   no
## 1473  38   blue-collar divorced secondary      no    1686     yes   no
## 1474  44   blue-collar   single secondary      no     712     yes  yes
## 1475  24        admin.   single secondary      no     845     yes   no
## 1476  28       student   single secondary      no     949     yes   no
## 1477  29   blue-collar   single   primary      no    3508     yes   no
## 1478  46    technician divorced secondary      no     119     yes   no
## 1479  77       retired  married  tertiary      no       0      no   no
## 1480  37    technician   single  tertiary      no     876     yes   no
## 1481  52   blue-collar   single   primary      no     210     yes   no
## 1482  48    management divorced  tertiary      no    5978      no   no
## 1483  43      services  married secondary      no    2478     yes   no
## 1484  57        admin.  married secondary      no     407     yes  yes
## 1485  34      services  married secondary      no    -211     yes   no
## 1486  37    technician   single secondary      no     181      no   no
## 1487  50   blue-collar  married secondary      no     562     yes   no
## 1488  34    management  married  tertiary      no     105     yes   no
## 1489  48   blue-collar  married secondary      no     341     yes  yes
## 1490  28      services   single secondary      no    2992     yes   no
## 1491  31        admin.   single secondary      no    1016     yes   no
## 1492  35   blue-collar  married secondary      no    5639     yes   no
## 1493  46    management  married  tertiary      no      48      no   no
## 1494  33    management  married  tertiary      no       0     yes   no
## 1495  56    technician  married   primary      no     675     yes   no
## 1496  60       retired divorced   primary      no    1582      no  yes
## 1497  52   blue-collar  married   primary      no    1141     yes   no
## 1498  43    technician   single secondary      no    4990     yes   no
## 1499  29        admin.   single secondary      no     454      no   no
## 1500  27        admin.  married secondary      no      73     yes   no
## 1501  50   blue-collar  married secondary      no     253     yes  yes
## 1502  46  entrepreneur  married secondary      no     583     yes   no
## 1503  49        admin.  married secondary      no    5361      no   no
## 1504  27        admin.  married secondary      no     639      no  yes
## 1505  37   blue-collar  married secondary      no     398     yes   no
## 1506  37   blue-collar  married   primary      no    1222     yes   no
## 1507  35    technician  married secondary      no     518     yes   no
## 1508  29   blue-collar   single secondary      no     992     yes  yes
## 1509  30    management  married  tertiary      no       0      no   no
## 1510  58      services  married secondary      no     307      no   no
## 1511  33     housemaid  married   primary      no    2054      no   no
## 1512  33    technician  married secondary      no     105     yes  yes
## 1513  39    management  married  tertiary      no    3518     yes   no
## 1514  26        admin.  married secondary      no     233     yes   no
## 1515  54    management  married  tertiary      no    2216     yes   no
## 1516  60    technician  married secondary      no    -247     yes   no
## 1517  40   blue-collar  married secondary      no    1386     yes  yes
## 1518  42    technician  married secondary      no     422     yes   no
## 1519  58    management  married  tertiary      no    1602      no   no
## 1520  56    technician  married secondary      no    1750      no   no
## 1521  45   blue-collar   single   primary      no     695     yes   no
## 1522  61        admin.  married secondary      no    1541      no   no
## 1523  36       unknown   single   unknown      no    1070      no   no
## 1524  34    management divorced  tertiary      no    1173      no  yes
## 1525  33        admin.   single secondary      no   21854     yes   no
## 1526  42    technician  married secondary      no      33      no   no
## 1527  35  entrepreneur  married   primary      no    -394     yes   no
## 1528  57    management  married   primary      no    6900      no   no
## 1529  39    management  married  tertiary      no       0     yes  yes
## 1530  49   blue-collar  married secondary      no     783     yes   no
## 1531  27   blue-collar  married   unknown      no     409     yes   no
## 1532  34        admin.   single secondary      no    1880     yes   no
## 1533  30    management   single secondary      no    -383     yes   no
## 1534  36   blue-collar   single secondary      no    1598     yes   no
## 1535  51  entrepreneur  married   primary      no     538      no   no
## 1536  35    technician   single  tertiary      no    2288      no   no
## 1537  30    technician   single  tertiary      no    1289     yes   no
## 1538  38    management  married  tertiary      no     484     yes   no
## 1539  43   blue-collar   single   primary      no       2     yes   no
## 1540  55      services divorced secondary      no     935      no   no
## 1541  37   blue-collar  married   primary      no    3370     yes   no
## 1542  32    technician  married secondary      no     587     yes   no
## 1543  36   blue-collar  married secondary      no       0     yes   no
## 1544  31      services  married secondary      no     447      no   no
## 1545  27      services  married secondary      no       8     yes   no
## 1546  30      services  married secondary      no    -932      no   no
## 1547  32   blue-collar  married   primary      no     400      no   no
## 1548  44   blue-collar  married   primary      no    -237     yes   no
## 1549  50    management  married  tertiary      no    1854     yes  yes
## 1550  24        admin.   single  tertiary      no     454     yes   no
## 1551  41    technician divorced  tertiary      no    3465     yes   no
## 1552  43   blue-collar  married   primary      no     547      no  yes
## 1553  23        admin.   single  tertiary      no     897     yes   no
## 1554  35    management  married  tertiary      no       0     yes   no
## 1555  56   blue-collar  married   primary      no     397     yes   no
## 1556  39   blue-collar  married secondary      no    7653      no   no
## 1557  44    management  married  tertiary      no     392     yes   no
## 1558  37      services  married   primary      no       0     yes   no
## 1559  33  entrepreneur divorced   primary      no     596      no  yes
## 1560  21       student   single   primary      no     423      no   no
## 1561  30    management   single  tertiary      no    2317     yes   no
## 1562  38   blue-collar divorced secondary      no     595     yes   no
## 1563  35   blue-collar  married   primary      no     994     yes   no
## 1564  51   blue-collar divorced secondary      no     104      no   no
## 1565  35    management  married  tertiary      no    3168      no   no
## 1566  38      services  married   unknown      no    4644     yes   no
## 1567  27    management   single  tertiary      no       3     yes  yes
## 1568  58   blue-collar  married   primary      no    3109      no   no
## 1569  47    technician  married   primary      no    1280      no   no
## 1570  54       retired  married   primary      no       0     yes   no
## 1571  34    management   single  tertiary      no    1049     yes   no
## 1572  42     housemaid   single   primary      no    5774     yes   no
## 1573  29    management   single  tertiary      no    1026      no   no
## 1574  35 self-employed  married  tertiary      no    1820     yes  yes
## 1575  52      services  married   primary      no     911      no   no
## 1576  38 self-employed  married secondary      no    -165     yes   no
## 1577  47    technician  married   unknown      no    2106     yes   no
## 1578  34    unemployed  married   primary      no     309      no   no
## 1579  41   blue-collar  married secondary      no       0     yes   no
## 1580  44    management  married  tertiary      no     368      no   no
## 1581  28      services   single secondary      no      45     yes   no
## 1582  54      services divorced   unknown      no       0     yes   no
## 1583  49   blue-collar  married   primary      no   11317     yes   no
## 1584  53    technician  married secondary      no    4930      no  yes
## 1585  43    management  married  tertiary      no      79      no   no
## 1586  57    unemployed divorced secondary      no    1088      no   no
## 1587  55      services  married   primary      no    -747     yes   no
## 1588  36    unemployed   single secondary      no     605      no   no
## 1589  50       retired  married   primary      no      14      no  yes
## 1590  46   blue-collar  married   primary      no     596     yes   no
## 1591  55      services  married secondary      no    1695     yes   no
## 1592  37   blue-collar  married secondary      no    1114     yes  yes
## 1593  31  entrepreneur  married  tertiary      no     312      no   no
## 1594  54    technician   single  tertiary      no    3233      no   no
## 1595  36   blue-collar  married   primary      no    1993     yes  yes
## 1596  40  entrepreneur  married secondary      no       0     yes  yes
## 1597  32   blue-collar   single secondary      no      33     yes   no
## 1598  56    management  married   primary      no      31     yes   no
## 1599  39    technician   single  tertiary      no    1043      no   no
## 1600  45 self-employed  married secondary      no    2278      no   no
## 1601  42    technician  married secondary      no     738      no   no
## 1602  37 self-employed divorced  tertiary      no    1513      no   no
## 1603  40    technician   single secondary      no      57      no  yes
## 1604  31    management   single  tertiary      no      59     yes  yes
## 1605  30      services   single secondary      no     399     yes  yes
## 1606  44    management  married secondary      no      27     yes   no
## 1607  49   blue-collar  married   primary      no    1387     yes  yes
## 1608  59    management  married  tertiary      no    5956      no   no
## 1609  31    management   single  tertiary      no     291     yes   no
## 1610  32    management   single  tertiary      no    2223      no   no
## 1611  46   blue-collar  married   primary      no     874      no   no
## 1612  40      services  married secondary      no    5248     yes  yes
## 1613  50    management  married  tertiary      no       4      no   no
## 1614  52    management  married  tertiary      no    1177     yes   no
## 1615  31    technician  married  tertiary      no    4089      no   no
## 1616  31        admin.  married secondary      no      23      no   no
## 1617  34    management  married  tertiary      no    1778      no   no
## 1618  34    technician  married secondary      no     260     yes   no
## 1619  53    management  married  tertiary      no       0     yes   no
## 1620  35    management   single  tertiary      no     578     yes   no
## 1621  35        admin.  married secondary      no     100     yes   no
## 1622  32   blue-collar divorced   primary      no    -156     yes   no
## 1623  39   blue-collar  married secondary      no     660     yes  yes
## 1624  51   blue-collar divorced secondary      no     113      no   no
## 1625  61       retired divorced secondary      no    4243      no   no
## 1626  33    management  married  tertiary      no     296      no   no
## 1627  25    technician   single secondary      no    1135     yes   no
## 1628  26      services  married secondary      no     104      no   no
## 1629  32        admin.   single secondary      no     184     yes   no
## 1630  27      services divorced secondary      no     397      no  yes
## 1631  32    management  married secondary      no   14611     yes   no
## 1632  52    technician  married secondary      no     945      no   no
## 1633  60       retired  married secondary      no      78      no  yes
## 1634  34    technician  married  tertiary      no    1524     yes   no
## 1635  37   blue-collar divorced secondary      no      48     yes   no
## 1636  19       student   single   unknown      no      60      no   no
## 1637  48    management  married   primary      no    1744      no   no
## 1638  48      services divorced secondary      no    -203     yes   no
## 1639  32   blue-collar divorced secondary      no    -289     yes  yes
## 1640  36    management  married secondary      no    -267      no   no
## 1641  47       unknown  married   unknown      no       0      no   no
## 1642  30   blue-collar   single secondary      no     953     yes   no
## 1643  45    technician divorced secondary      no     299     yes   no
## 1644  49   blue-collar  married secondary      no       0      no  yes
## 1645  48   blue-collar  married   primary      no     104      no   no
## 1646  25    technician   single secondary      no      31      no   no
## 1647  54   blue-collar divorced   primary      no    2656     yes   no
## 1648  47   blue-collar  married   primary      no    2642      no   no
## 1649  49    technician divorced secondary      no     790     yes   no
## 1650  28    technician  married  tertiary      no    1198      no  yes
## 1651  32   blue-collar   single secondary      no    2696     yes   no
## 1652  49    management divorced  tertiary      no    1253     yes   no
## 1653  55    management  married  tertiary      no     979      no  yes
## 1654  45        admin.  married secondary      no       0      no   no
## 1655  34    unemployed  married secondary      no     428     yes   no
## 1656  40    management  married  tertiary      no    8963      no   no
## 1657  35    technician  married secondary      no       2      no   no
## 1658  31    technician   single  tertiary      no    1710     yes   no
## 1659  28      services   single secondary      no     117     yes   no
## 1660  48    technician  married secondary      no       0     yes   no
## 1661  52    management  married   primary      no       0      no   no
## 1662  39     housemaid   single   primary      no    1340      no   no
## 1663  36   blue-collar  married   primary      no     345     yes   no
## 1664  29      services  married  tertiary      no     -62     yes  yes
## 1665  34        admin.  married secondary      no     920      no   no
## 1666  43    technician   single   unknown      no     572      no   no
## 1667  38    technician  married secondary      no       0     yes   no
## 1668  36    management divorced  tertiary      no    -978     yes   no
## 1669  44   blue-collar  married  tertiary      no    2185     yes   no
## 1670  56       retired divorced secondary      no    1005      no  yes
## 1671  57 self-employed   single secondary      no    3277      no   no
## 1672  40    technician   single secondary      no     191     yes   no
## 1673  23        admin.   single secondary      no    4681     yes   no
## 1674  36    technician  married secondary      no    -456     yes   no
## 1675  47        admin.   single secondary      no     303     yes  yes
## 1676  48    management   single  tertiary      no     399      no  yes
## 1677  28    technician   single secondary      no    2000      no   no
## 1678  32    management   single  tertiary      no       0      no   no
## 1679  44    technician  married secondary      no     945     yes   no
## 1680  52     housemaid divorced  tertiary      no    4306      no   no
## 1681  44 self-employed  married secondary      no     706      no   no
## 1682  45    unemployed  married secondary      no    -407     yes   no
## 1683  48   blue-collar  married secondary      no     865     yes   no
## 1684  28  entrepreneur  married secondary      no     490     yes   no
## 1685  29    management  married  tertiary      no      20     yes   no
## 1686  27    management   single  tertiary      no     170      no   no
## 1687  32    management   single secondary      no    1088     yes   no
## 1688  35   blue-collar   single   primary      no    -759     yes   no
## 1689  38  entrepreneur  married  tertiary      no     898     yes   no
## 1690  32    technician divorced secondary      no     210     yes  yes
## 1691  31      services  married secondary      no    -489     yes  yes
## 1692  41        admin.   single secondary      no       0     yes  yes
## 1693  34    technician  married secondary      no       1      no   no
## 1694  54        admin.  married   unknown      no    3965     yes   no
## 1695  30    management  married  tertiary      no     805      no   no
## 1696  26       student   single secondary      no    1164      no   no
## 1697  39   blue-collar  married secondary      no     481      no   no
## 1698  29      services  married secondary      no    1432      no   no
## 1699  31      services divorced secondary      no    1016     yes   no
## 1700  33   blue-collar  married secondary      no     596     yes   no
## 1701  34   blue-collar  married secondary      no     123     yes   no
## 1702  41    unemployed  married  tertiary      no    1666      no   no
## 1703  28    technician   single secondary      no     205     yes   no
## 1704  35   blue-collar   single   primary      no    -276     yes   no
## 1705  35   blue-collar   single secondary      no    1253      no   no
## 1706  29    technician   single secondary      no   22008     yes   no
## 1707  30    management  married  tertiary      no       0     yes   no
## 1708  50   blue-collar  married   primary      no    2590     yes   no
## 1709  57     housemaid divorced  tertiary      no    3767      no   no
## 1710  41   blue-collar  married secondary      no     -56     yes   no
## 1711  32     housemaid  married   primary      no     344     yes   no
## 1712  54      services  married   primary      no    1059      no   no
## 1713  25    management   single  tertiary      no     667      no   no
## 1714  42    management  married secondary      no    2580     yes   no
## 1715  36   blue-collar  married secondary      no    -231      no  yes
## 1716  41    technician  married secondary      no     767     yes  yes
## 1717  40    unemployed divorced secondary      no    1694      no   no
## 1718  41    technician  married  tertiary      no     744     yes   no
## 1719  40  entrepreneur  married   primary      no    3676     yes  yes
## 1720  27      services   single  tertiary      no    9965     yes   no
## 1721  54    management  married  tertiary      no       0      no   no
## 1722  29        admin.   single  tertiary      no     422     yes   no
## 1723  39   blue-collar  married secondary      no     507     yes   no
## 1724  33    technician   single secondary      no    -325     yes   no
## 1725  28      services   single secondary      no     129     yes   no
## 1726  36    technician divorced secondary      no     566     yes   no
## 1727  43   blue-collar  married   primary      no     445     yes   no
## 1728  50    management divorced  tertiary      no       0      no   no
## 1729  49    technician  married secondary      no     808     yes   no
## 1730  34    management  married secondary      no     240     yes   no
## 1731  33    technician divorced secondary     yes      10     yes  yes
## 1732  53    technician  married secondary      no    4807      no   no
## 1733  43    unemployed  married   primary      no     519      no   no
## 1734  32    management   single  tertiary      no     739     yes   no
## 1735  56    management divorced  tertiary      no      94      no   no
## 1736  26    management   single  tertiary      no     205      no   no
## 1737  46   blue-collar  married   primary      no     296     yes   no
## 1738  45    technician  married secondary      no    -149     yes   no
## 1739  42   blue-collar   single secondary      no     985      no   no
## 1740  39    management   single secondary      no     113     yes   no
## 1741  38    management   single  tertiary      no    8669     yes   no
## 1742  35    technician  married  tertiary      no    7050      no   no
## 1743  53 self-employed  married secondary      no       1     yes  yes
## 1744  29    management  married  tertiary      no     246     yes   no
## 1745  36    technician   single secondary      no    -206     yes   no
## 1746  25      services   single secondary      no    -107     yes   no
## 1747  44    management divorced  tertiary      no     193      no  yes
## 1748  49    technician  married secondary      no      25     yes  yes
## 1749  30    technician   single secondary      no    1286      no   no
## 1750  49   blue-collar divorced   primary      no      24     yes   no
## 1751  53 self-employed  married  tertiary      no    4397     yes   no
## 1752  28  entrepreneur  married  tertiary      no    4064      no  yes
## 1753  29    management   single  tertiary      no     307     yes   no
## 1754  28    technician   single  tertiary      no     183     yes  yes
## 1755  53    management  married  tertiary      no     490     yes   no
## 1756  35      services divorced  tertiary      no     877     yes   no
## 1757  32    management  married  tertiary      no    -383     yes   no
## 1758  26   blue-collar   single secondary      no     123      no  yes
## 1759  34    technician  married secondary      no    4248     yes   no
## 1760  43   blue-collar  married secondary      no       3     yes   no
## 1761  32        admin.  married secondary      no     277     yes   no
## 1762  24       student   single secondary      no    1925      no   no
## 1763  50   blue-collar  married   primary      no     -37     yes   no
## 1764  53        admin.   single secondary      no    1178     yes   no
## 1765  51    management  married secondary      no     873      no   no
## 1766  30    technician   single  tertiary      no      53      no   no
## 1767  54    technician  married secondary      no      25     yes   no
## 1768  35   blue-collar   single   primary      no     109     yes   no
## 1769  30    technician   single  tertiary      no    2832      no   no
## 1770  45      services  married secondary      no     350     yes  yes
## 1771  56       retired  married secondary      no     393      no  yes
## 1772  33    management  married  tertiary      no    3713     yes   no
## 1773  54      services  married secondary      no     158     yes   no
## 1774  39   blue-collar   single   unknown      no      10     yes   no
## 1775  29      services   single secondary      no       0      no   no
## 1776  49     housemaid divorced   primary      no     164     yes   no
## 1777  25       student   single secondary      no     722     yes   no
## 1778  40    technician   single  tertiary      no    1175      no   no
## 1779  52        admin.  married secondary      no     190      no   no
## 1780  35    technician  married secondary     yes     -29     yes  yes
## 1781  43   blue-collar  married   primary      no     582     yes   no
## 1782  32   blue-collar  married secondary      no     950     yes  yes
## 1783  55    management  married  tertiary      no    2537      no   no
## 1784  34      services  married secondary      no       0      no   no
## 1785  60   blue-collar  married secondary      no       0      no   no
## 1786  57        admin.  married secondary      no     567     yes   no
## 1787  58   blue-collar  married secondary      no    1075     yes   no
## 1788  26   blue-collar   single   primary      no     535     yes   no
## 1789  59        admin.  married secondary      no    1001      no   no
## 1790  58      services  married secondary      no     553      no  yes
## 1791  49    management  married  tertiary      no    2187      no   no
## 1792  37      services  married secondary      no    3429     yes  yes
## 1793  47    technician  married secondary      no     179     yes   no
## 1794  39      services divorced secondary      no    -152     yes   no
## 1795  58      services  married secondary      no     818      no   no
## 1796  30 self-employed  married  tertiary      no     805     yes   no
## 1797  44  entrepreneur  married secondary      no    6649     yes   no
## 1798  27   blue-collar  married secondary      no     556     yes   no
## 1799  42   blue-collar  married secondary      no    1598     yes  yes
## 1800  25    management  married  tertiary      no     127     yes   no
## 1801  32   blue-collar  married secondary      no     113     yes  yes
## 1802  55    technician  married secondary      no       0     yes   no
## 1803  55      services  married  tertiary      no    2877      no   no
## 1804  40      services   single secondary      no     326     yes   no
## 1805  35        admin. divorced secondary      no      45     yes   no
## 1806  25    unemployed  married secondary      no     285     yes   no
## 1807  36   blue-collar  married   unknown      no    -400     yes  yes
## 1808  32    technician  married secondary      no    6172     yes   no
## 1809  49    technician  married secondary      no    1982     yes  yes
## 1810  56      services  married   primary      no     219     yes   no
## 1811  32    management  married  tertiary      no    1388     yes   no
## 1812  26 self-employed   single  tertiary      no    3044     yes  yes
## 1813  33        admin.  married secondary      no       7     yes   no
## 1814  37    technician  married  tertiary      no     127     yes   no
## 1815  45    technician  married secondary      no    1412     yes   no
## 1816  49     housemaid  married   primary      no      78      no   no
## 1817  28        admin.   single  tertiary      no    1104     yes   no
## 1818  30   blue-collar   single   unknown      no     694     yes  yes
## 1819  31    technician  married secondary      no     585     yes   no
## 1820  54        admin. divorced   unknown      no       0      no   no
## 1821  27   blue-collar  married secondary      no      72     yes   no
## 1822  34    technician  married secondary      no      30      no   no
## 1823  41 self-employed  married secondary      no     305     yes   no
## 1824  58    technician  married secondary      no     589     yes   no
## 1825  31   blue-collar   single   primary      no    5972      no   no
## 1826  38    management divorced  tertiary      no    -980     yes   no
## 1827  30        admin.  married secondary      no      35     yes  yes
## 1828  36    technician  married secondary      no     154     yes   no
## 1829  51    technician  married  tertiary      no    2506      no   no
## 1830  53   blue-collar  married secondary      no     208      no   no
## 1831  27       student   single  tertiary      no    3687      no   no
## 1832  25   blue-collar  married secondary      no     -23     yes   no
## 1833  56    technician divorced  tertiary      no    1593     yes   no
## 1834  43        admin.  married secondary      no     324      no   no
## 1835  28      services   single secondary      no     168     yes   no
## 1836  53       retired divorced secondary      no    -477      no   no
## 1837  28 self-employed   single  tertiary      no       0     yes   no
## 1838  57    technician divorced  tertiary      no     114      no   no
## 1839  24       student   single   primary      no     474      no   no
## 1840  51   blue-collar  married   primary      no      19      no   no
## 1841  38      services  married secondary      no     433      no   no
## 1842  32      services   single secondary      no     -23      no   no
## 1843  51    management divorced  tertiary      no     492      no  yes
## 1844  45   blue-collar  married secondary      no    -149     yes   no
## 1845  33   blue-collar  married secondary      no       0      no   no
## 1846  51      services  married secondary      no       0      no  yes
## 1847  31    technician   single secondary      no     845     yes   no
## 1848  34 self-employed  married  tertiary      no     191      no   no
## 1849  42      services  married secondary      no    3236      no   no
## 1850  52      services divorced   primary      no    -644      no   no
## 1851  74       retired  married  tertiary      no    1843      no   no
## 1852  56       unknown  married   unknown      no   15088      no   no
## 1853  43 self-employed  married  tertiary      no   10072      no   no
## 1854  44    technician  married secondary      no       0     yes   no
## 1855  41   blue-collar  married   primary      no    3803     yes   no
## 1856  38   blue-collar   single secondary      no     745     yes   no
## 1857  40    technician   single  tertiary      no     693      no   no
## 1858  42   blue-collar  married secondary      no    2717     yes  yes
## 1859  48       retired  married  tertiary      no       4      no  yes
## 1860  55   blue-collar  married secondary      no     660      no   no
## 1861  38   blue-collar   single   unknown      no      10     yes   no
## 1862  37    management divorced  tertiary      no    1775      no   no
## 1863  42    unemployed  married   primary     yes    -581     yes   no
## 1864  42    technician  married secondary      no    4791     yes   no
## 1865  28    technician  married secondary      no     139     yes  yes
## 1866  54      services  married secondary      no    1301     yes   no
## 1867  43    management  married  tertiary      no    2886      no   no
## 1868  31    management divorced  tertiary      no    1742     yes   no
## 1869  50  entrepreneur  married   primary     yes     537     yes   no
## 1870  72       retired  married   primary      no     796      no   no
## 1871  54   blue-collar  married   unknown      no    1827      no   no
## 1872  57        admin.  married secondary      no    2137      no   no
## 1873  42    management  married  tertiary      no    -700     yes   no
## 1874  47     housemaid   single  tertiary      no    3232      no   no
## 1875  60        admin.  married secondary      no       0      no   no
## 1876  41   blue-collar divorced   primary      no    1498      no   no
## 1877  31 self-employed  married  tertiary      no       0     yes   no
## 1878  49    technician  married secondary      no    -215     yes   no
## 1879  60     housemaid  married   primary      no     211      no   no
## 1880  36     housemaid  married  tertiary     yes   -1941     yes   no
## 1881  37    management   single  tertiary      no     455     yes   no
## 1882  34   blue-collar  married   primary      no    1451     yes   no
## 1883  57    management  married  tertiary      no    1171      no   no
## 1884  34        admin.  married  tertiary      no     899     yes   no
## 1885  46      services divorced secondary      no     755      no   no
## 1886  36        admin.  married secondary      no     542     yes   no
## 1887  35    management  married  tertiary      no    5367      no   no
## 1888  40    management  married  tertiary      no     270      no   no
## 1889  30    management divorced secondary      no    -274     yes  yes
## 1890  53    management  married   unknown      no    2240     yes   no
## 1891  31    technician  married secondary      no     344     yes   no
## 1892  39    management  married  tertiary      no     575      no   no
## 1893  57        admin. divorced secondary      no   18268     yes   no
## 1894  54    unemployed  married   primary      no    6427     yes   no
## 1895  35        admin.  married secondary      no    -488     yes   no
## 1896  34   blue-collar  married   primary      no    1031     yes   no
## 1897  30       student   single   unknown      no    -145      no  yes
## 1898  39        admin.  married   primary      no       0      no   no
## 1899  49 self-employed  married secondary      no    1103      no   no
## 1900  58 self-employed  married   unknown      no    1187     yes   no
## 1901  37     housemaid  married   primary      no       0     yes   no
## 1902  34      services  married secondary      no     184     yes   no
## 1903  41    technician   single secondary      no      -3      no   no
## 1904  23       student   single secondary      no     556     yes   no
## 1905  47      services  married   primary      no    1496     yes   no
## 1906  35   blue-collar   single   primary      no    1277     yes   no
## 1907  42        admin. divorced secondary      no      24     yes   no
## 1908  49   blue-collar  married   primary      no     352     yes   no
## 1909  37        admin.   single secondary      no     262      no   no
## 1910  31   blue-collar   single secondary      no    4978     yes   no
## 1911  41    technician  married secondary      no    2125     yes  yes
## 1912  36    technician   single secondary      no      98      no   no
## 1913  29   blue-collar   single  tertiary      no      98      no   no
## 1914  39        admin.  married secondary      no     441      no   no
## 1915  53       retired  married secondary      no     366      no  yes
## 1916  36   blue-collar   single secondary      no     168     yes   no
## 1917  33    technician  married secondary      no     180      no   no
## 1918  29   blue-collar   single secondary      no    1166     yes   no
## 1919  43       retired  married   primary      no    7298      no   no
## 1920  32   blue-collar  married   primary      no    1518     yes   no
## 1921  44    technician  married  tertiary      no     851     yes   no
## 1922  50   blue-collar  married   primary      no    2190      no   no
## 1923  37    technician  married  tertiary      no    4596     yes   no
## 1924  31    technician   single  tertiary      no    1166     yes   no
## 1925  36   blue-collar  married secondary      no     108     yes   no
## 1926  38   blue-collar  married secondary      no    -152      no   no
## 1927  55   blue-collar divorced   primary      no     962      no  yes
## 1928  43    management  married  tertiary      no    9261     yes   no
## 1929  40   blue-collar  married secondary      no       0     yes   no
## 1930  38    technician   single secondary      no    2442      no   no
## 1931  36    management   single  tertiary      no    4123      no   no
## 1932  43    management divorced  tertiary      no    3163     yes   no
## 1933  43      services divorced secondary      no    1040     yes   no
## 1934  33   blue-collar divorced secondary      no     474      no   no
## 1935  30    management   single  tertiary      no    2186     yes   no
## 1936  54   blue-collar  married secondary      no     844      no   no
## 1937  41  entrepreneur  married  tertiary      no     221     yes   no
## 1938  46     housemaid   single   primary      no   10889      no   no
## 1939  50   blue-collar  married   primary      no     565     yes  yes
## 1940  36   blue-collar  married secondary     yes      13      no  yes
## 1941  43    management divorced  tertiary      no     481     yes   no
## 1942  32   blue-collar divorced secondary      no       8     yes   no
## 1943  25       student   single secondary      no    2975      no   no
## 1944  33   blue-collar  married secondary      no     331     yes   no
## 1945  41      services  married secondary      no    3992     yes   no
## 1946  70  entrepreneur  married  tertiary      no   15265      no   no
## 1947  37      services  married   unknown      no    -224      no   no
## 1948  52    management  married secondary      no    4873      no   no
## 1949  31  entrepreneur   single  tertiary      no     544      no  yes
## 1950  31    technician   single secondary      no    1819     yes   no
## 1951  45    management   single secondary      no     142      no  yes
## 1952  47   blue-collar  married   primary      no    4666      no   no
## 1953  50      services  married secondary      no    5699     yes   no
## 1954  49   blue-collar  married secondary      no      90     yes   no
## 1955  38    management   single  tertiary      no    2346     yes   no
## 1956  28    management  married secondary      no       3     yes   no
## 1957  42    management  married secondary      no    2608     yes   no
## 1958  30   blue-collar  married secondary      no    -269     yes   no
## 1959  37    management   single secondary      no    1572      no   no
## 1960  58       retired divorced secondary      no     439      no  yes
## 1961  46        admin.   single  tertiary      no    2889     yes   no
## 1962  33    management   single  tertiary      no     641     yes   no
## 1963  31 self-employed  married secondary      no       0     yes   no
## 1964  42        admin.   single secondary      no     -76     yes   no
## 1965  35      services   single   primary      no     739     yes   no
## 1966  32    management  married  tertiary     yes       2      no   no
## 1967  31        admin.   single secondary      no      43      no   no
## 1968  37      services  married secondary      no     -21     yes  yes
## 1969  44  entrepreneur divorced  tertiary      no     134     yes   no
## 1970  43        admin.  married secondary      no    1138      no   no
## 1971  31    technician   single  tertiary      no    1109      no   no
## 1972  37      services   single   primary      no    3715     yes   no
## 1973  41    technician  married secondary      no     201      no  yes
## 1974  32   blue-collar  married secondary      no     150     yes   no
## 1975  58    management divorced secondary      no      44     yes   no
## 1976  38    technician divorced  tertiary     yes    -530     yes   no
## 1977  52        admin.  married secondary      no     199      no   no
## 1978  33      services   single  tertiary      no    1595     yes   no
## 1979  31    unemployed  married   primary      no     213     yes   no
## 1980  52    management  married  tertiary      no     258      no   no
## 1981  30      services   single  tertiary      no    3516     yes   no
## 1982  31    technician   single secondary      no    1626      no   no
## 1983  42    management  married  tertiary      no     202      no   no
## 1984  43   blue-collar  married   primary     yes    -635     yes   no
## 1985  58    technician   single  tertiary      no     388      no   no
## 1986  32      services  married secondary      no    1977     yes  yes
## 1987  53       retired  married  tertiary      no    1778      no   no
## 1988  33        admin.   single secondary      no     395     yes   no
## 1989  47   blue-collar  married secondary      no     -18      no  yes
## 1990  36 self-employed  married  tertiary      no     254     yes   no
## 1991  58  entrepreneur  married  tertiary      no       0      no  yes
## 1992  35    management  married  tertiary      no      24     yes   no
## 1993  23       student   single secondary      no     107      no   no
## 1994  37   blue-collar  married   primary      no    2939     yes   no
## 1995  33    management divorced secondary      no     321      no  yes
## 1996  35      services  married   primary      no      31      no  yes
## 1997  57    management  married  tertiary      no    1832     yes   no
## 1998  36    technician  married secondary      no     696     yes   no
## 1999  31        admin.   single secondary      no    2076      no  yes
## 2000  47       unknown  married   unknown      no    1880      no   no
## 2001  45    unemployed   single   primary      no    2249     yes   no
## 2002  37    technician   single  tertiary      no     971      no   no
## 2003  33        admin. divorced secondary      no     661     yes   no
## 2004  24    management   single  tertiary      no     507      no   no
## 2005  46   blue-collar  married   primary      no    5461     yes   no
## 2006  43   blue-collar  married secondary      no    1127     yes   no
## 2007  30        admin.  married secondary      no     215      no  yes
## 2008  46        admin.   single secondary      no     849     yes   no
## 2009  47   blue-collar  married   primary      no      17      no   no
## 2010  49    technician  married  tertiary      no    8422     yes   no
## 2011  50   blue-collar  married secondary      no     378     yes   no
## 2012  61       retired  married secondary      no    1058      no   no
## 2013  31   blue-collar  married   primary      no     251     yes   no
## 2014  31    management  married  tertiary      no    2344     yes   no
## 2015  48   blue-collar  married secondary      no    5058      no   no
## 2016  28        admin.   single  tertiary      no    1540     yes   no
## 2017  27    unemployed   single  tertiary      no    -446     yes   no
## 2018  35        admin.   single  tertiary      no     777      no  yes
## 2019  43    unemployed  married secondary      no       0     yes   no
## 2020  36    technician  married secondary      no    1508      no   no
## 2021  39    management divorced  tertiary      no     295      no   no
## 2022  27       student   single secondary      no    2245      no   no
## 2023  34        admin.  married secondary      no      79     yes   no
## 2024  46   blue-collar  married   primary      no    1303      no   no
## 2025  39   blue-collar   single secondary      no      29     yes   no
## 2026  44     housemaid  married   primary      no    3706      no   no
## 2027  35   blue-collar   single secondary      no    4963     yes   no
## 2028  30        admin.  married secondary      no     518     yes   no
## 2029  26    technician  married secondary      no     267     yes   no
## 2030  26       student   single secondary      no     316      no   no
## 2031  28        admin.   single secondary      no     520     yes   no
## 2032  39   blue-collar  married secondary      no     474     yes  yes
## 2033  31   blue-collar  married secondary      no     512     yes   no
## 2034  55    management divorced  tertiary      no    1633      no   no
## 2035  57      services   single secondary      no    2236     yes   no
## 2036  41    technician   single   unknown      no    2701     yes   no
## 2037  26   blue-collar   single   primary      no      36      no  yes
## 2038  56    management  married   primary      no     870      no   no
## 2039  42        admin. divorced secondary      no     153     yes   no
## 2040  37    management   single  tertiary      no    1730      no   no
## 2041  55        admin.   single secondary     yes     986      no  yes
## 2042  23    technician   single secondary      no       4     yes   no
## 2043  35      services divorced secondary      no     440     yes   no
## 2044  34        admin. divorced secondary      no    1186     yes  yes
## 2045  35    technician divorced secondary      no    -281      no   no
## 2046  50   blue-collar divorced   primary      no     388      no   no
## 2047  47 self-employed  married secondary      no    4420     yes  yes
## 2048  43    management   single   primary      no       0      no   no
## 2049  58   blue-collar  married secondary      no     343     yes   no
## 2050  35    management divorced  tertiary      no     788     yes   no
## 2051  32 self-employed  married secondary      no      67      no   no
## 2052  39   blue-collar  married   unknown      no     295     yes   no
## 2053  46   blue-collar  married   primary      no       0     yes   no
## 2054  60   blue-collar  married   primary      no      93      no  yes
## 2055  29    management   single  tertiary      no    1739     yes   no
## 2056  34  entrepreneur  married  tertiary      no    1076     yes   no
## 2057  34      services  married secondary      no     404     yes   no
## 2058  30        admin.   single secondary      no    4925     yes   no
## 2059  41 self-employed  married secondary      no     323     yes   no
## 2060  55       retired  married   primary      no     868      no   no
## 2061  33    management  married  tertiary      no    2744     yes   no
## 2062  36   blue-collar divorced secondary      no     719     yes   no
## 2063  34       student   single   unknown      no    1281      no   no
## 2064  51      services  married   primary      no    -553     yes   no
## 2065  58     housemaid  married  tertiary      no     497      no   no
## 2066  25 self-employed   single  tertiary      no     882     yes   no
## 2067  50   blue-collar  married   primary      no    4121     yes  yes
## 2068  50    management  married  tertiary      no     536      no   no
## 2069  51  entrepreneur  married   primary      no     726     yes  yes
## 2070  56       retired  married secondary      no       0      no   no
## 2071  52        admin.  married secondary      no    2851      no  yes
## 2072  41   blue-collar  married secondary      no     232      no   no
## 2073  48        admin. divorced secondary      no       0      no  yes
## 2074  36    technician  married  tertiary      no      98      no   no
## 2075  31    management   single  tertiary      no   12857     yes   no
## 2076  39    management   single  tertiary      no    1509      no   no
## 2077  45    unemployed  married secondary      no    2040      no   no
## 2078  57   blue-collar  married   primary      no    1460      no   no
## 2079  44    management  married  tertiary      no     170      no   no
## 2080  42    management   single  tertiary      no     196     yes   no
## 2081  38   blue-collar  married   primary      no    1099     yes   no
## 2082  41     housemaid  married  tertiary      no     783     yes   no
## 2083  34    technician  married secondary      no    1137      no   no
## 2084  37      services   single secondary      no    -196     yes   no
## 2085  43        admin.   single secondary      no       6      no   no
## 2086  46        admin.  married secondary      no    9319     yes   no
## 2087  41   blue-collar   single secondary      no    1564     yes   no
## 2088  27   blue-collar   single   primary      no     140      no   no
## 2089  44   blue-collar  married   primary      no     195     yes   no
## 2090  35   blue-collar  married secondary      no    -461      no   no
## 2091  30    management   single  tertiary      no       0     yes   no
## 2092  36  entrepreneur  married secondary      no     302     yes   no
## 2093  41       unknown   single   unknown      no    1259      no   no
## 2094  61       retired divorced secondary      no    1857     yes   no
## 2095  38    management  married  tertiary      no    1221     yes   no
## 2096  36    technician  married secondary      no    1731     yes  yes
## 2097  34       student   single   unknown      no    1281      no   no
## 2098  46    technician  married secondary      no    9299      no   no
## 2099  31     housemaid   single  tertiary      no     287     yes   no
## 2100  43    management divorced  tertiary      no    -173      no  yes
## 2101  37   blue-collar   single secondary      no     240     yes   no
## 2102  37      services  married   primary      no       0     yes  yes
## 2103  56      services  married   primary      no     966      no  yes
## 2104  26    unemployed   single secondary      no     461      no   no
## 2105  42    unemployed  married   primary      no     259     yes   no
## 2106  31    technician  married secondary      no    -720     yes   no
## 2107  39     housemaid  married  tertiary      no      94      no   no
## 2108  34   blue-collar  married secondary      no     405     yes   no
## 2109  57        admin.  married secondary      no    1218      no   no
## 2110  48    unemployed  married  tertiary      no    1571     yes   no
## 2111  49    management   single  tertiary      no       1     yes   no
## 2112  44    technician  married   primary      no    4389      no   no
## 2113  46    technician  married  tertiary      no    4176     yes   no
## 2114  50    unemployed  married secondary      no     297     yes   no
## 2115  58    technician  married secondary      no    5618     yes   no
## 2116  61       retired  married  tertiary      no    1257      no   no
## 2117  49   blue-collar  married secondary      no    1350      no   no
## 2118  56      services divorced secondary      no    6101      no   no
## 2119  26       student   single   unknown      no     826      no   no
## 2120  44      services  married secondary      no    -230     yes  yes
## 2121  37        admin.  married secondary      no    1207     yes   no
## 2122  58   blue-collar  married   primary      no       0      no   no
## 2123  30      services   single secondary     yes    -366     yes   no
## 2124  37        admin.  married  tertiary      no     801      no   no
## 2125  36    technician   single secondary      no     333      no   no
## 2126  59    management  married  tertiary      no     518      no   no
## 2127  27      services  married secondary      no       0     yes   no
## 2128  42    unemployed  married  tertiary      no    1270     yes   no
## 2129  36        admin. divorced secondary      no     181     yes   no
## 2130  46    management   single  tertiary      no     311     yes  yes
## 2131  35    technician   single  tertiary      no       0      no   no
## 2132  24        admin.   single secondary      no     120     yes   no
## 2133  71       retired divorced secondary      no       0      no   no
## 2134  41   blue-collar  married secondary      no    2717     yes  yes
## 2135  25   blue-collar   single secondary      no    1429     yes   no
## 2136  52 self-employed  married secondary      no    1066     yes   no
## 2137  55   blue-collar  married   primary      no    3485      no   no
## 2138  52        admin.  married secondary      no    4493      no   no
## 2139  29   blue-collar  married secondary      no     415     yes   no
## 2140  44   blue-collar   single   primary      no    1593     yes   no
## 2141  46    management  married secondary      no      21     yes   no
## 2142  39   blue-collar  married secondary      no    3045      no   no
## 2143  28      services   single secondary      no     348     yes   no
## 2144  54    management  married  tertiary      no     384     yes   no
## 2145  47    technician  married secondary      no      11      no   no
## 2146  42   blue-collar  married secondary      no       0     yes   no
## 2147  40    technician  married secondary      no    -282     yes   no
## 2148  31    management  married  tertiary      no    1224     yes  yes
## 2149  37 self-employed  married  tertiary      no    1146      no  yes
## 2150  45      services  married secondary      no      27     yes  yes
## 2151  22      services   single secondary      no     652      no   no
## 2152  44        admin.   single secondary      no    2524      no   no
## 2153  59      services  married   primary      no      64     yes  yes
## 2154  27        admin.   single secondary      no    3638      no   no
## 2155  34   blue-collar  married   primary      no    -204     yes   no
## 2156  56    management  married secondary      no     208      no  yes
## 2157  33      services  married secondary      no    -384     yes   no
## 2158  28       student   single  tertiary      no    2306      no   no
## 2159  26    management   single  tertiary      no      45      no   no
## 2160  57    management divorced  tertiary      no    6468     yes   no
## 2161  52        admin.  married secondary      no    1746      no   no
## 2162  49    technician  married secondary      no     313      no   no
## 2163  44     housemaid  married   primary      no    1109     yes  yes
## 2164  30   blue-collar   single secondary      no     183     yes   no
## 2165  29        admin.   single secondary      no     200     yes   no
## 2166  43      services divorced secondary      no    -145     yes   no
## 2167  35    technician  married secondary      no     150      no   no
## 2168  34   blue-collar   single secondary      no    1599     yes   no
## 2169  34    management  married  tertiary      no     179     yes   no
## 2170  39  entrepreneur  married  tertiary      no       4     yes  yes
## 2171  33   blue-collar divorced secondary      no    3546     yes   no
## 2172  33    management  married  tertiary      no     149     yes  yes
## 2173  41    management divorced secondary      no     276     yes   no
## 2174  40    management  married secondary      no     569      no   no
## 2175  44      services divorced secondary      no      20      no   no
## 2176  56   blue-collar divorced   primary      no      12      no   no
## 2177  35    management  married  tertiary      no    5057     yes   no
## 2178  31    technician   single  tertiary      no     830     yes   no
## 2179  32      services   single  tertiary      no     785      no   no
## 2180  60    management  married secondary      no     358      no   no
## 2181  35    management   single  tertiary      no    1750     yes   no
## 2182  40        admin.  married secondary      no    1412      no   no
## 2183  37    technician  married secondary      no     720     yes   no
## 2184  35   blue-collar  married   primary      no     914     yes   no
## 2185  58        admin.  married secondary      no    3735      no   no
## 2186  46        admin. divorced secondary      no     289      no  yes
## 2187  37    management  married  tertiary      no    6771      no   no
## 2188  26       student   single secondary      no     279      no   no
## 2189  28    technician   single  tertiary      no    4513     yes   no
## 2190  48   blue-collar  married secondary      no     238     yes  yes
## 2191  36    management  married  tertiary      no   11675     yes   no
## 2192  39    technician  married secondary      no      52      no   no
## 2193  40        admin. divorced secondary      no       6      no   no
## 2194  56    management divorced  tertiary      no       0      no   no
## 2195  32        admin.   single   unknown      no    2692     yes   no
## 2196  34   blue-collar  married secondary      no    6411     yes  yes
## 2197  28    management  married  tertiary      no     247      no   no
## 2198  46    technician  married  tertiary      no    2207     yes   no
## 2199  33   blue-collar divorced   primary      no     -53     yes   no
## 2200  51      services divorced secondary      no       0      no   no
## 2201  59       retired  married   primary      no       0      no   no
## 2202  28   blue-collar  married   primary      no     -65     yes   no
## 2203  52    unemployed  married secondary      no    1639      no   no
## 2204  30    management   single  tertiary      no     220     yes   no
## 2205  41    management  married  tertiary      no     850      no   no
## 2206  37        admin.  married secondary      no      55     yes  yes
## 2207  35 self-employed   single  tertiary      no     398      no   no
## 2208  50  entrepreneur  married  tertiary      no    2410      no   no
## 2209  29    management  married  tertiary      no       0     yes   no
## 2210  54    technician  married secondary      no     415     yes   no
## 2211  27    management   single  tertiary      no    3104     yes   no
## 2212  32    management divorced  tertiary      no     530     yes   no
## 2213  39     housemaid  married   primary      no     562      no   no
## 2214  28    technician   single secondary      no     584     yes   no
## 2215  54        admin.  married  tertiary      no      19      no   no
## 2216  27      services   single secondary      no     167      no  yes
## 2217  35    management  married  tertiary      no    3161      no   no
## 2218  30    technician  married secondary      no     817     yes   no
## 2219  44  entrepreneur  married secondary      no     242      no  yes
## 2220  24        admin.   single secondary      no      66     yes   no
## 2221  33  entrepreneur   single  tertiary      no    1481     yes   no
## 2222  46   blue-collar  married secondary      no       5      no   no
## 2223  27    technician   single secondary      no     235     yes   no
## 2224  34    technician   single  tertiary     yes      -1      no   no
## 2225  55    technician divorced secondary      no    3450      no   no
## 2226  33      services  married secondary      no    4434     yes   no
## 2227  35    technician  married secondary      no      18     yes  yes
## 2228  33    unemployed   single secondary      no     237     yes   no
## 2229  51  entrepreneur  married  tertiary      no    3188     yes  yes
## 2230  57    technician divorced secondary      no       0     yes   no
## 2231  59        admin.  married secondary      no    1914     yes   no
## 2232  36      services   single secondary      no     461      no   no
## 2233  57    technician  married  tertiary      no     -40      no  yes
## 2234  46    management  married secondary      no       0      no   no
## 2235  44  entrepreneur  married secondary      no     692      no   no
## 2236  56    management  married  tertiary      no     154      no   no
## 2237  35    management   single  tertiary      no    1496     yes   no
## 2238  40  entrepreneur  married  tertiary      no      70      no   no
## 2239  30        admin.   single secondary      no      52      no  yes
## 2240  31        admin.   single secondary      no      78     yes   no
## 2241  36      services   single  tertiary      no      72     yes   no
## 2242  32   blue-collar  married  tertiary      no     143     yes  yes
## 2243  36   blue-collar  married secondary      no    1554     yes   no
## 2244  30       student   single  tertiary      no      34     yes   no
## 2245  59    unemployed divorced secondary      no    7469      no   no
## 2246  29        admin.  married secondary      no     453     yes   no
## 2247  53        admin. divorced secondary      no    -112      no   no
## 2248  41    unemployed  married secondary      no     121     yes   no
## 2249  24       student   single secondary      no      82     yes   no
## 2250  30    unemployed   single secondary      no    -306     yes   no
## 2251  31      services   single secondary      no       0     yes   no
## 2252  49 self-employed divorced  tertiary      no    3293      no   no
## 2253  30    unemployed  married secondary      no    1566      no   no
## 2254  43      services  married secondary      no       0     yes   no
## 2255  34   blue-collar  married secondary      no     587     yes   no
## 2256  44    technician  married secondary      no     858      no   no
## 2257  35      services  married secondary      no    2179      no   no
## 2258  36    management   single  tertiary      no     202      no   no
## 2259  43        admin.  married secondary      no    1625     yes  yes
## 2260  29   blue-collar   single  tertiary      no     455      no   no
## 2261  41        admin.  married secondary      no    3138      no   no
## 2262  35   blue-collar  married   unknown      no    -465      no   no
## 2263  57   blue-collar  married   unknown      no    4148      no   no
## 2264  43   blue-collar divorced secondary      no     110     yes  yes
## 2265  37    technician  married secondary      no    5287     yes  yes
## 2266  35    technician  married secondary      no    1140     yes   no
## 2267  26   blue-collar  married secondary      no    5795     yes   no
## 2268  37    technician  married  tertiary      no    1733     yes   no
## 2269  54       retired   single secondary      no     515     yes   no
## 2270  58   blue-collar  married   primary      no       0     yes   no
## 2271  49    management  married  tertiary      no     322      no   no
## 2272  39    management  married  tertiary      no    5142      no   no
## 2273  29       student  married  tertiary      no   10596     yes   no
## 2274  38      services  married secondary      no    5000      no   no
## 2275  56    management divorced  tertiary      no     -59      no  yes
## 2276  27      services   single secondary      no    9636     yes   no
## 2277  56  entrepreneur  married  tertiary      no   16125      no   no
## 2278  42   blue-collar  married   unknown      no    1123     yes   no
## 2279  19       student   single secondary      no     424      no   no
## 2280  44   blue-collar  married secondary      no    1308      no   no
## 2281  31        admin.   single secondary      no     483     yes  yes
## 2282  47    technician divorced   unknown      no     442     yes   no
## 2283  42    management  married  tertiary      no   27696      no   no
## 2284  53        admin. divorced secondary      no    2647     yes   no
## 2285  50   blue-collar  married   primary      no    1203     yes  yes
## 2286  33    management  married  tertiary      no      91      no   no
## 2287  32    management   single  tertiary      no     703     yes   no
## 2288  38        admin.  married  tertiary      no    1209      no   no
## 2289  34        admin. divorced secondary      no     183      no  yes
## 2290  27      services   single secondary      no    -266      no  yes
## 2291  50   blue-collar   single   primary      no     496     yes   no
## 2292  30 self-employed  married  tertiary     yes   -1083     yes   no
## 2293  33    technician   single  tertiary      no     318     yes   no
## 2294  58        admin. divorced secondary      no    3058     yes   no
## 2295  32    technician   single  tertiary      no    3818      no   no
## 2296  27   blue-collar  married   primary      no    1535     yes   no
## 2297  24    technician   single secondary      no    -192     yes   no
## 2298  57    management  married  tertiary      no     929      no   no
## 2299  59    management divorced  tertiary      no      51      no   no
## 2300  51        admin. divorced secondary      no    2717      no   no
## 2301  46    management  married  tertiary      no    7331      no   no
## 2302  35    technician   single secondary      no     175     yes   no
## 2303  41    technician   single secondary      no    1147     yes   no
## 2304  40       retired   single   primary      no       0      no   no
## 2305  34   blue-collar  married   primary      no    2720     yes   no
## 2306  30   blue-collar   single secondary      no     445     yes   no
## 2307  33   blue-collar   single secondary      no    4404     yes   no
## 2308  48     housemaid divorced   primary      no    1583      no  yes
## 2309  36    management  married  tertiary      no     332     yes   no
## 2310  30   blue-collar  married secondary      no     313     yes  yes
## 2311  37    unemployed   single   primary      no    1648     yes   no
## 2312  47      services  married secondary      no     459      no   no
## 2313  33   blue-collar  married secondary      no     833     yes  yes
## 2314  24       student   single secondary      no   23878      no   no
## 2315  32      services   single secondary      no    1987     yes   no
## 2316  45   blue-collar   single secondary      no     615     yes   no
## 2317  53 self-employed  married secondary      no    -488     yes   no
## 2318  55    management divorced secondary      no     204     yes   no
## 2319  32    management  married  tertiary      no    -360     yes   no
## 2320  35    technician divorced secondary      no       0      no   no
## 2321  48    technician  married  tertiary      no    9207      no   no
## 2322  43    technician divorced secondary      no    1612      no   no
## 2323  34    management   single  tertiary      no    -444     yes  yes
## 2324  58    management  married  tertiary      no    2360      no   no
## 2325  33    management   single  tertiary      no     383     yes   no
## 2326  32    unemployed   single secondary      no    8304      no   no
## 2327  43    management  married  tertiary      no     536     yes   no
## 2328  34   blue-collar  married secondary      no     283      no  yes
## 2329  42  entrepreneur  married secondary      no     718     yes   no
## 2330  47   blue-collar  married   primary     yes      25     yes  yes
## 2331  39   blue-collar  married   primary      no     879     yes   no
## 2332  48       unknown  married   unknown      no    2261      no   no
## 2333  24      services   single secondary      no    -141     yes   no
## 2334  36      services  married secondary      no       0     yes   no
## 2335  47    technician divorced secondary      no    4135     yes   no
## 2336  45   blue-collar  married   primary      no     532     yes   no
## 2337  33      services  married secondary      no       0     yes  yes
## 2338  31   blue-collar   single secondary      no    2089     yes   no
## 2339  32    technician   single secondary      no      14     yes  yes
## 2340  47      services  married secondary      no    -835     yes  yes
## 2341  27    technician   single secondary      no       8     yes   no
## 2342  37   blue-collar   single secondary      no   13156     yes   no
## 2343  52        admin.   single secondary      no    2398     yes   no
## 2344  41    technician  married secondary      no      -4      no   no
## 2345  33    technician  married secondary      no    1029     yes   no
## 2346  32   blue-collar   single secondary      no      22      no   no
## 2347  52    technician divorced secondary      no     511      no  yes
## 2348  34        admin.  married  tertiary      no     798     yes   no
## 2349  61    management  married  tertiary      no       0     yes   no
## 2350  40   blue-collar divorced   primary      no      71     yes   no
## 2351  30   blue-collar   single secondary      no     327     yes   no
## 2352  42    technician   single secondary      no     -15      no   no
## 2353  26        admin.   single secondary      no     338      no   no
## 2354  27    management  married  tertiary      no    1531     yes   no
## 2355  31    management   single  tertiary      no     241     yes   no
## 2356  34    technician   single secondary      no    1161     yes   no
## 2357  51    management divorced secondary      no     292      no   no
## 2358  60      services  married secondary      no     594     yes   no
## 2359  32    management   single  tertiary      no       2     yes   no
## 2360  49   blue-collar divorced   unknown      no      39     yes   no
## 2361  38       unknown  married   unknown      no     653      no   no
## 2362  37   blue-collar  married   primary      no     660     yes  yes
## 2363  45  entrepreneur  married  tertiary      no     369     yes   no
## 2364  33    unemployed   single   unknown      no     170     yes   no
## 2365  55   blue-collar  married   primary      no       0      no   no
## 2366  37    management  married  tertiary      no    1276      no   no
## 2367  31      services  married secondary      no     356     yes   no
## 2368  32    technician  married secondary      no    -300      no   no
## 2369  34    management   single  tertiary      no     549      no   no
## 2370  36   blue-collar   single secondary      no    1089     yes   no
## 2371  35        admin.   single secondary      no     368     yes   no
## 2372  30    management   single  tertiary      no     440     yes   no
## 2373  40    management  married  tertiary      no     373     yes  yes
## 2374  26     housemaid   single   primary     yes   -1006     yes  yes
## 2375  70       retired  married secondary      no    2626      no   no
## 2376  43    management  married  tertiary      no    3518      no   no
## 2377  29        admin.  married secondary      no     387     yes  yes
## 2378  31        admin. divorced secondary      no    1890     yes   no
## 2379  28    technician  married secondary      no    -302     yes   no
## 2380  53    technician  married secondary      no    6671     yes  yes
## 2381  46        admin.  married secondary      no     186     yes   no
## 2382  30    management   single  tertiary      no    2344     yes   no
## 2383  26   blue-collar   single   primary      no     102     yes   no
## 2384  47    technician  married   primary      no    1375     yes  yes
## 2385  55    technician   single secondary      no      99     yes   no
## 2386  54        admin.  married secondary      no    4943      no   no
## 2387  41   blue-collar   single secondary      no     925     yes   no
## 2388  34        admin.  married secondary      no     396     yes   no
## 2389  30   blue-collar  married secondary      no     365      no   no
## 2390  67       retired  married secondary      no    1443      no   no
## 2391  33   blue-collar   single secondary      no       0      no   no
## 2392  35    management  married  tertiary      no     387     yes   no
## 2393  36        admin.   single secondary      no    5871      no   no
## 2394  55       retired  married secondary      no      39      no   no
## 2395  39    management   single  tertiary      no    1234      no   no
## 2396  55    technician  married   unknown      no     240     yes   no
## 2397  37    management  married  tertiary      no     308     yes   no
## 2398  39    management  married  tertiary      no     568     yes  yes
## 2399  49        admin.  married secondary      no      82     yes   no
## 2400  48    unemployed  married   primary      no     484      no   no
## 2401  53       retired divorced   primary      no    1126      no   no
## 2402  46    technician  married secondary      no    1740     yes   no
## 2403  48    technician  married secondary      no     454     yes   no
## 2404  50   blue-collar  married secondary      no      26     yes   no
## 2405  38      services  married secondary      no    3259     yes   no
## 2406  30   blue-collar divorced secondary      no    4591     yes   no
## 2407  52      services  married secondary      no    2420     yes   no
## 2408  31   blue-collar  married secondary      no      33      no   no
## 2409  25        admin.  married secondary      no     894     yes   no
## 2410  30  entrepreneur   single  tertiary      no     999      no   no
## 2411  49   blue-collar  married   unknown      no     154     yes   no
## 2412  42   blue-collar  married   primary      no      15     yes   no
## 2413  50    technician  married secondary      no    3176      no   no
## 2414  35    technician  married secondary      no    1364     yes  yes
## 2415  29   blue-collar  married secondary      no    -114     yes   no
## 2416  55   blue-collar  married   unknown      no      23      no   no
## 2417  31    management divorced  tertiary      no     106     yes   no
## 2418  27      services   single secondary      no     430     yes   no
## 2419  29   blue-collar  married secondary      no     844     yes   no
## 2420  57     housemaid divorced   unknown      no   11632      no   no
## 2421  20       student   single  tertiary      no     556     yes   no
## 2422  29   blue-collar  married secondary      no    1171     yes   no
## 2423  59   blue-collar  married   primary      no       0     yes  yes
## 2424  37  entrepreneur  married   primary      no       0      no   no
## 2425  46    management  married  tertiary      no    1489     yes   no
## 2426  42    management  married  tertiary      no    1773      no   no
## 2427  52    technician  married   unknown      no       7      no   no
## 2428  38    technician   single  tertiary      no       9     yes   no
## 2429  46 self-employed  married secondary      no     156      no   no
## 2430  40    technician divorced secondary      no     348     yes   no
## 2431  41    management  married secondary      no    6526      no   no
## 2432  40    technician  married secondary      no     265      no   no
## 2433  58    management  married   primary      no    1021      no   no
## 2434  47    management  married secondary      no    2010      no   no
## 2435  46   blue-collar  married   primary      no     143     yes   no
## 2436  58   blue-collar  married secondary      no     381      no   no
## 2437  48      services   single   primary      no    1499     yes   no
## 2438  42      services  married  tertiary      no     412     yes   no
## 2439  30    management   single  tertiary      no    1571      no   no
## 2440  48    technician  married secondary     yes     295      no  yes
## 2441  28   blue-collar  married secondary      no       0     yes   no
## 2442  36 self-employed  married secondary      no     188     yes  yes
## 2443  40    management  married   primary      no     472     yes   no
## 2444  51   blue-collar divorced   primary      no     325     yes   no
## 2445  40        admin.  married secondary      no     153     yes   no
## 2446  50    management divorced  tertiary      no      30      no   no
## 2447  46   blue-collar  married secondary      no     176      no   no
## 2448  40   blue-collar  married   primary      no    2880     yes   no
## 2449  43    technician  married secondary      no     463      no   no
## 2450  37    management  married  tertiary      no     725      no   no
## 2451  47    management  married secondary     yes       0      no  yes
## 2452  31   blue-collar   single secondary      no       0     yes   no
## 2453  37   blue-collar  married secondary      no     298     yes   no
## 2454  38   blue-collar  married secondary      no     861     yes   no
## 2455  40        admin.  married secondary      no    2591     yes  yes
## 2456  43    technician  married secondary      no     764     yes   no
## 2457  34   blue-collar  married   primary      no    6352     yes   no
## 2458  50    management   single  tertiary      no     486      no  yes
## 2459  44    technician  married secondary      no       0      no  yes
## 2460  66       retired  married   primary      no    1004      no   no
## 2461  42    technician  married secondary      no     314      no   no
## 2462  54        admin. divorced secondary      no     791      no  yes
## 2463  30        admin. divorced secondary      no     370     yes   no
## 2464  58    management  married  tertiary      no    7387      no   no
## 2465  33    technician  married  tertiary      no     503      no   no
## 2466  37    management divorced  tertiary      no      88      no   no
## 2467  34   blue-collar  married   primary      no    -703     yes   no
## 2468  34    management divorced  tertiary      no     488     yes   no
## 2469  34    management  married  tertiary      no       0      no   no
## 2470  49   blue-collar  married secondary      no     141      no   no
## 2471  29      services   single   primary      no      95     yes   no
## 2472  46        admin.  married secondary      no      68     yes   no
## 2473  42    management  married  tertiary      no    1323     yes  yes
## 2474  54        admin.   single secondary      no    3344     yes   no
## 2475  32    management   single  tertiary      no     697      no   no
## 2476  38    unemployed   single secondary      no    1354     yes   no
## 2477  30    management   single  tertiary      no    3384      no   no
## 2478  28   blue-collar  married secondary      no      17      no   no
## 2479  61       retired  married secondary      no     483      no   no
## 2480  27    management   single  tertiary      no     616     yes   no
## 2481  65       retired  married  tertiary      no    1153      no   no
## 2482  35     housemaid  married   primary      no     113     yes   no
## 2483  56       retired  married secondary      no     102     yes   no
## 2484  32    management   single  tertiary      no    1834     yes   no
## 2485  32    technician  married secondary      no    4790     yes   no
## 2486  37    technician   single  tertiary      no    3943      no   no
## 2487  35   blue-collar  married   primary      no     378     yes   no
## 2488  37    management  married  tertiary      no       0     yes   no
## 2489  39   blue-collar   single  tertiary      no      48      no   no
## 2490  37      services   single secondary      no     608      no   no
## 2491  44   blue-collar  married   primary      no     617     yes   no
## 2492  67       retired   single  tertiary      no    3377      no   no
## 2493  46 self-employed  married   primary      no    2295     yes   no
## 2494  39        admin.   single secondary      no       0      no  yes
## 2495  58 self-employed  married  tertiary      no    8014     yes   no
## 2496  33        admin.  married secondary      no    2468     yes  yes
## 2497  32        admin.   single secondary      no     642     yes   no
## 2498  42      services  married secondary      no    -437     yes  yes
## 2499  45     housemaid  married  tertiary      no       0      no   no
## 2500  33    technician   single secondary      no     261     yes   no
## 2501  60       unknown  married  tertiary      no    2450      no   no
## 2502  50   blue-collar  married   unknown      no    1389     yes   no
## 2503  36    management   single  tertiary      no       0     yes   no
## 2504  31        admin.  married secondary      no    -581     yes   no
## 2505  25        admin.   single secondary      no     285      no   no
## 2506  34        admin.  married secondary      no    1551     yes  yes
## 2507  26       student   single secondary      no     655      no   no
## 2508  31    management  married  tertiary      no     242     yes   no
## 2509  28    technician   single  tertiary      no    1026     yes   no
## 2510  42   blue-collar  married secondary     yes    -204     yes   no
## 2511  38      services   single secondary      no    -196     yes   no
## 2512  38   blue-collar  married secondary      no    2283     yes   no
## 2513  53        admin. divorced secondary      no    2687     yes   no
## 2514  43   blue-collar  married   primary      no    1211     yes   no
## 2515  32      services   single secondary      no    2881      no   no
## 2516  49 self-employed divorced  tertiary      no    3293      no   no
## 2517  46    technician  married secondary      no    1975     yes   no
## 2518  54    unemployed   single secondary      no     380      no   no
## 2519  34    management  married   primary      no    2026     yes   no
## 2520  43    management  married  tertiary      no       0     yes   no
## 2521  36    management   single  tertiary      no     112     yes   no
## 2522  33    technician  married secondary      no    -160     yes   no
## 2523  74       retired  married   primary      no       0      no   no
## 2524  33        admin.   single secondary      no     555     yes   no
## 2525  23    management  married  tertiary      no     175     yes   no
## 2526  59    management  married secondary      no     771      no   no
## 2527  60       retired  married  tertiary      no    2196      no   no
## 2528  36      services divorced secondary      no    -330     yes  yes
## 2529  33   blue-collar  married secondary      no     312     yes   no
## 2530  39   blue-collar divorced secondary     yes    -202     yes  yes
## 2531  35    management   single  tertiary      no     996      no   no
## 2532  40  entrepreneur  married secondary      no    6403      no   no
## 2533  34        admin.  married  tertiary      no      21      no  yes
## 2534  51   blue-collar  married   primary      no     480     yes   no
## 2535  43    technician   single secondary      no     463     yes   no
## 2536  45    management  married secondary      no    1134      no  yes
## 2537  32      services  married secondary      no      59     yes  yes
## 2538  39       unknown   single   unknown      no       0      no   no
## 2539  37   blue-collar  married   primary      no      20      no  yes
## 2540  29        admin.  married   primary      no     624     yes   no
## 2541  44        admin.   single   unknown     yes    -612     yes   no
## 2542  31      services  married secondary      no   11512     yes   no
## 2543  29 self-employed   single  tertiary      no    3290      no   no
## 2544  49    unemployed  married   primary     yes      11     yes   no
## 2545  58      services divorced secondary      no    -158      no   no
## 2546  64     housemaid  married   primary      no      67      no   no
## 2547  62    management  married  tertiary      no    7458      no   no
## 2548  59 self-employed  married  tertiary      no     185      no   no
## 2549  52    technician  married secondary      no     371     yes  yes
## 2550  37      services   single secondary      no     459      no   no
## 2551  34  entrepreneur   single  tertiary     yes    1709      no  yes
## 2552  56   blue-collar  married   primary      no     551      no   no
## 2553  46    management divorced  tertiary      no     675      no  yes
## 2554  59    management  married  tertiary      no    4152     yes   no
## 2555  32   blue-collar   single secondary      no    -255      no  yes
## 2556  46    technician divorced secondary      no       0     yes  yes
## 2557  39        admin.  married secondary      no     168     yes   no
## 2558  46   blue-collar  married   primary      no    5393     yes   no
## 2559  44      services  married secondary      no     742      no   no
## 2560  35    technician   single   primary      no     744     yes   no
## 2561  54      services  married   primary      no     198     yes   no
## 2562  35    technician divorced secondary      no       0      no   no
## 2563  51  entrepreneur   single  tertiary      no       0      no   no
## 2564  34      services  married  tertiary      no    1442      no   no
## 2565  77       retired  married secondary      no    4112      no   no
## 2566  45   blue-collar  married secondary      no    4646     yes   no
## 2567  45        admin. divorced secondary      no    1201      no   no
## 2568  46    technician  married secondary      no    1028     yes   no
## 2569  28      services  married secondary      no     462     yes  yes
## 2570  45   blue-collar  married secondary      no     196     yes   no
## 2571  28     housemaid   single secondary      no     781     yes   no
## 2572  29      services  married secondary      no    -597      no   no
## 2573  37      services   single secondary      no     248     yes   no
## 2574  58    unemployed   single secondary      no    1013     yes   no
## 2575  31      services  married secondary      no     338     yes   no
## 2576  40        admin.  married secondary      no     824     yes   no
## 2577  32        admin.   single secondary      no     131     yes   no
## 2578  82       retired  married secondary      no     276      no   no
## 2579  29        admin.   single secondary      no      65     yes   no
## 2580  42      services divorced secondary      no     241     yes   no
## 2581  56     housemaid divorced secondary      no    1866      no  yes
## 2582  32   blue-collar  married secondary      no    1914     yes   no
## 2583  54   blue-collar  married secondary      no    1487     yes   no
## 2584  46    technician  married secondary      no       0     yes   no
## 2585  31    technician  married secondary      no       0      no   no
## 2586  47   blue-collar  married   primary      no       0      no   no
## 2587  34    management divorced  tertiary      no      27      no  yes
## 2588  47   blue-collar divorced secondary      no    1480     yes   no
## 2589  35        admin.   single  tertiary      no     994      no   no
## 2590  38    management  married  tertiary      no     546      no   no
## 2591  33    management divorced  tertiary      no     723     yes   no
## 2592  49    technician  married secondary      no    3635     yes   no
## 2593  35    technician  married secondary      no    -288     yes  yes
## 2594  40      services  married   primary      no    1117     yes   no
## 2595  48 self-employed  married secondary      no    1175     yes  yes
## 2596  43        admin.  married secondary      no     323     yes  yes
## 2597  29    management  married  tertiary      no       1     yes  yes
## 2598  60       retired  married   primary      no       3      no   no
## 2599  39        admin.  married secondary      no     104     yes   no
## 2600  31   blue-collar  married secondary      no     297     yes   no
## 2601  51   blue-collar  married secondary      no    4695      no   no
## 2602  33   blue-collar  married secondary      no     308     yes   no
## 2603  39   blue-collar  married   primary      no     315     yes   no
## 2604  28      services  married secondary      no     376      no  yes
## 2605  50   blue-collar  married secondary      no    -581     yes   no
## 2606  77       retired  married   primary      no    2590      no   no
## 2607  49    technician  married  tertiary      no    6138      no   no
## 2608  48        admin.  married   primary      no       3     yes   no
## 2609  34    management  married  tertiary      no     176      no   no
## 2610  42    technician   single secondary      no     146      no   no
## 2611  49  entrepreneur  married secondary      no     687      no   no
## 2612  56       retired  married   primary      no   16432      no   no
## 2613  29    unemployed  married secondary      no      39      no  yes
## 2614  33      services   single secondary      no     406     yes   no
## 2615  34    management   single  tertiary      no    1012     yes  yes
## 2616  57    unemployed  married  tertiary      no     209      no   no
## 2617  42    unemployed  married secondary      no    -523     yes   no
## 2618  54      services  married secondary      no     869      no   no
## 2619  43    management divorced secondary      no      51      no   no
## 2620  52  entrepreneur   single  tertiary      no    3469     yes   no
## 2621  45   blue-collar  married   unknown      no     248     yes   no
## 2622  36    management  married  tertiary      no     953     yes  yes
## 2623  27    management   single  tertiary      no       0     yes   no
## 2624  47    management   single secondary      no    -246     yes   no
## 2625  37    technician   single secondary      no     363     yes   no
## 2626  34   blue-collar  married   unknown      no      41     yes   no
## 2627  59    management  married   unknown      no    3428     yes  yes
## 2628  56    management  married  tertiary      no    1803      no   no
## 2629  50    management  married secondary      no    2717     yes   no
## 2630  59   blue-collar  married   primary      no      99     yes   no
## 2631  45        admin.  married   unknown      no    -299     yes   no
## 2632  32    technician  married  tertiary      no     903     yes   no
## 2633  43   blue-collar  married   primary      no      46     yes   no
## 2634  31      services   single secondary      no      13      no  yes
## 2635  46    technician   single secondary     yes   -1124     yes  yes
## 2636  38   blue-collar   single secondary      no     334     yes   no
## 2637  31    management   single  tertiary      no      18      no   no
## 2638  43    technician  married  tertiary      no    1485      no   no
## 2639  58       retired  married   primary      no      69      no   no
## 2640  36    management  married  tertiary      no     406      no   no
## 2641  33   blue-collar   single   primary      no     127     yes   no
## 2642  30      services   single  tertiary      no      44      no   no
## 2643  38  entrepreneur   single  tertiary     yes       0     yes   no
## 2644  48    technician  married secondary      no     504      no  yes
## 2645  35    technician   single secondary      no       2      no   no
## 2646  36   blue-collar  married   unknown      no    -417     yes   no
## 2647  41        admin.   single secondary      no    1322     yes   no
## 2648  52    management  married  tertiary      no    2578      no   no
## 2649  36    management divorced  tertiary      no    2397      no   no
## 2650  49    management  married  tertiary      no    1533      no   no
## 2651  42    management  married  tertiary      no    4014     yes   no
## 2652  55    management  married  tertiary      no      86      no   no
## 2653  52        admin.   single secondary      no    2332      no   no
## 2654  51  entrepreneur  married   unknown      no    3404      no   no
## 2655  55    technician  married  tertiary      no     199      no   no
## 2656  50      services  married secondary      no     901     yes   no
## 2657  48      services   single   primary      no     848     yes   no
## 2658  46    management  married  tertiary      no     144      no   no
## 2659  36      services  married secondary      no    1746     yes   no
## 2660  34   blue-collar  married secondary      no    -185     yes  yes
## 2661  33  entrepreneur  married secondary      no    3140     yes  yes
## 2662  27    technician   single secondary      no     629     yes  yes
## 2663  32      services  married secondary      no     109     yes   no
## 2664  27    management   single secondary      no     442     yes   no
## 2665  33   blue-collar   single secondary      no    6285     yes   no
## 2666  50    technician  married secondary      no       0     yes   no
## 2667  40   blue-collar  married secondary      no    3316      no   no
## 2668  41    management  married  tertiary      no    1409      no   no
## 2669  25    technician divorced secondary      no      86      no  yes
## 2670  37   blue-collar  married   primary      no      53     yes   no
## 2671  54 self-employed  married  tertiary      no     368      no   no
## 2672  39    management  married  tertiary      no    -468     yes  yes
## 2673  31    management  married  tertiary      no     777     yes   no
## 2674  30  entrepreneur  married secondary      no    2551     yes   no
## 2675  67       retired   single   primary      no     491      no   no
## 2676  46   blue-collar  married secondary      no    2944      no   no
## 2677  26    management   single  tertiary      no     157     yes   no
## 2678  38        admin.   single secondary      no     245     yes  yes
## 2679  45    management  married  tertiary      no    1847      no   no
## 2680  40    management   single  tertiary      no     269     yes   no
## 2681  29    technician   single secondary      no      18      no   no
## 2682  38    management  married  tertiary      no     465     yes  yes
## 2683  57       retired  married   primary      no    9367      no   no
## 2684  36   blue-collar  married secondary      no     142     yes   no
## 2685  20       student   single secondary      no     291      no   no
## 2686  28        admin.   single secondary      no     551      no  yes
## 2687  39    technician divorced secondary      no     807     yes  yes
## 2688  39    technician  married secondary      no     616      no   no
## 2689  51    technician  married secondary      no     371     yes  yes
## 2690  37    technician  married secondary      no    6384     yes  yes
## 2691  35        admin.   single secondary      no    2452     yes   no
## 2692  35    management  married  tertiary      no     972     yes  yes
## 2693  34        admin.  married  tertiary      no      10      no   no
## 2694  38    technician  married secondary      no     114      no   no
## 2695  34      services  married secondary      no     798     yes   no
## 2696  30    management  married  tertiary      no    1185     yes   no
## 2697  29      services   single secondary      no     703     yes   no
## 2698  32 self-employed  married   primary      no     102     yes   no
## 2699  40   blue-collar  married   unknown      no     874      no   no
## 2700  49   blue-collar  married   primary      no     391     yes   no
## 2701  46  entrepreneur  married   primary      no       0      no   no
## 2702  51 self-employed  married  tertiary      no     146      no   no
## 2703  46        admin.  married secondary      no     120     yes   no
## 2704  59    management   single secondary      no     671     yes  yes
## 2705  50       retired  married  tertiary      no       4     yes  yes
## 2706  56    technician  married secondary      no     589     yes   no
## 2707  47    management  married secondary      no    -521     yes   no
## 2708  70       retired divorced   primary      no     482      no   no
## 2709  49    management  married  tertiary      no     470      no   no
## 2710  60       retired  married   unknown      no     209      no   no
## 2711  29        admin.   single   unknown      no    2083     yes   no
## 2712  34 self-employed  married  tertiary      no    1545     yes   no
## 2713  53   blue-collar  married   primary      no    4641      no   no
## 2714  52    technician  married secondary      no       0      no   no
## 2715  76       retired  married secondary      no    4112      no   no
## 2716  47   blue-collar  married   primary      no     373     yes   no
## 2717  34   blue-collar  married   primary      no   17946     yes   no
## 2718  34   blue-collar   single secondary      no      62     yes   no
## 2719  55    management  married   primary      no    1691     yes   no
## 2720  39    management divorced  tertiary      no    4692     yes   no
## 2721  33    management  married  tertiary      no     808     yes   no
## 2722  35    management  married  tertiary      no       0      no   no
## 2723  52    management divorced  tertiary      no     427      no  yes
## 2724  30    management   single  tertiary      no     604      no  yes
## 2725  31    technician   single secondary      no     754      no   no
## 2726  41   blue-collar  married secondary      no     167      no   no
## 2727  38      services  married   unknown      no      15     yes   no
## 2728  37    technician  married secondary      no     332     yes   no
## 2729  35      services divorced secondary      no    -718     yes   no
## 2730  33        admin.   single secondary      no     303      no   no
## 2731  24       student   single  tertiary      no     834      no   no
## 2732  36   blue-collar  married   unknown      no    1023     yes   no
## 2733  38    management   single  tertiary      no      83      no  yes
## 2734  46     housemaid  married  tertiary      no     184      no   no
## 2735  24   blue-collar  married secondary      no    -254     yes  yes
## 2736  38    technician  married  tertiary      no    -255     yes  yes
## 2737  43  entrepreneur  married  tertiary      no     903     yes   no
## 2738  33    technician  married secondary      no    1021     yes   no
## 2739  38        admin.  married   unknown      no    4583     yes   no
## 2740  34    management   single  tertiary      no   13014      no   no
## 2741  26        admin.   single secondary      no     102      no  yes
## 2742  27    management   single  tertiary      no   12956     yes   no
## 2743  54       retired  married secondary      no    3846     yes  yes
## 2744  62    management  married  tertiary      no       0      no   no
## 2745  37     housemaid  married   primary      no    2410      no   no
## 2746  25    unemployed  married secondary      no     157     yes   no
## 2747  38    management  married secondary      no    3500     yes   no
## 2748  56    unemployed divorced   primary      no     438      no   no
## 2749  52    unemployed  married secondary      no      94      no   no
## 2750  54        admin.  married   unknown      no     140      no   no
## 2751  59    management divorced  tertiary      no      14      no  yes
## 2752  38        admin.  married secondary      no    1839      no   no
## 2753  30    technician   single secondary      no     237     yes   no
## 2754  30       student   single secondary      no      25      no   no
## 2755  33   blue-collar  married   primary      no      80     yes   no
## 2756  34    management  married  tertiary      no     557     yes   no
## 2757  66       unknown divorced   unknown      no    1993     yes   no
## 2758  38    technician  married secondary      no     525     yes  yes
## 2759  35    technician   single  tertiary      no      33      no   no
## 2760  31    management  married  tertiary      no     713     yes   no
## 2761  45   blue-collar  married   unknown      no     850      no   no
## 2762  62    management  married  tertiary      no       0      no   no
## 2763  52   blue-collar  married secondary      no     262      no   no
## 2764  24       student   single secondary      no    1234      no   no
## 2765  46        admin.  married secondary      no     154      no   no
## 2766  57    technician  married   primary      no    1276     yes   no
## 2767  37   blue-collar  married   primary      no      95     yes   no
## 2768  56       retired  married secondary      no     728      no   no
## 2769  43   blue-collar  married secondary     yes     128     yes   no
## 2770  43    management  married  tertiary      no     348      no  yes
## 2771  40    technician  married secondary      no    -396     yes   no
## 2772  56    technician divorced secondary      no     397     yes   no
## 2773  38    technician  married secondary      no     275     yes   no
## 2774  33    management divorced  tertiary      no    2695     yes   no
## 2775  37  entrepreneur  married   unknown      no    1134     yes   no
## 2776  83       retired divorced   primary      no      20      no   no
## 2777  29    technician  married  tertiary      no    4557      no   no
## 2778  47    technician  married secondary      no    3519      no  yes
## 2779  39    management  married secondary      no     794     yes   no
## 2780  48    management  married  tertiary      no     732      no   no
## 2781  27    unemployed   single   primary      no     799      no   no
## 2782  31    technician  married  tertiary      no      15      no   no
## 2783  54   blue-collar  married   primary      no     211      no   no
## 2784  40    technician divorced secondary      no       0      no   no
## 2785  39   blue-collar  married secondary      no     281      no   no
## 2786  34   blue-collar   single secondary      no     152     yes   no
## 2787  52    technician  married  tertiary      no    1785      no   no
## 2788  43   blue-collar  married   primary      no     197     yes   no
## 2789  40    management  married  tertiary      no      20     yes   no
## 2790  41   blue-collar  married secondary      no    -664     yes  yes
## 2791  56    technician  married secondary      no     225     yes   no
## 2792  39   blue-collar  married   primary      no    2003     yes   no
## 2793  21       student   single   primary      no    1596      no   no
## 2794  50      services  married secondary      no       1      no   no
## 2795  32    management  married  tertiary      no    2172     yes   no
## 2796  30    management   single  tertiary      no     147      no   no
## 2797  38    management  married secondary      no       0     yes   no
## 2798  34    technician  married secondary      no     -56     yes   no
## 2799  44   blue-collar  married   primary      no     300     yes   no
## 2800  31     housemaid  married   primary      no      25      no   no
## 2801  36  entrepreneur divorced  tertiary      no     299     yes   no
## 2802  59    management  married  tertiary      no    5314      no   no
## 2803  29      services   single secondary      no       0     yes   no
## 2804  43   blue-collar  married secondary      no     699     yes  yes
## 2805  51   blue-collar  married   primary      no     303     yes   no
## 2806  30    management  married  tertiary      no     604      no   no
## 2807  33    technician  married secondary      no       0      no   no
## 2808  31        admin.   single  tertiary      no       0      no   no
## 2809  34   blue-collar  married secondary      no     205     yes  yes
## 2810  52    unemployed  married   primary      no     255      no  yes
## 2811  44   blue-collar  married secondary      no     476      no   no
## 2812  36 self-employed  married  tertiary      no     328     yes  yes
## 2813  55    management  married  tertiary      no       0      no   no
## 2814  57       retired  married secondary      no     523      no  yes
## 2815  41    management  married  tertiary      no     226      no   no
## 2816  35    management   single  tertiary      no    1756      no   no
## 2817  50   blue-collar  married   primary      no    2610     yes  yes
## 2818  55        admin. divorced   unknown      no     789     yes   no
## 2819  35        admin.  married   unknown      no    1055      no   no
## 2820  33    management   single  tertiary      no     -61      no   no
## 2821  35    management  married  tertiary      no      93      no   no
## 2822  35 self-employed divorced secondary      no    3443      no   no
## 2823  51     housemaid  married secondary      no    2239      no   no
## 2824  26    technician   single secondary      no    1256      no   no
## 2825  46   blue-collar  married   primary      no      85     yes   no
## 2826  54  entrepreneur  married secondary      no       0      no   no
## 2827  21    technician   single   unknown      no     360      no   no
## 2828  45     housemaid  married  tertiary      no      40     yes   no
## 2829  36   blue-collar divorced secondary      no     107     yes   no
## 2830  65       retired divorced secondary      no     744      no   no
## 2831  26   blue-collar   single secondary      no      96     yes   no
## 2832  46      services  married secondary      no    2420      no   no
## 2833  57    management  married  tertiary      no    3250      no   no
## 2834  48        admin.  married secondary      no     257     yes   no
## 2835  30      services divorced secondary      no      63     yes   no
## 2836  46        admin.  married secondary      no    3145     yes   no
## 2837  28    management  married  tertiary      no    1480     yes   no
## 2838  35        admin.   single secondary      no    1721      no   no
## 2839  30    technician  married secondary      no    -280     yes   no
## 2840  31    technician   single  tertiary      no      25      no   no
## 2841  23   blue-collar   single   primary      no    8627     yes   no
## 2842  41    unemployed divorced secondary      no     271     yes   no
## 2843  47    technician  married secondary      no   17206     yes   no
## 2844  55     housemaid  married secondary      no     127     yes   no
## 2845  44    technician divorced secondary      no      12      no   no
## 2846  38    management  married  tertiary      no    1074      no   no
## 2847  49    technician   single secondary      no    -188     yes  yes
## 2848  27   blue-collar   single   unknown      no     -15     yes  yes
## 2849  57    management  married  tertiary      no       0     yes  yes
## 2850  30      services   single  tertiary      no    1788      no   no
## 2851  35    management   single  tertiary      no     592      no  yes
## 2852  41    technician divorced secondary      no     475     yes   no
## 2853  28   blue-collar  married secondary      no      83     yes   no
## 2854  41   blue-collar  married   primary     yes      76      no  yes
## 2855  37    management   single  tertiary      no     509     yes   no
## 2856  25      services   single secondary      no      32     yes   no
## 2857  27   blue-collar   single secondary      no    2752     yes   no
## 2858  41    management  married secondary      no     280     yes   no
## 2859  46   blue-collar  married secondary      no    1109     yes   no
## 2860  28        admin.  married secondary      no     -97     yes   no
## 2861  23    technician   single secondary      no     283     yes   no
## 2862  36        admin. divorced secondary      no     543     yes   no
## 2863  45       unknown divorced   unknown      no       0      no   no
## 2864  32    technician   single  tertiary      no     418      no  yes
## 2865  38    technician  married secondary      no     254     yes   no
## 2866  26   blue-collar   single secondary      no       8     yes   no
## 2867  27   blue-collar   single secondary      no     541     yes   no
## 2868  36  entrepreneur  married  tertiary      no       0     yes   no
## 2869  39 self-employed  married  tertiary      no    -176     yes   no
## 2870  38  entrepreneur   single  tertiary      no    -281     yes   no
## 2871  28    technician  married secondary      no    1180     yes   no
## 2872  52        admin.  married secondary      no     692     yes   no
## 2873  35    technician  married  tertiary      no     118      no   no
## 2874  30    technician   single secondary      no     341      no   no
## 2875  44    management divorced  tertiary      no      71     yes   no
## 2876  35    technician   single  tertiary      no     632      no   no
## 2877  30    management   single  tertiary      no     156     yes   no
## 2878  49        admin.   single secondary      no     981     yes   no
## 2879  39   blue-collar  married   unknown      no    2952     yes   no
## 2880  47    management   single  tertiary      no    1187      no   no
## 2881  33   blue-collar   single secondary      no    1794     yes   no
## 2882  18       student   single   unknown      no     108      no   no
## 2883  41      services  married   primary      no     450     yes   no
## 2884  44    management  married  tertiary      no     677     yes   no
## 2885  22     housemaid   single secondary      no     650     yes   no
## 2886  48   blue-collar  married   primary      no    1778     yes   no
## 2887  42    technician divorced secondary      no       0     yes   no
## 2888  44        admin.  married secondary      no      26     yes   no
## 2889  39 self-employed  married   primary      no    2165     yes   no
## 2890  25   blue-collar   single secondary      no    1857     yes   no
## 2891  34      services   single secondary      no     258     yes   no
## 2892  32    technician   single secondary      no       0      no   no
## 2893  30        admin.   single secondary      no     873      no   no
## 2894  32      services  married secondary      no     182      no   no
## 2895  33    management  married  tertiary      no       1     yes  yes
## 2896  33    technician   single  tertiary      no    1393     yes   no
## 2897  33  entrepreneur  married  tertiary      no    -886     yes  yes
## 2898  31   blue-collar  married secondary      no    1354     yes  yes
## 2899  40    technician  married secondary      no    4441     yes   no
## 2900  35        admin.   single secondary      no      57     yes   no
## 2901  29 self-employed   single  tertiary      no     476     yes   no
## 2902  36 self-employed   single  tertiary      no     351      no   no
## 2903  43     housemaid  married secondary      no    5233      no   no
## 2904  27    management   single  tertiary      no    2849      no   no
## 2905  37      services divorced secondary      no     731     yes   no
## 2906  37    technician  married secondary      no    1142     yes   no
## 2907  52    management  married  tertiary      no       0      no   no
## 2908  40    management  married  tertiary      no     572      no   no
## 2909  34    technician   single secondary      no     124      no   no
## 2910  48    technician   single secondary      no     329      no   no
## 2911  40        admin.  married secondary      no       0      no   no
## 2912  50   blue-collar  married secondary      no     289      no   no
## 2913  36    management  married  tertiary      no     753      no   no
## 2914  35    management  married  tertiary      no    -126      no   no
## 2915  18       student   single   primary      no     608      no   no
## 2916  26    technician  married  tertiary      no    2026      no   no
## 2917  26   blue-collar   single secondary      no     311     yes   no
## 2918  56       retired  married secondary      no    5879      no   no
## 2919  57    management  married secondary      no    2155      no  yes
## 2920  53   blue-collar  married secondary      no     148     yes   no
## 2921  38    technician   single  tertiary      no    1369     yes   no
## 2922  29    management  married secondary      no     147     yes  yes
## 2923  36 self-employed  married  tertiary      no     506      no   no
## 2924  48    management  married  tertiary      no   -1080     yes  yes
## 2925  32    technician  married  tertiary      no    2688      no   no
## 2926  30    management  married secondary      no       0      no   no
## 2927  36   blue-collar  married secondary      no    7265      no   no
## 2928  48    unemployed  married secondary      no   11371     yes   no
## 2929  32    technician   single secondary      no      10      no   no
## 2930  55   blue-collar  married   unknown      no    7561      no   no
## 2931  30    management   single  tertiary      no     119      no   no
## 2932  33    technician  married  tertiary      no       0     yes   no
## 2933  30    technician   single secondary      no    3096     yes   no
## 2934  38    management  married secondary      no   10357      no   no
## 2935  43   blue-collar  married secondary      no    1559     yes   no
## 2936  52   blue-collar  married secondary      no    2206     yes   no
## 2937  30      services  married secondary      no     683     yes   no
## 2938  34      services   single secondary      no       2     yes   no
## 2939  28    technician   single secondary      no     113      no   no
## 2940  24   blue-collar  married secondary      no     142     yes  yes
## 2941  43   blue-collar  married   primary      no    2047     yes   no
## 2942  36    technician   single  tertiary      no      97      no   no
## 2943  25 self-employed   single  tertiary      no     557      no   no
## 2944  27      services  married secondary      no       0     yes   no
## 2945  22       student   single secondary      no     948      no   no
## 2946  58    management  married secondary      no    -382      no   no
## 2947  31    management   single  tertiary      no     170     yes  yes
## 2948  29  entrepreneur   single secondary      no     404      no   no
## 2949  35     housemaid  married secondary      no     738     yes   no
## 2950  29      services  married   primary      no     549     yes   no
## 2951  32    technician  married secondary      no     901     yes   no
## 2952  30        admin.  married secondary      no     116     yes   no
## 2953  37      services  married secondary      no    1694     yes  yes
## 2954  24      services  married secondary      no    1354     yes  yes
## 2955  29        admin.   single secondary      no    1751      no   no
## 2956  51     housemaid  married secondary      no     294      no   no
## 2957  28   blue-collar  married  tertiary      no     417     yes  yes
## 2958  25    unemployed  married secondary      no     715      no   no
## 2959  43    technician   single secondary      no     257     yes   no
## 2960  47    management divorced  tertiary      no    2105      no  yes
## 2961  35     housemaid   single   unknown      no    4378      no   no
## 2962  60 self-employed  married   primary      no      46     yes   no
## 2963  35   blue-collar  married secondary      no    1602     yes  yes
## 2964  34      services   single secondary      no      34     yes  yes
## 2965  38    technician   single  tertiary      no      25     yes   no
## 2966  54    technician  married secondary      no       0      no   no
## 2967  48   blue-collar  married secondary      no     264      no   no
## 2968  48 self-employed  married   primary      no    1204     yes   no
## 2969  39    management  married  tertiary      no       0     yes   no
## 2970  52    technician  married secondary      no     989      no   no
## 2971  42   blue-collar   single   primary      no    4930      no   no
## 2972  53      services divorced   primary      no    -291     yes  yes
## 2973  31   blue-collar  married secondary      no     -45     yes   no
## 2974  47    technician  married  tertiary      no    1430     yes   no
## 2975  59     housemaid  married   primary      no    1100      no   no
## 2976  38        admin.  married secondary      no       8     yes   no
## 2977  39   blue-collar  married   primary      no    2133     yes  yes
## 2978  35    technician   single  tertiary      no    7546     yes   no
## 2979  73       retired  married   primary      no     934      no   no
## 2980  45    technician divorced  tertiary      no     378     yes  yes
## 2981  58    management divorced  tertiary      no     108      no   no
## 2982  47    management  married  tertiary      no   -1379     yes   no
## 2983  48    management   single  tertiary      no     830      no   no
## 2984  39  entrepreneur  married secondary      no       0     yes   no
## 2985  41    technician   single secondary      no     143      no   no
## 2986  29    technician   single secondary      no     740     yes   no
## 2987  58       retired  married   primary      no    1980      no   no
## 2988  53   blue-collar  married   primary      no    1794     yes   no
## 2989  52        admin.  married   primary      no    2281     yes  yes
## 2990  33    management   single secondary      no    1973     yes   no
## 2991  36    unemployed   single  tertiary      no     536      no   no
## 2992  32    management   single  tertiary      no       3     yes   no
## 2993  81       retired divorced   primary      no       0      no   no
## 2994  37      services  married secondary      no     616     yes   no
## 2995  30    management  married  tertiary      no     623     yes   no
## 2996  20       student   single secondary      no      53      no   no
## 2997  38      services  married   primary      no     -93     yes   no
## 2998  40    technician divorced  tertiary      no     568     yes   no
## 2999  55   blue-collar  married   primary      no     119      no   no
## 3000  30        admin.  married secondary     yes      23      no  yes
## 3001  55   blue-collar  married   primary      no     663     yes   no
## 3002  30   blue-collar  married secondary      no       0      no  yes
## 3003  47      services  married secondary      no    1160     yes   no
## 3004  30    management   single  tertiary      no     872     yes   no
## 3005  32   blue-collar  married secondary      no     180     yes   no
## 3006  31    management   single  tertiary      no      37      no   no
## 3007  52    management  married  tertiary      no    1339     yes   no
## 3008  36   blue-collar  married   unknown      no       6      no   no
## 3009  63       retired  married secondary      no     474      no   no
## 3010  35        admin.  married secondary      no    3187     yes   no
## 3011  32    management   single  tertiary      no     914     yes   no
## 3012  44   blue-collar  married   primary      no       0     yes   no
## 3013  32   blue-collar   single secondary      no    3044     yes   no
## 3014  45   blue-collar  married secondary      no    1003     yes   no
## 3015  41    management divorced  tertiary      no    3355      no   no
## 3016  44    technician  married  tertiary      no     964      no   no
## 3017  59    management divorced   primary      no   13308     yes   no
## 3018  31    management  married  tertiary      no    1755     yes   no
## 3019  39   blue-collar  married   primary      no     467     yes   no
## 3020  40    management divorced  tertiary      no    3355      no   no
## 3021  36    management   single  tertiary      no     317      no   no
## 3022  31    technician divorced secondary      no       0      no   no
## 3023  29    management   single  tertiary      no     722     yes   no
## 3024  45   blue-collar  married   primary      no     185      no   no
## 3025  37    technician  married secondary      no     603      no   no
## 3026  24   blue-collar   single secondary      no    -398     yes   no
## 3027  37    management   single  tertiary      no     105     yes   no
## 3028  30    technician   single  tertiary      no     985     yes   no
## 3029  33   blue-collar  married secondary      no       0      no   no
## 3030  59   blue-collar  married   primary      no     914      no   no
## 3031  33    management   single  tertiary      no     417     yes   no
## 3032  40   blue-collar   single   unknown      no      29      no   no
## 3033  40   blue-collar  married   primary      no    1802     yes   no
## 3034  75 self-employed  married   unknown      no    4984      no   no
## 3035  34   blue-collar   single secondary      no      47     yes   no
## 3036  24      services   single secondary      no      11     yes   no
## 3037  37   blue-collar   single secondary      no     277     yes   no
## 3038  51    technician divorced   primary      no     548      no   no
## 3039  39        admin.  married secondary      no    2783     yes   no
## 3040  50   blue-collar  married secondary      no       5      no   no
## 3041  35  entrepreneur  married  tertiary      no     753      no   no
## 3042  29    management   single  tertiary      no      91     yes   no
## 3043  37   blue-collar  married   primary      no    1534     yes   no
## 3044  32    technician   single secondary      no      43      no   no
## 3045  41      services  married   primary      no     373     yes   no
## 3046  32    management   single  tertiary      no     718     yes   no
## 3047  56   blue-collar  married secondary      no     345     yes   no
## 3048  35    management   single  tertiary      no       4     yes   no
## 3049  37   blue-collar  married   primary      no       0     yes   no
## 3050  31    technician   single  tertiary      no     319      no  yes
## 3051  36    management  married  tertiary      no      22      no   no
## 3052  25      services  married secondary      no     806     yes  yes
## 3053  40        admin.   single secondary      no    2360     yes   no
## 3054  57     housemaid  married   primary      no     151     yes   no
## 3055  31    technician   single secondary      no    -348     yes   no
## 3056  53       retired  married secondary      no     136      no   no
## 3057  32      services   single secondary      no      72      no   no
## 3058  33        admin.   single  tertiary      no   12704     yes   no
## 3059  45      services  married secondary      no    6397     yes   no
## 3060  42    technician  married secondary      no     525      no   no
## 3061  30 self-employed  married  tertiary      no    1930      no   no
## 3062  28    unemployed   single secondary      no      16      no   no
## 3063  47    technician  married secondary      no     826     yes   no
## 3064  27        admin. divorced secondary      no      76     yes   no
## 3065  60     housemaid  married secondary      no       0      no   no
## 3066  58  entrepreneur  married   primary      no    1153     yes  yes
## 3067  39    management  married secondary      no       0      no   no
## 3068  30   blue-collar   single secondary      no      23     yes   no
## 3069  60        admin. divorced secondary      no     162      no   no
## 3070  42    management  married  tertiary      no    3841     yes   no
## 3071  59       retired  married secondary      no    2396      no   no
## 3072  38    management  married  tertiary      no    1617     yes   no
## 3073  30    management  married  tertiary      no     131     yes   no
## 3074  38   blue-collar divorced secondary      no    -138     yes   no
## 3075  52       retired  married secondary      no     414      no   no
## 3076  33    management   single  tertiary      no   12686     yes   no
## 3077  50   blue-collar  married   primary      no    -522     yes   no
## 3078  35     housemaid   single  tertiary      no     608     yes  yes
## 3079  52    unemployed  married secondary      no      -9      no   no
## 3080  41   blue-collar  married secondary      no       0      no   no
## 3081  40    technician divorced  tertiary      no    1871     yes   no
## 3082  34   blue-collar divorced secondary      no       0     yes   no
## 3083  26        admin.  married secondary      no       0      no   no
## 3084  51    technician  married secondary      no     117      no   no
## 3085  52    management divorced secondary      no     944      no  yes
## 3086  37   blue-collar  married secondary      no       7     yes  yes
## 3087  53   blue-collar  married secondary      no      25      no   no
## 3088  28   blue-collar   single secondary      no    1103     yes   no
## 3089  39      services divorced secondary      no    -718     yes   no
## 3090  26 self-employed   single  tertiary      no    1393      no   no
## 3091  47      services  married secondary      no     440     yes   no
## 3092  32  entrepreneur  married secondary      no     -25     yes   no
## 3093  35   blue-collar   single secondary      no     448      no  yes
## 3094  35   blue-collar divorced secondary      no       0      no   no
## 3095  31    management   single secondary      no     783     yes   no
## 3096  54     housemaid  married secondary      no     209     yes  yes
## 3097  49   blue-collar  married secondary      no     188     yes   no
## 3098  54   blue-collar  married   primary      no     489     yes  yes
## 3099  33    management  married  tertiary      no     332     yes  yes
## 3100  38    technician   single secondary      no    1711      no   no
## 3101  34    management   single  tertiary      no    6766      no   no
## 3102  60    technician  married  tertiary      no      91      no   no
## 3103  35    technician  married secondary      no    4508     yes   no
## 3104  28    unemployed   single secondary      no    1055      no   no
## 3105  32   blue-collar divorced   primary      no      88     yes   no
## 3106  48    management divorced  tertiary      no     174      no   no
## 3107  52      services  married  tertiary      no    1135     yes  yes
## 3108  52    management   single  tertiary      no     597      no   no
## 3109  38    management   single  tertiary      no     455     yes   no
## 3110  39    management  married  tertiary      no    1654      no  yes
## 3111  50  entrepreneur  married  tertiary      no    5420     yes   no
## 3112  30    management   single  tertiary      no     424      no   no
## 3113  26  entrepreneur   single  tertiary      no      81      no   no
## 3114  57    management  married   primary      no       0      no   no
## 3115  42    technician  married secondary      no     613     yes   no
## 3116  32    unemployed   single secondary      no     104      no   no
## 3117  56       retired  married   primary      no      63      no   no
## 3118  49    technician  married secondary      no    -142     yes  yes
## 3119  48   blue-collar divorced   primary      no     -18     yes   no
## 3120  35   blue-collar divorced secondary      no       0     yes   no
## 3121  59    management  married  tertiary      no    5397      no   no
## 3122  36    technician   single  tertiary      no      53      no  yes
## 3123  37      services  married secondary      no      50     yes   no
## 3124  31        admin.   single secondary      no     144     yes   no
## 3125  35   blue-collar  married secondary      no    1287     yes   no
## 3126  35    technician  married secondary      no      14     yes   no
## 3127  38    management  married  tertiary      no    -469     yes   no
## 3128  35   blue-collar divorced secondary      no    3102     yes   no
## 3129  32    technician   single  tertiary      no    1849     yes   no
## 3130  57        admin.  married   unknown      no       5      no   no
## 3131  44        admin.  married secondary      no    1206      no   no
## 3132  32 self-employed   single secondary      no     123     yes   no
## 3133  26       student   single   unknown      no     -41     yes   no
## 3134  30      services   single secondary      no    1649     yes   no
## 3135  32   blue-collar  married secondary      no    -428     yes   no
## 3136  59       retired  married   primary      no    -411      no   no
## 3137  70       retired  married   unknown      no     647      no   no
## 3138  30   blue-collar   single   primary      no     334      no   no
## 3139  39  entrepreneur  married secondary      no     580     yes   no
## 3140  27    technician   single secondary      no      41     yes  yes
## 3141  60   blue-collar  married   unknown      no     104     yes   no
## 3142  35 self-employed  married  tertiary      no     980      no   no
## 3143  43    technician divorced secondary      no     -36     yes   no
## 3144  73       retired divorced secondary      no    1092      no   no
## 3145  35    management   single  tertiary      no      71     yes   no
## 3146  41      services  married secondary      no     510     yes   no
## 3147  33    technician  married secondary      no    1072      no  yes
## 3148  34  entrepreneur  married  tertiary      no     121     yes   no
## 3149  30    technician  married   unknown     yes    -315     yes   no
## 3150  34        admin.  married secondary      no     287     yes   no
## 3151  39   blue-collar   single secondary      no     175      no   no
## 3152  44        admin. divorced secondary      no       0      no   no
## 3153  30   blue-collar   single secondary      no     906     yes  yes
## 3154  30    technician  married secondary      no    -280     yes   no
## 3155  44      services  married secondary      no       0     yes  yes
## 3156  49        admin.  married secondary      no    1096     yes   no
## 3157  36    unemployed divorced secondary      no    2178     yes   no
## 3158  31 self-employed  married  tertiary      no       0     yes   no
## 3159  42   blue-collar divorced   primary      no     103     yes   no
## 3160  58       unknown  married   primary      no      15      no   no
## 3161  31        admin.  married secondary      no    1262     yes   no
## 3162  42    unemployed  married secondary      no    1289      no   no
## 3163  25    technician  married  tertiary      no     839     yes   no
## 3164  42    management  married  tertiary      no    1680     yes   no
## 3165  38   blue-collar  married secondary      no    1102     yes   no
## 3166  52    unemployed  married secondary      no    2142      no   no
## 3167  44   blue-collar   single   primary      no    1593     yes   no
## 3168  43    management   single  tertiary      no     359     yes   no
## 3169  36    management  married  tertiary      no    8277     yes   no
## 3170  25   blue-collar   single secondary      no     335     yes   no
## 3171  45   blue-collar  married secondary      no     -96      no   no
## 3172  28   blue-collar  married   primary      no       0     yes  yes
## 3173  45        admin.  married secondary      no     251     yes   no
## 3174  35    management  married  tertiary      no     697      no   no
## 3175  43   blue-collar  married   unknown      no     245     yes  yes
## 3176  50   blue-collar  married   primary      no     180     yes   no
## 3177  36        admin.   single secondary      no     587     yes   no
## 3178  44   blue-collar  married secondary      no      88     yes   no
## 3179  49        admin.   single secondary      no       0      no   no
## 3180  37     housemaid divorced   primary      no       0     yes  yes
## 3181  42   blue-collar  married   primary      no    1556      no  yes
## 3182  29   blue-collar   single secondary      no     348     yes   no
## 3183  32    technician   single  tertiary      no     190     yes  yes
## 3184  26       student   single secondary      no    1209     yes   no
## 3185  50    management   single  tertiary      no    3537      no   no
## 3186  38    management  married  tertiary      no     590      no   no
## 3187  54   blue-collar  married secondary      no    1291     yes   no
## 3188  34    technician   single  tertiary      no     612      no   no
## 3189  41      services   single secondary      no     397     yes   no
## 3190  31        admin.   single secondary      no     507     yes   no
## 3191  42    management  married  tertiary      no     478      no  yes
## 3192  44    management  married  tertiary      no     -61      no   no
## 3193  24      services  married secondary      no     183     yes   no
## 3194  38    management  married  tertiary      no     272     yes   no
## 3195  48    technician  married secondary      no     220      no   no
## 3196  36  entrepreneur divorced secondary      no    2996     yes   no
## 3197  49    management  married  tertiary      no    2005      no   no
## 3198  56     housemaid divorced   primary     yes    1238      no   no
## 3199  71       retired  married  tertiary      no    2651      no   no
## 3200  47        admin.  married secondary      no    1210      no   no
## 3201  52    management  married  tertiary      no     583      no   no
## 3202  37      services  married secondary      no     102     yes   no
## 3203  40    management divorced  tertiary      no     -78     yes   no
## 3204  30      services  married secondary      no    1743     yes   no
## 3205  35    management   single secondary      no       0      no   no
## 3206  38    technician  married secondary      no     508     yes   no
## 3207  52   blue-collar  married   primary      no     779     yes   no
## 3208  49    management  married  tertiary      no    3840     yes   no
## 3209  59    management   single  tertiary      no     911      no  yes
## 3210  47      services divorced   primary      no      91     yes   no
## 3211  43   blue-collar  married   primary      no     632     yes   no
## 3212  25    technician   single secondary      no     102      no  yes
## 3213  26   blue-collar   single   primary      no     619     yes  yes
## 3214  45      services  married secondary      no     507      no  yes
## 3215  26    technician   single  tertiary      no    1216     yes   no
## 3216  67       retired  married   primary      no    4416      no   no
## 3217  32    management  married  tertiary      no    1544     yes   no
## 3218  83     housemaid  married   primary      no    2140      no   no
## 3219  28   blue-collar  married   unknown      no     486     yes   no
## 3220  39   blue-collar  married   primary      no     519     yes  yes
## 3221  41      services  married secondary      no       0     yes  yes
## 3222  47 self-employed  married secondary      no    2830     yes   no
## 3223  49    management divorced  tertiary      no   20727      no   no
## 3224  59   blue-collar  married secondary      no     448      no   no
## 3225  25    management   single  tertiary      no     145      no   no
## 3226  57   blue-collar  married   primary      no     630     yes   no
## 3227  50   blue-collar  married secondary      no     170     yes  yes
## 3228  26   blue-collar   single secondary      no     339     yes   no
## 3229  42    technician   single secondary      no    1882     yes   no
## 3230  33    management   single  tertiary      no     206      no   no
## 3231  29   blue-collar  married   primary      no    1280     yes   no
## 3232  55   blue-collar  married secondary      no       0      no   no
## 3233  26    technician   single secondary      no     342      no   no
## 3234  36    unemployed   single  tertiary      no     577     yes   no
## 3235  31   blue-collar  married secondary      no     457     yes   no
## 3236  38     housemaid divorced secondary      no     216      no   no
## 3237  42    management   single  tertiary      no    1608      no   no
## 3238  29      services   single  tertiary      no    1788      no   no
## 3239  34        admin.  married secondary      no      19     yes  yes
## 3240  25       student   single  tertiary      no      58      no   no
## 3241  27        admin.  married secondary      no    1417     yes   no
## 3242  43 self-employed  married  tertiary      no      64      no   no
## 3243  41    management   single   unknown      no     335      no   no
## 3244  46   blue-collar  married   primary      no    -339     yes  yes
## 3245  38    technician  married secondary      no       0      no   no
## 3246  33      services  married  tertiary      no     546     yes  yes
## 3247  35  entrepreneur  married  tertiary      no    2723     yes  yes
## 3248  46   blue-collar  married secondary      no    2121     yes   no
## 3249  32    management  married  tertiary      no     141      no   no
## 3250  35    technician   single secondary      no     -54     yes   no
## 3251  54 self-employed  married secondary      no     153     yes   no
## 3252  32    technician  married secondary      no       0     yes   no
## 3253  55   blue-collar  married secondary      no    2854     yes   no
## 3254  30        admin.  married secondary      no    1589     yes   no
## 3255  36  entrepreneur  married   primary      no     600      no   no
## 3256  39    unemployed divorced secondary      no     193     yes   no
## 3257  50 self-employed  married  tertiary      no    4012      no   no
## 3258  56        admin. divorced secondary      no    3337     yes   no
## 3259  72       retired  married   primary      no       0      no   no
## 3260  46   blue-collar  married   primary      no     633     yes   no
## 3261  36    technician divorced  tertiary      no     119      no   no
## 3262  38      services  married secondary      no     497     yes  yes
## 3263  51    technician  married  tertiary      no     825      no   no
## 3264  32    management  married  tertiary      no     184     yes   no
## 3265  32   blue-collar  married secondary      no     944      no   no
## 3266  51   blue-collar  married   primary     yes    -283     yes   no
## 3267  31    unemployed   single secondary      no     209     yes   no
## 3268  33    technician divorced secondary      no     751     yes   no
## 3269  38    technician divorced  tertiary      no    1425     yes   no
## 3270  39   blue-collar  married secondary      no    1254     yes   no
## 3271  33   blue-collar  married secondary      no     327     yes   no
## 3272  46    management divorced  tertiary      no       0      no   no
## 3273  45       retired divorced   primary      no     261      no   no
## 3274  59       retired  married   unknown      no    7586      no   no
## 3275  25   blue-collar   single secondary     yes      15     yes   no
## 3276  36   blue-collar   single secondary      no    2390     yes   no
## 3277  33  entrepreneur  married secondary      no     135     yes   no
## 3278  46  entrepreneur  married secondary      no     757      no   no
## 3279  43  entrepreneur  married secondary      no       0     yes   no
## 3280  33      services  married secondary      no     260     yes   no
## 3281  46    management  married  tertiary      no      71     yes   no
## 3282  34    management  married secondary      no      15      no   no
## 3283  44      services   single secondary      no     862     yes   no
## 3284  56      services  married secondary      no     530     yes   no
## 3285  42        admin.  married secondary      no     976     yes   no
## 3286  45    management  married   primary      no    4758     yes   no
## 3287  58        admin.  married   primary      no     879     yes   no
## 3288  30    management  married  tertiary      no       3     yes   no
## 3289  51   blue-collar  married  tertiary      no    7816     yes   no
## 3290  53       retired  married secondary      no    1296     yes   no
## 3291  42    technician  married  tertiary      no     246     yes   no
## 3292  33   blue-collar  married secondary      no     478     yes   no
## 3293  32   blue-collar   single secondary      no    3845     yes   no
## 3294  59   blue-collar divorced secondary      no      61     yes   no
## 3295  58    management divorced   unknown      no    3498      no   no
## 3296  31    unemployed   single   unknown      no     167      no   no
## 3297  69       retired  married   primary      no     324      no   no
## 3298  51   blue-collar   single   primary      no      60      no   no
## 3299  30    technician  married secondary      no     616     yes   no
## 3300  33    unemployed   single  tertiary      no     617      no   no
## 3301  34        admin.   single  tertiary      no      18     yes   no
## 3302  48    technician divorced secondary      no    1290      no   no
## 3303  45     housemaid  married secondary      no     360      no   no
## 3304  36   blue-collar  married   primary      no    8135     yes   no
## 3305  39    technician   single  tertiary      no    1674      no   no
## 3306  58    management  married  tertiary      no    1016      no   no
## 3307  36   blue-collar   single secondary      no    2235     yes   no
## 3308  34      services  married secondary      no    -451     yes  yes
## 3309  36    management   single  tertiary      no     124     yes   no
## 3310  40    management  married secondary      no     752      no  yes
## 3311  33    management   single  tertiary      no     215     yes   no
## 3312  55       retired  married secondary      no    -185      no  yes
## 3313  45 self-employed  married secondary      no    -124      no   no
## 3314  31       student   single secondary      no      93      no   no
## 3315  51      services  married secondary      no     144      no  yes
## 3316  54    technician divorced secondary      no     255     yes   no
## 3317  48       retired  married   primary      no    1591      no   no
## 3318  28        admin. divorced secondary      no     451     yes   no
## 3319  57   blue-collar  married   primary      no     162     yes   no
## 3320  60       retired  married secondary      no     597      no   no
## 3321  51   blue-collar  married   primary      no     230     yes   no
## 3322  47        admin.  married secondary      no      70     yes   no
## 3323  40    management divorced  tertiary      no     490     yes   no
## 3324  43   blue-collar   single   primary      no   13620     yes   no
## 3325  50    unemployed  married secondary      no    5164      no   no
## 3326  41    technician  married secondary      no    -329      no   no
## 3327  30    technician   single  tertiary      no     419     yes  yes
## 3328  45  entrepreneur  married   unknown      no    3133     yes  yes
## 3329  23      services  married secondary      no    2673     yes   no
## 3330  31      services  married secondary      no    1004      no   no
## 3331  25        admin.   single  tertiary      no     760     yes   no
## 3332  34    management  married  tertiary      no       0      no   no
## 3333  55   blue-collar  married   primary      no    3957      no  yes
## 3334  29        admin.   single secondary      no     428     yes  yes
## 3335  58 self-employed  married  tertiary      no     327      no  yes
## 3336  30        admin.  married secondary      no     401      no   no
## 3337  51       unknown  married   unknown      no     167      no   no
## 3338  32    management  married  tertiary      no     258     yes  yes
## 3339  28       student   single secondary      no     970      no   no
## 3340  44    management  married  tertiary      no     839      no   no
## 3341  38     housemaid divorced  tertiary      no    4312      no   no
## 3342  57       retired  married secondary      no    1408      no   no
## 3343  34    management  married  tertiary      no     581     yes   no
## 3344  54   blue-collar divorced secondary      no    1145     yes   no
## 3345  33     housemaid  married  tertiary      no      10     yes   no
## 3346  34    management   single  tertiary      no      84      no   no
## 3347  55    technician  married secondary      no      77     yes   no
## 3348  52      services  married secondary      no      -1      no  yes
## 3349  38    management  married  tertiary      no     389     yes   no
## 3350  55        admin.  married secondary      no     183     yes   no
## 3351  45    technician  married secondary      no    1441     yes   no
## 3352  36   blue-collar  married secondary      no     975     yes   no
## 3353  56      services   single secondary      no     -40     yes   no
## 3354  38        admin.  married secondary      no     545      no   no
## 3355  29    management  married  tertiary      no      55     yes   no
## 3356  30   blue-collar  married   primary      no    5956     yes  yes
## 3357  28      services  married secondary      no    1214      no   no
## 3358  56    management  married   primary      no    7747      no   no
## 3359  49   blue-collar  married   primary      no    3028     yes   no
## 3360  58       retired divorced  tertiary      no    5253      no   no
## 3361  59       retired  married secondary      no    3382     yes   no
## 3362  36    management   single  tertiary      no     442     yes  yes
## 3363  53    management  married  tertiary      no    7067      no   no
## 3364  55   blue-collar  married   primary      no     135     yes   no
## 3365  33   blue-collar divorced secondary      no    -131     yes   no
## 3366  48   blue-collar  married secondary      no     893      no   no
## 3367  32   blue-collar  married secondary      no       0     yes  yes
## 3368  26    management   single  tertiary      no    1438      no   no
## 3369  56    unemployed divorced   primary      no     282      no   no
## 3370  32   blue-collar   single secondary      no      53     yes   no
## 3371  50      services   single secondary      no     321      no   no
## 3372  40  entrepreneur  married  tertiary      no    1089     yes  yes
## 3373  46      services  married secondary      no     244      no   no
## 3374  36  entrepreneur  married secondary      no     546      no   no
## 3375  48    management  married  tertiary      no    4006      no   no
## 3376  54     housemaid divorced  tertiary      no    1241      no   no
## 3377  52    management  married   primary      no     324      no   no
## 3378  38   blue-collar  married   primary      no     190     yes   no
## 3379  41   blue-collar  married secondary      no    1885     yes   no
## 3380  37    management  married  tertiary      no     142      no   no
## 3381  33      services  married secondary      no      39     yes   no
## 3382  54    technician divorced secondary      no    2156     yes   no
## 3383  30    technician  married secondary      no    -287     yes   no
## 3384  45    technician  married  tertiary      no    2359      no   no
## 3385  68       retired  married secondary      no    1316      no   no
## 3386  25      services   single secondary      no    -439     yes   no
## 3387  27   blue-collar  married   primary      no       0      no   no
## 3388  44   blue-collar  married secondary      no    1071     yes   no
## 3389  27    management   single  tertiary      no     831     yes   no
## 3390  29   blue-collar   single secondary      no     445     yes   no
## 3391  37      services   single secondary      no     253     yes  yes
## 3392  52        admin.  married secondary      no    -462     yes   no
## 3393  58       retired  married   primary      no    1241      no   no
## 3394  58    management divorced   unknown      no    2986      no   no
## 3395  37   blue-collar  married secondary      no     131     yes   no
## 3396  37   blue-collar  married   primary      no     -29     yes  yes
## 3397  30        admin.   single secondary      no    1223     yes   no
## 3398  34     housemaid   single secondary      no    1408     yes   no
## 3399  26    technician   single secondary      no       7     yes   no
## 3400  55    management   single   unknown      no     111      no   no
## 3401  58       retired  married secondary      no     630      no   no
## 3402  40    management divorced  tertiary      no     823      no   no
## 3403  32    management   single  tertiary      no    1131     yes   no
## 3404  51        admin.   single secondary      no     895      no   no
## 3405  45  entrepreneur  married secondary      no    4688      no   no
## 3406  57       retired divorced   primary      no     720      no   no
## 3407  57       retired  married  tertiary      no     478      no   no
## 3408  54   blue-collar divorced   primary      no     190     yes   no
## 3409  30    technician  married secondary      no       0     yes   no
## 3410  40      services  married secondary      no    1358      no   no
## 3411  53    management   single  tertiary      no       0      no   no
## 3412  33    technician  married secondary     yes      72     yes   no
## 3413  40    technician   single secondary      no      34      no   no
## 3414  41    management   single  tertiary      no    1253      no   no
## 3415  50    management  married  tertiary      no    2488     yes   no
## 3416  31        admin.   single  tertiary      no     253     yes   no
## 3417  49        admin.  married   unknown      no    1101      no   no
## 3418  41    technician  married secondary      no     634      no   no
## 3419  60    technician  married   primary      no    4243     yes   no
## 3420  34    technician  married  tertiary      no    2069      no   no
## 3421  32    technician  married   unknown      no    1879      no   no
## 3422  53       retired  married secondary      no     357      no   no
## 3423  34   blue-collar  married secondary      no     277      no  yes
## 3424  29        admin.   single secondary      no     171     yes   no
## 3425  38   blue-collar  married secondary      no      35     yes   no
## 3426  31    technician   single  tertiary      no     127     yes   no
## 3427  37   blue-collar  married   primary      no    5643     yes   no
## 3428  30      services   single secondary      no     148      no  yes
## 3429  32   blue-collar   single   primary      no      18     yes  yes
## 3430  30 self-employed   single secondary      no     280      no   no
## 3431  41    technician  married  tertiary      no     354      no   no
## 3432  47    management  married  tertiary      no    1493      no   no
## 3433  34    technician   single secondary      no    1866      no   no
## 3434  38   blue-collar  married secondary      no    1165     yes   no
## 3435  41    technician divorced secondary      no    1545      no  yes
## 3436  27    technician   single  tertiary      no     434     yes   no
## 3437  33       student  married  tertiary      no     476     yes   no
## 3438  38      services   single secondary      no     322     yes   no
## 3439  41    management  married  tertiary      no    2031     yes   no
## 3440  37    unemployed divorced secondary      no      74     yes   no
## 3441  26    management   single  tertiary      no    1720      no   no
## 3442  36      services  married secondary      no       0     yes   no
## 3443  28       student  married  tertiary      no     327     yes   no
## 3444  59    management  married  tertiary      no     101      no  yes
## 3445  35    management   single  tertiary      no    4788     yes   no
## 3446  43       unknown   single   unknown      no     181      no   no
## 3447  50   blue-collar divorced   primary      no    -333      no  yes
## 3448  24      services   single secondary      no       0      no   no
## 3449  32    technician  married  tertiary      no     500      no   no
## 3450  41    technician  married secondary      no    1043     yes  yes
## 3451  39    management  married  tertiary      no     399      no   no
## 3452  50       retired   single   primary      no     208      no   no
## 3453  40    management  married secondary      no    1576     yes  yes
## 3454  50    management  married  tertiary      no     346      no   no
## 3455  63   blue-collar  married secondary      no     641      no   no
## 3456  31    technician divorced secondary      no     105     yes   no
## 3457  34      services  married secondary      no    1337      no   no
## 3458  28   blue-collar   single secondary      no     121      no   no
## 3459  32    technician  married secondary      no    -410     yes  yes
## 3460  32   blue-collar  married secondary     yes      -1     yes   no
## 3461  52      services  married   primary      no    -585     yes  yes
## 3462  43       unknown  married   primary      no    2113      no   no
## 3463  43    unemployed  married  tertiary      no      58     yes   no
## 3464  23    management   single secondary      no      85     yes   no
## 3465  47    technician  married  tertiary      no    1115     yes   no
## 3466  52    management  married  tertiary      no    4173      no  yes
## 3467  37 self-employed  married secondary      no    2203      no  yes
## 3468  31    management   single  tertiary      no      15      no   no
## 3469  40     housemaid  married secondary      no    4136     yes   no
## 3470  42    management  married  tertiary      no     261      no   no
## 3471  33   blue-collar  married   primary      no     392     yes   no
## 3472  40       retired   single secondary      no    1400      no   no
## 3473  51    management  married  tertiary      no     615     yes   no
## 3474  53    unemployed   single secondary      no       4      no   no
## 3475  36    management   single  tertiary      no     339      no   no
## 3476  34    technician  married secondary      no    1553      no   no
## 3477  30    management  married  tertiary      no      14      no   no
## 3478  29   blue-collar  married   primary      no     258     yes   no
## 3479  38        admin.  married   primary      no       3     yes  yes
## 3480  41   blue-collar  married   primary      no     620      no   no
## 3481  33    management   single  tertiary      no     -67     yes   no
## 3482  28      services   single secondary      no     430     yes   no
## 3483  47       unknown  married   unknown      no     270      no   no
## 3484  36        admin.   single secondary      no    1328      no   no
## 3485  57   blue-collar  married   primary      no      93     yes   no
## 3486  36    management  married secondary      no    1825     yes   no
## 3487  51    technician  married   unknown      no     573     yes  yes
## 3488  51   blue-collar  married   primary      no     541      no   no
## 3489  40   blue-collar  married   primary      no    2133     yes  yes
## 3490  45    technician   single secondary      no     410     yes   no
## 3491  52        admin.  married secondary      no    2347      no  yes
## 3492  35  entrepreneur   single  tertiary      no     145     yes   no
## 3493  33    unemployed  married secondary     yes    -108     yes  yes
## 3494  38        admin. divorced secondary      no     382     yes   no
## 3495  36   blue-collar  married secondary      no      13      no   no
## 3496  75       retired  married   primary      no    3504      no   no
## 3497  31        admin.   single secondary      no    1801     yes   no
## 3498  33    management   single  tertiary      no    1308      no   no
## 3499  31   blue-collar  married secondary      no     136      no   no
## 3500  56    unemployed  married secondary      no      12      no   no
## 3501  37    technician  married secondary      no    -421     yes   no
## 3502  33    management   single  tertiary      no    1271     yes   no
## 3503  30    technician  married secondary      no    -910     yes   no
## 3504  56      services  married secondary      no    1150      no  yes
## 3505  35   blue-collar  married secondary      no    -102     yes   no
## 3506  56       unknown  married   unknown      no     778      no   no
## 3507  58      services  married secondary      no      74      no   no
## 3508  67 self-employed  married  tertiary      no    1979      no   no
## 3509  38    management  married  tertiary      no       0     yes   no
## 3510  37    management divorced  tertiary     yes      -1     yes  yes
## 3511  57   blue-collar  married secondary      no    8195     yes   no
## 3512  35  entrepreneur  married secondary      no      24     yes   no
## 3513  27   blue-collar   single secondary      no       1     yes   no
## 3514  33    management  married  tertiary      no     801      no   no
## 3515  37   blue-collar  married   primary      no    3517     yes   no
## 3516  37    management  married secondary      no     222     yes   no
## 3517  56       retired  married   primary      no    1906      no  yes
## 3518  55        admin.  married secondary      no     128      no   no
## 3519  40   blue-collar  married   primary      no       0     yes   no
## 3520  41   blue-collar  married   primary      no    5560     yes   no
## 3521  27   blue-collar  married secondary      no     613     yes   no
## 3522  49    management  married  tertiary      no   17432      no   no
## 3523  54    management divorced  tertiary      no    1692     yes   no
## 3524  42 self-employed  married  tertiary      no    1385      no   no
## 3525  34    technician   single secondary      no       0      no   no
## 3526  34    technician  married  tertiary      no     932     yes   no
## 3527  38        admin.  married secondary      no     257     yes   no
## 3528  33  entrepreneur  married secondary     yes     -54      no  yes
## 3529  26   blue-collar  married secondary      no     818      no   no
## 3530  35   blue-collar  married secondary      no    1257     yes   no
## 3531  48    management   single secondary      no      61     yes   no
## 3532  64       retired  married  tertiary      no     380      no   no
## 3533  31        admin.  married secondary      no    1229      no   no
## 3534  39      services  married secondary      no    1970     yes   no
## 3535  38    management  married  tertiary      no       0     yes   no
## 3536  40   blue-collar  married   primary      no    2562     yes   no
## 3537  49   blue-collar  married   primary     yes     -98     yes   no
## 3538  36    management  married  tertiary      no    1604     yes   no
## 3539  51       unknown  married   unknown      no    1585      no   no
## 3540  58    technician   single secondary      no     409      no  yes
## 3541  33    technician   single secondary      no    2481      no   no
## 3542  28   blue-collar   single secondary      no    2845     yes   no
## 3543  42   blue-collar  married   primary      no    1320      no   no
## 3544  52 self-employed  married secondary      no       9      no  yes
## 3545  54    management divorced  tertiary      no     496      no   no
## 3546  60       retired divorced secondary      no     514      no   no
## 3547  31        admin.   single secondary      no      40      no   no
## 3548  32   blue-collar   single secondary      no     760     yes   no
## 3549  53        admin.  married secondary      no    1796      no   no
## 3550  28 self-employed   single  tertiary      no       0     yes   no
## 3551  47    technician  married secondary      no     834      no  yes
## 3552  29   blue-collar   single secondary      no    -138     yes  yes
## 3553  78       retired  married   unknown      no    3208      no   no
## 3554  43  entrepreneur  married secondary      no      59      no   no
## 3555  27        admin.  married  tertiary      no      73      no   no
## 3556  51   blue-collar  married   primary      no       0     yes   no
## 3557  52   blue-collar  married   primary      no     -27      no   no
## 3558  49 self-employed  married secondary      no     358     yes  yes
## 3559  35      services  married secondary      no    1659     yes   no
## 3560  58      services  married secondary      no    1667     yes  yes
## 3561  36    management  married  tertiary      no     255      no   no
## 3562  58   blue-collar  married secondary      no    2592     yes   no
## 3563  51     housemaid  married   primary      no    1275      no   no
## 3564  42    technician  married secondary      no    3228      no   no
## 3565  37    management  married  tertiary      no    2401      no   no
## 3566  44   blue-collar  married secondary      no    3610     yes   no
## 3567  38   blue-collar divorced secondary      no     727     yes   no
## 3568  34   blue-collar  married secondary      no     452     yes   no
## 3569  31    unemployed   single  tertiary      no    1489     yes   no
## 3570  32      services   single secondary      no      81     yes   no
## 3571  54    management divorced  tertiary      no    -125      no  yes
## 3572  38   blue-collar   single   primary      no     162     yes   no
## 3573  40     housemaid  married secondary      no     864      no   no
## 3574  30      services   single secondary      no     187     yes   no
## 3575  43  entrepreneur  married secondary      no       0      no   no
## 3576  39    management  married  tertiary      no   21111     yes   no
## 3577  29    management   single  tertiary      no      21     yes   no
## 3578  46   blue-collar   single secondary      no      76     yes   no
## 3579  28    technician   single secondary      no     154     yes   no
## 3580  50    management  married  tertiary      no    4654      no   no
## 3581  29    technician   single secondary      no     359     yes   no
## 3582  39   blue-collar  married secondary      no     648     yes   no
## 3583  38    technician  married secondary      no       0     yes   no
## 3584  57    unemployed  married   primary      no    5126     yes   no
## 3585  54 self-employed divorced   primary      no     351     yes   no
## 3586  52      services  married secondary      no     540     yes   no
## 3587  50 self-employed  married secondary      no       0     yes   no
## 3588  30    technician   single secondary      no      18      no   no
## 3589  49    management  married  tertiary      no     350      no   no
## 3590  40        admin.   single secondary      no     419      no  yes
## 3591  42   blue-collar   single secondary      no     419      no   no
## 3592  52    management  married  tertiary      no    4675      no   no
## 3593  31    technician  married  tertiary      no    3192     yes   no
## 3594  33 self-employed   single  tertiary      no    4996      no   no
## 3595  26    technician   single secondary      no     174     yes   no
## 3596  36   blue-collar   single secondary      no     507     yes   no
## 3597  29    management   single secondary      no       0     yes   no
## 3598  42   blue-collar  married secondary      no    1657     yes  yes
## 3599  47    technician  married secondary      no    2394      no  yes
## 3600  33    management   single secondary      no    -298      no   no
## 3601  34        admin.  married secondary      no     -44     yes  yes
## 3602  57    technician  married secondary      no    1070      no   no
## 3603  36   blue-collar  married secondary      no     274     yes   no
## 3604  57        admin.  married secondary      no   16873      no   no
## 3605  36        admin.  married secondary      no     786     yes  yes
## 3606  29    technician   single secondary      no     525     yes   no
## 3607  32    technician   single secondary      no      35      no   no
## 3608  30        admin.   single secondary      no     223     yes   no
## 3609  41        admin.  married   primary      no    -306     yes   no
## 3610  50    management  married  tertiary      no     463      no  yes
## 3611  50    technician divorced secondary      no     636     yes   no
## 3612  41    unemployed divorced   primary      no     487      no   no
## 3613  36    management  married secondary      no     873     yes   no
## 3614  35    management  married  tertiary      no     267     yes   no
## 3615  63   blue-collar  married   primary      no     115      no   no
## 3616  25    technician   single secondary      no     -55     yes  yes
## 3617  33   blue-collar  married secondary      no       0     yes  yes
## 3618  37      services  married secondary      no    4760     yes   no
## 3619  28  entrepreneur   single  tertiary      no     219     yes   no
## 3620  43   blue-collar  married secondary      no     232     yes   no
## 3621  34   blue-collar  married secondary      no       0     yes   no
## 3622  26    technician   single secondary      no    -525     yes  yes
## 3623  57    technician  married  tertiary      no      -1      no   no
## 3624  20       student   single secondary      no    1191      no   no
## 3625  52    management  married  tertiary      no    7192      no   no
## 3626  39      services   single  tertiary      no     410      no   no
## 3627  32      services  married secondary      no       0     yes   no
## 3628  54        admin.   single secondary      no      15     yes   no
## 3629  39      services  married secondary      no      18     yes  yes
## 3630  31   blue-collar   single secondary      no     530      no  yes
## 3631  25       student   single secondary      no     715      no   no
## 3632  59    technician  married secondary      no     478      no   no
## 3633  39        admin.   single secondary      no     470     yes   no
## 3634  47    technician  married secondary      no      11      no   no
## 3635  22      services   single   primary      no      35     yes   no
## 3636  26    unemployed   single  tertiary      no    3511      no   no
## 3637  37      services  married secondary      no     655      no   no
## 3638  52      services divorced secondary      no      43     yes  yes
## 3639  28        admin.   single secondary      no     392     yes  yes
## 3640  46      services  married secondary      no       0     yes   no
## 3641  30        admin.   single secondary      no     523      no  yes
## 3642  30    technician  married  tertiary      no    1338     yes  yes
## 3643  34        admin.   single secondary      no     239      no   no
## 3644  51     housemaid  married   primary      no    1521      no   no
## 3645  46  entrepreneur  married  tertiary      no       0     yes  yes
## 3646  70       retired  married secondary      no    2815      no   no
## 3647  41    technician  married  tertiary      no       0      no   no
## 3648  32    technician   single  tertiary      no       0     yes   no
## 3649  32   blue-collar   single   primary      no      60     yes   no
## 3650  50    management  married secondary      no       0     yes   no
## 3651  38        admin.  married secondary      no     505     yes  yes
## 3652  32        admin.   single  tertiary      no    8866      no   no
## 3653  30   blue-collar   single secondary      no    1472     yes   no
## 3654  39   blue-collar  married secondary      no     -99      no   no
## 3655  30    technician   single   primary      no    2731     yes   no
## 3656  44  entrepreneur  married secondary      no    -165     yes  yes
## 3657  45   blue-collar  married   primary      no    2128     yes   no
## 3658  56 self-employed  married secondary      no     800      no  yes
## 3659  37    management  married  tertiary      no    1330     yes   no
## 3660  30   blue-collar  married   primary      no     837     yes   no
## 3661  54      services  married   primary      no       8     yes   no
## 3662  53        admin.  married secondary      no    -375     yes   no
## 3663  27       student   single  tertiary      no    5169     yes   no
## 3664  36    management  married  tertiary      no     162     yes   no
## 3665  43  entrepreneur   single  tertiary      no      42      no   no
## 3666  52     housemaid  married   primary      no     335      no   no
## 3667  48   blue-collar  married secondary      no   10724      no   no
## 3668  39    management   single  tertiary      no     416      no   no
## 3669  35   blue-collar  married   unknown      no    4822     yes   no
## 3670  76       retired divorced   primary      no    3049      no   no
## 3671  40      services  married secondary      no     191     yes   no
## 3672  57       retired  married   primary      no    4908      no   no
## 3673  59   blue-collar  married   primary      no    -546      no   no
## 3674  45     housemaid  married secondary      no     698     yes   no
## 3675  37    technician  married  tertiary      no     143      no   no
## 3676  28    technician   single  tertiary      no    -481     yes  yes
## 3677  57    unemployed  married secondary      no    3867     yes   no
## 3678  45   blue-collar  married   primary      no     292     yes   no
## 3679  58     housemaid  married   primary      no    4605      no   no
## 3680  30   blue-collar  married secondary      no    -529     yes   no
## 3681  48   blue-collar  married secondary      no    1738     yes   no
## 3682  61 self-employed  married  tertiary      no    4162      no   no
## 3683  34    management   single secondary      no     524      no   no
## 3684  43    technician divorced  tertiary      no     101      no   no
## 3685  44    technician   single secondary      no    2403     yes   no
## 3686  29   blue-collar  married   primary      no      50      no   no
## 3687  37   blue-collar  married   primary      no     357     yes   no
## 3688  41    unemployed divorced secondary      no    1281      no   no
## 3689  34    technician  married secondary      no    1795     yes   no
## 3690  40   blue-collar  married   primary      no      98     yes   no
## 3691  59 self-employed  married  tertiary      no    2013      no   no
## 3692  35 self-employed  married  tertiary      no     506      no   no
## 3693  58    management divorced  tertiary      no    1573     yes  yes
## 3694  20      services   single secondary      no    -103     yes   no
## 3695  55    technician divorced secondary      no     184      no   no
## 3696  51   blue-collar  married secondary      no     955      no  yes
## 3697  31 self-employed   single  tertiary      no    1788      no   no
## 3698  52    management  married  tertiary      no     547      no   no
## 3699  31    management   single  tertiary      no      62     yes   no
## 3700  34   blue-collar  married secondary      no    1575     yes   no
## 3701  32    management   single  tertiary      no     623      no   no
## 3702  36        admin.   single secondary      no      47      no  yes
## 3703  41   blue-collar  married secondary      no    1293      no   no
##        contact day month duration campaign pdays previous poutcome y age_&amp;lt;_29
## 1     cellular  29   jan      375        2    -1        0  unknown 0        0
## 2      unknown   2   jun      392        3    -1        0  unknown 0        0
## 3     cellular   3   feb      315        2   180        6  failure 1        0
## 4     cellular  12   may      309        1   306        4  success 1        0
## 5      unknown  15   may       67        4    -1        0  unknown 0        0
## 6      unknown  14   may      125        1    -1        0  unknown 0        0
## 7     cellular  14   aug      182        2    37        2  failure 0        0
## 8    telephone  13   may      185        1   370        3  failure 0        0
## 9    telephone  18   nov      296        2    -1        0  unknown 0        0
## 10    cellular  21   nov       80        1    -1        0  unknown 0        0
## 11    cellular   3   feb      236        2   272        1  failure 0        0
## 12     unknown   9   jun      199        4    -1        0  unknown 0        0
## 13    cellular   7   aug      182        2    99        1  failure 1        0
## 14    cellular  20   nov      250        1   155        2  failure 0        0
## 15    cellular  11   may       12        5    -1        0  unknown 0        0
## 16     unknown  19   jun      446        1    -1        0  unknown 0        0
## 17    cellular  27   aug       89       23    -1        0  unknown 0        0
## 18     unknown  20   jun        7        3    -1        0  unknown 0        0
## 19   telephone  31   jul      130        8    -1        0  unknown 0        0
## 20    cellular  13   aug      110        4    -1        0  unknown 0        0
## 21   telephone  28   aug       51        3    -1        0  unknown 0        0
## 22   telephone   9   jul       42        1    -1        0  unknown 0        0
## 23     unknown  28   may       33        2    -1        0  unknown 0        0
## 24    cellular  20   nov      112        1    -1        0  unknown 0        0
## 25     unknown  30   may      352        3    -1        0  unknown 0        0
## 26    cellular  20   nov      167        1    -1        0  unknown 0        0
## 27    cellular  25   aug       97        4    -1        0  unknown 0        0
## 28    cellular   9   jul      148        2    -1        0  unknown 0        0
## 29    cellular  19   nov      312        3    -1        0  unknown 0        0
## 30     unknown  21   may       73        1    -1        0  unknown 0        0
## 31    cellular   3   jun      244        2    -1        0  unknown 1        0
## 32    cellular   9   jun      835        2    -1        0  unknown 0        0
## 33    cellular   3   feb       22        6   196        6  failure 0        0
## 34     unknown   5   jun      135        2    -1        0  unknown 0        0
## 35    cellular  13   may      168        2    -1        0  unknown 0        0
## 36    cellular   4   feb      765        2    -1        0  unknown 0        0
## 37    cellular   9   apr       96        4   314        8    other 0        0
## 38    cellular  16   apr      334        2    -1        0  unknown 1        0
## 39   telephone  31   jul       46       21    -1        0  unknown 0        0
## 40    cellular   6   may       95        1    -1        0  unknown 0        0
## 41    cellular   5   may      305        5   349        7    other 0        0
## 42    cellular   8   may      206        1    -1        0  unknown 0        0
## 43    cellular  29   aug      106        2    -1        0  unknown 0        0
## 44    cellular  18   may      248        1    -1        0  unknown 0        1
## 45    cellular  20   apr       53        1   346        1  failure 0        0
## 46    cellular  14   aug      189        4    -1        0  unknown 0        0
## 47    cellular  21   nov       44        1    -1        0  unknown 0        0
## 48    cellular  20   apr      149        2    -1        0  unknown 0        1
## 49    cellular   1   sep      368        1    -1        0  unknown 0        0
## 50     unknown  13   may      139        4    -1        0  unknown 0        0
## 51     unknown   6   may     1623        1    -1        0  unknown 1        0
## 52    cellular  25   aug      342        5    -1        0  unknown 0        0
## 53    cellular  14   aug      106        2    -1        0  unknown 0        0
## 54    cellular   7   may      113        2    -1        0  unknown 0        0
## 55     unknown  28   may      181        1    -1        0  unknown 0        1
## 56    cellular  25   aug      265        4    -1        0  unknown 0        0
## 57    cellular  22   apr      400        1    -1        0  unknown 1        0
## 58    cellular  26   aug      158        9    -1        0  unknown 0        0
## 59    cellular  29   jan      100        1   170        4  failure 0        0
## 60     unknown   5   jun      517        3    -1        0  unknown 0        0
## 61    cellular   5   may       49        2    -1        0  unknown 0        1
## 62    cellular  10   jul      428        1    -1        0  unknown 0        0
## 63    cellular   5   may      381        1   342        7  failure 0        0
## 64     unknown   4   jun      179        1    -1        0  unknown 0        0
## 65     unknown  14   may       44        1    -1        0  unknown 0        0
## 66    cellular  15   may      578        1   364        1    other 0        1
## 67     unknown   9   jun      139        2    -1        0  unknown 0        0
## 68     unknown   9   may      211        2    -1        0  unknown 0        0
## 69    cellular  18   may      290        2   370        1  failure 0        0
## 70    cellular  18   nov      618        2    -1        0  unknown 0        0
## 71    cellular   7   apr      424        1   138        1  failure 0        0
## 72    cellular  19   nov      209        2   180        1    other 0        0
## 73    cellular   2   feb      164        2   262        2  failure 0        0
## 74   telephone  15   jan      814        1    -1        0  unknown 0        0
## 75    cellular   9   jul       92        1    -1        0  unknown 0        0
## 76     unknown  15   may      231        1    -1        0  unknown 0        0
## 77    cellular  29   jan      309        1   197       13    other 0        0
## 78    cellular  21   nov      319        3    -1        0  unknown 0        0
## 79    cellular  19   nov      189        1    -1        0  unknown 0        0
## 80    cellular  21   aug       54        5    86        3  failure 0        0
## 81    cellular   2   jun      149        1    -1        0  unknown 0        0
## 82    cellular  27   jan      143        1    -1        0  unknown 1        0
## 83    cellular  22   jul      134        1    -1        0  unknown 0        0
## 84    cellular  19   oct       54        1    -1        0  unknown 0        0
## 85    cellular  24   jul      901        2    -1        0  unknown 1        0
## 86    cellular  21   aug      140        2    -1        0  unknown 0        0
## 87   telephone  13   may      155        6    -1        0  unknown 0        0
## 88    cellular  13   may      204        3    -1        0  unknown 0        1
## 89    cellular   7   jul      625        1    -1        0  unknown 1        0
## 90     unknown  28   may      860        2    -1        0  unknown 0        0
## 91    cellular  18   may       16        4   273        7    other 0        0
## 92     unknown   4   jun      169        2    -1        0  unknown 0        0
## 93    cellular  20   apr      239        1   276        6  failure 0        0
## 94    cellular  16   sep      228        1   185        1  failure 0        0
## 95   telephone  20   oct      513        1    -1        0  unknown 1        0
## 96     unknown   7   may      152        3    -1        0  unknown 0        0
## 97    cellular  20   nov      352        3    -1        0  unknown 0        0
## 98    cellular  21   nov      203        2    -1        0  unknown 0        0
## 99    cellular  18   nov       34        1   124        6  failure 0        0
## 100    unknown  21   may      190        5    -1        0  unknown 0        0
## 101   cellular  25   may      324        1    -1        0  unknown 0        1
## 102   cellular  16   jul      231        2    -1        0  unknown 0        1
## 103    unknown   4   jul      203        1    -1        0  unknown 0        0
## 104   cellular   7   apr      411        1    -1        0  unknown 0        0
## 105    unknown   7   may      113        1    -1        0  unknown 0        0
## 106    unknown  20   jun       89        3    -1        0  unknown 0        0
## 107    unknown  16   may      379        1    -1        0  unknown 0        0
## 108    unknown   2   jun      174        1    -1        0  unknown 0        0
## 109   cellular   5   may      674        2   250        4  failure 0        0
## 110    unknown   5   may      313        3    -1        0  unknown 0        0
## 111  telephone  18   may       51        1    -1        0  unknown 0        1
## 112    unknown  28   may      200        4    -1        0  unknown 0        1
## 113   cellular   7   aug      714        1    -1        0  unknown 1        0
## 114    unknown  16   may      193        8    -1        0  unknown 0        0
## 115   cellular   6   may      827        1   329        9  failure 0        0
## 116  telephone  16   jul      126        4    -1        0  unknown 0        0
## 117  telephone  12   aug      127        1    -1        0  unknown 0        1
## 118   cellular  27   apr       98        1    -1        0  unknown 0        0
## 119   cellular  21   nov       41        2   123        3  failure 0        0
## 120    unknown  14   may       71        1    -1        0  unknown 0        0
## 121   cellular  24   jul      254        2    -1        0  unknown 0        1
## 122   cellular   8   apr      201        2    -1        0  unknown 0        0
## 123   cellular  19   aug      205        5    -1        0  unknown 0        0
## 124   cellular  29   aug       98       19    -1        0  unknown 0        0
## 125   cellular  20   apr      111        1    -1        0  unknown 0        0
## 126    unknown  21   may       97        1    -1        0  unknown 0        0
## 127   cellular  29   aug      185        2    -1        0  unknown 0        0
## 128  telephone  17   apr      100        2    -1        0  unknown 0        0
## 129    unknown  15   may       99        2    -1        0  unknown 0        0
## 130    unknown  19   may      360        2    -1        0  unknown 0        1
## 131   cellular  13   may       23        1   359        3  failure 0        0
## 132   cellular  17   nov      108        1    -1        0  unknown 0        0
## 133   cellular   5   may      184        1   167        6  failure 0        0
## 134    unknown  16   jun      757        2    -1        0  unknown 0        0
## 135   cellular   3   jun      240        1   307       10    other 0        0
## 136    unknown   7   may      322        2    -1        0  unknown 0        0
## 137   cellular  12   may      168        4    -1        0  unknown 0        0
## 138   cellular   6   may      192        1    -1        0  unknown 0        0
## 139   cellular  18   nov       92        1   188        1  failure 0        0
## 140   cellular  18   may       43        1   367        2  success 0        0
## 141    unknown  16   jun       66        5    -1        0  unknown 0        0
## 142   cellular   2   feb      344        2    -1        0  unknown 0        1
## 143   cellular   5   may      163        1    -1        0  unknown 0        0
## 144   cellular  15   may      183        1   361        1  failure 0        0
## 145   cellular  18   may       11        8    -1        0  unknown 0        0
## 146   cellular   6   aug     1471        7    -1        0  unknown 1        0
## 147   cellular  28   aug       70        8    -1        0  unknown 0        0
## 148    unknown  15   may       88        3    -1        0  unknown 0        0
## 149   cellular  18   aug      781        2    -1        0  unknown 0        0
## 150    unknown   8   may       58        2    -1        0  unknown 0        0
## 151   cellular  21   nov       55        2    -1        0  unknown 0        0
## 152   cellular   7   may      181        2   255        5  failure 0        0
## 153   cellular  28   jan      119        2    -1        0  unknown 0        0
## 154   cellular  30   jul      163        1    -1        0  unknown 0        0
## 155    unknown  19   may      140        2    -1        0  unknown 0        0
## 156   cellular  22   jul      151        2    -1        0  unknown 0        0
## 157   cellular  21   nov      752        3    -1        0  unknown 0        0
## 158    unknown   9   may      167        4    -1        0  unknown 0        0
## 159  telephone  12   feb       89        1    -1        0  unknown 0        0
## 160    unknown   7   may      275        4    -1        0  unknown 0        0
## 161   cellular   9   nov      347        4   189        2  success 1        0
## 162   cellular  28   jan      461        2   204        2  failure 0        0
## 163   cellular   4   feb       74        1    -1        0  unknown 0        0
## 164    unknown  30   may       86        1    -1        0  unknown 0        0
## 165   cellular   2   mar      116        1    -1        0  unknown 1        0
## 166   cellular  10   aug      507        1   181        2  success 1        0
## 167   cellular   9   feb      835        3    -1        0  unknown 1        0
## 168   cellular  26   oct      355        1   180        5  failure 1        0
## 169   cellular   3   nov      322        1    -1        0  unknown 1        0
## 170   cellular  11   jul      348        2    -1        0  unknown 0        0
## 171    unknown  27   may      336       10    -1        0  unknown 0        0
## 172   cellular  13   may      275        1   370        2  failure 0        0
## 173  telephone  29   jul      863       10    -1        0  unknown 0        0
## 174    unknown  14   may      180        1    -1        0  unknown 0        0
## 175   cellular  28   dec     1141        1   209        1    other 1        1
## 176    unknown  13   may      805        2    -1        0  unknown 0        1
## 177  telephone  21   jul     1877        1    -1        0  unknown 1        0
## 178   cellular  22   aug      121        1    -1        0  unknown 0        0
## 179    unknown   5   jun      174        1    -1        0  unknown 0        0
## 180   cellular  19   nov      130        3   188        2    other 0        0
## 181   cellular  31   jul      119        1    -1        0  unknown 0        0
## 182  telephone  23   sep      217        2   188        3    other 0        0
## 183   cellular  11   aug       96        2    -1        0  unknown 0        0
## 184   cellular   8   aug       81        2    -1        0  unknown 0        0
## 185   cellular   6   feb      150        3   270        2  failure 0        0
## 186    unknown   9   jul      399        8    -1        0  unknown 0        0
## 187   cellular  17   nov       66        1    -1        0  unknown 0        0
## 188   cellular  27   may      100        1    -1        0  unknown 0        1
## 189   cellular  11   jul      196        2    -1        0  unknown 0        0
## 190    unknown  30   may      121        1    -1        0  unknown 0        0
## 191   cellular  20   apr      138        2   263        7  failure 0        0
## 192   cellular  11   jul      123        2    -1        0  unknown 0        0
## 193  telephone  31   jul       92        2    -1        0  unknown 0        0
## 194   cellular   9   feb       89        2    -1        0  unknown 0        0
## 195   cellular   6   aug      304        3    -1        0  unknown 1        0
## 196   cellular  29   jan      533        1    92        1  success 1        0
## 197   cellular  23   mar      233        1    -1        0  unknown 0        0
## 198   cellular  22   jul      117        1    -1        0  unknown 0        0
## 199    unknown   9   may      244        4    -1        0  unknown 0        0
## 200   cellular  29   jan       90        1    -1        0  unknown 0        0
## 201    unknown  23   may      250        1    -1        0  unknown 0        1
## 202   cellular  20   jul      355        2    -1        0  unknown 1        0
## 203   cellular  18   may      336        1    89        5  failure 1        0
## 204   cellular  12   feb      118        4   210        3  failure 1        0
## 205   cellular  29   jan      253        1    -1        0  unknown 0        0
## 206   cellular  20   aug       75        1    -1        0  unknown 0        0
## 207  telephone   8   may      139        1    -1        0  unknown 0        0
## 208   cellular  20   aug       43        2    -1        0  unknown 0        0
## 209    unknown  18   jun       53        2    -1        0  unknown 0        0
## 210   cellular  25   jul      270        1    -1        0  unknown 0        0
## 211   cellular  17   nov       65        1   131        1  failure 0        0
## 212   cellular   7   jul      167        2    -1        0  unknown 0        0
## 213   cellular   3   dec      155        1   120        3  success 1        0
## 214   cellular   7   apr      479        1    -1        0  unknown 0        0
## 215  telephone   4   aug      250        2   187        2  success 1        0
## 216   cellular  22   aug       80        2    -1        0  unknown 0        0
## 217    unknown  28   may     1183        1    -1        0  unknown 1        1
## 218   cellular  29   jan      418        2    -1        0  unknown 0        0
## 219   cellular  10   jul      340        1    -1        0  unknown 0        0
## 220    unknown  19   may      468        1    -1        0  unknown 0        0
## 221  telephone  17   apr      777        2    -1        0  unknown 0        0
## 222   cellular  31   jul       18       44    -1        0  unknown 0        0
## 223   cellular  18   may      114        4   364       22    other 0        0
## 224   cellular  27   aug       15       20    -1        0  unknown 0        0
## 225    unknown  17   jun      167        1    -1        0  unknown 0        0
## 226   cellular  14   may      396        5    -1        0  unknown 1        1
## 227    unknown   8   may      159        4    -1        0  unknown 0        0
## 228  telephone   7   aug      430        4    -1        0  unknown 0        0
## 229    unknown   5   may      189        2    -1        0  unknown 0        0
## 230   cellular  27   nov      142        2    -1        0  unknown 0        0
## 231  telephone  30   apr      268        1    -1        0  unknown 0        1
## 232   cellular  29   jan       80        2    -1        0  unknown 0        0
## 233    unknown   5   may      233        3    -1        0  unknown 0        0
## 234    unknown   4   jun      208        4    -1        0  unknown 0        0
## 235   cellular  18   nov       79        3    -1        0  unknown 0        0
## 236   cellular  23   jul      118        1    -1        0  unknown 0        0
## 237   cellular  26   aug       73        4    -1        0  unknown 0        0
## 238    unknown  21   may      175        2    -1        0  unknown 0        0
## 239   cellular  17   nov      165        1    -1        0  unknown 0        0
## 240   cellular  29   jul      122       13    -1        0  unknown 0        1
## 241    unknown   1   jul      125        3    -1        0  unknown 0        0
## 242    unknown   8   may       23        4    -1        0  unknown 0        0
## 243    unknown  16   may      557        4    -1        0  unknown 0        0
## 244   cellular  12   may      528        5    -1        0  unknown 1        0
## 245   cellular  18   nov      420        2    -1        0  unknown 0        0
## 246    unknown  27   may      151        1    -1        0  unknown 0        0
## 247    unknown  14   may      407        2    -1        0  unknown 0        0
## 248   cellular  18   nov      104        2    28        2  success 0        0
## 249    unknown  13   may      351        1    -1        0  unknown 0        0
## 250   cellular  25   jul      357        1    -1        0  unknown 0        0
## 251   cellular  11   jul      255        3    -1        0  unknown 0        1
## 252   cellular  17   apr      426        3   323        3  failure 0        0
## 253   cellular  27   feb      204        1    -1        0  unknown 0        0
## 254    unknown  29   may      418        8    -1        0  unknown 0        0
## 255   cellular  27   oct      184        1    91        2  failure 1        1
## 256    unknown   3   jun       72        1    -1        0  unknown 0        0
## 257    unknown  19   jun      237        2    -1        0  unknown 0        0
## 258   cellular  21   jul      163        3    -1        0  unknown 0        0
## 259    unknown   6   jun      153        4    -1        0  unknown 0        0
## 260    unknown  20   jun        8        3    -1        0  unknown 0        0
## 261    unknown  19   jun      399        1    -1        0  unknown 0        1
## 262   cellular   5   may      185        2   165        2  failure 0        0
## 263  telephone  27   sep      379        3    -1        0  unknown 0        1
## 264    unknown  12   may      370        1    -1        0  unknown 0        0
## 265   cellular  20   apr      401        2    -1        0  unknown 0        1
## 266    unknown  20   jun       14        2    -1        0  unknown 0        0
## 267   cellular   8   may       85        1   168        2  failure 0        0
## 268    unknown  23   may      230        2    -1        0  unknown 0        0
## 269    unknown  19   jun       66        1    -1        0  unknown 0        0
## 270   cellular   5   may      236        1   287        2  failure 0        0
## 271   cellular   2   feb      138        3     5        1    other 0        0
## 272   cellular  25   jul      784        1    -1        0  unknown 1        1
## 273   cellular  11   aug      103        6    -1        0  unknown 0        0
## 274   cellular   7   aug      165        3    -1        0  unknown 0        0
## 275   cellular  13   may      325        2    -1        0  unknown 0        0
## 276    unknown  20   jun       75        4    -1        0  unknown 0        0
## 277    unknown   3   jun      157        2    -1        0  unknown 0        0
## 278   cellular  14   aug      297        2    -1        0  unknown 0        0
## 279   cellular   7   may       13        5    -1        0  unknown 0        1
## 280   cellular  14   may      177        2   345        3    other 0        0
## 281   cellular  28   aug       62        7    -1        0  unknown 0        0
## 282    unknown  20   may      834        6    -1        0  unknown 0        0
## 283    unknown   5   jun     1446        1    -1        0  unknown 1        0
## 284   cellular  18   jul      482        2    -1        0  unknown 0        0
## 285   cellular  13   mar      432        1    -1        0  unknown 0        0
## 286    unknown  28   may      173        3    -1        0  unknown 0        0
## 287    unknown   3   jun      157        2    -1        0  unknown 0        0
## 288   cellular  22   jul       95        1    -1        0  unknown 0        0
## 289   cellular  13   may      196        3   265        2  failure 0        0
## 290   cellular  17   apr      728        1    -1        0  unknown 0        0
## 291   cellular  21   nov        7        8   185        1  failure 0        0
## 292    unknown  20   may      203        1    -1        0  unknown 0        0
## 293   cellular  13   jan      169        2    -1        0  unknown 1        1
## 294   cellular  26   aug       65        4    -1        0  unknown 0        0
## 295  telephone  20   nov       66        1    -1        0  unknown 0        0
## 296    unknown  29   may      161        1    -1        0  unknown 0        0
## 297   cellular  12   may       63        5   370        1    other 0        0
## 298   cellular  20   nov      104        3   139        6  failure 0        0
## 299   cellular  29   jul      180       10    -1        0  unknown 0        0
## 300   cellular  10   jul      961        1    -1        0  unknown 1        0
## 301   cellular   8   jul      306        2    -1        0  unknown 0        0
## 302   cellular  28   aug       58        8    -1        0  unknown 0        0
## 303   cellular  30   apr      551        1    -1        0  unknown 0        0
## 304    unknown   6   jun       81        2    -1        0  unknown 0        0
## 305   cellular  17   apr      150        1    -1        0  unknown 0        0
## 306   cellular  16   apr      332        2   317        3  failure 0        0
## 307   cellular  11   mar      117        1    91        1  success 0        0
## 308    unknown  23   may      275        2    -1        0  unknown 0        0
## 309   cellular  18   nov      150        4    -1        0  unknown 0        0
## 310   cellular  22   may      121        1    -1        0  unknown 0        0
## 311    unknown  14   may      183        4    -1        0  unknown 0        0
## 312   cellular   6   oct      386        1   184        1    other 0        0
## 313   cellular  14   may       17        7    -1        0  unknown 0        0
## 314    unknown  27   may       72        3    -1        0  unknown 0        0
## 315   cellular   7   sep      133        3    -1        0  unknown 0        0
## 316   cellular  16   jul      278        2    -1        0  unknown 0        0
## 317   cellular  22   jun      113        1   109        1  failure 0        1
## 318   cellular  15   jul     1056        2    -1        0  unknown 1        1
## 319   cellular   4   may      190        3    -1        0  unknown 0        0
## 320   cellular  17   apr       57        1    -1        0  unknown 0        0
## 321   cellular  27   aug       50        4    -1        0  unknown 0        0
## 322   cellular   7   may      184        1   351        1  failure 0        0
## 323   cellular  28   aug       35       31    -1        0  unknown 0        0
## 324   cellular  21   jul       81        4    -1        0  unknown 0        0
## 325   cellular  18   nov      120        2    -1        0  unknown 0        0
## 326   cellular   2   jul      309        1    -1        0  unknown 1        0
## 327   cellular  31   jul      119        2    -1        0  unknown 0        0
## 328    unknown  19   may      206        4    -1        0  unknown 0        0
## 329   cellular  30   jul       92        3    -1        0  unknown 0        0
## 330  telephone  22   jul      204        2    -1        0  unknown 0        0
## 331  telephone   4   feb      176        3    -1        0  unknown 0        0
## 332    unknown  10   aug       11        1    -1        0  unknown 0        1
## 333   cellular  21   jul      407       11    -1        0  unknown 0        0
## 334  telephone  13   may      212        3    -1        0  unknown 0        0
## 335   cellular  15   may     1357        4   374        2  failure 1        0
## 336   cellular  25   may      867        1    -1        0  unknown 1        1
## 337   cellular  13   may      182        4    -1        0  unknown 0        0
## 338   cellular  18   aug       65        3    -1        0  unknown 0        0
## 339   cellular   8   may      265        1   290        2  failure 0        0
## 340    unknown  20   jun      116        3    -1        0  unknown 0        0
## 341  telephone  20   nov       88        6   113       13    other 0        0
## 342   cellular   4   feb      228        1    -1        0  unknown 0        0
## 343   cellular  17   nov      369        1    -1        0  unknown 0        0
## 344    unknown   6   jun       52        1    -1        0  unknown 0        0
## 345   cellular  21   aug      107        6    -1        0  unknown 0        0
## 346   cellular   7   aug       82        2    -1        0  unknown 0        0
## 347   cellular  18   may      767        2    -1        0  unknown 1        0
## 348   cellular  12   may      313        2    -1        0  unknown 0        0
## 349   cellular   7   jul       17       19    -1        0  unknown 0        0
## 350  telephone   3   mar      834        1    -1        0  unknown 1        0
## 351    unknown  21   may      178        1    -1        0  unknown 0        1
## 352   cellular   2   apr      108        1    -1        0  unknown 0        1
## 353   cellular  10   jul      200        5    -1        0  unknown 0        0
## 354    unknown  30   may      147        1    -1        0  unknown 0        0
## 355   cellular  21   nov      102        1    -1        0  unknown 0        0
## 356    unknown   8   may      202        1    -1        0  unknown 0        0
## 357   cellular   4   feb       93        2   274        2  failure 0        0
## 358   cellular  13   may      777        2    -1        0  unknown 0        0
## 359   cellular   9   jul      225        2    -1        0  unknown 0        0
## 360    unknown  27   may       32        1    -1        0  unknown 0        0
## 361    unknown  19   may      263        1    -1        0  unknown 0        1
## 362  telephone  17   feb      466        4    -1        0  unknown 1        0
## 363   cellular  15   jul      838        3    -1        0  unknown 1        0
## 364   cellular   5   feb      288        1    -1        0  unknown 0        0
## 365   cellular  21   nov      223        2   186        3    other 0        0
## 366   cellular  27   aug      183        5    -1        0  unknown 0        0
## 367    unknown  26   may      536        1    -1        0  unknown 0        0
## 368   cellular  25   aug      324        4    -1        0  unknown 0        0
## 369   cellular  19   nov      266        2    -1        0  unknown 0        0
## 370   cellular   6   may       98        2    -1        0  unknown 0        0
## 371    unknown  20   may      135        2    -1        0  unknown 0        0
## 372   cellular  14   jul      326       11    -1        0  unknown 0        0
## 373   cellular  18   may       98        2    -1        0  unknown 0        0
## 374   cellular  15   may      195        3   359        1  failure 0        0
## 375   cellular  19   nov      149        1   170        2  failure 0        0
## 376    unknown   4   jul       64        1    -1        0  unknown 0        0
## 377   cellular  29   aug      272        2    -1        0  unknown 0        0
## 378    unknown  30   may       38        3    -1        0  unknown 0        0
## 379   cellular  18   may      185        1   178        1  failure 0        0
## 380    unknown  20   jun      152        5    -1        0  unknown 0        0
## 381   cellular  29   aug      709       11    -1        0  unknown 0        0
## 382   cellular  11   jul     1187        3    -1        0  unknown 0        0
## 383   cellular  12   may      703        4    -1        0  unknown 1        0
## 384   cellular   7   may       62        2    -1        0  unknown 0        1
## 385    unknown   8   may      384        1    -1        0  unknown 0        0
## 386  telephone  12   may       34       12   347        5    other 0        0
## 387   cellular  28   jan      280        1    -1        0  unknown 0        0
## 388  telephone  25   jul      362        8    -1        0  unknown 1        0
## 389    unknown  20   jun      250        3    -1        0  unknown 0        0
## 390   cellular  17   nov       59        1    -1        0  unknown 0        0
## 391    unknown   5   may      541        1    -1        0  unknown 0        0
## 392   cellular   2   feb      361        2   258        1    other 0        0
## 393   cellular  15   feb      394        3   189        1  success 1        0
## 394   cellular  22   jul       70        1    -1        0  unknown 0        0
## 395    unknown   8   may       20        2    -1        0  unknown 0        0
## 396   cellular  11   jul     1389        2    -1        0  unknown 0        0
## 397    unknown  16   jun      215        3    -1        0  unknown 0        0
## 398   cellular  15   may      178        2   270        8    other 0        0
## 399   cellular  29   jul      218        4    -1        0  unknown 0        0
## 400   cellular  21   nov      664        3    -1        0  unknown 1        0
## 401   cellular  31   jul      244        2    -1        0  unknown 0        0
## 402   cellular  13   may      109        1   359        8  failure 0        0
## 403   cellular  12   may       76        2   348        1  failure 0        0
## 404   cellular  30   nov      598        4    -1        0  unknown 0        0
## 405    unknown   5   jun      805        2    -1        0  unknown 0        0
## 406   cellular  16   jul      335        1    -1        0  unknown 0        0
## 407   cellular   9   sep      202        1    -1        0  unknown 1        1
## 408   cellular  20   aug      214        8    -1        0  unknown 0        0
## 409    unknown  29   may      278        1    -1        0  unknown 0        0
## 410   cellular  11   jul       58        1    -1        0  unknown 0        0
## 411   cellular  20   aug       83        6    -1        0  unknown 0        0
## 412   cellular   8   may      291        1   337        1  failure 0        0
## 413    unknown   8   may      128        1    -1        0  unknown 0        0
## 414    unknown   6   jun      431        2    -1        0  unknown 0        0
## 415   cellular  20   nov      262        3    -1        0  unknown 0        0
## 416  telephone   4   aug      152        2    -1        0  unknown 0        0
## 417    unknown  13   may       98        1    -1        0  unknown 0        0
## 418    unknown   5   jun      718       13    -1        0  unknown 0        1
## 419  telephone  30   jul      285        2    -1        0  unknown 0        0
## 420   cellular   2   feb      246        1   259        2  failure 0        0
## 421    unknown  14   jun       20        1    -1        0  unknown 0        0
## 422  telephone   7   jul       41        9    -1        0  unknown 0        0
## 423    unknown  20   jun       73        3    -1        0  unknown 0        0
## 424   cellular   2   feb      237        2    -1        0  unknown 0        0
## 425   cellular  30   jan      592        1    -1        0  unknown 0        0
## 426   cellular  28   aug      622        1    -1        0  unknown 1        0
## 427   cellular   2   feb      427        4    -1        0  unknown 0        0
## 428   cellular  29   jul      646        2    -1        0  unknown 0        0
## 429    unknown   6   nov       26        1   101       11    other 0        0
## 430  telephone  19   nov      519        2    -1        0  unknown 0        0
## 431  telephone  20   apr      205        1    -1        0  unknown 0        0
## 432   cellular   2   jul      146        1    91        6  failure 0        0
## 433    unknown  21   may      104        1    -1        0  unknown 0        0
## 434    unknown  23   may      105        2    -1        0  unknown 0        0
## 435   cellular  19   aug      110        4    -1        0  unknown 0        0
## 436    unknown  27   may      138        2    -1        0  unknown 0        0
## 437   cellular  28   jan      134        1    91        1  success 1        0
## 438   cellular   6   feb     1423        3    -1        0  unknown 0        0
## 439   cellular  31   aug      298        2   300        1    other 0        0
## 440   cellular   7   aug      139        4    -1        0  unknown 0        0
## 441    unknown  18   jun      368        1    -1        0  unknown 0        0
## 442    unknown  19   may      546        2    -1        0  unknown 0        0
## 443   cellular  15   sep      103        1    91        2  failure 0        0
## 444   cellular  15   may     1259        2   333       18  failure 0        0
## 445    unknown   5   jun      267       11    -1        0  unknown 0        0
## 446    unknown  12   may      156        3    -1        0  unknown 0        0
## 447   cellular  31   jul       46        3    -1        0  unknown 0        0
## 448  telephone  13   may       38        3    -1        0  unknown 0        0
## 449    unknown  29   may      368        2    -1        0  unknown 0        0
## 450   cellular  18   jun      201        3    -1        0  unknown 0        0
## 451   cellular  18   aug      205        4    -1        0  unknown 0        0
## 452   cellular  22   aug      140       11    -1        0  unknown 0        0
## 453   cellular   4   feb      170        2    -1        0  unknown 0        0
## 454    unknown  27   may      198        2    -1        0  unknown 0        0
## 455   cellular  20   aug      143        4    -1        0  unknown 0        0
## 456   cellular  18   may     1434        2   356        4  failure 0        0
## 457   cellular   6   may      472        1    -1        0  unknown 0        0
## 458   cellular  25   jul       18        2    -1        0  unknown 0        0
## 459   cellular   8   may      158        3   354        1  failure 0        0
## 460   cellular  20   nov      366        6    -1        0  unknown 0        0
## 461   cellular  22   jul       70        9    -1        0  unknown 0        0
## 462   cellular  20   apr      142        3   150        3  failure 0        0
## 463   cellular   6   may       64        2   364        3  failure 0        0
## 464   cellular  19   nov      296        1    -1        0  unknown 0        0
## 465   cellular  14   aug      112        2    -1        0  unknown 0        0
## 466   cellular  20   nov      182        2    -1        0  unknown 0        0
## 467   cellular   4   feb      136        3    -1        0  unknown 1        0
## 468   cellular  17   nov       80        1    -1        0  unknown 0        0
## 469   cellular  30   jul     1013       29    -1        0  unknown 1        0
## 470    unknown  15   may      448        4    -1        0  unknown 0        1
## 471   cellular   4   aug      146        3    -1        0  unknown 0        0
## 472   cellular   7   jul      174        1    -1        0  unknown 0        0
## 473   cellular  30   jul       29        4    -1        0  unknown 0        0
## 474    unknown   8   may      202        2    -1        0  unknown 0        0
## 475   cellular  26   aug      189        4    -1        0  unknown 0        0
## 476   cellular  14   jul      144        2    -1        0  unknown 0        0
## 477    unknown  27   may      112        1    -1        0  unknown 0        0
## 478   cellular  11   jul       94        2    -1        0  unknown 0        0
## 479    unknown  15   may       58        5    -1        0  unknown 0        0
## 480    unknown  15   may      911        2    -1        0  unknown 1        0
## 481   cellular  17   aug      308        1   459        1  success 1        0
## 482  telephone   4   may      331        5    -1        0  unknown 1        0
## 483    unknown  18   jun      249        5    -1        0  unknown 0        0
## 484   cellular   9   jul      171        2    -1        0  unknown 0        1
## 485    unknown  14   may      123        5    -1        0  unknown 0        1
## 486   cellular  12   feb      251        1   186        3  success 1        0
## 487   cellular  14   apr      706        2    -1        0  unknown 0        0
## 488   cellular  21   oct      110        1   106        2  failure 0        0
## 489    unknown   9   jun       90        4    -1        0  unknown 0        0
## 490  telephone   7   aug      204        4    -1        0  unknown 0        0
## 491   cellular  27   oct      157        1    -1        0  unknown 0        0
## 492   cellular   2   feb      415        1    -1        0  unknown 1        0
## 493   cellular  27   mar      558        1    -1        0  unknown 0        0
## 494   cellular  20   apr       18        5   335        9    other 0        0
## 495    unknown  16   jun      342        1    -1        0  unknown 0        0
## 496   cellular  30   jul      159        2    -1        0  unknown 0        0
## 497   cellular   8   apr      518        2   261        2  failure 0        0
## 498   cellular  20   apr       59        1    -1        0  unknown 0        0
## 499   cellular  13   may      159        2   278        4  failure 0        0
## 500   cellular  17   jul       82        2    -1        0  unknown 0        0
## 501    unknown   9   may      169        2    -1        0  unknown 0        0
## 502   cellular  14   may        9       10   330       10    other 0        0
## 503    unknown  15   may      155        2    -1        0  unknown 0        0
## 504   cellular  16   apr      517        1   255        1  failure 0        0
## 505    unknown  11   jun      110        1    -1        0  unknown 0        0
## 506   cellular  18   may      189        3   348        3  failure 0        0
## 507   cellular   4   aug      441        2    -1        0  unknown 0        0
## 508   cellular  13   aug       95        4    -1        0  unknown 0        0
## 509    unknown  28   may      158        2    -1        0  unknown 0        1
## 510   cellular  29   jan       82        2    -1        0  unknown 0        0
## 511   cellular  15   may      141        1   343        3  failure 0        1
## 512   cellular  18   jun      813        4    -1        0  unknown 1        0
## 513    unknown  21   may      255        1    -1        0  unknown 0        0
## 514    unknown  20   jun       10       19    -1        0  unknown 0        0
## 515   cellular  30   apr      306        2    -1        0  unknown 1        0
## 516    unknown   9   may      322        5    -1        0  unknown 0        0
## 517   cellular   8   may       26        1    -1        0  unknown 0        1
## 518    unknown   7   may      944        3    -1        0  unknown 0        0
## 519   cellular  15   jun      270        2   377        3  success 0        1
## 520   cellular  28   jan      168        2   205        1  failure 0        0
## 521   cellular   2   aug       90        4    -1        0  unknown 0        0
## 522   cellular  13   may      191        1   342        2  failure 0        0
## 523   cellular  26   oct       99        2   185        3  failure 0        0
## 524   cellular   5   may       77        2    -1        0  unknown 0        0
## 525   cellular  12   aug      117        2    -1        0  unknown 0        0
## 526  telephone  18   may       52        9    -1        0  unknown 0        0
## 527   cellular  21   nov      119        1   157        2  failure 0        0
## 528   cellular  26   apr      166        5   181        5  failure 0        0
## 529   cellular  12   aug      338        2   104        1  success 1        0
## 530   cellular   7   may      109        2    -1        0  unknown 0        0
## 531   cellular  18   aug      296        3    -1        0  unknown 0        0
## 532    unknown   7   may      348        3    -1        0  unknown 0        0
## 533   cellular  26   may      133        2   363        5  failure 0        0
## 534    unknown   8   may      170        2    -1        0  unknown 0        0
## 535   cellular  31   jul      189        3    -1        0  unknown 0        0
## 536   cellular  30   jan      130        1     2        1    other 0        0
## 537   cellular   4   feb      254        2    -1        0  unknown 0        0
## 538   cellular  21   nov      681        4    -1        0  unknown 1        0
## 539   cellular  11   aug     1099        4    -1        0  unknown 0        0
## 540   cellular  25   aug      220        3    -1        0  unknown 0        0
## 541   cellular  18   nov      271        5    -1        0  unknown 0        0
## 542    unknown  28   may       86        1    -1        0  unknown 1        0
## 543   cellular   8   aug       49        2    -1        0  unknown 0        0
## 544   cellular  21   nov      808        2    -1        0  unknown 1        0
## 545   cellular  16   jul     1039        2    -1        0  unknown 1        0
## 546   cellular   8   aug       59        3    -1        0  unknown 0        0
## 547   cellular  14   jul      209        2    -1        0  unknown 0        0
## 548    unknown   6   may      208        1    -1        0  unknown 0        0
## 549   cellular  18   may       98        1    -1        0  unknown 0        0
## 550  telephone  10   jul      123        1    -1        0  unknown 0        0
## 551   cellular  21   nov       14        7    -1        0  unknown 0        0
## 552    unknown  19   may      492        6    -1        0  unknown 0        0
## 553   cellular   5   may      118        1    -1        0  unknown 0        0
## 554   cellular  21   nov      235        2    -1        0  unknown 0        0
## 555    unknown  11   jun      643        1    -1        0  unknown 0        0
## 556   cellular  12   jul      250        2   181        4  success 1        0
## 557   cellular  12   may     1272        1    -1        0  unknown 1        0
## 558  telephone  25   may      100        3    -1        0  unknown 0        0
## 559   cellular  21   nov      462        3    -1        0  unknown 0        0
## 560    unknown   3   jul       24        1    -1        0  unknown 0        0
## 561   cellular  30   jan      931        1    -1        0  unknown 1        0
## 562   cellular  20   apr      190        1   335        1    other 0        0
## 563   cellular   7   aug      133        4    -1        0  unknown 0        0
## 564   cellular   4   feb      227        2    -1        0  unknown 1        0
## 565   cellular  11   nov      357        3    93        5  success 1        0
## 566    unknown   2   jun      183        3    -1        0  unknown 0        0
## 567   cellular   2   jul      281        1    -1        0  unknown 0        1
## 568   cellular   9   jun      239        4    -1        0  unknown 1        0
## 569   cellular  30   apr      152        1    -1        0  unknown 0        1
## 570   cellular  18   nov     1268        2    -1        0  unknown 0        0
## 571   cellular  17   nov       73        1    -1        0  unknown 0        0
## 572    unknown  14   may      202        2    -1        0  unknown 0        0
## 573    unknown  26   may      247        1    -1        0  unknown 0        0
## 574   cellular  28   jul      418        3    -1        0  unknown 0        0
## 575   cellular   6   may      373        4    -1        0  unknown 0        1
## 576    unknown  20   jun       14        6    -1        0  unknown 0        0
## 577   cellular  21   nov      108        1    -1        0  unknown 0        0
## 578   cellular  29   jan      624        2    -1        0  unknown 0        0
## 579   cellular   5   may      278        1    -1        0  unknown 0        0
## 580   cellular  13   may      177        3   343        1    other 0        0
## 581   cellular  11   jul      191        1    -1        0  unknown 0        1
## 582   cellular  12   may      235        6    -1        0  unknown 0        0
## 583    unknown  16   jun      637        6    -1        0  unknown 1        0
## 584  telephone  29   apr      660        1   191        1  failure 1        0
## 585  telephone  13   aug       57        1    -1        0  unknown 0        0
## 586   cellular  13   may      307        2    -1        0  unknown 0        1
## 587   cellular  16   jul      165        5    -1        0  unknown 0        1
## 588   cellular  28   aug      140        9    -1        0  unknown 0        0
## 589  telephone  12   may       11        1    -1        0  unknown 0        0
## 590   cellular  15   may      228        2   297        1    other 0        0
## 591    unknown  28   may      210        1    -1        0  unknown 0        0
## 592   cellular  22   jul      321        4    -1        0  unknown 1        0
## 593   cellular  13   may      423        1   349        1  failure 0        0
## 594    unknown   9   may      210        3    -1        0  unknown 0        0
## 595   cellular  21   oct      825        1   183        4  success 1        1
## 596    unknown  23   may      224        4    -1        0  unknown 0        0
## 597   cellular  26   feb       51        1    -1        0  unknown 0        0
## 598   cellular   8   aug      121        2    -1        0  unknown 0        0
## 599   cellular   5   jun      206        1    99        1  failure 0        0
## 600    unknown   4   jun      142       11    -1        0  unknown 0        0
## 601    unknown   2   jun       41        5    -1        0  unknown 0        0
## 602   cellular  21   nov       53        1    31        1  failure 0        0
## 603    unknown  20   may      120        1    -1        0  unknown 0        0
## 604   cellular   7   jul      200        4    -1        0  unknown 0        0
## 605   cellular  18   nov       84        2    -1        0  unknown 0        0
## 606  telephone  23   jul      226        1    -1        0  unknown 0        0
## 607   cellular  21   nov      112        1    -1        0  unknown 0        0
## 608    unknown   7   may      274        2    -1        0  unknown 0        0
## 609   cellular  25   aug      417        4    -1        0  unknown 0        0
## 610   cellular  15   apr      266        2    -1        0  unknown 0        0
## 611   cellular   4   feb      453        2   273        2  failure 0        0
## 612  telephone  23   jul      203        2    -1        0  unknown 0        0
## 613    unknown  28   may      140        5    -1        0  unknown 0        0
## 614  telephone   4   feb      403        2    -1        0  unknown 0        0
## 615   cellular  27   feb       99        1   102        6  success 1        0
## 616    unknown  12   may      322        1    -1        0  unknown 0        0
## 617   cellular   4   aug      259        1    35        1  failure 0        0
## 618    unknown  21   may      290        2    -1        0  unknown 0        0
## 619    unknown   9   jun      438        5    -1        0  unknown 0        0
## 620   cellular  20   apr       93        4    -1        0  unknown 0        0
## 621   cellular  26   feb       74        1    24        1  failure 0        0
## 622  telephone  22   feb      363        2    -1        0  unknown 0        0
## 623   cellular  12   aug       90        1    68        1  success 0        0
## 624   cellular  13   aug       69        2    -1        0  unknown 0        0
## 625   cellular  22   jul      236        4    -1        0  unknown 0        0
## 626  telephone  21   nov      182        2    -1        0  unknown 0        0
## 627   cellular  21   nov       41        1    -1        0  unknown 0        0
## 628   cellular  19   nov      631        1    -1        0  unknown 0        0
## 629   cellular  15   may      103        5    -1        0  unknown 0        1
## 630   cellular   8   may      579        2   295        1  success 1        0
## 631    unknown  15   may      164        2    -1        0  unknown 0        0
## 632   cellular  14   jul      189        3    -1        0  unknown 0        1
## 633   cellular   2   feb      277        1    -1        0  unknown 0        0
## 634   cellular  25   jul      136        5    -1        0  unknown 0        0
## 635   cellular   7   may      329        1   168        2  success 0        0
## 636   cellular   7   aug      419        3    -1        0  unknown 0        0
## 637    unknown   4   jun      119        1    -1        0  unknown 0        0
## 638    unknown  19   jun       36        7    -1        0  unknown 0        0
## 639   cellular  29   jul      155        2    -1        0  unknown 0        0
## 640    unknown   9   jul      139        1    -1        0  unknown 0        1
## 641   cellular   7   jul      152        5    -1        0  unknown 0        0
## 642    unknown  20   jun       12       14    -1        0  unknown 0        0
## 643    unknown  20   may       88        2    -1        0  unknown 0        0
## 644   cellular   4   nov      116        4   154        1  failure 0        0
## 645    unknown  20   may      443        1    -1        0  unknown 0        0
## 646   cellular  25   may      214        1   305        1    other 1        0
## 647   cellular   5   feb      110        2    64        2  success 1        0
## 648   cellular  31   jul      101        2    -1        0  unknown 0        0
## 649  telephone  18   nov      177        2    -1        0  unknown 0        0
## 650   cellular  25   jul      289        1    -1        0  unknown 0        0
## 651   cellular   4   feb      362        2   169        2  failure 0        0
## 652    unknown  15   may      738        7    -1        0  unknown 0        0
## 653    unknown   7   may      128        2    -1        0  unknown 0        0
## 654   cellular  28   jan       76        1    -1        0  unknown 0        0
## 655   cellular  21   aug      175        2    -1        0  unknown 0        0
## 656   cellular  13   aug      206        2    -1        0  unknown 0        0
## 657    unknown  27   may      205        8    -1        0  unknown 0        0
## 658    unknown   7   may      152        3    -1        0  unknown 0        0
## 659  telephone  12   aug      542        1    78        5  failure 0        0
## 660    unknown  19   may       85        3    -1        0  unknown 0        0
## 661    unknown  20   may      172        1    -1        0  unknown 0        0
## 662   cellular  30   apr      149        1    84        7  success 0        1
## 663   cellular  23   jul      151        1    -1        0  unknown 0        0
## 664   cellular  21   nov      233        1    -1        0  unknown 0        0
## 665  telephone  21   apr      396        3    -1        0  unknown 1        0
## 666    unknown  15   may       49        1    -1        0  unknown 0        0
## 667    unknown  20   may      201        1    -1        0  unknown 0        0
## 668    unknown  20   jun      285        4    -1        0  unknown 0        0
## 669   cellular  17   aug      125        1    -1        0  unknown 0        1
## 670    unknown  21   may      206        1    -1        0  unknown 0        0
## 671  telephone  31   jul       36        4    -1        0  unknown 0        0
## 672   cellular  19   nov      635        3   170        2  failure 0        0
## 673   cellular   7   aug      314        4    -1        0  unknown 0        0
## 674   cellular  16   apr      474        2    -1        0  unknown 0        0
## 675    unknown   3   jun      277        1    -1        0  unknown 0        1
## 676    unknown   6   jun       64        1    -1        0  unknown 0        0
## 677   cellular  17   nov      376        1    -1        0  unknown 0        0
## 678   cellular  10   feb      158        2    92        5  success 1        0
## 679  telephone   6   aug      115        5    -1        0  unknown 0        0
## 680  telephone  12   may      148        6   308        1  failure 0        0
## 681   cellular  18   nov      114        1    -1        0  unknown 0        0
## 682    unknown  17   jun       92        2    -1        0  unknown 0        0
## 683   cellular  28   jan       62        1    -1        0  unknown 0        0
## 684   cellular  22   aug      314        4    -1        0  unknown 0        0
## 685    unknown  30   may      104        3    -1        0  unknown 0        0
## 686   cellular  18   may      186        1    -1        0  unknown 0        0
## 687   cellular   9   mar      273        2   182        1  success 1        1
## 688   cellular  26   aug      102        7    -1        0  unknown 0        0
## 689  telephone  13   may      246        2   370        2  success 0        0
## 690   cellular  12   aug      138        2    -1        0  unknown 0        0
## 691    unknown  19   jun       64        1    -1        0  unknown 0        0
## 692   cellular  26   jul      546        2   784        3  failure 1        0
## 693   cellular  21   aug     1503        2    -1        0  unknown 1        0
## 694   cellular  11   aug      220        1    -1        0  unknown 0        0
## 695   cellular  25   aug      585        4    -1        0  unknown 0        0
## 696    unknown  16   may      270        1    -1        0  unknown 0        1
## 697   cellular   7   jul      295        1    -1        0  unknown 0        0
## 698  telephone   6   feb       48        5    -1        0  unknown 0        0
## 699    unknown   3   jun      186        1    -1        0  unknown 0        0
## 700   cellular  20   apr      246        2   334        3    other 0        0
## 701   cellular  13   may      247        1    -1        0  unknown 0        0
## 702   cellular   7   jul      136        1    -1        0  unknown 0        0
## 703   cellular  28   aug      149       14    -1        0  unknown 0        0
## 704    unknown  13   may       70        1    -1        0  unknown 0        1
## 705   cellular   5   may       84        5    -1        0  unknown 0        0
## 706   cellular  31   jul      251        3    -1        0  unknown 0        0
## 707   cellular  16   jul       57        2    -1        0  unknown 0        1
## 708  telephone  25   jul      219        2    -1        0  unknown 0        0
## 709    unknown   9   may      164        1    -1        0  unknown 0        0
## 710    unknown   6   jun      126        1    -1        0  unknown 0        0
## 711    unknown   3   jul       74        5    -1        0  unknown 0        0
## 712   cellular   7   may      266        2   168        1  failure 0        0
## 713   cellular  25   jul      194        2    -1        0  unknown 0        1
## 714    unknown  12   may       81        4    -1        0  unknown 0        0
## 715   cellular   4   feb       56        1   274        2  failure 0        0
## 716   cellular   2   feb      138        2    -1        0  unknown 0        0
## 717    unknown  18   jun       61        3    -1        0  unknown 0        0
## 718    unknown  17   jun      160        3    -1        0  unknown 0        0
## 719  telephone  15   may        8        7    -1        0  unknown 0        0
## 720    unknown   6   may      128        2    -1        0  unknown 0        0
## 721   cellular   5   feb      232        1   211        1  failure 0        0
## 722    unknown   6   jun      264        1    -1        0  unknown 0        0
## 723   cellular  20   nov      356        1    -1        0  unknown 0        0
## 724   cellular  20   nov      271        1   184        1  failure 0        0
## 725   cellular  20   apr        6        6   328        8  failure 0        0
## 726    unknown   8   may       74        7    -1        0  unknown 0        0
## 727   cellular  27   oct      424        1   515        1  failure 1        0
## 728   cellular  11   aug      312        3    -1        0  unknown 0        0
## 729    unknown  28   may       87        5    -1        0  unknown 0        0
## 730   cellular  13   may      204        2    -1        0  unknown 0        0
## 731    unknown   9   may      408        2    -1        0  unknown 0        0
## 732  telephone  14   jul      413        1   181        3  success 1        0
## 733   cellular  23   jun      124        1   105        1  failure 0        1
## 734   cellular  14   may      797        2    -1        0  unknown 0        0
## 735    unknown   9   may      180        1    -1        0  unknown 0        0
## 736    unknown  19   jun     2028        1    -1        0  unknown 1        0
## 737   cellular  12   apr      203        1    -1        0  unknown 0        0
## 738   cellular   4   feb      162        2   184        1  failure 0        0
## 739   cellular  20   apr      856        3    -1        0  unknown 0        0
## 740   cellular  11   aug      135        6    -1        0  unknown 0        0
## 741   cellular  13   may       38        3    -1        0  unknown 0        0
## 742   cellular  20   aug      256        4    -1        0  unknown 0        0
## 743   cellular  27   aug       59        6    -1        0  unknown 0        0
## 744   cellular  25   aug      304        6    -1        0  unknown 0        0
## 745   cellular  18   aug      128        2    -1        0  unknown 0        0
## 746   cellular  19   jun      474        3    95        3    other 1        1
## 747    unknown  29   may       59        3    -1        0  unknown 0        0
## 748   cellular  30   jan      510        2    -1        0  unknown 0        0
## 749    unknown  29   may       52        8    -1        0  unknown 0        0
## 750   cellular   8   may      389        1    -1        0  unknown 0        0
## 751   cellular  11   aug      232        4    -1        0  unknown 0        0
## 752   cellular  20   apr      233        3    -1        0  unknown 0        0
## 753   cellular   4   nov      298        2    82        4    other 0        1
## 754   cellular  19   nov      287        3   117        2    other 0        0
## 755    unknown  30   may       58        1    -1        0  unknown 0        0
## 756   cellular   9   jul     1426        3    -1        0  unknown 1        0
## 757   cellular  17   sep      285        3    81        3  failure 1        0
## 758   cellular   6   feb       10        5    -1        0  unknown 0        0
## 759    unknown   5   jun      243        1    -1        0  unknown 0        0
## 760   cellular  30   jan      180        1    -1        0  unknown 0        0
## 761    unknown   8   may       93        2    -1        0  unknown 0        1
## 762   cellular   7   aug      229        4    -1        0  unknown 0        0
## 763   cellular   2   apr      313        3    -1        0  unknown 1        0
## 764   cellular   9   jul      140        3    -1        0  unknown 0        0
## 765    unknown  23   may       95        4    -1        0  unknown 0        0
## 766   cellular  20   aug      132        1    -1        0  unknown 0        0
## 767    unknown   9   may      210        3    -1        0  unknown 0        0
## 768    unknown  20   jun       99        5    -1        0  unknown 0        0
## 769  telephone  24   jul      393        3    -1        0  unknown 0        0
## 770   cellular  28   aug       31        9    -1        0  unknown 0        0
## 771   cellular  20   apr      239        2   259        2  failure 0        0
## 772    unknown  20   jun      496        3    -1        0  unknown 0        0
## 773   cellular  25   aug      454        4    -1        0  unknown 0        0
## 774   cellular  24   apr      155        9    -1        0  unknown 0        0
## 775   cellular  14   may      183        3    -1        0  unknown 0        0
## 776    unknown  15   may      318        1    -1        0  unknown 0        0
## 777   cellular  13   may      316        1    -1        0  unknown 0        0
## 778  telephone  17   apr      246        1   317        1  failure 0        0
## 779    unknown   3   jul       90        1    -1        0  unknown 0        0
## 780   cellular  31   jul       28        2    -1        0  unknown 0        0
## 781   cellular   7   jul      185        1    -1        0  unknown 0        1
## 782   cellular   8   aug      885        5    -1        0  unknown 0        0
## 783    unknown   7   may      435        2    -1        0  unknown 0        0
## 784   cellular  21   nov      140        1    -1        0  unknown 0        0
## 785   cellular  27   mar      271        2    -1        0  unknown 1        1
## 786   cellular   7   sep      120        3    -1        0  unknown 0        0
## 787    unknown  30   may       80        2    -1        0  unknown 0        0
## 788   cellular   4   feb      331        1    -1        0  unknown 0        0
## 789    unknown  28   may      171        6    -1        0  unknown 0        0
## 790    unknown   4   jun      276        1    -1        0  unknown 0        0
## 791    unknown   2   jun      162        3    -1        0  unknown 0        1
## 792    unknown   9   may       70        1    -1        0  unknown 0        0
## 793   cellular   3   jun      592        4    -1        0  unknown 1        1
## 794   cellular  20   may      165        1    56        3  failure 0        0
## 795    unknown   5   jun      179        1    -1        0  unknown 0        0
## 796   cellular   6   aug      232        2    -1        0  unknown 0        0
## 797    unknown  23   may       78        1    -1        0  unknown 0        0
## 798   cellular  29   aug      114        3    -1        0  unknown 0        0
## 799   cellular  12   may      136        2    -1        0  unknown 0        0
## 800   cellular  17   jul     1390        2    -1        0  unknown 0        0
## 801    unknown   8   may      152        1    -1        0  unknown 0        0
## 802   cellular  13   aug       74        2    -1        0  unknown 0        1
## 803   cellular   8   jul      119        2    -1        0  unknown 0        0
## 804   cellular   5   may      286        1   252        3  failure 0        0
## 805   cellular  13   nov      226        1    94        4  success 1        0
## 806   cellular   6   aug       54        3    -1        0  unknown 0        0
## 807   cellular  12   feb      122        1    92        5  success 1        0
## 808   cellular   2   feb      105        1    -1        0  unknown 0        0
## 809   cellular  29   jan      414        2   192        3  failure 0        0
## 810    unknown  14   may      126        3    -1        0  unknown 0        0
## 811   cellular  24   jul       91        1    -1        0  unknown 0        0
## 812   cellular  29   jan       41        1   184        7  failure 0        0
## 813    unknown  19   may      943        2    -1        0  unknown 1        0
## 814   cellular   6   apr      332        2   335        1  failure 0        0
## 815    unknown   6   may      501        4    -1        0  unknown 0        0
## 816   cellular  30   jul      486        2    -1        0  unknown 0        0
## 817    unknown  12   jun       69        3    -1        0  unknown 0        0
## 818   cellular  31   jul      228        2    -1        0  unknown 0        0
## 819   cellular   4   nov      199        1   275        3  success 0        0
## 820   cellular   1   jun      141        1    -1        0  unknown 0        0
## 821   cellular  15   may      117        1    -1        0  unknown 0        0
## 822   cellular   6   aug      302        4    -1        0  unknown 0        0
## 823   cellular  18   nov       83        1   102        2  failure 0        0
## 824    unknown  27   may       57        5    -1        0  unknown 0        0
## 825   cellular  18   jul      185        2    -1        0  unknown 0        0
## 826    unknown  21   may      233        3    -1        0  unknown 0        0
## 827    unknown  29   may      110        3    -1        0  unknown 0        0
## 828    unknown   6   may      174        2    -1        0  unknown 0        0
## 829    unknown   5   may      248        2    -1        0  unknown 0        0
## 830   cellular  31   jul       38       18    -1        0  unknown 0        0
## 831    unknown  30   may      306        1    -1        0  unknown 0        0
## 832   cellular  27   jan      185        2    92        3  success 0        0
## 833   cellular  19   nov      161        2    -1        0  unknown 0        0
## 834    unknown   7   may      432        1    -1        0  unknown 0        0
## 835    unknown  24   jun      790        3    -1        0  unknown 0        0
## 836   cellular  13   may       86        3    -1        0  unknown 0        0
## 837    unknown  18   jun      130        6    -1        0  unknown 0        0
## 838    unknown   6   jun      330        1    -1        0  unknown 0        0
## 839    unknown   5   jun       56        1    -1        0  unknown 0        0
## 840   cellular   5   feb       11        6   231        9  failure 0        0
## 841   cellular  13   may      240        3   370        1  failure 0        0
## 842   cellular  13   may      277        2   343        2  failure 0        0
## 843   cellular  26   aug       59        6    -1        0  unknown 0        0
## 844   cellular  18   may       82        4    -1        0  unknown 0        0
## 845   cellular   4   may      742        4    -1        0  unknown 1        0
## 846   cellular  18   may      305        2    -1        0  unknown 0        1
## 847   cellular  17   nov      318        1    -1        0  unknown 0        0
## 848  telephone  29   aug       81        2    -1        0  unknown 0        0
## 849    unknown  26   may      748        3    -1        0  unknown 1        0
## 850   cellular  11   may      308        1    -1        0  unknown 0        0
## 851   cellular  21   nov      331        2    -1        0  unknown 1        0
## 852   cellular  30   jan      491        1    -1        0  unknown 0        0
## 853   cellular  16   apr      144        2    -1        0  unknown 0        0
## 854   cellular  15   jul      415        2   342        1    other 1        0
## 855   cellular  11   may      930        1    -1        0  unknown 1        0
## 856   cellular   8   may      120        2    -1        0  unknown 0        0
## 857   cellular  26   may      133        1    97        1  success 1        1
## 858   cellular  25   aug       83        5    -1        0  unknown 0        0
## 859   cellular  12   mar      102        2   184        2  failure 0        0
## 860   cellular  29   jan      207        2    -1        0  unknown 0        0
## 861    unknown  15   may      285        1    -1        0  unknown 0        0
## 862   cellular  20   aug       95        2    -1        0  unknown 0        0
## 863  telephone   6   feb      124        2     9        2    other 0        0
## 864   cellular   3   jun      447        2    96        1  success 1        0
## 865    unknown   5   jun      256        2    -1        0  unknown 0        0
## 866   cellular   8   aug      188        5    -1        0  unknown 0        0
## 867   cellular   2   jun      479        1    -1        0  unknown 1        1
## 868    unknown  20   jun      136        3    -1        0  unknown 0        0
## 869   cellular   9   jul     1121        1    -1        0  unknown 1        0
## 870   cellular   2   feb       73        1   252        1  failure 0        0
## 871    unknown  16   may      144        4    -1        0  unknown 0        0
## 872    unknown   3   jun      211        5    -1        0  unknown 0        0
## 873   cellular  17   nov       51        1    -1        0  unknown 0        0
## 874   cellular   2   feb      167        1   263        3    other 0        0
## 875   cellular  29   jul       51        2    -1        0  unknown 0        0
## 876   cellular   4   may      326        3   357       15    other 0        0
## 877   cellular   6   may      101        1   362        5    other 0        0
## 878   cellular   1   jul      174        1   199        3  failure 0        1
## 879   cellular  22   apr      292        4   247        1    other 0        0
## 880   cellular   2   feb      171        2   193        2    other 0        0
## 881   cellular  22   jul      312        1    -1        0  unknown 0        0
## 882   cellular  21   nov       58        1   127        1  failure 0        0
## 883    unknown  16   jun       35        6    -1        0  unknown 0        0
## 884   cellular  13   jul      256        2   181        3  success 0        0
## 885   cellular  18   aug       66        4    -1        0  unknown 0        0
## 886   cellular   9   jun      192        1    93        7    other 1        0
## 887   cellular  31   jul      255        2    -1        0  unknown 0        0
## 888   cellular  24   jun      136        5    94       30  failure 0        1
## 889    unknown   2   jun      351        6    -1        0  unknown 0        0
## 890   cellular  14   jul      123        3    -1        0  unknown 0        0
## 891   cellular  22   aug      121        2    -1        0  unknown 0        0
## 892   cellular  13   may      161        2    -1        0  unknown 0        0
## 893   cellular  15   may      229        2   294        1    other 0        0
## 894    unknown   7   may      396        4    -1        0  unknown 0        0
## 895   cellular  12   may       88        2    -1        0  unknown 0        0
## 896    unknown   7   may      223        2    -1        0  unknown 0        0
## 897   cellular  18   may       13        3    -1        0  unknown 0        1
## 898    unknown  15   may      244        2    -1        0  unknown 0        1
## 899   cellular   6   may      274        1    -1        0  unknown 0        0
## 900   cellular   7   aug      144       18    -1        0  unknown 0        0
## 901    unknown  19   may      125        5    -1        0  unknown 0        0
## 902    unknown  29   may      347        2    -1        0  unknown 0        0
## 903    unknown   5   jun      869        2    -1        0  unknown 0        0
## 904    unknown  20   jun      174        3    -1        0  unknown 0        0
## 905   cellular  29   jul      276        8    97       12    other 1        1
## 906   cellular  30   jan      339        2    -1        0  unknown 0        0
## 907   cellular   5   jun       96        2    -1        0  unknown 0        1
## 908   cellular   7   jul       61        6    -1        0  unknown 0        0
## 909   cellular  31   jul      632       18    -1        0  unknown 0        1
## 910    unknown  16   jun      109        2    -1        0  unknown 0        0
## 911   cellular   3   feb      280        2    -1        0  unknown 0        0
## 912   cellular  29   aug      339        2    -1        0  unknown 0        0
## 913   cellular  25   aug      211        7    -1        0  unknown 0        0
## 914  telephone  15   apr      165        2   327        3  failure 1        0
## 915    unknown  11   jun      354       17    -1        0  unknown 0        0
## 916   cellular  20   apr      122        4   238       12    other 0        0
## 917   cellular  17   nov      110        1    -1        0  unknown 0        0
## 918    unknown  15   may      918        1    -1        0  unknown 0        1
## 919   cellular  27   may      145        1    -1        0  unknown 1        0
## 920   cellular  20   nov      319        1   105        2    other 0        0
## 921   cellular   9   feb       61        1    -1        0  unknown 0        1
## 922   cellular  13   aug      633        1   182        2    other 1        0
## 923   cellular  22   jul      345        5    -1        0  unknown 0        0
## 924   cellular  16   apr      114        2   304        2  failure 0        0
## 925    unknown   5   may      119        1    -1        0  unknown 0        0
## 926    unknown   7   may     1062        1    -1        0  unknown 0        0
## 927   cellular   6   may      687        2   343        1  failure 1        0
## 928   cellular  13   aug      103        1   105        2  success 0        1
## 929    unknown  16   jun      335        3    -1        0  unknown 0        0
## 930   cellular  11   oct      185        2    -1        0  unknown 0        0
## 931   cellular  17   apr      341        1    -1        0  unknown 0        0
## 932   cellular  10   nov      254        5    -1        0  unknown 1        0
## 933    unknown   2   jun      180        1    -1        0  unknown 0        0
## 934   cellular   9   apr      337        2    -1        0  unknown 0        0
## 935   cellular  17   nov       99        1   151        2  failure 0        0
## 936   cellular  10   jul      323        1    -1        0  unknown 0        0
## 937   cellular  23   jul      222        1    -1        0  unknown 0        0
## 938   cellular  18   nov      105        1   179        2  failure 0        0
## 939   cellular  22   aug      117        4    -1        0  unknown 0        0
## 940   cellular  20   apr      207        1   308        2  failure 0        0
## 941   cellular  12   oct      323        1    -1        0  unknown 1        1
## 942  telephone  22   jul      275        4    -1        0  unknown 0        0
## 943   cellular  15   apr      309        2    -1        0  unknown 0        1
## 944    unknown   6   may      225        1    -1        0  unknown 0        0
## 945   cellular   6   jul      316        4    -1        0  unknown 1        1
## 946    unknown  20   may      473        2    -1        0  unknown 0        0
## 947    unknown  16   may      393        2    -1        0  unknown 0        0
## 948   cellular  30   jul      227        8    -1        0  unknown 0        0
## 949   cellular  12   may      609        1    -1        0  unknown 1        0
## 950    unknown   8   may      189        1    -1        0  unknown 0        0
## 951   cellular  26   may      323        1    -1        0  unknown 0        0
## 952   cellular  20   nov      113        1    -1        0  unknown 0        0
## 953   cellular   2   feb      432        1    -1        0  unknown 0        0
## 954   cellular   7   apr       43        3    -1        0  unknown 0        0
## 955    unknown  28   may      489        1    -1        0  unknown 0        1
## 956   cellular  18   jul      362        2    -1        0  unknown 0        1
## 957   cellular   8   apr      101        1    -1        0  unknown 0        0
## 958   cellular  20   nov      179        1    -1        0  unknown 0        0
## 959   cellular  14   may        8        4   300        5  failure 0        0
## 960   cellular   2   feb      389        1    -1        0  unknown 0        0
## 961   cellular   9   jul       64        1    -1        0  unknown 0        0
## 962   cellular   4   may      223        9     4        1  success 0        0
## 963   cellular   3   feb      151        1    -1        0  unknown 0        0
## 964   cellular  25   may      354        1    -1        0  unknown 0        0
## 965   cellular   5   feb      253        1    -1        0  unknown 0        0
## 966    unknown   4   nov       15        1    -1        0  unknown 0        1
## 967    unknown  20   jun      459        3    -1        0  unknown 0        0
## 968    unknown   5   jun      193        2    -1        0  unknown 0        0
## 969   cellular  31   jul      345        1    -1        0  unknown 0        0
## 970  telephone  29   jan      389        3    -1        0  unknown 0        1
## 971   cellular  29   jan      305        2   261        2  failure 0        0
## 972   cellular   2   apr       96        3   330        1    other 0        0
## 973  telephone  21   jul      465        6    -1        0  unknown 0        0
## 974   cellular   3   feb       39        1    -1        0  unknown 0        0
## 975   cellular  17   apr      368        1   336        2  failure 0        0
## 976   cellular   7   jul      112        1    -1        0  unknown 0        0
## 977  telephone  20   apr       26        4   150        5  failure 0        0
## 978   cellular  11   jul      163        2    -1        0  unknown 0        0
## 979   cellular   8   may      132        1    -1        0  unknown 0        1
## 980   cellular  28   jan       67        1    -1        0  unknown 0        0
## 981    unknown   7   may      634        2    -1        0  unknown 0        0
## 982   cellular  17   apr      174        2    -1        0  unknown 0        0
## 983   cellular  14   may      157        4   367        1  failure 0        0
## 984  telephone  13   may      421        3    -1        0  unknown 0        1
## 985   cellular  12   may      104        3   371        2  failure 0        0
## 986    unknown   4   jun      355        1    -1        0  unknown 0        0
## 987   cellular  19   nov      401        1    -1        0  unknown 0        0
## 988    unknown   9   jun      772        1    -1        0  unknown 0        0
## 989    unknown  28   may      268        1    -1        0  unknown 0        0
## 990   cellular  30   apr      532        1    -1        0  unknown 1        0
## 991   cellular  22   aug      256        2    -1        0  unknown 0        0
## 992   cellular  16   jul      605        6    -1        0  unknown 0        0
## 993   cellular   7   aug       92        2    -1        0  unknown 0        0
## 994    unknown  12   jun      298        3    -1        0  unknown 0        0
## 995   cellular  21   nov      614        1    -1        0  unknown 1        0
## 996   cellular  17   nov      113        1    -1        0  unknown 0        0
## 997   cellular  15   may       45        1    -1        0  unknown 0        0
## 998   cellular  29   jan      259        1   259        9  failure 0        0
## 999   cellular  15   may       10        5    -1        0  unknown 0        0
## 1000   unknown   9   may      218        1    -1        0  unknown 0        0
## 1001   unknown   8   may        6        2    -1        0  unknown 0        0
## 1002  cellular  18   nov      543        1    -1        0  unknown 1        0
## 1003  cellular  11   feb      105        7   188        2  failure 0        0
## 1004  cellular  19   nov      369        1   191        1  failure 0        0
## 1005   unknown   2   jul      220        2    -1        0  unknown 0        0
## 1006  cellular  16   apr      297        1    -1        0  unknown 0        0
## 1007 telephone  29   jul      103        3    -1        0  unknown 0        0
## 1008   unknown   2   jun       63        1    -1        0  unknown 0        0
## 1009   unknown  26   jun      677        3    -1        0  unknown 1        0
## 1010   unknown  15   may      133        2    -1        0  unknown 0        0
## 1011 telephone  19   nov      433        1   113        1  failure 0        0
## 1012  cellular  21   may       91        3   361        1  failure 0        0
## 1013  cellular  17   nov      501        1    -1        0  unknown 0        0
## 1014  cellular  29   aug      153        2    -1        0  unknown 0        0
## 1015  cellular  16   jul      771        1    -1        0  unknown 0        0
## 1016   unknown  29   may      233        1    -1        0  unknown 0        0
## 1017   unknown  17   jun      979        9    -1        0  unknown 0        0
## 1018  cellular  14   may      201        1   345        1    other 0        0
## 1019   unknown  14   may      188        1    -1        0  unknown 0        0
## 1020  cellular   7   aug      398        2    -1        0  unknown 0        0
## 1021 telephone  12   apr      271        1   187        1  failure 0        0
## 1022  cellular   4   aug      112        1    -1        0  unknown 0        0
## 1023  cellular   5   feb      450        3    -1        0  unknown 0        0
## 1024  cellular  15   may      165        3    -1        0  unknown 0        0
## 1025  cellular  12   aug      152        2    -1        0  unknown 0        0
## 1026  cellular  14   may      959        3   174        7    other 1        0
## 1027  cellular  10   jul      262        1    -1        0  unknown 0        0
## 1028  cellular   7   may      161        2    -1        0  unknown 0        0
## 1029   unknown  23   may      253        2    -1        0  unknown 0        0
## 1030   unknown  27   may      204        3    -1        0  unknown 0        0
## 1031   unknown   8   may      242        1    -1        0  unknown 0        0
## 1032  cellular  11   may      102        2    -1        0  unknown 0        0
## 1033  cellular  14   may       60        5   371        2  failure 0        0
## 1034   unknown  16   jun      263        8    -1        0  unknown 0        0
## 1035  cellular  19   nov      169        1    -1        0  unknown 0        0
## 1036 telephone   2   nov      214        3    -1        0  unknown 0        0
## 1037  cellular  30   jan       81        1    -1        0  unknown 0        1
## 1038  cellular  31   jul      110        3    -1        0  unknown 0        0
## 1039  cellular   6   aug      384        6    -1        0  unknown 0        0
## 1040  cellular   6   aug      188        4    -1        0  unknown 0        0
## 1041   unknown  21   may      282        2    -1        0  unknown 0        0
## 1042  cellular   4   may      601        3    -1        0  unknown 1        0
## 1043   unknown  20   may     1287        2    -1        0  unknown 0        0
## 1044   unknown  30   may       33        5    -1        0  unknown 0        0
## 1045  cellular  16   jul      455        1    -1        0  unknown 1        0
## 1046  cellular  16   apr      241        2   317        1  failure 0        0
## 1047  cellular  15   apr      158        2   329        1  failure 0        0
## 1048   unknown  14   may       75        1    -1        0  unknown 0        0
## 1049  cellular  29   jul       86        3    -1        0  unknown 0        0
## 1050  cellular  28   jan      121        1   190        2  failure 0        0
## 1051 telephone  10   jul      185        1    -1        0  unknown 0        0
## 1052  cellular   6   may       90        1    -1        0  unknown 0        0
## 1053 telephone  14   apr       61        3    -1        0  unknown 0        0
## 1054 telephone   9   feb       48        7    -1        0  unknown 0        0
## 1055  cellular   7   jul      206        6    -1        0  unknown 0        0
## 1056  cellular  15   may      670        4   346        1  failure 1        0
## 1057  cellular   7   may      249        4   332        3  failure 0        0
## 1058  cellular   6   may      236        1    -1        0  unknown 0        0
## 1059  cellular  17   apr      358        2    -1        0  unknown 0        0
## 1060  cellular  18   nov      154        3   189        1  failure 0        0
## 1061   unknown  29   may      125        2    -1        0  unknown 0        0
## 1062  cellular   7   aug      117        2    -1        0  unknown 0        0
## 1063  cellular  18   jul      337        1    -1        0  unknown 0        1
## 1064  cellular  18   may      380        2   355        1  failure 0        0
## 1065   unknown  19   jun      130        1    -1        0  unknown 0        0
## 1066  cellular  21   jul      354        1    -1        0  unknown 0        0
## 1067  cellular  19   aug       42        1    -1        0  unknown 0        0
## 1068   unknown  29   may     1207        1    -1        0  unknown 1        0
## 1069  cellular  11   may      240        2   343        5  failure 0        0
## 1070  cellular  18   nov      295        2    -1        0  unknown 0        0
## 1071   unknown  19   jun      416        3    -1        0  unknown 0        0
## 1072  cellular  18   may      229        2   355        1  failure 0        0
## 1073   unknown   5   may      208        1    -1        0  unknown 0        0
## 1074  cellular   3   nov      193        1    -1        0  unknown 0        0
## 1075   unknown  21   may      158        2    -1        0  unknown 0        0
## 1076  cellular   8   jul       70        2    -1        0  unknown 0        1
## 1077  cellular  22   jul      145        4    -1        0  unknown 0        0
## 1078   unknown  15   may      309        2    -1        0  unknown 0        0
## 1079   unknown  20   may      249        3    -1        0  unknown 0        0
## 1080  cellular  29   jan      626        1    -1        0  unknown 0        0
## 1081  cellular  12   feb      138        2   184        3  success 1        0
## 1082  cellular  17   jul      602        1    -1        0  unknown 0        1
## 1083  cellular  11   may      212        1    -1        0  unknown 0        0
## 1084  cellular   5   feb      103        1   248        1  failure 0        0
## 1085   unknown  29   may      217        5    -1        0  unknown 0        0
## 1086  cellular  20   nov      179        1   197        1  failure 0        0
## 1087  cellular  21   nov      615        3    34        1  failure 1        0
## 1088   unknown   2   jun      230        3    -1        0  unknown 0        0
## 1089 telephone  19   nov      111        2   156        1  failure 0        0
## 1090  cellular  12   may       16        5    -1        0  unknown 0        0
## 1091  cellular  30   mar      171        4    -1        0  unknown 0        1
## 1092  cellular   3   feb      185        1    92        1  success 1        0
## 1093  cellular  18   nov      162        1   175        2  failure 0        0
## 1094  cellular   9   jul       98        1    -1        0  unknown 0        0
## 1095  cellular   5   may      223        1    -1        0  unknown 0        0
## 1096   unknown   5   may      677        1    -1        0  unknown 0        0
## 1097  cellular  22   aug      109        2    -1        0  unknown 0        0
## 1098   unknown   5   may      267        2    -1        0  unknown 0        0
## 1099  cellular  12   nov      123        1   196        1  success 1        1
## 1100 telephone   9   jun      712        1    64       12  failure 1        0
## 1101  cellular   6   mar      229        1    -1        0  unknown 1        0
## 1102  cellular  12   may      267        1    -1        0  unknown 0        0
## 1103   unknown  14   may       86        2    -1        0  unknown 0        0
## 1104  cellular   5   may       98        4    -1        0  unknown 0        0
## 1105   unknown  14   may      287        3    -1        0  unknown 0        0
## 1106 telephone  21   jul      132       10    -1        0  unknown 0        0
## 1107   unknown  11   jun      647        2    -1        0  unknown 0        0
## 1108  cellular  21   nov       49        1    -1        0  unknown 0        0
## 1109  cellular   4   feb      406        2    -1        0  unknown 0        0
## 1110 telephone  14   oct      290        2    -1        0  unknown 1        0
## 1111 telephone  19   aug      223        7    -1        0  unknown 0        0
## 1112  cellular   9   jul       70        1    -1        0  unknown 0        0
## 1113   unknown  15   may      311        5    -1        0  unknown 0        1
## 1114   unknown  16   jun       57        8    -1        0  unknown 0        0
## 1115  cellular  20   nov        7        5    -1        0  unknown 0        0
## 1116   unknown   3   jun      207        1    -1        0  unknown 0        0
## 1117  cellular  22   jul       93        2    -1        0  unknown 0        0
## 1118   unknown  16   may      806        4    -1        0  unknown 0        0
## 1119  cellular  16   jul      214        1    -1        0  unknown 0        0
## 1120   unknown  28   may      135        1    -1        0  unknown 0        1
## 1121 telephone  28   jan      119        1    -1        0  unknown 0        0
## 1122  cellular  30   apr      387        3    87        1  success 1        0
## 1123 telephone  21   jul      733        3    -1        0  unknown 1        0
## 1124  cellular  18   aug       91        4    -1        0  unknown 0        0
## 1125  cellular   8   aug      138        2    -1        0  unknown 0        0
## 1126   unknown  18   jun      392        1    -1        0  unknown 0        0
## 1127  cellular  18   aug      773        4    -1        0  unknown 1        0
## 1128 telephone  28   jul       75        3    -1        0  unknown 0        0
## 1129   unknown  12   jun       92        2    -1        0  unknown 0        0
## 1130  cellular  29   jan       84        3   183        3  failure 0        0
## 1131  cellular   9   feb        8        7   248        9  success 0        0
## 1132  cellular   8   jul      225        1    -1        0  unknown 0        0
## 1133  cellular  28   jan      399        1    -1        0  unknown 0        0
## 1134   unknown   3   jun      288        2    -1        0  unknown 0        0
## 1135  cellular   9   jul      366        1    -1        0  unknown 0        0
## 1136  cellular  14   jul      131        4    -1        0  unknown 0        0
## 1137  cellular   9   jul      157        1    -1        0  unknown 0        0
## 1138  cellular  19   nov      141        2    -1        0  unknown 0        0
## 1139   unknown  20   jun      122        1    -1        0  unknown 0        0
## 1140  cellular   9   apr      592        4   316        3  failure 1        0
## 1141   unknown   4   jun      132        1    -1        0  unknown 0        1
## 1142  cellular   6   may      155        1    -1        0  unknown 0        0
## 1143   unknown  12   may      165        4    -1        0  unknown 0        0
## 1144   unknown  27   may      147        1    -1        0  unknown 0        0
## 1145  cellular  22   apr       91        2   275        1  failure 0        0
## 1146   unknown   5   jun      112        2    -1        0  unknown 0        0
## 1147  cellular  17   apr      598        1   150        1  failure 0        0
## 1148  cellular  18   jul      178        3    -1        0  unknown 0        0
## 1149  cellular   8   jul      230        2    -1        0  unknown 0        0
## 1150  cellular  24   jul      125        2    -1        0  unknown 0        0
## 1151   unknown  26   may      109        2    -1        0  unknown 0        1
## 1152  cellular  29   jul      122        7    -1        0  unknown 0        0
## 1153   unknown  20   may      128        6    -1        0  unknown 0        0
## 1154  cellular  18   jul       83        2    -1        0  unknown 0        0
## 1155  cellular  18   nov      173        1    -1        0  unknown 0        0
## 1156  cellular  17   nov       58        1   188        1  failure 0        0
## 1157  cellular  20   apr       20        2   335       12  failure 0        0
## 1158  cellular  26   aug      135       22    -1        0  unknown 0        0
## 1159   unknown  12   jun      144        1    -1        0  unknown 0        0
## 1160   unknown  12   may      225        1    -1        0  unknown 0        0
## 1161  cellular  19   aug      256        2    -1        0  unknown 0        0
## 1162  cellular   6   may       28        2   345        3    other 0        0
## 1163  cellular  28   jul      124        3    -1        0  unknown 0        0
## 1164  cellular  31   jul      727        4    -1        0  unknown 1        0
## 1165  cellular  23   jul      122        3    -1        0  unknown 0        0
## 1166   unknown   9   may      237        1    -1        0  unknown 0        0
## 1167 telephone   9   jul       60        1    -1        0  unknown 0        0
## 1168  cellular  10   jul      183        1    -1        0  unknown 0        0
## 1169   unknown  19   jun       77        1    -1        0  unknown 0        0
## 1170  cellular   3   apr     1090        1    -1        0  unknown 0        0
## 1171  cellular  17   nov      282        1    -1        0  unknown 0        0
## 1172  cellular  13   may      199        1   173        2  failure 0        0
## 1173  cellular  11   jul      593        2    -1        0  unknown 0        0
## 1174  cellular  31   jul      126       23    -1        0  unknown 0        0
## 1175  cellular  20   aug      251        3    -1        0  unknown 0        0
## 1176 telephone  14   jul      123        4    -1        0  unknown 0        0
## 1177 telephone  24   feb       98        2    -1        0  unknown 0        0
## 1178   unknown   3   jun      497        2    -1        0  unknown 0        0
## 1179  cellular   7   jul      830        5    -1        0  unknown 1        0
## 1180   unknown   9   may      485        1    -1        0  unknown 0        0
## 1181  cellular   6   aug      637        2    -1        0  unknown 1        0
## 1182  cellular  16   feb      170        2    -1        0  unknown 1        0
## 1183  cellular  26   jan      122        4    50        4    other 0        0
## 1184   unknown  11   jun      561        1    -1        0  unknown 0        0
## 1185   unknown  19   may      114        2    -1        0  unknown 0        0
## 1186   unknown  20   jun       34       29    -1        0  unknown 0        0
## 1187  cellular  20   aug       15       19    -1        0  unknown 0        0
## 1188  cellular  10   jul      154       14    -1        0  unknown 0        0
## 1189  cellular  30   jul       98       13    -1        0  unknown 0        0
## 1190  cellular  31   jul      212        4    -1        0  unknown 0        0
## 1191   unknown  21   may      692        1    -1        0  unknown 0        0
## 1192  cellular   2   jul      301        2    88        5  failure 0        0
## 1193  cellular   7   may      412        2    -1        0  unknown 0        0
## 1194  cellular  11   may      877        7   300        2    other 1        0
## 1195  cellular  18   mar      236        2    -1        0  unknown 0        1
## 1196  cellular  22   may      354        1    -1        0  unknown 1        0
## 1197  cellular  29   jan       79        2   265        2  failure 0        0
## 1198  cellular   3   apr      329        2    -1        0  unknown 0        0
## 1199  cellular  17   jul      245        1    -1        0  unknown 0        0
## 1200  cellular  15   may      504        2    -1        0  unknown 0        1
## 1201  cellular  15   may      437        3   347        3    other 1        1
## 1202  cellular   5   apr      144        1    -1        0  unknown 1        0
## 1203  cellular  18   jul      264        2    -1        0  unknown 0        0
## 1204   unknown  30   may      178        2    -1        0  unknown 0        0
## 1205   unknown   7   may      173        1    -1        0  unknown 0        0
## 1206 telephone  30   jan      258        5   248        2  failure 0        0
## 1207  cellular  12   feb      666        4    -1        0  unknown 1        0
## 1208  cellular  16   dec      283        2   196        1  success 1        0
## 1209  cellular   3   feb      372        1    -1        0  unknown 1        0
## 1210  cellular  17   apr       46        4    -1        0  unknown 0        0
## 1211   unknown  23   may       77        3    -1        0  unknown 0        0
## 1212  cellular  29   jan     1424        1    -1        0  unknown 0        0
## 1213  cellular  23   jul      152        1    -1        0  unknown 0        0
## 1214  cellular   9   jul      427        1    -1        0  unknown 0        0
## 1215  cellular  17   apr      171        2    -1        0  unknown 0        1
## 1216  cellular   1   apr     1196        1    -1        0  unknown 1        0
## 1217   unknown  20   may      211        1    -1        0  unknown 0        0
## 1218  cellular   8   may      154        3   367        2  failure 0        0
## 1219  cellular   7   may      198        2    -1        0  unknown 0        0
## 1220   unknown  16   may      225        1    -1        0  unknown 0        1
## 1221   unknown  28   may      145        2    -1        0  unknown 0        0
## 1222  cellular   6   may      165        2    -1        0  unknown 0        0
## 1223  cellular  18   nov      596        1   182        1    other 1        0
## 1224  cellular  18   aug      150        2    -1        0  unknown 0        0
## 1225   unknown  27   jun      110        1    -1        0  unknown 0        0
## 1226  cellular  17   apr      146        1   281        1  failure 0        0
## 1227  cellular  20   apr      271        1   300        2  success 0        1
## 1228  cellular  19   nov      289        1    -1        0  unknown 0        0
## 1229  cellular   2   feb      142        2    -1        0  unknown 0        0
## 1230  cellular  21   nov      103        1   141        2  failure 0        0
## 1231   unknown  16   may      186        5    -1        0  unknown 0        0
## 1232  cellular  28   jan     1121        2   205        3  failure 0        0
## 1233  cellular  21   aug      121        1    -1        0  unknown 0        0
## 1234   unknown   6   may      325        1    -1        0  unknown 0        0
## 1235  cellular  12   aug      331        2    -1        0  unknown 0        0
## 1236   unknown  20   jun      115        4    -1        0  unknown 0        0
## 1237   unknown  13   may      144        1    -1        0  unknown 0        0
## 1238  cellular  20   aug      203        4    -1        0  unknown 0        0
## 1239   unknown   9   jun      213        1    -1        0  unknown 0        0
## 1240  cellular  18   nov       61        2   131        1  failure 0        0
## 1241  cellular  17   apr      707        1   149        2  failure 0        0
## 1242   unknown  30   may       41        8    -1        0  unknown 0        0
## 1243  cellular  18   jul       67       11    -1        0  unknown 0        0
## 1244   unknown  26   may      180        2    -1        0  unknown 0        0
## 1245   unknown   9   may      103        2    -1        0  unknown 0        0
## 1246  cellular  11   sep      260        3    95        3  success 1        0
## 1247  cellular   5   aug      335        3    -1        0  unknown 0        0
## 1248 telephone  17   apr      460        2   345        2  failure 0        0
## 1249  cellular  20   aug      291        1    -1        0  unknown 0        0
## 1250  cellular  29   jan      126        1    -1        0  unknown 0        0
## 1251  cellular  18   aug      360        1    -1        0  unknown 0        0
## 1252  cellular  30   apr      370        3    -1        0  unknown 1        0
## 1253  cellular   8   aug      351        2    -1        0  unknown 0        0
## 1254   unknown  14   jul       70        1    -1        0  unknown 0        0
## 1255  cellular  30   mar      180        2    -1        0  unknown 1        1
## 1256  cellular  30   mar       96        6    -1        0  unknown 0        0
## 1257   unknown   5   may      611        2    -1        0  unknown 0        0
## 1258  cellular  29   aug       19       16    -1        0  unknown 0        0
## 1259  cellular   2   jun      482        2    -1        0  unknown 1        0
## 1260   unknown   7   may      295        2    -1        0  unknown 0        0
## 1261  cellular  11   jul      124        1    -1        0  unknown 0        1
## 1262   unknown  26   may       70        3    -1        0  unknown 0        0
## 1263  cellular  30   apr      571        1    -1        0  unknown 1        0
## 1264  cellular  14   may      143        2   370        2  failure 0        0
## 1265   unknown  23   may       66        1    -1        0  unknown 0        1
## 1266  cellular  21   nov       89        2    -1        0  unknown 0        0
## 1267  cellular  16   apr     1007        3   325        4  failure 0        0
## 1268  cellular   4   aug      173        1    92        5  success 1        0
## 1269  cellular   7   jul     2201        1    -1        0  unknown 0        0
## 1270  cellular  22   jul      285        1    -1        0  unknown 0        0
## 1271  cellular   2   feb      751        2    76        4  failure 1        0
## 1272   unknown  29   may      543        1    -1        0  unknown 1        0
## 1273  cellular  18   aug      147        1   379        1  failure 0        0
## 1274  cellular  17   apr      346        2    -1        0  unknown 0        0
## 1275 telephone  17   nov      661        4    -1        0  unknown 0        0
## 1276  cellular   8   jul      268        2    -1        0  unknown 0        0
## 1277  cellular  31   jul       61        4    -1        0  unknown 0        0
## 1278  cellular  19   nov      258        2    -1        0  unknown 0        0
## 1279   unknown  21   may       45       13    -1        0  unknown 0        0
## 1280  cellular  24   jul       53        1    -1        0  unknown 0        0
## 1281  cellular   4   feb      226        1    -1        0  unknown 0        0
## 1282   unknown  20   jun       42        7    -1        0  unknown 0        0
## 1283  cellular  11   jul      812        1    -1        0  unknown 1        0
## 1284  cellular   8   may      262        3    -1        0  unknown 0        0
## 1285  cellular  22   aug      579        2    -1        0  unknown 1        0
## 1286  cellular  29   jan      801        1    -1        0  unknown 1        0
## 1287   unknown  23   may      493        2    -1        0  unknown 0        0
## 1288  cellular  26   aug      271        4    -1        0  unknown 0        0
## 1289  cellular  22   jul      427        2    94        4  failure 0        0
## 1290  cellular   8   apr      163        3    -1        0  unknown 0        0
## 1291   unknown  15   may      141        1    -1        0  unknown 0        0
## 1292   unknown   8   may      160        1    -1        0  unknown 0        0
## 1293  cellular   4   may       55        2    -1        0  unknown 0        0
## 1294   unknown  19   may       66        9    -1        0  unknown 0        0
## 1295   unknown   8   may      108        3    -1        0  unknown 0        0
## 1296  cellular  16   sep      106        1    -1        0  unknown 0        0
## 1297  cellular  28   aug       68       27    -1        0  unknown 0        0
## 1298   unknown  13   may      210        3    -1        0  unknown 0        1
## 1299  cellular  18   may       20        6    -1        0  unknown 0        1
## 1300  cellular   8   may      104        4   252        3  failure 0        0
## 1301   unknown   6   may      227        1    -1        0  unknown 0        0
## 1302  cellular   7   may      201        1    -1        0  unknown 0        0
## 1303  cellular  26   aug      610        2    -1        0  unknown 0        0
## 1304  cellular  30   apr      381        1   269        1  failure 1        0
## 1305   unknown  29   may      184        1    -1        0  unknown 0        0
## 1306  cellular  11   may      369        1    -1        0  unknown 0        0
## 1307  cellular  27   aug      111        5    -1        0  unknown 0        0
## 1308   unknown  28   may      282        2    -1        0  unknown 0        1
## 1309  cellular   5   aug      603        3    -1        0  unknown 1        0
## 1310   unknown  17   jun       21        1    -1        0  unknown 0        1
## 1311 telephone  18   may       12        5    -1        0  unknown 0        0
## 1312  cellular  25   jul     1106        1    -1        0  unknown 0        0
## 1313  cellular  18   may       98        1   178        1  failure 0        0
## 1314  cellular   5   aug      553        1    -1        0  unknown 1        0
## 1315 telephone   4   may     1076        3   175        1  success 1        0
## 1316  cellular   7   may      369        1    -1        0  unknown 0        0
## 1317   unknown  16   jun      142        2    -1        0  unknown 0        0
## 1318  cellular  17   apr      179        1    -1        0  unknown 0        0
## 1319  cellular  30   jan       54        1    -1        0  unknown 0        0
## 1320   unknown   2   jun      277        2    -1        0  unknown 0        0
## 1321  cellular  19   aug      295        2    -1        0  unknown 0        0
## 1322  cellular  13   may      294        1    -1        0  unknown 0        0
## 1323  cellular   5   may      232        1    89        4    other 1        0
## 1324  cellular  21   nov      127        3    -1        0  unknown 0        0
## 1325  cellular  18   may      185        1    -1        0  unknown 0        0
## 1326   unknown  14   may      203        1    -1        0  unknown 0        0
## 1327  cellular  19   nov      157        1    -1        0  unknown 0        0
## 1328  cellular  30   jan      217        2    -1        0  unknown 0        0
## 1329   unknown   5   jun      409        1    -1        0  unknown 0        0
## 1330  cellular  12   may      328        2    -1        0  unknown 0        0
## 1331  cellular  17   apr      660        3    -1        0  unknown 0        0
## 1332   unknown  12   may      157        5    -1        0  unknown 0        0
## 1333 telephone  29   jan      403        2    -1        0  unknown 1        0
## 1334   unknown   6   may      215        1    -1        0  unknown 0        0
## 1335  cellular  13   may       68        2   363        2  failure 0        1
## 1336  cellular  11   aug       93        1   190        2    other 0        0
## 1337   unknown  25   jun       53        1    -1        0  unknown 0        0
## 1338  cellular  17   jul      199        2    -1        0  unknown 0        0
## 1339 telephone  20   nov      442        4    -1        0  unknown 0        0
## 1340  cellular  13   aug      403        2    -1        0  unknown 0        0
## 1341   unknown  28   may      116       12    -1        0  unknown 0        0
## 1342   unknown  13   may      185        6    -1        0  unknown 0        0
## 1343   unknown   5   jun       22       15    -1        0  unknown 0        0
## 1344   unknown  14   may      452        2    -1        0  unknown 0        0
## 1345  cellular  13   may      323        1    -1        0  unknown 0        0
## 1346   unknown  29   may      752        2    -1        0  unknown 0        0
## 1347  cellular  25   jul      118        3    -1        0  unknown 0        1
## 1348   unknown   6   may       92        2    -1        0  unknown 0        0
## 1349  cellular  29   jan       27        1    -1        0  unknown 0        0
## 1350   unknown  19   jun      169        2    -1        0  unknown 0        0
## 1351   unknown  26   may      470        1    -1        0  unknown 0        0
## 1352  cellular  15   may      193        1    -1        0  unknown 0        0
## 1353 telephone  27   jul      195        2    -1        0  unknown 0        0
## 1354  cellular  17   apr      264        1   317        1  failure 0        0
## 1355  cellular   9   feb      269        9    -1        0  unknown 0        1
## 1356 telephone  12   jan      411        1    -1        0  unknown 1        0
## 1357  cellular  13   aug      526        2    -1        0  unknown 1        0
## 1358  cellular  31   aug       83        1    -1        0  unknown 0        0
## 1359  cellular  14   may       17        8    -1        0  unknown 0        0
## 1360   unknown  12   may      112        2    -1        0  unknown 0        0
## 1361  cellular   3   feb       94        4   271        4  failure 0        0
## 1362   unknown  17   jun      441        3    -1        0  unknown 0        0
## 1363  cellular   3   feb       83        3    -1        0  unknown 0        0
## 1364   unknown  26   may      102       23    -1        0  unknown 0        0
## 1365  cellular   8   aug       62        3    -1        0  unknown 0        0
## 1366 telephone   4   jul      141        2    -1        0  unknown 0        0
## 1367  cellular  30   jul      241        2    -1        0  unknown 0        0
## 1368   unknown  13   may      255        5    -1        0  unknown 0        0
## 1369   unknown  30   jun        6        1    -1        0  unknown 0        0
## 1370   unknown  13   may      226        1    -1        0  unknown 0        0
## 1371  cellular   8   oct      147        1    92        5    other 1        1
## 1372  cellular  28   jul      132        4    -1        0  unknown 0        0
## 1373   unknown  12   may      379        2    -1        0  unknown 0        0
## 1374  cellular  29   aug       73        2    -1        0  unknown 0        0
## 1375  cellular  11   may      177        4   367        1  failure 0        1
## 1376  cellular   8   may      213        5    -1        0  unknown 0        0
## 1377  cellular  18   may      182        1    -1        0  unknown 0        0
## 1378  cellular  20   apr      575        2    -1        0  unknown 0        0
## 1379  cellular  28   jul      258        2    -1        0  unknown 0        0
## 1380  cellular  11   aug      237        1   180        6  success 1        0
## 1381   unknown  26   jul        9        1    -1        0  unknown 0        1
## 1382   unknown  26   may       45        5    -1        0  unknown 0        0
## 1383  cellular  24   jul      633        7    -1        0  unknown 0        0
## 1384   unknown  16   jun      301        6    -1        0  unknown 0        0
## 1385  cellular  11   jul      108        1    -1        0  unknown 0        0
## 1386  cellular  28   jan      192        1    -1        0  unknown 0        0
## 1387  cellular  18   nov      250        2    -1        0  unknown 0        0
## 1388  cellular  14   apr      344        1    74        2  failure 1        0
## 1389  cellular  18   may      221        2   350        4    other 0        0
## 1390   unknown   3   jun       48        2    -1        0  unknown 0        0
## 1391  cellular   7   aug      124        3    -1        0  unknown 0        0
## 1392  cellular   8   may      237        1   368        1    other 0        0
## 1393  cellular   4   feb      108        2   195        6  failure 0        1
## 1394  cellular   5   feb      604        1    -1        0  unknown 0        0
## 1395  cellular  27   aug       34       14    -1        0  unknown 0        0
## 1396  cellular  17   nov     1091        2   150        1  success 1        0
## 1397  cellular  15   may      200        5    -1        0  unknown 0        0
## 1398   unknown  30   may      159        1    -1        0  unknown 0        0
## 1399  cellular  17   apr      193        2   322        1    other 0        0
## 1400 telephone   5   may       36        7   165        5    other 0        0
## 1401   unknown  11   jun       48        3    -1        0  unknown 0        0
## 1402  cellular  12   may      350        5   286        2  failure 0        0
## 1403  cellular  22   aug       77        9    -1        0  unknown 0        0
## 1404  cellular  29   jan       58        1    -1        0  unknown 0        0
## 1405   unknown   9   may      282        2    -1        0  unknown 0        1
## 1406  cellular  18   nov      329        1    -1        0  unknown 0        0
## 1407  cellular  26   feb      281        2   270        2    other 0        1
## 1408  cellular  27   aug       63        6    -1        0  unknown 0        0
## 1409   unknown  20   jun      168        2    -1        0  unknown 0        0
## 1410   unknown  23   may      395        1    -1        0  unknown 0        0
## 1411   unknown   4   jun      193        2    -1        0  unknown 0        0
## 1412  cellular   4   feb       62        1    -1        0  unknown 0        0
## 1413  cellular  21   nov      744        2    -1        0  unknown 0        0
## 1414  cellular  13   aug      104        6    -1        0  unknown 0        0
## 1415  cellular  21   jul      249        3    -1        0  unknown 0        0
## 1416  cellular  18   nov      123        1   124        1  failure 0        0
## 1417  cellular  18   may       44        1   355        3  failure 0        0
## 1418   unknown  18   jun      188        1    -1        0  unknown 0        0
## 1419  cellular   3   sep      104        1   380        3  failure 0        0
## 1420  cellular  15   may      173        4    -1        0  unknown 0        0
## 1421  cellular  17   apr       96        2   344        2  failure 0        0
## 1422  cellular  29   aug      256        2    -1        0  unknown 0        0
## 1423   unknown  13   may      170        1    -1        0  unknown 0        0
## 1424   unknown   9   may      245        4    -1        0  unknown 0        0
## 1425   unknown  23   may      245        1    -1        0  unknown 0        0
## 1426 telephone  15   jul      277        1    -1        0  unknown 0        0
## 1427   unknown   9   may      198        1    -1        0  unknown 0        0
## 1428   unknown  26   may      290        2    -1        0  unknown 0        0
## 1429   unknown   6   may      154        2    -1        0  unknown 0        0
## 1430  cellular  10   jul      149        1    -1        0  unknown 0        0
## 1431  cellular  15   jul      323        2   163        2    other 1        1
## 1432   unknown  12   may       63        5    -1        0  unknown 0        0
## 1433  cellular  14   may      162        2   350        4  failure 0        0
## 1434  cellular   5   aug      231        1    -1        0  unknown 0        0
## 1435  cellular  29   jan      456        1   205        2    other 0        0
## 1436   unknown  27   may      212        2    -1        0  unknown 0        0
## 1437  cellular  20   nov      426        2    -1        0  unknown 0        0
## 1438  cellular  16   apr      444        2    -1        0  unknown 0        0
## 1439  cellular  18   nov      240        3   119        2  failure 0        0
## 1440 telephone   4   sep      770        3    -1        0  unknown 1        0
## 1441   unknown  19   jun       93        2    -1        0  unknown 0        1
## 1442  cellular  20   aug      154        2    -1        0  unknown 0        0
## 1443   unknown   2   jul       60        2    -1        0  unknown 0        0
## 1444  cellular   8   jul      202        2    -1        0  unknown 0        0
## 1445  cellular  13   may      204        1   331        3  success 0        0
## 1446   unknown  18   jun      129        1    -1        0  unknown 0        0
## 1447  cellular  15   apr      149        1   268        2    other 0        0
## 1448  cellular   7   aug      122        5    -1        0  unknown 0        0
## 1449  cellular  16   apr      201        1    -1        0  unknown 0        0
## 1450 telephone  28   jan      309        1    -1        0  unknown 0        0
## 1451  cellular  11   aug      146        1   286        2  failure 1        0
## 1452  cellular   5   feb      217        1    -1        0  unknown 0        0
## 1453  cellular  10   jul      412        1    -1        0  unknown 0        0
## 1454 telephone  25   jul      395        6    -1        0  unknown 0        0
## 1455   unknown   4   jun       71        1    -1        0  unknown 0        0
## 1456  cellular   8   may      105        1    -1        0  unknown 0        0
## 1457   unknown  28   may      189        2    -1        0  unknown 0        0
## 1458  cellular   3   feb      128        2    -1        0  unknown 0        0
## 1459  cellular  31   jul      321        2    -1        0  unknown 0        0
## 1460  cellular  18   nov       36        1    -1        0  unknown 0        0
## 1461  cellular  24   jul       58        2    -1        0  unknown 0        0
## 1462  cellular  25   aug      121        4    -1        0  unknown 0        0
## 1463  cellular  27   jul      287        2   181        1  success 1        0
## 1464   unknown   3   jun      310        4    -1        0  unknown 0        0
## 1465   unknown  20   jun      115        1    -1        0  unknown 0        0
## 1466   unknown   9   may       71        3    -1        0  unknown 0        0
## 1467  cellular   5   aug      328        1    -1        0  unknown 0        0
## 1468   unknown   8   sep        9        1    -1        0  unknown 0        0
## 1469  cellular  20   nov       91        3    -1        0  unknown 0        0
## 1470   unknown  18   jun       61       23    -1        0  unknown 0        0
## 1471  cellular  15   jul      232        3    -1        0  unknown 0        0
## 1472  cellular  28   jan       30        1    -1        0  unknown 0        1
## 1473   unknown  19   jun        9       28    -1        0  unknown 0        0
## 1474  cellular   6   apr      740        3    -1        0  unknown 1        0
## 1475   unknown  13   may      105        1    -1        0  unknown 0        1
## 1476   unknown  28   may     1730        1    -1        0  unknown 1        1
## 1477  cellular  17   apr      462        1    -1        0  unknown 0        0
## 1478   unknown  27   may      106        1    -1        0  unknown 0        0
## 1479  cellular  27   sep      990        4    -1        0  unknown 0        0
## 1480   unknown  23   may      213        4    -1        0  unknown 0        0
## 1481   unknown  12   may      154        1    -1        0  unknown 0        0
## 1482  cellular  28   jan       58        1    -1        0  unknown 0        0
## 1483   unknown  12   jun      157        1    -1        0  unknown 0        0
## 1484  cellular  15   may      166        3    -1        0  unknown 0        0
## 1485   unknown   4   jun       16        8    -1        0  unknown 0        0
## 1486  cellular   5   aug      140        1    -1        0  unknown 0        0
## 1487  cellular   8   apr      280        2    -1        0  unknown 0        0
## 1488   unknown   6   may      314        3    -1        0  unknown 0        0
## 1489   unknown  26   jun      251        3    -1        0  unknown 0        0
## 1490  cellular  30   jan      337        4    -1        0  unknown 0        1
## 1491   unknown  20   jun        9        5    -1        0  unknown 0        0
## 1492  cellular  20   nov      945        2    -1        0  unknown 1        0
## 1493   unknown  13   may      120        1    -1        0  unknown 0        0
## 1494   unknown   6   may      290        1    -1        0  unknown 0        0
## 1495   unknown  29   may      137        1    -1        0  unknown 0        0
## 1496   unknown  18   jun      159        1    -1        0  unknown 0        0
## 1497  cellular  12   may       22        5    -1        0  unknown 0        0
## 1498  cellular  22   aug       88       10    -1        0  unknown 0        0
## 1499 telephone  16   jul      127       11    -1        0  unknown 0        0
## 1500  cellular   5   feb      140        1    -1        0  unknown 0        1
## 1501  cellular   5   may      475        2    -1        0  unknown 0        0
## 1502   unknown  20   may      137        2    -1        0  unknown 0        0
## 1503  cellular   7   aug       70        1    -1        0  unknown 0        0
## 1504  cellular  14   jul      243        3    -1        0  unknown 0        1
## 1505   unknown  19   may      206        1    -1        0  unknown 0        0
## 1506  cellular   6   may      206        1    -1        0  unknown 0        0
## 1507  cellular  30   apr      616        1    -1        0  unknown 1        0
## 1508   unknown  28   may      456        2    -1        0  unknown 0        0
## 1509  cellular   7   aug       74        1    -1        0  unknown 0        0
## 1510 telephone  25   mar      282        2    -1        0  unknown 0        0
## 1511  cellular  25   aug      472        6    -1        0  unknown 1        0
## 1512   unknown  20   may      360        1    -1        0  unknown 0        0
## 1513  cellular   8   may      440        1    -1        0  unknown 0        0
## 1514  cellular  21   jul      236        3    -1        0  unknown 0        1
## 1515  cellular  13   oct      167        1    -1        0  unknown 0        0
## 1516 telephone  12   may      472        2   351        1  failure 0        0
## 1517  cellular  20   apr      396        3   151        4    other 0        0
## 1518  cellular  16   jul      400        1    -1        0  unknown 0        0
## 1519  cellular  21   nov     1032       10   115        3  failure 0        0
## 1520  cellular  19   aug      629        7    -1        0  unknown 0        0
## 1521  cellular  21   jul      167        1    -1        0  unknown 0        0
## 1522  cellular  20   oct       59        1   104        3  failure 0        0
## 1523   unknown   5   jun      346        3    -1        0  unknown 0        0
## 1524  cellular  18   jul       93        1    -1        0  unknown 0        0
## 1525  cellular  20   nov      215        2    -1        0  unknown 0        0
## 1526 telephone  22   jul      158        5    -1        0  unknown 0        0
## 1527  cellular  20   nov      217        3    -1        0  unknown 0        0
## 1528  cellular  23   oct      255        4   185        2  failure 1        0
## 1529  cellular  17   jul      301        1    -1        0  unknown 0        0
## 1530   unknown  12   may      166        4    -1        0  unknown 0        0
## 1531  cellular  18   may      525        1    -1        0  unknown 1        1
## 1532   unknown  23   may      297        1    -1        0  unknown 0        0
## 1533  cellular  18   may      170        1    -1        0  unknown 0        0
## 1534  cellular   5   feb      208        1    -1        0  unknown 0        0
## 1535  cellular  18   nov     1122        4    -1        0  unknown 1        0
## 1536 telephone  28   may       32        2    -1        0  unknown 0        0
## 1537   unknown  21   may     1697        2    -1        0  unknown 1        0
## 1538  cellular   8   aug      173        8    -1        0  unknown 0        0
## 1539  cellular  30   jul      783        3    -1        0  unknown 0        0
## 1540  cellular  14   jul       65        2    -1        0  unknown 0        0
## 1541  cellular  20   nov      156        4    -1        0  unknown 0        0
## 1542   unknown  23   may      203        1    -1        0  unknown 0        0
## 1543  cellular  30   jul      184        6    -1        0  unknown 0        0
## 1544  cellular  19   mar      220        3    -1        0  unknown 1        0
## 1545   unknown   6   may       88        3    -1        0  unknown 0        1
## 1546   unknown  27   may      349        3    -1        0  unknown 0        0
## 1547  cellular  20   oct       76        2    -1        0  unknown 0        0
## 1548 telephone  10   jul       73        1    -1        0  unknown 0        0
## 1549   unknown   3   jun      119        2    -1        0  unknown 0        0
## 1550  cellular  15   jun      139        1    -1        0  unknown 0        1
## 1551  cellular  11   aug      389        4    -1        0  unknown 0        0
## 1552   unknown   9   jun       96        6    -1        0  unknown 0        0
## 1553  cellular   8   feb      190        2   280        8  failure 1        1
## 1554  cellular  20   nov      197        4    30        1  failure 0        0
## 1555  cellular  13   aug      240        2    -1        0  unknown 0        0
## 1556   unknown  11   jun      165        2    -1        0  unknown 0        0
## 1557   unknown   9   may      124        2    -1        0  unknown 0        0
## 1558  cellular  12   may      631        1   344        1  success 0        0
## 1559  cellular   5   feb      308        1   213        1    other 0        0
## 1560 telephone  18   jan      287        5   285        5  success 1        1
## 1561   unknown  26   may      260        5    -1        0  unknown 0        0
## 1562  cellular   7   may      245        3    -1        0  unknown 0        0
## 1563   unknown  23   may     1349        8    -1        0  unknown 1        0
## 1564  cellular   9   jul       71        1    -1        0  unknown 0        0
## 1565  cellular  22   aug       24       30    -1        0  unknown 0        0
## 1566 telephone  18   nov       55        2    -1        0  unknown 0        0
## 1567  cellular  22   jul      506        1    -1        0  unknown 0        1
## 1568  cellular  29   jun      295        1   287        4  success 1        0
## 1569  cellular   8   may       51        1    -1        0  unknown 0        0
## 1570   unknown  13   may      106        1    -1        0  unknown 0        0
## 1571  cellular  11   jul       55        1    -1        0  unknown 0        0
## 1572   unknown  15   may       54        2    -1        0  unknown 0        0
## 1573  cellular  12   feb      138        2    92        2  success 1        0
## 1574  cellular  29   jan      120        1    -1        0  unknown 0        0
## 1575   unknown  20   jun       29        2    -1        0  unknown 0        0
## 1576   unknown  21   may      230        2    -1        0  unknown 0        0
## 1577   unknown   6   may      168        1    -1        0  unknown 0        0
## 1578  cellular   5   feb      578        1    -1        0  unknown 1        0
## 1579  cellular   3   feb      182        2    -1        0  unknown 0        0
## 1580  cellular   9   jul       73        3    -1        0  unknown 0        0
## 1581   unknown  16   may      345        1    -1        0  unknown 0        1
## 1582  cellular  16   apr      263        1    -1        0  unknown 0        0
## 1583   unknown  14   may      208        1    -1        0  unknown 0        0
## 1584  cellular   2   feb      228        2    -1        0  unknown 0        0
## 1585  cellular  26   may      640        1    -1        0  unknown 1        0
## 1586  cellular  29   jul     1697        1    -1        0  unknown 0        0
## 1587  cellular  15   may      265        7    -1        0  unknown 0        0
## 1588  cellular  30   jan      410        2    -1        0  unknown 0        0
## 1589 telephone  23   jul       83        4    -1        0  unknown 0        0
## 1590   unknown   3   jun      404       13    -1        0  unknown 0        0
## 1591   unknown   3   jun       69        2    -1        0  unknown 0        0
## 1592  cellular   6   may      133        1    -1        0  unknown 0        0
## 1593  cellular  29   jan      468        2    -1        0  unknown 0        0
## 1594   unknown  20   jun       17        3    -1        0  unknown 0        0
## 1595  cellular  13   may      174        1   359        2    other 0        0
## 1596   unknown  15   may      435        1    -1        0  unknown 0        0
## 1597  cellular  18   may      125        1   368        4  failure 0        0
## 1598  cellular  12   may      215        2    -1        0  unknown 0        0
## 1599  cellular  18   aug      195       10    -1        0  unknown 0        0
## 1600   unknown  17   nov     1735        2    -1        0  unknown 0        0
## 1601   unknown  20   jun       20        3    -1        0  unknown 0        0
## 1602   unknown  30   may      510        1    -1        0  unknown 0        0
## 1603  cellular   6   aug      102        4    -1        0  unknown 0        0
## 1604  cellular   6   may     1347        2   363        1  failure 1        0
## 1605   unknown  23   may      158        3    -1        0  unknown 0        0
## 1606   unknown  29   may      158        1    -1        0  unknown 0        0
## 1607   unknown   9   may      161        2    -1        0  unknown 0        0
## 1608  cellular   3   feb      541        1    -1        0  unknown 0        0
## 1609  cellular  15   may       48        1    -1        0  unknown 0        0
## 1610   unknown   9   dec       10        1    -1        0  unknown 0        0
## 1611  cellular   6   aug      996        1    -1        0  unknown 1        0
## 1612  cellular  20   nov      194        4   188        8    other 0        0
## 1613  cellular  17   nov      223        1    96        2  failure 0        0
## 1614   unknown  29   may      473        1    -1        0  unknown 0        0
## 1615  cellular  12   aug      433        3    -1        0  unknown 0        0
## 1616  cellular  28   aug      322        7    -1        0  unknown 0        0
## 1617  cellular   5   feb       99        1    93        3  success 0        0
## 1618  cellular  17   apr       20        2   238        2  failure 0        0
## 1619  cellular   9   jul      296        1    -1        0  unknown 0        0
## 1620  cellular  19   nov      112        1    -1        0  unknown 0        0
## 1621  cellular  14   may      171        4    -1        0  unknown 0        0
## 1622  cellular  24   jul      129        2    -1        0  unknown 0        0
## 1623  cellular  20   nov      180        1   185        2  failure 0        0
## 1624  cellular  15   may       71        3    -1        0  unknown 0        0
## 1625  cellular  30   apr      315        1   182        2  success 1        0
## 1626  cellular  13   aug      142        4    -1        0  unknown 0        0
## 1627   unknown  12   may      396        3    -1        0  unknown 0        1
## 1628   unknown  14   may        7        1    -1        0  unknown 0        1
## 1629   unknown   8   may      230        4    -1        0  unknown 0        0
## 1630  cellular  30   jul      192        3    -1        0  unknown 0        1
## 1631  cellular  17   jul       67        1    -1        0  unknown 0        0
## 1632   unknown  20   jun       16        8    -1        0  unknown 0        0
## 1633   unknown  27   jun      151        2    -1        0  unknown 0        0
## 1634  cellular  16   apr      399        1    -1        0  unknown 0        0
## 1635   unknown   8   may      133        2    -1        0  unknown 0        0
## 1636  cellular  14   aug      253        1    -1        0  unknown 0        1
## 1637   unknown   9   jun      181        1    -1        0  unknown 0        0
## 1638  cellular  18   may      156        5   297        1    other 0        0
## 1639  cellular  21   jul      808        5    -1        0  unknown 0        0
## 1640  cellular  21   jul      368        2    -1        0  unknown 0        0
## 1641   unknown   6   jun      466        2    -1        0  unknown 0        0
## 1642   unknown   2   jun      747        2    -1        0  unknown 1        0
## 1643  cellular  28   jan      368        1    -1        0  unknown 0        0
## 1644  cellular   9   jul      625        1    -1        0  unknown 1        0
## 1645  cellular   8   aug      103        4    -1        0  unknown 0        0
## 1646  cellular   2   aug      300        3    -1        0  unknown 0        1
## 1647  cellular  15   apr     1187        2   320        2  success 0        0
## 1648  cellular  13   aug      310        2    -1        0  unknown 0        0
## 1649  cellular   7   aug      324        3    -1        0  unknown 0        0
## 1650  cellular  10   jul       57        3    -1        0  unknown 0        1
## 1651  cellular  20   nov      564        2   183        1  failure 0        0
## 1652  cellular  14   may       83        2    -1        0  unknown 0        0
## 1653  cellular   8   jul      123        1    -1        0  unknown 0        0
## 1654  cellular  19   aug      145       10    -1        0  unknown 0        0
## 1655  cellular   7   apr      221        2   267        3    other 0        0
## 1656  cellular   3   jun      203        2    -1        0  unknown 0        0
## 1657 telephone  28   jan      653        3    -1        0  unknown 0        0
## 1658   unknown  23   may      385        1    -1        0  unknown 0        0
## 1659  cellular  11   may      133        1    -1        0  unknown 0        1
## 1660  cellular  21   jul      112        1    -1        0  unknown 0        0
## 1661   unknown   5   jun       85        3    -1        0  unknown 0        0
## 1662   unknown  18   jun      113        2    -1        0  unknown 0        0
## 1663  cellular  20   apr      223        1    -1        0  unknown 0        0
## 1664  cellular  25   jul      126        1    -1        0  unknown 0        0
## 1665  cellular  14   may      526        3   179        3  success 1        0
## 1666  cellular  17   nov       80        2    -1        0  unknown 0        0
## 1667  cellular   4   aug       71        1    -1        0  unknown 0        0
## 1668  cellular  13   may       62        3    -1        0  unknown 0        0
## 1669   unknown  16   may      698        1    -1        0  unknown 0        0
## 1670  cellular  30   jul       69        4    -1        0  unknown 0        0
## 1671   unknown   5   jun      127        4    -1        0  unknown 0        0
## 1672  cellular  18   may       19        4   374        1    other 0        0
## 1673   unknown  28   may      507        2    -1        0  unknown 0        1
## 1674  cellular  11   jul      252        1    -1        0  unknown 0        0
## 1675  cellular  28   jul      152        4    -1        0  unknown 0        0
## 1676  cellular   7   aug      126        1    -1        0  unknown 0        0
## 1677 telephone   3   feb      226        2    -1        0  unknown 0        1
## 1678  cellular  29   aug      255        2    -1        0  unknown 0        0
## 1679  cellular   4   aug      190        1    -1        0  unknown 0        0
## 1680  cellular  22   jul      107        2    -1        0  unknown 0        0
## 1681   unknown   5   nov      204        1    -1        0  unknown 1        0
## 1682  cellular  15   may      320        3   371        2  failure 0        0
## 1683  cellular  13   may       78        2    -1        0  unknown 0        0
## 1684  cellular  17   apr      728        1   316        3    other 0        1
## 1685  cellular  12   may      418        1    -1        0  unknown 0        0
## 1686  cellular  29   jan       76        2    -1        0  unknown 0        1
## 1687  cellular   6   apr      317        1   363        2  success 1        0
## 1688  cellular  31   jul      142        2    -1        0  unknown 0        0
## 1689  cellular  20   nov       80        5   198        2  failure 0        0
## 1690   unknown   7   may      188        2    -1        0  unknown 0        0
## 1691  cellular  19   nov      392        3    -1        0  unknown 0        0
## 1692  cellular   7   jul      166        1    -1        0  unknown 0        0
## 1693  cellular  22   jul      344        3    -1        0  unknown 0        0
## 1694   unknown  15   may      138        2    -1        0  unknown 0        0
## 1695  cellular  10   aug      134        3   194        1  failure 0        0
## 1696  cellular   9   jul      116        1   301        1    other 0        1
## 1697  cellular   4   feb       38        8    -1        0  unknown 0        0
## 1698  cellular  22   jul      728        8    -1        0  unknown 0        0
## 1699  cellular   6   may       20        1   342        1  failure 0        0
## 1700  cellular  18   nov       77        1   127        3  failure 0        0
## 1701  cellular   8   jul      218        3    -1        0  unknown 0        0
## 1702   unknown   9   jun      291        3    -1        0  unknown 0        0
## 1703   unknown  12   may       92        3    -1        0  unknown 0        1
## 1704  cellular  13   may      850        1    -1        0  unknown 1        0
## 1705   unknown  29   may     2260        2    -1        0  unknown 0        0
## 1706   unknown  28   may      139        2    -1        0  unknown 0        0
## 1707  cellular   9   jul      127        1    -1        0  unknown 0        0
## 1708 telephone  20   nov      281        2   195        6  failure 0        0
## 1709  cellular   2   feb       19        6    -1        0  unknown 0        0
## 1710  cellular  13   apr      137        1   333        2    other 0        0
## 1711   unknown   9   may       85        2    -1        0  unknown 0        0
## 1712  cellular   7   aug      147        3    -1        0  unknown 0        0
## 1713  cellular  29   oct      408        2    -1        0  unknown 0        1
## 1714   unknown  16   jun      154        3    -1        0  unknown 0        0
## 1715  cellular  15   jul      779        2    -1        0  unknown 0        0
## 1716   unknown   6   may      204        1    -1        0  unknown 0        0
## 1717  cellular  12   aug      473        6    -1        0  unknown 1        0
## 1718   unknown  14   may      125        1    -1        0  unknown 0        0
## 1719   unknown  15   may      101        1    -1        0  unknown 0        0
## 1720  cellular  22   jul      662        1    -1        0  unknown 0        1
## 1721  cellular  14   aug      260        7    -1        0  unknown 0        0
## 1722  cellular   7   may      103        1   363        1  failure 0        0
## 1723   unknown   8   may      136        2    -1        0  unknown 0        0
## 1724  cellular  15   jul      159        6    -1        0  unknown 0        0
## 1725  cellular  18   may       32        2    -1        0  unknown 0        1
## 1726   unknown  20   may      129        2    -1        0  unknown 0        0
## 1727   unknown  15   sep      173        1    -1        0  unknown 0        0
## 1728  cellular  29   aug      128        2    -1        0  unknown 0        0
## 1729  cellular  28   jan     1232        1    -1        0  unknown 1        0
## 1730   unknown  23   may      260        3    -1        0  unknown 0        0
## 1731  cellular  18   nov      167        5    -1        0  unknown 0        0
## 1732 telephone  19   feb      255        3    -1        0  unknown 0        0
## 1733   unknown  20   jun      973        2    -1        0  unknown 1        0
## 1734  cellular   2   feb      266        2    -1        0  unknown 0        0
## 1735   unknown   4   jul      121        1    -1        0  unknown 0        0
## 1736   unknown  26   may      111        1    -1        0  unknown 0        1
## 1737   unknown   4   jun       92        2    -1        0  unknown 0        0
## 1738  cellular  14   jul      287        2    -1        0  unknown 0        0
## 1739  cellular  20   nov      141        2    -1        0  unknown 0        0
## 1740 telephone  27   aug       23        9    -1        0  unknown 0        0
## 1741 telephone  20   apr        5        3   150        6  failure 0        0
## 1742  cellular  11   aug      222        3   182        4  success 1        0
## 1743   unknown  23   may      178        1    -1        0  unknown 0        0
## 1744   unknown   9   may       45        1    -1        0  unknown 0        0
## 1745  cellular  14   may      419        1   360        4  failure 0        0
## 1746  cellular  14   may      156        1    -1        0  unknown 0        1
## 1747  cellular   8   jul      104        2    -1        0  unknown 0        0
## 1748  cellular  19   aug       51        2    -1        0  unknown 0        0
## 1749 telephone  28   aug       44       12    -1        0  unknown 0        0
## 1750  cellular  11   may      701        1   362        1  success 1        0
## 1751   unknown  12   jun      252        1    -1        0  unknown 0        0
## 1752  cellular  11   may       93        2    -1        0  unknown 0        1
## 1753  cellular   2   jun      690        1    -1        0  unknown 1        0
## 1754   unknown  28   may       62        2    -1        0  unknown 0        1
## 1755   unknown  28   may      103        2    -1        0  unknown 0        0
## 1756  cellular  15   apr       61        3    -1        0  unknown 0        0
## 1757   unknown  27   may      241        1    -1        0  unknown 0        0
## 1758  cellular   7   jul      209        1    -1        0  unknown 0        1
## 1759  cellular  20   apr      627        5    -1        0  unknown 0        0
## 1760 telephone  13   may       26        1   174        2  failure 0        0
## 1761   unknown   3   jun      231       12    -1        0  unknown 0        0
## 1762  cellular  11   aug     1363        1    -1        0  unknown 1        1
## 1763   unknown  12   may       78        3    -1        0  unknown 0        0
## 1764   unknown  15   may      295        2    -1        0  unknown 0        0
## 1765  cellular  29   jan      273        1    -1        0  unknown 0        0
## 1766  cellular  29   apr      375        1    -1        0  unknown 1        0
## 1767 telephone   2   mar       88        3    -1        0  unknown 0        0
## 1768   unknown   7   may       83        2    -1        0  unknown 0        0
## 1769  cellular  18   aug      350        6    -1        0  unknown 0        0
## 1770   unknown  13   may      146        1    -1        0  unknown 0        0
## 1771  cellular  26   jul      183        1   221        2  failure 1        0
## 1772  cellular  20   nov      175        1    -1        0  unknown 0        0
## 1773   unknown  19   may      198        1    -1        0  unknown 0        0
## 1774 telephone  15   may       23        3   346       10  failure 0        0
## 1775  cellular  17   jul       58        1    -1        0  unknown 0        0
## 1776   unknown   9   may     1080        5    -1        0  unknown 0        0
## 1777   unknown  19   jun      172        1    -1        0  unknown 0        1
## 1778  cellular  14   apr      184        1    -1        0  unknown 1        0
## 1779  cellular  27   aug      276        3    -1        0  unknown 0        0
## 1780   unknown  21   may      208        3    -1        0  unknown 0        0
## 1781 telephone  11   may      544        3    -1        0  unknown 0        0
## 1782  cellular  20   apr      219        4    -1        0  unknown 0        0
## 1783  cellular  19   aug       97        5    -1        0  unknown 0        0
## 1784   unknown  27   may       56        2    -1        0  unknown 0        0
## 1785  cellular  21   aug      111        2    -1        0  unknown 0        0
## 1786  cellular   2   feb       87        2   265        3    other 0        0
## 1787  cellular  18   may       42        1    -1        0  unknown 0        0
## 1788   unknown   9   jun       21       37    -1        0  unknown 0        1
## 1789   unknown   6   jun      175        2    -1        0  unknown 0        0
## 1790 telephone  17   jul      109        3    -1        0  unknown 0        0
## 1791  cellular  25   nov       92        2    -1        0  unknown 0        0
## 1792  cellular   8   may      151        4   171       11    other 0        0
## 1793  cellular  18   may       55        1    -1        0  unknown 0        0
## 1794  cellular   3   apr      179        3    -1        0  unknown 0        0
## 1795  cellular  22   aug      283        1    -1        0  unknown 0        0
## 1796   unknown   1   sep       20        1   478        2    other 0        0
## 1797  cellular  19   nov      354        2    -1        0  unknown 0        0
## 1798  cellular   9   feb       11        7    -1        0  unknown 0        1
## 1799  cellular  16   apr     1463        2    -1        0  unknown 1        0
## 1800  cellular  18   may      695        2    -1        0  unknown 0        1
## 1801   unknown  20   may      235        2    -1        0  unknown 0        0
## 1802   unknown  30   may      119        2    -1        0  unknown 0        0
## 1803  cellular   9   aug      305        1    91        2    other 0        0
## 1804  cellular  18   nov      124        1   175        1  failure 0        0
## 1805   unknown  29   may      167        1    -1        0  unknown 0        0
## 1806   unknown  29   may      859        2    -1        0  unknown 0        1
## 1807  cellular   6   may      362        2   307        1  failure 0        0
## 1808  cellular   4   feb       93        1    -1        0  unknown 0        0
## 1809  cellular  22   aug       73       15    -1        0  unknown 0        0
## 1810   unknown   7   may      130        4    -1        0  unknown 0        0
## 1811  cellular  13   aug      102        1   105        1  success 0        0
## 1812  cellular  17   apr      550        1   325        1    other 0        1
## 1813  cellular  20   nov      203        1    -1        0  unknown 0        0
## 1814  cellular  25   aug      192        1   193        1  success 1        0
## 1815  cellular  11   may      764        4    -1        0  unknown 0        0
## 1816 telephone  10   jul      139        1    -1        0  unknown 0        0
## 1817  cellular  28   jul       73        7    -1        0  unknown 0        1
## 1818  cellular  18   may      599        1   306        4  success 0        0
## 1819 telephone  11   nov      133        1    -1        0  unknown 0        0
## 1820  cellular  14   jul      191        3    -1        0  unknown 0        0
## 1821   unknown  19   may      105        1    -1        0  unknown 0        1
## 1822  cellular  19   aug      193        2    -1        0  unknown 0        0
## 1823  cellular  13   may      174        2    -1        0  unknown 0        0
## 1824  cellular  10   feb      511        3   183        6  success 1        0
## 1825 telephone  20   nov       59        1    -1        0  unknown 0        0
## 1826   unknown  20   may       91        1    -1        0  unknown 0        0
## 1827  cellular  21   nov       91        2    -1        0  unknown 0        0
## 1828  cellular  18   nov      231        1    96        2    other 0        0
## 1829  cellular  30   nov      210        3    -1        0  unknown 0        0
## 1830   unknown  20   jun      333       15    -1        0  unknown 0        0
## 1831  cellular   8   apr      335        2    -1        0  unknown 0        1
## 1832  cellular  25   jul      936        1    -1        0  unknown 0        1
## 1833  cellular  31   jul      434        4    -1        0  unknown 0        0
## 1834  cellular   8   aug      629        4    -1        0  unknown 0        0
## 1835  cellular   7   may      128        1    -1        0  unknown 0        1
## 1836  cellular  17   jul      235        2    -1        0  unknown 0        0
## 1837  cellular  29   jan      379        1   192        1  failure 0        1
## 1838  cellular  19   aug      281        2    -1        0  unknown 0        0
## 1839  cellular  12   aug      249        1   104        1  success 0        1
## 1840  cellular  26   aug       26       10    -1        0  unknown 0        0
## 1841   unknown  11   jun      148        1    -1        0  unknown 0        0
## 1842  cellular  10   jul      182        1    -1        0  unknown 0        0
## 1843  cellular  29   jul       54        7    -1        0  unknown 0        0
## 1844   unknown  15   may      644        2    -1        0  unknown 0        0
## 1845   unknown   7   may      107        1    -1        0  unknown 0        0
## 1846   unknown  26   jun      565        3    -1        0  unknown 0        0
## 1847  cellular  22   oct      168        2    -1        0  unknown 0        0
## 1848  cellular   8   jul       59        1    -1        0  unknown 0        0
## 1849   unknown  18   jun      521       11    -1        0  unknown 0        0
## 1850  cellular  18   aug      119        3    -1        0  unknown 0        0
## 1851  cellular  15   mar      192        1   185        2  success 1        0
## 1852  cellular  11   aug      179        4    -1        0  unknown 0        0
## 1853  cellular  12   may       98        1    77        5  failure 0        0
## 1854   unknown   5   may      225        2    -1        0  unknown 0        0
## 1855  cellular  20   nov      611        3    -1        0  unknown 0        0
## 1856   unknown  21   may      281       15    -1        0  unknown 0        0
## 1857  cellular  30   jan      427        1    -1        0  unknown 0        0
## 1858  cellular  20   apr      181        2   270        2  failure 0        0
## 1859  cellular  23   jul       70        5    -1        0  unknown 0        0
## 1860   unknown   5   jun      348        1    -1        0  unknown 0        0
## 1861   unknown   3   jun      266       10    -1        0  unknown 0        0
## 1862  cellular  15   jul      514        5    -1        0  unknown 1        0
## 1863  cellular  13   may      224        1   370        2  failure 0        0
## 1864   unknown  30   may       88        2    -1        0  unknown 0        0
## 1865  cellular   8   apr       72        1    -1        0  unknown 0        1
## 1866   unknown  13   may      173        1    -1        0  unknown 0        0
## 1867  cellular  20   nov      230        1    -1        0  unknown 0        0
## 1868  cellular  20   apr      156        1    -1        0  unknown 0        0
## 1869   unknown  20   jun       11       15    -1        0  unknown 0        0
## 1870  cellular  24   apr      173        2    -1        0  unknown 0        0
## 1871  cellular  20   apr      167        1   350        1  failure 0        0
## 1872 telephone   8   jul      132        7    -1        0  unknown 0        0
## 1873   unknown  14   may      110        1    -1        0  unknown 0        0
## 1874 telephone  16   mar      294        1   274        2  failure 0        0
## 1875  cellular   5   aug      202        1    -1        0  unknown 0        0
## 1876   unknown  20   jun       10        2    -1        0  unknown 0        0
## 1877  cellular  30   jul     1037       24    -1        0  unknown 0        0
## 1878   unknown  26   may      155        2    -1        0  unknown 0        0
## 1879  cellular  26   feb      480        2   189        1  failure 0        0
## 1880   unknown  16   jun      505        1    -1        0  unknown 0        0
## 1881  cellular  13   aug      904        6    -1        0  unknown 1        0
## 1882  cellular   9   apr      765        3    -1        0  unknown 0        0
## 1883  cellular   8   aug      448        5    -1        0  unknown 0        0
## 1884   unknown  12   nov      114        1   170        3  failure 1        0
## 1885  cellular  28   jan      246        1    -1        0  unknown 0        0
## 1886   unknown  18   jun      604        6    -1        0  unknown 0        0
## 1887  cellular   2   jun       80        1    92        1  failure 0        0
## 1888   unknown  16   jun      362        3    -1        0  unknown 0        0
## 1889  cellular  19   aug      166        2    -1        0  unknown 0        0
## 1890  cellular   2   jun      282        2   385        1  success 1        0
## 1891   unknown   7   may      123        1    -1        0  unknown 0        0
## 1892   unknown   6   jun      109        1    -1        0  unknown 0        0
## 1893  cellular  19   nov       68        1    -1        0  unknown 0        0
## 1894 telephone  19   nov       53        1    -1        0  unknown 0        0
## 1895   unknown   2   jun       97        4    -1        0  unknown 0        0
## 1896   unknown  29   may      751        3    -1        0  unknown 1        0
## 1897  cellular   8   jul      154        1    -1        0  unknown 0        0
## 1898  cellular  17   nov      106        1    -1        0  unknown 0        0
## 1899  cellular  12   aug      428        2    -1        0  unknown 0        0
## 1900  cellular   6   may      228        2    -1        0  unknown 0        0
## 1901  cellular  24   jul      347        5    -1        0  unknown 0        0
## 1902  cellular  18   nov       87        1    -1        0  unknown 0        0
## 1903  cellular   8   jul      413        1    -1        0  unknown 0        0
## 1904  cellular  15   may      170        2    -1        0  unknown 0        1
## 1905   unknown  16   may      211        2    -1        0  unknown 0        0
## 1906  cellular  20   apr      143        4    -1        0  unknown 0        0
## 1907  cellular   6   may      219        2    -1        0  unknown 0        0
## 1908   unknown   9   may      188        2    -1        0  unknown 0        0
## 1909  cellular   7   aug      305        1   179        5    other 0        0
## 1910  cellular  12   may      313        1    -1        0  unknown 0        0
## 1911  cellular  21   nov      285        3   116        4  failure 0        0
## 1912  cellular  30   jan      771        1    -1        0  unknown 1        0
## 1913  cellular  10   aug      170        2    -1        0  unknown 0        0
## 1914   unknown   6   jun      101        2    -1        0  unknown 0        0
## 1915  cellular  16   jul      171        6    -1        0  unknown 0        0
## 1916 telephone  12   may       52        1    -1        0  unknown 0        0
## 1917  cellular   4   aug      561        1   435        3  failure 1        0
## 1918   unknown  16   may       33        1    -1        0  unknown 0        0
## 1919   unknown  11   jun       36        2    -1        0  unknown 0        0
## 1920 telephone   6   feb       35        3    -1        0  unknown 0        0
## 1921  cellular  11   jul       47        2    -1        0  unknown 0        0
## 1922   unknown  17   jun      269        1    -1        0  unknown 0        0
## 1923  cellular   7   may      218        2   211        4  success 0        0
## 1924  cellular  21   nov      119        2   171        1  failure 0        0
## 1925  cellular   5   may      348        1    -1        0  unknown 0        0
## 1926   unknown  20   may      100        1    -1        0  unknown 0        0
## 1927 telephone  28   jan       88        2    -1        0  unknown 0        0
## 1928  cellular  17   apr      273        2   254        2  failure 0        0
## 1929  cellular  11   may       54        1    -1        0  unknown 0        0
## 1930  cellular  27   may      161        1   100        3  success 0        0
## 1931  cellular  11   aug      146        2    -1        0  unknown 0        0
## 1932  cellular  22   jul      211        3    -1        0  unknown 0        0
## 1933   unknown  19   may      552        3    -1        0  unknown 1        0
## 1934  cellular  22   jul      400        2    -1        0  unknown 0        0
## 1935   unknown   3   jun      366        1    -1        0  unknown 0        0
## 1936 telephone   5   feb        8        7   189       18    other 0        0
## 1937   unknown  14   may       57        2    -1        0  unknown 0        0
## 1938  cellular  19   oct      167        3    -1        0  unknown 0        0
## 1939  cellular  28   aug       36        3    -1        0  unknown 0        0
## 1940  cellular   3   feb      150        4    -1        0  unknown 0        0
## 1941  cellular   3   jun      187        1    20        1    other 1        0
## 1942  cellular  16   jul      226        1    -1        0  unknown 0        0
## 1943  cellular   2   sep      799        2    -1        0  unknown 1        1
## 1944  cellular  14   may      178        7   365        5    other 0        0
## 1945 telephone  20   nov      281        2    -1        0  unknown 0        0
## 1946  cellular  17   aug      551        2    -1        0  unknown 0        0
## 1947   unknown  18   jun      332        2    -1        0  unknown 0        0
## 1948 telephone   6   feb      381        6   213        9  failure 0        0
## 1949  cellular   5   feb      401        2     8        3    other 0        0
## 1950   unknown  15   may      226        2    -1        0  unknown 0        0
## 1951  cellular   6   aug       99        4    -1        0  unknown 0        0
## 1952   unknown  14   may      451        3    -1        0  unknown 0        0
## 1953   unknown   5   may      381        2    -1        0  unknown 0        0
## 1954   unknown   7   may      127        1    -1        0  unknown 0        0
## 1955  cellular  28   jan      315        1    -1        0  unknown 0        0
## 1956  cellular  14   sep      112        2    24        2    other 0        1
## 1957   unknown  29   may      201        1    -1        0  unknown 0        0
## 1958   unknown  27   may      293        2    -1        0  unknown 0        0
## 1959  cellular  13   may      499        3    -1        0  unknown 0        0
## 1960  cellular  10   jul       48        2    -1        0  unknown 0        0
## 1961  cellular   5   may      494        1    -1        0  unknown 1        0
## 1962  cellular   4   feb      147        1   253        7    other 0        0
## 1963  cellular  20   nov       23        1    -1        0  unknown 0        0
## 1964   unknown   5   may      787        1    -1        0  unknown 0        0
## 1965  cellular   4   feb      605        1    -1        0  unknown 0        0
## 1966  cellular   8   jul       82        1    -1        0  unknown 0        0
## 1967   unknown   1   jul      484        1    -1        0  unknown 0        0
## 1968   unknown  23   may       61        2    -1        0  unknown 0        0
## 1969  cellular  12   may       78        5    -1        0  unknown 0        0
## 1970  cellular  16   apr      132        2    -1        0  unknown 0        0
## 1971  cellular   5   feb      642        1   167        2  failure 1        0
## 1972   unknown  20   jun        6       17    -1        0  unknown 0        0
## 1973  cellular  14   jul       53        8    -1        0  unknown 0        0
## 1974   unknown   9   may     1178        4    -1        0  unknown 0        0
## 1975  cellular  29   jan      147        1   195        1    other 0        0
## 1976   unknown  21   may      236        1    -1        0  unknown 0        0
## 1977  cellular  28   jan      978        2   189        1    other 0        0
## 1978   unknown  26   may      296        1    -1        0  unknown 0        0
## 1979   unknown   9   may      479        2    -1        0  unknown 0        0
## 1980   unknown  14   may      188        1    -1        0  unknown 0        0
## 1981   unknown  29   may      447        4    -1        0  unknown 0        0
## 1982  cellular   7   may      356        2   286        3  failure 0        0
## 1983   unknown   6   jun      136        1    -1        0  unknown 0        0
## 1984   unknown  20   may       37        9    -1        0  unknown 0        0
## 1985  cellular  19   nov       96        1    -1        0  unknown 0        0
## 1986  cellular  18   may       44        4    -1        0  unknown 0        0
## 1987  cellular  19   nov      186        2    -1        0  unknown 0        0
## 1988   unknown  12   may       95        8    -1        0  unknown 0        0
## 1989  cellular  22   aug      155        2    -1        0  unknown 0        0
## 1990 telephone  17   jul      202        5    -1        0  unknown 0        0
## 1991  cellular  30   jan      540        1     2        2    other 0        0
## 1992  cellular   8   apr      169        1   231        2  failure 0        0
## 1993  cellular  13   apr      256        5   181        2  success 1        1
## 1994  cellular   4   may      191        3    -1        0  unknown 0        0
## 1995  cellular  30   jul      151       10    -1        0  unknown 0        0
## 1996  cellular  19   nov      131        3   133        3  failure 0        0
## 1997  cellular   2   nov      131        2    -1        0  unknown 0        0
## 1998  cellular   5   feb      590        5    -1        0  unknown 0        0
## 1999  cellular  18   nov      178        1   127        7    other 0        0
## 2000   unknown  18   jun       64        2    -1        0  unknown 0        0
## 2001  cellular   9   feb      247        5    -1        0  unknown 0        0
## 2002  cellular  19   aug      120        6    -1        0  unknown 0        0
## 2003  cellular  11   aug      108        1    99        7  failure 0        0
## 2004  cellular   3   jul      257        1    -1        0  unknown 1        1
## 2005  cellular  13   may      562        2   174        2  success 0        0
## 2006  cellular  17   apr      126        3   345        2    other 0        0
## 2007  cellular   4   jul       95        2    -1        0  unknown 0        0
## 2008   unknown   5   jun      508        2    -1        0  unknown 1        0
## 2009  cellular   8   aug      121        2    -1        0  unknown 0        0
## 2010  cellular  20   nov      166        3    -1        0  unknown 0        0
## 2011  cellular  28   jan      155        1    -1        0  unknown 0        0
## 2012  cellular  27   apr      159        3    -1        0  unknown 1        0
## 2013   unknown   7   may      212        2    -1        0  unknown 0        0
## 2014  cellular  14   aug      221        6    -1        0  unknown 0        0
## 2015   unknown  20   may      169        4    -1        0  unknown 0        0
## 2016   unknown   2   jun      442       11    -1        0  unknown 0        1
## 2017   unknown  26   may      120        1    -1        0  unknown 0        1
## 2018  cellular  28   may       85        1    -1        0  unknown 0        0
## 2019   unknown   6   may      245        1    -1        0  unknown 0        0
## 2020  cellular  29   jan      187        2   185        8  failure 0        0
## 2021  cellular  28   aug       68        2    -1        0  unknown 0        0
## 2022  cellular  18   jan      163        1    -1        0  unknown 0        1
## 2023   unknown  23   may       83        1    -1        0  unknown 0        0
## 2024  cellular   4   aug      174        1    -1        0  unknown 0        0
## 2025   unknown   7   may      214        2    -1        0  unknown 0        0
## 2026   unknown  17   jun      209        3    -1        0  unknown 0        0
## 2027  cellular  14   may      456        1   300        1  failure 1        0
## 2028  cellular   8   may      127        1    -1        0  unknown 0        0
## 2029  cellular  28   jul      817        2    -1        0  unknown 1        1
## 2030  cellular  18   oct      375        2    -1        0  unknown 0        1
## 2031  cellular  15   jun       29        1    -1        0  unknown 0        1
## 2032   unknown  26   may      219        4    -1        0  unknown 0        0
## 2033  cellular  18   may      109        2    -1        0  unknown 0        0
## 2034 telephone   2   jun      128        1    -1        0  unknown 0        0
## 2035   unknown  14   may       73        2    -1        0  unknown 0        0
## 2036  cellular   6   feb      278        4    -1        0  unknown 0        0
## 2037  cellular  31   jul       34       32    -1        0  unknown 0        1
## 2038  cellular  16   nov      257        1    -1        0  unknown 1        0
## 2039   unknown  16   may      844        1    -1        0  unknown 1        0
## 2040  cellular  19   mar      167        1    -1        0  unknown 1        0
## 2041  cellular   2   feb       12        3    -1        0  unknown 0        0
## 2042  cellular   8   may      763        1    -1        0  unknown 1        1
## 2043   unknown   2   jun      101        1    -1        0  unknown 0        0
## 2044  cellular  18   nov      131        1    -1        0  unknown 0        0
## 2045  cellular   4   aug      148        1    -1        0  unknown 0        0
## 2046  cellular   5   feb      701        1    -1        0  unknown 0        0
## 2047  cellular  20   nov      454        1    -1        0  unknown 1        0
## 2048   unknown  20   jun      280        1    -1        0  unknown 0        0
## 2049   unknown  26   may      265        4    -1        0  unknown 0        0
## 2050   unknown   7   may      297        3    -1        0  unknown 0        0
## 2051  cellular   5   aug      153        1    -1        0  unknown 0        0
## 2052  cellular   3   feb      254        1    -1        0  unknown 0        0
## 2053 telephone  11   may       30        4   304        2    other 0        0
## 2054   unknown  27   may      125        4    -1        0  unknown 0        0
## 2055  cellular   3   jun      114        1    -1        0  unknown 0        0
## 2056  cellular   5   feb      136       10    -1        0  unknown 1        0
## 2057  cellular   9   apr      208       12   337        1  failure 0        0
## 2058  cellular  21   nov       86        1    -1        0  unknown 0        0
## 2059  cellular  17   apr      949        2   254        6    other 1        0
## 2060   unknown  19   jun      207        1    -1        0  unknown 0        0
## 2061 telephone  19   nov      103        1    -1        0  unknown 0        0
## 2062   unknown  13   may     1052        1    -1        0  unknown 0        0
## 2063  cellular  30   apr      109        1    -1        0  unknown 0        0
## 2064   unknown   4   jun      149        8    -1        0  unknown 0        0
## 2065   unknown  11   jun      138        5    -1        0  unknown 0        0
## 2066  cellular  13   may      341        1    -1        0  unknown 0        1
## 2067  cellular  20   apr      184        2   151        1  failure 0        0
## 2068   unknown  20   jun       75        3    -1        0  unknown 0        0
## 2069  cellular  15   apr       87        2    -1        0  unknown 0        0
## 2070  cellular  26   jan      413        2    -1        0  unknown 0        0
## 2071 telephone   2   feb       35        1    -1        0  unknown 0        0
## 2072 telephone   8   jul      104        3    -1        0  unknown 0        0
## 2073  cellular  11   jul      487        3    -1        0  unknown 0        0
## 2074  cellular   4   feb      146        1    -1        0  unknown 0        0
## 2075 telephone   4   may      483        4    87        2  success 1        0
## 2076  cellular  11   nov      248        1    -1        0  unknown 0        0
## 2077 telephone   2   feb      803        1    -1        0  unknown 1        0
## 2078   unknown  13   may       91        2    -1        0  unknown 0        0
## 2079  cellular   4   jun       94        1    -1        0  unknown 0        0
## 2080   unknown  12   may      325        3    -1        0  unknown 0        0
## 2081  cellular  15   may       22        5    -1        0  unknown 0        0
## 2082   unknown  30   may      130        2    -1        0  unknown 0        0
## 2083  cellular  29   jan      383        2   206        1    other 0        0
## 2084   unknown   7   may      207        1    -1        0  unknown 0        0
## 2085   unknown  16   may      244        1    -1        0  unknown 0        0
## 2086  cellular  21   nov       31        7    -1        0  unknown 0        0
## 2087  cellular  12   may      493       10   362        1    other 0        0
## 2088 telephone  28   jan      183        2    -1        0  unknown 0        1
## 2089   unknown  16   may      541        5    -1        0  unknown 0        0
## 2090   unknown  23   may      339        1    -1        0  unknown 0        0
## 2091  cellular   2   apr      293        2   314        2  failure 0        0
## 2092  cellular  17   apr      112        1    -1        0  unknown 0        0
## 2093   unknown  11   jun      177        8    -1        0  unknown 0        0
## 2094   unknown  28   may      173        4    -1        0  unknown 0        0
## 2095   unknown   3   jun      258        1    -1        0  unknown 0        0
## 2096   unknown  28   may      207        1    -1        0  unknown 0        0
## 2097  cellular  25   aug      279        1   117        1  failure 0        0
## 2098  cellular  19   jul     1148        1   276        2    other 1        0
## 2099  cellular  19   nov      182        1    -1        0  unknown 0        0
## 2100  cellular  18   aug      119        7    -1        0  unknown 0        0
## 2101   unknown   6   may      246        1    -1        0  unknown 0        0
## 2102   unknown  12   jun      137        1    -1        0  unknown 0        0
## 2103  cellular  10   jul       68        1    -1        0  unknown 0        0
## 2104  cellular  28   jan      214        1    -1        0  unknown 0        1
## 2105   unknown  15   may      155        6    -1        0  unknown 0        0
## 2106   unknown  17   jun      638       16    -1        0  unknown 0        0
## 2107  cellular   6   aug      181        2    -1        0  unknown 0        0
## 2108   unknown  21   may      103        1    -1        0  unknown 0        0
## 2109  cellular  29   aug      214        7    -1        0  unknown 0        0
## 2110  cellular  24   feb      104        3    -1        0  unknown 0        0
## 2111   unknown   6   jun       59        3    -1        0  unknown 0        0
## 2112  cellular  29   jul       33        1    -1        0  unknown 0        0
## 2113   unknown  12   jun      153        6    -1        0  unknown 0        0
## 2114  cellular  31   jul       29       10    -1        0  unknown 0        0
## 2115   unknown  15   may      113        1    -1        0  unknown 0        0
## 2116  cellular  10   feb      503        1    -1        0  unknown 1        0
## 2117  cellular  18   aug       22        2    -1        0  unknown 0        0
## 2118  cellular  14   apr      422        4    -1        0  unknown 0        0
## 2119  cellular  29   jan      177        1    -1        0  unknown 0        1
## 2120   unknown  27   may       99        1    -1        0  unknown 0        0
## 2121 telephone   6   apr     1353        2   138        2  success 1        0
## 2122 telephone  13   aug      181        1    -1        0  unknown 0        0
## 2123  cellular  18   jul      516        1    -1        0  unknown 1        0
## 2124  cellular  11   aug      331        7    -1        0  unknown 0        0
## 2125  cellular   7   aug       44        2    -1        0  unknown 0        0
## 2126  cellular  11   aug      230        2    -1        0  unknown 0        0
## 2127  cellular  22   jul     1608       13    -1        0  unknown 1        1
## 2128   unknown  15   may      192        1    -1        0  unknown 0        0
## 2129  cellular   7   may      271        2    -1        0  unknown 0        0
## 2130  cellular  27   oct       96        1   158        1  failure 0        0
## 2131  cellular  14   jan      187        7    -1        0  unknown 1        0
## 2132  cellular  18   may      145        1    -1        0  unknown 0        1
## 2133  cellular  26   feb      771        1   171        1  success 1        0
## 2134  cellular  24   jul      559        2    -1        0  unknown 0        0
## 2135   unknown  29   may      187        3    -1        0  unknown 0        1
## 2136   unknown  16   may       65        3    -1        0  unknown 0        0
## 2137  cellular  18   aug      625        4    -1        0  unknown 1        0
## 2138  cellular  21   nov      268        3    -1        0  unknown 0        0
## 2139  cellular  11   may      128        3    -1        0  unknown 0        0
## 2140  cellular  19   nov      201        2   174        3  success 0        0
## 2141  cellular   7   may      124        1   338        2  failure 0        0
## 2142  cellular   4   feb      260        2    -1        0  unknown 0        0
## 2143   unknown  21   may       86        2    -1        0  unknown 0        1
## 2144  cellular  12   may       30        7    -1        0  unknown 0        0
## 2145  cellular  21   aug      184        3    -1        0  unknown 0        0
## 2146  cellular  30   jan       82        2    -1        0  unknown 0        0
## 2147   unknown   6   jun      223        3    -1        0  unknown 0        0
## 2148  cellular  20   nov       75        2   119        2  success 0        0
## 2149  cellular   9   jul       80        1    -1        0  unknown 0        0
## 2150  cellular  31   jul       43        2    -1        0  unknown 0        0
## 2151 telephone  31   aug      139        1    -1        0  unknown 0        1
## 2152   unknown  19   jun       82        1    -1        0  unknown 0        0
## 2153 telephone  12   may      370        2    -1        0  unknown 0        0
## 2154  cellular  11   jul      271        5    -1        0  unknown 0        1
## 2155  cellular  14   may       61        6    -1        0  unknown 0        0
## 2156 telephone  31   jul       84        6    -1        0  unknown 0        0
## 2157   unknown  28   may      513        2    -1        0  unknown 0        0
## 2158  cellular  29   oct      140        2    -1        0  unknown 0        1
## 2159  cellular  10   jul     1187        3    -1        0  unknown 1        1
## 2160  cellular  31   mar      684        4    -1        0  unknown 0        0
## 2161  cellular  30   jul      142        9    -1        0  unknown 0        0
## 2162  cellular   9   jul      115        2    -1        0  unknown 0        0
## 2163  cellular  29   jul      176        4    -1        0  unknown 0        0
## 2164  cellular  18   jul      610        1    -1        0  unknown 1        0
## 2165  cellular  18   may      261        1    -1        0  unknown 0        0
## 2166  cellular  28   jul       68        3    -1        0  unknown 0        0
## 2167  cellular  18   aug      242        5    -1        0  unknown 0        0
## 2168  cellular  12   may       59        3    -1        0  unknown 0        0
## 2169  cellular  20   nov      184        1    -1        0  unknown 0        0
## 2170  cellular   2   feb      871        4    -1        0  unknown 0        0
## 2171   unknown  23   may      777        2    -1        0  unknown 1        0
## 2172  cellular  22   jul      153        1    -1        0  unknown 0        0
## 2173   unknown   7   may       60        1    -1        0  unknown 0        0
## 2174  cellular  20   aug      129        2    -1        0  unknown 0        0
## 2175   unknown   9   jun       98        1    -1        0  unknown 0        0
## 2176  cellular   8   jul      226        1    -1        0  unknown 0        0
## 2177   unknown   4   jun      193       10    -1        0  unknown 0        0
## 2178  cellular   9   feb      150        3    -1        0  unknown 0        0
## 2179  cellular   3   jun      273        1    -1        0  unknown 0        0
## 2180   unknown  18   jun       74        2    -1        0  unknown 0        0
## 2181  cellular  30   apr      687        1     9        3  success 1        0
## 2182  cellular  31   jul       48        3    -1        0  unknown 0        0
## 2183  cellular  14   may      365        6    36        3  failure 0        0
## 2184   unknown  27   may      374        9    -1        0  unknown 0        0
## 2185  cellular  17   nov       91        2    -1        0  unknown 0        0
## 2186  cellular  21   jul       76        3    -1        0  unknown 0        0
## 2187  cellular   7   sep      337        1   186        1  success 1        0
## 2188  cellular   7   may      239        3    -1        0  unknown 0        1
## 2189   unknown  27   may      167        3    -1        0  unknown 0        1
## 2190  cellular   2   jun      118        2    81        1  success 0        0
## 2191  cellular  20   nov       48        1    -1        0  unknown 0        0
## 2192  cellular  12   aug       96        2    -1        0  unknown 0        0
## 2193   unknown  11   jun      140        1    -1        0  unknown 0        0
## 2194   unknown   6   jun      463        4    -1        0  unknown 0        0
## 2195  cellular  18   may       99        2    -1        0  unknown 0        0
## 2196   unknown   9   may      226        2    -1        0  unknown 0        0
## 2197  cellular   6   feb     1192        3    -1        0  unknown 0        1
## 2198   unknown  16   may      243        3    -1        0  unknown 0        0
## 2199   unknown  26   may      369        1    -1        0  unknown 0        0
## 2200 telephone  30   jul      273        4    -1        0  unknown 0        0
## 2201   unknown  18   jun     1009        1    -1        0  unknown 0        0
## 2202  cellular   4   may       90        4    -1        0  unknown 0        1
## 2203  cellular   8   aug       93        1    -1        0  unknown 0        0
## 2204  cellular   4   may      233        2    -1        0  unknown 0        0
## 2205   unknown   6   jun      262        2    -1        0  unknown 0        0
## 2206  cellular  27   apr       99        1   329        4    other 0        0
## 2207  cellular   5   jul      101        3    -1        0  unknown 0        0
## 2208  cellular  21   nov       65        1    -1        0  unknown 0        0
## 2209  cellular   6   may      667        2    -1        0  unknown 1        0
## 2210   unknown  19   jun       34       31    -1        0  unknown 0        0
## 2211   unknown  28   may      160        2    -1        0  unknown 0        1
## 2212  cellular   3   apr      170        1    -1        0  unknown 0        0
## 2213  cellular  12   aug      234        2    -1        0  unknown 0        0
## 2214  cellular  13   may      354        1   370        2  failure 0        1
## 2215  cellular  26   aug      131        2    -1        0  unknown 0        0
## 2216  cellular   8   jul      606        2    -1        0  unknown 0        1
## 2217  cellular   8   aug      433        2    -1        0  unknown 0        0
## 2218  cellular  21   nov      208        3    91        4  failure 0        0
## 2219  cellular  21   jul      100        4    -1        0  unknown 0        0
## 2220   unknown   3   jun      825        1    -1        0  unknown 0        1
## 2221  cellular  13   may      172        3   173        1    other 0        0
## 2222  cellular  18   aug       71        3    -1        0  unknown 0        0
## 2223  cellular  12   may       13        5    -1        0  unknown 0        1
## 2224  cellular  27   aug      787       13    -1        0  unknown 0        0
## 2225  cellular  11   aug      110        1    -1        0  unknown 0        0
## 2226   unknown  20   may      265        1    -1        0  unknown 0        0
## 2227  cellular  14   may       62        2    -1        0  unknown 0        0
## 2228  cellular   4   feb     1052        2    -1        0  unknown 0        0
## 2229  cellular  19   nov      339        3    -1        0  unknown 0        0
## 2230   unknown  14   may      360        2    -1        0  unknown 0        0
## 2231  cellular   7   jul      126        3    -1        0  unknown 0        0
## 2232  cellular  18   nov      434        2    -1        0  unknown 0        0
## 2233  cellular   7   jul       88        1    -1        0  unknown 0        0
## 2234  cellular  27   aug       38        6    -1        0  unknown 0        0
## 2235   unknown  18   jun       73        4    -1        0  unknown 0        0
## 2236  cellular  25   aug      454        6    -1        0  unknown 0        0
## 2237  cellular  22   aug       73        4    -1        0  unknown 0        0
## 2238  cellular  20   nov       57        1    -1        0  unknown 0        0
## 2239  cellular   7   jul      422        1    -1        0  unknown 0        0
## 2240  cellular  11   may      360        1   370        1    other 0        0
## 2241   unknown   8   may       80        1    -1        0  unknown 0        0
## 2242  cellular  18   may       90        1    -1        0  unknown 0        0
## 2243   unknown  12   may      325        4    -1        0  unknown 0        0
## 2244   unknown   6   may      289        1    -1        0  unknown 0        0
## 2245  cellular  22   feb      287        1   130        1  failure 0        0
## 2246  cellular  17   jul      384        4    -1        0  unknown 0        0
## 2247   unknown  19   jun      394        1    -1        0  unknown 0        0
## 2248   unknown   9   may      390        2    -1        0  unknown 0        0
## 2249   unknown   5   may      204        2    -1        0  unknown 0        1
## 2250   unknown   3   jun      275        1    -1        0  unknown 0        0
## 2251  cellular  17   apr      815        2    -1        0  unknown 0        0
## 2252  cellular   8   mar      111        3   585        6    other 0        0
## 2253  cellular  19   nov       73        1    -1        0  unknown 0        0
## 2254   unknown  14   may      260        3    -1        0  unknown 0        0
## 2255   unknown   4   jun       77        8    -1        0  unknown 0        0
## 2256   unknown  30   may      567        2    -1        0  unknown 0        0
## 2257  cellular  20   apr      207        1    -1        0  unknown 0        0
## 2258  cellular  13   aug      150        4    -1        0  unknown 0        0
## 2259  cellular  21   jul       56        1    -1        0  unknown 0        0
## 2260 telephone  21   apr      403        1    -1        0  unknown 1        0
## 2261  cellular  14   sep      409        1   398        1  failure 1        0
## 2262  cellular  12   may      158        1   351        1  failure 0        0
## 2263   unknown  18   jun      340        3    -1        0  unknown 0        0
## 2264   unknown   6   may      448        1    -1        0  unknown 0        0
## 2265  cellular  19   nov      599        4   100        2  failure 0        0
## 2266  cellular  14   jul       69        2    -1        0  unknown 0        0
## 2267  cellular  14   may     1094        2    -1        0  unknown 1        1
## 2268  cellular  12   may      524        3   326        1    other 0        0
## 2269   unknown  17   jun      205        1    -1        0  unknown 0        0
## 2270   unknown  19   jun      573        1    -1        0  unknown 0        0
## 2271  cellular   6   aug       72        4    -1        0  unknown 0        0
## 2272  cellular   3   jun      157        1    -1        0  unknown 0        0
## 2273  cellular  12   apr      143        1    -1        0  unknown 0        0
## 2274  cellular   4   dec      720        5   536        5  failure 0        0
## 2275  cellular  28   jul      127        6    -1        0  unknown 0        0
## 2276   unknown  28   may      184        2    -1        0  unknown 0        1
## 2277 telephone   7   may      202        2   167        1  failure 0        0
## 2278   unknown  29   may      105        3    -1        0  unknown 0        0
## 2279  cellular  30   jun      121        3   195        2    other 0        1
## 2280  cellular  30   jan      334        1    -1        0  unknown 0        0
## 2281  cellular  20   apr      159        2    -1        0  unknown 0        0
## 2282  cellular  11   may       85        1    -1        0  unknown 0        0
## 2283  cellular  12   may      176        2    89        5  success 1        0
## 2284  cellular   9   apr      494        1    -1        0  unknown 0        0
## 2285   unknown  28   may       66        7    -1        0  unknown 0        0
## 2286  cellular  10   jul      526        1    -1        0  unknown 0        0
## 2287  cellular  17   apr      200        3    -1        0  unknown 0        0
## 2288  cellular  31   jul       98        5    -1        0  unknown 0        0
## 2289   unknown   4   jul       88        1    -1        0  unknown 0        0
## 2290  cellular  10   jul      162        6    -1        0  unknown 0        1
## 2291  cellular   8   may      108        1    -1        0  unknown 0        0
## 2292  cellular   6   may      401        1   336        2  failure 0        0
## 2293  cellular  14   apr      401        1    -1        0  unknown 0        0
## 2294 telephone  11   may      114        1   368        1  failure 0        0
## 2295  cellular  18   aug      100        4    -1        0  unknown 0        0
## 2296  cellular  15   may      238        1    -1        0  unknown 0        1
## 2297   unknown  13   may      125        1    -1        0  unknown 0        1
## 2298  cellular  19   aug      387        8    -1        0  unknown 0        0
## 2299  cellular  28   aug      129        2    -1        0  unknown 0        0
## 2300   unknown   9   jun      559        2    -1        0  unknown 0        0
## 2301  cellular  11   sep      658        4    95        2    other 1        0
## 2302  cellular  29   jan      219        1   246        1  failure 0        0
## 2303   unknown  20   jun       17       10    -1        0  unknown 0        0
## 2304   unknown   5   may      136        2    -1        0  unknown 0        0
## 2305  cellular  21   nov      147        2   179        3  failure 0        0
## 2306  cellular  16   apr      218        1   330        2  failure 0        0
## 2307  cellular  20   nov      766        3    -1        0  unknown 0        0
## 2308 telephone  18   jul      494        2    -1        0  unknown 0        0
## 2309  cellular  22   may      566        7    -1        0  unknown 0        0
## 2310  cellular   6   may      311        3   364        1  failure 0        0
## 2311   unknown   5   jun      166        2    -1        0  unknown 0        0
## 2312  cellular  19   aug      599        3    -1        0  unknown 0        0
## 2313  cellular  18   nov       62        6    -1        0  unknown 0        0
## 2314  cellular  18   feb      185        1    -1        0  unknown 1        1
## 2315 telephone  15   may       36        2   176        2  failure 0        0
## 2316  cellular  15   may      133        1    -1        0  unknown 0        0
## 2317  cellular   6   may      207        1   342        1  failure 0        0
## 2318  cellular  11   jul     1973        2    -1        0  unknown 1        0
## 2319  cellular  21   jul      176        4    -1        0  unknown 0        0
## 2320   unknown  21   may      162        1    -1        0  unknown 0        0
## 2321  cellular  18   aug      445        3    -1        0  unknown 0        0
## 2322  cellular  28   aug      119        2    95        3  success 0        0
## 2323  cellular  17   apr      129        2   148        4    other 0        0
## 2324   unknown  15   may      177        3    -1        0  unknown 0        0
## 2325  cellular   9   jul      125        1    -1        0  unknown 0        0
## 2326  cellular   2   aug      486        1   286        2  failure 0        0
## 2327  cellular  14   may      167        4    -1        0  unknown 0        0
## 2328   unknown   6   may      199        1    -1        0  unknown 0        0
## 2329  cellular  14   may      201        2   365        2  failure 0        0
## 2330  cellular   7   jul      142        3    -1        0  unknown 0        0
## 2331   unknown  26   may      102        2    -1        0  unknown 0        0
## 2332   unknown  18   jun      445        3    -1        0  unknown 0        0
## 2333   unknown   4   jun      654        2    -1        0  unknown 0        1
## 2334  cellular   8   may      346        1   368        1  failure 0        0
## 2335   unknown  14   may      283        8    -1        0  unknown 0        0
## 2336   unknown  14   may      137        2    -1        0  unknown 0        0
## 2337  cellular   7   apr      487        1    -1        0  unknown 0        0
## 2338   unknown  20   may       34        1    -1        0  unknown 0        0
## 2339  cellular  16   apr      429        1    -1        0  unknown 0        0
## 2340   unknown  25   jun      231        1    -1        0  unknown 0        0
## 2341   unknown  20   may      777        3    -1        0  unknown 0        1
## 2342   unknown  21   may      240        1    -1        0  unknown 0        0
## 2343  cellular   3   nov      412        1    -1        0  unknown 1        0
## 2344  cellular  20   aug      171        6    -1        0  unknown 0        0
## 2345  cellular   9   feb      345        5    -1        0  unknown 0        0
## 2346  cellular   7   jul      280        1    -1        0  unknown 0        0
## 2347  cellular  20   aug       98        4    -1        0  unknown 0        0
## 2348  cellular   8   mar      284        2    -1        0  unknown 0        0
## 2349  cellular  15   apr      114        1    -1        0  unknown 0        0
## 2350  cellular   8   may      225        1    -1        0  unknown 0        0
## 2351 telephone  18   may       21        2    -1        0  unknown 0        0
## 2352  cellular  17   nov       89        1   145        1  failure 0        0
## 2353  cellular  29   jan      245        1    92        3  success 0        1
## 2354  cellular  15   may      187        1   367        4  failure 0        1
## 2355  cellular  24   jul      241        3    -1        0  unknown 0        0
## 2356   unknown  21   may      192        1    -1        0  unknown 0        0
## 2357  cellular  26   aug      146        9    -1        0  unknown 0        0
## 2358  cellular   3   feb       35        7   265        5    other 0        0
## 2359  cellular  11   sep      100        2    -1        0  unknown 1        0
## 2360  cellular  13   may       27        5    -1        0  unknown 0        0
## 2361 telephone  29   aug       17       18    -1        0  unknown 0        0
## 2362   unknown  20   may      170        2    -1        0  unknown 0        0
## 2363   unknown  19   may      182        2    -1        0  unknown 0        0
## 2364   unknown   3   jun      327        1    -1        0  unknown 0        0
## 2365   unknown  17   jun      285        1    -1        0  unknown 0        0
## 2366  cellular  14   aug      156        2    -1        0  unknown 1        0
## 2367   unknown  20   jun      228        5    -1        0  unknown 0        0
## 2368  cellular  28   aug      226        9    -1        0  unknown 0        0
## 2369  cellular   6   oct     1246        2    -1        0  unknown 1        0
## 2370 telephone  11   may       75        4    -1        0  unknown 0        0
## 2371   unknown  16   may      218        3    -1        0  unknown 0        0
## 2372  cellular  11   sep      129        2    -1        0  unknown 0        0
## 2373   unknown  13   may      518        1    -1        0  unknown 0        0
## 2374  cellular  21   jul      222        1    -1        0  unknown 0        1
## 2375  cellular   2   sep      140        2    -1        0  unknown 1        0
## 2376  cellular  15   jun      181        2    -1        0  unknown 1        0
## 2377   unknown  14   may       49        1    -1        0  unknown 0        0
## 2378  cellular  21   jul      588        1    -1        0  unknown 0        0
## 2379  cellular  13   may      152        4   366        3  failure 0        1
## 2380  cellular  30   jul       72        9    -1        0  unknown 0        0
## 2381  cellular  11   may      643        2    -1        0  unknown 0        0
## 2382  cellular  20   oct      316        2    92        3  failure 0        0
## 2383   unknown  16   may       46        1    -1        0  unknown 0        1
## 2384   unknown   2   jun      218        2    -1        0  unknown 0        0
## 2385  cellular  12   may      300        1   370        3  failure 0        0
## 2386  cellular  12   aug      145       11    -1        0  unknown 0        0
## 2387 telephone  13   may       43        1    -1        0  unknown 0        0
## 2388  cellular  16   jul      101        3    -1        0  unknown 0        0
## 2389   unknown   1   jul      381        4    -1        0  unknown 0        0
## 2390  cellular   8   apr      245        1    -1        0  unknown 1        0
## 2391 telephone  25   jul      511        1    -1        0  unknown 0        0
## 2392  cellular  16   jul      254        2    -1        0  unknown 0        0
## 2393  cellular  19   aug      321        2    -1        0  unknown 0        0
## 2394  cellular  27   aug      281        5    -1        0  unknown 0        0
## 2395 telephone  29   jul       64        4    -1        0  unknown 0        0
## 2396  cellular   2   aug      108        3   277        1  success 1        0
## 2397   unknown   7   may       96        3    -1        0  unknown 0        0
## 2398   unknown  30   may      206        3    -1        0  unknown 0        0
## 2399   unknown   6   may      310        1    -1        0  unknown 0        0
## 2400  cellular  18   nov      399        1    -1        0  unknown 0        0
## 2401   unknown  20   jun       92        3    -1        0  unknown 0        0
## 2402  cellular  11   may      333        1    -1        0  unknown 0        0
## 2403  cellular  10   jul      114        1    -1        0  unknown 0        0
## 2404  cellular   7   may      245        5   366        2  failure 0        0
## 2405   unknown  19   may      241        1    -1        0  unknown 0        0
## 2406  cellular  19   nov       89        1   175        1    other 0        0
## 2407   unknown  19   may      215        3    -1        0  unknown 0        0
## 2408   unknown   4   jul      165        2    -1        0  unknown 0        0
## 2409   unknown  28   may      328        1    -1        0  unknown 0        1
## 2410  cellular  22   may      157        3    -1        0  unknown 0        0
## 2411   unknown   5   may      357        1    -1        0  unknown 0        0
## 2412   unknown   6   may      230        1    -1        0  unknown 0        0
## 2413  cellular   7   aug      670        1    -1        0  unknown 1        0
## 2414  cellular  20   apr       25        2    -1        0  unknown 0        0
## 2415  cellular  15   may      132        2   359        2  failure 0        0
## 2416  cellular  13   aug      123        2    -1        0  unknown 0        0
## 2417  cellular   5   feb       67        2   202        1  failure 0        0
## 2418   unknown  23   may      116        2    -1        0  unknown 0        1
## 2419   unknown  27   may      157        2    -1        0  unknown 0        0
## 2420 telephone  30   apr       71        2    -1        0  unknown 0        0
## 2421   unknown  27   may       15       10    -1        0  unknown 0        1
## 2422   unknown  28   may      565        2    -1        0  unknown 0        0
## 2423  cellular  21   aug      140        5    -1        0  unknown 0        0
## 2424  cellular  25   may      163        1    -1        0  unknown 0        0
## 2425   unknown  20   jun      375        5    -1        0  unknown 0        0
## 2426  cellular   9   apr      311        1   336        1  failure 0        0
## 2427   unknown   6   may      203        2    -1        0  unknown 0        0
## 2428   unknown   6   may      185        3    -1        0  unknown 0        0
## 2429  cellular  20   apr      268        1    -1        0  unknown 0        0
## 2430  cellular   5   aug      142        2    -1        0  unknown 0        0
## 2431   unknown  15   may      334        3    -1        0  unknown 0        0
## 2432   unknown  18   jun     1365        4    -1        0  unknown 0        0
## 2433   unknown  18   nov      205        1    -1        0  unknown 0        0
## 2434 telephone   4   may      222        6    -1        0  unknown 0        0
## 2435   unknown   7   may      279        1    -1        0  unknown 0        0
## 2436  cellular  11   nov       79        4    -1        0  unknown 0        0
## 2437  cellular  12   may       17        7    -1        0  unknown 0        0
## 2438 telephone  19   nov      142        4   169        5  failure 0        0
## 2439  cellular   5   aug      996        2    -1        0  unknown 0        0
## 2440  cellular  17   nov      190        2    -1        0  unknown 0        0
## 2441  cellular  15   may        6        4    -1        0  unknown 0        1
## 2442  cellular   4   may     1046        3   333        2  success 1        0
## 2443   unknown  30   may       85        2    -1        0  unknown 0        0
## 2444   unknown   6   may      254        2    -1        0  unknown 0        0
## 2445   unknown  14   may      159        2    -1        0  unknown 0        0
## 2446  cellular  20   aug       76        2    -1        0  unknown 0        0
## 2447   unknown  29   may      131        1    -1        0  unknown 0        0
## 2448   unknown   6   may      145        2    -1        0  unknown 0        0
## 2449   unknown   3   jun      268        1    -1        0  unknown 0        0
## 2450  cellular  26   aug      162       13    -1        0  unknown 0        0
## 2451  cellular  22   aug      644        9    -1        0  unknown 0        0
## 2452  cellular   7   may      113        2   345        1    other 0        0
## 2453  cellular  31   jul       10        6    -1        0  unknown 0        0
## 2454  cellular  11   may      565        2    -1        0  unknown 0        0
## 2455  cellular   7   apr      389        1   266        2    other 0        0
## 2456  cellular  14   jul      557        5    -1        0  unknown 0        0
## 2457  cellular   5   may      338        4   288        2    other 0        0
## 2458   unknown  11   jan       28        1    -1        0  unknown 0        0
## 2459  cellular   4   feb      351        2    -1        0  unknown 0        0
## 2460  cellular  28   apr      154        1   182        1  success 0        0
## 2461  cellular  27   aug       11       22    -1        0  unknown 0        0
## 2462  cellular  10   jul       66        1    -1        0  unknown 0        0
## 2463   unknown  15   may      160        1    -1        0  unknown 0        0
## 2464 telephone  17   nov       85        1    -1        0  unknown 0        0
## 2465  cellular  29   aug       91        2    -1        0  unknown 0        0
## 2466  cellular   2   feb      608        1    -1        0  unknown 0        0
## 2467  cellular  18   may      160        2    -1        0  unknown 0        0
## 2468   unknown  16   may        4        2    -1        0  unknown 0        0
## 2469  cellular   3   jul      122        1    72        1  failure 0        0
## 2470  cellular   6   aug      275        1    -1        0  unknown 0        0
## 2471   unknown  13   may      266        2    -1        0  unknown 0        0
## 2472  cellular  27   aug      267        3    -1        0  unknown 0        0
## 2473   unknown  15   may      193        5    -1        0  unknown 0        0
## 2474  cellular  14   may       12        8    -1        0  unknown 0        0
## 2475  cellular   7   aug      119        1    99        3  failure 0        0
## 2476  cellular  13   may      364        2   343        4  failure 0        0
## 2477  cellular   4   jun      578        2    -1        0  unknown 1        0
## 2478   unknown  28   may        8        4    -1        0  unknown 0        1
## 2479  cellular  23   apr      164        1    -1        0  unknown 0        0
## 2480  cellular  22   may      685        1   101        1    other 1        1
## 2481  cellular   3   feb      224        1    -1        0  unknown 0        0
## 2482  cellular  17   jul      923        2    -1        0  unknown 1        0
## 2483 telephone  11   may      267        1   369        1  failure 0        0
## 2484   unknown   2   jun      159        1    -1        0  unknown 0        0
## 2485  cellular  22   jul      314        2    -1        0  unknown 0        0
## 2486  cellular   6   apr     1138        2   138        1  failure 1        0
## 2487   unknown  16   may      427        3    -1        0  unknown 0        0
## 2488   unknown  12   may      346        4    -1        0  unknown 0        0
## 2489  cellular   3   jun      539        1    -1        0  unknown 1        0
## 2490  cellular  14   may      380        3    -1        0  unknown 0        0
## 2491   unknown  13   may      227        2    -1        0  unknown 0        0
## 2492 telephone  23   apr       77        2    -1        0  unknown 0        0
## 2493   unknown  11   jun      138        1    -1        0  unknown 0        0
## 2494   unknown  19   jun      142        1    -1        0  unknown 0        0
## 2495  cellular  19   nov      697        2   184        3  failure 0        0
## 2496  cellular   6   may       84        1   282        4  failure 0        0
## 2497  cellular   5   feb       52        1   253        2  failure 0        0
## 2498   unknown  27   may      318        1    -1        0  unknown 0        0
## 2499   unknown   9   jun      100        1    -1        0  unknown 0        0
## 2500   unknown  14   may      622        1    -1        0  unknown 0        0
## 2501   unknown   9   jul      297        5    -1        0  unknown 0        0
## 2502  cellular  17   apr      300        3   302        3  failure 0        0
## 2503   unknown   3   jun      174        1    -1        0  unknown 0        0
## 2504   unknown   2   jun      562        3    -1        0  unknown 0        0
## 2505  cellular   3   jul      658        3    -1        0  unknown 1        1
## 2506  cellular   8   jul      188        2    82        4    other 0        0
## 2507  cellular  16   sep      190        1    -1        0  unknown 1        1
## 2508  cellular   9   jun      106        4    -1        0  unknown 0        0
## 2509  cellular  13   may      101        3    -1        0  unknown 0        1
## 2510  cellular  11   may       34        1   361        7  failure 0        0
## 2511  cellular   2   feb       60        1   271        1  failure 0        0
## 2512  cellular  14   jul      221        3    -1        0  unknown 0        0
## 2513  cellular  29   jan      373        1    -1        0  unknown 0        0
## 2514   unknown   6   may      208        3    -1        0  unknown 0        0
## 2515  cellular   2   jul      356        1    -1        0  unknown 1        0
## 2516  cellular  24   may      260        1    77        9  failure 0        0
## 2517  cellular   8   aug       41        2    -1        0  unknown 0        0
## 2518  cellular  17   nov      696        2    -1        0  unknown 1        0
## 2519   unknown  17   jun      100        8    -1        0  unknown 0        0
## 2520  cellular  17   nov      360        2    -1        0  unknown 0        0
## 2521  cellular  15   jul       83        2    -1        0  unknown 0        0
## 2522  cellular  21   jul      898        5    -1        0  unknown 0        0
## 2523 telephone  13   aug      562        2    -1        0  unknown 1        0
## 2524  cellular   9   sep      204        1   365        1  success 1        0
## 2525   unknown  26   may      796        1    -1        0  unknown 0        1
## 2526 telephone  13   may      125        2   370        3  failure 0        0
## 2527  cellular  15   jun      318        3    -1        0  unknown 0        0
## 2528   unknown  27   may      207        2    -1        0  unknown 0        0
## 2529   unknown   4   jun      151        2    -1        0  unknown 0        0
## 2530  cellular  15   may      157        4    -1        0  unknown 0        0
## 2531   unknown  20   jun       17        2    -1        0  unknown 0        0
## 2532  cellular  22   sep      208        2    -1        0  unknown 1        0
## 2533  cellular   2   jun      269        1    92        2  failure 0        0
## 2534  cellular  12   may      189        1   326        5  failure 0        0
## 2535  cellular  17   nov      266        2    -1        0  unknown 0        0
## 2536  cellular   9   feb      102        4    -1        0  unknown 0        0
## 2537   unknown   9   may      202        2    -1        0  unknown 0        0
## 2538 telephone  28   jan       28        1    -1        0  unknown 0        0
## 2539 telephone  15   jul      469        4    -1        0  unknown 0        0
## 2540   unknown  12   may      246        1    -1        0  unknown 0        0
## 2541  cellular  31   jul      297        1    -1        0  unknown 0        0
## 2542   unknown  21   may      179        1    -1        0  unknown 0        0
## 2543  cellular  12   may      430        1    50        3  success 1        0
## 2544 telephone  31   jul      166        8    -1        0  unknown 0        0
## 2545 telephone  18   jul       11        3    -1        0  unknown 0        0
## 2546 telephone  25   aug      153        1    -1        0  unknown 0        0
## 2547  cellular  30   oct      212        2    -1        0  unknown 1        0
## 2548  cellular  22   jun      177        5   138        1  failure 0        0
## 2549  cellular  21   apr      224        2   182        1  success 1        0
## 2550 telephone  16   jul       61       14    -1        0  unknown 0        0
## 2551  cellular  18   nov      288        1    -1        0  unknown 0        0
## 2552   unknown  29   may       27        1    -1        0  unknown 0        0
## 2553   unknown  12   jun      190        2    -1        0  unknown 0        0
## 2554  cellular   1   oct       67        6   141       13  failure 0        0
## 2555   unknown   2   jul      957        3    -1        0  unknown 0        0
## 2556  cellular   8   may      306        1   262        1    other 0        0
## 2557  cellular  19   nov      183        1    -1        0  unknown 0        0
## 2558  cellular  20   nov      997        2    -1        0  unknown 0        0
## 2559 telephone  30   jul       77        5    -1        0  unknown 0        0
## 2560  cellular   7   apr     1096        1    -1        0  unknown 0        0
## 2561  cellular  31   jul       69        3    -1        0  unknown 0        0
## 2562  cellular  24   jul      262        2    -1        0  unknown 0        0
## 2563  cellular  30   jan      643        1    -1        0  unknown 0        0
## 2564  cellular  11   dec      234        1    -1        0  unknown 0        0
## 2565 telephone  26   jan     1616        1    95        2  success 1        0
## 2566   unknown  13   may      118        1    -1        0  unknown 0        0
## 2567  cellular  30   jul      652        2    -1        0  unknown 0        0
## 2568  cellular   2   feb       96        2   208        1  failure 0        0
## 2569  cellular   5   feb      410        1    -1        0  unknown 0        1
## 2570  cellular   2   feb       91        1    -1        0  unknown 0        0
## 2571  cellular  17   apr       52        1    -1        0  unknown 0        1
## 2572  cellular   7   jul      500        2    -1        0  unknown 0        0
## 2573  cellular   8   apr      417        2    57        3  failure 0        0
## 2574  cellular  30   jul      341        5    -1        0  unknown 0        0
## 2575  cellular  28   jan      155        1    -1        0  unknown 0        0
## 2576  cellular  17   apr      359        1    -1        0  unknown 0        0
## 2577  cellular  22   jun      522        1   183        2  success 1        0
## 2578 telephone  17   aug      199        1    -1        0  unknown 1        0
## 2579  cellular  14   may        9        6    -1        0  unknown 0        0
## 2580   unknown  19   jun      405        2    -1        0  unknown 0        0
## 2581  cellular   1   oct      760        1    -1        0  unknown 0        0
## 2582  cellular  14   may      532        1   358        1  failure 0        0
## 2583   unknown  14   may      302       16    -1        0  unknown 0        0
## 2584 telephone  31   jul      181        2    -1        0  unknown 0        0
## 2585  cellular  20   aug      117        4    -1        0  unknown 0        0
## 2586  cellular  26   aug       71        4    -1        0  unknown 0        0
## 2587  cellular  19   nov      190        1    -1        0  unknown 0        0
## 2588  cellular  15   may      144        1   365        1  failure 0        0
## 2589  cellular   2   feb       75        2    -1        0  unknown 0        0
## 2590  cellular  22   aug       82        2    -1        0  unknown 0        0
## 2591   unknown  27   may      246        1    -1        0  unknown 0        0
## 2592  cellular   5   aug      171        2    -1        0  unknown 0        0
## 2593  cellular  30   apr      126        3    -1        0  unknown 0        0
## 2594   unknown  13   may      280        1    -1        0  unknown 0        0
## 2595  cellular  19   nov       62        1    -1        0  unknown 0        0
## 2596  cellular  12   may       43        3   369        2  failure 0        0
## 2597   unknown  16   may       49        1    -1        0  unknown 0        0
## 2598   unknown  18   jun      227        1    -1        0  unknown 0        0
## 2599   unknown   6   may      412        1    -1        0  unknown 0        0
## 2600   unknown  12   may      480        1    -1        0  unknown 0        0
## 2601  cellular  29   aug        8       10    -1        0  unknown 0        0
## 2602  cellular  13   may      147        2    -1        0  unknown 0        0
## 2603  cellular  15   may      259        3   353        3  failure 0        0
## 2604 telephone  29   jul       49        4    -1        0  unknown 0        1
## 2605  cellular  14   may      877        2   345        5  failure 0        0
## 2606 telephone  15   feb      112        5    94       15  success 0        0
## 2607   unknown  20   jun      100        3    -1        0  unknown 0        0
## 2608   unknown  27   may      148        4    -1        0  unknown 0        0
## 2609  cellular  18   aug       61        4    -1        0  unknown 0        0
## 2610  cellular   8   aug      229        2    -1        0  unknown 0        0
## 2611  cellular  18   aug       65        6    -1        0  unknown 0        0
## 2612  cellular  19   feb      702        2   189        2  failure 0        0
## 2613  cellular  18   jul      184        3    -1        0  unknown 0        0
## 2614  cellular   5   feb       61        1   275        1  failure 0        0
## 2615  cellular  15   may      109        3    -1        0  unknown 0        0
## 2616   unknown  19   jun      453        1    -1        0  unknown 0        0
## 2617  cellular  11   may      327        2    -1        0  unknown 0        0
## 2618  cellular  14   aug      152        2    -1        0  unknown 0        0
## 2619  cellular   2   feb      430        1    -1        0  unknown 1        0
## 2620  cellular  20   nov      653        1    -1        0  unknown 1        0
## 2621   unknown   6   may       88        5    -1        0  unknown 0        0
## 2622 telephone   4   may      354        2   335        3    other 0        0
## 2623  cellular   1   apr      124        1    -1        0  unknown 0        1
## 2624  cellular   5   may      145        1   365        2  failure 0        0
## 2625  cellular  21   nov       39        4   182        3  failure 0        0
## 2626  cellular   6   may       34        9    -1        0  unknown 0        0
## 2627  cellular  19   nov      103        1    -1        0  unknown 0        0
## 2628  cellular  20   nov      305        2    -1        0  unknown 0        0
## 2629  cellular  18   nov      188        1    -1        0  unknown 0        0
## 2630  cellular   5   feb       43        1   261        3  failure 0        0
## 2631  cellular   8   may      154        2   350        1  failure 0        0
## 2632  cellular  23   jun      181        1   320        1    other 0        0
## 2633  cellular  15   may       38        7   332        6  failure 0        0
## 2634  cellular   6   feb     1019        2    -1        0  unknown 1        0
## 2635   unknown   9   may      206        2    -1        0  unknown 0        0
## 2636  cellular  18   jul      541        7    -1        0  unknown 0        0
## 2637  cellular   8   aug       82        2    -1        0  unknown 0        0
## 2638  cellular  21   aug      180        2    -1        0  unknown 0        0
## 2639  cellular  29   aug       76        8    -1        0  unknown 0        0
## 2640  cellular  14   aug      123        2    -1        0  unknown 0        0
## 2641   unknown  29   may     1059        2    -1        0  unknown 1        0
## 2642   unknown  16   jun      108        2    -1        0  unknown 0        0
## 2643  cellular  18   nov      120        1    -1        0  unknown 0        0
## 2644  cellular   6   aug      227        3    -1        0  unknown 0        0
## 2645  cellular  11   aug      239        4    -1        0  unknown 0        0
## 2646   unknown  27   may      597        3    -1        0  unknown 0        0
## 2647  cellular  29   jan       58        1   266        1  failure 0        0
## 2648  cellular  17   nov      412        1    -1        0  unknown 0        0
## 2649  cellular  25   aug       93        9    -1        0  unknown 0        0
## 2650  cellular  17   nov      324        1   172        1  failure 0        0
## 2651  cellular  21   nov      149        4   186        1    other 0        0
## 2652 telephone  16   jun       64        1    -1        0  unknown 0        0
## 2653  cellular  29   jul      108        2    -1        0  unknown 0        0
## 2654  cellular  31   jul       44        7    -1        0  unknown 0        0
## 2655  cellular  11   aug      151        1    -1        0  unknown 0        0
## 2656   unknown  20   jun        8        6    -1        0  unknown 0        0
## 2657   unknown  15   may       98        1    -1        0  unknown 0        0
## 2658  cellular  22   aug       79        4    -1        0  unknown 0        0
## 2659   unknown  26   may       99        1    -1        0  unknown 0        0
## 2660   unknown  13   may      276        1    -1        0  unknown 0        0
## 2661  cellular  21   nov        7        5    -1        0  unknown 0        0
## 2662   unknown  18   jun      680        2    -1        0  unknown 0        1
## 2663   unknown   2   jun      364       13    -1        0  unknown 0        0
## 2664   unknown  28   may      212        1    -1        0  unknown 0        1
## 2665   unknown   2   jun      689        3    -1        0  unknown 0        0
## 2666   unknown   2   jun      171        2    -1        0  unknown 0        0
## 2667   unknown  19   jun      102        3    -1        0  unknown 0        0
## 2668  cellular   5   aug      138        1    -1        0  unknown 0        0
## 2669  cellular   8   jul      483        2    -1        0  unknown 0        1
## 2670   unknown  19   may      467        4    -1        0  unknown 0        0
## 2671  cellular  18   nov       74        2   110        4  failure 0        0
## 2672  cellular   8   aug       88        2    -1        0  unknown 0        0
## 2673  cellular   3   feb      245        4    -1        0  unknown 0        0
## 2674   unknown   5   jun      142        2    -1        0  unknown 0        0
## 2675 telephone   6   feb      110        1    -1        0  unknown 0        0
## 2676   unknown  20   jun       20        5    -1        0  unknown 0        0
## 2677  cellular  30   jan       78        2    -1        0  unknown 0        1
## 2678  cellular  17   apr       71        2   345        2  success 0        0
## 2679   unknown  16   jun       77        5    -1        0  unknown 0        0
## 2680  cellular  27   aug       97        4    -1        0  unknown 0        0
## 2681  cellular   3   feb      206        3    -1        0  unknown 0        0
## 2682  cellular  15   jul      156        4    -1        0  unknown 0        0
## 2683  cellular  14   may      700        4    92        7  success 1        0
## 2684  cellular  17   apr      251        1    -1        0  unknown 0        0
## 2685 telephone  11   may      172        5   371        5  failure 0        1
## 2686  cellular   8   jul      161        1    -1        0  unknown 0        1
## 2687  cellular  13   may       69        1   260        6  failure 0        0
## 2688 telephone   8   dec      170        1    -1        0  unknown 0        0
## 2689  cellular  21   oct      287        1    -1        0  unknown 1        0
## 2690  cellular   3   jun      254        1    96        2  failure 0        0
## 2691   unknown   5   jun       91        2    -1        0  unknown 0        0
## 2692  cellular  25   jul       23       16    -1        0  unknown 0        0
## 2693  cellular  21   aug       90        1    91        1  failure 0        0
## 2694  cellular  11   jul      117        3    -1        0  unknown 0        0
## 2695   unknown   2   jun      304        2    -1        0  unknown 0        0
## 2696  cellular  18   nov      342        2   120        4  failure 0        0
## 2697   unknown   7   may      129        5    -1        0  unknown 0        0
## 2698  cellular  18   jul      560        1    -1        0  unknown 1        0
## 2699   unknown  14   may       75        1    -1        0  unknown 0        0
## 2700   unknown   4   jun      245        1    -1        0  unknown 0        0
## 2701  cellular   2   feb       64        1    -1        0  unknown 0        0
## 2702  cellular  15   jul      132        3    -1        0  unknown 0        0
## 2703   unknown  14   may       20       11    -1        0  unknown 0        0
## 2704   unknown  15   may      157        5    -1        0  unknown 0        0
## 2705  cellular  11   may       67        1    -1        0  unknown 0        0
## 2706   unknown  23   oct      518        1   147        2  success 1        0
## 2707  cellular   3   apr      148        2    -1        0  unknown 0        0
## 2708 telephone  14   jan      372        1   196        2  success 1        0
## 2709  cellular  18   nov       79        1    -1        0  unknown 0        0
## 2710  cellular  14   aug      391        3   106        1  failure 1        0
## 2711   unknown   3   jun       94        2    -1        0  unknown 0        0
## 2712  cellular  20   nov      895        1   183        2  failure 0        0
## 2713   unknown  16   jun      356        2    -1        0  unknown 0        0
## 2714  cellular   2   jun      541        3    -1        0  unknown 1        0
## 2715 telephone  23   oct      282        2    -1        0  unknown 1        0
## 2716  cellular  11   may      480        2    -1        0  unknown 0        0
## 2717  cellular   6   may      258        9    -1        0  unknown 0        0
## 2718  cellular  14   may      105        1    -1        0  unknown 0        0
## 2719  cellular  13   may      358        2   174        1  failure 0        0
## 2720 telephone  19   nov      214        2   174        2  success 0        0
## 2721  cellular  19   aug       12       16    -1        0  unknown 0        0
## 2722  cellular  25   aug      484        4    -1        0  unknown 0        0
## 2723 telephone  20   nov       36        3    -1        0  unknown 0        0
## 2724  cellular   2   feb      475        1    -1        0  unknown 0        0
## 2725  cellular   7   aug      145        2    -1        0  unknown 0        0
## 2726   unknown  20   jun       48        1    -1        0  unknown 0        0
## 2727  cellular  18   may      233        1    -1        0  unknown 0        0
## 2728  cellular  19   nov      342        2    -1        0  unknown 0        0
## 2729  cellular  21   nov       47        1    -1        0  unknown 0        0
## 2730   unknown   8   may      149        1    -1        0  unknown 0        0
## 2731  cellular   9   sep      679        1    -1        0  unknown 1        1
## 2732  cellular   4   feb      184        2    -1        0  unknown 0        0
## 2733 telephone  15   jul       32        7    -1        0  unknown 0        0
## 2734  cellular   3   jun      167        1    -1        0  unknown 0        0
## 2735   unknown  27   may      290        2    -1        0  unknown 0        1
## 2736  cellular  24   jul       63        1    -1        0  unknown 0        0
## 2737  cellular   7   apr      197        1    -1        0  unknown 0        0
## 2738   unknown   3   jun      361        3    -1        0  unknown 0        0
## 2739  cellular  17   nov      191        2    -1        0  unknown 0        0
## 2740  cellular  12   feb      637        1   183        1  success 1        0
## 2741  cellular   8   jul      658        2    -1        0  unknown 1        1
## 2742   unknown  29   may      789        3    -1        0  unknown 1        1
## 2743   unknown  19   jun      216        2    -1        0  unknown 0        0
## 2744  cellular  13   oct       78        3    -1        0  unknown 0        0
## 2745  cellular   4   aug      315        1    -1        0  unknown 0        0
## 2746  cellular  28   jul       33       31    -1        0  unknown 0        1
## 2747  cellular  16   jul      406        4    -1        0  unknown 0        0
## 2748   unknown  20   jun      139        2    -1        0  unknown 0        0
## 2749  cellular  10   feb      153        1    92       13  success 1        0
## 2750 telephone  27   oct      521        2    -1        0  unknown 0        0
## 2751  cellular  28   jul      114        2    -1        0  unknown 0        0
## 2752   unknown  23   may       63        2    -1        0  unknown 0        0
## 2753  cellular   5   may       39        1    -1        0  unknown 0        0
## 2754 telephone  30   apr       44        1    -1        0  unknown 0        0
## 2755  cellular  18   may      126        1    -1        0  unknown 0        0
## 2756  cellular  29   jan      354        1   197        1  failure 0        0
## 2757  cellular   6   jul      117        4    -1        0  unknown 0        0
## 2758 telephone  18   may       15        7   178        1    other 0        0
## 2759  cellular  29   aug      300        2    -1        0  unknown 0        0
## 2760   unknown   9   may     1534        2    -1        0  unknown 0        0
## 2761  cellular  19   aug      211        2    -1        0  unknown 0        0
## 2762  cellular   3   sep      299        1    -1        0  unknown 1        0
## 2763   unknown  18   jun     1062        4    -1        0  unknown 0        0
## 2764 telephone  26   oct      280        2    97        3  success 0        1
## 2765  cellular  22   aug       58        2    -1        0  unknown 0        0
## 2766  cellular  14   jul      103        4    -1        0  unknown 0        0
## 2767  cellular   5   feb      415        2   272        2  failure 0        0
## 2768  cellular  18   nov      163        2   110       15  failure 0        0
## 2769  cellular   3   feb       71        1    -1        0  unknown 0        0
## 2770  cellular  15   jul       88        3    -1        0  unknown 0        0
## 2771   unknown  26   may      127        1    -1        0  unknown 0        0
## 2772   unknown   8   may      185        7    -1        0  unknown 0        0
## 2773  cellular   3   apr      277        2   333        1  failure 0        0
## 2774  cellular  12   aug      711        3    -1        0  unknown 0        0
## 2775   unknown   9   jun      142        3    -1        0  unknown 0        0
## 2776  cellular  27   nov       65        3    -1        0  unknown 0        0
## 2777  cellular  28   jan      103        2    -1        0  unknown 0        0
## 2778 telephone  22   may      152        1    -1        0  unknown 0        0
## 2779  cellular   4   feb       71        1   243        3  failure 0        0
## 2780  cellular  13   aug      255        1    -1        0  unknown 0        0
## 2781  cellular   9   feb      106        4    -1        0  unknown 0        1
## 2782   unknown   2   jun      389        1    -1        0  unknown 0        0
## 2783  cellular  25   aug      160        6    -1        0  unknown 0        0
## 2784  cellular  29   aug      299        3    -1        0  unknown 0        0
## 2785   unknown  20   jun       78        7    -1        0  unknown 0        0
## 2786  cellular  23   jul      112        1    -1        0  unknown 0        0
## 2787  cellular  10   nov      133        3    89        1  failure 0        0
## 2788  cellular  17   nov       48        2    -1        0  unknown 0        0
## 2789   unknown  19   jun      106        2    -1        0  unknown 0        0
## 2790  cellular  13   may      185        4    -1        0  unknown 0        0
## 2791   unknown  12   jun       71       12    -1        0  unknown 0        0
## 2792   unknown  21   may      229        2    -1        0  unknown 0        0
## 2793  cellular  26   aug      115        1    93        2  failure 0        1
## 2794 telephone  11   aug       80       10    -1        0  unknown 0        0
## 2795  cellular  22   aug      306        4    -1        0  unknown 0        0
## 2796  cellular   9   sep      234        1   100        1  failure 1        0
## 2797   unknown  27   may      233        2    -1        0  unknown 0        0
## 2798  cellular  13   may      197        2    -1        0  unknown 0        0
## 2799   unknown  13   may      297        3    -1        0  unknown 0        0
## 2800  cellular  21   aug      169        5    -1        0  unknown 0        0
## 2801  cellular  18   nov      583        2    -1        0  unknown 0        0
## 2802  cellular  20   nov      116        2    -1        0  unknown 0        0
## 2803   unknown  20   may      227        9    -1        0  unknown 0        0
## 2804  cellular  20   nov     1258        2   122        2    other 1        0
## 2805   unknown   3   jun       87        7    -1        0  unknown 0        0
## 2806  cellular  25   aug      132        2    -1        0  unknown 0        0
## 2807   unknown   9   may      120        1    -1        0  unknown 0        0
## 2808  cellular  17   nov      173        1    -1        0  unknown 0        0
## 2809  cellular   7   jul      309        1    -1        0  unknown 0        0
## 2810  cellular  10   jul      374        3    -1        0  unknown 0        0
## 2811  cellular  14   jul      173        6    -1        0  unknown 0        0
## 2812  cellular  23   jul      136        1    -1        0  unknown 0        0
## 2813   unknown  16   jun      607        2    -1        0  unknown 0        0
## 2814  cellular   2   feb       49        6    -1        0  unknown 0        0
## 2815  cellular  28   jan      227        1    -1        0  unknown 0        0
## 2816  cellular  20   aug      195        1    -1        0  unknown 1        0
## 2817   unknown  20   may      181        6    -1        0  unknown 0        0
## 2818   unknown  13   may      434        2    -1        0  unknown 0        0
## 2819  cellular   2   mar       59        2    -1        0  unknown 0        0
## 2820   unknown  28   may       50        2    -1        0  unknown 0        0
## 2821  cellular   4   may      198        2    88        1    other 0        0
## 2822  cellular  30   jul      409        4    -1        0  unknown 0        0
## 2823  cellular  27   may     1576        1    -1        0  unknown 0        0
## 2824   unknown  26   may      404        1    -1        0  unknown 0        1
## 2825  cellular  17   apr       70        1   344        1  failure 0        0
## 2826   unknown   9   jun       96        1    -1        0  unknown 0        0
## 2827  cellular  26   may      131        2    -1        0  unknown 1        1
## 2828  cellular   2   feb       68        1    -1        0  unknown 0        0
## 2829  cellular  31   jul      134        2    -1        0  unknown 0        0
## 2830  cellular   5   jul      182        1    -1        0  unknown 0        0
## 2831   unknown  12   may      181        2    -1        0  unknown 0        1
## 2832  cellular  19   nov      405        2    -1        0  unknown 0        0
## 2833  cellular  20   aug      162        3    -1        0  unknown 0        0
## 2834 telephone   8   may      186        4   358       11  failure 0        0
## 2835   unknown  29   may       96        5    -1        0  unknown 0        0
## 2836  cellular   5   may       28        1    -1        0  unknown 0        0
## 2837  cellular  18   may      143        1    -1        0  unknown 0        1
## 2838 telephone  30   jan      103        3    -1        0  unknown 0        0
## 2839  cellular  17   apr      609        2   266        2  failure 0        0
## 2840  cellular  26   aug      265       16    -1        0  unknown 0        0
## 2841  cellular  15   may      169        1   346        1  failure 0        1
## 2842   unknown  19   jun      196        2    -1        0  unknown 0        0
## 2843  cellular  19   aug      125        4    -1        0  unknown 0        0
## 2844 telephone  21   jul     1130        8    -1        0  unknown 1        0
## 2845  cellular  11   aug      295        3    -1        0  unknown 0        0
## 2846  cellular   8   aug      153        8    -1        0  unknown 0        0
## 2847  cellular  17   nov      454        1    -1        0  unknown 1        0
## 2848  cellular  15   may      212        4   312        6    other 0        1
## 2849   unknown  20   may      107        2    -1        0  unknown 0        0
## 2850  cellular   4   aug      288        1   181        2  failure 1        0
## 2851   unknown  14   may      192        1    -1        0  unknown 0        0
## 2852  cellular  28   aug       49        7    -1        0  unknown 0        0
## 2853  cellular  15   may      224        1    -1        0  unknown 0        1
## 2854  cellular  10   jul      439        1    -1        0  unknown 0        0
## 2855  cellular   6   may      133        1    -1        0  unknown 0        0
## 2856   unknown  16   may      124        1    -1        0  unknown 0        1
## 2857  cellular  18   may      165        2    -1        0  unknown 0        1
## 2858  cellular  27   feb       87        2    -1        0  unknown 1        0
## 2859  cellular  19   aug      221       12    -1        0  unknown 0        0
## 2860  cellular  13   may      129        1    -1        0  unknown 0        1
## 2861  cellular  22   sep      175        1   184        2  success 1        1
## 2862  cellular  11   may       66        3    -1        0  unknown 0        0
## 2863  cellular  21   apr      278        3    -1        0  unknown 1        0
## 2864  cellular  14   jul      138        3    -1        0  unknown 0        0
## 2865   unknown  27   may      359        6    -1        0  unknown 0        0
## 2866  cellular  13   may      167        1    -1        0  unknown 0        1
## 2867  cellular  12   may      341        1    -1        0  unknown 0        1
## 2868  cellular   9   apr      339        1    -1        0  unknown 0        0
## 2869   unknown  15   may      156       13    -1        0  unknown 0        0
## 2870   unknown  27   may       85       16    -1        0  unknown 0        0
## 2871   unknown  29   may      637        3    -1        0  unknown 0        1
## 2872  cellular  12   aug      129        9    -1        0  unknown 0        0
## 2873  cellular   6   aug      358        2    -1        0  unknown 0        0
## 2874   unknown  23   feb       20        1    -1        0  unknown 0        0
## 2875  cellular   7   aug      142        2    -1        0  unknown 0        0
## 2876  cellular   7   aug      141        1    -1        0  unknown 0        0
## 2877   unknown   9   jun      174        9    -1        0  unknown 0        0
## 2878 telephone  21   nov       10        3    -1        0  unknown 0        0
## 2879   unknown  12   jun      307        2    -1        0  unknown 0        0
## 2880  cellular  31   jul     1739        7    -1        0  unknown 0        0
## 2881  cellular  12   may      360        1   173        1    other 0        0
## 2882  cellular   8   sep      169        1    -1        0  unknown 1        1
## 2883  cellular  17   apr      122        1   338        2  failure 0        0
## 2884   unknown  12   jun      130        2    -1        0  unknown 0        0
## 2885   unknown  12   may      181        4    -1        0  unknown 0        1
## 2886 telephone   8   may      267        3    -1        0  unknown 0        0
## 2887   unknown  30   may      115        6    -1        0  unknown 0        0
## 2888  cellular  21   jul      105       10    -1        0  unknown 0        0
## 2889  cellular  18   nov      213        1    -1        0  unknown 0        0
## 2890  cellular  13   jul      195        2    91       10  success 1        1
## 2891   unknown   4   jun      131        2    -1        0  unknown 0        0
## 2892  cellular  21   aug      126        2    -1        0  unknown 0        0
## 2893  cellular   7   oct      301        1   216        2  failure 0        0
## 2894  cellular   5   feb      277        1   169        2  failure 0        0
## 2895  cellular  21   jul      551        8    -1        0  unknown 0        0
## 2896  cellular  18   jul     1127        3    -1        0  unknown 1        0
## 2897  cellular  25   aug      103        6    -1        0  unknown 0        0
## 2898  cellular  17   nov      222        2    -1        0  unknown 0        0
## 2899  cellular  20   nov      153        2   183        2  failure 0        0
## 2900  cellular  18   may      173        1    -1        0  unknown 0        0
## 2901  cellular  18   may      427        1    -1        0  unknown 1        0
## 2902  cellular  30   apr       78        1    84        1  failure 0        0
## 2903   unknown  18   jun      108        2    -1        0  unknown 0        0
## 2904  cellular   5   feb      335        1    -1        0  unknown 0        1
## 2905  cellular   5   may      160        1    -1        0  unknown 0        0
## 2906  cellular  17   jul      309        2    -1        0  unknown 0        0
## 2907  cellular  12   aug      106        2    -1        0  unknown 0        0
## 2908  cellular   2   feb      133        3     5        2    other 0        0
## 2909 telephone  14   aug       31        2    -1        0  unknown 0        0
## 2910  cellular  23   jul      711        1    -1        0  unknown 0        0
## 2911  cellular  28   jul      496        2   182       11  success 1        0
## 2912   unknown   6   jun       73        1    -1        0  unknown 0        0
## 2913  cellular  26   may       71        5    40        4  failure 0        0
## 2914  cellular  22   aug       82        2    -1        0  unknown 0        0
## 2915  cellular  13   nov      210        1    93        1  success 1        1
## 2916  cellular  22   may       43        1    -1        0  unknown 0        1
## 2917  cellular   7   may      798        2    -1        0  unknown 1        1
## 2918   unknown  20   jun      237        3    -1        0  unknown 0        0
## 2919  cellular  11   aug       82        2    -1        0  unknown 0        0
## 2920  cellular   7   may       66        1   359        1  failure 0        0
## 2921  cellular   3   feb      841        3    -1        0  unknown 0        0
## 2922   unknown   7   may      376        2    -1        0  unknown 0        0
## 2923  cellular   3   nov      217        1    70        2  failure 1        0
## 2924  cellular  18   nov       76        3    -1        0  unknown 0        0
## 2925  cellular  14   oct      216        1    57        1  failure 1        0
## 2926  cellular  22   aug       78        2    -1        0  unknown 0        0
## 2927   unknown  17   jun      243        1    -1        0  unknown 0        0
## 2928  cellular  30   apr      249        1    86        3  failure 0        0
## 2929  cellular  19   aug      190        2    -1        0  unknown 0        0
## 2930   unknown   6   jun      685        3    -1        0  unknown 1        0
## 2931  cellular  28   jan      430        1    -1        0  unknown 0        0
## 2932  cellular   8   may      206        1    -1        0  unknown 0        0
## 2933  cellular  11   aug      272        4    -1        0  unknown 0        0
## 2934  cellular  15   may      103        3    -1        0  unknown 0        0
## 2935   unknown  30   may      123        1    -1        0  unknown 0        0
## 2936   unknown  15   may      875        5    -1        0  unknown 0        0
## 2937  cellular  15   may       66        1    -1        0  unknown 0        0
## 2938  cellular  15   may      153        2    -1        0  unknown 1        0
## 2939  cellular  13   aug      204        3   105        1  failure 1        1
## 2940   unknown  16   may      300        1    -1        0  unknown 0        1
## 2941   unknown  13   may      163        2    -1        0  unknown 0        0
## 2942  cellular  28   aug       69       17    -1        0  unknown 0        0
## 2943 telephone   5   aug      813        2    -1        0  unknown 0        1
## 2944  cellular  17   jul      991        5    -1        0  unknown 1        1
## 2945 telephone  25   feb      169        1   191        3  success 1        1
## 2946 telephone   5   feb      398        4   189       12  success 0        0
## 2947  cellular   5   may      168        1   265        2  failure 0        0
## 2948  cellular  30   jan      413        3    -1        0  unknown 0        0
## 2949  cellular   5   may       81        9    -1        0  unknown 0        0
## 2950   unknown   5   jun       61        2    -1        0  unknown 0        0
## 2951   unknown  21   may      102        3    -1        0  unknown 0        0
## 2952  cellular  31   jul       15       19    -1        0  unknown 0        0
## 2953  cellular  29   jan      404        2   251        6  failure 0        0
## 2954  cellular  18   may      239        2    -1        0  unknown 0        1
## 2955  cellular  30   jan      150        1    -1        0  unknown 0        0
## 2956  cellular  20   nov      640        1    -1        0  unknown 0        0
## 2957  cellular   6   may      523        2   363        2  failure 0        1
## 2958  cellular   4   may      254        4    -1        0  unknown 0        1
## 2959  cellular   2   feb       64        2    -1        0  unknown 0        0
## 2960  cellular  21   jul      363        1    -1        0  unknown 0        0
## 2961   unknown   9   jun      376        3    -1        0  unknown 0        0
## 2962   unknown   6   may      202        4    -1        0  unknown 0        0
## 2963   unknown  20   may      171        1    -1        0  unknown 0        0
## 2964   unknown  29   may      333        3    -1        0  unknown 0        0
## 2965  cellular   1   jun      232        2    -1        0  unknown 1        0
## 2966 telephone  30   apr      766        3    84        3  success 1        0
## 2967  cellular   6   feb      439        2    -1        0  unknown 0        0
## 2968   unknown  19   jun       53        1    -1        0  unknown 0        0
## 2969  cellular  11   may      112        1    -1        0  unknown 0        0
## 2970  cellular  11   aug      356        1    -1        0  unknown 0        0
## 2971   unknown  18   jun      973        1    -1        0  unknown 1        0
## 2972   unknown   7   may      591        1    -1        0  unknown 1        0
## 2973   unknown   2   jun      184        1    -1        0  unknown 0        0
## 2974  cellular  24   jul      120       11    -1        0  unknown 0        0
## 2975  cellular  18   aug      147       10    -1        0  unknown 0        0
## 2976   unknown   7   may      125        1    -1        0  unknown 0        0
## 2977   unknown  16   may      179        1    -1        0  unknown 0        0
## 2978  cellular  28   dec      137        1   122        3  failure 0        0
## 2979  cellular  14   sep      961        5    -1        0  unknown 1        0
## 2980  cellular  13   may       67        2    -1        0  unknown 0        0
## 2981  cellular  12   aug      231        4    -1        0  unknown 0        0
## 2982   unknown  27   may      114        3    -1        0  unknown 0        0
## 2983  cellular  25   aug      961        4    -1        0  unknown 1        0
## 2984   unknown  15   may      171       10    -1        0  unknown 0        0
## 2985  cellular  20   aug      744        7    -1        0  unknown 0        0
## 2986   unknown  28   may      194        3    -1        0  unknown 0        0
## 2987  cellular   5   jun      255        1    -1        0  unknown 1        0
## 2988  cellular  17   apr      557        1    -1        0  unknown 0        0
## 2989 telephone   4   feb       82        1   244        1  failure 0        0
## 2990   unknown  28   may      151        8    -1        0  unknown 0        0
## 2991  cellular  19   nov      520        1    -1        0  unknown 0        0
## 2992   unknown   8   may      161        1    -1        0  unknown 0        0
## 2993 telephone  15   oct      172        1    -1        0  unknown 0        0
## 2994  cellular  17   apr       18        1    -1        0  unknown 0        0
## 2995   unknown  29   may      512        5    -1        0  unknown 0        0
## 2996  cellular  11   aug      203        1    -1        0  unknown 0        1
## 2997   unknown   3   jun      263        1    -1        0  unknown 0        0
## 2998   unknown  24   oct      112        1    -1        0  unknown 1        0
## 2999  cellular  29   jan      118        1    -1        0  unknown 0        0
## 3000  cellular   4   feb      149        2    -1        0  unknown 0        0
## 3001  cellular   6   may      230        1    -1        0  unknown 0        0
## 3002  cellular  21   nov      718        1    -1        0  unknown 0        0
## 3003   unknown  27   jun       59        4    -1        0  unknown 0        0
## 3004  cellular  15   may       61        1   298        2  failure 0        0
## 3005  cellular  14   apr      179        1   334        1    other 0        0
## 3006  cellular   8   aug      669        2    -1        0  unknown 1        0
## 3007  cellular  22   aug      343        5    -1        0  unknown 0        0
## 3008   unknown  20   jun       41        7    -1        0  unknown 0        0
## 3009  cellular  25   jan      423        1    -1        0  unknown 1        0
## 3010  cellular   3   apr      445        1   135        3  failure 0        0
## 3011  cellular  20   apr      224        1    -1        0  unknown 0        0
## 3012 telephone   5   may      408        2   350        1  failure 0        0
## 3013  cellular  20   apr      533        1    -1        0  unknown 0        0
## 3014  cellular  14   may      444        1    -1        0  unknown 0        0
## 3015  cellular  14   oct      181        2   500        1  failure 0        0
## 3016  cellular  29   jul      158        2    -1        0  unknown 0        0
## 3017   unknown  13   may      131        1    -1        0  unknown 0        0
## 3018   unknown  21   may      588        2    -1        0  unknown 0        0
## 3019  cellular  16   apr      232        1   335        1  failure 0        0
## 3020  cellular   1   jun      212        1    -1        0  unknown 0        0
## 3021   unknown  16   jun      348        1    -1        0  unknown 0        0
## 3022  cellular  29   jan      138        2   164        4    other 0        0
## 3023 telephone  18   may       81        4    -1        0  unknown 0        0
## 3024  cellular  18   aug       34       14    -1        0  unknown 0        0
## 3025   unknown  18   jun      339        2    -1        0  unknown 0        0
## 3026  cellular  18   may       14        3   355        4    other 0        1
## 3027  cellular   8   may      349        1    -1        0  unknown 0        0
## 3028  cellular  19   feb       88        2    -1        0  unknown 0        0
## 3029   unknown  23   may      211        3    -1        0  unknown 0        0
## 3030  cellular  11   aug      139        8    -1        0  unknown 0        0
## 3031  cellular   4   may      170        2    87        1  failure 0        0
## 3032 telephone   7   jul      118        2    -1        0  unknown 0        0
## 3033  cellular  17   apr      326        1   319        1  failure 0        0
## 3034 telephone  28   oct      509        1    -1        0  unknown 1        0
## 3035  cellular  14   apr      232        1   147        2  failure 0        0
## 3036   unknown  27   jun      114        4    -1        0  unknown 0        1
## 3037   unknown   3   jun       87        6    -1        0  unknown 0        0
## 3038   unknown  12   jun      138        2    -1        0  unknown 0        0
## 3039  cellular  12   may      131        2    -1        0  unknown 0        0
## 3040   unknown  19   jun      170        7    -1        0  unknown 0        0
## 3041  cellular   7   aug      187        4    -1        0  unknown 0        0
## 3042 telephone  28   jul      426        4    -1        0  unknown 0        0
## 3043   unknown   3   jun      126        4    -1        0  unknown 0        0
## 3044  cellular   5   aug      159        1    -1        0  unknown 0        0
## 3045   unknown  30   may      240        2    -1        0  unknown 0        0
## 3046  cellular  15   jun       95        1    -1        0  unknown 1        0
## 3047 telephone  22   jul      605        1    -1        0  unknown 0        0
## 3048   unknown  30   may      449        1    -1        0  unknown 0        0
## 3049   unknown  26   may       24        1    -1        0  unknown 0        0
## 3050  cellular   7   aug      446        1    -1        0  unknown 0        0
## 3051  cellular   2   oct       91        2    -1        0  unknown 0        0
## 3052  cellular  15   may      193        2    -1        0  unknown 0        1
## 3053  cellular  20   apr       15        2    -1        0  unknown 0        0
## 3054  cellular  18   may       14        4    -1        0  unknown 0        0
## 3055  cellular  18   may      410        1    -1        0  unknown 0        0
## 3056   unknown  16   jun      254        1    -1        0  unknown 0        0
## 3057  cellular  28   jul       88        9    -1        0  unknown 0        0
## 3058  cellular  21   nov      246        2    -1        0  unknown 0        0
## 3059   unknown   5   jun      117        2    -1        0  unknown 0        0
## 3060  cellular  17   nov      172        3    -1        0  unknown 0        0
## 3061  cellular  20   nov       80        1    -1        0  unknown 0        0
## 3062  cellular  12   aug      119        4    -1        0  unknown 0        1
## 3063 telephone  18   nov      195        3   112        8    other 0        0
## 3064   unknown   4   jun      236        1    -1        0  unknown 0        1
## 3065 telephone   4   aug      153        1     1        7  success 0        0
## 3066 telephone  12   may      206        6   337        6  failure 0        0
## 3067  cellular  28   jan      224        2    -1        0  unknown 0        0
## 3068   unknown   6   jun       36       24    -1        0  unknown 0        0
## 3069   unknown  27   may       74        1    -1        0  unknown 0        0
## 3070  cellular  25   jul      720        2    -1        0  unknown 0        0
## 3071  cellular  27   aug     1040        6    -1        0  unknown 1        0
## 3072  cellular  16   apr      691        1    -1        0  unknown 0        0
## 3073  cellular  11   aug      384        6    -1        0  unknown 1        0
## 3074  cellular  18   may      644        1    -1        0  unknown 0        0
## 3075  cellular  28   jan      207        3    -1        0  unknown 0        0
## 3076  cellular   5   may      470        2   166        2  failure 0        0
## 3077  cellular  13   may      863        3    -1        0  unknown 1        0
## 3078   unknown   2   jun      227        1    -1        0  unknown 0        0
## 3079   unknown   9   jun      123        1    -1        0  unknown 0        0
## 3080   unknown   5   jun       85        2    -1        0  unknown 0        0
## 3081  cellular  17   nov       64        1    -1        0  unknown 0        0
## 3082  cellular   5   may      150        1    -1        0  unknown 0        0
## 3083   unknown  27   may      755        1    -1        0  unknown 0        1
## 3084  cellular  18   feb      442        2    -1        0  unknown 1        0
## 3085   unknown   9   jun      119        1    -1        0  unknown 0        0
## 3086  cellular   7   may      336        1    -1        0  unknown 0        0
## 3087  cellular  22   aug      528        2    -1        0  unknown 1        0
## 3088   unknown   4   jun       14       11    -1        0  unknown 0        1
## 3089   unknown   2   jun       90        4    -1        0  unknown 0        0
## 3090  cellular   3   jul      194        1    -1        0  unknown 0        1
## 3091   unknown  12   jun       91        1    -1        0  unknown 0        0
## 3092  cellular   7   may      243        2    -1        0  unknown 0        0
## 3093  cellular  20   nov     1031        6    -1        0  unknown 0        0
## 3094  cellular  15   jul      129        2    -1        0  unknown 0        0
## 3095  cellular   2   feb      221        2   272        1  failure 0        0
## 3096  cellular  25   jul       97        1    -1        0  unknown 0        0
## 3097   unknown  23   may      181       16    -1        0  unknown 0        0
## 3098  cellular  20   apr      280        4   287        3    other 0        0
## 3099  cellular  28   jan      706        1    -1        0  unknown 0        0
## 3100  cellular  20   apr      379        3   202        1  success 1        0
## 3101  cellular  28   aug      210        5    -1        0  unknown 0        0
## 3102  cellular  27   aug      105        4    -1        0  unknown 0        0
## 3103  cellular  18   nov      854        1    -1        0  unknown 1        0
## 3104  cellular  28   jan      196        1    -1        0  unknown 0        1
## 3105   unknown   8   may       17        3    -1        0  unknown 0        0
## 3106  cellular   6   aug      290        2    -1        0  unknown 0        0
## 3107   unknown  13   may      514        5    -1        0  unknown 0        0
## 3108  cellular  25   aug       84        4    -1        0  unknown 0        0
## 3109  cellular  19   feb      255        2   555        6  success 1        0
## 3110  cellular  21   nov      151        1    -1        0  unknown 0        0
## 3111  cellular  17   nov       73        1    -1        0  unknown 0        0
## 3112  cellular  16   apr      298        4    -1        0  unknown 1        0
## 3113  cellular  21   jul      262        3    -1        0  unknown 0        1
## 3114   unknown  19   may      455        1    -1        0  unknown 0        0
## 3115  cellular  11   may      432        2    -1        0  unknown 0        0
## 3116  cellular   4   feb      233        3    -1        0  unknown 0        0
## 3117  cellular  19   aug      122        2    -1        0  unknown 0        0
## 3118  cellular  23   jul       73        4    -1        0  unknown 0        0
## 3119   unknown   8   may       11        1    -1        0  unknown 0        0
## 3120   unknown   8   may      477        1    -1        0  unknown 0        0
## 3121  cellular  23   sep      244        1    92        3  success 1        0
## 3122  cellular  18   aug       64        7    -1        0  unknown 0        0
## 3123   unknown   8   may      352        3    -1        0  unknown 0        0
## 3124  cellular  21   nov       51        2   140       11  failure 0        0
## 3125  cellular  14   jul      330        2    -1        0  unknown 0        0
## 3126 telephone  18   nov       23        1    -1        0  unknown 0        0
## 3127   unknown  16   jun      209       12    -1        0  unknown 0        0
## 3128  cellular  20   nov      138        1    -1        0  unknown 0        0
## 3129  cellular   7   may      155        1    -1        0  unknown 0        0
## 3130   unknown  20   jun      165        2    -1        0  unknown 0        0
## 3131  cellular  19   nov      180        3    -1        0  unknown 0        0
## 3132   unknown   9   may      278        1    -1        0  unknown 0        0
## 3133   unknown   8   may      229        2    -1        0  unknown 0        1
## 3134   unknown  23   may      206        1    -1        0  unknown 0        0
## 3135   unknown  13   may      518        1    -1        0  unknown 0        0
## 3136  cellular  29   jan      225        1    -1        0  unknown 0        0
## 3137 telephone  10   mar      152        1   348        1  failure 0        0
## 3138  cellular  12   aug      188        1    -1        0  unknown 0        0
## 3139   unknown  14   may      323        4    -1        0  unknown 0        0
## 3140  cellular  25   jul      803        1    -1        0  unknown 0        1
## 3141   unknown   5   may       22        1    -1        0  unknown 0        0
## 3142  cellular   2   aug      428        2   336        6  failure 0        0
## 3143  cellular  17   nov      190        1   104        1  failure 0        0
## 3144  cellular   7   aug      390        2    -1        0  unknown 0        0
## 3145   unknown  21   may      836       12    -1        0  unknown 0        0
## 3146   unknown   9   may      231        2    -1        0  unknown 0        0
## 3147   unknown  29   may      144        2    -1        0  unknown 0        0
## 3148 telephone  18   may       57        6    -1        0  unknown 0        0
## 3149   unknown   8   may      201        2    -1        0  unknown 0        0
## 3150   unknown   2   jun      149        8    -1        0  unknown 0        0
## 3151  cellular  12   may       17        1   365        2    other 0        0
## 3152  cellular  14   apr     1594        1   148        1  failure 1        0
## 3153   unknown  21   may      218        7    -1        0  unknown 0        0
## 3154  cellular  25   jul      246        2    -1        0  unknown 0        0
## 3155  cellular  11   may      161        1    -1        0  unknown 0        0
## 3156  cellular  17   apr      609        1   303        5  failure 0        0
## 3157  cellular  30   jul       74        2    -1        0  unknown 0        0
## 3158  cellular  22   jul      392        2    -1        0  unknown 0        0
## 3159  cellular   6   feb      170        1    -1        0  unknown 0        0
## 3160  cellular  11   aug       57        2    -1        0  unknown 0        0
## 3161  cellular  20   apr       74        2    -1        0  unknown 0        0
## 3162  cellular  15   jul      250        4   415        2  failure 1        0
## 3163  cellular  18   may      700        3    -1        0  unknown 1        1
## 3164   unknown   6   may      765        1    -1        0  unknown 0        0
## 3165   unknown  23   may      159        3    -1        0  unknown 0        0
## 3166  cellular   8   aug      104        2    -1        0  unknown 0        0
## 3167   unknown  29   may      828        3    -1        0  unknown 1        0
## 3168 telephone  12   may      899        3    -1        0  unknown 0        0
## 3169  cellular  18   nov      613        1    -1        0  unknown 0        0
## 3170   unknown  13   may      164        1    -1        0  unknown 0        1
## 3171  cellular  28   jan      517        2    -1        0  unknown 0        0
## 3172   unknown  17   jun      273       27    -1        0  unknown 0        1
## 3173  cellular   5   may      304        2   259        2  failure 0        0
## 3174  cellular   5   jun       57        2   304        1  failure 0        0
## 3175  cellular  12   may      112        4   369        2    other 0        0
## 3176  cellular  16   apr      105        2    -1        0  unknown 0        0
## 3177  cellular  13   apr      239        3    -1        0  unknown 0        0
## 3178  cellular   2   jul      275        1    -1        0  unknown 1        0
## 3179  cellular  19   nov      325        2    -1        0  unknown 0        0
## 3180  cellular  21   nov      158        7    -1        0  unknown 0        0
## 3181  cellular   8   jul      113        1    -1        0  unknown 0        0
## 3182   unknown   9   may      185        2    -1        0  unknown 0        0
## 3183   unknown   9   may      352        1    -1        0  unknown 0        0
## 3184  cellular   7   may       57        4    -1        0  unknown 0        1
## 3185   unknown  24   oct      305        1    -1        0  unknown 1        0
## 3186  cellular  31   jul       49        2    -1        0  unknown 0        0
## 3187   unknown   5   may      266        1    -1        0  unknown 0        0
## 3188  cellular  25   may       91        1    -1        0  unknown 0        0
## 3189   unknown  20   may       19       15    -1        0  unknown 0        0
## 3190  cellular  13   may       65        2   299        3    other 0        0
## 3191  cellular   8   jul      165        1    -1        0  unknown 0        0
## 3192  cellular  11   aug     1015        1    -1        0  unknown 0        0
## 3193  cellular  18   may      453        4    -1        0  unknown 0        1
## 3194  cellular  24   jul       62        1    -1        0  unknown 0        0
## 3195  cellular  28   jan       73        1    -1        0  unknown 0        0
## 3196  cellular  14   may      104        1    -1        0  unknown 0        0
## 3197   unknown  16   jun       81        4    -1        0  unknown 0        0
## 3198   unknown   5   jun     1558        1    -1        0  unknown 1        0
## 3199  cellular  24   aug       73        3   200        2  failure 0        0
## 3200  cellular  26   oct      604        1    91        4  failure 1        0
## 3201  cellular  18   aug       61        1    84        1  failure 0        0
## 3202  cellular  31   jul      107        3    -1        0  unknown 0        0
## 3203   unknown  27   may       67        4    -1        0  unknown 0        0
## 3204  cellular   5   feb      192        4    -1        0  unknown 0        0
## 3205  cellular  21   aug      163        1    -1        0  unknown 0        0
## 3206  cellular  18   nov      722        3   175        2  failure 0        0
## 3207   unknown  16   may       30        3    -1        0  unknown 0        0
## 3208   unknown  15   may      146        4    -1        0  unknown 0        0
## 3209   unknown   5   jun      172        2    -1        0  unknown 0        0
## 3210  cellular  17   apr      473        2   339        1  failure 0        0
## 3211   unknown  15   may      440        2    -1        0  unknown 0        0
## 3212  cellular   8   jul      574        2    -1        0  unknown 1        1
## 3213   unknown  27   may      305        1    -1        0  unknown 0        1
## 3214  cellular  21   nov      304        2    -1        0  unknown 0        0
## 3215  cellular  16   apr      472        2    -1        0  unknown 0        1
## 3216  cellular  29   sep      245        3    -1        0  unknown 1        0
## 3217  cellular   7   may      265        1    -1        0  unknown 0        0
## 3218  cellular   6   sep      109        3   276        8    other 0        0
## 3219   unknown   8   may      180        1    -1        0  unknown 0        1
## 3220   unknown  26   may      117        1    -1        0  unknown 0        0
## 3221  cellular   4   jun      352        2   122        2  failure 1        0
## 3222 telephone  20   nov      713        6    -1        0  unknown 0        0
## 3223  cellular  20   nov       88        2    -1        0  unknown 0        0
## 3224   unknown   8   jun      198        1   651        7    other 0        0
## 3225  cellular   7   aug      121        1    -1        0  unknown 0        1
## 3226   unknown  29   may       52        1    -1        0  unknown 0        0
## 3227   unknown  19   may      234       13    -1        0  unknown 0        0
## 3228   unknown  26   may      165        5    -1        0  unknown 0        1
## 3229   unknown  15   may       87        1    -1        0  unknown 0        0
## 3230  cellular  21   aug      231        3    -1        0  unknown 0        0
## 3231   unknown  28   may      629        2    -1        0  unknown 0        0
## 3232   unknown  12   jun      614        2    -1        0  unknown 1        0
## 3233  cellular  14   oct      133        2    -1        0  unknown 0        1
## 3234   unknown  30   may      155        1    -1        0  unknown 0        0
## 3235  cellular  11   may      236        1    -1        0  unknown 0        0
## 3236  cellular   7   jul       97        3    -1        0  unknown 0        0
## 3237  cellular  28   aug       13       21    -1        0  unknown 0        0
## 3238  cellular  27   oct      353        1    -1        0  unknown 1        0
## 3239  cellular  13   oct       98        1    -1        0  unknown 0        0
## 3240  cellular  24   jul      139        5    -1        0  unknown 1        1
## 3241  cellular  15   may      143        2   343        3  failure 0        1
## 3242   unknown   6   jun      230        2    -1        0  unknown 0        0
## 3243  cellular  30   jul       44        4    -1        0  unknown 0        0
## 3244  cellular  11   may      182        2    -1        0  unknown 0        0
## 3245  cellular  25   aug      431        5    -1        0  unknown 0        0
## 3246   unknown   9   may      253        1    -1        0  unknown 0        0
## 3247  cellular   8   aug      275        4    -1        0  unknown 0        0
## 3248   unknown  14   may      160        1    -1        0  unknown 0        0
## 3249  cellular   2   feb       64        2    -1        0  unknown 0        0
## 3250   unknown  30   may       70        2    -1        0  unknown 0        0
## 3251   unknown   5   jun       40        1    -1        0  unknown 0        0
## 3252  cellular  18   aug      143        4    -1        0  unknown 0        0
## 3253  cellular   7   may      312        1    -1        0  unknown 0        0
## 3254  cellular  18   nov       51        4    -1        0  unknown 0        0
## 3255  cellular  21   jul      538        1    -1        0  unknown 0        0
## 3256   unknown  15   may       73        1    -1        0  unknown 0        0
## 3257  cellular  19   nov      690        3    -1        0  unknown 0        0
## 3258 telephone  17   nov       99        3    -1        0  unknown 0        0
## 3259  cellular  28   jun      348        6    94        6  failure 0        0
## 3260   unknown  12   may      236       10    -1        0  unknown 0        0
## 3261  cellular  23   jul      127        8    -1        0  unknown 0        0
## 3262   unknown  19   may       88        5    -1        0  unknown 0        0
## 3263  cellular  17   nov      977        3    -1        0  unknown 1        0
## 3264  cellular  14   jul      238        3    -1        0  unknown 0        0
## 3265  cellular  13   may      231        2   362        1    other 0        0
## 3266   unknown  12   may       38        4    -1        0  unknown 0        0
## 3267  cellular   6   may      193        1    -1        0  unknown 0        0
## 3268  cellular  18   nov      237        1    -1        0  unknown 0        0
## 3269  cellular  15   jul      347        4    -1        0  unknown 0        0
## 3270  cellular  15   may      133        1   353        5    other 0        0
## 3271  cellular  21   jul       81        1    -1        0  unknown 0        0
## 3272  cellular  20   aug       50        2    -1        0  unknown 0        0
## 3273   unknown   9   jun      123        1    -1        0  unknown 0        0
## 3274  cellular  12   aug      632        6    -1        0  unknown 0        0
## 3275 telephone   6   may       44        1    -1        0  unknown 0        1
## 3276   unknown  20   may      446       12    -1        0  unknown 0        0
## 3277  cellular  17   apr      114        1   345        2  failure 0        0
## 3278   unknown  16   jun      382        3    -1        0  unknown 0        0
## 3279 telephone   6   may      167        3    -1        0  unknown 0        0
## 3280  cellular  31   mar      248        1    -1        0  unknown 0        0
## 3281  cellular  19   aug      220        4    -1        0  unknown 0        0
## 3282  cellular  25   aug      184        7    -1        0  unknown 0        0
## 3283  cellular   3   apr      582        2    -1        0  unknown 0        0
## 3284   unknown  20   may       51        7    -1        0  unknown 0        0
## 3285  cellular  18   jul       69        7    -1        0  unknown 0        0
## 3286  cellular   5   may      632        5   287        6  success 0        0
## 3287   unknown  16   may      242        7    -1        0  unknown 0        0
## 3288  cellular  22   jul       67        9    -1        0  unknown 0        0
## 3289   unknown  12   may       76        2    -1        0  unknown 0        0
## 3290   unknown  17   jun      115        1    -1        0  unknown 0        0
## 3291 telephone  12   may      360        2    -1        0  unknown 0        0
## 3292  cellular   7   may      349        1   338        1  failure 0        0
## 3293  cellular  18   nov      459        3    -1        0  unknown 0        0
## 3294  cellular  13   may       61        1    -1        0  unknown 0        0
## 3295  cellular  19   nov      175        1    -1        0  unknown 0        0
## 3296  cellular  20   nov      316        1    -1        0  unknown 0        0
## 3297  cellular   4   feb      136        4    -1        0  unknown 1        0
## 3298   unknown   3   jul       93        1    -1        0  unknown 0        0
## 3299  cellular   6   may       19        1    -1        0  unknown 0        0
## 3300  cellular   2   feb      620        2    -1        0  unknown 0        0
## 3301  cellular   6   may      285        1   288       17    other 0        0
## 3302   unknown  16   jun       58        1    -1        0  unknown 0        0
## 3303  cellular   3   nov      215        1    -1        0  unknown 1        0
## 3304   unknown  20   may      522        1    -1        0  unknown 0        0
## 3305  cellular  15   may       12       10   178        1  failure 0        0
## 3306 telephone  11   mar       78        2    91        1  failure 0        0
## 3307  cellular  20   nov      287        2    -1        0  unknown 0        0
## 3308  cellular  23   jul      498        1    -1        0  unknown 0        0
## 3309 telephone  24   jul      308        4    -1        0  unknown 0        0
## 3310   unknown  17   jun      717        1    -1        0  unknown 0        0
## 3311  cellular  28   jan      144        1    -1        0  unknown 0        0
## 3312 telephone   2   feb      463        2    -1        0  unknown 0        0
## 3313  cellular  25   aug      343        4    -1        0  unknown 0        0
## 3314  cellular  19   nov      584        2    -1        0  unknown 0        0
## 3315   unknown  27   jun      153        2    -1        0  unknown 0        0
## 3316   unknown  27   jun      140        2    -1        0  unknown 0        0
## 3317  cellular  31   jul      217        4    -1        0  unknown 0        0
## 3318  cellular  13   may      302        1   301        1  success 1        1
## 3319   unknown   6   may      155        2    -1        0  unknown 0        0
## 3320  cellular  15   jul      981        1    -1        0  unknown 1        0
## 3321  cellular  17   nov      174        1   195        1  failure 0        0
## 3322  cellular   5   apr      144        4   374        2  success 1        0
## 3323   unknown   7   may      477        2    -1        0  unknown 0        0
## 3324  cellular  20   nov      128        1    -1        0  unknown 0        0
## 3325   unknown  12   jun      117        5    -1        0  unknown 0        0
## 3326 telephone   5   feb       13        8   238        9    other 0        0
## 3327   unknown  28   may      299        3    -1        0  unknown 0        0
## 3328  cellular  10   jul      804        1    -1        0  unknown 1        0
## 3329   unknown   5   jun       81        2    -1        0  unknown 0        1
## 3330  cellular   5   feb       96        6    -1        0  unknown 0        0
## 3331  cellular  27   feb       58        2    -1        0  unknown 0        1
## 3332  cellular  22   jul       81        2    -1        0  unknown 0        0
## 3333  cellular   4   feb       79        2    -1        0  unknown 0        0
## 3334  cellular   7   may       54        1   345        2  failure 0        0
## 3335  cellular  14   jul      145        2    -1        0  unknown 0        0
## 3336  cellular  19   nov       50        1    -1        0  unknown 0        0
## 3337   unknown  18   jun      205        4    -1        0  unknown 0        0
## 3338  cellular  18   nov      197        1    -1        0  unknown 0        0
## 3339 telephone   4   aug      297        1    -1        0  unknown 0        1
## 3340  cellular   8   nov      240        1    40        2    other 0        0
## 3341  cellular  15   may       67        4   175        6  failure 0        0
## 3342   unknown  21   may      202        6    -1        0  unknown 0        0
## 3343   unknown  29   may      182        1    -1        0  unknown 0        0
## 3344  cellular   7   may      178        3    -1        0  unknown 0        0
## 3345  cellular  20   apr      129        1   322        2  failure 0        0
## 3346  cellular   5   feb      231        1    -1        0  unknown 0        0
## 3347   unknown  23   jun      364        2    -1        0  unknown 0        0
## 3348   unknown  26   jun      138        3    -1        0  unknown 0        0
## 3349   unknown   6   may      262        1    -1        0  unknown 0        0
## 3350   unknown   6   may      150        1    -1        0  unknown 0        0
## 3351  cellular  18   nov       93        1   113        2    other 0        0
## 3352  cellular   7   may      186        2   295        1  failure 0        0
## 3353  cellular  15   may      311        1   368        2  failure 1        0
## 3354   unknown  12   jun      436        1    -1        0  unknown 0        0
## 3355  cellular  10   jul      235        1    -1        0  unknown 0        0
## 3356  cellular  20   nov      405        1   139        1  failure 0        0
## 3357   unknown  28   may      582        1    -1        0  unknown 0        1
## 3358   unknown   5   jun      103        2    -1        0  unknown 0        0
## 3359  cellular  12   may      216        2   259        3    other 0        0
## 3360  cellular   9   apr      162        4   295        3  failure 0        0
## 3361   unknown  13   may      806        1    -1        0  unknown 0        0
## 3362  cellular  29   jul      102        3    -1        0  unknown 0        0
## 3363   unknown   6   jun       82        3    -1        0  unknown 0        0
## 3364  cellular  15   may      641        6    -1        0  unknown 0        0
## 3365   unknown  16   may      145        1    -1        0  unknown 0        0
## 3366  cellular  13   aug       62        2    -1        0  unknown 0        0
## 3367  cellular  28   jan      117        2    -1        0  unknown 0        0
## 3368  cellular  27   apr      321        1   449        1    other 1        1
## 3369  cellular  28   jan      156        2    -1        0  unknown 0        0
## 3370  cellular  18   nov      276        1   195        1  failure 0        0
## 3371 telephone  22   aug       90       11    -1        0  unknown 0        0
## 3372   unknown  13   may      195        5    -1        0  unknown 0        0
## 3373  cellular  21   aug      139        2    -1        0  unknown 0        0
## 3374  cellular   9   feb      297        3    -1        0  unknown 0        0
## 3375  cellular  25   jul       51        4    -1        0  unknown 0        0
## 3376   unknown  20   jun       17        5    -1        0  unknown 0        0
## 3377  cellular   9   jul       81        1    -1        0  unknown 0        0
## 3378 telephone  19   nov      623        1   175        1    other 1        0
## 3379  cellular   7   apr      158        2    -1        0  unknown 0        0
## 3380   unknown  20   jun      553        2    -1        0  unknown 0        0
## 3381   unknown   4   jun       66        4    -1        0  unknown 0        0
## 3382  cellular   3   feb      261        1   195        4  failure 1        0
## 3383  cellular  14   jul      244        3    -1        0  unknown 0        0
## 3384  cellular  18   aug      199        7    -1        0  unknown 0        0
## 3385 telephone   4   mar       92        5    -1        0  unknown 0        0
## 3386   unknown  12   may      293        1    -1        0  unknown 0        1
## 3387 telephone   2   feb       45        1    -1        0  unknown 0        1
## 3388  cellular  11   may      143        3   357        1  failure 0        0
## 3389  cellular  21   jul      369        1    -1        0  unknown 0        1
## 3390   unknown  21   may      139        2    -1        0  unknown 0        0
## 3391   unknown   9   may      280        1    -1        0  unknown 0        0
## 3392  cellular   9   feb      172        5    -1        0  unknown 0        0
## 3393  cellular  18   aug      194        2    -1        0  unknown 1        0
## 3394  cellular  16   sep      414        1    91        5    other 1        0
## 3395   unknown   9   may      137        2    -1        0  unknown 0        0
## 3396  cellular  15   may       25        1   350        5    other 0        0
## 3397  cellular  30   jul      112        5    -1        0  unknown 0        0
## 3398   unknown  23   may      245        1    -1        0  unknown 0        0
## 3399  cellular  22   jul      188        2    -1        0  unknown 0        1
## 3400  cellular  16   apr      117        1    -1        0  unknown 0        0
## 3401   unknown   9   jun      443        2    -1        0  unknown 0        0
## 3402  cellular  13   aug      159        4    -1        0  unknown 0        0
## 3403   unknown  20   may      267        2    -1        0  unknown 0        0
## 3404  cellular  23   jul      638        2    -1        0  unknown 1        0
## 3405  cellular   7   jul      112       10    -1        0  unknown 0        0
## 3406 telephone  17   feb      202        4    -1        0  unknown 1        0
## 3407  cellular  30   apr       70        1    84        1  failure 0        0
## 3408   unknown  15   may      196        2    -1        0  unknown 0        0
## 3409   unknown  23   may      541        2    -1        0  unknown 0        0
## 3410   unknown  19   jun       96        1    -1        0  unknown 0        0
## 3411   unknown  20   jun       94        7    -1        0  unknown 0        0
## 3412   unknown   6   may      623        1    -1        0  unknown 0        0
## 3413  cellular  20   aug       66        3    -1        0  unknown 0        0
## 3414  cellular  21   jul     1134        5    -1        0  unknown 1        0
## 3415   unknown  29   may       91        2    -1        0  unknown 0        0
## 3416  cellular  13   may       82        5   355        4  failure 0        0
## 3417  cellular  18   aug       29        3    -1        0  unknown 0        0
## 3418  cellular   7   aug      122        2    -1        0  unknown 0        0
## 3419  cellular   4   feb      387        1   251        1  failure 0        0
## 3420  cellular  20   aug      328        2    -1        0  unknown 0        0
## 3421   unknown  19   may      115        1    -1        0  unknown 0        0
## 3422   unknown  18   jun      154        2    -1        0  unknown 0        0
## 3423   unknown   3   jul      225        2    -1        0  unknown 0        0
## 3424   unknown  11   jun       83       10    -1        0  unknown 0        0
## 3425   unknown  28   may      130        2    -1        0  unknown 0        0
## 3426  cellular  16   jul      122        1    -1        0  unknown 0        0
## 3427   unknown  21   may      295        1    -1        0  unknown 0        0
## 3428  cellular   7   jul      482        3    -1        0  unknown 0        0
## 3429  cellular   6   may      305        1    -1        0  unknown 0        0
## 3430 telephone   5   may       92        3    -1        0  unknown 0        0
## 3431  cellular  29   jul       95        5    -1        0  unknown 0        0
## 3432  cellular  31   jul       89        5    -1        0  unknown 0        0
## 3433  cellular   4   nov       95        1    -1        0  unknown 0        0
## 3434  cellular  13   aug      784        3    94       10  failure 1        0
## 3435  cellular  13   aug      183        2    -1        0  unknown 0        0
## 3436   unknown  13   jan      127        1    -1        0  unknown 0        1
## 3437  cellular  12   aug      113        1    -1        0  unknown 0        0
## 3438   unknown  26   may       61        1    -1        0  unknown 0        0
## 3439   unknown  20   jun        7        3    -1        0  unknown 0        0
## 3440   unknown   7   may      150        1    -1        0  unknown 0        0
## 3441  cellular   3   feb      383        1    -1        0  unknown 0        1
## 3442  cellular   6   may      215        3   280        3  failure 0        0
## 3443  cellular  15   may      104        3    -1        0  unknown 0        1
## 3444   unknown   9   jun       29        1   686        2  failure 0        0
## 3445   unknown   3   jun      227        1    -1        0  unknown 0        0
## 3446 telephone  28   jan       41        1    -1        0  unknown 0        0
## 3447  cellular  30   jul      208        2    -1        0  unknown 0        0
## 3448   unknown  16   may      280        1    -1        0  unknown 0        1
## 3449  cellular   6   aug      105        6    -1        0  unknown 0        0
## 3450   unknown  14   may      225        1    -1        0  unknown 0        0
## 3451  cellular   9   apr      504        1    -1        0  unknown 0        0
## 3452   unknown   9   jun       51        1    -1        0  unknown 0        0
## 3453   unknown  29   may      253        3    -1        0  unknown 0        0
## 3454  cellular   4   may       76        2    87        1  success 0        0
## 3455  cellular  27   may      417        2    -1        0  unknown 1        0
## 3456  cellular  16   jul       72        1    -1        0  unknown 0        0
## 3457  cellular  12   aug      255        2   104        1  success 1        0
## 3458  cellular   4   feb      542        2    -1        0  unknown 0        1
## 3459  cellular  12   may      179        3    -1        0  unknown 0        0
## 3460   unknown   9   may      653        1    -1        0  unknown 1        0
## 3461   unknown  27   may      201        2    -1        0  unknown 0        0
## 3462  cellular  29   jul       33        2    -1        0  unknown 0        0
## 3463  cellular   9   feb       48        4    -1        0  unknown 0        0
## 3464   unknown  19   may      109        2    -1        0  unknown 0        1
## 3465 telephone  23   jul       18        9    -1        0  unknown 0        0
## 3466  cellular  21   nov      159        2    -1        0  unknown 0        0
## 3467  cellular   5   feb        9        8    -1        0  unknown 0        0
## 3468  cellular  11   aug      119        2    -1        0  unknown 0        0
## 3469  cellular  11   may      508        3   173        5  failure 0        0
## 3470  cellular  27   may      207        5    -1        0  unknown 0        0
## 3471   unknown  23   may      302        1    -1        0  unknown 0        0
## 3472   unknown  20   jun       20        7    -1        0  unknown 0        0
## 3473  cellular  17   apr       97        1    -1        0  unknown 0        0
## 3474  cellular  30   jul      259        3    -1        0  unknown 0        0
## 3475  cellular  21   nov        6        6    -1        0  unknown 0        0
## 3476  cellular  20   aug      200        2    -1        0  unknown 0        0
## 3477  cellular  24   jul       90        2    -1        0  unknown 0        0
## 3478   unknown  26   may      130        1    -1        0  unknown 0        0
## 3479   unknown   5   jun      124        2    -1        0  unknown 0        0
## 3480  cellular  28   jan      314        1    -1        0  unknown 0        0
## 3481   unknown   5   may      364        1    -1        0  unknown 0        0
## 3482  cellular   8   may      158        2   350        2  failure 0        1
## 3483  cellular   6   aug      467        2    -1        0  unknown 0        0
## 3484  cellular  30   jul       69        9    -1        0  unknown 0        0
## 3485 telephone  17   apr      137        1    -1        0  unknown 0        0
## 3486  cellular  14   may       24        1   346        1  failure 0        0
## 3487   unknown  14   may      231        1    -1        0  unknown 0        0
## 3488  cellular  11   aug      663        3    -1        0  unknown 1        0
## 3489  cellular   6   apr      377        3   325        1  failure 0        0
## 3490   unknown  30   may      891        4    -1        0  unknown 1        0
## 3491  cellular  12   aug      603        3    -1        0  unknown 0        0
## 3492  cellular  18   jul      799        2    -1        0  unknown 1        0
## 3493  cellular  19   nov      286        3    -1        0  unknown 0        0
## 3494  cellular  17   apr      397        1    -1        0  unknown 0        0
## 3495   unknown   3   jun      284        1    -1        0  unknown 0        0
## 3496 telephone   9   aug      195        1    -1        0  unknown 0        0
## 3497  cellular  12   may      306        1    -1        0  unknown 0        0
## 3498  cellular   7   aug      194        6    -1        0  unknown 0        0
## 3499  cellular  12   may      228        2   267        1  failure 1        0
## 3500  cellular  12   oct      511        3   187        1  failure 1        0
## 3501   unknown   6   may      183        5    -1        0  unknown 0        0
## 3502  cellular  15   apr      636        3   330        1  failure 1        0
## 3503  cellular  15   may      124        2   298        1  failure 0        0
## 3504  cellular  17   nov      107        1   117        3  failure 0        0
## 3505  cellular  14   jul      334        3    -1        0  unknown 0        0
## 3506   unknown  20   jun       32        4    -1        0  unknown 0        0
## 3507  cellular  29   aug      105        2    -1        0  unknown 0        0
## 3508  cellular  10   sep      105        2    -1        0  unknown 0        0
## 3509 telephone  12   dec      136        1    -1        0  unknown 0        0
## 3510  cellular   7   may      101        1   349        1  failure 0        0
## 3511   unknown  19   may      160        2    -1        0  unknown 0        0
## 3512   unknown  20   may       81        1    -1        0  unknown 0        0
## 3513  cellular  18   jul      320        2    -1        0  unknown 0        1
## 3514  cellular  19   aug      133        4    -1        0  unknown 0        0
## 3515   unknown  23   may      445        1    -1        0  unknown 0        0
## 3516  cellular  20   apr      115        2    -1        0  unknown 0        0
## 3517   unknown  19   jun       45        9    -1        0  unknown 0        0
## 3518  cellular  20   aug      359        2    -1        0  unknown 0        0
## 3519   unknown   3   jun      329        3    -1        0  unknown 0        0
## 3520  cellular  12   may      280        2   335        3  failure 0        0
## 3521   unknown  19   may       65        3    -1        0  unknown 0        1
## 3522  cellular  17   nov      102        1    -1        0  unknown 0        0
## 3523  cellular  29   jul      299        5    -1        0  unknown 0        0
## 3524  cellular  25   aug       15       19    -1        0  unknown 0        0
## 3525  cellular  28   aug       54        4    -1        0  unknown 0        0
## 3526  cellular   4   jun      218        1    -1        0  unknown 0        0
## 3527  cellular  15   may       10        5    -1        0  unknown 0        0
## 3528  cellular   8   jul       42        1    -1        0  unknown 0        0
## 3529  cellular   9   jul      226        2    -1        0  unknown 0        1
## 3530  cellular  20   apr       93        3   329        7  failure 0        0
## 3531   unknown  28   may      198        1    -1        0  unknown 0        0
## 3532  cellular  25   aug      479        1    -1        0  unknown 1        0
## 3533  cellular  12   apr      176        1    -1        0  unknown 1        0
## 3534   unknown   8   jun       30        1   404        2  success 0        0
## 3535   unknown  20   jun      211        2    -1        0  unknown 0        0
## 3536   unknown  15   may      487        4    -1        0  unknown 0        0
## 3537  cellular  20   nov      182        2    -1        0  unknown 0        0
## 3538   unknown  11   jun       47        3    -1        0  unknown 0        0
## 3539 telephone  30   oct      152        4    -1        0  unknown 0        0
## 3540  cellular  14   jul      643        2    -1        0  unknown 0        0
## 3541  cellular  12   aug      104        2    -1        0  unknown 0        0
## 3542   unknown  12   may      182        2    -1        0  unknown 0        1
## 3543   unknown  15   may      301        4    -1        0  unknown 0        0
## 3544   unknown   6   jun       44        1    -1        0  unknown 0        0
## 3545  cellular  13   jan      452        3    -1        0  unknown 1        0
## 3546  cellular  16   mar      263        1   124        9    other 1        0
## 3547  cellular   4   aug      158        1   104        2  failure 0        0
## 3548  cellular  16   apr      445        1   148        2    other 0        0
## 3549 telephone   5   jun      145        1    -1        0  unknown 0        0
## 3550  cellular  21   jul      479        1    -1        0  unknown 0        1
## 3551  cellular  21   nov      902        1   133        2    other 1        0
## 3552   unknown   8   may      271        5    -1        0  unknown 0        0
## 3553 telephone  20   may      351        3    -1        0  unknown 1        0
## 3554   unknown  13   may      437        2    -1        0  unknown 0        0
## 3555  cellular  10   feb      159        1    -1        0  unknown 1        1
## 3556  cellular  10   jul      324        1    -1        0  unknown 0        0
## 3557  cellular  28   aug       51        8    -1        0  unknown 0        0
## 3558   unknown  13   may      176        3    -1        0  unknown 0        0
## 3559  cellular   3   feb      149        3   215        1  failure 0        0
## 3560   unknown   6   may       85        1    -1        0  unknown 0        0
## 3561  cellular  25   aug      242        6    95        4  success 1        0
## 3562   unknown  25   jun      249        1    -1        0  unknown 0        0
## 3563   unknown   6   jun       92        1    -1        0  unknown 0        0
## 3564  cellular  21   nov      133        1    -1        0  unknown 0        0
## 3565  cellular   6   aug      203        7    -1        0  unknown 0        0
## 3566   unknown  29   may       23       15    -1        0  unknown 0        0
## 3567   unknown  16   jun      119        2    -1        0  unknown 0        0
## 3568   unknown  15   may       90        3    -1        0  unknown 0        0
## 3569  cellular   3   feb      678        1    -1        0  unknown 0        0
## 3570   unknown   7   may      126        5    -1        0  unknown 0        0
## 3571  cellular   8   aug      107        2    -1        0  unknown 0        0
## 3572   unknown   8   may      200        2    -1        0  unknown 0        0
## 3573  cellular  14   aug       36        2    -1        0  unknown 0        0
## 3574   unknown  23   may      110        1    -1        0  unknown 0        0
## 3575 telephone  24   jul      122       12    -1        0  unknown 0        0
## 3576   unknown  26   may      695        4    -1        0  unknown 0        0
## 3577  cellular  14   may      107        4   371        3  failure 0        0
## 3578   unknown   7   may      245        2    -1        0  unknown 0        0
## 3579  cellular  18   feb      416        2    -1        0  unknown 1        1
## 3580  cellular  17   nov      251        2    -1        0  unknown 0        0
## 3581  cellular   8   jul      604        1    -1        0  unknown 0        0
## 3582  cellular  29   jan       85        2   240        1  failure 0        0
## 3583  cellular  22   jul     1545        1    -1        0  unknown 1        0
## 3584  cellular   2   feb      113        2    -1        0  unknown 0        0
## 3585   unknown   6   jun      642        2    -1        0  unknown 1        0
## 3586  cellular  11   may      154        2   340        2  failure 0        0
## 3587 telephone  12   may      352        2   175       11    other 0        0
## 3588   unknown  19   may      798        1    -1        0  unknown 0        0
## 3589  cellular  12   aug      238        6    -1        0  unknown 0        0
## 3590  cellular  28   jul      100       16    -1        0  unknown 0        0
## 3591  cellular   7   jul       88        3    -1        0  unknown 0        0
## 3592  cellular  12   feb      181        3    -1        0  unknown 1        0
## 3593  cellular   7   sep      179        1   186        2  failure 0        0
## 3594  cellular  20   nov      230        1    -1        0  unknown 0        0
## 3595   unknown  30   may       67        2    -1        0  unknown 0        1
## 3596  cellular  22   may      210        1    -1        0  unknown 0        0
## 3597  cellular  22   jul      403        7    -1        0  unknown 0        0
## 3598  cellular  17   nov      155        1    -1        0  unknown 0        0
## 3599   unknown  20   jun       61        2    -1        0  unknown 0        0
## 3600  cellular  22   aug      168        2    -1        0  unknown 0        0
## 3601  cellular  17   apr      759        2    -1        0  unknown 0        0
## 3602   unknown  19   jun       73        1    -1        0  unknown 0        0
## 3603   unknown  16   jun      686       11    -1        0  unknown 1        0
## 3604  cellular  14   oct      219        3   372        1  failure 0        0
## 3605  cellular  10   jul      148        1    -1        0  unknown 0        0
## 3606  cellular  16   apr      228        2    -1        0  unknown 0        0
## 3607  cellular  28   aug      199        6    -1        0  unknown 0        0
## 3608   unknown   6   jun      862       11    -1        0  unknown 1        0
## 3609   unknown  15   may      500        1    -1        0  unknown 1        0
## 3610  cellular  17   nov      141        3    -1        0  unknown 0        0
## 3611  cellular   6   may      127        2   254       23    other 0        0
## 3612  cellular  16   nov      163        1   200        1  failure 0        0
## 3613   unknown  21   may      210        1    -1        0  unknown 0        0
## 3614   unknown   7   may      192        1    -1        0  unknown 0        0
## 3615 telephone  27   apr      325        1   180        7  failure 1        0
## 3616  cellular   7   jul      242        1    -1        0  unknown 0        1
## 3617   unknown  20   may      114        1    -1        0  unknown 0        0
## 3618  cellular  20   nov      187        2    -1        0  unknown 0        0
## 3619   unknown  27   may      257        1    -1        0  unknown 0        1
## 3620 telephone   8   may      128        8   324        7    other 0        0
## 3621  cellular  17   nov      301        1    -1        0  unknown 0        0
## 3622  cellular  22   jul      417        1    -1        0  unknown 0        1
## 3623   unknown  14   may      850        2    -1        0  unknown 1        0
## 3624  cellular  28   sep      500        2   228        1  failure 0        1
## 3625  cellular   4   aug     1486        1    -1        0  unknown 1        0
## 3626   unknown  19   jun      266        4    -1        0  unknown 0        0
## 3627  cellular  28   jul       36        5    -1        0  unknown 0        0
## 3628  cellular   4   feb       93        1    -1        0  unknown 0        0
## 3629  cellular  20   apr      155        1   154        2  failure 0        0
## 3630  cellular  18   nov      251        2    -1        0  unknown 0        0
## 3631  cellular  26   may      217        1    -1        0  unknown 0        1
## 3632  cellular  11   aug      108        5    -1        0  unknown 0        0
## 3633   unknown  20   jun       44        2    -1        0  unknown 0        0
## 3634  cellular  20   aug      162        2    -1        0  unknown 0        0
## 3635   unknown  28   may      106        3    -1        0  unknown 0        1
## 3636  cellular  30   apr      439        2    -1        0  unknown 1        1
## 3637  cellular  13   may      272        1   342        2    other 0        0
## 3638  cellular  11   may      131        2    -1        0  unknown 0        0
## 3639  cellular   4   feb      214        2   259        2  failure 0        1
## 3640  cellular  22   jun      154        1   124        1    other 0        0
## 3641  cellular   3   mar       83        1    -1        0  unknown 1        0
## 3642  cellular  10   jul       81        6    -1        0  unknown 0        0
## 3643   unknown   5   oct        6        1    -1        0  unknown 0        0
## 3644   unknown   6   jun       24        1    -1        0  unknown 0        0
## 3645  cellular   6   may       37        1    -1        0  unknown 0        0
## 3646  cellular  26   apr      125        2   182        1  failure 0        0
## 3647   unknown  20   jun       95        1    -1        0  unknown 0        0
## 3648   unknown  21   may      250        2    -1        0  unknown 0        0
## 3649  cellular  28   jul      136        2    -1        0  unknown 0        0
## 3650  cellular  19   nov      122        2    -1        0  unknown 0        0
## 3651   unknown  17   jun       48        2    -1        0  unknown 0        0
## 3652  cellular  18   mar      278        2    -1        0  unknown 1        0
## 3653  cellular  20   nov      769        4    -1        0  unknown 0        0
## 3654  cellular  17   jul      260        1    -1        0  unknown 0        0
## 3655  cellular  14   apr      314        1    -1        0  unknown 0        0
## 3656   unknown   4   jun      184        2    -1        0  unknown 0        0
## 3657   unknown  19   may      149        4    -1        0  unknown 0        0
## 3658  cellular   9   jul      170        1    -1        0  unknown 0        0
## 3659  cellular  29   jan       41        2   261        1  failure 0        0
## 3660  cellular  15   apr      190        2    -1        0  unknown 0        0
## 3661  cellular  14   may      143        1    -1        0  unknown 0        0
## 3662   unknown  23   may       24        1    -1        0  unknown 0        0
## 3663  cellular   3   sep      431        1   466        3  success 1        1
## 3664  cellular   8   aug       75        2    -1        0  unknown 0        0
## 3665  cellular   7   jul      285        1    -1        0  unknown 0        0
## 3666  cellular  22   aug      217        5    -1        0  unknown 0        0
## 3667   unknown  20   jun      238        3    -1        0  unknown 0        0
## 3668  cellular  23   oct       56        4    -1        0  unknown 0        0
## 3669   unknown  20   may      843        2    -1        0  unknown 1        0
## 3670  cellular  24   mar      170        3    -1        0  unknown 1        0
## 3671  cellular  18   may      201        2   293        6    other 0        0
## 3672  cellular  30   jan      868        1    -1        0  unknown 0        0
## 3673  cellular  25   aug     1152        6    -1        0  unknown 1        0
## 3674   unknown  17   jun      160        4    -1        0  unknown 0        0
## 3675  cellular  27   aug       57        6    -1        0  unknown 0        0
## 3676  cellular   2   feb      100        1    -1        0  unknown 0        1
## 3677   unknown  12   may       71        2    -1        0  unknown 0        0
## 3678  cellular  29   aug      961        4    -1        0  unknown 0        0
## 3679  cellular  11   sep      339        1    38        1  failure 0        0
## 3680  cellular  12   may      416        4    -1        0  unknown 0        0
## 3681  cellular  15   apr      349        1    -1        0  unknown 0        0
## 3682  cellular  10   nov      185        1    -1        0  unknown 0        0
## 3683   unknown  13   aug        9        1    -1        0  unknown 0        0
## 3684  cellular  19   aug      173        3    -1        0  unknown 0        0
## 3685   unknown  30   may      158        1    -1        0  unknown 0        0
## 3686  cellular   8   jul      185        2    -1        0  unknown 0        0
## 3687  cellular  15   may       14        2   344        3    other 0        0
## 3688  cellular  31   jul       45        3    -1        0  unknown 0        0
## 3689  cellular  29   aug      201        2    -1        0  unknown 0        0
## 3690   unknown   2   jun      193        5    -1        0  unknown 0        0
## 3691  cellular  17   nov      409        2    -1        0  unknown 1        0
## 3692  cellular  27   apr      144        1    -1        0  unknown 0        0
## 3693  cellular  17   nov      279        1    -1        0  unknown 0        0
## 3694   unknown  13   may      180        1    -1        0  unknown 0        1
## 3695   unknown  13   may       18        1    -1        0  unknown 0        0
## 3696  cellular  17   dec      221        3    -1        0  unknown 1        0
## 3697  cellular  27   aug      212       15    -1        0  unknown 0        0
## 3698  cellular   5   aug      112        2    -1        0  unknown 0        0
## 3699  cellular  18   may      175        1   293        5  failure 0        0
## 3700   unknown  27   may      148        3    -1        0  unknown 0        0
## 3701  cellular   6   jul      335        3   194        2  failure 1        0
## 3702  cellular   9   jul       36        6    -1        0  unknown 0        0
## 3703 telephone  31   jul      350       15    -1        0  unknown 0        0
##      age_&amp;lt;_31 age_&amp;lt;_34 age_&amp;lt;_36 age_&amp;lt;_39 age_&amp;lt;_42 age_&amp;lt;_46 age_&amp;lt;_51 age_&amp;lt;_56
## 1           0        0        1        0        0        0        0        0
## 2           0        0        0        0        0        0        1        0
## 3           0        0        0        1        0        0        0        0
## 4           0        0        0        0        0        0        1        0
## 5           0        0        0        0        0        0        0        1
## 6           0        0        0        0        1        0        0        0
## 7           0        0        0        0        0        0        0        0
## 8           0        1        0        0        0        0        0        0
## 9           0        0        0        0        0        0        1        0
## 10          0        1        0        0        0        0        0        0
## 11          0        1        0        0        0        0        0        0
## 12          0        0        0        0        0        0        1        0
## 13          0        0        0        0        1        0        0        0
## 14          0        0        0        1        0        0        0        0
## 15          0        1        0        0        0        0        0        0
## 16          0        0        0        0        0        1        0        0
## 17          0        0        0        0        0        0        0        0
## 18          0        0        0        0        0        0        0        1
## 19          0        0        0        0        0        1        0        0
## 20          0        0        0        0        0        0        0        0
## 21          0        0        0        0        0        0        0        1
## 22          0        0        0        0        0        1        0        0
## 23          0        0        0        0        0        0        0        1
## 24          0        0        0        0        1        0        0        0
## 25          0        0        0        0        0        0        0        0
## 26          0        1        0        0        0        0        0        0
## 27          0        1        0        0        0        0        0        0
## 28          0        0        0        0        0        1        0        0
## 29          0        0        0        0        0        0        0        0
## 30          0        0        0        1        0        0        0        0
## 31          0        0        0        0        0        0        0        1
## 32          0        0        0        0        0        0        0        1
## 33          0        0        0        1        0        0        0        0
## 34          0        0        0        1        0        0        0        0
## 35          0        1        0        0        0        0        0        0
## 36          0        0        0        0        0        1        0        0
## 37          0        0        1        0        0        0        0        0
## 38          0        0        0        1        0        0        0        0
## 39          0        0        0        0        0        0        0        0
## 40          0        0        0        0        0        0        0        1
## 41          0        0        0        0        0        0        0        1
## 42          0        0        0        0        0        0        0        0
## 43          0        1        0        0        0        0        0        0
## 44          0        0        0        0        0        0        0        0
## 45          1        0        0        0        0        0        0        0
## 46          0        0        0        0        0        0        1        0
## 47          0        0        0        1        0        0        0        0
## 48          0        0        0        0        0        0        0        0
## 49          0        0        0        0        0        0        0        0
## 50          0        0        0        0        0        0        0        0
## 51          0        0        0        0        1        0        0        0
## 52          0        0        0        0        1        0        0        0
## 53          0        1        0        0        0        0        0        0
## 54          0        1        0        0        0        0        0        0
## 55          0        0        0        0        0        0        0        0
## 56          0        0        0        0        0        0        0        1
## 57          0        1        0        0        0        0        0        0
## 58          0        1        0        0        0        0        0        0
## 59          0        1        0        0        0        0        0        0
## 60          0        0        0        0        0        1        0        0
## 61          0        0        0        0        0        0        0        0
## 62          0        1        0        0        0        0        0        0
## 63          1        0        0        0        0        0        0        0
## 64          0        0        0        0        0        1        0        0
## 65          0        0        0        0        0        1        0        0
## 66          0        0        0        0        0        0        0        0
## 67          0        0        0        0        0        0        0        0
## 68          0        1        0        0        0        0        0        0
## 69          0        1        0        0        0        0        0        0
## 70          0        0        0        1        0        0        0        0
## 71          0        1        0        0        0        0        0        0
## 72          0        0        0        0        1        0        0        0
## 73          0        0        0        0        0        1        0        0
## 74          0        0        0        0        0        0        0        0
## 75          0        0        0        0        0        0        0        0
## 76          0        0        0        0        0        0        1        0
## 77          0        0        1        0        0        0        0        0
## 78          0        0        0        0        0        0        1        0
## 79          0        0        0        0        0        0        1        0
## 80          0        0        0        0        0        0        0        0
## 81          0        1        0        0        0        0        0        0
## 82          1        0        0        0        0        0        0        0
## 83          0        0        0        0        0        0        1        0
## 84          1        0        0        0        0        0        0        0
## 85          0        1        0        0        0        0        0        0
## 86          0        0        0        0        0        1        0        0
## 87          0        0        1        0        0        0        0        0
## 88          0        0        0        0        0        0        0        0
## 89          0        1        0        0        0        0        0        0
## 90          0        0        0        0        0        0        1        0
## 91          0        0        1        0        0        0        0        0
## 92          1        0        0        0        0        0        0        0
## 93          1        0        0        0        0        0        0        0
## 94          0        0        0        0        0        0        0        0
## 95          0        0        0        0        0        0        0        0
## 96          0        0        0        0        0        0        1        0
## 97          0        0        0        1        0        0        0        0
## 98          0        0        1        0        0        0        0        0
## 99          0        0        0        0        0        1        0        0
## 100         0        0        1        0        0        0        0        0
## 101         0        0        0        0        0        0        0        0
## 102         0        0        0        0        0        0        0        0
## 103         0        0        0        0        0        0        0        1
## 104         0        0        0        0        0        1        0        0
## 105         0        0        0        0        0        0        1        0
## 106         0        0        0        0        0        0        0        0
## 107         0        0        0        1        0        0        0        0
## 108         0        0        0        0        1        0        0        0
## 109         0        0        0        0        0        1        0        0
## 110         0        0        0        0        0        1        0        0
## 111         0        0        0        0        0        0        0        0
## 112         0        0        0        0        0        0        0        0
## 113         0        0        0        0        0        0        0        0
## 114         0        0        0        1        0        0        0        0
## 115         1        0        0        0        0        0        0        0
## 116         0        0        0        0        0        0        0        1
## 117         0        0        0        0        0        0        0        0
## 118         0        0        0        0        0        0        0        1
## 119         0        0        0        0        1        0        0        0
## 120         0        0        0        0        0        1        0        0
## 121         0        0        0        0        0        0        0        0
## 122         0        0        0        0        1        0        0        0
## 123         0        0        0        0        0        0        1        0
## 124         0        0        0        0        0        0        0        1
## 125         0        0        1        0        0        0        0        0
## 126         0        1        0        0        0        0        0        0
## 127         0        1        0        0        0        0        0        0
## 128         0        0        0        0        0        0        0        0
## 129         0        0        0        0        0        0        0        1
## 130         0        0        0        0        0        0        0        0
## 131         0        1        0        0        0        0        0        0
## 132         0        0        0        0        0        0        0        1
## 133         0        0        1        0        0        0        0        0
## 134         0        0        0        0        1        0        0        0
## 135         0        0        0        0        0        1        0        0
## 136         0        0        0        0        0        1        0        0
## 137         0        0        0        0        0        0        0        1
## 138         0        0        1        0        0        0        0        0
## 139         0        0        0        0        0        1        0        0
## 140         0        0        0        1        0        0        0        0
## 141         0        1        0        0        0        0        0        0
## 142         0        0        0        0        0        0        0        0
## 143         0        0        0        0        0        0        0        1
## 144         0        1        0        0        0        0        0        0
## 145         0        0        0        1        0        0        0        0
## 146         0        0        0        0        0        0        0        1
## 147         0        0        0        0        0        0        0        1
## 148         0        0        0        0        0        0        0        0
## 149         0        0        0        0        1        0        0        0
## 150         0        0        0        0        1        0        0        0
## 151         0        0        1        0        0        0        0        0
## 152         0        0        0        1        0        0        0        0
## 153         1        0        0        0        0        0        0        0
## 154         0        0        0        0        0        0        0        1
## 155         0        0        0        0        0        0        1        0
## 156         0        1        0        0        0        0        0        0
## 157         0        0        0        0        0        1        0        0
## 158         0        0        0        0        0        0        0        1
## 159         0        0        0        0        0        0        0        0
## 160         0        0        0        0        0        1        0        0
## 161         0        0        0        1        0        0        0        0
## 162         0        0        0        0        0        0        0        0
## 163         0        0        0        0        0        0        0        1
## 164         0        0        0        0        0        0        0        0
## 165         0        0        0        0        0        0        0        1
## 166         0        0        0        0        0        0        0        0
## 167         1        0        0        0        0        0        0        0
## 168         0        0        0        0        0        0        0        0
## 169         0        0        0        0        0        0        0        0
## 170         0        0        0        0        0        0        0        0
## 171         0        0        0        1        0        0        0        0
## 172         0        1        0        0        0        0        0        0
## 173         0        0        0        0        0        0        1        0
## 174         0        1        0        0        0        0        0        0
## 175         0        0        0        0        0        0        0        0
## 176         0        0        0        0        0        0        0        0
## 177         0        0        0        0        0        0        0        0
## 178         0        1        0        0        0        0        0        0
## 179         0        0        0        1        0        0        0        0
## 180         0        0        0        0        0        0        0        1
## 181         0        0        0        0        1        0        0        0
## 182         0        0        0        0        0        0        0        0
## 183         1        0        0        0        0        0        0        0
## 184         0        1        0        0        0        0        0        0
## 185         0        0        0        0        0        0        1        0
## 186         0        0        0        0        0        0        0        0
## 187         0        0        0        0        0        0        0        1
## 188         0        0        0        0        0        0        0        0
## 189         0        1        0        0        0        0        0        0
## 190         0        0        0        0        0        0        0        1
## 191         0        0        0        0        0        1        0        0
## 192         0        0        0        0        0        0        0        0
## 193         0        0        0        0        0        0        0        1
## 194         0        0        1        0        0        0        0        0
## 195         0        0        0        0        0        1        0        0
## 196         0        0        0        0        0        0        0        0
## 197         0        0        0        0        0        0        1        0
## 198         0        0        0        0        1        0        0        0
## 199         0        0        0        0        0        0        0        1
## 200         0        0        0        0        0        0        0        0
## 201         0        0        0        0        0        0        0        0
## 202         0        1        0        0        0        0        0        0
## 203         0        0        0        0        0        0        0        0
## 204         0        0        0        1        0        0        0        0
## 205         1        0        0        0        0        0        0        0
## 206         0        0        0        1        0        0        0        0
## 207         0        0        0        0        0        0        1        0
## 208         0        0        0        0        0        0        1        0
## 209         0        0        0        0        0        0        1        0
## 210         0        0        0        1        0        0        0        0
## 211         0        0        0        0        0        1        0        0
## 212         0        1        0        0        0        0        0        0
## 213         0        0        0        0        0        0        1        0
## 214         0        0        0        0        1        0        0        0
## 215         0        0        0        0        0        0        0        0
## 216         0        0        0        0        1        0        0        0
## 217         0        0        0        0        0        0        0        0
## 218         1        0        0        0        0        0        0        0
## 219         0        0        0        0        0        0        0        1
## 220         0        0        0        0        0        1        0        0
## 221         0        0        0        0        1        0        0        0
## 222         0        0        0        0        0        0        1        0
## 223         0        0        1        0        0        0        0        0
## 224         0        1        0        0        0        0        0        0
## 225         0        0        0        0        0        0        0        1
## 226         0        0        0        0        0        0        0        0
## 227         0        0        1        0        0        0        0        0
## 228         0        0        0        0        0        0        1        0
## 229         0        0        0        0        0        1        0        0
## 230         0        0        0        0        0        0        0        0
## 231         0        0        0        0        0        0        0        0
## 232         1        0        0        0        0        0        0        0
## 233         0        0        0        0        0        0        1        0
## 234         0        0        0        0        0        0        0        1
## 235         0        1        0        0        0        0        0        0
## 236         0        1        0        0        0        0        0        0
## 237         0        1        0        0        0        0        0        0
## 238         0        1        0        0        0        0        0        0
## 239         0        0        0        0        1        0        0        0
## 240         0        0        0        0        0        0        0        0
## 241         0        0        0        0        1        0        0        0
## 242         0        1        0        0        0        0        0        0
## 243         0        0        0        0        0        0        1        0
## 244         0        0        0        0        0        1        0        0
## 245         0        0        0        0        1        0        0        0
## 246         0        0        0        1        0        0        0        0
## 247         0        0        0        0        0        0        0        0
## 248         0        0        0        0        0        1        0        0
## 249         0        0        1        0        0        0        0        0
## 250         0        0        0        0        1        0        0        0
## 251         0        0        0        0        0        0        0        0
## 252         0        0        0        0        0        1        0        0
## 253         0        0        0        0        0        0        1        0
## 254         0        0        1        0        0        0        0        0
## 255         0        0        0        0        0        0        0        0
## 256         0        0        0        0        0        1        0        0
## 257         0        0        0        0        0        0        0        1
## 258         0        0        0        0        0        1        0        0
## 259         0        0        0        0        0        1        0        0
## 260         0        0        0        0        0        1        0        0
## 261         0        0        0        0        0        0        0        0
## 262         0        0        0        0        0        0        0        1
## 263         0        0        0        0        0        0        0        0
## 264         0        1        0        0        0        0        0        0
## 265         0        0        0        0        0        0        0        0
## 266         0        0        0        0        0        0        0        1
## 267         0        0        0        0        0        0        1        0
## 268         0        1        0        0        0        0        0        0
## 269         0        0        0        0        0        1        0        0
## 270         0        0        0        1        0        0        0        0
## 271         0        0        0        0        0        0        0        1
## 272         0        0        0        0        0        0        0        0
## 273         0        0        1        0        0        0        0        0
## 274         0        1        0        0        0        0        0        0
## 275         0        0        0        0        0        1        0        0
## 276         0        0        0        0        0        0        0        0
## 277         0        0        0        1        0        0        0        0
## 278         0        0        0        0        1        0        0        0
## 279         0        0        0        0        0        0        0        0
## 280         0        0        1        0        0        0        0        0
## 281         1        0        0        0        0        0        0        0
## 282         0        0        0        0        1        0        0        0
## 283         0        0        0        0        0        0        1        0
## 284         0        0        0        1        0        0        0        0
## 285         0        0        0        0        0        0        0        0
## 286         0        0        1        0        0        0        0        0
## 287         1        0        0        0        0        0        0        0
## 288         0        0        1        0        0        0        0        0
## 289         0        0        1        0        0        0        0        0
## 290         0        1        0        0        0        0        0        0
## 291         0        0        0        0        1        0        0        0
## 292         1        0        0        0        0        0        0        0
## 293         0        0        0        0        0        0        0        0
## 294         0        0        0        1        0        0        0        0
## 295         0        0        0        0        0        0        0        1
## 296         0        0        1        0        0        0        0        0
## 297         0        0        0        0        0        1        0        0
## 298         0        0        0        1        0        0        0        0
## 299         0        0        0        0        0        1        0        0
## 300         0        0        1        0        0        0        0        0
## 301         0        0        0        1        0        0        0        0
## 302         0        0        0        1        0        0        0        0
## 303         1        0        0        0        0        0        0        0
## 304         0        0        0        0        0        1        0        0
## 305         0        0        0        0        0        0        1        0
## 306         0        0        0        0        0        1        0        0
## 307         0        0        0        0        0        0        0        0
## 308         0        1        0        0        0        0        0        0
## 309         0        0        1        0        0        0        0        0
## 310         0        0        0        0        0        0        0        0
## 311         0        0        0        0        0        1        0        0
## 312         0        0        0        0        0        0        0        0
## 313         0        0        0        1        0        0        0        0
## 314         0        0        0        1        0        0        0        0
## 315         0        0        0        0        0        0        0        0
## 316         0        1        0        0        0        0        0        0
## 317         0        0        0        0        0        0        0        0
## 318         0        0        0        0        0        0        0        0
## 319         0        0        0        0        1        0        0        0
## 320         0        0        0        0        1        0        0        0
## 321         0        0        0        0        0        0        1        0
## 322         0        0        0        1        0        0        0        0
## 323         0        1        0        0        0        0        0        0
## 324         0        0        0        0        0        1        0        0
## 325         0        0        0        0        0        0        0        0
## 326         1        0        0        0        0        0        0        0
## 327         0        0        0        1        0        0        0        0
## 328         0        1        0        0        0        0        0        0
## 329         0        0        0        0        1        0        0        0
## 330         0        0        0        0        0        0        0        0
## 331         0        0        0        0        0        0        0        0
## 332         0        0        0        0        0        0        0        0
## 333         0        0        0        0        0        0        1        0
## 334         0        0        0        1        0        0        0        0
## 335         0        0        0        1        0        0        0        0
## 336         0        0        0        0        0        0        0        0
## 337         0        0        0        0        0        0        0        1
## 338         0        0        1        0        0        0        0        0
## 339         0        0        1        0        0        0        0        0
## 340         0        0        0        0        1        0        0        0
## 341         0        0        0        0        0        0        0        1
## 342         0        0        0        0        0        0        0        1
## 343         0        0        0        0        1        0        0        0
## 344         0        0        0        0        0        0        1        0
## 345         0        0        0        0        0        0        0        0
## 346         0        0        0        0        0        0        0        0
## 347         0        0        1        0        0        0        0        0
## 348         0        0        0        0        1        0        0        0
## 349         0        0        0        0        0        0        0        1
## 350         0        0        0        0        0        0        0        0
## 351         0        0        0        0        0        0        0        0
## 352         0        0        0        0        0        0        0        0
## 353         0        0        0        0        0        0        1        0
## 354         0        0        1        0        0        0        0        0
## 355         0        0        0        1        0        0        0        0
## 356         1        0        0        0        0        0        0        0
## 357         0        0        0        1        0        0        0        0
## 358         0        0        0        1        0        0        0        0
## 359         0        0        0        0        0        1        0        0
## 360         0        0        0        0        0        1        0        0
## 361         0        0        0        0        0        0        0        0
## 362         0        0        0        1        0        0        0        0
## 363         0        0        0        0        1        0        0        0
## 364         0        0        1        0        0        0        0        0
## 365         0        0        0        0        0        0        0        1
## 366         0        0        0        1        0        0        0        0
## 367         1        0        0        0        0        0        0        0
## 368         0        0        1        0        0        0        0        0
## 369         0        0        0        0        0        1        0        0
## 370         0        1        0        0        0        0        0        0
## 371         0        1        0        0        0        0        0        0
## 372         0        0        1        0        0        0        0        0
## 373         0        0        0        0        1        0        0        0
## 374         0        0        1        0        0        0        0        0
## 375         0        0        0        0        0        0        0        1
## 376         0        1        0        0        0        0        0        0
## 377         0        0        0        0        0        0        0        0
## 378         0        0        1        0        0        0        0        0
## 379         0        0        0        0        0        0        0        1
## 380         0        0        0        1        0        0        0        0
## 381         0        0        0        0        1        0        0        0
## 382         0        0        0        0        0        0        1        0
## 383         0        1        0        0        0        0        0        0
## 384         0        0        0        0        0        0        0        0
## 385         0        0        0        0        0        0        0        1
## 386         0        0        0        0        1        0        0        0
## 387         0        0        0        0        0        0        1        0
## 388         0        0        0        0        1        0        0        0
## 389         0        0        0        0        0        0        1        0
## 390         0        0        0        0        0        1        0        0
## 391         0        0        0        0        0        0        1        0
## 392         0        0        0        0        1        0        0        0
## 393         0        0        0        0        0        0        0        0
## 394         0        0        0        1        0        0        0        0
## 395         0        0        0        1        0        0        0        0
## 396         0        1        0        0        0        0        0        0
## 397         0        0        0        0        0        0        0        1
## 398         0        0        0        1        0        0        0        0
## 399         0        0        0        0        1        0        0        0
## 400         0        0        0        0        0        1        0        0
## 401         0        0        0        0        0        1        0        0
## 402         0        0        0        1        0        0        0        0
## 403         0        0        0        0        0        0        1        0
## 404         0        0        0        0        0        0        0        0
## 405         0        0        0        0        1        0        0        0
## 406         0        0        0        0        0        0        1        0
## 407         0        0        0        0        0        0        0        0
## 408         0        0        0        0        0        0        0        1
## 409         0        0        0        0        0        0        1        0
## 410         1        0        0        0        0        0        0        0
## 411         0        0        0        0        0        0        0        1
## 412         0        0        0        0        1        0        0        0
## 413         0        1        0        0        0        0        0        0
## 414         0        1        0        0        0        0        0        0
## 415         0        1        0        0        0        0        0        0
## 416         0        0        0        0        0        0        0        0
## 417         0        0        0        0        0        0        1        0
## 418         0        0        0        0        0        0        0        0
## 419         0        0        0        1        0        0        0        0
## 420         0        0        0        0        0        1        0        0
## 421         0        1        0        0        0        0        0        0
## 422         0        0        0        0        0        0        1        0
## 423         0        1        0        0        0        0        0        0
## 424         0        0        0        1        0        0        0        0
## 425         0        0        0        0        0        0        1        0
## 426         1        0        0        0        0        0        0        0
## 427         0        0        1        0        0        0        0        0
## 428         0        0        0        0        0        1        0        0
## 429         0        0        1        0        0        0        0        0
## 430         1        0        0        0        0        0        0        0
## 431         0        0        0        0        0        0        0        0
## 432         0        0        0        0        0        0        1        0
## 433         0        0        1        0        0        0        0        0
## 434         0        0        0        1        0        0        0        0
## 435         0        0        0        0        0        1        0        0
## 436         0        0        0        0        0        0        0        1
## 437         0        0        0        0        0        0        0        0
## 438         0        0        0        0        0        0        1        0
## 439         0        0        0        0        0        0        0        0
## 440         0        0        0        0        0        0        0        1
## 441         0        0        0        0        0        0        0        0
## 442         0        0        0        0        0        1        0        0
## 443         0        0        0        0        0        0        1        0
## 444         0        0        0        0        1        0        0        0
## 445         0        0        0        0        0        0        1        0
## 446         0        0        0        1        0        0        0        0
## 447         0        0        0        1        0        0        0        0
## 448         1        0        0        0        0        0        0        0
## 449         1        0        0        0        0        0        0        0
## 450         0        0        0        0        1        0        0        0
## 451         0        0        0        1        0        0        0        0
## 452         0        0        0        0        0        0        0        1
## 453         1        0        0        0        0        0        0        0
## 454         0        1        0        0        0        0        0        0
## 455         0        0        0        0        0        1        0        0
## 456         1        0        0        0        0        0        0        0
## 457         0        0        0        0        0        1        0        0
## 458         0        0        0        0        0        0        1        0
## 459         0        1        0        0        0        0        0        0
## 460         0        1        0        0        0        0        0        0
## 461         0        0        0        0        0        0        0        1
## 462         0        0        0        1        0        0        0        0
## 463         0        0        0        0        0        0        1        0
## 464         0        0        0        0        0        1        0        0
## 465         1        0        0        0        0        0        0        0
## 466         0        0        0        0        1        0        0        0
## 467         0        0        0        0        0        0        0        0
## 468         0        0        0        0        0        1        0        0
## 469         0        0        0        0        0        0        1        0
## 470         0        0        0        0        0        0        0        0
## 471         0        0        1        0        0        0        0        0
## 472         1        0        0        0        0        0        0        0
## 473         0        0        0        0        0        0        1        0
## 474         0        1        0        0        0        0        0        0
## 475         0        0        0        0        0        0        1        0
## 476         0        0        0        1        0        0        0        0
## 477         0        0        1        0        0        0        0        0
## 478         0        0        0        0        0        0        0        0
## 479         0        0        0        0        0        0        0        1
## 480         0        0        0        0        0        1        0        0
## 481         0        0        0        0        0        1        0        0
## 482         0        0        0        0        0        1        0        0
## 483         0        0        0        0        0        0        0        1
## 484         0        0        0        0        0        0        0        0
## 485         0        0        0        0        0        0        0        0
## 486         0        0        0        0        0        0        0        1
## 487         0        1        0        0        0        0        0        0
## 488         0        0        0        0        0        0        0        0
## 489         0        0        0        0        1        0        0        0
## 490         0        0        0        0        0        0        1        0
## 491         0        0        0        0        0        0        0        1
## 492         0        0        0        0        0        0        0        0
## 493         0        0        0        0        0        0        0        0
## 494         0        0        0        0        0        1        0        0
## 495         0        0        0        0        0        0        0        1
## 496         0        0        0        0        1        0        0        0
## 497         0        1        0        0        0        0        0        0
## 498         0        0        0        1        0        0        0        0
## 499         0        0        0        1        0        0        0        0
## 500         0        0        0        0        0        0        0        0
## 501         0        1        0        0        0        0        0        0
## 502         0        0        0        0        1        0        0        0
## 503         0        0        0        0        0        0        1        0
## 504         0        0        0        0        1        0        0        0
## 505         0        0        0        0        0        1        0        0
## 506         0        0        1        0        0        0        0        0
## 507         0        0        0        0        0        0        0        1
## 508         0        0        0        1        0        0        0        0
## 509         0        0        0        0        0        0        0        0
## 510         0        0        0        0        0        0        0        1
## 511         0        0        0        0        0        0        0        0
## 512         1        0        0        0        0        0        0        0
## 513         0        1        0        0        0        0        0        0
## 514         0        0        0        1        0        0        0        0
## 515         1        0        0        0        0        0        0        0
## 516         0        0        0        0        0        0        0        1
## 517         0        0        0        0        0        0        0        0
## 518         0        0        0        1        0        0        0        0
## 519         0        0        0        0        0        0        0        0
## 520         0        0        0        0        1        0        0        0
## 521         0        0        0        0        0        0        0        0
## 522         0        1        0        0        0        0        0        0
## 523         0        0        0        0        0        0        0        1
## 524         0        0        0        0        0        1        0        0
## 525         0        0        1        0        0        0        0        0
## 526         0        0        0        0        0        1        0        0
## 527         0        0        0        1        0        0        0        0
## 528         0        0        0        0        0        0        0        0
## 529         0        1        0        0        0        0        0        0
## 530         1        0        0        0        0        0        0        0
## 531         0        0        0        0        1        0        0        0
## 532         0        0        0        1        0        0        0        0
## 533         0        0        0        0        1        0        0        0
## 534         0        0        0        0        1        0        0        0
## 535         0        0        0        0        0        1        0        0
## 536         0        1        0        0        0        0        0        0
## 537         0        1        0        0        0        0        0        0
## 538         1        0        0        0        0        0        0        0
## 539         0        0        0        0        1        0        0        0
## 540         0        0        0        0        0        0        1        0
## 541         0        1        0        0        0        0        0        0
## 542         0        1        0        0        0        0        0        0
## 543         0        0        0        0        0        0        1        0
## 544         0        0        1        0        0        0        0        0
## 545         0        0        0        0        0        1        0        0
## 546         0        0        0        0        0        0        1        0
## 547         1        0        0        0        0        0        0        0
## 548         0        0        0        0        0        0        0        1
## 549         1        0        0        0        0        0        0        0
## 550         0        0        0        0        0        0        0        0
## 551         0        0        0        1        0        0        0        0
## 552         0        0        0        0        0        0        0        1
## 553         0        1        0        0        0        0        0        0
## 554         0        0        0        0        0        0        0        1
## 555         0        0        0        0        0        1        0        0
## 556         0        0        0        0        0        0        1        0
## 557         0        0        0        0        0        0        0        0
## 558         0        0        0        1        0        0        0        0
## 559         0        1        0        0        0        0        0        0
## 560         0        0        0        0        0        0        1        0
## 561         0        0        0        0        0        1        0        0
## 562         0        1        0        0        0        0        0        0
## 563         0        1        0        0        0        0        0        0
## 564         1        0        0        0        0        0        0        0
## 565         0        0        0        1        0        0        0        0
## 566         0        1        0        0        0        0        0        0
## 567         0        0        0        0        0        0        0        0
## 568         0        0        0        0        0        0        1        0
## 569         0        0        0        0        0        0        0        0
## 570         0        0        0        0        1        0        0        0
## 571         0        0        0        0        0        0        0        1
## 572         0        0        0        0        1        0        0        0
## 573         0        0        1        0        0        0        0        0
## 574         0        0        0        1        0        0        0        0
## 575         0        0        0        0        0        0        0        0
## 576         0        0        0        0        0        0        0        1
## 577         1        0        0        0        0        0        0        0
## 578         1        0        0        0        0        0        0        0
## 579         0        0        0        0        0        0        1        0
## 580         0        0        0        0        0        1        0        0
## 581         0        0        0        0        0        0        0        0
## 582         0        1        0        0        0        0        0        0
## 583         0        0        0        1        0        0        0        0
## 584         0        0        0        0        0        0        0        0
## 585         0        0        0        1        0        0        0        0
## 586         0        0        0        0        0        0        0        0
## 587         0        0        0        0        0        0        0        0
## 588         1        0        0        0        0        0        0        0
## 589         0        0        0        0        0        0        1        0
## 590         0        0        1        0        0        0        0        0
## 591         0        0        0        0        1        0        0        0
## 592         0        0        0        0        0        0        0        1
## 593         0        1        0        0        0        0        0        0
## 594         0        0        0        0        0        0        1        0
## 595         0        0        0        0        0        0        0        0
## 596         0        1        0        0        0        0        0        0
## 597         1        0        0        0        0        0        0        0
## 598         0        0        0        0        0        0        0        0
## 599         0        0        1        0        0        0        0        0
## 600         0        0        0        0        0        0        1        0
## 601         0        1        0        0        0        0        0        0
## 602         0        0        0        0        0        0        0        0
## 603         0        0        1        0        0        0        0        0
## 604         0        0        0        0        0        0        0        0
## 605         0        0        0        1        0        0        0        0
## 606         0        0        0        0        0        0        0        0
## 607         0        0        0        0        1        0        0        0
## 608         0        0        1        0        0        0        0        0
## 609         0        1        0        0        0        0        0        0
## 610         0        1        0        0        0        0        0        0
## 611         1        0        0        0        0        0        0        0
## 612         0        0        0        0        0        0        0        1
## 613         0        0        0        0        0        1        0        0
## 614         0        0        0        1        0        0        0        0
## 615         0        0        0        1        0        0        0        0
## 616         0        0        0        0        0        0        1        0
## 617         0        0        0        0        0        0        0        0
## 618         0        0        0        1        0        0        0        0
## 619         0        0        1        0        0        0        0        0
## 620         0        0        1        0        0        0        0        0
## 621         0        0        1        0        0        0        0        0
## 622         0        1        0        0        0        0        0        0
## 623         0        0        0        0        0        0        1        0
## 624         0        0        0        0        0        0        1        0
## 625         0        0        0        0        0        0        0        0
## 626         0        0        0        0        0        0        0        0
## 627         0        0        0        0        0        0        0        1
## 628         0        1        0        0        0        0        0        0
## 629         0        0        0        0        0        0        0        0
## 630         0        0        0        0        0        1        0        0
## 631         0        0        0        0        0        0        1        0
## 632         0        0        0        0        0        0        0        0
## 633         0        0        0        0        0        0        0        0
## 634         0        0        1        0        0        0        0        0
## 635         0        0        0        0        0        0        0        1
## 636         0        1        0        0        0        0        0        0
## 637         0        1        0        0        0        0        0        0
## 638         0        0        0        0        0        1        0        0
## 639         0        0        0        0        0        0        1        0
## 640         0        0        0        0        0        0        0        0
## 641         0        0        0        0        0        0        0        1
## 642         0        0        0        1        0        0        0        0
## 643         0        0        0        0        1        0        0        0
## 644         0        0        0        1        0        0        0        0
## 645         0        0        0        1        0        0        0        0
## 646         0        0        1        0        0        0        0        0
## 647         1        0        0        0        0        0        0        0
## 648         0        0        0        1        0        0        0        0
## 649         0        0        0        0        0        0        1        0
## 650         0        0        0        0        0        0        0        1
## 651         0        0        1        0        0        0        0        0
## 652         0        0        0        0        0        0        0        1
## 653         1        0        0        0        0        0        0        0
## 654         0        0        0        1        0        0        0        0
## 655         0        1        0        0        0        0        0        0
## 656         0        1        0        0        0        0        0        0
## 657         0        0        0        0        1        0        0        0
## 658         0        0        0        0        0        1        0        0
## 659         0        0        0        0        0        0        1        0
## 660         0        0        0        0        0        0        0        1
## 661         0        0        0        1        0        0        0        0
## 662         0        0        0        0        0        0        0        0
## 663         0        0        0        0        0        0        0        0
## 664         0        0        0        0        0        0        1        0
## 665         0        0        0        0        0        0        0        0
## 666         0        0        0        0        0        1        0        0
## 667         0        1        0        0        0        0        0        0
## 668         0        0        0        0        0        1        0        0
## 669         0        0        0        0        0        0        0        0
## 670         0        0        0        1        0        0        0        0
## 671         0        0        0        0        0        0        0        1
## 672         0        0        0        0        0        0        1        0
## 673         0        0        0        0        0        0        0        0
## 674         0        0        0        1        0        0        0        0
## 675         0        0        0        0        0        0        0        0
## 676         0        0        0        1        0        0        0        0
## 677         0        0        0        0        1        0        0        0
## 678         0        0        0        0        0        0        0        0
## 679         0        0        0        0        0        0        0        0
## 680         0        0        0        0        0        0        0        1
## 681         0        0        0        0        0        0        1        0
## 682         0        0        0        1        0        0        0        0
## 683         0        0        0        1        0        0        0        0
## 684         0        0        0        0        0        0        0        1
## 685         0        1        0        0        0        0        0        0
## 686         0        1        0        0        0        0        0        0
## 687         0        0        0        0        0        0        0        0
## 688         0        0        0        0        0        0        1        0
## 689         0        0        0        0        0        1        0        0
## 690         0        0        0        0        0        0        1        0
## 691         0        0        0        0        1        0        0        0
## 692         0        0        0        1        0        0        0        0
## 693         0        0        1        0        0        0        0        0
## 694         0        0        0        1        0        0        0        0
## 695         1        0        0        0        0        0        0        0
## 696         0        0        0        0        0        0        0        0
## 697         1        0        0        0        0        0        0        0
## 698         0        0        0        0        0        0        0        1
## 699         0        1        0        0        0        0        0        0
## 700         0        0        0        1        0        0        0        0
## 701         0        0        0        0        1        0        0        0
## 702         0        0        0        0        0        0        1        0
## 703         0        0        0        0        0        0        0        0
## 704         0        0        0        0        0        0        0        0
## 705         0        0        1        0        0        0        0        0
## 706         0        0        0        0        0        0        1        0
## 707         0        0        0        0        0        0        0        0
## 708         0        0        0        0        0        0        1        0
## 709         1        0        0        0        0        0        0        0
## 710         0        0        0        0        1        0        0        0
## 711         0        0        0        0        0        0        1        0
## 712         0        0        1        0        0        0        0        0
## 713         0        0        0        0        0        0        0        0
## 714         0        0        0        0        0        0        1        0
## 715         0        1        0        0        0        0        0        0
## 716         0        0        0        1        0        0        0        0
## 717         0        0        0        1        0        0        0        0
## 718         0        0        0        0        1        0        0        0
## 719         0        0        0        0        0        0        0        0
## 720         0        0        1        0        0        0        0        0
## 721         0        0        0        0        1        0        0        0
## 722         0        0        0        0        1        0        0        0
## 723         0        1        0        0        0        0        0        0
## 724         0        0        1        0        0        0        0        0
## 725         0        0        1        0        0        0        0        0
## 726         0        0        0        0        0        1        0        0
## 727         0        0        0        0        0        0        0        1
## 728         0        1        0        0        0        0        0        0
## 729         0        1        0        0        0        0        0        0
## 730         0        0        0        0        1        0        0        0
## 731         0        0        0        1        0        0        0        0
## 732         0        0        0        0        0        0        0        0
## 733         0        0        0        0        0        0        0        0
## 734         0        0        0        1        0        0        0        0
## 735         0        0        0        0        1        0        0        0
## 736         0        0        0        1        0        0        0        0
## 737         0        0        0        0        0        0        0        0
## 738         1        0        0        0        0        0        0        0
## 739         0        1        0        0        0        0        0        0
## 740         0        0        0        0        0        0        1        0
## 741         0        0        0        0        0        1        0        0
## 742         0        0        0        0        0        1        0        0
## 743         0        1        0        0        0        0        0        0
## 744         0        0        0        0        0        0        0        1
## 745         0        0        0        1        0        0        0        0
## 746         0        0        0        0        0        0        0        0
## 747         0        0        0        0        1        0        0        0
## 748         1        0        0        0        0        0        0        0
## 749         0        0        0        0        0        1        0        0
## 750         0        0        0        0        0        0        1        0
## 751         0        0        0        1        0        0        0        0
## 752         0        0        0        0        0        1        0        0
## 753         0        0        0        0        0        0        0        0
## 754         0        0        0        0        1        0        0        0
## 755         0        0        0        0        0        0        0        0
## 756         1        0        0        0        0        0        0        0
## 757         0        1        0        0        0        0        0        0
## 758         1        0        0        0        0        0        0        0
## 759         0        0        0        0        0        1        0        0
## 760         1        0        0        0        0        0        0        0
## 761         0        0        0        0        0        0        0        0
## 762         0        0        0        0        0        1        0        0
## 763         0        1        0        0        0        0        0        0
## 764         0        0        0        0        1        0        0        0
## 765         0        0        1        0        0        0        0        0
## 766         0        0        0        0        1        0        0        0
## 767         0        1        0        0        0        0        0        0
## 768         0        0        0        0        0        0        1        0
## 769         0        0        0        0        0        0        0        0
## 770         0        0        0        0        0        0        0        0
## 771         0        0        0        0        0        0        1        0
## 772         0        0        0        0        0        0        0        1
## 773         0        0        0        0        0        0        1        0
## 774         0        0        0        0        0        0        1        0
## 775         0        0        0        0        1        0        0        0
## 776         0        0        1        0        0        0        0        0
## 777         0        0        0        1        0        0        0        0
## 778         0        0        0        0        0        0        0        1
## 779         0        0        0        0        0        0        1        0
## 780         0        0        0        0        0        0        1        0
## 781         0        0        0        0        0        0        0        0
## 782         0        0        1        0        0        0        0        0
## 783         1        0        0        0        0        0        0        0
## 784         0        0        0        0        0        0        0        1
## 785         0        0        0        0        0        0        0        0
## 786         0        0        0        1        0        0        0        0
## 787         0        0        0        0        0        0        0        1
## 788         1        0        0        0        0        0        0        0
## 789         0        0        0        0        0        0        0        1
## 790         1        0        0        0        0        0        0        0
## 791         0        0        0        0        0        0        0        0
## 792         0        0        0        0        0        0        0        1
## 793         0        0        0        0        0        0        0        0
## 794         0        0        0        0        0        0        1        0
## 795         0        0        0        0        0        1        0        0
## 796         0        0        0        0        1        0        0        0
## 797         0        0        0        0        0        0        1        0
## 798         0        0        1        0        0        0        0        0
## 799         0        0        0        1        0        0        0        0
## 800         0        0        0        0        1        0        0        0
## 801         0        0        0        0        0        0        1        0
## 802         0        0        0        0        0        0        0        0
## 803         0        0        1        0        0        0        0        0
## 804         0        0        0        0        0        0        0        1
## 805         0        0        0        0        1        0        0        0
## 806         0        0        1        0        0        0        0        0
## 807         0        0        0        0        0        0        0        1
## 808         0        0        0        0        0        1        0        0
## 809         0        0        0        0        0        0        1        0
## 810         0        0        0        0        0        1        0        0
## 811         0        0        0        1        0        0        0        0
## 812         0        0        1        0        0        0        0        0
## 813         0        0        0        0        0        0        1        0
## 814         0        0        1        0        0        0        0        0
## 815         0        1        0        0        0        0        0        0
## 816         0        0        0        0        1        0        0        0
## 817         0        0        0        0        1        0        0        0
## 818         0        0        0        0        0        1        0        0
## 819         0        0        0        0        0        0        0        0
## 820         0        0        0        0        0        0        1        0
## 821         0        0        0        0        0        1        0        0
## 822         0        0        0        0        0        0        1        0
## 823         0        0        1        0        0        0        0        0
## 824         0        1        0        0        0        0        0        0
## 825         0        1        0        0        0        0        0        0
## 826         0        0        0        0        0        1        0        0
## 827         0        0        0        0        0        1        0        0
## 828         0        0        0        0        1        0        0        0
## 829         0        0        0        0        0        0        0        0
## 830         0        0        0        1        0        0        0        0
## 831         0        0        0        0        1        0        0        0
## 832         0        0        0        0        0        0        0        0
## 833         0        0        0        0        0        0        1        0
## 834         0        1        0        0        0        0        0        0
## 835         0        0        0        0        0        1        0        0
## 836         0        1        0        0        0        0        0        0
## 837         0        0        0        0        0        0        0        1
## 838         0        0        0        0        0        0        0        1
## 839         0        0        0        1        0        0        0        0
## 840         0        0        0        0        0        1        0        0
## 841         0        1        0        0        0        0        0        0
## 842         0        0        0        0        1        0        0        0
## 843         0        0        0        0        0        1        0        0
## 844         0        1        0        0        0        0        0        0
## 845         0        0        0        0        0        1        0        0
## 846         0        0        0        0        0        0        0        0
## 847         0        0        0        0        0        0        1        0
## 848         0        0        0        0        0        0        1        0
## 849         0        0        0        0        0        0        0        0
## 850         0        1        0        0        0        0        0        0
## 851         0        0        0        1        0        0        0        0
## 852         0        0        0        0        0        0        0        1
## 853         0        0        0        0        0        0        0        1
## 854         0        0        0        0        0        0        1        0
## 855         0        0        0        0        0        0        0        1
## 856         0        0        0        0        0        0        1        0
## 857         0        0        0        0        0        0        0        0
## 858         0        0        0        0        0        0        1        0
## 859         0        1        0        0        0        0        0        0
## 860         1        0        0        0        0        0        0        0
## 861         0        0        0        0        0        0        0        1
## 862         0        0        0        0        0        0        1        0
## 863         0        0        0        0        0        0        0        0
## 864         0        0        0        0        0        1        0        0
## 865         0        0        0        0        1        0        0        0
## 866         0        0        0        0        0        0        1        0
## 867         0        0        0        0        0        0        0        0
## 868         0        0        0        1        0        0        0        0
## 869         0        0        1        0        0        0        0        0
## 870         0        0        0        0        1        0        0        0
## 871         0        0        0        0        0        0        0        0
## 872         0        0        0        0        1        0        0        0
## 873         0        0        0        1        0        0        0        0
## 874         0        0        0        0        0        0        1        0
## 875         0        0        0        0        0        1        0        0
## 876         0        1        0        0        0        0        0        0
## 877         0        0        0        0        0        0        0        1
## 878         0        0        0        0        0        0        0        0
## 879         0        0        0        0        0        0        0        0
## 880         0        0        1        0        0        0        0        0
## 881         0        0        0        0        0        1        0        0
## 882         0        0        0        0        0        0        1        0
## 883         0        0        0        0        1        0        0        0
## 884         0        0        0        0        0        0        0        0
## 885         0        1        0        0        0        0        0        0
## 886         0        1        0        0        0        0        0        0
## 887         0        0        0        0        1        0        0        0
## 888         0        0        0        0        0        0        0        0
## 889         0        0        0        0        0        1        0        0
## 890         0        0        0        0        1        0        0        0
## 891         1        0        0        0        0        0        0        0
## 892         0        0        1        0        0        0        0        0
## 893         1        0        0        0        0        0        0        0
## 894         0        0        0        0        0        1        0        0
## 895         0        0        0        0        0        1        0        0
## 896         0        0        0        1        0        0        0        0
## 897         0        0        0        0        0        0        0        0
## 898         0        0        0        0        0        0        0        0
## 899         0        1        0        0        0        0        0        0
## 900         0        0        1        0        0        0        0        0
## 901         0        0        0        0        0        1        0        0
## 902         0        0        0        1        0        0        0        0
## 903         0        0        0        1        0        0        0        0
## 904         0        0        0        0        0        0        0        0
## 905         0        0        0        0        0        0        0        0
## 906         0        0        0        1        0        0        0        0
## 907         0        0        0        0        0        0        0        0
## 908         0        0        0        0        1        0        0        0
## 909         0        0        0        0        0        0        0        0
## 910         0        0        0        0        0        0        0        0
## 911         0        1        0        0        0        0        0        0
## 912         0        0        0        0        0        0        1        0
## 913         1        0        0        0        0        0        0        0
## 914         0        0        0        0        0        1        0        0
## 915         0        1        0        0        0        0        0        0
## 916         0        0        0        0        0        0        0        1
## 917         0        0        0        0        0        1        0        0
## 918         0        0        0        0        0        0        0        0
## 919         0        0        1        0        0        0        0        0
## 920         1        0        0        0        0        0        0        0
## 921         0        0        0        0        0        0        0        0
## 922         0        0        0        0        0        1        0        0
## 923         0        0        0        1        0        0        0        0
## 924         0        0        0        1        0        0        0        0
## 925         0        0        0        0        0        0        1        0
## 926         0        0        1        0        0        0        0        0
## 927         0        0        0        0        0        0        1        0
## 928         0        0        0        0        0        0        0        0
## 929         0        0        0        0        0        0        0        0
## 930         1        0        0        0        0        0        0        0
## 931         1        0        0        0        0        0        0        0
## 932         0        0        0        0        0        0        0        0
## 933         0        1        0        0        0        0        0        0
## 934         0        1        0        0        0        0        0        0
## 935         0        0        0        0        1        0        0        0
## 936         0        0        0        0        0        0        0        0
## 937         0        0        0        1        0        0        0        0
## 938         0        0        0        1        0        0        0        0
## 939         0        0        0        0        1        0        0        0
## 940         0        1        0        0        0        0        0        0
## 941         0        0        0        0        0        0        0        0
## 942         0        0        0        0        0        0        0        1
## 943         0        0        0        0        0        0        0        0
## 944         0        0        0        0        1        0        0        0
## 945         0        0        0        0        0        0        0        0
## 946         0        0        0        0        0        1        0        0
## 947         0        0        0        0        1        0        0        0
## 948         0        0        0        0        0        0        1        0
## 949         0        1        0        0        0        0        0        0
## 950         0        0        0        0        0        0        1        0
## 951         0        0        0        0        0        0        1        0
## 952         0        1        0        0        0        0        0        0
## 953         0        0        0        0        0        0        0        0
## 954         0        0        0        0        0        0        0        0
## 955         0        0        0        0        0        0        0        0
## 956         0        0        0        0        0        0        0        0
## 957         0        0        0        0        1        0        0        0
## 958         1        0        0        0        0        0        0        0
## 959         0        0        0        0        0        0        0        1
## 960         0        0        0        0        0        0        0        0
## 961         0        0        1        0        0        0        0        0
## 962         0        0        0        0        0        0        0        1
## 963         0        0        1        0        0        0        0        0
## 964         0        0        0        1        0        0        0        0
## 965         1        0        0        0        0        0        0        0
## 966         0        0        0        0        0        0        0        0
## 967         0        0        0        0        0        0        0        0
## 968         0        0        0        0        0        1        0        0
## 969         0        0        0        1        0        0        0        0
## 970         0        0        0        0        0        0        0        0
## 971         0        0        0        0        0        1        0        0
## 972         0        0        1        0        0        0        0        0
## 973         0        0        0        0        0        0        0        0
## 974         0        1        0        0        0        0        0        0
## 975         1        0        0        0        0        0        0        0
## 976         0        0        0        0        1        0        0        0
## 977         0        0        0        0        0        0        0        1
## 978         0        0        1        0        0        0        0        0
## 979         0        0        0        0        0        0        0        0
## 980         0        0        0        0        0        0        0        1
## 981         0        0        0        0        0        0        0        1
## 982         0        0        0        0        0        0        1        0
## 983         0        0        0        0        0        0        1        0
## 984         0        0        0        0        0        0        0        0
## 985         0        0        0        0        0        0        1        0
## 986         1        0        0        0        0        0        0        0
## 987         0        0        0        0        0        1        0        0
## 988         0        0        0        0        1        0        0        0
## 989         0        1        0        0        0        0        0        0
## 990         0        1        0        0        0        0        0        0
## 991         0        0        0        0        0        0        0        1
## 992         1        0        0        0        0        0        0        0
## 993         0        0        1        0        0        0        0        0
## 994         0        0        0        0        0        0        0        1
## 995         0        1        0        0        0        0        0        0
## 996         0        0        0        0        0        0        0        0
## 997         0        0        0        0        0        1        0        0
## 998         0        1        0        0        0        0        0        0
## 999         0        0        0        0        0        0        1        0
## 1000        0        0        0        0        0        1        0        0
## 1001        0        1        0        0        0        0        0        0
## 1002        0        0        0        0        0        0        0        0
## 1003        0        0        0        0        0        0        0        0
## 1004        1        0        0        0        0        0        0        0
## 1005        0        0        0        0        0        0        0        1
## 1006        0        1        0        0        0        0        0        0
## 1007        0        0        0        0        0        1        0        0
## 1008        0        0        0        0        0        0        0        1
## 1009        1        0        0        0        0        0        0        0
## 1010        0        0        0        1        0        0        0        0
## 1011        0        0        0        0        0        0        1        0
## 1012        0        1        0        0        0        0        0        0
## 1013        0        0        0        0        0        0        0        1
## 1014        0        1        0        0        0        0        0        0
## 1015        0        0        0        0        0        0        0        1
## 1016        0        0        0        0        0        0        0        0
## 1017        0        0        0        1        0        0        0        0
## 1018        0        0        0        0        0        0        1        0
## 1019        0        0        0        0        0        0        0        1
## 1020        0        0        0        0        0        0        0        0
## 1021        0        0        0        0        0        0        0        0
## 1022        0        0        0        0        0        1        0        0
## 1023        0        1        0        0        0        0        0        0
## 1024        0        0        0        0        0        0        1        0
## 1025        0        0        0        0        0        0        1        0
## 1026        0        0        0        0        0        0        0        1
## 1027        0        0        0        0        1        0        0        0
## 1028        0        0        0        0        0        0        0        1
## 1029        0        1        0        0        0        0        0        0
## 1030        0        0        0        1        0        0        0        0
## 1031        0        0        1        0        0        0        0        0
## 1032        0        0        0        0        1        0        0        0
## 1033        0        0        0        0        0        1        0        0
## 1034        0        0        0        0        0        0        1        0
## 1035        0        0        1        0        0        0        0        0
## 1036        0        0        0        0        0        0        0        0
## 1037        0        0        0        0        0        0        0        0
## 1038        0        0        0        1        0        0        0        0
## 1039        0        0        0        0        0        1        0        0
## 1040        0        0        0        1        0        0        0        0
## 1041        0        0        0        1        0        0        0        0
## 1042        0        0        0        0        0        0        0        1
## 1043        0        1        0        0        0        0        0        0
## 1044        0        0        0        0        0        0        0        1
## 1045        0        0        0        0        0        0        1        0
## 1046        0        0        0        1        0        0        0        0
## 1047        0        0        1        0        0        0        0        0
## 1048        0        0        0        0        0        0        0        1
## 1049        0        1        0        0        0        0        0        0
## 1050        0        0        0        0        0        0        1        0
## 1051        0        0        1        0        0        0        0        0
## 1052        0        1        0        0        0        0        0        0
## 1053        0        0        0        0        0        0        0        1
## 1054        0        0        0        0        0        0        0        1
## 1055        0        0        0        1        0        0        0        0
## 1056        0        0        0        0        0        1        0        0
## 1057        0        0        0        1        0        0        0        0
## 1058        0        0        0        0        0        0        1        0
## 1059        1        0        0        0        0        0        0        0
## 1060        0        0        0        1        0        0        0        0
## 1061        0        0        0        0        0        0        1        0
## 1062        0        0        0        1        0        0        0        0
## 1063        0        0        0        0        0        0        0        0
## 1064        0        0        0        0        0        0        1        0
## 1065        0        0        0        1        0        0        0        0
## 1066        0        0        0        0        1        0        0        0
## 1067        0        0        0        0        0        0        1        0
## 1068        0        0        0        0        0        0        0        0
## 1069        0        0        0        0        1        0        0        0
## 1070        0        0        0        0        0        0        1        0
## 1071        0        0        0        0        0        1        0        0
## 1072        1        0        0        0        0        0        0        0
## 1073        0        0        0        0        0        0        0        0
## 1074        0        0        1        0        0        0        0        0
## 1075        0        0        0        1        0        0        0        0
## 1076        0        0        0        0        0        0        0        0
## 1077        0        0        0        0        0        1        0        0
## 1078        0        0        0        0        0        0        0        0
## 1079        1        0        0        0        0        0        0        0
## 1080        0        0        0        0        0        0        1        0
## 1081        0        0        0        0        1        0        0        0
## 1082        0        0        0        0        0        0        0        0
## 1083        0        0        0        1        0        0        0        0
## 1084        0        0        1        0        0        0        0        0
## 1085        0        0        0        0        1        0        0        0
## 1086        0        1        0        0        0        0        0        0
## 1087        0        0        0        0        0        0        1        0
## 1088        0        0        0        0        0        0        1        0
## 1089        0        0        0        0        1        0        0        0
## 1090        0        0        0        0        1        0        0        0
## 1091        0        0        0        0        0        0        0        0
## 1092        0        0        0        1        0        0        0        0
## 1093        0        0        0        0        0        0        1        0
## 1094        0        0        0        0        0        0        0        0
## 1095        0        1        0        0        0        0        0        0
## 1096        0        0        0        0        0        0        0        1
## 1097        0        0        0        0        1        0        0        0
## 1098        0        0        0        0        0        0        0        1
## 1099        0        0        0        0        0        0        0        0
## 1100        0        0        0        0        0        0        0        0
## 1101        0        0        0        1        0        0        0        0
## 1102        0        0        0        0        0        1        0        0
## 1103        0        0        0        0        0        0        1        0
## 1104        0        0        0        0        1        0        0        0
## 1105        0        1        0        0        0        0        0        0
## 1106        0        0        0        0        0        0        0        0
## 1107        0        0        0        0        0        0        0        0
## 1108        1        0        0        0        0        0        0        0
## 1109        0        1        0        0        0        0        0        0
## 1110        0        0        0        0        0        0        0        0
## 1111        0        0        0        0        0        0        0        1
## 1112        0        0        0        0        0        0        0        0
## 1113        0        0        0        0        0        0        0        0
## 1114        0        0        1        0        0        0        0        0
## 1115        0        0        0        1        0        0        0        0
## 1116        0        1        0        0        0        0        0        0
## 1117        1        0        0        0        0        0        0        0
## 1118        0        1        0        0        0        0        0        0
## 1119        0        0        0        0        0        0        0        0
## 1120        0        0        0        0        0        0        0        0
## 1121        0        0        0        1        0        0        0        0
## 1122        0        0        0        0        0        0        1        0
## 1123        0        0        0        0        1        0        0        0
## 1124        0        1        0        0        0        0        0        0
## 1125        0        1        0        0        0        0        0        0
## 1126        0        0        0        0        0        0        0        1
## 1127        0        0        0        0        0        1        0        0
## 1128        0        0        0        0        0        1        0        0
## 1129        0        0        0        0        0        0        0        1
## 1130        0        0        0        0        0        0        0        1
## 1131        0        0        0        1        0        0        0        0
## 1132        0        0        1        0        0        0        0        0
## 1133        0        0        0        1        0        0        0        0
## 1134        0        0        0        0        0        0        1        0
## 1135        0        0        0        1        0        0        0        0
## 1136        1        0        0        0        0        0        0        0
## 1137        0        0        0        0        1        0        0        0
## 1138        0        0        1        0        0        0        0        0
## 1139        0        0        0        0        0        0        0        0
## 1140        0        0        0        0        1        0        0        0
## 1141        0        0        0        0        0        0        0        0
## 1142        0        1        0        0        0        0        0        0
## 1143        0        0        0        1        0        0        0        0
## 1144        0        0        0        1        0        0        0        0
## 1145        0        0        0        0        0        0        0        1
## 1146        0        0        0        0        0        0        0        1
## 1147        0        1        0        0        0        0        0        0
## 1148        0        0        0        0        0        1        0        0
## 1149        0        0        0        1        0        0        0        0
## 1150        0        0        0        0        0        0        0        0
## 1151        0        0        0        0        0        0        0        0
## 1152        0        0        0        0        0        0        1        0
## 1153        0        0        0        0        0        0        1        0
## 1154        0        0        0        0        0        0        0        1
## 1155        0        0        0        0        0        0        1        0
## 1156        0        0        0        0        0        1        0        0
## 1157        0        0        0        1        0        0        0        0
## 1158        0        0        1        0        0        0        0        0
## 1159        0        0        0        0        1        0        0        0
## 1160        0        0        1        0        0        0        0        0
## 1161        0        0        1        0        0        0        0        0
## 1162        0        1        0        0        0        0        0        0
## 1163        0        0        0        1        0        0        0        0
## 1164        0        0        0        0        0        0        0        1
## 1165        0        0        0        0        0        0        0        0
## 1166        0        0        0        1        0        0        0        0
## 1167        0        0        0        0        0        0        0        1
## 1168        1        0        0        0        0        0        0        0
## 1169        0        0        0        0        0        0        0        0
## 1170        0        0        0        0        1        0        0        0
## 1171        0        0        0        0        0        0        0        0
## 1172        0        0        0        1        0        0        0        0
## 1173        0        0        0        0        0        0        0        1
## 1174        0        0        0        0        0        0        0        1
## 1175        0        0        0        0        0        0        1        0
## 1176        0        0        0        0        0        0        1        0
## 1177        0        0        0        0        0        0        0        0
## 1178        0        0        0        0        0        0        0        0
## 1179        0        1        0        0        0        0        0        0
## 1180        0        0        0        0        0        0        0        0
## 1181        0        0        1        0        0        0        0        0
## 1182        0        0        0        0        0        1        0        0
## 1183        0        0        0        0        0        0        1        0
## 1184        0        0        0        0        0        0        1        0
## 1185        0        0        0        0        0        1        0        0
## 1186        0        0        1        0        0        0        0        0
## 1187        0        0        0        1        0        0        0        0
## 1188        0        0        0        0        0        0        0        1
## 1189        1        0        0        0        0        0        0        0
## 1190        0        0        0        0        0        0        0        1
## 1191        0        0        0        0        1        0        0        0
## 1192        0        0        0        0        0        1        0        0
## 1193        0        0        0        0        1        0        0        0
## 1194        0        0        0        0        1        0        0        0
## 1195        0        0        0        0        0        0        0        0
## 1196        0        0        0        1        0        0        0        0
## 1197        0        0        0        0        0        0        1        0
## 1198        0        0        0        0        1        0        0        0
## 1199        0        0        0        0        0        0        0        0
## 1200        0        0        0        0        0        0        0        0
## 1201        0        0        0        0        0        0        0        0
## 1202        0        0        1        0        0        0        0        0
## 1203        1        0        0        0        0        0        0        0
## 1204        0        0        1        0        0        0        0        0
## 1205        0        0        0        0        0        0        0        0
## 1206        0        0        0        0        0        0        0        1
## 1207        0        1        0        0        0        0        0        0
## 1208        0        0        0        0        0        0        0        0
## 1209        0        0        0        0        1        0        0        0
## 1210        0        0        0        0        1        0        0        0
## 1211        0        1        0        0        0        0        0        0
## 1212        0        0        0        1        0        0        0        0
## 1213        0        0        0        0        0        0        0        1
## 1214        0        0        0        0        1        0        0        0
## 1215        0        0        0        0        0        0        0        0
## 1216        0        0        0        0        0        0        1        0
## 1217        0        0        1        0        0        0        0        0
## 1218        0        1        0        0        0        0        0        0
## 1219        0        0        0        1        0        0        0        0
## 1220        0        0        0        0        0        0        0        0
## 1221        0        0        0        0        1        0        0        0
## 1222        1        0        0        0        0        0        0        0
## 1223        0        0        1        0        0        0        0        0
## 1224        0        0        0        0        0        0        0        0
## 1225        0        1        0        0        0        0        0        0
## 1226        0        0        0        0        1        0        0        0
## 1227        0        0        0        0        0        0        0        0
## 1228        0        0        1        0        0        0        0        0
## 1229        1        0        0        0        0        0        0        0
## 1230        0        0        0        0        0        1        0        0
## 1231        0        0        0        0        0        0        0        0
## 1232        0        0        0        0        0        0        0        1
## 1233        1        0        0        0        0        0        0        0
## 1234        0        0        0        0        1        0        0        0
## 1235        0        0        0        0        0        0        0        0
## 1236        0        0        0        0        0        0        0        1
## 1237        0        0        0        0        0        0        0        0
## 1238        0        0        0        0        0        0        1        0
## 1239        0        0        0        0        0        1        0        0
## 1240        0        0        0        0        0        0        0        1
## 1241        0        0        0        1        0        0        0        0
## 1242        0        0        0        0        0        0        1        0
## 1243        0        0        0        0        0        1        0        0
## 1244        0        0        0        1        0        0        0        0
## 1245        0        0        0        0        0        0        0        1
## 1246        0        0        0        1        0        0        0        0
## 1247        0        0        0        0        0        0        0        0
## 1248        0        1        0        0        0        0        0        0
## 1249        0        1        0        0        0        0        0        0
## 1250        0        0        0        0        0        0        0        0
## 1251        0        0        0        0        0        1        0        0
## 1252        0        1        0        0        0        0        0        0
## 1253        0        0        1        0        0        0        0        0
## 1254        0        0        0        0        0        0        1        0
## 1255        0        0        0        0        0        0        0        0
## 1256        0        0        0        0        0        0        1        0
## 1257        0        0        0        0        0        0        0        1
## 1258        0        0        1        0        0        0        0        0
## 1259        0        0        0        0        0        0        0        0
## 1260        0        0        0        1        0        0        0        0
## 1261        0        0        0        0        0        0        0        0
## 1262        0        0        0        0        1        0        0        0
## 1263        0        0        0        1        0        0        0        0
## 1264        0        0        0        0        1        0        0        0
## 1265        0        0        0        0        0        0        0        0
## 1266        0        0        0        1        0        0        0        0
## 1267        0        0        0        0        1        0        0        0
## 1268        0        0        0        0        1        0        0        0
## 1269        0        0        1        0        0        0        0        0
## 1270        1        0        0        0        0        0        0        0
## 1271        0        0        0        0        0        1        0        0
## 1272        0        0        1        0        0        0        0        0
## 1273        0        0        0        1        0        0        0        0
## 1274        0        1        0        0        0        0        0        0
## 1275        0        0        0        0        1        0        0        0
## 1276        0        0        0        1        0        0        0        0
## 1277        0        1        0        0        0        0        0        0
## 1278        1        0        0        0        0        0        0        0
## 1279        0        0        0        0        0        0        0        1
## 1280        0        0        0        0        1        0        0        0
## 1281        0        0        0        1        0        0        0        0
## 1282        0        0        0        0        0        0        0        0
## 1283        0        1        0        0        0        0        0        0
## 1284        0        0        0        0        0        1        0        0
## 1285        0        1        0        0        0        0        0        0
## 1286        1        0        0        0        0        0        0        0
## 1287        0        0        0        1        0        0        0        0
## 1288        0        1        0        0        0        0        0        0
## 1289        0        0        1        0        0        0        0        0
## 1290        1        0        0        0        0        0        0        0
## 1291        0        0        0        0        0        0        1        0
## 1292        0        0        0        0        1        0        0        0
## 1293        0        0        0        0        0        0        0        0
## 1294        0        0        0        0        0        1        0        0
## 1295        0        0        0        0        0        0        1        0
## 1296        1        0        0        0        0        0        0        0
## 1297        0        1        0        0        0        0        0        0
## 1298        0        0        0        0        0        0        0        0
## 1299        0        0        0        0        0        0        0        0
## 1300        0        0        0        1        0        0        0        0
## 1301        0        1        0        0        0        0        0        0
## 1302        0        0        0        0        1        0        0        0
## 1303        0        0        0        0        0        0        1        0
## 1304        0        0        0        0        0        0        0        1
## 1305        0        0        0        0        1        0        0        0
## 1306        0        1        0        0        0        0        0        0
## 1307        0        0        0        0        0        1        0        0
## 1308        0        0        0        0        0        0        0        0
## 1309        0        0        0        0        0        0        0        0
## 1310        0        0        0        0        0        0        0        0
## 1311        0        0        0        0        0        0        0        0
## 1312        0        0        0        0        1        0        0        0
## 1313        1        0        0        0        0        0        0        0
## 1314        0        0        0        0        0        0        1        0
## 1315        0        0        0        0        0        0        1        0
## 1316        0        0        0        0        0        0        0        1
## 1317        0        0        0        0        0        0        1        0
## 1318        0        0        0        0        0        1        0        0
## 1319        0        0        0        0        0        1        0        0
## 1320        0        0        1        0        0        0        0        0
## 1321        0        0        0        0        0        0        1        0
## 1322        0        0        0        0        0        1        0        0
## 1323        1        0        0        0        0        0        0        0
## 1324        0        0        0        0        0        1        0        0
## 1325        0        0        1        0        0        0        0        0
## 1326        0        0        0        0        0        0        0        1
## 1327        0        0        0        0        0        0        1        0
## 1328        0        0        0        0        0        1        0        0
## 1329        0        0        0        0        0        0        0        1
## 1330        0        0        0        0        0        0        1        0
## 1331        0        1        0        0        0        0        0        0
## 1332        0        1        0        0        0        0        0        0
## 1333        0        0        0        0        0        0        0        0
## 1334        1        0        0        0        0        0        0        0
## 1335        0        0        0        0        0        0        0        0
## 1336        0        0        0        1        0        0        0        0
## 1337        0        0        1        0        0        0        0        0
## 1338        0        0        0        0        0        1        0        0
## 1339        0        1        0        0        0        0        0        0
## 1340        0        0        0        0        0        1        0        0
## 1341        1        0        0        0        0        0        0        0
## 1342        0        1        0        0        0        0        0        0
## 1343        0        0        0        0        0        1        0        0
## 1344        0        0        0        0        0        0        0        1
## 1345        0        0        0        1        0        0        0        0
## 1346        0        0        0        1        0        0        0        0
## 1347        0        0        0        0        0        0        0        0
## 1348        0        0        0        0        0        0        1        0
## 1349        0        0        1        0        0        0        0        0
## 1350        0        0        0        0        0        0        0        1
## 1351        0        0        0        0        1        0        0        0
## 1352        0        0        0        0        1        0        0        0
## 1353        0        0        0        0        0        0        0        0
## 1354        0        0        0        0        0        0        1        0
## 1355        0        0        0        0        0        0        0        0
## 1356        0        0        0        0        0        0        0        0
## 1357        0        0        0        1        0        0        0        0
## 1358        0        0        0        0        0        0        1        0
## 1359        0        0        0        0        0        0        0        1
## 1360        0        0        0        0        0        0        1        0
## 1361        0        0        0        0        0        0        0        1
## 1362        0        0        0        0        0        0        0        0
## 1363        0        0        0        0        0        0        0        0
## 1364        0        0        0        0        1        0        0        0
## 1365        0        0        0        0        0        0        0        0
## 1366        0        0        0        0        0        0        1        0
## 1367        0        0        0        0        0        0        0        1
## 1368        1        0        0        0        0        0        0        0
## 1369        0        0        0        0        0        0        1        0
## 1370        0        0        0        0        0        1        0        0
## 1371        0        0        0        0        0        0        0        0
## 1372        1        0        0        0        0        0        0        0
## 1373        0        0        1        0        0        0        0        0
## 1374        0        1        0        0        0        0        0        0
## 1375        0        0        0        0        0        0        0        0
## 1376        0        0        0        0        0        1        0        0
## 1377        0        0        0        0        0        1        0        0
## 1378        0        0        1        0        0        0        0        0
## 1379        0        0        0        1        0        0        0        0
## 1380        0        0        0        0        0        0        0        1
## 1381        0        0        0        0        0        0        0        0
## 1382        0        0        0        0        0        1        0        0
## 1383        0        0        1        0        0        0        0        0
## 1384        0        0        0        1        0        0        0        0
## 1385        0        0        0        0        0        0        0        1
## 1386        0        0        0        0        0        0        0        0
## 1387        0        0        0        1        0        0        0        0
## 1388        0        1        0        0        0        0        0        0
## 1389        0        1        0        0        0        0        0        0
## 1390        0        0        0        1        0        0        0        0
## 1391        0        0        1        0        0        0        0        0
## 1392        0        0        1        0        0        0        0        0
## 1393        0        0        0        0        0        0        0        0
## 1394        0        0        0        0        0        0        0        0
## 1395        0        1        0        0        0        0        0        0
## 1396        0        0        0        0        0        0        0        1
## 1397        0        0        0        1        0        0        0        0
## 1398        0        0        0        0        0        0        0        1
## 1399        0        1        0        0        0        0        0        0
## 1400        1        0        0        0        0        0        0        0
## 1401        0        0        0        0        0        0        0        0
## 1402        0        0        0        0        1        0        0        0
## 1403        0        0        0        0        0        0        0        1
## 1404        1        0        0        0        0        0        0        0
## 1405        0        0        0        0        0        0        0        0
## 1406        1        0        0        0        0        0        0        0
## 1407        0        0        0        0        0        0        0        0
## 1408        0        0        1        0        0        0        0        0
## 1409        0        0        0        0        1        0        0        0
## 1410        0        1        0        0        0        0        0        0
## 1411        0        0        0        0        1        0        0        0
## 1412        0        0        0        0        1        0        0        0
## 1413        0        0        0        0        1        0        0        0
## 1414        0        0        0        0        1        0        0        0
## 1415        0        0        1        0        0        0        0        0
## 1416        0        0        1        0        0        0        0        0
## 1417        1        0        0        0        0        0        0        0
## 1418        0        0        0        0        0        0        0        0
## 1419        0        0        0        1        0        0        0        0
## 1420        0        0        0        0        1        0        0        0
## 1421        0        0        1        0        0        0        0        0
## 1422        0        0        1        0        0        0        0        0
## 1423        0        0        0        0        0        1        0        0
## 1424        0        0        1        0        0        0        0        0
## 1425        0        1        0        0        0        0        0        0
## 1426        0        0        0        0        0        0        1        0
## 1427        0        0        1        0        0        0        0        0
## 1428        0        0        1        0        0        0        0        0
## 1429        0        0        1        0        0        0        0        0
## 1430        0        0        0        0        1        0        0        0
## 1431        0        0        0        0        0        0        0        0
## 1432        0        0        0        1        0        0        0        0
## 1433        0        0        0        1        0        0        0        0
## 1434        0        0        0        0        0        0        0        1
## 1435        0        0        1        0        0        0        0        0
## 1436        0        0        0        1        0        0        0        0
## 1437        0        0        0        0        0        0        0        0
## 1438        0        0        0        1        0        0        0        0
## 1439        0        0        0        0        0        0        1        0
## 1440        0        0        0        0        0        0        0        0
## 1441        0        0        0        0        0        0        0        0
## 1442        0        0        0        0        0        0        0        1
## 1443        0        0        0        0        0        0        1        0
## 1444        0        0        0        0        1        0        0        0
## 1445        0        0        0        0        0        0        0        1
## 1446        0        0        0        0        0        0        1        0
## 1447        0        0        1        0        0        0        0        0
## 1448        0        0        0        1        0        0        0        0
## 1449        0        0        0        0        0        0        1        0
## 1450        0        1        0        0        0        0        0        0
## 1451        0        0        0        0        0        0        0        0
## 1452        0        0        0        1        0        0        0        0
## 1453        0        0        0        0        0        0        0        1
## 1454        0        1        0        0        0        0        0        0
## 1455        0        0        0        0        0        1        0        0
## 1456        0        0        0        0        0        1        0        0
## 1457        0        0        0        0        0        0        1        0
## 1458        0        0        0        0        0        0        0        0
## 1459        0        0        0        0        0        0        1        0
## 1460        1        0        0        0        0        0        0        0
## 1461        0        0        0        0        0        0        1        0
## 1462        0        0        0        0        0        1        0        0
## 1463        0        0        0        0        0        1        0        0
## 1464        0        0        0        0        0        0        1        0
## 1465        0        0        0        0        0        1        0        0
## 1466        0        0        0        0        0        1        0        0
## 1467        0        0        0        0        0        0        1        0
## 1468        0        1        0        0        0        0        0        0
## 1469        0        1        0        0        0        0        0        0
## 1470        0        0        0        0        0        0        1        0
## 1471        0        0        0        0        0        0        1        0
## 1472        0        0        0        0        0        0        0        0
## 1473        0        0        0        1        0        0        0        0
## 1474        0        0        0        0        0        1        0        0
## 1475        0        0        0        0        0        0        0        0
## 1476        0        0        0        0        0        0        0        0
## 1477        1        0        0        0        0        0        0        0
## 1478        0        0        0        0        0        0        1        0
## 1479        0        0        0        0        0        0        0        0
## 1480        0        0        0        1        0        0        0        0
## 1481        0        0        0        0        0        0        0        1
## 1482        0        0        0        0        0        0        1        0
## 1483        0        0        0        0        0        1        0        0
## 1484        0        0        0        0        0        0        0        0
## 1485        0        0        1        0        0        0        0        0
## 1486        0        0        0        1        0        0        0        0
## 1487        0        0        0        0        0        0        1        0
## 1488        0        0        1        0        0        0        0        0
## 1489        0        0        0        0        0        0        1        0
## 1490        0        0        0        0        0        0        0        0
## 1491        0        1        0        0        0        0        0        0
## 1492        0        0        1        0        0        0        0        0
## 1493        0        0        0        0        0        0        1        0
## 1494        0        1        0        0        0        0        0        0
## 1495        0        0        0        0        0        0        0        0
## 1496        0        0        0        0        0        0        0        0
## 1497        0        0        0        0        0        0        0        1
## 1498        0        0        0        0        0        1        0        0
## 1499        1        0        0        0        0        0        0        0
## 1500        0        0        0        0        0        0        0        0
## 1501        0        0        0        0        0        0        1        0
## 1502        0        0        0        0        0        0        1        0
## 1503        0        0        0        0        0        0        1        0
## 1504        0        0        0        0        0        0        0        0
## 1505        0        0        0        1        0        0        0        0
## 1506        0        0        0        1        0        0        0        0
## 1507        0        0        1        0        0        0        0        0
## 1508        1        0        0        0        0        0        0        0
## 1509        1        0        0        0        0        0        0        0
## 1510        0        0        0        0        0        0        0        0
## 1511        0        1        0        0        0        0        0        0
## 1512        0        1        0        0        0        0        0        0
## 1513        0        0        0        0        1        0        0        0
## 1514        0        0        0        0        0        0        0        0
## 1515        0        0        0        0        0        0        0        1
## 1516        0        0        0        0        0        0        0        0
## 1517        0        0        0        0        1        0        0        0
## 1518        0        0        0        0        0        1        0        0
## 1519        0        0        0        0        0        0        0        0
## 1520        0        0        0        0        0        0        0        0
## 1521        0        0        0        0        0        1        0        0
## 1522        0        0        0        0        0        0        0        0
## 1523        0        0        0        1        0        0        0        0
## 1524        0        0        1        0        0        0        0        0
## 1525        0        1        0        0        0        0        0        0
## 1526        0        0        0        0        0        1        0        0
## 1527        0        0        1        0        0        0        0        0
## 1528        0        0        0        0        0        0        0        0
## 1529        0        0        0        0        1        0        0        0
## 1530        0        0        0        0        0        0        1        0
## 1531        0        0        0        0        0        0        0        0
## 1532        0        0        1        0        0        0        0        0
## 1533        1        0        0        0        0        0        0        0
## 1534        0        0        0        1        0        0        0        0
## 1535        0        0        0        0        0        0        0        1
## 1536        0        0        1        0        0        0        0        0
## 1537        1        0        0        0        0        0        0        0
## 1538        0        0        0        1        0        0        0        0
## 1539        0        0        0        0        0        1        0        0
## 1540        0        0        0        0        0        0        0        1
## 1541        0        0        0        1        0        0        0        0
## 1542        0        1        0        0        0        0        0        0
## 1543        0        0        0        1        0        0        0        0
## 1544        0        1        0        0        0        0        0        0
## 1545        0        0        0        0        0        0        0        0
## 1546        1        0        0        0        0        0        0        0
## 1547        0        1        0        0        0        0        0        0
## 1548        0        0        0        0        0        1        0        0
## 1549        0        0        0        0        0        0        1        0
## 1550        0        0        0        0        0        0        0        0
## 1551        0        0        0        0        1        0        0        0
## 1552        0        0        0        0        0        1        0        0
## 1553        0        0        0        0        0        0        0        0
## 1554        0        0        1        0        0        0        0        0
## 1555        0        0        0        0        0        0        0        0
## 1556        0        0        0        0        1        0        0        0
## 1557        0        0        0        0        0        1        0        0
## 1558        0        0        0        1        0        0        0        0
## 1559        0        1        0        0        0        0        0        0
## 1560        0        0        0        0        0        0        0        0
## 1561        1        0        0        0        0        0        0        0
## 1562        0        0        0        1        0        0        0        0
## 1563        0        0        1        0        0        0        0        0
## 1564        0        0        0        0        0        0        0        1
## 1565        0        0        1        0        0        0        0        0
## 1566        0        0        0        1        0        0        0        0
## 1567        0        0        0        0        0        0        0        0
## 1568        0        0        0        0        0        0        0        0
## 1569        0        0        0        0        0        0        1        0
## 1570        0        0        0        0        0        0        0        1
## 1571        0        0        1        0        0        0        0        0
## 1572        0        0        0        0        0        1        0        0
## 1573        1        0        0        0        0        0        0        0
## 1574        0        0        1        0        0        0        0        0
## 1575        0        0        0        0        0        0        0        1
## 1576        0        0        0        1        0        0        0        0
## 1577        0        0        0        0        0        0        1        0
## 1578        0        0        1        0        0        0        0        0
## 1579        0        0        0        0        1        0        0        0
## 1580        0        0        0        0        0        1        0        0
## 1581        0        0        0        0        0        0        0        0
## 1582        0        0        0        0        0        0        0        1
## 1583        0        0        0        0        0        0        1        0
## 1584        0        0        0        0        0        0        0        1
## 1585        0        0        0        0        0        1        0        0
## 1586        0        0        0        0        0        0        0        0
## 1587        0        0        0        0        0        0        0        1
## 1588        0        0        0        1        0        0        0        0
## 1589        0        0        0        0        0        0        1        0
## 1590        0        0        0        0        0        0        1        0
## 1591        0        0        0        0        0        0        0        1
## 1592        0        0        0        1        0        0        0        0
## 1593        0        1        0        0        0        0        0        0
## 1594        0        0        0        0        0        0        0        1
## 1595        0        0        0        1        0        0        0        0
## 1596        0        0        0        0        1        0        0        0
## 1597        0        1        0        0        0        0        0        0
## 1598        0        0        0        0        0        0        0        0
## 1599        0        0        0        0        1        0        0        0
## 1600        0        0        0        0        0        1        0        0
## 1601        0        0        0        0        0        1        0        0
## 1602        0        0        0        1        0        0        0        0
## 1603        0        0        0        0        1        0        0        0
## 1604        0        1        0        0        0        0        0        0
## 1605        1        0        0        0        0        0        0        0
## 1606        0        0        0        0        0        1        0        0
## 1607        0        0        0        0        0        0        1        0
## 1608        0        0        0        0        0        0        0        0
## 1609        0        1        0        0        0        0        0        0
## 1610        0        1        0        0        0        0        0        0
## 1611        0        0        0        0        0        0        1        0
## 1612        0        0        0        0        1        0        0        0
## 1613        0        0        0        0        0        0        1        0
## 1614        0        0        0        0        0        0        0        1
## 1615        0        1        0        0        0        0        0        0
## 1616        0        1        0        0        0        0        0        0
## 1617        0        0        1        0        0        0        0        0
## 1618        0        0        1        0        0        0        0        0
## 1619        0        0        0        0        0        0        0        1
## 1620        0        0        1        0        0        0        0        0
## 1621        0        0        1        0        0        0        0        0
## 1622        0        1        0        0        0        0        0        0
## 1623        0        0        0        0        1        0        0        0
## 1624        0        0        0        0        0        0        0        1
## 1625        0        0        0        0        0        0        0        0
## 1626        0        1        0        0        0        0        0        0
## 1627        0        0        0        0        0        0        0        0
## 1628        0        0        0        0        0        0        0        0
## 1629        0        1        0        0        0        0        0        0
## 1630        0        0        0        0        0        0        0        0
## 1631        0        1        0        0        0        0        0        0
## 1632        0        0        0        0        0        0        0        1
## 1633        0        0        0        0        0        0        0        0
## 1634        0        0        1        0        0        0        0        0
## 1635        0        0        0        1        0        0        0        0
## 1636        0        0        0        0        0        0        0        0
## 1637        0        0        0        0        0        0        1        0
## 1638        0        0        0        0        0        0        1        0
## 1639        0        1        0        0        0        0        0        0
## 1640        0        0        0        1        0        0        0        0
## 1641        0        0        0        0        0        0        1        0
## 1642        1        0        0        0        0        0        0        0
## 1643        0        0        0        0        0        1        0        0
## 1644        0        0        0        0        0        0        1        0
## 1645        0        0        0        0        0        0        1        0
## 1646        0        0        0        0        0        0        0        0
## 1647        0        0        0        0        0        0        0        1
## 1648        0        0        0        0        0        0        1        0
## 1649        0        0        0        0        0        0        1        0
## 1650        0        0        0        0        0        0        0        0
## 1651        0        1        0        0        0        0        0        0
## 1652        0        0        0        0        0        0        1        0
## 1653        0        0        0        0        0        0        0        1
## 1654        0        0        0        0        0        1        0        0
## 1655        0        0        1        0        0        0        0        0
## 1656        0        0        0        0        1        0        0        0
## 1657        0        0        1        0        0        0        0        0
## 1658        0        1        0        0        0        0        0        0
## 1659        0        0        0        0        0        0        0        0
## 1660        0        0        0        0        0        0        1        0
## 1661        0        0        0        0        0        0        0        1
## 1662        0        0        0        0        1        0        0        0
## 1663        0        0        0        1        0        0        0        0
## 1664        1        0        0        0        0        0        0        0
## 1665        0        0        1        0        0        0        0        0
## 1666        0        0        0        0        0        1        0        0
## 1667        0        0        0        1        0        0        0        0
## 1668        0        0        0        1        0        0        0        0
## 1669        0        0        0        0        0        1        0        0
## 1670        0        0        0        0        0        0        0        0
## 1671        0        0        0        0        0        0        0        0
## 1672        0        0        0        0        1        0        0        0
## 1673        0        0        0        0        0        0        0        0
## 1674        0        0        0        1        0        0        0        0
## 1675        0        0        0        0        0        0        1        0
## 1676        0        0        0        0        0        0        1        0
## 1677        0        0        0        0        0        0        0        0
## 1678        0        1        0        0        0        0        0        0
## 1679        0        0        0        0        0        1        0        0
## 1680        0        0        0        0        0        0        0        1
## 1681        0        0        0        0        0        1        0        0
## 1682        0        0        0        0        0        1        0        0
## 1683        0        0        0        0        0        0        1        0
## 1684        0        0        0        0        0        0        0        0
## 1685        1        0        0        0        0        0        0        0
## 1686        0        0        0        0        0        0        0        0
## 1687        0        1        0        0        0        0        0        0
## 1688        0        0        1        0        0        0        0        0
## 1689        0        0        0        1        0        0        0        0
## 1690        0        1        0        0        0        0        0        0
## 1691        0        1        0        0        0        0        0        0
## 1692        0        0        0        0        1        0        0        0
## 1693        0        0        1        0        0        0        0        0
## 1694        0        0        0        0        0        0        0        1
## 1695        1        0        0        0        0        0        0        0
## 1696        0        0        0        0        0        0        0        0
## 1697        0        0        0        0        1        0        0        0
## 1698        1        0        0        0        0        0        0        0
## 1699        0        1        0        0        0        0        0        0
## 1700        0        1        0        0        0        0        0        0
## 1701        0        0        1        0        0        0        0        0
## 1702        0        0        0        0        1        0        0        0
## 1703        0        0        0        0        0        0        0        0
## 1704        0        0        1        0        0        0        0        0
## 1705        0        0        1        0        0        0        0        0
## 1706        1        0        0        0        0        0        0        0
## 1707        1        0        0        0        0        0        0        0
## 1708        0        0        0        0        0        0        1        0
## 1709        0        0        0        0        0        0        0        0
## 1710        0        0        0        0        1        0        0        0
## 1711        0        1        0        0        0        0        0        0
## 1712        0        0        0        0        0        0        0        1
## 1713        0        0        0        0        0        0        0        0
## 1714        0        0        0        0        0        1        0        0
## 1715        0        0        0        1        0        0        0        0
## 1716        0        0        0        0        1        0        0        0
## 1717        0        0        0        0        1        0        0        0
## 1718        0        0        0        0        1        0        0        0
## 1719        0        0        0        0        1        0        0        0
## 1720        0        0        0        0        0        0        0        0
## 1721        0        0        0        0        0        0        0        1
## 1722        1        0        0        0        0        0        0        0
## 1723        0        0        0        0        1        0        0        0
## 1724        0        1        0        0        0        0        0        0
## 1725        0        0        0        0        0        0        0        0
## 1726        0        0        0        1        0        0        0        0
## 1727        0        0        0        0        0        1        0        0
## 1728        0        0        0        0        0        0        1        0
## 1729        0        0        0        0        0        0        1        0
## 1730        0        0        1        0        0        0        0        0
## 1731        0        1        0        0        0        0        0        0
## 1732        0        0        0        0        0        0        0        1
## 1733        0        0        0        0        0        1        0        0
## 1734        0        1        0        0        0        0        0        0
## 1735        0        0        0        0        0        0        0        0
## 1736        0        0        0        0        0        0        0        0
## 1737        0        0        0        0        0        0        1        0
## 1738        0        0        0        0        0        1        0        0
## 1739        0        0        0        0        0        1        0        0
## 1740        0        0        0        0        1        0        0        0
## 1741        0        0        0        1        0        0        0        0
## 1742        0        0        1        0        0        0        0        0
## 1743        0        0        0        0        0        0        0        1
## 1744        1        0        0        0        0        0        0        0
## 1745        0        0        0        1        0        0        0        0
## 1746        0        0        0        0        0        0        0        0
## 1747        0        0        0        0        0        1        0        0
## 1748        0        0        0        0        0        0        1        0
## 1749        1        0        0        0        0        0        0        0
## 1750        0        0        0        0        0        0        1        0
## 1751        0        0        0        0        0        0        0        1
## 1752        0        0        0        0        0        0        0        0
## 1753        1        0        0        0        0        0        0        0
## 1754        0        0        0        0        0        0        0        0
## 1755        0        0        0        0        0        0        0        1
## 1756        0        0        1        0        0        0        0        0
## 1757        0        1        0        0        0        0        0        0
## 1758        0        0        0        0        0        0        0        0
## 1759        0        0        1        0        0        0        0        0
## 1760        0        0        0        0        0        1        0        0
## 1761        0        1        0        0        0        0        0        0
## 1762        0        0        0        0        0        0        0        0
## 1763        0        0        0        0        0        0        1        0
## 1764        0        0        0        0        0        0        0        1
## 1765        0        0        0        0        0        0        0        1
## 1766        1        0        0        0        0        0        0        0
## 1767        0        0        0        0        0        0        0        1
## 1768        0        0        1        0        0        0        0        0
## 1769        1        0        0        0        0        0        0        0
## 1770        0        0        0        0        0        1        0        0
## 1771        0        0        0        0        0        0        0        0
## 1772        0        1        0        0        0        0        0        0
## 1773        0        0        0        0        0        0        0        1
## 1774        0        0        0        0        1        0        0        0
## 1775        1        0        0        0        0        0        0        0
## 1776        0        0        0        0        0        0        1        0
## 1777        0        0        0        0        0        0        0        0
## 1778        0        0        0        0        1        0        0        0
## 1779        0        0        0        0        0        0        0        1
## 1780        0        0        1        0        0        0        0        0
## 1781        0        0        0        0        0        1        0        0
## 1782        0        1        0        0        0        0        0        0
## 1783        0        0        0        0        0        0        0        1
## 1784        0        0        1        0        0        0        0        0
## 1785        0        0        0        0        0        0        0        0
## 1786        0        0        0        0        0        0        0        0
## 1787        0        0        0        0        0        0        0        0
## 1788        0        0        0        0        0        0        0        0
## 1789        0        0        0        0        0        0        0        0
## 1790        0        0        0        0        0        0        0        0
## 1791        0        0        0        0        0        0        1        0
## 1792        0        0        0        1        0        0        0        0
## 1793        0        0        0        0        0        0        1        0
## 1794        0        0        0        0        1        0        0        0
## 1795        0        0        0        0        0        0        0        0
## 1796        1        0        0        0        0        0        0        0
## 1797        0        0        0        0        0        1        0        0
## 1798        0        0        0        0        0        0        0        0
## 1799        0        0        0        0        0        1        0        0
## 1800        0        0        0        0        0        0        0        0
## 1801        0        1        0        0        0        0        0        0
## 1802        0        0        0        0        0        0        0        1
## 1803        0        0        0        0        0        0        0        1
## 1804        0        0        0        0        1        0        0        0
## 1805        0        0        1        0        0        0        0        0
## 1806        0        0        0        0        0        0        0        0
## 1807        0        0        0        1        0        0        0        0
## 1808        0        1        0        0        0        0        0        0
## 1809        0        0        0        0        0        0        1        0
## 1810        0        0        0        0        0        0        0        0
## 1811        0        1        0        0        0        0        0        0
## 1812        0        0        0        0        0        0        0        0
## 1813        0        1        0        0        0        0        0        0
## 1814        0        0        0        1        0        0        0        0
## 1815        0        0        0        0        0        1        0        0
## 1816        0        0        0        0        0        0        1        0
## 1817        0        0        0        0        0        0        0        0
## 1818        1        0        0        0        0        0        0        0
## 1819        0        1        0        0        0        0        0        0
## 1820        0        0        0        0        0        0        0        1
## 1821        0        0        0        0        0        0        0        0
## 1822        0        0        1        0        0        0        0        0
## 1823        0        0        0        0        1        0        0        0
## 1824        0        0        0        0        0        0        0        0
## 1825        0        1        0        0        0        0        0        0
## 1826        0        0        0        1        0        0        0        0
## 1827        1        0        0        0        0        0        0        0
## 1828        0        0        0        1        0        0        0        0
## 1829        0        0        0        0        0        0        0        1
## 1830        0        0        0        0        0        0        0        1
## 1831        0        0        0        0        0        0        0        0
## 1832        0        0        0        0        0        0        0        0
## 1833        0        0        0        0        0        0        0        0
## 1834        0        0        0        0        0        1        0        0
## 1835        0        0        0        0        0        0        0        0
## 1836        0        0        0        0        0        0        0        1
## 1837        0        0        0        0        0        0        0        0
## 1838        0        0        0        0        0        0        0        0
## 1839        0        0        0        0        0        0        0        0
## 1840        0        0        0        0        0        0        0        1
## 1841        0        0        0        1        0        0        0        0
## 1842        0        1        0        0        0        0        0        0
## 1843        0        0        0        0        0        0        0        1
## 1844        0        0        0        0        0        1        0        0
## 1845        0        1        0        0        0        0        0        0
## 1846        0        0        0        0        0        0        0        1
## 1847        0        1        0        0        0        0        0        0
## 1848        0        0        1        0        0        0        0        0
## 1849        0        0        0        0        0        1        0        0
## 1850        0        0        0        0        0        0        0        1
## 1851        0        0        0        0        0        0        0        0
## 1852        0        0        0        0        0        0        0        0
## 1853        0        0        0        0        0        1        0        0
## 1854        0        0        0        0        0        1        0        0
## 1855        0        0        0        0        1        0        0        0
## 1856        0        0        0        1        0        0        0        0
## 1857        0        0        0        0        1        0        0        0
## 1858        0        0        0        0        0        1        0        0
## 1859        0        0        0        0        0        0        1        0
## 1860        0        0        0        0        0        0        0        1
## 1861        0        0        0        1        0        0        0        0
## 1862        0        0        0        1        0        0        0        0
## 1863        0        0        0        0        0        1        0        0
## 1864        0        0        0        0        0        1        0        0
## 1865        0        0        0        0        0        0        0        0
## 1866        0        0        0        0        0        0        0        1
## 1867        0        0        0        0        0        1        0        0
## 1868        0        1        0        0        0        0        0        0
## 1869        0        0        0        0        0        0        1        0
## 1870        0        0        0        0        0        0        0        0
## 1871        0        0        0        0        0        0        0        1
## 1872        0        0        0        0        0        0        0        0
## 1873        0        0        0        0        0        1        0        0
## 1874        0        0        0        0        0        0        1        0
## 1875        0        0        0        0        0        0        0        0
## 1876        0        0        0        0        1        0        0        0
## 1877        0        1        0        0        0        0        0        0
## 1878        0        0        0        0        0        0        1        0
## 1879        0        0        0        0        0        0        0        0
## 1880        0        0        0        1        0        0        0        0
## 1881        0        0        0        1        0        0        0        0
## 1882        0        0        1        0        0        0        0        0
## 1883        0        0        0        0        0        0        0        0
## 1884        0        0        1        0        0        0        0        0
## 1885        0        0        0        0        0        0        1        0
## 1886        0        0        0        1        0        0        0        0
## 1887        0        0        1        0        0        0        0        0
## 1888        0        0        0        0        1        0        0        0
## 1889        1        0        0        0        0        0        0        0
## 1890        0        0        0        0        0        0        0        1
## 1891        0        1        0        0        0        0        0        0
## 1892        0        0        0        0        1        0        0        0
## 1893        0        0        0        0        0        0        0        0
## 1894        0        0        0        0        0        0        0        1
## 1895        0        0        1        0        0        0        0        0
## 1896        0        0        1        0        0        0        0        0
## 1897        1        0        0        0        0        0        0        0
## 1898        0        0        0        0        1        0        0        0
## 1899        0        0        0        0        0        0        1        0
## 1900        0        0        0        0        0        0        0        0
## 1901        0        0        0        1        0        0        0        0
## 1902        0        0        1        0        0        0        0        0
## 1903        0        0        0        0        1        0        0        0
## 1904        0        0        0        0        0        0        0        0
## 1905        0        0        0        0        0        0        1        0
## 1906        0        0        1        0        0        0        0        0
## 1907        0        0        0        0        0        1        0        0
## 1908        0        0        0        0        0        0        1        0
## 1909        0        0        0        1        0        0        0        0
## 1910        0        1        0        0        0        0        0        0
## 1911        0        0        0        0        1        0        0        0
## 1912        0        0        0        1        0        0        0        0
## 1913        1        0        0        0        0        0        0        0
## 1914        0        0        0        0        1        0        0        0
## 1915        0        0        0        0        0        0        0        1
## 1916        0        0        0        1        0        0        0        0
## 1917        0        1        0        0        0        0        0        0
## 1918        1        0        0        0        0        0        0        0
## 1919        0        0        0        0        0        1        0        0
## 1920        0        1        0        0        0        0        0        0
## 1921        0        0        0        0        0        1        0        0
## 1922        0        0        0        0        0        0        1        0
## 1923        0        0        0        1        0        0        0        0
## 1924        0        1        0        0        0        0        0        0
## 1925        0        0        0        1        0        0        0        0
## 1926        0        0        0        1        0        0        0        0
## 1927        0        0        0        0        0        0        0        1
## 1928        0        0        0        0        0        1        0        0
## 1929        0        0        0        0        1        0        0        0
## 1930        0        0        0        1        0        0        0        0
## 1931        0        0        0        1        0        0        0        0
## 1932        0        0        0        0        0        1        0        0
## 1933        0        0        0        0        0        1        0        0
## 1934        0        1        0        0        0        0        0        0
## 1935        1        0        0        0        0        0        0        0
## 1936        0        0        0        0        0        0        0        1
## 1937        0        0        0        0        1        0        0        0
## 1938        0        0        0        0        0        0        1        0
## 1939        0        0        0        0        0        0        1        0
## 1940        0        0        0        1        0        0        0        0
## 1941        0        0        0        0        0        1        0        0
## 1942        0        1        0        0        0        0        0        0
## 1943        0        0        0        0        0        0        0        0
## 1944        0        1        0        0        0        0        0        0
## 1945        0        0        0        0        1        0        0        0
## 1946        0        0        0        0        0        0        0        0
## 1947        0        0        0        1        0        0        0        0
## 1948        0        0        0        0        0        0        0        1
## 1949        0        1        0        0        0        0        0        0
## 1950        0        1        0        0        0        0        0        0
## 1951        0        0        0        0        0        1        0        0
## 1952        0        0        0        0        0        0        1        0
## 1953        0        0        0        0        0        0        1        0
## 1954        0        0        0        0        0        0        1        0
## 1955        0        0        0        1        0        0        0        0
## 1956        0        0        0        0        0        0        0        0
## 1957        0        0        0        0        0        1        0        0
## 1958        1        0        0        0        0        0        0        0
## 1959        0        0        0        1        0        0        0        0
## 1960        0        0        0        0        0        0        0        0
## 1961        0        0        0        0        0        0        1        0
## 1962        0        1        0        0        0        0        0        0
## 1963        0        1        0        0        0        0        0        0
## 1964        0        0        0        0        0        1        0        0
## 1965        0        0        1        0        0        0        0        0
## 1966        0        1        0        0        0        0        0        0
## 1967        0        1        0        0        0        0        0        0
## 1968        0        0        0        1        0        0        0        0
## 1969        0        0        0        0        0        1        0        0
## 1970        0        0        0        0        0        1        0        0
## 1971        0        1        0        0        0        0        0        0
## 1972        0        0        0        1        0        0        0        0
## 1973        0        0        0        0        1        0        0        0
## 1974        0        1        0        0        0        0        0        0
## 1975        0        0        0        0        0        0        0        0
## 1976        0        0        0        1        0        0        0        0
## 1977        0        0        0        0        0        0        0        1
## 1978        0        1        0        0        0        0        0        0
## 1979        0        1        0        0        0        0        0        0
## 1980        0        0        0        0        0        0        0        1
## 1981        1        0        0        0        0        0        0        0
## 1982        0        1        0        0        0        0        0        0
## 1983        0        0        0        0        0        1        0        0
## 1984        0        0        0        0        0        1        0        0
## 1985        0        0        0        0        0        0        0        0
## 1986        0        1        0        0        0        0        0        0
## 1987        0        0        0        0        0        0        0        1
## 1988        0        1        0        0        0        0        0        0
## 1989        0        0        0        0        0        0        1        0
## 1990        0        0        0        1        0        0        0        0
## 1991        0        0        0        0        0        0        0        0
## 1992        0        0        1        0        0        0        0        0
## 1993        0        0        0        0        0        0        0        0
## 1994        0        0        0        1        0        0        0        0
## 1995        0        1        0        0        0        0        0        0
## 1996        0        0        1        0        0        0        0        0
## 1997        0        0        0        0        0        0        0        0
## 1998        0        0        0        1        0        0        0        0
## 1999        0        1        0        0        0        0        0        0
## 2000        0        0        0        0        0        0        1        0
## 2001        0        0        0        0        0        1        0        0
## 2002        0        0        0        1        0        0        0        0
## 2003        0        1        0        0        0        0        0        0
## 2004        0        0        0        0        0        0        0        0
## 2005        0        0        0        0        0        0        1        0
## 2006        0        0        0        0        0        1        0        0
## 2007        1        0        0        0        0        0        0        0
## 2008        0        0        0        0        0        0        1        0
## 2009        0        0        0        0        0        0        1        0
## 2010        0        0        0        0        0        0        1        0
## 2011        0        0        0        0        0        0        1        0
## 2012        0        0        0        0        0        0        0        0
## 2013        0        1        0        0        0        0        0        0
## 2014        0        1        0        0        0        0        0        0
## 2015        0        0        0        0        0        0        1        0
## 2016        0        0        0        0        0        0        0        0
## 2017        0        0        0        0        0        0        0        0
## 2018        0        0        1        0        0        0        0        0
## 2019        0        0        0        0        0        1        0        0
## 2020        0        0        0        1        0        0        0        0
## 2021        0        0        0        0        1        0        0        0
## 2022        0        0        0        0        0        0        0        0
## 2023        0        0        1        0        0        0        0        0
## 2024        0        0        0        0        0        0        1        0
## 2025        0        0        0        0        1        0        0        0
## 2026        0        0        0        0        0        1        0        0
## 2027        0        0        1        0        0        0        0        0
## 2028        1        0        0        0        0        0        0        0
## 2029        0        0        0        0        0        0        0        0
## 2030        0        0        0        0        0        0        0        0
## 2031        0        0        0        0        0        0        0        0
## 2032        0        0        0        0        1        0        0        0
## 2033        0        1        0        0        0        0        0        0
## 2034        0        0        0        0        0        0        0        1
## 2035        0        0        0        0        0        0        0        0
## 2036        0        0        0        0        1        0        0        0
## 2037        0        0        0        0        0        0        0        0
## 2038        0        0        0        0        0        0        0        0
## 2039        0        0        0        0        0        1        0        0
## 2040        0        0        0        1        0        0        0        0
## 2041        0        0        0        0        0        0        0        1
## 2042        0        0        0        0        0        0        0        0
## 2043        0        0        1        0        0        0        0        0
## 2044        0        0        1        0        0        0        0        0
## 2045        0        0        1        0        0        0        0        0
## 2046        0        0        0        0        0        0        1        0
## 2047        0        0        0        0        0        0        1        0
## 2048        0        0        0        0        0        1        0        0
## 2049        0        0        0        0        0        0        0        0
## 2050        0        0        1        0        0        0        0        0
## 2051        0        1        0        0        0        0        0        0
## 2052        0        0        0        0        1        0        0        0
## 2053        0        0        0        0        0        0        1        0
## 2054        0        0        0        0        0        0        0        0
## 2055        1        0        0        0        0        0        0        0
## 2056        0        0        1        0        0        0        0        0
## 2057        0        0        1        0        0        0        0        0
## 2058        1        0        0        0        0        0        0        0
## 2059        0        0        0        0        1        0        0        0
## 2060        0        0        0        0        0        0        0        1
## 2061        0        1        0        0        0        0        0        0
## 2062        0        0        0        1        0        0        0        0
## 2063        0        0        1        0        0        0        0        0
## 2064        0        0        0        0        0        0        0        1
## 2065        0        0        0        0        0        0        0        0
## 2066        0        0        0        0        0        0        0        0
## 2067        0        0        0        0        0        0        1        0
## 2068        0        0        0        0        0        0        1        0
## 2069        0        0        0        0        0        0        0        1
## 2070        0        0        0        0        0        0        0        0
## 2071        0        0        0        0        0        0        0        1
## 2072        0        0        0        0        1        0        0        0
## 2073        0        0        0        0        0        0        1        0
## 2074        0        0        0        1        0        0        0        0
## 2075        0        1        0        0        0        0        0        0
## 2076        0        0        0        0        1        0        0        0
## 2077        0        0        0        0        0        1        0        0
## 2078        0        0        0        0        0        0        0        0
## 2079        0        0        0        0        0        1        0        0
## 2080        0        0        0        0        0        1        0        0
## 2081        0        0        0        1        0        0        0        0
## 2082        0        0        0        0        1        0        0        0
## 2083        0        0        1        0        0        0        0        0
## 2084        0        0        0        1        0        0        0        0
## 2085        0        0        0        0        0        1        0        0
## 2086        0        0        0        0        0        0        1        0
## 2087        0        0        0        0        1        0        0        0
## 2088        0        0        0        0        0        0        0        0
## 2089        0        0        0        0        0        1        0        0
## 2090        0        0        1        0        0        0        0        0
## 2091        1        0        0        0        0        0        0        0
## 2092        0        0        0        1        0        0        0        0
## 2093        0        0        0        0        1        0        0        0
## 2094        0        0        0        0        0        0        0        0
## 2095        0        0        0        1        0        0        0        0
## 2096        0        0        0        1        0        0        0        0
## 2097        0        0        1        0        0        0        0        0
## 2098        0        0        0        0        0        0        1        0
## 2099        0        1        0        0        0        0        0        0
## 2100        0        0        0        0        0        1        0        0
## 2101        0        0        0        1        0        0        0        0
## 2102        0        0        0        1        0        0        0        0
## 2103        0        0        0        0        0        0        0        0
## 2104        0        0        0        0        0        0        0        0
## 2105        0        0        0        0        0        1        0        0
## 2106        0        1        0        0        0        0        0        0
## 2107        0        0        0        0        1        0        0        0
## 2108        0        0        1        0        0        0        0        0
## 2109        0        0        0        0        0        0        0        0
## 2110        0        0        0        0        0        0        1        0
## 2111        0        0        0        0        0        0        1        0
## 2112        0        0        0        0        0        1        0        0
## 2113        0        0        0        0        0        0        1        0
## 2114        0        0        0        0        0        0        1        0
## 2115        0        0        0        0        0        0        0        0
## 2116        0        0        0        0        0        0        0        0
## 2117        0        0        0        0        0        0        1        0
## 2118        0        0        0        0        0        0        0        0
## 2119        0        0        0        0        0        0        0        0
## 2120        0        0        0        0        0        1        0        0
## 2121        0        0        0        1        0        0        0        0
## 2122        0        0        0        0        0        0        0        0
## 2123        1        0        0        0        0        0        0        0
## 2124        0        0        0        1        0        0        0        0
## 2125        0        0        0        1        0        0        0        0
## 2126        0        0        0        0        0        0        0        0
## 2127        0        0        0        0        0        0        0        0
## 2128        0        0        0        0        0        1        0        0
## 2129        0        0        0        1        0        0        0        0
## 2130        0        0        0        0        0        0        1        0
## 2131        0        0        1        0        0        0        0        0
## 2132        0        0        0        0        0        0        0        0
## 2133        0        0        0        0        0        0        0        0
## 2134        0        0        0        0        1        0        0        0
## 2135        0        0        0        0        0        0        0        0
## 2136        0        0        0        0        0        0        0        1
## 2137        0        0        0        0        0        0        0        1
## 2138        0        0        0        0        0        0        0        1
## 2139        1        0        0        0        0        0        0        0
## 2140        0        0        0        0        0        1        0        0
## 2141        0        0        0        0        0        0        1        0
## 2142        0        0        0        0        1        0        0        0
## 2143        0        0        0        0        0        0        0        0
## 2144        0        0        0        0        0        0        0        1
## 2145        0        0        0        0        0        0        1        0
## 2146        0        0        0        0        0        1        0        0
## 2147        0        0        0        0        1        0        0        0
## 2148        0        1        0        0        0        0        0        0
## 2149        0        0        0        1        0        0        0        0
## 2150        0        0        0        0        0        1        0        0
## 2151        0        0        0        0        0        0        0        0
## 2152        0        0        0        0        0        1        0        0
## 2153        0        0        0        0        0        0        0        0
## 2154        0        0        0        0        0        0        0        0
## 2155        0        0        1        0        0        0        0        0
## 2156        0        0        0        0        0        0        0        0
## 2157        0        1        0        0        0        0        0        0
## 2158        0        0        0        0        0        0        0        0
## 2159        0        0        0        0        0        0        0        0
## 2160        0        0        0        0        0        0        0        0
## 2161        0        0        0        0        0        0        0        1
## 2162        0        0        0        0        0        0        1        0
## 2163        0        0        0        0        0        1        0        0
## 2164        1        0        0        0        0        0        0        0
## 2165        1        0        0        0        0        0        0        0
## 2166        0        0        0        0        0        1        0        0
## 2167        0        0        1        0        0        0        0        0
## 2168        0        0        1        0        0        0        0        0
## 2169        0        0        1        0        0        0        0        0
## 2170        0        0        0        0        1        0        0        0
## 2171        0        1        0        0        0        0        0        0
## 2172        0        1        0        0        0        0        0        0
## 2173        0        0        0        0        1        0        0        0
## 2174        0        0        0        0        1        0        0        0
## 2175        0        0        0        0        0        1        0        0
## 2176        0        0        0        0        0        0        0        0
## 2177        0        0        1        0        0        0        0        0
## 2178        0        1        0        0        0        0        0        0
## 2179        0        1        0        0        0        0        0        0
## 2180        0        0        0        0        0        0        0        0
## 2181        0        0        1        0        0        0        0        0
## 2182        0        0        0        0        1        0        0        0
## 2183        0        0        0        1        0        0        0        0
## 2184        0        0        1        0        0        0        0        0
## 2185        0        0        0        0        0        0        0        0
## 2186        0        0        0        0        0        0        1        0
## 2187        0        0        0        1        0        0        0        0
## 2188        0        0        0        0        0        0        0        0
## 2189        0        0        0        0        0        0        0        0
## 2190        0        0        0        0        0        0        1        0
## 2191        0        0        0        1        0        0        0        0
## 2192        0        0        0        0        1        0        0        0
## 2193        0        0        0        0        1        0        0        0
## 2194        0        0        0        0        0        0        0        0
## 2195        0        1        0        0        0        0        0        0
## 2196        0        0        1        0        0        0        0        0
## 2197        0        0        0        0        0        0        0        0
## 2198        0        0        0        0        0        0        1        0
## 2199        0        1        0        0        0        0        0        0
## 2200        0        0        0        0        0        0        0        1
## 2201        0        0        0        0        0        0        0        0
## 2202        0        0        0        0        0        0        0        0
## 2203        0        0        0        0        0        0        0        1
## 2204        1        0        0        0        0        0        0        0
## 2205        0        0        0        0        1        0        0        0
## 2206        0        0        0        1        0        0        0        0
## 2207        0        0        1        0        0        0        0        0
## 2208        0        0        0        0        0        0        1        0
## 2209        1        0        0        0        0        0        0        0
## 2210        0        0        0        0        0        0        0        1
## 2211        0        0        0        0        0        0        0        0
## 2212        0        1        0        0        0        0        0        0
## 2213        0        0        0        0        1        0        0        0
## 2214        0        0        0        0        0        0        0        0
## 2215        0        0        0        0        0        0        0        1
## 2216        0        0        0        0        0        0        0        0
## 2217        0        0        1        0        0        0        0        0
## 2218        1        0        0        0        0        0        0        0
## 2219        0        0        0        0        0        1        0        0
## 2220        0        0        0        0        0        0        0        0
## 2221        0        1        0        0        0        0        0        0
## 2222        0        0        0        0        0        0        1        0
## 2223        0        0        0        0        0        0        0        0
## 2224        0        0        1        0        0        0        0        0
## 2225        0        0        0        0        0        0        0        1
## 2226        0        1        0        0        0        0        0        0
## 2227        0        0        1        0        0        0        0        0
## 2228        0        1        0        0        0        0        0        0
## 2229        0        0        0        0        0        0        0        1
## 2230        0        0        0        0        0        0        0        0
## 2231        0        0        0        0        0        0        0        0
## 2232        0        0        0        1        0        0        0        0
## 2233        0        0        0        0        0        0        0        0
## 2234        0        0        0        0        0        0        1        0
## 2235        0        0        0        0        0        1        0        0
## 2236        0        0        0        0        0        0        0        0
## 2237        0        0        1        0        0        0        0        0
## 2238        0        0        0        0        1        0        0        0
## 2239        1        0        0        0        0        0        0        0
## 2240        0        1        0        0        0        0        0        0
## 2241        0        0        0        1        0        0        0        0
## 2242        0        1        0        0        0        0        0        0
## 2243        0        0        0        1        0        0        0        0
## 2244        1        0        0        0        0        0        0        0
## 2245        0        0        0        0        0        0        0        0
## 2246        1        0        0        0        0        0        0        0
## 2247        0        0        0        0        0        0        0        1
## 2248        0        0        0        0        1        0        0        0
## 2249        0        0        0        0        0        0        0        0
## 2250        1        0        0        0        0        0        0        0
## 2251        0        1        0        0        0        0        0        0
## 2252        0        0        0        0        0        0        1        0
## 2253        1        0        0        0        0        0        0        0
## 2254        0        0        0        0        0        1        0        0
## 2255        0        0        1        0        0        0        0        0
## 2256        0        0        0        0        0        1        0        0
## 2257        0        0        1        0        0        0        0        0
## 2258        0        0        0        1        0        0        0        0
## 2259        0        0        0        0        0        1        0        0
## 2260        1        0        0        0        0        0        0        0
## 2261        0        0        0        0        1        0        0        0
## 2262        0        0        1        0        0        0        0        0
## 2263        0        0        0        0        0        0        0        0
## 2264        0        0        0        0        0        1        0        0
## 2265        0        0        0        1        0        0        0        0
## 2266        0        0        1        0        0        0        0        0
## 2267        0        0        0        0        0        0        0        0
## 2268        0        0        0        1        0        0        0        0
## 2269        0        0        0        0        0        0        0        1
## 2270        0        0        0        0        0        0        0        0
## 2271        0        0        0        0        0        0        1        0
## 2272        0        0        0        0        1        0        0        0
## 2273        1        0        0        0        0        0        0        0
## 2274        0        0        0        1        0        0        0        0
## 2275        0        0        0        0        0        0        0        0
## 2276        0        0        0        0        0        0        0        0
## 2277        0        0        0        0        0        0        0        0
## 2278        0        0        0        0        0        1        0        0
## 2279        0        0        0        0        0        0        0        0
## 2280        0        0        0        0        0        1        0        0
## 2281        0        1        0        0        0        0        0        0
## 2282        0        0        0        0        0        0        1        0
## 2283        0        0        0        0        0        1        0        0
## 2284        0        0        0        0        0        0        0        1
## 2285        0        0        0        0        0        0        1        0
## 2286        0        1        0        0        0        0        0        0
## 2287        0        1        0        0        0        0        0        0
## 2288        0        0        0        1        0        0        0        0
## 2289        0        0        1        0        0        0        0        0
## 2290        0        0        0        0        0        0        0        0
## 2291        0        0        0        0        0        0        1        0
## 2292        1        0        0        0        0        0        0        0
## 2293        0        1        0        0        0        0        0        0
## 2294        0        0        0        0        0        0        0        0
## 2295        0        1        0        0        0        0        0        0
## 2296        0        0        0        0        0        0        0        0
## 2297        0        0        0        0        0        0        0        0
## 2298        0        0        0        0        0        0        0        0
## 2299        0        0        0        0        0        0        0        0
## 2300        0        0        0        0        0        0        0        1
## 2301        0        0        0        0        0        0        1        0
## 2302        0        0        1        0        0        0        0        0
## 2303        0        0        0        0        1        0        0        0
## 2304        0        0        0        0        1        0        0        0
## 2305        0        0        1        0        0        0        0        0
## 2306        1        0        0        0        0        0        0        0
## 2307        0        1        0        0        0        0        0        0
## 2308        0        0        0        0        0        0        1        0
## 2309        0        0        0        1        0        0        0        0
## 2310        1        0        0        0        0        0        0        0
## 2311        0        0        0        1        0        0        0        0
## 2312        0        0        0        0        0        0        1        0
## 2313        0        1        0        0        0        0        0        0
## 2314        0        0        0        0        0        0        0        0
## 2315        0        1        0        0        0        0        0        0
## 2316        0        0        0        0        0        1        0        0
## 2317        0        0        0        0        0        0        0        1
## 2318        0        0        0        0        0        0        0        1
## 2319        0        1        0        0        0        0        0        0
## 2320        0        0        1        0        0        0        0        0
## 2321        0        0        0        0        0        0        1        0
## 2322        0        0        0        0        0        1        0        0
## 2323        0        0        1        0        0        0        0        0
## 2324        0        0        0        0        0        0        0        0
## 2325        0        1        0        0        0        0        0        0
## 2326        0        1        0        0        0        0        0        0
## 2327        0        0        0        0        0        1        0        0
## 2328        0        0        1        0        0        0        0        0
## 2329        0        0        0        0        0        1        0        0
## 2330        0        0        0        0        0        0        1        0
## 2331        0        0        0        0        1        0        0        0
## 2332        0        0        0        0        0        0        1        0
## 2333        0        0        0        0        0        0        0        0
## 2334        0        0        0        1        0        0        0        0
## 2335        0        0        0        0        0        0        1        0
## 2336        0        0        0        0        0        1        0        0
## 2337        0        1        0        0        0        0        0        0
## 2338        0        1        0        0        0        0        0        0
## 2339        0        1        0        0        0        0        0        0
## 2340        0        0        0        0        0        0        1        0
## 2341        0        0        0        0        0        0        0        0
## 2342        0        0        0        1        0        0        0        0
## 2343        0        0        0        0        0        0        0        1
## 2344        0        0        0        0        1        0        0        0
## 2345        0        1        0        0        0        0        0        0
## 2346        0        1        0        0        0        0        0        0
## 2347        0        0        0        0        0        0        0        1
## 2348        0        0        1        0        0        0        0        0
## 2349        0        0        0        0        0        0        0        0
## 2350        0        0        0        0        1        0        0        0
## 2351        1        0        0        0        0        0        0        0
## 2352        0        0        0        0        0        1        0        0
## 2353        0        0        0        0        0        0        0        0
## 2354        0        0        0        0        0        0        0        0
## 2355        0        1        0        0        0        0        0        0
## 2356        0        0        1        0        0        0        0        0
## 2357        0        0        0        0        0        0        0        1
## 2358        0        0        0        0        0        0        0        0
## 2359        0        1        0        0        0        0        0        0
## 2360        0        0        0        0        0        0        1        0
## 2361        0        0        0        1        0        0        0        0
## 2362        0        0        0        1        0        0        0        0
## 2363        0        0        0        0        0        1        0        0
## 2364        0        1        0        0        0        0        0        0
## 2365        0        0        0        0        0        0        0        1
## 2366        0        0        0        1        0        0        0        0
## 2367        0        1        0        0        0        0        0        0
## 2368        0        1        0        0        0        0        0        0
## 2369        0        0        1        0        0        0        0        0
## 2370        0        0        0        1        0        0        0        0
## 2371        0        0        1        0        0        0        0        0
## 2372        1        0        0        0        0        0        0        0
## 2373        0        0        0        0        1        0        0        0
## 2374        0        0        0        0        0        0        0        0
## 2375        0        0        0        0        0        0        0        0
## 2376        0        0        0        0        0        1        0        0
## 2377        1        0        0        0        0        0        0        0
## 2378        0        1        0        0        0        0        0        0
## 2379        0        0        0        0        0        0        0        0
## 2380        0        0        0        0        0        0        0        1
## 2381        0        0        0        0        0        0        1        0
## 2382        1        0        0        0        0        0        0        0
## 2383        0        0        0        0        0        0        0        0
## 2384        0        0        0        0        0        0        1        0
## 2385        0        0        0        0        0        0        0        1
## 2386        0        0        0        0        0        0        0        1
## 2387        0        0        0        0        1        0        0        0
## 2388        0        0        1        0        0        0        0        0
## 2389        1        0        0        0        0        0        0        0
## 2390        0        0        0        0        0        0        0        0
## 2391        0        1        0        0        0        0        0        0
## 2392        0        0        1        0        0        0        0        0
## 2393        0        0        0        1        0        0        0        0
## 2394        0        0        0        0        0        0        0        1
## 2395        0        0        0        0        1        0        0        0
## 2396        0        0        0        0        0        0        0        1
## 2397        0        0        0        1        0        0        0        0
## 2398        0        0        0        0        1        0        0        0
## 2399        0        0        0        0        0        0        1        0
## 2400        0        0        0        0        0        0        1        0
## 2401        0        0        0        0        0        0        0        1
## 2402        0        0        0        0        0        0        1        0
## 2403        0        0        0        0        0        0        1        0
## 2404        0        0        0        0        0        0        1        0
## 2405        0        0        0        1        0        0        0        0
## 2406        1        0        0        0        0        0        0        0
## 2407        0        0        0        0        0        0        0        1
## 2408        0        1        0        0        0        0        0        0
## 2409        0        0        0        0        0        0        0        0
## 2410        1        0        0        0        0        0        0        0
## 2411        0        0        0        0        0        0        1        0
## 2412        0        0        0        0        0        1        0        0
## 2413        0        0        0        0        0        0        1        0
## 2414        0        0        1        0        0        0        0        0
## 2415        1        0        0        0        0        0        0        0
## 2416        0        0        0        0        0        0        0        1
## 2417        0        1        0        0        0        0        0        0
## 2418        0        0        0        0        0        0        0        0
## 2419        1        0        0        0        0        0        0        0
## 2420        0        0        0        0        0        0        0        0
## 2421        0        0        0        0        0        0        0        0
## 2422        1        0        0        0        0        0        0        0
## 2423        0        0        0        0        0        0        0        0
## 2424        0        0        0        1        0        0        0        0
## 2425        0        0        0        0        0        0        1        0
## 2426        0        0        0        0        0        1        0        0
## 2427        0        0        0        0        0        0        0        1
## 2428        0        0        0        1        0        0        0        0
## 2429        0        0        0        0        0        0        1        0
## 2430        0        0        0        0        1        0        0        0
## 2431        0        0        0        0        1        0        0        0
## 2432        0        0        0        0        1        0        0        0
## 2433        0        0        0        0        0        0        0        0
## 2434        0        0        0        0        0        0        1        0
## 2435        0        0        0        0        0        0        1        0
## 2436        0        0        0        0        0        0        0        0
## 2437        0        0        0        0        0        0        1        0
## 2438        0        0        0        0        0        1        0        0
## 2439        1        0        0        0        0        0        0        0
## 2440        0        0        0        0        0        0        1        0
## 2441        0        0        0        0        0        0        0        0
## 2442        0        0        0        1        0        0        0        0
## 2443        0        0        0        0        1        0        0        0
## 2444        0        0        0        0        0        0        0        1
## 2445        0        0        0        0        1        0        0        0
## 2446        0        0        0        0        0        0        1        0
## 2447        0        0        0        0        0        0        1        0
## 2448        0        0        0        0        1        0        0        0
## 2449        0        0        0        0        0        1        0        0
## 2450        0        0        0        1        0        0        0        0
## 2451        0        0        0        0        0        0        1        0
## 2452        0        1        0        0        0        0        0        0
## 2453        0        0        0        1        0        0        0        0
## 2454        0        0        0        1        0        0        0        0
## 2455        0        0        0        0        1        0        0        0
## 2456        0        0        0        0        0        1        0        0
## 2457        0        0        1        0        0        0        0        0
## 2458        0        0        0        0        0        0        1        0
## 2459        0        0        0        0        0        1        0        0
## 2460        0        0        0        0        0        0        0        0
## 2461        0        0        0        0        0        1        0        0
## 2462        0        0        0        0        0        0        0        1
## 2463        1        0        0        0        0        0        0        0
## 2464        0        0        0        0        0        0        0        0
## 2465        0        1        0        0        0        0        0        0
## 2466        0        0        0        1        0        0        0        0
## 2467        0        0        1        0        0        0        0        0
## 2468        0        0        1        0        0        0        0        0
## 2469        0        0        1        0        0        0        0        0
## 2470        0        0        0        0        0        0        1        0
## 2471        1        0        0        0        0        0        0        0
## 2472        0        0        0        0        0        0        1        0
## 2473        0        0        0        0        0        1        0        0
## 2474        0        0        0        0        0        0        0        1
## 2475        0        1        0        0        0        0        0        0
## 2476        0        0        0        1        0        0        0        0
## 2477        1        0        0        0        0        0        0        0
## 2478        0        0        0        0        0        0        0        0
## 2479        0        0        0        0        0        0        0        0
## 2480        0        0        0        0        0        0        0        0
## 2481        0        0        0        0        0        0        0        0
## 2482        0        0        1        0        0        0        0        0
## 2483        0        0        0        0        0        0        0        0
## 2484        0        1        0        0        0        0        0        0
## 2485        0        1        0        0        0        0        0        0
## 2486        0        0        0        1        0        0        0        0
## 2487        0        0        1        0        0        0        0        0
## 2488        0        0        0        1        0        0        0        0
## 2489        0        0        0        0        1        0        0        0
## 2490        0        0        0        1        0        0        0        0
## 2491        0        0        0        0        0        1        0        0
## 2492        0        0        0        0        0        0        0        0
## 2493        0        0        0        0        0        0        1        0
## 2494        0        0        0        0        1        0        0        0
## 2495        0        0        0        0        0        0        0        0
## 2496        0        1        0        0        0        0        0        0
## 2497        0        1        0        0        0        0        0        0
## 2498        0        0        0        0        0        1        0        0
## 2499        0        0        0        0        0        1        0        0
## 2500        0        1        0        0        0        0        0        0
## 2501        0        0        0        0        0        0        0        0
## 2502        0        0        0        0        0        0        1        0
## 2503        0        0        0        1        0        0        0        0
## 2504        0        1        0        0        0        0        0        0
## 2505        0        0        0        0        0        0        0        0
## 2506        0        0        1        0        0        0        0        0
## 2507        0        0        0        0        0        0        0        0
## 2508        0        1        0        0        0        0        0        0
## 2509        0        0        0        0        0        0        0        0
## 2510        0        0        0        0        0        1        0        0
## 2511        0        0        0        1        0        0        0        0
## 2512        0        0        0        1        0        0        0        0
## 2513        0        0        0        0        0        0        0        1
## 2514        0        0        0        0        0        1        0        0
## 2515        0        1        0        0        0        0        0        0
## 2516        0        0        0        0        0        0        1        0
## 2517        0        0        0        0        0        0        1        0
## 2518        0        0        0        0        0        0        0        1
## 2519        0        0        1        0        0        0        0        0
## 2520        0        0        0        0        0        1        0        0
## 2521        0        0        0        1        0        0        0        0
## 2522        0        1        0        0        0        0        0        0
## 2523        0        0        0        0        0        0        0        0
## 2524        0        1        0        0        0        0        0        0
## 2525        0        0        0        0        0        0        0        0
## 2526        0        0        0        0        0        0        0        0
## 2527        0        0        0        0        0        0        0        0
## 2528        0        0        0        1        0        0        0        0
## 2529        0        1        0        0        0        0        0        0
## 2530        0        0        0        0        1        0        0        0
## 2531        0        0        1        0        0        0        0        0
## 2532        0        0        0        0        1        0        0        0
## 2533        0        0        1        0        0        0        0        0
## 2534        0        0        0        0        0        0        0        1
## 2535        0        0        0        0        0        1        0        0
## 2536        0        0        0        0        0        1        0        0
## 2537        0        1        0        0        0        0        0        0
## 2538        0        0        0        0        1        0        0        0
## 2539        0        0        0        1        0        0        0        0
## 2540        1        0        0        0        0        0        0        0
## 2541        0        0        0        0        0        1        0        0
## 2542        0        1        0        0        0        0        0        0
## 2543        1        0        0        0        0        0        0        0
## 2544        0        0        0        0        0        0        1        0
## 2545        0        0        0        0        0        0        0        0
## 2546        0        0        0        0        0        0        0        0
## 2547        0        0        0        0        0        0        0        0
## 2548        0        0        0        0        0        0        0        0
## 2549        0        0        0        0        0        0        0        1
## 2550        0        0        0        1        0        0        0        0
## 2551        0        0        1        0        0        0        0        0
## 2552        0        0        0        0        0        0        0        0
## 2553        0        0        0        0        0        0        1        0
## 2554        0        0        0        0        0        0        0        0
## 2555        0        1        0        0        0        0        0        0
## 2556        0        0        0        0        0        0        1        0
## 2557        0        0        0        0        1        0        0        0
## 2558        0        0        0        0        0        0        1        0
## 2559        0        0        0        0        0        1        0        0
## 2560        0        0        1        0        0        0        0        0
## 2561        0        0        0        0        0        0        0        1
## 2562        0        0        1        0        0        0        0        0
## 2563        0        0        0        0        0        0        0        1
## 2564        0        0        1        0        0        0        0        0
## 2565        0        0        0        0        0        0        0        0
## 2566        0        0        0        0        0        1        0        0
## 2567        0        0        0        0        0        1        0        0
## 2568        0        0        0        0        0        0        1        0
## 2569        0        0        0        0        0        0        0        0
## 2570        0        0        0        0        0        1        0        0
## 2571        0        0        0        0        0        0        0        0
## 2572        1        0        0        0        0        0        0        0
## 2573        0        0        0        1        0        0        0        0
## 2574        0        0        0        0        0        0        0        0
## 2575        0        1        0        0        0        0        0        0
## 2576        0        0        0        0        1        0        0        0
## 2577        0        1        0        0        0        0        0        0
## 2578        0        0        0        0        0        0        0        0
## 2579        1        0        0        0        0        0        0        0
## 2580        0        0        0        0        0        1        0        0
## 2581        0        0        0        0        0        0        0        0
## 2582        0        1        0        0        0        0        0        0
## 2583        0        0        0        0        0        0        0        1
## 2584        0        0        0        0        0        0        1        0
## 2585        0        1        0        0        0        0        0        0
## 2586        0        0        0        0        0        0        1        0
## 2587        0        0        1        0        0        0        0        0
## 2588        0        0        0        0        0        0        1        0
## 2589        0        0        1        0        0        0        0        0
## 2590        0        0        0        1        0        0        0        0
## 2591        0        1        0        0        0        0        0        0
## 2592        0        0        0        0        0        0        1        0
## 2593        0        0        1        0        0        0        0        0
## 2594        0        0        0        0        1        0        0        0
## 2595        0        0        0        0        0        0        1        0
## 2596        0        0        0        0        0        1        0        0
## 2597        1        0        0        0        0        0        0        0
## 2598        0        0        0        0        0        0        0        0
## 2599        0        0        0        0        1        0        0        0
## 2600        0        1        0        0        0        0        0        0
## 2601        0        0        0        0        0        0        0        1
## 2602        0        1        0        0        0        0        0        0
## 2603        0        0        0        0        1        0        0        0
## 2604        0        0        0        0        0        0        0        0
## 2605        0        0        0        0        0        0        1        0
## 2606        0        0        0        0        0        0        0        0
## 2607        0        0        0        0        0        0        1        0
## 2608        0        0        0        0        0        0        1        0
## 2609        0        0        1        0        0        0        0        0
## 2610        0        0        0        0        0        1        0        0
## 2611        0        0        0        0        0        0        1        0
## 2612        0        0        0        0        0        0        0        0
## 2613        1        0        0        0        0        0        0        0
## 2614        0        1        0        0        0        0        0        0
## 2615        0        0        1        0        0        0        0        0
## 2616        0        0        0        0        0        0        0        0
## 2617        0        0        0        0        0        1        0        0
## 2618        0        0        0        0        0        0        0        1
## 2619        0        0        0        0        0        1        0        0
## 2620        0        0        0        0        0        0        0        1
## 2621        0        0        0        0        0        1        0        0
## 2622        0        0        0        1        0        0        0        0
## 2623        0        0        0        0        0        0        0        0
## 2624        0        0        0        0        0        0        1        0
## 2625        0        0        0        1        0        0        0        0
## 2626        0        0        1        0        0        0        0        0
## 2627        0        0        0        0        0        0        0        0
## 2628        0        0        0        0        0        0        0        0
## 2629        0        0        0        0        0        0        1        0
## 2630        0        0        0        0        0        0        0        0
## 2631        0        0        0        0        0        1        0        0
## 2632        0        1        0        0        0        0        0        0
## 2633        0        0        0        0        0        1        0        0
## 2634        0        1        0        0        0        0        0        0
## 2635        0        0        0        0        0        0        1        0
## 2636        0        0        0        1        0        0        0        0
## 2637        0        1        0        0        0        0        0        0
## 2638        0        0        0        0        0        1        0        0
## 2639        0        0        0        0        0        0        0        0
## 2640        0        0        0        1        0        0        0        0
## 2641        0        1        0        0        0        0        0        0
## 2642        1        0        0        0        0        0        0        0
## 2643        0        0        0        1        0        0        0        0
## 2644        0        0        0        0        0        0        1        0
## 2645        0        0        1        0        0        0        0        0
## 2646        0        0        0        1        0        0        0        0
## 2647        0        0        0        0        1        0        0        0
## 2648        0        0        0        0        0        0        0        1
## 2649        0        0        0        1        0        0        0        0
## 2650        0        0        0        0        0        0        1        0
## 2651        0        0        0        0        0        1        0        0
## 2652        0        0        0        0        0        0        0        1
## 2653        0        0        0        0        0        0        0        1
## 2654        0        0        0        0        0        0        0        1
## 2655        0        0        0        0        0        0        0        1
## 2656        0        0        0        0        0        0        1        0
## 2657        0        0        0        0        0        0        1        0
## 2658        0        0        0        0        0        0        1        0
## 2659        0        0        0        1        0        0        0        0
## 2660        0        0        1        0        0        0        0        0
## 2661        0        1        0        0        0        0        0        0
## 2662        0        0        0        0        0        0        0        0
## 2663        0        1        0        0        0        0        0        0
## 2664        0        0        0        0        0        0        0        0
## 2665        0        1        0        0        0        0        0        0
## 2666        0        0        0        0        0        0        1        0
## 2667        0        0        0        0        1        0        0        0
## 2668        0        0        0        0        1        0        0        0
## 2669        0        0        0        0        0        0        0        0
## 2670        0        0        0        1        0        0        0        0
## 2671        0        0        0        0        0        0        0        1
## 2672        0        0        0        0        1        0        0        0
## 2673        0        1        0        0        0        0        0        0
## 2674        1        0        0        0        0        0        0        0
## 2675        0        0        0        0        0        0        0        0
## 2676        0        0        0        0        0        0        1        0
## 2677        0        0        0        0        0        0        0        0
## 2678        0        0        0        1        0        0        0        0
## 2679        0        0        0        0        0        1        0        0
## 2680        0        0        0        0        1        0        0        0
## 2681        1        0        0        0        0        0        0        0
## 2682        0        0        0        1        0        0        0        0
## 2683        0        0        0        0        0        0        0        0
## 2684        0        0        0        1        0        0        0        0
## 2685        0        0        0        0        0        0        0        0
## 2686        0        0        0        0        0        0        0        0
## 2687        0        0        0        0        1        0        0        0
## 2688        0        0        0        0        1        0        0        0
## 2689        0        0        0        0        0        0        0        1
## 2690        0        0        0        1        0        0        0        0
## 2691        0        0        1        0        0        0        0        0
## 2692        0        0        1        0        0        0        0        0
## 2693        0        0        1        0        0        0        0        0
## 2694        0        0        0        1        0        0        0        0
## 2695        0        0        1        0        0        0        0        0
## 2696        1        0        0        0        0        0        0        0
## 2697        1        0        0        0        0        0        0        0
## 2698        0        1        0        0        0        0        0        0
## 2699        0        0        0        0        1        0        0        0
## 2700        0        0        0        0        0        0        1        0
## 2701        0        0        0        0        0        0        1        0
## 2702        0        0        0        0        0        0        0        1
## 2703        0        0        0        0        0        0        1        0
## 2704        0        0        0        0        0        0        0        0
## 2705        0        0        0        0        0        0        1        0
## 2706        0        0        0        0        0        0        0        0
## 2707        0        0        0        0        0        0        1        0
## 2708        0        0        0        0        0        0        0        0
## 2709        0        0        0        0        0        0        1        0
## 2710        0        0        0        0        0        0        0        0
## 2711        1        0        0        0        0        0        0        0
## 2712        0        0        1        0        0        0        0        0
## 2713        0        0        0        0        0        0        0        1
## 2714        0        0        0        0        0        0        0        1
## 2715        0        0        0        0        0        0        0        0
## 2716        0        0        0        0        0        0        1        0
## 2717        0        0        1        0        0        0        0        0
## 2718        0        0        1        0        0        0        0        0
## 2719        0        0        0        0        0        0        0        1
## 2720        0        0        0        0        1        0        0        0
## 2721        0        1        0        0        0        0        0        0
## 2722        0        0        1        0        0        0        0        0
## 2723        0        0        0        0        0        0        0        1
## 2724        1        0        0        0        0        0        0        0
## 2725        0        1        0        0        0        0        0        0
## 2726        0        0        0        0        1        0        0        0
## 2727        0        0        0        1        0        0        0        0
## 2728        0        0        0        1        0        0        0        0
## 2729        0        0        1        0        0        0        0        0
## 2730        0        1        0        0        0        0        0        0
## 2731        0        0        0        0        0        0        0        0
## 2732        0        0        0        1        0        0        0        0
## 2733        0        0        0        1        0        0        0        0
## 2734        0        0        0        0        0        0        1        0
## 2735        0        0        0        0        0        0        0        0
## 2736        0        0        0        1        0        0        0        0
## 2737        0        0        0        0        0        1        0        0
## 2738        0        1        0        0        0        0        0        0
## 2739        0        0        0        1        0        0        0        0
## 2740        0        0        1        0        0        0        0        0
## 2741        0        0        0        0        0        0        0        0
## 2742        0        0        0        0        0        0        0        0
## 2743        0        0        0        0        0        0        0        1
## 2744        0        0        0        0        0        0        0        0
## 2745        0        0        0        1        0        0        0        0
## 2746        0        0        0        0        0        0        0        0
## 2747        0        0        0        1        0        0        0        0
## 2748        0        0        0        0        0        0        0        0
## 2749        0        0        0        0        0        0        0        1
## 2750        0        0        0        0        0        0        0        1
## 2751        0        0        0        0        0        0        0        0
## 2752        0        0        0        1        0        0        0        0
## 2753        1        0        0        0        0        0        0        0
## 2754        1        0        0        0        0        0        0        0
## 2755        0        1        0        0        0        0        0        0
## 2756        0        0        1        0        0        0        0        0
## 2757        0        0        0        0        0        0        0        0
## 2758        0        0        0        1        0        0        0        0
## 2759        0        0        1        0        0        0        0        0
## 2760        0        1        0        0        0        0        0        0
## 2761        0        0        0        0        0        1        0        0
## 2762        0        0        0        0        0        0        0        0
## 2763        0        0        0        0        0        0        0        1
## 2764        0        0        0        0        0        0        0        0
## 2765        0        0        0        0        0        0        1        0
## 2766        0        0        0        0        0        0        0        0
## 2767        0        0        0        1        0        0        0        0
## 2768        0        0        0        0        0        0        0        0
## 2769        0        0        0        0        0        1        0        0
## 2770        0        0        0        0        0        1        0        0
## 2771        0        0        0        0        1        0        0        0
## 2772        0        0        0        0        0        0        0        0
## 2773        0        0        0        1        0        0        0        0
## 2774        0        1        0        0        0        0        0        0
## 2775        0        0        0        1        0        0        0        0
## 2776        0        0        0        0        0        0        0        0
## 2777        1        0        0        0        0        0        0        0
## 2778        0        0        0        0        0        0        1        0
## 2779        0        0        0        0        1        0        0        0
## 2780        0        0        0        0        0        0        1        0
## 2781        0        0        0        0        0        0        0        0
## 2782        0        1        0        0        0        0        0        0
## 2783        0        0        0        0        0        0        0        1
## 2784        0        0        0        0        1        0        0        0
## 2785        0        0        0        0        1        0        0        0
## 2786        0        0        1        0        0        0        0        0
## 2787        0        0        0        0        0        0        0        1
## 2788        0        0        0        0        0        1        0        0
## 2789        0        0        0        0        1        0        0        0
## 2790        0        0        0        0        1        0        0        0
## 2791        0        0        0        0        0        0        0        0
## 2792        0        0        0        0        1        0        0        0
## 2793        0        0        0        0        0        0        0        0
## 2794        0        0        0        0        0        0        1        0
## 2795        0        1        0        0        0        0        0        0
## 2796        1        0        0        0        0        0        0        0
## 2797        0        0        0        1        0        0        0        0
## 2798        0        0        1        0        0        0        0        0
## 2799        0        0        0        0        0        1        0        0
## 2800        0        1        0        0        0        0        0        0
## 2801        0        0        0        1        0        0        0        0
## 2802        0        0        0        0        0        0        0        0
## 2803        1        0        0        0        0        0        0        0
## 2804        0        0        0        0        0        1        0        0
## 2805        0        0        0        0        0        0        0        1
## 2806        1        0        0        0        0        0        0        0
## 2807        0        1        0        0        0        0        0        0
## 2808        0        1        0        0        0        0        0        0
## 2809        0        0        1        0        0        0        0        0
## 2810        0        0        0        0        0        0        0        1
## 2811        0        0        0        0        0        1        0        0
## 2812        0        0        0        1        0        0        0        0
## 2813        0        0        0        0        0        0        0        1
## 2814        0        0        0        0        0        0        0        0
## 2815        0        0        0        0        1        0        0        0
## 2816        0        0        1        0        0        0        0        0
## 2817        0        0        0        0        0        0        1        0
## 2818        0        0        0        0        0        0        0        1
## 2819        0        0        1        0        0        0        0        0
## 2820        0        1        0        0        0        0        0        0
## 2821        0        0        1        0        0        0        0        0
## 2822        0        0        1        0        0        0        0        0
## 2823        0        0        0        0        0        0        0        1
## 2824        0        0        0        0        0        0        0        0
## 2825        0        0        0        0        0        0        1        0
## 2826        0        0        0        0        0        0        0        1
## 2827        0        0        0        0        0        0        0        0
## 2828        0        0        0        0        0        1        0        0
## 2829        0        0        0        1        0        0        0        0
## 2830        0        0        0        0        0        0        0        0
## 2831        0        0        0        0        0        0        0        0
## 2832        0        0        0        0        0        0        1        0
## 2833        0        0        0        0        0        0        0        0
## 2834        0        0        0        0        0        0        1        0
## 2835        1        0        0        0        0        0        0        0
## 2836        0        0        0        0        0        0        1        0
## 2837        0        0        0        0        0        0        0        0
## 2838        0        0        1        0        0        0        0        0
## 2839        1        0        0        0        0        0        0        0
## 2840        0        1        0        0        0        0        0        0
## 2841        0        0        0        0        0        0        0        0
## 2842        0        0        0        0        1        0        0        0
## 2843        0        0        0        0        0        0        1        0
## 2844        0        0        0        0        0        0        0        1
## 2845        0        0        0        0        0        1        0        0
## 2846        0        0        0        1        0        0        0        0
## 2847        0        0        0        0        0        0        1        0
## 2848        0        0        0        0        0        0        0        0
## 2849        0        0        0        0        0        0        0        0
## 2850        1        0        0        0        0        0        0        0
## 2851        0        0        1        0        0        0        0        0
## 2852        0        0        0        0        1        0        0        0
## 2853        0        0        0        0        0        0        0        0
## 2854        0        0        0        0        1        0        0        0
## 2855        0        0        0        1        0        0        0        0
## 2856        0        0        0        0        0        0        0        0
## 2857        0        0        0        0        0        0        0        0
## 2858        0        0        0        0        1        0        0        0
## 2859        0        0        0        0        0        0        1        0
## 2860        0        0        0        0        0        0        0        0
## 2861        0        0        0        0        0        0        0        0
## 2862        0        0        0        1        0        0        0        0
## 2863        0        0        0        0        0        1        0        0
## 2864        0        1        0        0        0        0        0        0
## 2865        0        0        0        1        0        0        0        0
## 2866        0        0        0        0        0        0        0        0
## 2867        0        0        0        0        0        0        0        0
## 2868        0        0        0        1        0        0        0        0
## 2869        0        0        0        0        1        0        0        0
## 2870        0        0        0        1        0        0        0        0
## 2871        0        0        0        0        0        0        0        0
## 2872        0        0        0        0        0        0        0        1
## 2873        0        0        1        0        0        0        0        0
## 2874        1        0        0        0        0        0        0        0
## 2875        0        0        0        0        0        1        0        0
## 2876        0        0        1        0        0        0        0        0
## 2877        1        0        0        0        0        0        0        0
## 2878        0        0        0        0        0        0        1        0
## 2879        0        0        0        0        1        0        0        0
## 2880        0        0        0        0        0        0        1        0
## 2881        0        1        0        0        0        0        0        0
## 2882        0        0        0        0        0        0        0        0
## 2883        0        0        0        0        1        0        0        0
## 2884        0        0        0        0        0        1        0        0
## 2885        0        0        0        0        0        0        0        0
## 2886        0        0        0        0        0        0        1        0
## 2887        0        0        0        0        0        1        0        0
## 2888        0        0        0        0        0        1        0        0
## 2889        0        0        0        0        1        0        0        0
## 2890        0        0        0        0        0        0        0        0
## 2891        0        0        1        0        0        0        0        0
## 2892        0        1        0        0        0        0        0        0
## 2893        1        0        0        0        0        0        0        0
## 2894        0        1        0        0        0        0        0        0
## 2895        0        1        0        0        0        0        0        0
## 2896        0        1        0        0        0        0        0        0
## 2897        0        1        0        0        0        0        0        0
## 2898        0        1        0        0        0        0        0        0
## 2899        0        0        0        0        1        0        0        0
## 2900        0        0        1        0        0        0        0        0
## 2901        1        0        0        0        0        0        0        0
## 2902        0        0        0        1        0        0        0        0
## 2903        0        0        0        0        0        1        0        0
## 2904        0        0        0        0        0        0        0        0
## 2905        0        0        0        1        0        0        0        0
## 2906        0        0        0        1        0        0        0        0
## 2907        0        0        0        0        0        0        0        1
## 2908        0        0        0        0        1        0        0        0
## 2909        0        0        1        0        0        0        0        0
## 2910        0        0        0        0        0        0        1        0
## 2911        0        0        0        0        1        0        0        0
## 2912        0        0        0        0        0        0        1        0
## 2913        0        0        0        1        0        0        0        0
## 2914        0        0        1        0        0        0        0        0
## 2915        0        0        0        0        0        0        0        0
## 2916        0        0        0        0        0        0        0        0
## 2917        0        0        0        0        0        0        0        0
## 2918        0        0        0        0        0        0        0        0
## 2919        0        0        0        0        0        0        0        0
## 2920        0        0        0        0        0        0        0        1
## 2921        0        0        0        1        0        0        0        0
## 2922        1        0        0        0        0        0        0        0
## 2923        0        0        0        1        0        0        0        0
## 2924        0        0        0        0        0        0        1        0
## 2925        0        1        0        0        0        0        0        0
## 2926        1        0        0        0        0        0        0        0
## 2927        0        0        0        1        0        0        0        0
## 2928        0        0        0        0        0        0        1        0
## 2929        0        1        0        0        0        0        0        0
## 2930        0        0        0        0        0        0        0        1
## 2931        1        0        0        0        0        0        0        0
## 2932        0        1        0        0        0        0        0        0
## 2933        1        0        0        0        0        0        0        0
## 2934        0        0        0        1        0        0        0        0
## 2935        0        0        0        0        0        1        0        0
## 2936        0        0        0        0        0        0        0        1
## 2937        1        0        0        0        0        0        0        0
## 2938        0        0        1        0        0        0        0        0
## 2939        0        0        0        0        0        0        0        0
## 2940        0        0        0        0        0        0        0        0
## 2941        0        0        0        0        0        1        0        0
## 2942        0        0        0        1        0        0        0        0
## 2943        0        0        0        0        0        0        0        0
## 2944        0        0        0        0        0        0        0        0
## 2945        0        0        0        0        0        0        0        0
## 2946        0        0        0        0        0        0        0        0
## 2947        0        1        0        0        0        0        0        0
## 2948        1        0        0        0        0        0        0        0
## 2949        0        0        1        0        0        0        0        0
## 2950        1        0        0        0        0        0        0        0
## 2951        0        1        0        0        0        0        0        0
## 2952        1        0        0        0        0        0        0        0
## 2953        0        0        0        1        0        0        0        0
## 2954        0        0        0        0        0        0        0        0
## 2955        1        0        0        0        0        0        0        0
## 2956        0        0        0        0        0        0        0        1
## 2957        0        0        0        0        0        0        0        0
## 2958        0        0        0        0        0        0        0        0
## 2959        0        0        0        0        0        1        0        0
## 2960        0        0        0        0        0        0        1        0
## 2961        0        0        1        0        0        0        0        0
## 2962        0        0        0        0        0        0        0        0
## 2963        0        0        1        0        0        0        0        0
## 2964        0        0        1        0        0        0        0        0
## 2965        0        0        0        1        0        0        0        0
## 2966        0        0        0        0        0        0        0        1
## 2967        0        0        0        0        0        0        1        0
## 2968        0        0        0        0        0        0        1        0
## 2969        0        0        0        0        1        0        0        0
## 2970        0        0        0        0        0        0        0        1
## 2971        0        0        0        0        0        1        0        0
## 2972        0        0        0        0        0        0        0        1
## 2973        0        1        0        0        0        0        0        0
## 2974        0        0        0        0        0        0        1        0
## 2975        0        0        0        0        0        0        0        0
## 2976        0        0        0        1        0        0        0        0
## 2977        0        0        0        0        1        0        0        0
## 2978        0        0        1        0        0        0        0        0
## 2979        0        0        0        0        0        0        0        0
## 2980        0        0        0        0        0        1        0        0
## 2981        0        0        0        0        0        0        0        0
## 2982        0        0        0        0        0        0        1        0
## 2983        0        0        0        0        0        0        1        0
## 2984        0        0        0        0        1        0        0        0
## 2985        0        0        0        0        1        0        0        0
## 2986        1        0        0        0        0        0        0        0
## 2987        0        0        0        0        0        0        0        0
## 2988        0        0        0        0        0        0        0        1
## 2989        0        0        0        0        0        0        0        1
## 2990        0        1        0        0        0        0        0        0
## 2991        0        0        0        1        0        0        0        0
## 2992        0        1        0        0        0        0        0        0
## 2993        0        0        0        0        0        0        0        0
## 2994        0        0        0        1        0        0        0        0
## 2995        1        0        0        0        0        0        0        0
## 2996        0        0        0        0        0        0        0        0
## 2997        0        0        0        1        0        0        0        0
## 2998        0        0        0        0        1        0        0        0
## 2999        0        0        0        0        0        0        0        1
## 3000        1        0        0        0        0        0        0        0
## 3001        0        0        0        0        0        0        0        1
## 3002        1        0        0        0        0        0        0        0
## 3003        0        0        0        0        0        0        1        0
## 3004        1        0        0        0        0        0        0        0
## 3005        0        1        0        0        0        0        0        0
## 3006        0        1        0        0        0        0        0        0
## 3007        0        0        0        0        0        0        0        1
## 3008        0        0        0        1        0        0        0        0
## 3009        0        0        0        0        0        0        0        0
## 3010        0        0        1        0        0        0        0        0
## 3011        0        1        0        0        0        0        0        0
## 3012        0        0        0        0        0        1        0        0
## 3013        0        1        0        0        0        0        0        0
## 3014        0        0        0        0        0        1        0        0
## 3015        0        0        0        0        1        0        0        0
## 3016        0        0        0        0        0        1        0        0
## 3017        0        0        0        0        0        0        0        0
## 3018        0        1        0        0        0        0        0        0
## 3019        0        0        0        0        1        0        0        0
## 3020        0        0        0        0        1        0        0        0
## 3021        0        0        0        1        0        0        0        0
## 3022        0        1        0        0        0        0        0        0
## 3023        1        0        0        0        0        0        0        0
## 3024        0        0        0        0        0        1        0        0
## 3025        0        0        0        1        0        0        0        0
## 3026        0        0        0        0        0        0        0        0
## 3027        0        0        0        1        0        0        0        0
## 3028        1        0        0        0        0        0        0        0
## 3029        0        1        0        0        0        0        0        0
## 3030        0        0        0        0        0        0        0        0
## 3031        0        1        0        0        0        0        0        0
## 3032        0        0        0        0        1        0        0        0
## 3033        0        0        0        0        1        0        0        0
## 3034        0        0        0        0        0        0        0        0
## 3035        0        0        1        0        0        0        0        0
## 3036        0        0        0        0        0        0        0        0
## 3037        0        0        0        1        0        0        0        0
## 3038        0        0        0        0        0        0        0        1
## 3039        0        0        0        0        1        0        0        0
## 3040        0        0        0        0        0        0        1        0
## 3041        0        0        1        0        0        0        0        0
## 3042        1        0        0        0        0        0        0        0
## 3043        0        0        0        1        0        0        0        0
## 3044        0        1        0        0        0        0        0        0
## 3045        0        0        0        0        1        0        0        0
## 3046        0        1        0        0        0        0        0        0
## 3047        0        0        0        0        0        0        0        0
## 3048        0        0        1        0        0        0        0        0
## 3049        0        0        0        1        0        0        0        0
## 3050        0        1        0        0        0        0        0        0
## 3051        0        0        0        1        0        0        0        0
## 3052        0        0        0        0        0        0        0        0
## 3053        0        0        0        0        1        0        0        0
## 3054        0        0        0        0        0        0        0        0
## 3055        0        1        0        0        0        0        0        0
## 3056        0        0        0        0        0        0        0        1
## 3057        0        1        0        0        0        0        0        0
## 3058        0        1        0        0        0        0        0        0
## 3059        0        0        0        0        0        1        0        0
## 3060        0        0        0        0        0        1        0        0
## 3061        1        0        0        0        0        0        0        0
## 3062        0        0        0        0        0        0        0        0
## 3063        0        0        0        0        0        0        1        0
## 3064        0        0        0        0        0        0        0        0
## 3065        0        0        0        0        0        0        0        0
## 3066        0        0        0        0        0        0        0        0
## 3067        0        0        0        0        1        0        0        0
## 3068        1        0        0        0        0        0        0        0
## 3069        0        0        0        0        0        0        0        0
## 3070        0        0        0        0        0        1        0        0
## 3071        0        0        0        0        0        0        0        0
## 3072        0        0        0        1        0        0        0        0
## 3073        1        0        0        0        0        0        0        0
## 3074        0        0        0        1        0        0        0        0
## 3075        0        0        0        0        0        0        0        1
## 3076        0        1        0        0        0        0        0        0
## 3077        0        0        0        0        0        0        1        0
## 3078        0        0        1        0        0        0        0        0
## 3079        0        0        0        0        0        0        0        1
## 3080        0        0        0        0        1        0        0        0
## 3081        0        0        0        0        1        0        0        0
## 3082        0        0        1        0        0        0        0        0
## 3083        0        0        0        0        0        0        0        0
## 3084        0        0        0        0        0        0        0        1
## 3085        0        0        0        0        0        0        0        1
## 3086        0        0        0        1        0        0        0        0
## 3087        0        0        0        0        0        0        0        1
## 3088        0        0        0        0        0        0        0        0
## 3089        0        0        0        0        1        0        0        0
## 3090        0        0        0        0        0        0        0        0
## 3091        0        0        0        0        0        0        1        0
## 3092        0        1        0        0        0        0        0        0
## 3093        0        0        1        0        0        0        0        0
## 3094        0        0        1        0        0        0        0        0
## 3095        0        1        0        0        0        0        0        0
## 3096        0        0        0        0        0        0        0        1
## 3097        0        0        0        0        0        0        1        0
## 3098        0        0        0        0        0        0        0        1
## 3099        0        1        0        0        0        0        0        0
## 3100        0        0        0        1        0        0        0        0
## 3101        0        0        1        0        0        0        0        0
## 3102        0        0        0        0        0        0        0        0
## 3103        0        0        1        0        0        0        0        0
## 3104        0        0        0        0        0        0        0        0
## 3105        0        1        0        0        0        0        0        0
## 3106        0        0        0        0        0        0        1        0
## 3107        0        0        0        0        0        0        0        1
## 3108        0        0        0        0        0        0        0        1
## 3109        0        0        0        1        0        0        0        0
## 3110        0        0        0        0        1        0        0        0
## 3111        0        0        0        0        0        0        1        0
## 3112        1        0        0        0        0        0        0        0
## 3113        0        0        0        0        0        0        0        0
## 3114        0        0        0        0        0        0        0        0
## 3115        0        0        0        0        0        1        0        0
## 3116        0        1        0        0        0        0        0        0
## 3117        0        0        0        0        0        0        0        0
## 3118        0        0        0        0        0        0        1        0
## 3119        0        0        0        0        0        0        1        0
## 3120        0        0        1        0        0        0        0        0
## 3121        0        0        0        0        0        0        0        0
## 3122        0        0        0        1        0        0        0        0
## 3123        0        0        0        1        0        0        0        0
## 3124        0        1        0        0        0        0        0        0
## 3125        0        0        1        0        0        0        0        0
## 3126        0        0        1        0        0        0        0        0
## 3127        0        0        0        1        0        0        0        0
## 3128        0        0        1        0        0        0        0        0
## 3129        0        1        0        0        0        0        0        0
## 3130        0        0        0        0        0        0        0        0
## 3131        0        0        0        0        0        1        0        0
## 3132        0        1        0        0        0        0        0        0
## 3133        0        0        0        0        0        0        0        0
## 3134        1        0        0        0        0        0        0        0
## 3135        0        1        0        0        0        0        0        0
## 3136        0        0        0        0        0        0        0        0
## 3137        0        0        0        0        0        0        0        0
## 3138        1        0        0        0        0        0        0        0
## 3139        0        0        0        0        1        0        0        0
## 3140        0        0        0        0        0        0        0        0
## 3141        0        0        0        0        0        0        0        0
## 3142        0        0        1        0        0        0        0        0
## 3143        0        0        0        0        0        1        0        0
## 3144        0        0        0        0        0        0        0        0
## 3145        0        0        1        0        0        0        0        0
## 3146        0        0        0        0        1        0        0        0
## 3147        0        1        0        0        0        0        0        0
## 3148        0        0        1        0        0        0        0        0
## 3149        1        0        0        0        0        0        0        0
## 3150        0        0        1        0        0        0        0        0
## 3151        0        0        0        0        1        0        0        0
## 3152        0        0        0        0        0        1        0        0
## 3153        1        0        0        0        0        0        0        0
## 3154        1        0        0        0        0        0        0        0
## 3155        0        0        0        0        0        1        0        0
## 3156        0        0        0        0        0        0        1        0
## 3157        0        0        0        1        0        0        0        0
## 3158        0        1        0        0        0        0        0        0
## 3159        0        0        0        0        0        1        0        0
## 3160        0        0        0        0        0        0        0        0
## 3161        0        1        0        0        0        0        0        0
## 3162        0        0        0        0        0        1        0        0
## 3163        0        0        0        0        0        0        0        0
## 3164        0        0        0        0        0        1        0        0
## 3165        0        0        0        1        0        0        0        0
## 3166        0        0        0        0        0        0        0        1
## 3167        0        0        0        0        0        1        0        0
## 3168        0        0        0        0        0        1        0        0
## 3169        0        0        0        1        0        0        0        0
## 3170        0        0        0        0        0        0        0        0
## 3171        0        0        0        0        0        1        0        0
## 3172        0        0        0        0        0        0        0        0
## 3173        0        0        0        0        0        1        0        0
## 3174        0        0        1        0        0        0        0        0
## 3175        0        0        0        0        0        1        0        0
## 3176        0        0        0        0        0        0        1        0
## 3177        0        0        0        1        0        0        0        0
## 3178        0        0        0        0        0        1        0        0
## 3179        0        0        0        0        0        0        1        0
## 3180        0        0        0        1        0        0        0        0
## 3181        0        0        0        0        0        1        0        0
## 3182        1        0        0        0        0        0        0        0
## 3183        0        1        0        0        0        0        0        0
## 3184        0        0        0        0        0        0        0        0
## 3185        0        0        0        0        0        0        1        0
## 3186        0        0        0        1        0        0        0        0
## 3187        0        0        0        0        0        0        0        1
## 3188        0        0        1        0        0        0        0        0
## 3189        0        0        0        0        1        0        0        0
## 3190        0        1        0        0        0        0        0        0
## 3191        0        0        0        0        0        1        0        0
## 3192        0        0        0        0        0        1        0        0
## 3193        0        0        0        0        0        0        0        0
## 3194        0        0        0        1        0        0        0        0
## 3195        0        0        0        0        0        0        1        0
## 3196        0        0        0        1        0        0        0        0
## 3197        0        0        0        0        0        0        1        0
## 3198        0        0        0        0        0        0        0        0
## 3199        0        0        0        0        0        0        0        0
## 3200        0        0        0        0        0        0        1        0
## 3201        0        0        0        0        0        0        0        1
## 3202        0        0        0        1        0        0        0        0
## 3203        0        0        0        0        1        0        0        0
## 3204        1        0        0        0        0        0        0        0
## 3205        0        0        1        0        0        0        0        0
## 3206        0        0        0        1        0        0        0        0
## 3207        0        0        0        0        0        0        0        1
## 3208        0        0        0        0        0        0        1        0
## 3209        0        0        0        0        0        0        0        0
## 3210        0        0        0        0        0        0        1        0
## 3211        0        0        0        0        0        1        0        0
## 3212        0        0        0        0        0        0        0        0
## 3213        0        0        0        0        0        0        0        0
## 3214        0        0        0        0        0        1        0        0
## 3215        0        0        0        0        0        0        0        0
## 3216        0        0        0        0        0        0        0        0
## 3217        0        1        0        0        0        0        0        0
## 3218        0        0        0        0        0        0        0        0
## 3219        0        0        0        0        0        0        0        0
## 3220        0        0        0        0        1        0        0        0
## 3221        0        0        0        0        1        0        0        0
## 3222        0        0        0        0        0        0        1        0
## 3223        0        0        0        0        0        0        1        0
## 3224        0        0        0        0        0        0        0        0
## 3225        0        0        0        0        0        0        0        0
## 3226        0        0        0        0        0        0        0        0
## 3227        0        0        0        0        0        0        1        0
## 3228        0        0        0        0        0        0        0        0
## 3229        0        0        0        0        0        1        0        0
## 3230        0        1        0        0        0        0        0        0
## 3231        1        0        0        0        0        0        0        0
## 3232        0        0        0        0        0        0        0        1
## 3233        0        0        0        0        0        0        0        0
## 3234        0        0        0        1        0        0        0        0
## 3235        0        1        0        0        0        0        0        0
## 3236        0        0        0        1        0        0        0        0
## 3237        0        0        0        0        0        1        0        0
## 3238        1        0        0        0        0        0        0        0
## 3239        0        0        1        0        0        0        0        0
## 3240        0        0        0        0        0        0        0        0
## 3241        0        0        0        0        0        0        0        0
## 3242        0        0        0        0        0        1        0        0
## 3243        0        0        0        0        1        0        0        0
## 3244        0        0        0        0        0        0        1        0
## 3245        0        0        0        1        0        0        0        0
## 3246        0        1        0        0        0        0        0        0
## 3247        0        0        1        0        0        0        0        0
## 3248        0        0        0        0        0        0        1        0
## 3249        0        1        0        0        0        0        0        0
## 3250        0        0        1        0        0        0        0        0
## 3251        0        0        0        0        0        0        0        1
## 3252        0        1        0        0        0        0        0        0
## 3253        0        0        0        0        0        0        0        1
## 3254        1        0        0        0        0        0        0        0
## 3255        0        0        0        1        0        0        0        0
## 3256        0        0        0        0        1        0        0        0
## 3257        0        0        0        0        0        0        1        0
## 3258        0        0        0        0        0        0        0        0
## 3259        0        0        0        0        0        0        0        0
## 3260        0        0        0        0        0        0        1        0
## 3261        0        0        0        1        0        0        0        0
## 3262        0        0        0        1        0        0        0        0
## 3263        0        0        0        0        0        0        0        1
## 3264        0        1        0        0        0        0        0        0
## 3265        0        1        0        0        0        0        0        0
## 3266        0        0        0        0        0        0        0        1
## 3267        0        1        0        0        0        0        0        0
## 3268        0        1        0        0        0        0        0        0
## 3269        0        0        0        1        0        0        0        0
## 3270        0        0        0        0        1        0        0        0
## 3271        0        1        0        0        0        0        0        0
## 3272        0        0        0        0        0        0        1        0
## 3273        0        0        0        0        0        1        0        0
## 3274        0        0        0        0        0        0        0        0
## 3275        0        0        0        0        0        0        0        0
## 3276        0        0        0        1        0        0        0        0
## 3277        0        1        0        0        0        0        0        0
## 3278        0        0        0        0        0        0        1        0
## 3279        0        0        0        0        0        1        0        0
## 3280        0        1        0        0        0        0        0        0
## 3281        0        0        0        0        0        0        1        0
## 3282        0        0        1        0        0        0        0        0
## 3283        0        0        0        0        0        1        0        0
## 3284        0        0        0        0        0        0        0        0
## 3285        0        0        0        0        0        1        0        0
## 3286        0        0        0        0        0        1        0        0
## 3287        0        0        0        0        0        0        0        0
## 3288        1        0        0        0        0        0        0        0
## 3289        0        0        0        0        0        0        0        1
## 3290        0        0        0        0        0        0        0        1
## 3291        0        0        0        0        0        1        0        0
## 3292        0        1        0        0        0        0        0        0
## 3293        0        1        0        0        0        0        0        0
## 3294        0        0        0        0        0        0        0        0
## 3295        0        0        0        0        0        0        0        0
## 3296        0        1        0        0        0        0        0        0
## 3297        0        0        0        0        0        0        0        0
## 3298        0        0        0        0        0        0        0        1
## 3299        1        0        0        0        0        0        0        0
## 3300        0        1        0        0        0        0        0        0
## 3301        0        0        1        0        0        0        0        0
## 3302        0        0        0        0        0        0        1        0
## 3303        0        0        0        0        0        1        0        0
## 3304        0        0        0        1        0        0        0        0
## 3305        0        0        0        0        1        0        0        0
## 3306        0        0        0        0        0        0        0        0
## 3307        0        0        0        1        0        0        0        0
## 3308        0        0        1        0        0        0        0        0
## 3309        0        0        0        1        0        0        0        0
## 3310        0        0        0        0        1        0        0        0
## 3311        0        1        0        0        0        0        0        0
## 3312        0        0        0        0        0        0        0        1
## 3313        0        0        0        0        0        1        0        0
## 3314        0        1        0        0        0        0        0        0
## 3315        0        0        0        0        0        0        0        1
## 3316        0        0        0        0        0        0        0        1
## 3317        0        0        0        0        0        0        1        0
## 3318        0        0        0        0        0        0        0        0
## 3319        0        0        0        0        0        0        0        0
## 3320        0        0        0        0        0        0        0        0
## 3321        0        0        0        0        0        0        0        1
## 3322        0        0        0        0        0        0        1        0
## 3323        0        0        0        0        1        0        0        0
## 3324        0        0        0        0        0        1        0        0
## 3325        0        0        0        0        0        0        1        0
## 3326        0        0        0        0        1        0        0        0
## 3327        1        0        0        0        0        0        0        0
## 3328        0        0        0        0        0        1        0        0
## 3329        0        0        0        0        0        0        0        0
## 3330        0        1        0        0        0        0        0        0
## 3331        0        0        0        0        0        0        0        0
## 3332        0        0        1        0        0        0        0        0
## 3333        0        0        0        0        0        0        0        1
## 3334        1        0        0        0        0        0        0        0
## 3335        0        0        0        0        0        0        0        0
## 3336        1        0        0        0        0        0        0        0
## 3337        0        0        0        0        0        0        0        1
## 3338        0        1        0        0        0        0        0        0
## 3339        0        0        0        0        0        0        0        0
## 3340        0        0        0        0        0        1        0        0
## 3341        0        0        0        1        0        0        0        0
## 3342        0        0        0        0        0        0        0        0
## 3343        0        0        1        0        0        0        0        0
## 3344        0        0        0        0        0        0        0        1
## 3345        0        1        0        0        0        0        0        0
## 3346        0        0        1        0        0        0        0        0
## 3347        0        0        0        0        0        0        0        1
## 3348        0        0        0        0        0        0        0        1
## 3349        0        0        0        1        0        0        0        0
## 3350        0        0        0        0        0        0        0        1
## 3351        0        0        0        0        0        1        0        0
## 3352        0        0        0        1        0        0        0        0
## 3353        0        0        0        0        0        0        0        0
## 3354        0        0        0        1        0        0        0        0
## 3355        1        0        0        0        0        0        0        0
## 3356        1        0        0        0        0        0        0        0
## 3357        0        0        0        0        0        0        0        0
## 3358        0        0        0        0        0        0        0        0
## 3359        0        0        0        0        0        0        1        0
## 3360        0        0        0        0        0        0        0        0
## 3361        0        0        0        0        0        0        0        0
## 3362        0        0        0        1        0        0        0        0
## 3363        0        0        0        0        0        0        0        1
## 3364        0        0        0        0        0        0        0        1
## 3365        0        1        0        0        0        0        0        0
## 3366        0        0        0        0        0        0        1        0
## 3367        0        1        0        0        0        0        0        0
## 3368        0        0        0        0        0        0        0        0
## 3369        0        0        0        0        0        0        0        0
## 3370        0        1        0        0        0        0        0        0
## 3371        0        0        0        0        0        0        1        0
## 3372        0        0        0        0        1        0        0        0
## 3373        0        0        0        0        0        0        1        0
## 3374        0        0        0        1        0        0        0        0
## 3375        0        0        0        0        0        0        1        0
## 3376        0        0        0        0        0        0        0        1
## 3377        0        0        0        0        0        0        0        1
## 3378        0        0        0        1        0        0        0        0
## 3379        0        0        0        0        1        0        0        0
## 3380        0        0        0        1        0        0        0        0
## 3381        0        1        0        0        0        0        0        0
## 3382        0        0        0        0        0        0        0        1
## 3383        1        0        0        0        0        0        0        0
## 3384        0        0        0        0        0        1        0        0
## 3385        0        0        0        0        0        0        0        0
## 3386        0        0        0        0        0        0        0        0
## 3387        0        0        0        0        0        0        0        0
## 3388        0        0        0        0        0        1        0        0
## 3389        0        0        0        0        0        0        0        0
## 3390        1        0        0        0        0        0        0        0
## 3391        0        0        0        1        0        0        0        0
## 3392        0        0        0        0        0        0        0        1
## 3393        0        0        0        0        0        0        0        0
## 3394        0        0        0        0        0        0        0        0
## 3395        0        0        0        1        0        0        0        0
## 3396        0        0        0        1        0        0        0        0
## 3397        1        0        0        0        0        0        0        0
## 3398        0        0        1        0        0        0        0        0
## 3399        0        0        0        0        0        0        0        0
## 3400        0        0        0        0        0        0        0        1
## 3401        0        0        0        0        0        0        0        0
## 3402        0        0        0        0        1        0        0        0
## 3403        0        1        0        0        0        0        0        0
## 3404        0        0        0        0        0        0        0        1
## 3405        0        0        0        0        0        1        0        0
## 3406        0        0        0        0        0        0        0        0
## 3407        0        0        0        0        0        0        0        0
## 3408        0        0        0        0        0        0        0        1
## 3409        1        0        0        0        0        0        0        0
## 3410        0        0        0        0        1        0        0        0
## 3411        0        0        0        0        0        0        0        1
## 3412        0        1        0        0        0        0        0        0
## 3413        0        0        0        0        1        0        0        0
## 3414        0        0        0        0        1        0        0        0
## 3415        0        0        0        0        0        0        1        0
## 3416        0        1        0        0        0        0        0        0
## 3417        0        0        0        0        0        0        1        0
## 3418        0        0        0        0        1        0        0        0
## 3419        0        0        0        0        0        0        0        0
## 3420        0        0        1        0        0        0        0        0
## 3421        0        1        0        0        0        0        0        0
## 3422        0        0        0        0        0        0        0        1
## 3423        0        0        1        0        0        0        0        0
## 3424        1        0        0        0        0        0        0        0
## 3425        0        0        0        1        0        0        0        0
## 3426        0        1        0        0        0        0        0        0
## 3427        0        0        0        1        0        0        0        0
## 3428        1        0        0        0        0        0        0        0
## 3429        0        1        0        0        0        0        0        0
## 3430        1        0        0        0        0        0        0        0
## 3431        0        0        0        0        1        0        0        0
## 3432        0        0        0        0        0        0        1        0
## 3433        0        0        1        0        0        0        0        0
## 3434        0        0        0        1        0        0        0        0
## 3435        0        0        0        0        1        0        0        0
## 3436        0        0        0        0        0        0        0        0
## 3437        0        1        0        0        0        0        0        0
## 3438        0        0        0        1        0        0        0        0
## 3439        0        0        0        0        1        0        0        0
## 3440        0        0        0        1        0        0        0        0
## 3441        0        0        0        0        0        0        0        0
## 3442        0        0        0        1        0        0        0        0
## 3443        0        0        0        0        0        0        0        0
## 3444        0        0        0        0        0        0        0        0
## 3445        0        0        1        0        0        0        0        0
## 3446        0        0        0        0        0        1        0        0
## 3447        0        0        0        0        0        0        1        0
## 3448        0        0        0        0        0        0        0        0
## 3449        0        1        0        0        0        0        0        0
## 3450        0        0        0        0        1        0        0        0
## 3451        0        0        0        0        1        0        0        0
## 3452        0        0        0        0        0        0        1        0
## 3453        0        0        0        0        1        0        0        0
## 3454        0        0        0        0        0        0        1        0
## 3455        0        0        0        0        0        0        0        0
## 3456        0        1        0        0        0        0        0        0
## 3457        0        0        1        0        0        0        0        0
## 3458        0        0        0        0        0        0        0        0
## 3459        0        1        0        0        0        0        0        0
## 3460        0        1        0        0        0        0        0        0
## 3461        0        0        0        0        0        0        0        1
## 3462        0        0        0        0        0        1        0        0
## 3463        0        0        0        0        0        1        0        0
## 3464        0        0        0        0        0        0        0        0
## 3465        0        0        0        0        0        0        1        0
## 3466        0        0        0        0        0        0        0        1
## 3467        0        0        0        1        0        0        0        0
## 3468        0        1        0        0        0        0        0        0
## 3469        0        0        0        0        1        0        0        0
## 3470        0        0        0        0        0        1        0        0
## 3471        0        1        0        0        0        0        0        0
## 3472        0        0        0        0        1        0        0        0
## 3473        0        0        0        0        0        0        0        1
## 3474        0        0        0        0        0        0        0        1
## 3475        0        0        0        1        0        0        0        0
## 3476        0        0        1        0        0        0        0        0
## 3477        1        0        0        0        0        0        0        0
## 3478        1        0        0        0        0        0        0        0
## 3479        0        0        0        1        0        0        0        0
## 3480        0        0        0        0        1        0        0        0
## 3481        0        1        0        0        0        0        0        0
## 3482        0        0        0        0        0        0        0        0
## 3483        0        0        0        0        0        0        1        0
## 3484        0        0        0        1        0        0        0        0
## 3485        0        0        0        0        0        0        0        0
## 3486        0        0        0        1        0        0        0        0
## 3487        0        0        0        0        0        0        0        1
## 3488        0        0        0        0        0        0        0        1
## 3489        0        0        0        0        1        0        0        0
## 3490        0        0        0        0        0        1        0        0
## 3491        0        0        0        0        0        0        0        1
## 3492        0        0        1        0        0        0        0        0
## 3493        0        1        0        0        0        0        0        0
## 3494        0        0        0        1        0        0        0        0
## 3495        0        0        0        1        0        0        0        0
## 3496        0        0        0        0        0        0        0        0
## 3497        0        1        0        0        0        0        0        0
## 3498        0        1        0        0        0        0        0        0
## 3499        0        1        0        0        0        0        0        0
## 3500        0        0        0        0        0        0        0        0
## 3501        0        0        0        1        0        0        0        0
## 3502        0        1        0        0        0        0        0        0
## 3503        1        0        0        0        0        0        0        0
## 3504        0        0        0        0        0        0        0        0
## 3505        0        0        1        0        0        0        0        0
## 3506        0        0        0        0        0        0        0        0
## 3507        0        0        0        0        0        0        0        0
## 3508        0        0        0        0        0        0        0        0
## 3509        0        0        0        1        0        0        0        0
## 3510        0        0        0        1        0        0        0        0
## 3511        0        0        0        0        0        0        0        0
## 3512        0        0        1        0        0        0        0        0
## 3513        0        0        0        0        0        0        0        0
## 3514        0        1        0        0        0        0        0        0
## 3515        0        0        0        1        0        0        0        0
## 3516        0        0        0        1        0        0        0        0
## 3517        0        0        0        0        0        0        0        0
## 3518        0        0        0        0        0        0        0        1
## 3519        0        0        0        0        1        0        0        0
## 3520        0        0        0        0        1        0        0        0
## 3521        0        0        0        0        0        0        0        0
## 3522        0        0        0        0        0        0        1        0
## 3523        0        0        0        0        0        0        0        1
## 3524        0        0        0        0        0        1        0        0
## 3525        0        0        1        0        0        0        0        0
## 3526        0        0        1        0        0        0        0        0
## 3527        0        0        0        1        0        0        0        0
## 3528        0        1        0        0        0        0        0        0
## 3529        0        0        0        0        0        0        0        0
## 3530        0        0        1        0        0        0        0        0
## 3531        0        0        0        0        0        0        1        0
## 3532        0        0        0        0        0        0        0        0
## 3533        0        1        0        0        0        0        0        0
## 3534        0        0        0        0        1        0        0        0
## 3535        0        0        0        1        0        0        0        0
## 3536        0        0        0        0        1        0        0        0
## 3537        0        0        0        0        0        0        1        0
## 3538        0        0        0        1        0        0        0        0
## 3539        0        0        0        0        0        0        0        1
## 3540        0        0        0        0        0        0        0        0
## 3541        0        1        0        0        0        0        0        0
## 3542        0        0        0        0        0        0        0        0
## 3543        0        0        0        0        0        1        0        0
## 3544        0        0        0        0        0        0        0        1
## 3545        0        0        0        0        0        0        0        1
## 3546        0        0        0        0        0        0        0        0
## 3547        0        1        0        0        0        0        0        0
## 3548        0        1        0        0        0        0        0        0
## 3549        0        0        0        0        0        0        0        1
## 3550        0        0        0        0        0        0        0        0
## 3551        0        0        0        0        0        0        1        0
## 3552        1        0        0        0        0        0        0        0
## 3553        0        0        0        0        0        0        0        0
## 3554        0        0        0        0        0        1        0        0
## 3555        0        0        0        0        0        0        0        0
## 3556        0        0        0        0        0        0        0        1
## 3557        0        0        0        0        0        0        0        1
## 3558        0        0        0        0        0        0        1        0
## 3559        0        0        1        0        0        0        0        0
## 3560        0        0        0        0        0        0        0        0
## 3561        0        0        0        1        0        0        0        0
## 3562        0        0        0        0        0        0        0        0
## 3563        0        0        0        0        0        0        0        1
## 3564        0        0        0        0        0        1        0        0
## 3565        0        0        0        1        0        0        0        0
## 3566        0        0        0        0        0        1        0        0
## 3567        0        0        0        1        0        0        0        0
## 3568        0        0        1        0        0        0        0        0
## 3569        0        1        0        0        0        0        0        0
## 3570        0        1        0        0        0        0        0        0
## 3571        0        0        0        0        0        0        0        1
## 3572        0        0        0        1        0        0        0        0
## 3573        0        0        0        0        1        0        0        0
## 3574        1        0        0        0        0        0        0        0
## 3575        0        0        0        0        0        1        0        0
## 3576        0        0        0        0        1        0        0        0
## 3577        1        0        0        0        0        0        0        0
## 3578        0        0        0        0        0        0        1        0
## 3579        0        0        0        0        0        0        0        0
## 3580        0        0        0        0        0        0        1        0
## 3581        1        0        0        0        0        0        0        0
## 3582        0        0        0        0        1        0        0        0
## 3583        0        0        0        1        0        0        0        0
## 3584        0        0        0        0        0        0        0        0
## 3585        0        0        0        0        0        0        0        1
## 3586        0        0        0        0        0        0        0        1
## 3587        0        0        0        0        0        0        1        0
## 3588        1        0        0        0        0        0        0        0
## 3589        0        0        0        0        0        0        1        0
## 3590        0        0        0        0        1        0        0        0
## 3591        0        0        0        0        0        1        0        0
## 3592        0        0        0        0        0        0        0        1
## 3593        0        1        0        0        0        0        0        0
## 3594        0        1        0        0        0        0        0        0
## 3595        0        0        0        0        0        0        0        0
## 3596        0        0        0        1        0        0        0        0
## 3597        1        0        0        0        0        0        0        0
## 3598        0        0        0        0        0        1        0        0
## 3599        0        0        0        0        0        0        1        0
## 3600        0        1        0        0        0        0        0        0
## 3601        0        0        1        0        0        0        0        0
## 3602        0        0        0        0        0        0        0        0
## 3603        0        0        0        1        0        0        0        0
## 3604        0        0        0        0        0        0        0        0
## 3605        0        0        0        1        0        0        0        0
## 3606        1        0        0        0        0        0        0        0
## 3607        0        1        0        0        0        0        0        0
## 3608        1        0        0        0        0        0        0        0
## 3609        0        0        0        0        1        0        0        0
## 3610        0        0        0        0        0        0        1        0
## 3611        0        0        0        0        0        0        1        0
## 3612        0        0        0        0        1        0        0        0
## 3613        0        0        0        1        0        0        0        0
## 3614        0        0        1        0        0        0        0        0
## 3615        0        0        0        0        0        0        0        0
## 3616        0        0        0        0        0        0        0        0
## 3617        0        1        0        0        0        0        0        0
## 3618        0        0        0        1        0        0        0        0
## 3619        0        0        0        0        0        0        0        0
## 3620        0        0        0        0        0        1        0        0
## 3621        0        0        1        0        0        0        0        0
## 3622        0        0        0        0        0        0        0        0
## 3623        0        0        0        0        0        0        0        0
## 3624        0        0        0        0        0        0        0        0
## 3625        0        0        0        0        0        0        0        1
## 3626        0        0        0        0        1        0        0        0
## 3627        0        1        0        0        0        0        0        0
## 3628        0        0        0        0        0        0        0        1
## 3629        0        0        0        0        1        0        0        0
## 3630        0        1        0        0        0        0        0        0
## 3631        0        0        0        0        0        0        0        0
## 3632        0        0        0        0        0        0        0        0
## 3633        0        0        0        0        1        0        0        0
## 3634        0        0        0        0        0        0        1        0
## 3635        0        0        0        0        0        0        0        0
## 3636        0        0        0        0        0        0        0        0
## 3637        0        0        0        1        0        0        0        0
## 3638        0        0        0        0        0        0        0        1
## 3639        0        0        0        0        0        0        0        0
## 3640        0        0        0        0        0        0        1        0
## 3641        1        0        0        0        0        0        0        0
## 3642        1        0        0        0        0        0        0        0
## 3643        0        0        1        0        0        0        0        0
## 3644        0        0        0        0        0        0        0        1
## 3645        0        0        0        0        0        0        1        0
## 3646        0        0        0        0        0        0        0        0
## 3647        0        0        0        0        1        0        0        0
## 3648        0        1        0        0        0        0        0        0
## 3649        0        1        0        0        0        0        0        0
## 3650        0        0        0        0        0        0        1        0
## 3651        0        0        0        1        0        0        0        0
## 3652        0        1        0        0        0        0        0        0
## 3653        1        0        0        0        0        0        0        0
## 3654        0        0        0        0        1        0        0        0
## 3655        1        0        0        0        0        0        0        0
## 3656        0        0        0        0        0        1        0        0
## 3657        0        0        0        0        0        1        0        0
## 3658        0        0        0        0        0        0        0        0
## 3659        0        0        0        1        0        0        0        0
## 3660        1        0        0        0        0        0        0        0
## 3661        0        0        0        0        0        0        0        1
## 3662        0        0        0        0        0        0        0        1
## 3663        0        0        0        0        0        0        0        0
## 3664        0        0        0        1        0        0        0        0
## 3665        0        0        0        0        0        1        0        0
## 3666        0        0        0        0        0        0        0        1
## 3667        0        0        0        0        0        0        1        0
## 3668        0        0        0        0        1        0        0        0
## 3669        0        0        1        0        0        0        0        0
## 3670        0        0        0        0        0        0        0        0
## 3671        0        0        0        0        1        0        0        0
## 3672        0        0        0        0        0        0        0        0
## 3673        0        0        0        0        0        0        0        0
## 3674        0        0        0        0        0        1        0        0
## 3675        0        0        0        1        0        0        0        0
## 3676        0        0        0        0        0        0        0        0
## 3677        0        0        0        0        0        0        0        0
## 3678        0        0        0        0        0        1        0        0
## 3679        0        0        0        0        0        0        0        0
## 3680        1        0        0        0        0        0        0        0
## 3681        0        0        0        0        0        0        1        0
## 3682        0        0        0        0        0        0        0        0
## 3683        0        0        1        0        0        0        0        0
## 3684        0        0        0        0        0        1        0        0
## 3685        0        0        0        0        0        1        0        0
## 3686        1        0        0        0        0        0        0        0
## 3687        0        0        0        1        0        0        0        0
## 3688        0        0        0        0        1        0        0        0
## 3689        0        0        1        0        0        0        0        0
## 3690        0        0        0        0        1        0        0        0
## 3691        0        0        0        0        0        0        0        0
## 3692        0        0        1        0        0        0        0        0
## 3693        0        0        0        0        0        0        0        0
## 3694        0        0        0        0        0        0        0        0
## 3695        0        0        0        0        0        0        0        1
## 3696        0        0        0        0        0        0        0        1
## 3697        0        1        0        0        0        0        0        0
## 3698        0        0        0        0        0        0        0        1
## 3699        0        1        0        0        0        0        0        0
## 3700        0        0        1        0        0        0        0        0
## 3701        0        1        0        0        0        0        0        0
## 3702        0        0        0        1        0        0        0        0
## 3703        0        0        0        0        1        0        0        0
##      age_&amp;gt;=_56
## 1            0
## 2            0
## 3            0
## 4            0
## 5            0
## 6            0
## 7            1
## 8            0
## 9            0
## 10           0
## 11           0
## 12           0
## 13           0
## 14           0
## 15           0
## 16           0
## 17           1
## 18           0
## 19           0
## 20           1
## 21           0
## 22           0
## 23           0
## 24           0
## 25           1
## 26           0
## 27           0
## 28           0
## 29           1
## 30           0
## 31           0
## 32           0
## 33           0
## 34           0
## 35           0
## 36           0
## 37           0
## 38           0
## 39           1
## 40           0
## 41           0
## 42           1
## 43           0
## 44           0
## 45           0
## 46           0
## 47           0
## 48           0
## 49           1
## 50           1
## 51           0
## 52           0
## 53           0
## 54           0
## 55           0
## 56           0
## 57           0
## 58           0
## 59           0
## 60           0
## 61           0
## 62           0
## 63           0
## 64           0
## 65           0
## 66           0
## 67           1
## 68           0
## 69           0
## 70           0
## 71           0
## 72           0
## 73           0
## 74           1
## 75           1
## 76           0
## 77           0
## 78           0
## 79           0
## 80           1
## 81           0
## 82           0
## 83           0
## 84           0
## 85           0
## 86           0
## 87           0
## 88           0
## 89           0
## 90           0
## 91           0
## 92           0
## 93           0
## 94           1
## 95           1
## 96           0
## 97           0
## 98           0
## 99           0
## 100          0
## 101          0
## 102          0
## 103          0
## 104          0
## 105          0
## 106          1
## 107          0
## 108          0
## 109          0
## 110          0
## 111          0
## 112          0
## 113          1
## 114          0
## 115          0
## 116          0
## 117          0
## 118          0
## 119          0
## 120          0
## 121          0
## 122          0
## 123          0
## 124          0
## 125          0
## 126          0
## 127          0
## 128          1
## 129          0
## 130          0
## 131          0
## 132          0
## 133          0
## 134          0
## 135          0
## 136          0
## 137          0
## 138          0
## 139          0
## 140          0
## 141          0
## 142          0
## 143          0
## 144          0
## 145          0
## 146          0
## 147          0
## 148          1
## 149          0
## 150          0
## 151          0
## 152          0
## 153          0
## 154          0
## 155          0
## 156          0
## 157          0
## 158          0
## 159          1
## 160          0
## 161          0
## 162          1
## 163          0
## 164          1
## 165          0
## 166          1
## 167          0
## 168          1
## 169          1
## 170          1
## 171          0
## 172          0
## 173          0
## 174          0
## 175          0
## 176          0
## 177          1
## 178          0
## 179          0
## 180          0
## 181          0
## 182          1
## 183          0
## 184          0
## 185          0
## 186          1
## 187          0
## 188          0
## 189          0
## 190          0
## 191          0
## 192          1
## 193          0
## 194          0
## 195          0
## 196          1
## 197          0
## 198          0
## 199          0
## 200          1
## 201          0
## 202          0
## 203          1
## 204          0
## 205          0
## 206          0
## 207          0
## 208          0
## 209          0
## 210          0
## 211          0
## 212          0
## 213          0
## 214          0
## 215          1
## 216          0
## 217          0
## 218          0
## 219          0
## 220          0
## 221          0
## 222          0
## 223          0
## 224          0
## 225          0
## 226          0
## 227          0
## 228          0
## 229          0
## 230          1
## 231          0
## 232          0
## 233          0
## 234          0
## 235          0
## 236          0
## 237          0
## 238          0
## 239          0
## 240          0
## 241          0
## 242          0
## 243          0
## 244          0
## 245          0
## 246          0
## 247          1
## 248          0
## 249          0
## 250          0
## 251          0
## 252          0
## 253          0
## 254          0
## 255          0
## 256          0
## 257          0
## 258          0
## 259          0
## 260          0
## 261          0
## 262          0
## 263          0
## 264          0
## 265          0
## 266          0
## 267          0
## 268          0
## 269          0
## 270          0
## 271          0
## 272          0
## 273          0
## 274          0
## 275          0
## 276          1
## 277          0
## 278          0
## 279          0
## 280          0
## 281          0
## 282          0
## 283          0
## 284          0
## 285          1
## 286          0
## 287          0
## 288          0
## 289          0
## 290          0
## 291          0
## 292          0
## 293          0
## 294          0
## 295          0
## 296          0
## 297          0
## 298          0
## 299          0
## 300          0
## 301          0
## 302          0
## 303          0
## 304          0
## 305          0
## 306          0
## 307          1
## 308          0
## 309          0
## 310          1
## 311          0
## 312          1
## 313          0
## 314          0
## 315          1
## 316          0
## 317          0
## 318          0
## 319          0
## 320          0
## 321          0
## 322          0
## 323          0
## 324          0
## 325          1
## 326          0
## 327          0
## 328          0
## 329          0
## 330          1
## 331          1
## 332          0
## 333          0
## 334          0
## 335          0
## 336          0
## 337          0
## 338          0
## 339          0
## 340          0
## 341          0
## 342          0
## 343          0
## 344          0
## 345          1
## 346          1
## 347          0
## 348          0
## 349          0
## 350          1
## 351          0
## 352          0
## 353          0
## 354          0
## 355          0
## 356          0
## 357          0
## 358          0
## 359          0
## 360          0
## 361          0
## 362          0
## 363          0
## 364          0
## 365          0
## 366          0
## 367          0
## 368          0
## 369          0
## 370          0
## 371          0
## 372          0
## 373          0
## 374          0
## 375          0
## 376          0
## 377          1
## 378          0
## 379          0
## 380          0
## 381          0
## 382          0
## 383          0
## 384          0
## 385          0
## 386          0
## 387          0
## 388          0
## 389          0
## 390          0
## 391          0
## 392          0
## 393          1
## 394          0
## 395          0
## 396          0
## 397          0
## 398          0
## 399          0
## 400          0
## 401          0
## 402          0
## 403          0
## 404          1
## 405          0
## 406          0
## 407          0
## 408          0
## 409          0
## 410          0
## 411          0
## 412          0
## 413          0
## 414          0
## 415          0
## 416          1
## 417          0
## 418          0
## 419          0
## 420          0
## 421          0
## 422          0
## 423          0
## 424          0
## 425          0
## 426          0
## 427          0
## 428          0
## 429          0
## 430          0
## 431          1
## 432          0
## 433          0
## 434          0
## 435          0
## 436          0
## 437          1
## 438          0
## 439          1
## 440          0
## 441          1
## 442          0
## 443          0
## 444          0
## 445          0
## 446          0
## 447          0
## 448          0
## 449          0
## 450          0
## 451          0
## 452          0
## 453          0
## 454          0
## 455          0
## 456          0
## 457          0
## 458          0
## 459          0
## 460          0
## 461          0
## 462          0
## 463          0
## 464          0
## 465          0
## 466          0
## 467          1
## 468          0
## 469          0
## 470          0
## 471          0
## 472          0
## 473          0
## 474          0
## 475          0
## 476          0
## 477          0
## 478          1
## 479          0
## 480          0
## 481          0
## 482          0
## 483          0
## 484          0
## 485          0
## 486          0
## 487          0
## 488          1
## 489          0
## 490          0
## 491          0
## 492          1
## 493          1
## 494          0
## 495          0
## 496          0
## 497          0
## 498          0
## 499          0
## 500          1
## 501          0
## 502          0
## 503          0
## 504          0
## 505          0
## 506          0
## 507          0
## 508          0
## 509          0
## 510          0
## 511          0
## 512          0
## 513          0
## 514          0
## 515          0
## 516          0
## 517          0
## 518          0
## 519          0
## 520          0
## 521          1
## 522          0
## 523          0
## 524          0
## 525          0
## 526          0
## 527          0
## 528          1
## 529          0
## 530          0
## 531          0
## 532          0
## 533          0
## 534          0
## 535          0
## 536          0
## 537          0
## 538          0
## 539          0
## 540          0
## 541          0
## 542          0
## 543          0
## 544          0
## 545          0
## 546          0
## 547          0
## 548          0
## 549          0
## 550          1
## 551          0
## 552          0
## 553          0
## 554          0
## 555          0
## 556          0
## 557          1
## 558          0
## 559          0
## 560          0
## 561          0
## 562          0
## 563          0
## 564          0
## 565          0
## 566          0
## 567          0
## 568          0
## 569          0
## 570          0
## 571          0
## 572          0
## 573          0
## 574          0
## 575          0
## 576          0
## 577          0
## 578          0
## 579          0
## 580          0
## 581          0
## 582          0
## 583          0
## 584          1
## 585          0
## 586          0
## 587          0
## 588          0
## 589          0
## 590          0
## 591          0
## 592          0
## 593          0
## 594          0
## 595          0
## 596          0
## 597          0
## 598          1
## 599          0
## 600          0
## 601          0
## 602          1
## 603          0
## 604          1
## 605          0
## 606          1
## 607          0
## 608          0
## 609          0
## 610          0
## 611          0
## 612          0
## 613          0
## 614          0
## 615          0
## 616          0
## 617          1
## 618          0
## 619          0
## 620          0
## 621          0
## 622          0
## 623          0
## 624          0
## 625          1
## 626          1
## 627          0
## 628          0
## 629          0
## 630          0
## 631          0
## 632          0
## 633          1
## 634          0
## 635          0
## 636          0
## 637          0
## 638          0
## 639          0
## 640          0
## 641          0
## 642          0
## 643          0
## 644          0
## 645          0
## 646          0
## 647          0
## 648          0
## 649          0
## 650          0
## 651          0
## 652          0
## 653          0
## 654          0
## 655          0
## 656          0
## 657          0
## 658          0
## 659          0
## 660          0
## 661          0
## 662          0
## 663          1
## 664          0
## 665          1
## 666          0
## 667          0
## 668          0
## 669          0
## 670          0
## 671          0
## 672          0
## 673          1
## 674          0
## 675          0
## 676          0
## 677          0
## 678          1
## 679          1
## 680          0
## 681          0
## 682          0
## 683          0
## 684          0
## 685          0
## 686          0
## 687          0
## 688          0
## 689          0
## 690          0
## 691          0
## 692          0
## 693          0
## 694          0
## 695          0
## 696          0
## 697          0
## 698          0
## 699          0
## 700          0
## 701          0
## 702          0
## 703          1
## 704          0
## 705          0
## 706          0
## 707          0
## 708          0
## 709          0
## 710          0
## 711          0
## 712          0
## 713          0
## 714          0
## 715          0
## 716          0
## 717          0
## 718          0
## 719          1
## 720          0
## 721          0
## 722          0
## 723          0
## 724          0
## 725          0
## 726          0
## 727          0
## 728          0
## 729          0
## 730          0
## 731          0
## 732          1
## 733          0
## 734          0
## 735          0
## 736          0
## 737          1
## 738          0
## 739          0
## 740          0
## 741          0
## 742          0
## 743          0
## 744          0
## 745          0
## 746          0
## 747          0
## 748          0
## 749          0
## 750          0
## 751          0
## 752          0
## 753          0
## 754          0
## 755          1
## 756          0
## 757          0
## 758          0
## 759          0
## 760          0
## 761          0
## 762          0
## 763          0
## 764          0
## 765          0
## 766          0
## 767          0
## 768          0
## 769          1
## 770          1
## 771          0
## 772          0
## 773          0
## 774          0
## 775          0
## 776          0
## 777          0
## 778          0
## 779          0
## 780          0
## 781          0
## 782          0
## 783          0
## 784          0
## 785          0
## 786          0
## 787          0
## 788          0
## 789          0
## 790          0
## 791          0
## 792          0
## 793          0
## 794          0
## 795          0
## 796          0
## 797          0
## 798          0
## 799          0
## 800          0
## 801          0
## 802          0
## 803          0
## 804          0
## 805          0
## 806          0
## 807          0
## 808          0
## 809          0
## 810          0
## 811          0
## 812          0
## 813          0
## 814          0
## 815          0
## 816          0
## 817          0
## 818          0
## 819          1
## 820          0
## 821          0
## 822          0
## 823          0
## 824          0
## 825          0
## 826          0
## 827          0
## 828          0
## 829          1
## 830          0
## 831          0
## 832          1
## 833          0
## 834          0
## 835          0
## 836          0
## 837          0
## 838          0
## 839          0
## 840          0
## 841          0
## 842          0
## 843          0
## 844          0
## 845          0
## 846          0
## 847          0
## 848          0
## 849          1
## 850          0
## 851          0
## 852          0
## 853          0
## 854          0
## 855          0
## 856          0
## 857          0
## 858          0
## 859          0
## 860          0
## 861          0
## 862          0
## 863          1
## 864          0
## 865          0
## 866          0
## 867          0
## 868          0
## 869          0
## 870          0
## 871          1
## 872          0
## 873          0
## 874          0
## 875          0
## 876          0
## 877          0
## 878          0
## 879          1
## 880          0
## 881          0
## 882          0
## 883          0
## 884          1
## 885          0
## 886          0
## 887          0
## 888          0
## 889          0
## 890          0
## 891          0
## 892          0
## 893          0
## 894          0
## 895          0
## 896          0
## 897          0
## 898          0
## 899          0
## 900          0
## 901          0
## 902          0
## 903          0
## 904          1
## 905          0
## 906          0
## 907          0
## 908          0
## 909          0
## 910          1
## 911          0
## 912          0
## 913          0
## 914          0
## 915          0
## 916          0
## 917          0
## 918          0
## 919          0
## 920          0
## 921          0
## 922          0
## 923          0
## 924          0
## 925          0
## 926          0
## 927          0
## 928          0
## 929          1
## 930          0
## 931          0
## 932          1
## 933          0
## 934          0
## 935          0
## 936          1
## 937          0
## 938          0
## 939          0
## 940          0
## 941          0
## 942          0
## 943          0
## 944          0
## 945          0
## 946          0
## 947          0
## 948          0
## 949          0
## 950          0
## 951          0
## 952          0
## 953          1
## 954          1
## 955          0
## 956          0
## 957          0
## 958          0
## 959          0
## 960          1
## 961          0
## 962          0
## 963          0
## 964          0
## 965          0
## 966          0
## 967          1
## 968          0
## 969          0
## 970          0
## 971          0
## 972          0
## 973          1
## 974          0
## 975          0
## 976          0
## 977          0
## 978          0
## 979          0
## 980          0
## 981          0
## 982          0
## 983          0
## 984          0
## 985          0
## 986          0
## 987          0
## 988          0
## 989          0
## 990          0
## 991          0
## 992          0
## 993          0
## 994          0
## 995          0
## 996          1
## 997          0
## 998          0
## 999          0
## 1000         0
## 1001         0
## 1002         1
## 1003         1
## 1004         0
## 1005         0
## 1006         0
## 1007         0
## 1008         0
## 1009         0
## 1010         0
## 1011         0
## 1012         0
## 1013         0
## 1014         0
## 1015         0
## 1016         1
## 1017         0
## 1018         0
## 1019         0
## 1020         1
## 1021         1
## 1022         0
## 1023         0
## 1024         0
## 1025         0
## 1026         0
## 1027         0
## 1028         0
## 1029         0
## 1030         0
## 1031         0
## 1032         0
## 1033         0
## 1034         0
## 1035         0
## 1036         1
## 1037         0
## 1038         0
## 1039         0
## 1040         0
## 1041         0
## 1042         0
## 1043         0
## 1044         0
## 1045         0
## 1046         0
## 1047         0
## 1048         0
## 1049         0
## 1050         0
## 1051         0
## 1052         0
## 1053         0
## 1054         0
## 1055         0
## 1056         0
## 1057         0
## 1058         0
## 1059         0
## 1060         0
## 1061         0
## 1062         0
## 1063         0
## 1064         0
## 1065         0
## 1066         0
## 1067         0
## 1068         1
## 1069         0
## 1070         0
## 1071         0
## 1072         0
## 1073         1
## 1074         0
## 1075         0
## 1076         0
## 1077         0
## 1078         1
## 1079         0
## 1080         0
## 1081         0
## 1082         0
## 1083         0
## 1084         0
## 1085         0
## 1086         0
## 1087         0
## 1088         0
## 1089         0
## 1090         0
## 1091         0
## 1092         0
## 1093         0
## 1094         1
## 1095         0
## 1096         0
## 1097         0
## 1098         0
## 1099         0
## 1100         1
## 1101         0
## 1102         0
## 1103         0
## 1104         0
## 1105         0
## 1106         1
## 1107         1
## 1108         0
## 1109         0
## 1110         1
## 1111         0
## 1112         1
## 1113         0
## 1114         0
## 1115         0
## 1116         0
## 1117         0
## 1118         0
## 1119         1
## 1120         0
## 1121         0
## 1122         0
## 1123         0
## 1124         0
## 1125         0
## 1126         0
## 1127         0
## 1128         0
## 1129         0
## 1130         0
## 1131         0
## 1132         0
## 1133         0
## 1134         0
## 1135         0
## 1136         0
## 1137         0
## 1138         0
## 1139         1
## 1140         0
## 1141         0
## 1142         0
## 1143         0
## 1144         0
## 1145         0
## 1146         0
## 1147         0
## 1148         0
## 1149         0
## 1150         1
## 1151         0
## 1152         0
## 1153         0
## 1154         0
## 1155         0
## 1156         0
## 1157         0
## 1158         0
## 1159         0
## 1160         0
## 1161         0
## 1162         0
## 1163         0
## 1164         0
## 1165         1
## 1166         0
## 1167         0
## 1168         0
## 1169         1
## 1170         0
## 1171         1
## 1172         0
## 1173         0
## 1174         0
## 1175         0
## 1176         0
## 1177         1
## 1178         1
## 1179         0
## 1180         1
## 1181         0
## 1182         0
## 1183         0
## 1184         0
## 1185         0
## 1186         0
## 1187         0
## 1188         0
## 1189         0
## 1190         0
## 1191         0
## 1192         0
## 1193         0
## 1194         0
## 1195         0
## 1196         0
## 1197         0
## 1198         0
## 1199         1
## 1200         0
## 1201         0
## 1202         0
## 1203         0
## 1204         0
## 1205         1
## 1206         0
## 1207         0
## 1208         1
## 1209         0
## 1210         0
## 1211         0
## 1212         0
## 1213         0
## 1214         0
## 1215         0
## 1216         0
## 1217         0
## 1218         0
## 1219         0
## 1220         0
## 1221         0
## 1222         0
## 1223         0
## 1224         1
## 1225         0
## 1226         0
## 1227         0
## 1228         0
## 1229         0
## 1230         0
## 1231         1
## 1232         0
## 1233         0
## 1234         0
## 1235         1
## 1236         0
## 1237         1
## 1238         0
## 1239         0
## 1240         0
## 1241         0
## 1242         0
## 1243         0
## 1244         0
## 1245         0
## 1246         0
## 1247         1
## 1248         0
## 1249         0
## 1250         1
## 1251         0
## 1252         0
## 1253         0
## 1254         0
## 1255         0
## 1256         0
## 1257         0
## 1258         0
## 1259         1
## 1260         0
## 1261         0
## 1262         0
## 1263         0
## 1264         0
## 1265         0
## 1266         0
## 1267         0
## 1268         0
## 1269         0
## 1270         0
## 1271         0
## 1272         0
## 1273         0
## 1274         0
## 1275         0
## 1276         0
## 1277         0
## 1278         0
## 1279         0
## 1280         0
## 1281         0
## 1282         1
## 1283         0
## 1284         0
## 1285         0
## 1286         0
## 1287         0
## 1288         0
## 1289         0
## 1290         0
## 1291         0
## 1292         0
## 1293         1
## 1294         0
## 1295         0
## 1296         0
## 1297         0
## 1298         0
## 1299         0
## 1300         0
## 1301         0
## 1302         0
## 1303         0
## 1304         0
## 1305         0
## 1306         0
## 1307         0
## 1308         0
## 1309         1
## 1310         0
## 1311         1
## 1312         0
## 1313         0
## 1314         0
## 1315         0
## 1316         0
## 1317         0
## 1318         0
## 1319         0
## 1320         0
## 1321         0
## 1322         0
## 1323         0
## 1324         0
## 1325         0
## 1326         0
## 1327         0
## 1328         0
## 1329         0
## 1330         0
## 1331         0
## 1332         0
## 1333         1
## 1334         0
## 1335         0
## 1336         0
## 1337         0
## 1338         0
## 1339         0
## 1340         0
## 1341         0
## 1342         0
## 1343         0
## 1344         0
## 1345         0
## 1346         0
## 1347         0
## 1348         0
## 1349         0
## 1350         0
## 1351         0
## 1352         0
## 1353         1
## 1354         0
## 1355         0
## 1356         1
## 1357         0
## 1358         0
## 1359         0
## 1360         0
## 1361         0
## 1362         1
## 1363         1
## 1364         0
## 1365         1
## 1366         0
## 1367         0
## 1368         0
## 1369         0
## 1370         0
## 1371         0
## 1372         0
## 1373         0
## 1374         0
## 1375         0
## 1376         0
## 1377         0
## 1378         0
## 1379         0
## 1380         0
## 1381         0
## 1382         0
## 1383         0
## 1384         0
## 1385         0
## 1386         1
## 1387         0
## 1388         0
## 1389         0
## 1390         0
## 1391         0
## 1392         0
## 1393         0
## 1394         1
## 1395         0
## 1396         0
## 1397         0
## 1398         0
## 1399         0
## 1400         0
## 1401         1
## 1402         0
## 1403         0
## 1404         0
## 1405         0
## 1406         0
## 1407         0
## 1408         0
## 1409         0
## 1410         0
## 1411         0
## 1412         0
## 1413         0
## 1414         0
## 1415         0
## 1416         0
## 1417         0
## 1418         1
## 1419         0
## 1420         0
## 1421         0
## 1422         0
## 1423         0
## 1424         0
## 1425         0
## 1426         0
## 1427         0
## 1428         0
## 1429         0
## 1430         0
## 1431         0
## 1432         0
## 1433         0
## 1434         0
## 1435         0
## 1436         0
## 1437         1
## 1438         0
## 1439         0
## 1440         1
## 1441         0
## 1442         0
## 1443         0
## 1444         0
## 1445         0
## 1446         0
## 1447         0
## 1448         0
## 1449         0
## 1450         0
## 1451         1
## 1452         0
## 1453         0
## 1454         0
## 1455         0
## 1456         0
## 1457         0
## 1458         1
## 1459         0
## 1460         0
## 1461         0
## 1462         0
## 1463         0
## 1464         0
## 1465         0
## 1466         0
## 1467         0
## 1468         0
## 1469         0
## 1470         0
## 1471         0
## 1472         0
## 1473         0
## 1474         0
## 1475         0
## 1476         0
## 1477         0
## 1478         0
## 1479         1
## 1480         0
## 1481         0
## 1482         0
## 1483         0
## 1484         1
## 1485         0
## 1486         0
## 1487         0
## 1488         0
## 1489         0
## 1490         0
## 1491         0
## 1492         0
## 1493         0
## 1494         0
## 1495         1
## 1496         1
## 1497         0
## 1498         0
## 1499         0
## 1500         0
## 1501         0
## 1502         0
## 1503         0
## 1504         0
## 1505         0
## 1506         0
## 1507         0
## 1508         0
## 1509         0
## 1510         1
## 1511         0
## 1512         0
## 1513         0
## 1514         0
## 1515         0
## 1516         1
## 1517         0
## 1518         0
## 1519         1
## 1520         1
## 1521         0
## 1522         1
## 1523         0
## 1524         0
## 1525         0
## 1526         0
## 1527         0
## 1528         1
## 1529         0
## 1530         0
## 1531         0
## 1532         0
## 1533         0
## 1534         0
## 1535         0
## 1536         0
## 1537         0
## 1538         0
## 1539         0
## 1540         0
## 1541         0
## 1542         0
## 1543         0
## 1544         0
## 1545         0
## 1546         0
## 1547         0
## 1548         0
## 1549         0
## 1550         0
## 1551         0
## 1552         0
## 1553         0
## 1554         0
## 1555         1
## 1556         0
## 1557         0
## 1558         0
## 1559         0
## 1560         0
## 1561         0
## 1562         0
## 1563         0
## 1564         0
## 1565         0
## 1566         0
## 1567         0
## 1568         1
## 1569         0
## 1570         0
## 1571         0
## 1572         0
## 1573         0
## 1574         0
## 1575         0
## 1576         0
## 1577         0
## 1578         0
## 1579         0
## 1580         0
## 1581         0
## 1582         0
## 1583         0
## 1584         0
## 1585         0
## 1586         1
## 1587         0
## 1588         0
## 1589         0
## 1590         0
## 1591         0
## 1592         0
## 1593         0
## 1594         0
## 1595         0
## 1596         0
## 1597         0
## 1598         1
## 1599         0
## 1600         0
## 1601         0
## 1602         0
## 1603         0
## 1604         0
## 1605         0
## 1606         0
## 1607         0
## 1608         1
## 1609         0
## 1610         0
## 1611         0
## 1612         0
## 1613         0
## 1614         0
## 1615         0
## 1616         0
## 1617         0
## 1618         0
## 1619         0
## 1620         0
## 1621         0
## 1622         0
## 1623         0
## 1624         0
## 1625         1
## 1626         0
## 1627         0
## 1628         0
## 1629         0
## 1630         0
## 1631         0
## 1632         0
## 1633         1
## 1634         0
## 1635         0
## 1636         0
## 1637         0
## 1638         0
## 1639         0
## 1640         0
## 1641         0
## 1642         0
## 1643         0
## 1644         0
## 1645         0
## 1646         0
## 1647         0
## 1648         0
## 1649         0
## 1650         0
## 1651         0
## 1652         0
## 1653         0
## 1654         0
## 1655         0
## 1656         0
## 1657         0
## 1658         0
## 1659         0
## 1660         0
## 1661         0
## 1662         0
## 1663         0
## 1664         0
## 1665         0
## 1666         0
## 1667         0
## 1668         0
## 1669         0
## 1670         1
## 1671         1
## 1672         0
## 1673         0
## 1674         0
## 1675         0
## 1676         0
## 1677         0
## 1678         0
## 1679         0
## 1680         0
## 1681         0
## 1682         0
## 1683         0
## 1684         0
## 1685         0
## 1686         0
## 1687         0
## 1688         0
## 1689         0
## 1690         0
## 1691         0
## 1692         0
## 1693         0
## 1694         0
## 1695         0
## 1696         0
## 1697         0
## 1698         0
## 1699         0
## 1700         0
## 1701         0
## 1702         0
## 1703         0
## 1704         0
## 1705         0
## 1706         0
## 1707         0
## 1708         0
## 1709         1
## 1710         0
## 1711         0
## 1712         0
## 1713         0
## 1714         0
## 1715         0
## 1716         0
## 1717         0
## 1718         0
## 1719         0
## 1720         0
## 1721         0
## 1722         0
## 1723         0
## 1724         0
## 1725         0
## 1726         0
## 1727         0
## 1728         0
## 1729         0
## 1730         0
## 1731         0
## 1732         0
## 1733         0
## 1734         0
## 1735         1
## 1736         0
## 1737         0
## 1738         0
## 1739         0
## 1740         0
## 1741         0
## 1742         0
## 1743         0
## 1744         0
## 1745         0
## 1746         0
## 1747         0
## 1748         0
## 1749         0
## 1750         0
## 1751         0
## 1752         0
## 1753         0
## 1754         0
## 1755         0
## 1756         0
## 1757         0
## 1758         0
## 1759         0
## 1760         0
## 1761         0
## 1762         0
## 1763         0
## 1764         0
## 1765         0
## 1766         0
## 1767         0
## 1768         0
## 1769         0
## 1770         0
## 1771         1
## 1772         0
## 1773         0
## 1774         0
## 1775         0
## 1776         0
## 1777         0
## 1778         0
## 1779         0
## 1780         0
## 1781         0
## 1782         0
## 1783         0
## 1784         0
## 1785         1
## 1786         1
## 1787         1
## 1788         0
## 1789         1
## 1790         1
## 1791         0
## 1792         0
## 1793         0
## 1794         0
## 1795         1
## 1796         0
## 1797         0
## 1798         0
## 1799         0
## 1800         0
## 1801         0
## 1802         0
## 1803         0
## 1804         0
## 1805         0
## 1806         0
## 1807         0
## 1808         0
## 1809         0
## 1810         1
## 1811         0
## 1812         0
## 1813         0
## 1814         0
## 1815         0
## 1816         0
## 1817         0
## 1818         0
## 1819         0
## 1820         0
## 1821         0
## 1822         0
## 1823         0
## 1824         1
## 1825         0
## 1826         0
## 1827         0
## 1828         0
## 1829         0
## 1830         0
## 1831         0
## 1832         0
## 1833         1
## 1834         0
## 1835         0
## 1836         0
## 1837         0
## 1838         1
## 1839         0
## 1840         0
## 1841         0
## 1842         0
## 1843         0
## 1844         0
## 1845         0
## 1846         0
## 1847         0
## 1848         0
## 1849         0
## 1850         0
## 1851         1
## 1852         1
## 1853         0
## 1854         0
## 1855         0
## 1856         0
## 1857         0
## 1858         0
## 1859         0
## 1860         0
## 1861         0
## 1862         0
## 1863         0
## 1864         0
## 1865         0
## 1866         0
## 1867         0
## 1868         0
## 1869         0
## 1870         1
## 1871         0
## 1872         1
## 1873         0
## 1874         0
## 1875         1
## 1876         0
## 1877         0
## 1878         0
## 1879         1
## 1880         0
## 1881         0
## 1882         0
## 1883         1
## 1884         0
## 1885         0
## 1886         0
## 1887         0
## 1888         0
## 1889         0
## 1890         0
## 1891         0
## 1892         0
## 1893         1
## 1894         0
## 1895         0
## 1896         0
## 1897         0
## 1898         0
## 1899         0
## 1900         1
## 1901         0
## 1902         0
## 1903         0
## 1904         0
## 1905         0
## 1906         0
## 1907         0
## 1908         0
## 1909         0
## 1910         0
## 1911         0
## 1912         0
## 1913         0
## 1914         0
## 1915         0
## 1916         0
## 1917         0
## 1918         0
## 1919         0
## 1920         0
## 1921         0
## 1922         0
## 1923         0
## 1924         0
## 1925         0
## 1926         0
## 1927         0
## 1928         0
## 1929         0
## 1930         0
## 1931         0
## 1932         0
## 1933         0
## 1934         0
## 1935         0
## 1936         0
## 1937         0
## 1938         0
## 1939         0
## 1940         0
## 1941         0
## 1942         0
## 1943         0
## 1944         0
## 1945         0
## 1946         1
## 1947         0
## 1948         0
## 1949         0
## 1950         0
## 1951         0
## 1952         0
## 1953         0
## 1954         0
## 1955         0
## 1956         0
## 1957         0
## 1958         0
## 1959         0
## 1960         1
## 1961         0
## 1962         0
## 1963         0
## 1964         0
## 1965         0
## 1966         0
## 1967         0
## 1968         0
## 1969         0
## 1970         0
## 1971         0
## 1972         0
## 1973         0
## 1974         0
## 1975         1
## 1976         0
## 1977         0
## 1978         0
## 1979         0
## 1980         0
## 1981         0
## 1982         0
## 1983         0
## 1984         0
## 1985         1
## 1986         0
## 1987         0
## 1988         0
## 1989         0
## 1990         0
## 1991         1
## 1992         0
## 1993         0
## 1994         0
## 1995         0
## 1996         0
## 1997         1
## 1998         0
## 1999         0
## 2000         0
## 2001         0
## 2002         0
## 2003         0
## 2004         0
## 2005         0
## 2006         0
## 2007         0
## 2008         0
## 2009         0
## 2010         0
## 2011         0
## 2012         1
## 2013         0
## 2014         0
## 2015         0
## 2016         0
## 2017         0
## 2018         0
## 2019         0
## 2020         0
## 2021         0
## 2022         0
## 2023         0
## 2024         0
## 2025         0
## 2026         0
## 2027         0
## 2028         0
## 2029         0
## 2030         0
## 2031         0
## 2032         0
## 2033         0
## 2034         0
## 2035         1
## 2036         0
## 2037         0
## 2038         1
## 2039         0
## 2040         0
## 2041         0
## 2042         0
## 2043         0
## 2044         0
## 2045         0
## 2046         0
## 2047         0
## 2048         0
## 2049         1
## 2050         0
## 2051         0
## 2052         0
## 2053         0
## 2054         1
## 2055         0
## 2056         0
## 2057         0
## 2058         0
## 2059         0
## 2060         0
## 2061         0
## 2062         0
## 2063         0
## 2064         0
## 2065         1
## 2066         0
## 2067         0
## 2068         0
## 2069         0
## 2070         1
## 2071         0
## 2072         0
## 2073         0
## 2074         0
## 2075         0
## 2076         0
## 2077         0
## 2078         1
## 2079         0
## 2080         0
## 2081         0
## 2082         0
## 2083         0
## 2084         0
## 2085         0
## 2086         0
## 2087         0
## 2088         0
## 2089         0
## 2090         0
## 2091         0
## 2092         0
## 2093         0
## 2094         1
## 2095         0
## 2096         0
## 2097         0
## 2098         0
## 2099         0
## 2100         0
## 2101         0
## 2102         0
## 2103         1
## 2104         0
## 2105         0
## 2106         0
## 2107         0
## 2108         0
## 2109         1
## 2110         0
## 2111         0
## 2112         0
## 2113         0
## 2114         0
## 2115         1
## 2116         1
## 2117         0
## 2118         1
## 2119         0
## 2120         0
## 2121         0
## 2122         1
## 2123         0
## 2124         0
## 2125         0
## 2126         1
## 2127         0
## 2128         0
## 2129         0
## 2130         0
## 2131         0
## 2132         0
## 2133         1
## 2134         0
## 2135         0
## 2136         0
## 2137         0
## 2138         0
## 2139         0
## 2140         0
## 2141         0
## 2142         0
## 2143         0
## 2144         0
## 2145         0
## 2146         0
## 2147         0
## 2148         0
## 2149         0
## 2150         0
## 2151         0
## 2152         0
## 2153         1
## 2154         0
## 2155         0
## 2156         1
## 2157         0
## 2158         0
## 2159         0
## 2160         1
## 2161         0
## 2162         0
## 2163         0
## 2164         0
## 2165         0
## 2166         0
## 2167         0
## 2168         0
## 2169         0
## 2170         0
## 2171         0
## 2172         0
## 2173         0
## 2174         0
## 2175         0
## 2176         1
## 2177         0
## 2178         0
## 2179         0
## 2180         1
## 2181         0
## 2182         0
## 2183         0
## 2184         0
## 2185         1
## 2186         0
## 2187         0
## 2188         0
## 2189         0
## 2190         0
## 2191         0
## 2192         0
## 2193         0
## 2194         1
## 2195         0
## 2196         0
## 2197         0
## 2198         0
## 2199         0
## 2200         0
## 2201         1
## 2202         0
## 2203         0
## 2204         0
## 2205         0
## 2206         0
## 2207         0
## 2208         0
## 2209         0
## 2210         0
## 2211         0
## 2212         0
## 2213         0
## 2214         0
## 2215         0
## 2216         0
## 2217         0
## 2218         0
## 2219         0
## 2220         0
## 2221         0
## 2222         0
## 2223         0
## 2224         0
## 2225         0
## 2226         0
## 2227         0
## 2228         0
## 2229         0
## 2230         1
## 2231         1
## 2232         0
## 2233         1
## 2234         0
## 2235         0
## 2236         1
## 2237         0
## 2238         0
## 2239         0
## 2240         0
## 2241         0
## 2242         0
## 2243         0
## 2244         0
## 2245         1
## 2246         0
## 2247         0
## 2248         0
## 2249         0
## 2250         0
## 2251         0
## 2252         0
## 2253         0
## 2254         0
## 2255         0
## 2256         0
## 2257         0
## 2258         0
## 2259         0
## 2260         0
## 2261         0
## 2262         0
## 2263         1
## 2264         0
## 2265         0
## 2266         0
## 2267         0
## 2268         0
## 2269         0
## 2270         1
## 2271         0
## 2272         0
## 2273         0
## 2274         0
## 2275         1
## 2276         0
## 2277         1
## 2278         0
## 2279         0
## 2280         0
## 2281         0
## 2282         0
## 2283         0
## 2284         0
## 2285         0
## 2286         0
## 2287         0
## 2288         0
## 2289         0
## 2290         0
## 2291         0
## 2292         0
## 2293         0
## 2294         1
## 2295         0
## 2296         0
## 2297         0
## 2298         1
## 2299         1
## 2300         0
## 2301         0
## 2302         0
## 2303         0
## 2304         0
## 2305         0
## 2306         0
## 2307         0
## 2308         0
## 2309         0
## 2310         0
## 2311         0
## 2312         0
## 2313         0
## 2314         0
## 2315         0
## 2316         0
## 2317         0
## 2318         0
## 2319         0
## 2320         0
## 2321         0
## 2322         0
## 2323         0
## 2324         1
## 2325         0
## 2326         0
## 2327         0
## 2328         0
## 2329         0
## 2330         0
## 2331         0
## 2332         0
## 2333         0
## 2334         0
## 2335         0
## 2336         0
## 2337         0
## 2338         0
## 2339         0
## 2340         0
## 2341         0
## 2342         0
## 2343         0
## 2344         0
## 2345         0
## 2346         0
## 2347         0
## 2348         0
## 2349         1
## 2350         0
## 2351         0
## 2352         0
## 2353         0
## 2354         0
## 2355         0
## 2356         0
## 2357         0
## 2358         1
## 2359         0
## 2360         0
## 2361         0
## 2362         0
## 2363         0
## 2364         0
## 2365         0
## 2366         0
## 2367         0
## 2368         0
## 2369         0
## 2370         0
## 2371         0
## 2372         0
## 2373         0
## 2374         0
## 2375         1
## 2376         0
## 2377         0
## 2378         0
## 2379         0
## 2380         0
## 2381         0
## 2382         0
## 2383         0
## 2384         0
## 2385         0
## 2386         0
## 2387         0
## 2388         0
## 2389         0
## 2390         1
## 2391         0
## 2392         0
## 2393         0
## 2394         0
## 2395         0
## 2396         0
## 2397         0
## 2398         0
## 2399         0
## 2400         0
## 2401         0
## 2402         0
## 2403         0
## 2404         0
## 2405         0
## 2406         0
## 2407         0
## 2408         0
## 2409         0
## 2410         0
## 2411         0
## 2412         0
## 2413         0
## 2414         0
## 2415         0
## 2416         0
## 2417         0
## 2418         0
## 2419         0
## 2420         1
## 2421         0
## 2422         0
## 2423         1
## 2424         0
## 2425         0
## 2426         0
## 2427         0
## 2428         0
## 2429         0
## 2430         0
## 2431         0
## 2432         0
## 2433         1
## 2434         0
## 2435         0
## 2436         1
## 2437         0
## 2438         0
## 2439         0
## 2440         0
## 2441         0
## 2442         0
## 2443         0
## 2444         0
## 2445         0
## 2446         0
## 2447         0
## 2448         0
## 2449         0
## 2450         0
## 2451         0
## 2452         0
## 2453         0
## 2454         0
## 2455         0
## 2456         0
## 2457         0
## 2458         0
## 2459         0
## 2460         1
## 2461         0
## 2462         0
## 2463         0
## 2464         1
## 2465         0
## 2466         0
## 2467         0
## 2468         0
## 2469         0
## 2470         0
## 2471         0
## 2472         0
## 2473         0
## 2474         0
## 2475         0
## 2476         0
## 2477         0
## 2478         0
## 2479         1
## 2480         0
## 2481         1
## 2482         0
## 2483         1
## 2484         0
## 2485         0
## 2486         0
## 2487         0
## 2488         0
## 2489         0
## 2490         0
## 2491         0
## 2492         1
## 2493         0
## 2494         0
## 2495         1
## 2496         0
## 2497         0
## 2498         0
## 2499         0
## 2500         0
## 2501         1
## 2502         0
## 2503         0
## 2504         0
## 2505         0
## 2506         0
## 2507         0
## 2508         0
## 2509         0
## 2510         0
## 2511         0
## 2512         0
## 2513         0
## 2514         0
## 2515         0
## 2516         0
## 2517         0
## 2518         0
## 2519         0
## 2520         0
## 2521         0
## 2522         0
## 2523         1
## 2524         0
## 2525         0
## 2526         1
## 2527         1
## 2528         0
## 2529         0
## 2530         0
## 2531         0
## 2532         0
## 2533         0
## 2534         0
## 2535         0
## 2536         0
## 2537         0
## 2538         0
## 2539         0
## 2540         0
## 2541         0
## 2542         0
## 2543         0
## 2544         0
## 2545         1
## 2546         1
## 2547         1
## 2548         1
## 2549         0
## 2550         0
## 2551         0
## 2552         1
## 2553         0
## 2554         1
## 2555         0
## 2556         0
## 2557         0
## 2558         0
## 2559         0
## 2560         0
## 2561         0
## 2562         0
## 2563         0
## 2564         0
## 2565         1
## 2566         0
## 2567         0
## 2568         0
## 2569         0
## 2570         0
## 2571         0
## 2572         0
## 2573         0
## 2574         1
## 2575         0
## 2576         0
## 2577         0
## 2578         1
## 2579         0
## 2580         0
## 2581         1
## 2582         0
## 2583         0
## 2584         0
## 2585         0
## 2586         0
## 2587         0
## 2588         0
## 2589         0
## 2590         0
## 2591         0
## 2592         0
## 2593         0
## 2594         0
## 2595         0
## 2596         0
## 2597         0
## 2598         1
## 2599         0
## 2600         0
## 2601         0
## 2602         0
## 2603         0
## 2604         0
## 2605         0
## 2606         1
## 2607         0
## 2608         0
## 2609         0
## 2610         0
## 2611         0
## 2612         1
## 2613         0
## 2614         0
## 2615         0
## 2616         1
## 2617         0
## 2618         0
## 2619         0
## 2620         0
## 2621         0
## 2622         0
## 2623         0
## 2624         0
## 2625         0
## 2626         0
## 2627         1
## 2628         1
## 2629         0
## 2630         1
## 2631         0
## 2632         0
## 2633         0
## 2634         0
## 2635         0
## 2636         0
## 2637         0
## 2638         0
## 2639         1
## 2640         0
## 2641         0
## 2642         0
## 2643         0
## 2644         0
## 2645         0
## 2646         0
## 2647         0
## 2648         0
## 2649         0
## 2650         0
## 2651         0
## 2652         0
## 2653         0
## 2654         0
## 2655         0
## 2656         0
## 2657         0
## 2658         0
## 2659         0
## 2660         0
## 2661         0
## 2662         0
## 2663         0
## 2664         0
## 2665         0
## 2666         0
## 2667         0
## 2668         0
## 2669         0
## 2670         0
## 2671         0
## 2672         0
## 2673         0
## 2674         0
## 2675         1
## 2676         0
## 2677         0
## 2678         0
## 2679         0
## 2680         0
## 2681         0
## 2682         0
## 2683         1
## 2684         0
## 2685         0
## 2686         0
## 2687         0
## 2688         0
## 2689         0
## 2690         0
## 2691         0
## 2692         0
## 2693         0
## 2694         0
## 2695         0
## 2696         0
## 2697         0
## 2698         0
## 2699         0
## 2700         0
## 2701         0
## 2702         0
## 2703         0
## 2704         1
## 2705         0
## 2706         1
## 2707         0
## 2708         1
## 2709         0
## 2710         1
## 2711         0
## 2712         0
## 2713         0
## 2714         0
## 2715         1
## 2716         0
## 2717         0
## 2718         0
## 2719         0
## 2720         0
## 2721         0
## 2722         0
## 2723         0
## 2724         0
## 2725         0
## 2726         0
## 2727         0
## 2728         0
## 2729         0
## 2730         0
## 2731         0
## 2732         0
## 2733         0
## 2734         0
## 2735         0
## 2736         0
## 2737         0
## 2738         0
## 2739         0
## 2740         0
## 2741         0
## 2742         0
## 2743         0
## 2744         1
## 2745         0
## 2746         0
## 2747         0
## 2748         1
## 2749         0
## 2750         0
## 2751         1
## 2752         0
## 2753         0
## 2754         0
## 2755         0
## 2756         0
## 2757         1
## 2758         0
## 2759         0
## 2760         0
## 2761         0
## 2762         1
## 2763         0
## 2764         0
## 2765         0
## 2766         1
## 2767         0
## 2768         1
## 2769         0
## 2770         0
## 2771         0
## 2772         1
## 2773         0
## 2774         0
## 2775         0
## 2776         1
## 2777         0
## 2778         0
## 2779         0
## 2780         0
## 2781         0
## 2782         0
## 2783         0
## 2784         0
## 2785         0
## 2786         0
## 2787         0
## 2788         0
## 2789         0
## 2790         0
## 2791         1
## 2792         0
## 2793         0
## 2794         0
## 2795         0
## 2796         0
## 2797         0
## 2798         0
## 2799         0
## 2800         0
## 2801         0
## 2802         1
## 2803         0
## 2804         0
## 2805         0
## 2806         0
## 2807         0
## 2808         0
## 2809         0
## 2810         0
## 2811         0
## 2812         0
## 2813         0
## 2814         1
## 2815         0
## 2816         0
## 2817         0
## 2818         0
## 2819         0
## 2820         0
## 2821         0
## 2822         0
## 2823         0
## 2824         0
## 2825         0
## 2826         0
## 2827         0
## 2828         0
## 2829         0
## 2830         1
## 2831         0
## 2832         0
## 2833         1
## 2834         0
## 2835         0
## 2836         0
## 2837         0
## 2838         0
## 2839         0
## 2840         0
## 2841         0
## 2842         0
## 2843         0
## 2844         0
## 2845         0
## 2846         0
## 2847         0
## 2848         0
## 2849         1
## 2850         0
## 2851         0
## 2852         0
## 2853         0
## 2854         0
## 2855         0
## 2856         0
## 2857         0
## 2858         0
## 2859         0
## 2860         0
## 2861         0
## 2862         0
## 2863         0
## 2864         0
## 2865         0
## 2866         0
## 2867         0
## 2868         0
## 2869         0
## 2870         0
## 2871         0
## 2872         0
## 2873         0
## 2874         0
## 2875         0
## 2876         0
## 2877         0
## 2878         0
## 2879         0
## 2880         0
## 2881         0
## 2882         0
## 2883         0
## 2884         0
## 2885         0
## 2886         0
## 2887         0
## 2888         0
## 2889         0
## 2890         0
## 2891         0
## 2892         0
## 2893         0
## 2894         0
## 2895         0
## 2896         0
## 2897         0
## 2898         0
## 2899         0
## 2900         0
## 2901         0
## 2902         0
## 2903         0
## 2904         0
## 2905         0
## 2906         0
## 2907         0
## 2908         0
## 2909         0
## 2910         0
## 2911         0
## 2912         0
## 2913         0
## 2914         0
## 2915         0
## 2916         0
## 2917         0
## 2918         1
## 2919         1
## 2920         0
## 2921         0
## 2922         0
## 2923         0
## 2924         0
## 2925         0
## 2926         0
## 2927         0
## 2928         0
## 2929         0
## 2930         0
## 2931         0
## 2932         0
## 2933         0
## 2934         0
## 2935         0
## 2936         0
## 2937         0
## 2938         0
## 2939         0
## 2940         0
## 2941         0
## 2942         0
## 2943         0
## 2944         0
## 2945         0
## 2946         1
## 2947         0
## 2948         0
## 2949         0
## 2950         0
## 2951         0
## 2952         0
## 2953         0
## 2954         0
## 2955         0
## 2956         0
## 2957         0
## 2958         0
## 2959         0
## 2960         0
## 2961         0
## 2962         1
## 2963         0
## 2964         0
## 2965         0
## 2966         0
## 2967         0
## 2968         0
## 2969         0
## 2970         0
## 2971         0
## 2972         0
## 2973         0
## 2974         0
## 2975         1
## 2976         0
## 2977         0
## 2978         0
## 2979         1
## 2980         0
## 2981         1
## 2982         0
## 2983         0
## 2984         0
## 2985         0
## 2986         0
## 2987         1
## 2988         0
## 2989         0
## 2990         0
## 2991         0
## 2992         0
## 2993         1
## 2994         0
## 2995         0
## 2996         0
## 2997         0
## 2998         0
## 2999         0
## 3000         0
## 3001         0
## 3002         0
## 3003         0
## 3004         0
## 3005         0
## 3006         0
## 3007         0
## 3008         0
## 3009         1
## 3010         0
## 3011         0
## 3012         0
## 3013         0
## 3014         0
## 3015         0
## 3016         0
## 3017         1
## 3018         0
## 3019         0
## 3020         0
## 3021         0
## 3022         0
## 3023         0
## 3024         0
## 3025         0
## 3026         0
## 3027         0
## 3028         0
## 3029         0
## 3030         1
## 3031         0
## 3032         0
## 3033         0
## 3034         1
## 3035         0
## 3036         0
## 3037         0
## 3038         0
## 3039         0
## 3040         0
## 3041         0
## 3042         0
## 3043         0
## 3044         0
## 3045         0
## 3046         0
## 3047         1
## 3048         0
## 3049         0
## 3050         0
## 3051         0
## 3052         0
## 3053         0
## 3054         1
## 3055         0
## 3056         0
## 3057         0
## 3058         0
## 3059         0
## 3060         0
## 3061         0
## 3062         0
## 3063         0
## 3064         0
## 3065         1
## 3066         1
## 3067         0
## 3068         0
## 3069         1
## 3070         0
## 3071         1
## 3072         0
## 3073         0
## 3074         0
## 3075         0
## 3076         0
## 3077         0
## 3078         0
## 3079         0
## 3080         0
## 3081         0
## 3082         0
## 3083         0
## 3084         0
## 3085         0
## 3086         0
## 3087         0
## 3088         0
## 3089         0
## 3090         0
## 3091         0
## 3092         0
## 3093         0
## 3094         0
## 3095         0
## 3096         0
## 3097         0
## 3098         0
## 3099         0
## 3100         0
## 3101         0
## 3102         1
## 3103         0
## 3104         0
## 3105         0
## 3106         0
## 3107         0
## 3108         0
## 3109         0
## 3110         0
## 3111         0
## 3112         0
## 3113         0
## 3114         1
## 3115         0
## 3116         0
## 3117         1
## 3118         0
## 3119         0
## 3120         0
## 3121         1
## 3122         0
## 3123         0
## 3124         0
## 3125         0
## 3126         0
## 3127         0
## 3128         0
## 3129         0
## 3130         1
## 3131         0
## 3132         0
## 3133         0
## 3134         0
## 3135         0
## 3136         1
## 3137         1
## 3138         0
## 3139         0
## 3140         0
## 3141         1
## 3142         0
## 3143         0
## 3144         1
## 3145         0
## 3146         0
## 3147         0
## 3148         0
## 3149         0
## 3150         0
## 3151         0
## 3152         0
## 3153         0
## 3154         0
## 3155         0
## 3156         0
## 3157         0
## 3158         0
## 3159         0
## 3160         1
## 3161         0
## 3162         0
## 3163         0
## 3164         0
## 3165         0
## 3166         0
## 3167         0
## 3168         0
## 3169         0
## 3170         0
## 3171         0
## 3172         0
## 3173         0
## 3174         0
## 3175         0
## 3176         0
## 3177         0
## 3178         0
## 3179         0
## 3180         0
## 3181         0
## 3182         0
## 3183         0
## 3184         0
## 3185         0
## 3186         0
## 3187         0
## 3188         0
## 3189         0
## 3190         0
## 3191         0
## 3192         0
## 3193         0
## 3194         0
## 3195         0
## 3196         0
## 3197         0
## 3198         1
## 3199         1
## 3200         0
## 3201         0
## 3202         0
## 3203         0
## 3204         0
## 3205         0
## 3206         0
## 3207         0
## 3208         0
## 3209         1
## 3210         0
## 3211         0
## 3212         0
## 3213         0
## 3214         0
## 3215         0
## 3216         1
## 3217         0
## 3218         1
## 3219         0
## 3220         0
## 3221         0
## 3222         0
## 3223         0
## 3224         1
## 3225         0
## 3226         1
## 3227         0
## 3228         0
## 3229         0
## 3230         0
## 3231         0
## 3232         0
## 3233         0
## 3234         0
## 3235         0
## 3236         0
## 3237         0
## 3238         0
## 3239         0
## 3240         0
## 3241         0
## 3242         0
## 3243         0
## 3244         0
## 3245         0
## 3246         0
## 3247         0
## 3248         0
## 3249         0
## 3250         0
## 3251         0
## 3252         0
## 3253         0
## 3254         0
## 3255         0
## 3256         0
## 3257         0
## 3258         1
## 3259         1
## 3260         0
## 3261         0
## 3262         0
## 3263         0
## 3264         0
## 3265         0
## 3266         0
## 3267         0
## 3268         0
## 3269         0
## 3270         0
## 3271         0
## 3272         0
## 3273         0
## 3274         1
## 3275         0
## 3276         0
## 3277         0
## 3278         0
## 3279         0
## 3280         0
## 3281         0
## 3282         0
## 3283         0
## 3284         1
## 3285         0
## 3286         0
## 3287         1
## 3288         0
## 3289         0
## 3290         0
## 3291         0
## 3292         0
## 3293         0
## 3294         1
## 3295         1
## 3296         0
## 3297         1
## 3298         0
## 3299         0
## 3300         0
## 3301         0
## 3302         0
## 3303         0
## 3304         0
## 3305         0
## 3306         1
## 3307         0
## 3308         0
## 3309         0
## 3310         0
## 3311         0
## 3312         0
## 3313         0
## 3314         0
## 3315         0
## 3316         0
## 3317         0
## 3318         0
## 3319         1
## 3320         1
## 3321         0
## 3322         0
## 3323         0
## 3324         0
## 3325         0
## 3326         0
## 3327         0
## 3328         0
## 3329         0
## 3330         0
## 3331         0
## 3332         0
## 3333         0
## 3334         0
## 3335         1
## 3336         0
## 3337         0
## 3338         0
## 3339         0
## 3340         0
## 3341         0
## 3342         1
## 3343         0
## 3344         0
## 3345         0
## 3346         0
## 3347         0
## 3348         0
## 3349         0
## 3350         0
## 3351         0
## 3352         0
## 3353         1
## 3354         0
## 3355         0
## 3356         0
## 3357         0
## 3358         1
## 3359         0
## 3360         1
## 3361         1
## 3362         0
## 3363         0
## 3364         0
## 3365         0
## 3366         0
## 3367         0
## 3368         0
## 3369         1
## 3370         0
## 3371         0
## 3372         0
## 3373         0
## 3374         0
## 3375         0
## 3376         0
## 3377         0
## 3378         0
## 3379         0
## 3380         0
## 3381         0
## 3382         0
## 3383         0
## 3384         0
## 3385         1
## 3386         0
## 3387         0
## 3388         0
## 3389         0
## 3390         0
## 3391         0
## 3392         0
## 3393         1
## 3394         1
## 3395         0
## 3396         0
## 3397         0
## 3398         0
## 3399         0
## 3400         0
## 3401         1
## 3402         0
## 3403         0
## 3404         0
## 3405         0
## 3406         1
## 3407         1
## 3408         0
## 3409         0
## 3410         0
## 3411         0
## 3412         0
## 3413         0
## 3414         0
## 3415         0
## 3416         0
## 3417         0
## 3418         0
## 3419         1
## 3420         0
## 3421         0
## 3422         0
## 3423         0
## 3424         0
## 3425         0
## 3426         0
## 3427         0
## 3428         0
## 3429         0
## 3430         0
## 3431         0
## 3432         0
## 3433         0
## 3434         0
## 3435         0
## 3436         0
## 3437         0
## 3438         0
## 3439         0
## 3440         0
## 3441         0
## 3442         0
## 3443         0
## 3444         1
## 3445         0
## 3446         0
## 3447         0
## 3448         0
## 3449         0
## 3450         0
## 3451         0
## 3452         0
## 3453         0
## 3454         0
## 3455         1
## 3456         0
## 3457         0
## 3458         0
## 3459         0
## 3460         0
## 3461         0
## 3462         0
## 3463         0
## 3464         0
## 3465         0
## 3466         0
## 3467         0
## 3468         0
## 3469         0
## 3470         0
## 3471         0
## 3472         0
## 3473         0
## 3474         0
## 3475         0
## 3476         0
## 3477         0
## 3478         0
## 3479         0
## 3480         0
## 3481         0
## 3482         0
## 3483         0
## 3484         0
## 3485         1
## 3486         0
## 3487         0
## 3488         0
## 3489         0
## 3490         0
## 3491         0
## 3492         0
## 3493         0
## 3494         0
## 3495         0
## 3496         1
## 3497         0
## 3498         0
## 3499         0
## 3500         1
## 3501         0
## 3502         0
## 3503         0
## 3504         1
## 3505         0
## 3506         1
## 3507         1
## 3508         1
## 3509         0
## 3510         0
## 3511         1
## 3512         0
## 3513         0
## 3514         0
## 3515         0
## 3516         0
## 3517         1
## 3518         0
## 3519         0
## 3520         0
## 3521         0
## 3522         0
## 3523         0
## 3524         0
## 3525         0
## 3526         0
## 3527         0
## 3528         0
## 3529         0
## 3530         0
## 3531         0
## 3532         1
## 3533         0
## 3534         0
## 3535         0
## 3536         0
## 3537         0
## 3538         0
## 3539         0
## 3540         1
## 3541         0
## 3542         0
## 3543         0
## 3544         0
## 3545         0
## 3546         1
## 3547         0
## 3548         0
## 3549         0
## 3550         0
## 3551         0
## 3552         0
## 3553         1
## 3554         0
## 3555         0
## 3556         0
## 3557         0
## 3558         0
## 3559         0
## 3560         1
## 3561         0
## 3562         1
## 3563         0
## 3564         0
## 3565         0
## 3566         0
## 3567         0
## 3568         0
## 3569         0
## 3570         0
## 3571         0
## 3572         0
## 3573         0
## 3574         0
## 3575         0
## 3576         0
## 3577         0
## 3578         0
## 3579         0
## 3580         0
## 3581         0
## 3582         0
## 3583         0
## 3584         1
## 3585         0
## 3586         0
## 3587         0
## 3588         0
## 3589         0
## 3590         0
## 3591         0
## 3592         0
## 3593         0
## 3594         0
## 3595         0
## 3596         0
## 3597         0
## 3598         0
## 3599         0
## 3600         0
## 3601         0
## 3602         1
## 3603         0
## 3604         1
## 3605         0
## 3606         0
## 3607         0
## 3608         0
## 3609         0
## 3610         0
## 3611         0
## 3612         0
## 3613         0
## 3614         0
## 3615         1
## 3616         0
## 3617         0
## 3618         0
## 3619         0
## 3620         0
## 3621         0
## 3622         0
## 3623         1
## 3624         0
## 3625         0
## 3626         0
## 3627         0
## 3628         0
## 3629         0
## 3630         0
## 3631         0
## 3632         1
## 3633         0
## 3634         0
## 3635         0
## 3636         0
## 3637         0
## 3638         0
## 3639         0
## 3640         0
## 3641         0
## 3642         0
## 3643         0
## 3644         0
## 3645         0
## 3646         1
## 3647         0
## 3648         0
## 3649         0
## 3650         0
## 3651         0
## 3652         0
## 3653         0
## 3654         0
## 3655         0
## 3656         0
## 3657         0
## 3658         1
## 3659         0
## 3660         0
## 3661         0
## 3662         0
## 3663         0
## 3664         0
## 3665         0
## 3666         0
## 3667         0
## 3668         0
## 3669         0
## 3670         1
## 3671         0
## 3672         1
## 3673         1
## 3674         0
## 3675         0
## 3676         0
## 3677         1
## 3678         0
## 3679         1
## 3680         0
## 3681         0
## 3682         1
## 3683         0
## 3684         0
## 3685         0
## 3686         0
## 3687         0
## 3688         0
## 3689         0
## 3690         0
## 3691         1
## 3692         0
## 3693         1
## 3694         0
## 3695         0
## 3696         0
## 3697         0
## 3698         0
## 3699         0
## 3700         0
## 3701         0
## 3702         0
## 3703         0
##  [ reached &amp;#39;max&amp;#39; / getOption(&amp;quot;max.print&amp;quot;) -- omitted 818 rows ]&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;factor-binning&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Factor Binning&lt;/h3&gt;
&lt;p&gt;You can collapse or combine levels of a factor/categorical variable using
&lt;code&gt;rbin_factor_combine()&lt;/code&gt; and then use &lt;code&gt;rbin_factor()&lt;/code&gt; to look at weight of
evidence, entropy and information value. After finalizing the bins, you can
use &lt;code&gt;rbin_factor_create()&lt;/code&gt; to create the dummy variables. You can use the
RStudio addin, &lt;code&gt;rbinFactorAddin()&lt;/code&gt; to interactively combine the levels and
create dummy variables after finalizing the bins.&lt;/p&gt;
&lt;div id=&#34;combine-levels&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Combine Levels&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;upper &amp;lt;- c(&amp;quot;secondary&amp;quot;, &amp;quot;tertiary&amp;quot;)
out &amp;lt;- rbin_factor_combine(mbank, education, upper, &amp;quot;upper&amp;quot;)
table(out$education)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##   upper unknown primary 
##    3651     179     691&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;out &amp;lt;- rbin_factor_combine(mbank, education, c(&amp;quot;secondary&amp;quot;, &amp;quot;tertiary&amp;quot;), &amp;quot;upper&amp;quot;)
table(out$education)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##   upper unknown primary 
##    3651     179     691&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;bins-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Bins&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;bins &amp;lt;- rbin_factor(mbank, y, education)
bins&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Binning Summary
## ---------------------------
## Method               Custom 
## Response             y 
## Predictor            education 
## Levels               4 
## Count                4521 
## Goods                517 
## Bads                 4004 
## Entropy              0.51 
## Information Value    0.05 
## 
## 
##       level bin_count good  bad        woe          iv   entropy
## 1  tertiary      1299  195 1104 -0.3133106 0.031785905 0.6101292
## 2 secondary      2352  231 2121  0.1702190 0.014113157 0.4633093
## 3   primary       691   66  625  0.2010906 0.005717878 0.4546110
## 4   unknown       179   25  154 -0.2289295 0.002265111 0.5833603&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;plot-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Plot&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(bins)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-12-introducing-rbin_files/figure-html/factor_plot-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;create-bins&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Create Bins&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;upper &amp;lt;- c(&amp;quot;secondary&amp;quot;, &amp;quot;tertiary&amp;quot;)
out &amp;lt;- rbin_factor_combine(mbank, education, upper, &amp;quot;upper&amp;quot;)
rbin_factor_create(out, education)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      age           job  marital default balance housing loan   contact day
## 1     34    technician  married      no     297     yes   no  cellular  29
## 2     49      services  married      no     180     yes  yes   unknown   2
## 3     38        admin.   single      no     262      no   no  cellular   3
## 4     47      services  married      no     367     yes   no  cellular  12
## 5     51 self-employed   single      no    1640     yes   no   unknown  15
## 6     40    unemployed  married      no    3382     yes   no   unknown  14
## 7     58       retired  married      no    1227      no   no  cellular  14
## 8     32    unemployed  married      no     309     yes   no telephone  13
## 9     46   blue-collar  married      no     922     yes   no telephone  18
## 10    32      services  married      no       0      no   no  cellular  21
## 11    32      services  married      no     414     yes   no  cellular   3
## 12    50   blue-collar  married      no       0      no   no   unknown   9
## 13    41    management  married      no    2226      no   no  cellular   7
## 14    38      services divorced      no       0     yes   no  cellular  20
## 15    31 self-employed  married     yes     147     yes   no  cellular  11
## 16    42        admin.   single      no     283     yes   no   unknown  19
## 17    56       retired  married      no      -1      no   no  cellular  27
## 18    54    management divorced      no     901      no   no   unknown  20
## 19    42    management  married      no     372     yes   no telephone  31
## 20    58      services  married      no     627      no   no  cellular  13
## 21    51        admin.  married      no      26     yes   no telephone  28
## 22    44    management  married      no     438     yes   no telephone   9
## 23    51    management   single      no    -461     yes   no   unknown  28
## 24    41    management  married      no    -195      no  yes  cellular  20
## 25    57    technician  married      no   16063     yes   no   unknown  30
## 26    32    management   single      no    3097     yes   no  cellular  20
## 27    32    management  married      no    1232      no   no  cellular  25
## 28    45    management  married      no    4693      no  yes  cellular   9
## 29    56  entrepreneur  married      no     196      no   no  cellular  19
## 30    38    technician  married      no       0     yes   no   unknown  21
## 31    54 self-employed  married      no     990      no   no  cellular   3
## 32    53    unemployed   single      no     183      no   no  cellular   9
## 33    36    management   single      no     219      no   no  cellular   3
## 34    37   blue-collar  married      no     -97     yes   no   unknown   5
## 35    31      services   single      no     222     yes   no  cellular  13
## 36    42    technician  married      no     234      no   no  cellular   4
## 37    34      services   single      no      25     yes  yes  cellular   9
## 38    37    technician  married      no    1762      no   no  cellular  16
## 39    59   blue-collar  married      no      80     yes   no telephone  31
## 40    54    management  married     yes       0     yes  yes  cellular   6
## 41    54   blue-collar  married      no    1357     yes  yes  cellular   5
## 42    59        admin.  married      no    -198     yes  yes  cellular   8
## 43    33    management   single      no    2059      no   no  cellular  29
## 44    24      services   single      no     258     yes   no  cellular  18
## 45    29    technician   single      no    2269     yes   no  cellular  20
## 46    49   blue-collar  married      no       0      no   no  cellular  14
## 47    37    technician  married      no      77     yes  yes  cellular  21
## 48    28   blue-collar  married      no     254     yes   no  cellular  20
## 49    82       retired  married      no     103      no   no  cellular   1
## 50    57   blue-collar  married      no     452     yes   no   unknown  13
## 51    39    technician   single      no   45248     yes   no   unknown   6
## 52    39    management   single      no       0      no   no  cellular  25
## 53    33    technician  married      no     620      no   no  cellular  14
## 54    32   blue-collar  married      no    2263      no   no  cellular   7
## 55    24   blue-collar   single      no    8594     yes   no   unknown  28
## 56    52    technician  married      no     306      no   no  cellular  25
## 57    32    management   single      no   10281      no   no  cellular  22
## 58    33    technician   single      no     469      no   no  cellular  26
## 59    31    management   single      no      86      no   no  cellular  29
## 60    42    management  married      no     477     yes   no   unknown   5
## 61    27   blue-collar  married      no       1     yes   no  cellular   5
## 62    32    technician  married      no       0     yes  yes  cellular  10
## 63    30    management   single      no       0     yes   no  cellular   5
## 64    42        admin. divorced      no    -172     yes  yes   unknown   4
## 65    43   blue-collar  married      no    2706     yes  yes   unknown  14
## 66    27    technician   single      no     808     yes   no  cellular  15
## 67    57    technician divorced      no     164      no   no   unknown   9
## 68    32    unemployed   single      no     331     yes   no   unknown   9
## 69    31        admin.   single      no    1374     yes   no  cellular  18
## 70    36   blue-collar  married      no       0     yes   no  cellular  18
## 71    31    management  married      no     625     yes   no  cellular   7
## 72    39   blue-collar  married      no     747     yes  yes  cellular  19
## 73    42      services  married      no     124     yes   no  cellular   2
## 74    68       retired  married      no       0      no   no telephone  15
## 75    56    technician  married      no     787      no  yes  cellular   9
## 76    46    technician divorced      no     405     yes   no   unknown  15
## 77    35        admin.  married      no    -272      no  yes  cellular  29
## 78    50      services  married      no   57435     yes   no  cellular  21
## 79    50   blue-collar  married      no     167      no   no  cellular  19
## 80    60     housemaid divorced      no    2063      no   no  cellular  21
## 81    32    technician  married      no       0     yes   no  cellular   2
## 82    30        admin.   single      no     255      no   no  cellular  27
## 83    48      services   single      no     204     yes   no  cellular  22
## 84    30        admin.   single      no     648      no   no  cellular  19
## 85    31   blue-collar  married      no      33     yes   no  cellular  24
## 86    45   blue-collar  married      no     430      no  yes  cellular  21
## 87    35   blue-collar  married      no     260     yes   no telephone  13
## 88    26        admin.   single      no       0     yes   no  cellular  13
## 89    32        admin.  married      no    1604      no  yes  cellular   7
## 90    50    technician  married      no    -568     yes  yes   unknown  28
## 91    34    technician  married      no     966     yes   no  cellular  18
## 92    29   blue-collar  married      no     356     yes   no   unknown   4
## 93    29   blue-collar  married      no    2378     yes  yes  cellular  20
## 94    75       retired divorced      no     852      no   no  cellular  16
## 95    72       retired  married      no    1388      no   no telephone  20
## 96    48   blue-collar  married      no    1230     yes  yes   unknown   7
## 97    37    management  married      no    9895     yes   no  cellular  20
## 98    34    technician   single      no   27446     yes   no  cellular  21
## 99    44    management  married      no    1880     yes   no  cellular  18
## 100   35      services  married      no       0     yes   no   unknown  21
## 101   28       student  married      no     803     yes   no  cellular  25
## 102   25   blue-collar   single      no     158     yes  yes  cellular  16
## 103   51   blue-collar  married      no     328      no   no   unknown   4
## 104   44    unemployed divorced      no     522      no   no  cellular   7
## 105   47   blue-collar  married      no     550     yes   no   unknown   7
## 106   59       retired divorced      no     602      no   no   unknown  20
## 107   38   blue-collar  married      no     467     yes   no   unknown  16
## 108   39    management   single      no    1682     yes   no   unknown   2
## 109   43    technician divorced      no     305     yes   no  cellular   5
## 110   45    management divorced      no   24598     yes   no   unknown   5
## 111   24   blue-collar   single      no    2129     yes  yes telephone  18
## 112   24 self-employed   single      no     931     yes   no   unknown  28
## 113   69    technician  married      no    9064      no   no  cellular   7
## 114   37   blue-collar   single      no    2188      no   no   unknown  16
## 115   29    technician   single      no    -803     yes  yes  cellular   6
## 116   51   blue-collar  married      no     -11      no   no telephone  16
## 117   26       student   single      no    5296      no   no telephone  12
## 118   53        admin. divorced      no     122      no   no  cellular  27
## 119   41      services  married      no    6687     yes   no  cellular  21
## 120   42   blue-collar  married      no     902     yes   no   unknown  14
## 121   25  entrepreneur  married      no      30     yes   no  cellular  24
## 122   39    technician   single      no    1048     yes  yes  cellular   8
## 123   50      services  married      no    1687      no   no  cellular  19
## 124   55   blue-collar  married      no     771      no   no  cellular  29
## 125   34        admin.   single      no     663     yes   no  cellular  20
## 126   31    technician divorced      no    2287     yes   no   unknown  21
## 127   32    technician   single     yes      -1      no   no  cellular  29
## 128   56   blue-collar  married      no    1686      no   no telephone  17
## 129   51   blue-collar  married      no    1779     yes   no   unknown  15
## 130   25   blue-collar  married      no     316     yes  yes   unknown  19
## 131   33    management divorced      no     312     yes  yes  cellular  13
## 132   54    management  married     yes    5249     yes   no  cellular  17
## 133   34  entrepreneur  married      no       2     yes  yes  cellular   5
## 134   39    technician   single      no     175      no  yes   unknown  16
## 135   45    technician  married      no     406     yes   no  cellular   3
## 136   43   blue-collar  married      no    -454     yes   no   unknown   7
## 137   54    technician divorced      no     -11     yes   no  cellular  12
## 138   34      services divorced      no      27     yes   no  cellular   6
## 139   45    technician  married      no    3395     yes   no  cellular  18
## 140   38      services divorced      no      49     yes   no  cellular  18
## 141   33   blue-collar divorced      no       1      no   no   unknown  16
## 142   27       student   single      no      24     yes   no  cellular   2
## 143   53    management divorced      no    2894     yes   no  cellular   5
## 144   32        admin.   single      no    6042     yes   no  cellular  15
## 145   37   blue-collar   single      no     481      no   no  cellular  18
## 146   51   blue-collar  married      no    7098      no   no  cellular   6
## 147   55       retired  married      no     123      no   no  cellular  28
## 148   61       retired  married      no     280     yes   no   unknown  15
## 149   41    technician  married      no     139      no   no  cellular  18
## 150   39   blue-collar  married      no    1042     yes   no   unknown   8
## 151   34   blue-collar   single      no    1423     yes   no  cellular  21
## 152   37    management  married      no     591     yes   no  cellular   7
## 153   30    management  married      no    1235      no   no  cellular  28
## 154   54    unemployed divorced      no    3721     yes   no  cellular  30
## 155   47    technician divorced      no    1851     yes   no   unknown  19
## 156   32    unemployed  married      no     283     yes   no  cellular  22
## 157   42        admin.   single      no    2095     yes   no  cellular  21
## 158   52   blue-collar divorced      no     -97     yes  yes   unknown   9
## 159   83       retired   single      no    3349      no   no telephone  12
## 160   42    technician   single      no       0     yes   no   unknown   7
## 161   38    management   single      no    3141      no   no  cellular   9
## 162   56    unemployed  married      no    -246      no  yes  cellular  28
## 163   52    management divorced      no       0      no   no  cellular   4
## 164   56      services divorced      no    1877     yes   no   unknown  30
## 165   55    technician  married      no       0     yes  yes  cellular   2
## 166   56    technician divorced      no    3450      no   no  cellular  10
## 167   29    technician   single      no     673     yes   no  cellular   9
## 168   73       retired  married      no     542      no   no  cellular  26
## 169   62     housemaid  married      no       2      no   no  cellular   3
## 170   56    management  married      no    -762     yes  yes  cellular  11
## 171   36    technician  married      no    1653     yes  yes   unknown  27
## 172   32   blue-collar  married      no      50     yes   no  cellular  13
## 173   48    management  married      no   14530     yes  yes telephone  29
## 174   31        admin.   single      no     358     yes   no   unknown  14
## 175   26   blue-collar   single      no    3145      no   no  cellular  28
## 176   27   blue-collar   single      no    1311     yes   no   unknown  13
## 177   56      services  married      no     486      no  yes telephone  21
## 178   31    management   single      no      34      no   no  cellular  22
## 179   36   blue-collar  married      no       0      no   no   unknown   5
## 180   53    technician  married      no    6921     yes   no  cellular  19
## 181   39   blue-collar  married      no      98      no   no  cellular  31
## 182   82       retired divorced      no     928      no   no telephone  23
## 183   30    technician  married      no     671      no   no  cellular  11
## 184   31    technician  married      no     535      no   no  cellular   8
## 185   47 self-employed  married      no     -80     yes   no  cellular   6
## 186   58    unemployed  married      no    3884      no   no   unknown   9
## 187   55    management  married      no    1402     yes   no  cellular  17
## 188   25        admin.   single      no     425      no   no  cellular  27
## 189   31   blue-collar   single      no    -161      no   no  cellular  11
## 190   53    technician  married      no    2647     yes   no   unknown  30
## 191   43   blue-collar  married      no     517     yes   no  cellular  20
## 192   56  entrepreneur  married      no      40      no  yes  cellular  11
## 193   51    technician  married      no    8758      no   no telephone  31
## 194   34        admin.  married      no     764      no   no  cellular   9
## 195   45    management  married      no     446      no   no  cellular   6
## 196   60   blue-collar  married      no       5      no   no  cellular  29
## 197   46    management   single      no    6651      no   no  cellular  23
## 198   40  entrepreneur  married      no       0     yes   no  cellular  22
## 199   53    management  married      no     913     yes   no   unknown   9
## 200   57        admin.  married      no     596      no   no  cellular  29
## 201   25   blue-collar   single      no    -221     yes   no   unknown  23
## 202   31    unemployed divorced      no     756      no   no  cellular  20
## 203   64       retired  married      no    1612      no   no  cellular  18
## 204   37        admin.  married      no    1314     yes   no  cellular  12
## 205   30        admin.   single      no    1009     yes   no  cellular  29
## 206   37        admin.   single      no     781      no   no  cellular  20
## 207   48   blue-collar  married      no    5078     yes   no telephone   8
## 208   48   blue-collar  married      no       8      no   no  cellular  20
## 209   50      services  married      no    1134      no   no   unknown  18
## 210   38        admin.  married      no     689     yes   no  cellular  25
## 211   43 self-employed  married      no     634     yes   no  cellular  17
## 212   31    technician   single      no       9      no   no  cellular   7
## 213   48    management  married      no    1147      no   no  cellular   3
## 214   40        admin.   single      no     963     yes   no  cellular   7
## 215   63  entrepreneur  married      no    3904      no   no telephone   4
## 216   41    management  married      no      23      no   no  cellular  22
## 217   23      services   single      no     665     yes   no   unknown  28
## 218   29    management   single      no     536      no   no  cellular  29
## 219   52   blue-collar   single     yes    -517      no  yes  cellular  10
## 220   44  entrepreneur  married     yes    -848     yes   no   unknown  19
## 221   39    technician  married      no     375     yes  yes telephone  17
## 222   49   blue-collar  married      no     371     yes   no  cellular  31
## 223   34        admin.  married      no      95     yes   no  cellular  18
## 224   33    technician  married      no     148      no   no  cellular  27
## 225   51   blue-collar divorced      no     886      no   no   unknown  17
## 226   24    management   single      no       1      no   no  cellular  14
## 227   34      services  married      no     142     yes   no   unknown   8
## 228   50   blue-collar  married      no     506     yes   no telephone   7
## 229   44   blue-collar  married      no     129     yes  yes   unknown   5
## 230   57   blue-collar divorced      no    1299      no   no  cellular  27
## 231   26       student   single      no      19      no   no telephone  30
## 232   29   blue-collar  married      no     163     yes  yes  cellular  29
## 233   50   blue-collar  married      no       0      no   no   unknown   5
## 234   52    management  married      no    4096     yes   no   unknown   4
## 235   31        admin.  married      no       0     yes  yes  cellular  18
## 236   32   blue-collar   single      no      33      no   no  cellular  23
## 237   33    technician   single      no       0      no   no  cellular  26
## 238   33        admin.   single      no    1779     yes   no   unknown  21
## 239   41    unemployed divorced      no    -198     yes   no  cellular  17
## 240   28    technician  married      no     107     yes   no  cellular  29
## 241   41  entrepreneur   single      no    7264      no  yes   unknown   1
## 242   32   blue-collar  married      no     289     yes   no   unknown   8
## 243   48      services  married      no    1155     yes   no   unknown  16
## 244   45 self-employed divorced      no     963     yes   no  cellular  12
## 245   39   blue-collar  married      no       0     yes   no  cellular  18
## 246   36        admin. divorced      no     -37     yes   no   unknown  27
## 247   60       retired  married      no    3932     yes   no   unknown  14
## 248   42        admin.   single      no    -247     yes  yes  cellular  18
## 249   34   blue-collar   single      no     505     yes   no   unknown  13
## 250   40    management divorced      no     205      no   no  cellular  25
## 251   26     housemaid   single      no      93      no   no  cellular  11
## 252   42      services  married      no    1545     yes   no  cellular  17
## 253   47    management  married      no    1147      no   no  cellular  27
## 254   35   blue-collar  married      no     765     yes   no   unknown  29
## 255   24       student   single      no     822      no   no  cellular  27
## 256   42    management divorced      no     461     yes   no   unknown   3
## 257   53      services  married      no      76     yes   no   unknown  19
## 258   44    technician divorced      no     316     yes   no  cellular  21
## 259   44 self-employed   single      no      97     yes   no   unknown   6
## 260   43   blue-collar  married      no     -41      no   no   unknown  20
## 261   28   blue-collar   single      no    2340     yes   no   unknown  19
## 262   53      services  married      no    2618     yes   no  cellular   5
## 263   23       student   single      no    1062      no   no telephone  27
## 264   32      services  married      no     206     yes  yes   unknown  12
## 265   27   blue-collar  married      no     191     yes   no  cellular  20
## 266   55    technician   single      no      11      no   no   unknown  20
## 267   48        admin.  married      no       0     yes   no  cellular   8
## 268   32   blue-collar  married      no     827     yes   no   unknown  23
## 269   45   blue-collar  married      no     351     yes   no   unknown  19
## 270   38    technician  married      no      54     yes  yes  cellular   5
## 271   53   blue-collar divorced      no      -1     yes   no  cellular   2
## 272   26    technician   single      no     941      no  yes  cellular  25
## 273   34  entrepreneur  married      no     223      no  yes  cellular  11
## 274   31    management   single      no      53     yes   no  cellular   7
## 275   45  entrepreneur divorced      no       0     yes   no  cellular  13
## 276   56    management divorced      no     310      no   no   unknown  20
## 277   38   blue-collar  married      no     635     yes   no   unknown   3
## 278   39    management   single      no     668      no   no  cellular  14
## 279   26      services   single      no    1700     yes   no  cellular   7
## 280   35       student divorced      no    2755     yes   no  cellular  14
## 281   30    management   single      no       0      no   no  cellular  28
## 282   41      services divorced      no      83      no   no   unknown  20
## 283   47  entrepreneur  married      no       0      no   no   unknown   5
## 284   38      services  married      no   10189     yes   no  cellular  18
## 285   61    management  married      no    5157      no   no  cellular  13
## 286   35   blue-collar  married      no    4366     yes   no   unknown  28
## 287   30   blue-collar  married     yes     -18      no   no   unknown   3
## 288   35    technician  married      no     561     yes   no  cellular  22
## 289   35    technician  married      no    -255     yes   no  cellular  13
## 290   32   blue-collar  married      no     391     yes   no  cellular  17
## 291   40      services  married      no    9374     yes   no  cellular  21
## 292   30      services   single      no     695     yes   no   unknown  20
## 293   21       student   single      no      71      no   no  cellular  13
## 294   38    technician  married      no       0      no   no  cellular  26
## 295   54  entrepreneur divorced      no   20527      no   no telephone  20
## 296   35   blue-collar   single      no     219     yes  yes   unknown  29
## 297   45   blue-collar  married      no     491     yes  yes  cellular  12
## 298   37    technician   single      no    -272      no  yes  cellular  20
## 299   42  entrepreneur  married      no     859      no   no  cellular  29
## 300   34        admin.  married      no     -33     yes  yes  cellular  10
## 301   38     housemaid  married      no    1508      no  yes  cellular   8
## 302   36    management  married      no     918      no   no  cellular  28
## 303   30    technician  married      no     606     yes   no  cellular  30
## 304   44    technician divorced      no     414     yes  yes   unknown   6
## 305   50   blue-collar  married      no     325     yes   no  cellular  17
## 306   42        admin.   single      no     734     yes   no  cellular  16
## 307   64       retired  married      no      43      no   no  cellular  11
## 308   31  entrepreneur  married      no       0     yes   no   unknown  23
## 309   35  entrepreneur  married      no       0      no   no  cellular  18
## 310   58    management divorced      no    4256      no   no  cellular  22
## 311   44    management  married      no     474     yes  yes   unknown  14
## 312   79       retired divorced      no     336      no   no  cellular   6
## 313   37        admin. divorced      no       0     yes  yes  cellular  14
## 314   36      services   single      no    9713     yes   no   unknown  27
## 315   57       retired  married      no    4451      no  yes  cellular   7
## 316   32    technician   single      no    -138      no   no  cellular  16
## 317   26    unemployed   single      no     771      no   no  cellular  22
## 318   25      services   single      no     333      no  yes  cellular  15
## 319   39        admin.  married      no     563     yes   no  cellular   4
## 320   40   blue-collar  married      no    4795     yes   no  cellular  17
## 321   50   blue-collar  married      no     157      no   no  cellular  27
## 322   38    technician   single      no     178     yes   no  cellular   7
## 323   31    management   single      no       0      no   no  cellular  28
## 324   45   blue-collar  married      no       0     yes   no  cellular  21
## 325   57    management divorced      no     236      no   no  cellular  18
## 326   30    management   single      no     536      no   no  cellular   2
## 327   36        admin.  married      no    3308      no  yes  cellular  31
## 328   32   blue-collar   single      no    1211     yes   no   unknown  19
## 329   41        admin.  married      no    1705      no   no  cellular  30
## 330   59     housemaid  married      no       5      no  yes telephone  22
## 331   58    unemployed  married      no    4967      no   no telephone   4
## 332   26        admin.  married      no     284      no   no   unknown  10
## 333   50   blue-collar divorced      no     -19     yes   no  cellular  21
## 334   38   blue-collar  married      no     168     yes  yes telephone  13
## 335   36        admin.   single      no     148     yes   no  cellular  15
## 336   28    technician   single      no     386      no   no  cellular  25
## 337   52  entrepreneur  married      no    3332     yes  yes  cellular  13
## 338   35     housemaid  married      no       0      no   no  cellular  18
## 339   35   blue-collar  married      no       0     yes   no  cellular   8
## 340   39    technician  married      no    2765     yes  yes   unknown  20
## 341   53    technician  married      no    3398      no  yes telephone  20
## 342   52  entrepreneur  married      no     330      no  yes  cellular   4
## 343   41   blue-collar  married      no    2152     yes   no  cellular  17
## 344   50    technician  married      no    8001      no   no   unknown   6
## 345   57 self-employed  married      no    2109      no   no  cellular  21
## 346   56    management  married      no      79      no   no  cellular   7
## 347   34    management   single      no    -578     yes   no  cellular  18
## 348   41   blue-collar  married      no     449     yes  yes  cellular  12
## 349   54    management divorced      no    5253     yes  yes  cellular   7
## 350   66     housemaid divorced      no    3701      no   no telephone   3
## 351   28    management  married      no     395      no   no   unknown  21
## 352   22       student   single      no     722     yes   no  cellular   2
## 353   50    technician  married      no       4      no   no  cellular  10
## 354   35    management   single      no       0     yes   no   unknown  30
## 355   37  entrepreneur  married      no    7944      no   no  cellular  21
## 356   30    management   single      no      59     yes  yes   unknown   8
## 357   38        admin.   single      no     221     yes   no  cellular   4
## 358   36   blue-collar  married      no     330     yes   no  cellular  13
## 359   43    management   single      no    3872     yes   no  cellular   9
## 360   42   blue-collar  married      no    3052     yes   no   unknown  27
## 361   28   blue-collar   single      no     362     yes   no   unknown  19
## 362   37    management  married      no    5355      no   no telephone  17
## 363   39    management  married      no     285     yes   no  cellular  15
## 364   34      services   single      no    3648     yes   no  cellular   5
## 365   55    unemployed  married      no    4809     yes   no  cellular  21
## 366   37  entrepreneur  married      no     298      no   no  cellular  27
## 367   29    technician   single      no    1185     yes   no   unknown  26
## 368   34    technician  married      no       2     yes   no  cellular  25
## 369   42      services   single      no     838     yes   no  cellular  19
## 370   32        admin.  married      no     552     yes   no  cellular   6
## 371   32   blue-collar  married      no    2561     yes   no   unknown  20
## 372   34   blue-collar  married      no     351      no  yes  cellular  14
## 373   39   blue-collar  married      no     161     yes   no  cellular  18
## 374   35   blue-collar  married      no    -167     yes   no  cellular  15
## 375   55       retired  married      no    3948      no   no  cellular  19
## 376   31        admin.  married      no     -36     yes  yes   unknown   4
## 377   59       retired  married      no     374      no   no  cellular  29
## 378   34    management  married      no     362     yes   no   unknown  30
## 379   53      services   single      no    1162     yes   no  cellular  18
## 380   38   blue-collar  married      no       0      no   no   unknown  20
## 381   41    management  married      no    5936      no   no  cellular  29
## 382   46   blue-collar  married      no     853      no   no  cellular  11
## 383   31        admin.  married      no       2     yes  yes  cellular  12
## 384   27      services   single      no     814     yes   no  cellular   7
## 385   51   blue-collar  married      no       0      no   no   unknown   8
## 386   40    technician divorced      no      16     yes   no telephone  12
## 387   49    management  married      no     865      no   no  cellular  28
## 388   39     housemaid  married      no    1444      no   no telephone  25
## 389   50   blue-collar  married      no     278      no   no   unknown  20
## 390   45    management  married      no      77     yes   no  cellular  17
## 391   46   blue-collar  married      no     265     yes   no   unknown   5
## 392   39   blue-collar  married      no     541     yes   no  cellular   2
## 393   61 self-employed divorced      no   52587      no   no  cellular  15
## 394   37    technician   single      no     -59     yes   no  cellular  22
## 395   38    technician  married      no      90     yes  yes   unknown   8
## 396   32    management  married      no    1660     yes   no  cellular  11
## 397   51        admin.  married      no     924     yes   no   unknown  16
## 398   38    technician   single      no     553     yes   no  cellular  15
## 399   39     housemaid  married      no       0     yes   no  cellular  29
## 400   42    management  married      no      36      no   no  cellular  21
## 401   43 self-employed  married      no    5317      no   no  cellular  31
## 402   38    technician   single      no      61     yes   no  cellular  13
## 403   49    management divorced      no    1598     yes   no  cellular  12
## 404   58       retired  married      no    4007      no   no  cellular  30
## 405   39   blue-collar   single      no    1537      no  yes   unknown   5
## 406   50    management  married      no     782      no   no  cellular  16
## 407   28    management  married      no      12     yes   no  cellular   9
## 408   51   blue-collar  married      no      51      no  yes  cellular  20
## 409   47    technician  married      no      72      no   no   unknown  29
## 410   30        admin.   single      no       5      no  yes  cellular  11
## 411   55    technician divorced      no     852      no   no  cellular  20
## 412   40    management   single      no    -222     yes   no  cellular   8
## 413   33    technician   single      no     129     yes   no   unknown   8
## 414   31    technician   single      no     694     yes   no   unknown   6
## 415   33    technician  married      no     145     yes   no  cellular  20
## 416   58       retired  married      no     928      no   no telephone   4
## 417   48  entrepreneur  married      no      86     yes   no   unknown  13
## 418   28        admin.   single      no     731     yes   no   unknown   5
## 419   38    unemployed   single      no    7159      no   no telephone  30
## 420   44   blue-collar  married      no     294     yes   no  cellular   2
## 421   31    management  married      no    1126      no   no   unknown  14
## 422   46       unknown  married      no    2911      no   no telephone   7
## 423   32    management   single      no    1804     yes   no   unknown  20
## 424   36    management   single      no     601      no   no  cellular   2
## 425   47     housemaid  married      no    1692     yes   no  cellular  30
## 426   29    unemployed   single      no    1311      no   no  cellular  28
## 427   35    management   single      no     342      no  yes  cellular   2
## 428   43  entrepreneur  married      no     210      no   no  cellular  29
## 429   34    management  married      no    1770     yes   no   unknown   6
## 430   30    technician   single      no    1416      no   no telephone  19
## 431   59      services  married      no     196     yes   no telephone  20
## 432   50    management divorced      no     405      no   no  cellular   2
## 433   35   blue-collar  married      no     463     yes   no   unknown  21
## 434   37        admin.   single      no     192     yes   no   unknown  23
## 435   45   blue-collar  married      no     487     yes   no  cellular  19
## 436   54        admin. divorced      no    -288     yes   no   unknown  27
## 437   64    management  married      no    3951      no   no  cellular  28
## 438   48    management  married      no       0      no  yes  cellular   6
## 439   62    unemployed  married      no     532      no   no  cellular  31
## 440   53   blue-collar  married      no    1388      no   no  cellular   7
## 441   59   blue-collar  married      no       0      no   no   unknown  18
## 442   43        admin.   single      no     445     yes   no   unknown  19
## 443   48    management  married      no       2      no   no  cellular  15
## 444   40    management  married      no   -1212     yes   no  cellular  15
## 445   46   blue-collar  married      no    5164     yes   no   unknown   5
## 446   36      services   single      no     616     yes  yes   unknown  12
## 447   36    technician  married      no     571     yes  yes  cellular  31
## 448   29      services  married      no     182     yes   no telephone  13
## 449   29       student   single      no    1093     yes   no   unknown  29
## 450   39   blue-collar divorced      no     382      no   no  cellular  18
## 451   38 self-employed  married      no     173      no   no  cellular  18
## 452   55   blue-collar  married      no     176      no  yes  cellular  22
## 453   30    management  married      no     367      no   no  cellular   4
## 454   33    technician   single      no     231     yes   no   unknown  27
## 455   42    technician  married      no     233      no   no  cellular  20
## 456   29    management  married      no     318     yes   no  cellular  18
## 457   43    unemployed  married      no       9     yes  yes  cellular   6
## 458   46    management   single      no     502      no   no  cellular  25
## 459   32   blue-collar   single      no     259     yes   no  cellular   8
## 460   33      services  married      no    1631     yes   no  cellular  20
## 461   55    technician  married      no     284      no   no  cellular  22
## 462   36    management  married      no       0     yes   no  cellular  20
## 463   47  entrepreneur  married      no    1481     yes   no  cellular   6
## 464   45 self-employed  married      no    3080      no   no  cellular  19
## 465   30    management   single      no     135      no   no  cellular  14
## 466   41    management  married      no    5883      no   no  cellular  20
## 467   75       retired divorced      no    3881     yes   no  cellular   4
## 468   43    technician divorced      no    1648      no   no  cellular  17
## 469   46     housemaid  married      no     271     yes   no  cellular  30
## 470   23      services   single      no      75     yes   no   unknown  15
## 471   35    technician   single      no     354     yes   no  cellular   4
## 472   30        admin.  married      no      40     yes  yes  cellular   7
## 473   48    unemployed   single      no      63      no   no  cellular  30
## 474   32      services   single      no     459     yes   no   unknown   8
## 475   49      services  married      no       0      no   no  cellular  26
## 476   37   blue-collar  married      no     223     yes   no  cellular  14
## 477   35      services  married      no      74     yes   no   unknown  27
## 478   58    management  married      no    2769     yes   no  cellular  11
## 479   53    technician  married      no    4323     yes   no   unknown  15
## 480   44    technician  married      no    4580     yes   no   unknown  15
## 481   42        admin.  married      no    -306     yes   no  cellular  17
## 482   43    technician  married      no    2643      no   no telephone   4
## 483   53  entrepreneur  married      no    -257     yes  yes   unknown  18
## 484   28    technician   single      no     441      no  yes  cellular   9
## 485   27   blue-collar   single     yes      -2     yes  yes   unknown  14
## 486   54    technician  married      no   10185      no   no  cellular  12
## 487   33        admin.  married      no    2374     yes   no  cellular  14
## 488   69       retired  married      no     473      no   no  cellular  21
## 489   39    management   single      no    3281      no   no   unknown   9
## 490   50    technician  married      no     423      no   no telephone   7
## 491   52    technician  married      no    1373      no   no  cellular  27
## 492   60       retired  married      no    2557     yes   no  cellular   2
## 493   57    technician  married      no    3858      no   no  cellular  27
## 494   42    technician  married      no     334     yes   no  cellular  20
## 495   52   blue-collar divorced      no    1250      no   no   unknown  16
## 496   40    technician  married      no     657     yes   no  cellular  30
## 497   32    technician  married      no    1951     yes   no  cellular   8
## 498   37        admin.   single      no     515     yes   no  cellular  20
## 499   36    management   single      no     181     yes   no  cellular  13
## 500   60       retired  married      no    -222      no   no  cellular  17
## 501   31      services   single     yes      68     yes   no   unknown   9
## 502   39   blue-collar   single      no       0     yes   no  cellular  14
## 503   49      services   single      no    3061     yes   no   unknown  15
## 504   39    management  married      no     691     yes  yes  cellular  16
## 505   45     housemaid divorced      no     544      no   no   unknown  11
## 506   34   blue-collar  married      no     355     yes   no  cellular  18
## 507   53        admin.  married      no    6280      no   no  cellular   4
## 508   38    technician   single      no     227      no   no  cellular  13
## 509   28        admin.   single      no     419     yes   no   unknown  28
## 510   53     housemaid  married     yes     945      no   no  cellular  29
## 511   27   blue-collar   single      no     940     yes   no  cellular  15
## 512   30    technician   single      no    2567      no   no  cellular  18
## 513   33    management  married      no      56     yes   no   unknown  21
## 514   37    technician   single      no    1609      no  yes   unknown  20
## 515   30    management   single      no     364      no   no  cellular  30
## 516   53   blue-collar  married      no    -864     yes   no   unknown   9
## 517   27    management   single      no    1137     yes   no  cellular   8
## 518   37   blue-collar  married      no     374     yes   no   unknown   7
## 519   27    management   single      no    2786      no   no  cellular  15
## 520   40   blue-collar   single      no     366     yes  yes  cellular  28
## 521   76     housemaid  married      no    1483      no   no  cellular   2
## 522   32   blue-collar  married      no    1779     yes   no  cellular  13
## 523   52        admin.  married      no     722      no   no  cellular  26
## 524   45        admin.   single      no     341     yes  yes  cellular   5
## 525   34    management divorced      no     157     yes   no  cellular  12
## 526   43    management   single      no     776      no   no telephone  18
## 527   38        admin.  married      no     505     yes  yes  cellular  21
## 528   60     housemaid  married      no     182      no   no  cellular  26
## 529   33   blue-collar   single      no     498      no   no  cellular  12
## 530   29    management  married      no     991      no   no  cellular   7
## 531   41    technician  married      no    2851      no   no  cellular  18
## 532   38   blue-collar  married      no    1807      no   no   unknown   7
## 533   40   blue-collar  married      no    -310     yes  yes  cellular  26
## 534   41  entrepreneur divorced      no    -413     yes   no   unknown   8
## 535   45        admin.  married      no    -405      no   no  cellular  31
## 536   31    unemployed   single      no     315      no   no  cellular  30
## 537   33    technician  married      no     575      no  yes  cellular   4
## 538   30      services  married      no       0     yes   no  cellular  21
## 539   40     housemaid  married      no     116      no   no  cellular  11
## 540   49        admin.  married      no     635      no   no  cellular  25
## 541   31      services  married      no    2050     yes   no  cellular  18
## 542   33      services   single      no     523     yes   no   unknown  28
## 543   47    technician divorced      no      84      no   no  cellular   8
## 544   35        admin. divorced      no    3636      no  yes  cellular  21
## 545   42      services  married      no    3465     yes  yes  cellular  16
## 546   47     housemaid  married      no    1765      no   no  cellular   8
## 547   30 self-employed   single      no     635      no  yes  cellular  14
## 548   51   blue-collar  married      no     653     yes  yes   unknown   6
## 549   30      services   single      no     631     yes   no  cellular  18
## 550   56    management  married      no     586      no   no telephone  10
## 551   37   blue-collar  married      no    1407     yes   no  cellular  21
## 552   55        admin. divorced      no    3524     yes   no   unknown  19
## 553   32    management   single      no     112     yes   no  cellular   5
## 554   52    management  married      no    6873     yes   no  cellular  21
## 555   43     housemaid divorced      no       0      no   no   unknown  11
## 556   47        admin.   single      no    3696      no   no  cellular  12
## 557   58  entrepreneur  married      no     670     yes   no  cellular  12
## 558   37    unemployed  married      no    7620      no   no telephone  25
## 559   32    unemployed   single      no    2706      no   no  cellular  21
## 560   50    management  married      no       5      no   no   unknown   3
## 561   42        admin. divorced      no     936      no   no  cellular  30
## 562   32    technician   single      no    1454     yes   no  cellular  20
## 563   33    technician   single      no    1500      no   no  cellular   7
## 564   30        admin.   single      no     305      no   no  cellular   4
## 565   38  entrepreneur   single      no    2543      no   no  cellular  11
## 566   32    technician  married      no    1242     yes   no   unknown   2
## 567   28    management   single      no     492      no   no  cellular   2
## 568   50    unemployed  married      no    3357      no   no  cellular   9
## 569   27       student   single      no    1390      no   no  cellular  30
## 570   41        admin.  married      no   16517      no   no  cellular  18
## 571   54      services divorced      no    2398     yes   no  cellular  17
## 572   39    technician  married     yes    -183     yes   no   unknown  14
## 573   34        admin.  married      no     635     yes   no   unknown  26
## 574   37      services  married      no    1616     yes   no  cellular  28
## 575   20       student   single      no     602     yes   no  cellular   6
## 576   53       retired divorced      no     797      no   no   unknown  20
## 577   30      services   single      no     677     yes   no  cellular  21
## 578   29  entrepreneur   single      no     430      no  yes  cellular  29
## 579   47    technician  married      no     434     yes  yes  cellular   5
## 580   44    management  married      no   12392     yes   no  cellular  13
## 581   26     housemaid  married      no    -759     yes   no  cellular  11
## 582   31   blue-collar  married      no     295     yes   no  cellular  12
## 583   37    management  married      no       0      no   no   unknown  16
## 584   63       retired  married      no   12067      no   no telephone  29
## 585   37    management   single      no    8066      no   no telephone  13
## 586   27        admin.  married      no     249     yes   no  cellular  13
## 587   26    management   single      no      55      no  yes  cellular  16
## 588   30    technician  married      no       0      no   no  cellular  28
## 589   50   blue-collar  married      no      65     yes   no telephone  12
## 590   34   blue-collar divorced      no    1614     yes   no  cellular  15
## 591   39   blue-collar divorced      no     412      no   no   unknown  28
## 592   54    management divorced      no    5475      no   no  cellular  22
## 593   32   blue-collar   single      no    2137      no   no  cellular  13
## 594   50   blue-collar  married      no      89     yes   no   unknown   9
## 595   27       student   single      no    1134      no   no  cellular  21
## 596   32    technician  married      no     221     yes   no   unknown  23
## 597   29       student   single      no      48      no   no  cellular  26
## 598   58       unknown  married      no     208      no   no  cellular   8
## 599   34      services   single      no      88      no   no  cellular   5
## 600   50    technician  married      no    1616     yes  yes   unknown   4
## 601   31    technician   single      no    -167     yes   no   unknown   2
## 602   58    management divorced      no   26254     yes   no  cellular  21
## 603   34   blue-collar  married      no    1298     yes   no   unknown  20
## 604   58   blue-collar divorced      no     820     yes   no  cellular   7
## 605   38  entrepreneur divorced      no      36      no   no  cellular  18
## 606   59    technician  married      no    2342      no  yes telephone  23
## 607   40    unemployed  married      no    1872      no   no  cellular  21
## 608   35      services  married      no     528      no   no   unknown   7
## 609   32    technician  married      no      79     yes   no  cellular  25
## 610   32     housemaid divorced      no    -613     yes   no  cellular  15
## 611   29        admin.   single      no     260     yes   no  cellular   4
## 612   53    management divorced      no    6388     yes   no telephone  23
## 613   44    technician  married      no     398     yes   no   unknown  28
## 614   36        admin.  married      no     313     yes   no telephone   4
## 615   38    technician  married      no    5115     yes   no  cellular  27
## 616   46   blue-collar  married      no     -29     yes   no   unknown  12
## 617   62       retired  married      no    3340      no   no  cellular   4
## 618   36   blue-collar divorced      no    3202     yes   no   unknown  21
## 619   35 self-employed  married      no      -3      no   no   unknown   9
## 620   35   blue-collar   single      no     218     yes   no  cellular  20
## 621   35    technician divorced      no    2823     yes   no  cellular  26
## 622   33    unemployed   single      no    4874      no   no telephone  22
## 623   49    technician  married      no     905      no   no  cellular  12
## 624   46    management  married      no    3570      no   no  cellular  13
## 625   57  entrepreneur  married      no     975     yes  yes  cellular  22
## 626   58    technician  married      no     289      no   no telephone  21
## 627   51  entrepreneur  married      no   36935     yes   no  cellular  21
## 628   31    unemployed  married      no      24     yes   no  cellular  19
## 629   26        admin.   single      no     140     yes   no  cellular  15
## 630   42    management  married      no       4     yes   no  cellular   8
## 631   46   blue-collar  married      no     536     yes   no   unknown  15
## 632   25    technician  married      no    -559     yes   no  cellular  14
## 633   58       retired  married      no    1227      no   no  cellular   2
## 634   35    technician   single      no    2471     yes  yes  cellular  25
## 635   54    management divorced      no     300     yes   no  cellular   7
## 636   33    technician  married      no    6419      no   no  cellular   7
## 637   31        admin.  married      no     454     yes   no   unknown   4
## 638   45    technician  married      no    3388      no   no   unknown  19
## 639   50        admin.  married      no     176      no   no  cellular  29
## 640   28 self-employed  married      no       0     yes   no   unknown   9
## 641   51    management  married      no    1421     yes   no  cellular   7
## 642   37      services  married      no       0      no   no   unknown  20
## 643   40        admin.  married      no       0     yes   no   unknown  20
## 644   36    unemployed  married      no    7222     yes   no  cellular   4
## 645   36    technician   single      no    5436     yes   no   unknown  20
## 646   35    technician   single      no      27     yes   no  cellular  25
## 647   29     housemaid   single      no      19      no   no  cellular   5
## 648   36   blue-collar  married      no     723     yes   no  cellular  31
## 649   50    unemployed  married      no     525     yes   no telephone  18
## 650   52      services divorced      no    2455      no   no  cellular  25
## 651   34 self-employed  married      no      47      no   no  cellular   4
## 652   53    management  married      no    4928     yes   no   unknown  15
## 653   29      services   single      no    -158     yes   no   unknown   7
## 654   36    management  married      no     105      no   no  cellular  28
## 655   31    technician  married      no      28      no   no  cellular  21
## 656   33    technician   single      no    6325      no   no  cellular  13
## 657   39    management  married      no       0      no   no   unknown  27
## 658   45 self-employed divorced      no    -139     yes   no   unknown   7
## 659   46    unemployed  married      no    1040      no   no telephone  12
## 660   52      services  married      no     337     yes   no   unknown  19
## 661   38   blue-collar  married      no     171     yes  yes   unknown  20
## 662   25       student   single      no    2354      no   no  cellular  30
## 663   60    management   single      no       0      no  yes  cellular  23
## 664   49    management  married      no     412      no   no  cellular  21
## 665   65       retired  married      no    1973      no   no telephone  21
## 666   43    technician   single      no     293     yes   no   unknown  15
## 667   33      services  married      no     210     yes  yes   unknown  20
## 668   43 self-employed  married      no     819      no   no   unknown  20
## 669   26    management   single      no     948     yes   no  cellular  17
## 670   36        admin.  married      no     957     yes   no   unknown  21
## 671   53   blue-collar  married      no       0      no   no telephone  31
## 672   47   blue-collar  married      no    3696     yes   no  cellular  19
## 673   57    management  married      no    4547      no   no  cellular   7
## 674   37    management   single      no    8311     yes   no  cellular  16
## 675   23   blue-collar   single     yes    -207     yes   no   unknown   3
## 676   38    technician   single      no       0     yes   no   unknown   6
## 677   39  entrepreneur  married      no    1654      no   no  cellular  17
## 678   61       retired  married      no    2557     yes   no  cellular  10
## 679   60       retired  married      no    1720      no   no telephone   6
## 680   55        admin.  married      no     859      no   no telephone  12
## 681   50      services  married      no    2603      no   no  cellular  18
## 682   38   blue-collar  married      no     702      no   no   unknown  17
## 683   38    management   single      no     574     yes   no  cellular  28
## 684   52   blue-collar  married      no    -164      no   no  cellular  22
## 685   32        admin.  married      no    1974     yes   no   unknown  30
## 686   33        admin.   single      no    2557     yes   no  cellular  18
## 687   19       student   single      no     108      no   no  cellular   9
## 688   47        admin.  married      no     175     yes   no  cellular  26
## 689   44    management divorced      no     388     yes   no telephone  13
## 690   47    management   single      no       0      no   no  cellular  12
## 691   41        admin.  married      no       2     yes   no   unknown  19
## 692   37    technician  married      no    1707     yes   no  cellular  26
## 693   34    technician   single      no     666      no   no  cellular  21
## 694   38    technician  married      no    -267      no   no  cellular  11
## 695   30       student  married      no     324      no   no  cellular  25
## 696   22        admin.   single      no     118     yes   no   unknown  16
## 697   29   blue-collar   single      no     161      no  yes  cellular   7
## 698   54 self-employed  married      no     542      no   no telephone   6
## 699   31    technician  married      no    -292     yes  yes   unknown   3
## 700   36        admin.  married      no     421     yes   no  cellular  20
## 701   39   blue-collar  married      no    1360     yes   no  cellular  13
## 702   46    management  married      no     700      no  yes  cellular   7
## 703   56 self-employed  married      no    1539      no   no  cellular  28
## 704   22      services   single      no     395     yes   no   unknown  13
## 705   35        admin.   single      no    1537     yes   no  cellular   5
## 706   46        admin.  married      no     526      no  yes  cellular  31
## 707   27      services  married      no     100      no   no  cellular  16
## 708   50    management  married      no     619     yes   no telephone  25
## 709   30    management  married      no    1825     yes   no   unknown   9
## 710   39    management divorced      no     401      no   no   unknown   6
## 711   47        admin.  married      no    1156      no  yes   unknown   3
## 712   35   blue-collar   single      no     142     yes   no  cellular   7
## 713   28    management   single      no     265     yes   no  cellular  25
## 714   48   blue-collar  married      no     762     yes   no   unknown  12
## 715   33    technician  married      no       0     yes   no  cellular   4
## 716   36      services  married      no     812     yes  yes  cellular   2
## 717   38      services  married      no     611     yes  yes   unknown  18
## 718   41    technician  married      no     130      no   no   unknown  17
## 719   57        admin.  married      no    -967     yes   no telephone  15
## 720   35        admin.   single      no     148     yes   no   unknown   6
## 721   41        admin. divorced      no       4     yes   no  cellular   5
## 722   41     housemaid   single      no      21      no   no   unknown   6
## 723   31      services   single      no   11386     yes   no  cellular  20
## 724   34    management   single      no     673     yes  yes  cellular  20
## 725   34      services  married      no    1553     yes   no  cellular  20
## 726   43      services   single      no     193     yes   no   unknown   8
## 727   52      services  married      no     992     yes   no  cellular  27
## 728   31 self-employed   single      no     762      no   no  cellular  11
## 729   31    technician   single      no     335     yes   no   unknown  28
## 730   41    management   single      no    3371     yes  yes  cellular  13
## 731   38   blue-collar  married      no      49     yes   no   unknown   9
## 732   70       retired divorced      no     482      no   no telephone  14
## 733   19       student   single      no    1803      no   no  cellular  23
## 734   38   blue-collar  married      no     132     yes   no  cellular  14
## 735   39       retired   single      no     -79      no   no   unknown   9
## 736   36    management  married      no    1352      no   no   unknown  19
## 737   56    technician  married      no     147      no   no  cellular  12
## 738   29    management   single      no     308      no   no  cellular   4
## 739   33    management  married      no     -14     yes   no  cellular  20
## 740   48   blue-collar  married      no     794      no   no  cellular  11
## 741   43   blue-collar  married      no     794     yes   no  cellular  13
## 742   44    technician  married      no     331     yes   no  cellular  20
## 743   31    management   single      no     347     yes   no  cellular  27
## 744   54   blue-collar  married      no    2255      no   no  cellular  25
## 745   37 self-employed  married      no     129      no   no  cellular  18
## 746   28 self-employed   single      no     442      no   no  cellular  19
## 747   39        admin.  married     yes       0      no   no   unknown  29
## 748   29    unemployed  married      no     596      no   no  cellular  30
## 749   44   blue-collar  married      no    -431     yes   no   unknown  29
## 750   46   blue-collar  married      no    9083     yes   no  cellular   8
## 751   37    management   single      no      24     yes  yes  cellular  11
## 752   42   blue-collar  married      no    -150     yes   no  cellular  20
## 753   18       student   single      no     156      no   no  cellular   4
## 754   39        admin.  married      no    -982     yes  yes  cellular  19
## 755   58 self-employed  married      no    1407     yes   no   unknown  30
## 756   30   blue-collar   single      no     155     yes  yes  cellular   9
## 757   31       student   single      no    4951      no   no  cellular  17
## 758   30       student   single      no       0      no   no  cellular   6
## 759   44    management  married      no    7454      no   no   unknown   5
## 760   30    technician   single      no    6683      no   no  cellular  30
## 761   27       student   single      no       0      no   no   unknown   8
## 762   43    management  married      no     248      no   no  cellular   7
## 763   33    management   single      no    3161     yes   no  cellular   2
## 764   40   blue-collar  married      no     252     yes  yes  cellular   9
## 765   35    technician   single      no    1529      no   no   unknown  23
## 766   41     housemaid  married      no     304      no   no  cellular  20
## 767   31   blue-collar  married      no      42     yes   no   unknown   9
## 768   50   blue-collar  married      no     480     yes   no   unknown  20
## 769   59   blue-collar  married      no       0      no   no telephone  24
## 770   57       retired  married      no    -157      no   no  cellular  28
## 771   46        admin.  married      no       0     yes  yes  cellular  20
## 772   52   blue-collar  married      no    1860      no   no   unknown  20
## 773   47   blue-collar  married      no      85      no   no  cellular  25
## 774   46      services   single      no     454      no   no  cellular  24
## 775   40    management  married      no     229     yes   no  cellular  14
## 776   34      services divorced      no     202     yes   no   unknown  15
## 777   38   blue-collar   single      no    1137      no   no  cellular  13
## 778   52   blue-collar  married      no     568     yes   no telephone  17
## 779   50        admin.  married      no    -221      no  yes   unknown   3
## 780   50   blue-collar  married      no      37     yes  yes  cellular  31
## 781   27   blue-collar  married      no      52      no  yes  cellular   7
## 782   35    management  married      no    1650      no   no  cellular   8
## 783   30      services   single      no     542     yes   no   unknown   7
## 784   53    management  married      no    2693      no   no  cellular  21
## 785   19       student   single      no     134      no   no  cellular  27
## 786   36        admin.  married      no     194     yes  yes  cellular   7
## 787   53      services  married      no    2719     yes   no   unknown  30
## 788   30   blue-collar  married      no     364     yes  yes  cellular   4
## 789   53    technician divorced      no      45      no   no   unknown  28
## 790   30        admin.   single     yes    -242      no   no   unknown   4
## 791   27      services   single      no       1     yes  yes   unknown   2
## 792   51   blue-collar  married      no    -286     yes   no   unknown   9
## 793   27        admin.   single      no     261     yes  yes  cellular   3
## 794   46    management   single      no    5993      no   no  cellular  20
## 795   44    technician  married      no     358      no   no   unknown   5
## 796   39    management  married      no    1112      no   no  cellular   6
## 797   47    technician  married      no    -401     yes   no   unknown  23
## 798   35    technician divorced      no     515     yes  yes  cellular  29
## 799   37   blue-collar  married      no       6     yes   no  cellular  12
## 800   40 self-employed  married      no     355     yes   no  cellular  17
## 801   50   blue-collar  married      no      40     yes   no   unknown   8
## 802   24       student   single      no       0      no   no  cellular  13
## 803   34     housemaid  married      no     -97     yes  yes  cellular   8
## 804   55    management divorced      no    2625     yes   no  cellular   5
## 805   39        admin.  married      no     260     yes   no  cellular  13
## 806   34       unknown  married      no    4535      no   no  cellular   6
## 807   51    management  married      no     346      no   no  cellular  12
## 808   44 self-employed  married      no     335      no   no  cellular   2
## 809   48    technician  married      no     101     yes   no  cellular  29
## 810   45  entrepreneur  married      no     245     yes   no   unknown  14
## 811   37        admin. divorced      no       0      no   no  cellular  24
## 812   35        admin.  married      no     147     yes  yes  cellular  29
## 813   47   blue-collar  married      no     863     yes   no   unknown  19
## 814   35   blue-collar  married      no     270     yes  yes  cellular   6
## 815   32    unemployed  married      no      10     yes   no   unknown   6
## 816   39      services  married      no    1116     yes   no  cellular  30
## 817   41   blue-collar  married      no    1165      no   no   unknown  12
## 818   43    technician  married      no     533     yes   no  cellular  31
## 819   61    management  married      no    6016      no   no  cellular   4
## 820   50    management  married      no      85      no  yes  cellular   1
## 821   42   blue-collar  married      no     505     yes   no  cellular  15
## 822   47    management  married      no      -1      no   no  cellular   6
## 823   34    management  married      no      63      no   no  cellular  18
## 824   32    management  married      no    3517     yes   no   unknown  27
## 825   31      services  married      no    1670      no   no  cellular  18
## 826   44       retired  married      no     779     yes   no   unknown  21
## 827   45        admin.  married      no     142     yes  yes   unknown  29
## 828   39        admin.   single      no       0     yes   no   unknown   6
## 829   57       retired  married      no     211     yes   no   unknown   5
## 830   37   blue-collar  married      no      14     yes   no  cellular  31
## 831   39    management  married      no    1034     yes   no   unknown  30
## 832   69       retired divorced      no    4572      no   no  cellular  27
## 833   46    technician  married      no       0     yes   no  cellular  19
## 834   33    technician  married      no       0     yes   no   unknown   7
## 835   42     housemaid  married      no     341      no   no   unknown  24
## 836   32    management   single      no     593     yes   no  cellular  13
## 837   53    management  married      no     694      no   no   unknown  18
## 838   54      services   single      no     492      no   no   unknown   6
## 839   37 self-employed   single      no     125      no   no   unknown   5
## 840   43    management  married      no     587     yes   no  cellular   5
## 841   32   blue-collar  married      no     335     yes   no  cellular  13
## 842   40   blue-collar  married      no     104     yes   no  cellular  13
## 843   44    technician  married      no    7863      no   no  cellular  26
## 844   31   blue-collar   single      no    1124     yes   no  cellular  18
## 845   45   blue-collar  married      no     803     yes   no  cellular   4
## 846   26        admin.   single      no     483     yes   no  cellular  18
## 847   46    management  married      no    9678     yes   no  cellular  17
## 848   46    technician  married      no     591      no   no telephone  29
## 849   59      services  married      no     -22     yes   no   unknown  26
## 850   32   blue-collar  married      no     -94     yes  yes  cellular  11
## 851   37    management   single      no   22125      no  yes  cellular  21
## 852   54    technician  married      no       0      no   no  cellular  30
## 853   53      services  married      no      -2     yes  yes  cellular  16
## 854   47        admin.  married      no    3676      no   no  cellular  15
## 855   52      services divorced      no      36     yes  yes  cellular  11
## 856   46   blue-collar   single      no       0     yes   no  cellular   8
## 857   24       student   single      no   23878      no   no  cellular  26
## 858   47   blue-collar  married      no     259      no   no  cellular  25
## 859   33 self-employed  married      no    1676     yes   no  cellular  12
## 860   30    management  married      no      24     yes   no  cellular  29
## 861   51 self-employed divorced      no     154     yes   no   unknown  15
## 862   46      services  married     yes     130      no   no  cellular  20
## 863   56    technician   single      no     145     yes   no telephone   6
## 864   42    unemployed  married      no     576      no   no  cellular   3
## 865   39        admin.  married      no      15      no   no   unknown   5
## 866   46     housemaid  married      no     269      no   no  cellular   8
## 867   26    management   single      no    1623      no   no  cellular   2
## 868   36        admin.   single      no     449     yes   no   unknown  20
## 869   35    management divorced      no    6997     yes   no  cellular   9
## 870   40    unemployed   single      no      97     yes  yes  cellular   2
## 871   60      services  married      no    8837     yes   no   unknown  16
## 872   41   blue-collar divorced      no    2195     yes   no   unknown   3
## 873   37 self-employed  married      no    8230     yes   no  cellular  17
## 874   48   blue-collar   single      no    -269      no   no  cellular   2
## 875   44    technician  married      no    1226     yes  yes  cellular  29
## 876   32   blue-collar  married     yes    -148     yes   no  cellular   4
## 877   52      services divorced      no     238     yes   no  cellular   6
## 878   19       student   single      no     526      no   no  cellular   1
## 879   62    technician  married      no     635      no   no  cellular  22
## 880   34   blue-collar  married      no       7     yes  yes  cellular   2
## 881   45    technician  married      no    -847      no  yes  cellular  22
## 882   47    technician  married      no    1059     yes   no  cellular  21
## 883   41    technician  married      no     902      no   no   unknown  16
## 884   80       retired  married      no    1468      no   no  cellular  13
## 885   32    technician   single      no      82      no   no  cellular  18
## 886   31    management  married      no     877      no   no  cellular   9
## 887   39    management   single      no    2258     yes   no  cellular  31
## 888   27    management   single      no    6791      no   no  cellular  24
## 889   42  entrepreneur  married      no    -480     yes  yes   unknown   2
## 890   40      services divorced      no     160      no   no  cellular  14
## 891   30    technician   single      no       0      no   no  cellular  22
## 892   35   blue-collar   single      no     546     yes   no  cellular  13
## 893   30    management   single      no    1761     yes   no  cellular  15
## 894   44      services divorced      no     396     yes  yes   unknown   7
## 895   45   blue-collar  married      no    1335     yes   no  cellular  12
## 896   36      services   single      no     174     yes   no   unknown   7
## 897   27  entrepreneur  married      no      97     yes  yes  cellular  18
## 898   25   blue-collar   single      no       0     yes   no   unknown  15
## 899   32   blue-collar   single      no    1137     yes  yes  cellular   6
## 900   34    technician  married      no     555     yes   no  cellular   7
## 901   45   blue-collar  married      no      42     yes   no   unknown  19
## 902   38   blue-collar   single      no     522     yes   no   unknown  29
## 903   37 self-employed   single      no     281     yes   no   unknown   5
## 904   57    technician  married      no   27069      no  yes   unknown  20
## 905   25      services   single      no    2022      no   no  cellular  29
## 906   38    management   single      no    1495     yes   no  cellular  30
## 907   25    technician   single      no    1693      no   no  cellular   5
## 908   41     housemaid  married      no    1529      no   no  cellular   7
## 909   27    management   single      no     148     yes   no  cellular  31
## 910   57   blue-collar  married      no      24      no   no   unknown  16
## 911   33 self-employed  married      no     483     yes   no  cellular   3
## 912   46   blue-collar  married      no     877      no   no  cellular  29
## 913   30    technician  married      no    3418      no   no  cellular  25
## 914   43      services  married      no    2557     yes   no telephone  15
## 915   32    technician divorced      no       2     yes   no   unknown  11
## 916   51   blue-collar  married      no    2832     yes   no  cellular  20
## 917   43    management  married      no       0     yes   no  cellular  17
## 918   28   blue-collar  married      no      86     yes  yes   unknown  15
## 919   34        admin.  married      no    1406     yes   no  cellular  27
## 920   30    management  married      no   11391     yes   no  cellular  20
## 921   27    management  married      no    1918      no   no  cellular   9
## 922   42        admin. divorced      no    2129      no   no  cellular  13
## 923   38        admin.   single      no    -327      no   no  cellular  22
## 924   36   blue-collar   single      no     736     yes   no  cellular  16
## 925   50    management   single      no     297     yes   no   unknown   5
## 926   34   blue-collar  married      no    2308     yes   no   unknown   7
## 927   49    management  married      no      99     yes   no  cellular   6
## 928   24       student   single      no     382      no   no  cellular  13
## 929   57    management divorced      no       0      no   no   unknown  16
## 930   29        admin.  married      no     535      no   no  cellular  11
## 931   29   blue-collar   single      no     770     yes   no  cellular  17
## 932   79       retired  married      no    2661      no   no  cellular  10
## 933   31   blue-collar  married      no    3659      no   no   unknown   2
## 934   31        admin.   single      no    3323     yes   no  cellular   9
## 935   41    management  married      no      20     yes   no  cellular  17
## 936   56       retired divorced      no     275     yes  yes  cellular  10
## 937   38    technician  married      no   -1038      no  yes  cellular  23
## 938   37   blue-collar   single      no     690     yes   no  cellular  18
## 939   41    technician  married      no     994      no   no  cellular  22
## 940   31    management   single      no     775     yes   no  cellular  20
## 941   27       student   single      no     279      no   no  cellular  12
## 942   52  entrepreneur divorced      no     105      no  yes telephone  22
## 943   27   blue-collar   single      no     484     yes   no  cellular  15
## 944   40   blue-collar  married      no       0     yes   no   unknown   6
## 945   23      services   single      no     870      no   no  cellular   6
## 946   43    management  married      no      -8     yes   no   unknown  20
## 947   41      services  married      no     124     yes   no   unknown  16
## 948   46        admin. divorced      no    1203      no   no  cellular  30
## 949   31        admin.   single      no     355     yes   no  cellular  12
## 950   48   blue-collar  married      no     448     yes   no   unknown   8
## 951   46    technician  married      no    2501      no   no  cellular  26
## 952   33   blue-collar  married      no      53      no   no  cellular  20
## 953   65       retired  married      no   23421      no   no  cellular   2
## 954   65       retired  married      no    3713      no   no  cellular   7
## 955   27       student   single      no   16173     yes   no   unknown  28
## 956   27        admin.  married      no      53     yes   no  cellular  18
## 957   39    management  married      no     271     yes   no  cellular   8
## 958   30        admin.   single      no     732      no   no  cellular  20
## 959   55    management  married      no     338     yes   no  cellular  14
## 960   58       retired  married      no     662     yes   no  cellular   2
## 961   35        admin.  married      no    1994      no   no  cellular   9
## 962   52    unemployed  married      no      94      no   no  cellular   4
## 963   34        admin. divorced      no     -75      no   no  cellular   3
## 964   37    technician  married      no     732      no   no  cellular  25
## 965   29    technician  married      no     767     yes   no  cellular   5
## 966   28    management   single      no    1335      no  yes   unknown   4
## 967   60       unknown  married      no    4722      no   no   unknown  20
## 968   44    unemployed  married      no     280     yes   no   unknown   5
## 969   36   blue-collar  married      no      29     yes  yes  cellular  31
## 970   27   blue-collar   single      no    1049      no   no telephone  29
## 971   42   blue-collar divorced      no     299     yes   no  cellular  29
## 972   35   blue-collar  married      no    2643     yes   no  cellular   2
## 973   61       unknown   single      no      50      no   no telephone  21
## 974   31    technician   single      no    1214      no   no  cellular   3
## 975   29    management  married      no     103     yes   no  cellular  17
## 976   40   blue-collar  married      no     326     yes  yes  cellular   7
## 977   53   blue-collar  married      no    4793     yes   no telephone  20
## 978   35    management  married      no     272     yes  yes  cellular  11
## 979   26    management   single      no     962     yes   no  cellular   8
## 980   51       retired  married      no     965     yes   no  cellular  28
## 981   55       retired  married      no     -90     yes  yes   unknown   7
## 982   47    management  married      no    6637     yes   no  cellular  17
## 983   46   blue-collar  married      no     431     yes   no  cellular  14
## 984   28    management   single      no    4937     yes   no telephone  13
## 985   47      services  married      no     216     yes   no  cellular  12
## 986   29        admin.  married      no     943     yes   no   unknown   4
## 987   45  entrepreneur  married      no       1      no   no  cellular  19
## 988   41    management  married      no    5585      no   no   unknown   9
## 989   33 self-employed  married      no    -103     yes   no   unknown  28
## 990   32    management  married      no    4733      no   no  cellular  30
## 991   55     housemaid  married      no     139      no   no  cellular  22
## 992   29    management  married      no      16     yes   no  cellular  16
## 993   35    management  married      no     616      no  yes  cellular   7
## 994   55    management  married      no    1433      no   no   unknown  12
## 995   31 self-employed   single      no    2589      no   no  cellular  21
## 996   56    management  married      no    5282      no   no  cellular  17
## 997   43   blue-collar  married      no     232      no  yes  cellular  15
## 998   33    management divorced      no     893     yes   no  cellular  29
## 999   48       retired divorced      no     666     yes   no  cellular  15
## 1000  45        admin.  married      no     180     yes   no   unknown   9
## 1001  31      services  married      no    -732     yes   no   unknown   8
## 1002  56    management  married      no    1390     yes   no  cellular  18
## 1003  57     housemaid  married      no     501     yes  yes  cellular  11
## 1004  30        admin.   single      no     382     yes   no  cellular  19
## 1005  51   blue-collar divorced      no     -28      no  yes   unknown   2
## 1006  33 self-employed  married      no     666     yes   no  cellular  16
## 1007  43    management  married      no    1800      no   no telephone  29
## 1008  55    technician   single      no    3339     yes   no   unknown   2
## 1009  30    technician  married      no     526     yes  yes   unknown  26
## 1010  36    unemployed  married     yes    -318     yes   no   unknown  15
## 1011  50    management  married      no    2910      no   no telephone  19
## 1012  31   blue-collar   single      no     411      no   no  cellular  21
## 1013  55    technician  married      no       0      no   no  cellular  17
## 1014  31    management   single      no     471      no   no  cellular  29
## 1015  54       retired divorced      no    2761      no   no  cellular  16
## 1016  59    technician  married      no    4243     yes   no   unknown  29
## 1017  38  entrepreneur  married      no     197      no   no   unknown  17
## 1018  46    management divorced      no     225     yes   no  cellular  14
## 1019  54   blue-collar  married      no    1765     yes   no   unknown  14
## 1020  58       retired divorced      no     312      no   no  cellular   7
## 1021  71       retired divorced      no    3104      no   no telephone  12
## 1022  45       unknown  married      no    2834      no   no  cellular   4
## 1023  32    unemployed  married      no    2400     yes  yes  cellular   5
## 1024  46      services  married      no      72     yes   no  cellular  15
## 1025  48    management divorced      no     148      no   no  cellular  12
## 1026  53      services divorced      no     765     yes   no  cellular  14
## 1027  40   blue-collar   single      no    3571     yes   no  cellular  10
## 1028  55    management divorced      no     608     yes   no  cellular   7
## 1029  32      services   single      no    -408     yes   no   unknown  23
## 1030  38    management divorced      no    5455     yes   no   unknown  27
## 1031  35   blue-collar   single      no     907     yes  yes   unknown   8
## 1032  39 self-employed  married      no     266      no   no  cellular  11
## 1033  43   blue-collar  married      no      30      no   no  cellular  14
## 1034  48   blue-collar  married      no     554      no   no   unknown  16
## 1035  35 self-employed  married      no    1340      no  yes  cellular  19
## 1036  58        admin.  married      no    2777     yes   no telephone   2
## 1037  28   blue-collar  married      no     -26      no  yes  cellular  30
## 1038  36   blue-collar  married      no    -742     yes  yes  cellular  31
## 1039  44    management  married      no    1242     yes   no  cellular   6
## 1040  36    technician  married      no     361      no   no  cellular   6
## 1041  37    technician divorced      no    1176      no  yes   unknown  21
## 1042  52    technician  married      no     876      no   no  cellular   4
## 1043  33    management  married      no     876      no   no   unknown  20
## 1044  52    management divorced      no      12     yes   no   unknown  30
## 1045  50    management  married      no    1165      no   no  cellular  16
## 1046  36    management   single      no    4788     yes   no  cellular  16
## 1047  34    technician   single      no    2660     yes   no  cellular  15
## 1048  54    management divorced      no     155     yes   no   unknown  14
## 1049  32      services  married      no    2578      no   no  cellular  29
## 1050  48    management   single      no    -295      no  yes  cellular  28
## 1051  34    technician   single      no       0      no   no telephone  10
## 1052  32   blue-collar   single      no     181     yes   no  cellular   6
## 1053  53   blue-collar  married      no    1311      no   no telephone  14
## 1054  52    technician  married      no    2709     yes   no telephone   9
## 1055  36   blue-collar  married      no     537      no  yes  cellular   7
## 1056  42      services  married      no     146     yes  yes  cellular  15
## 1057  38  entrepreneur  married      no    1134     yes   no  cellular   7
## 1058  48  entrepreneur   single      no       0     yes   no  cellular   6
## 1059  30      services   single      no     732     yes   no  cellular  17
## 1060  36    technician divorced      no     556     yes   no  cellular  18
## 1061  48    management divorced     yes    -625     yes   no   unknown  29
## 1062  38    management   single      no    3813      no   no  cellular   7
## 1063  27    management  married      no      33     yes   no  cellular  18
## 1064  48        admin. divorced      no    -480      no   no  cellular  18
## 1065  36   blue-collar  married      no    -453     yes   no   unknown  19
## 1066  41  entrepreneur  married      no     187      no  yes  cellular  21
## 1067  46    technician   single      no       0      no   no  cellular  19
## 1068  60   blue-collar divorced      no       0     yes   no   unknown  29
## 1069  40   blue-collar  married      no      98     yes   no  cellular  11
## 1070  46   blue-collar  married     yes    -388      no   no  cellular  18
## 1071  45    management  married      no    9711      no   no   unknown  19
## 1072  30    management  married      no     168     yes   no  cellular  18
## 1073  60        admin.  married      no      39     yes  yes   unknown   5
## 1074  34    management   single      no     382      no   no  cellular   3
## 1075  37   blue-collar   single      no    2032     yes   no   unknown  21
## 1076  28    management  married      no    3694      no  yes  cellular   8
## 1077  43      services divorced      no     957      no  yes  cellular  22
## 1078  56   blue-collar  married      no     690     yes   no   unknown  15
## 1079  30    management  married      no     859     yes   no   unknown  20
## 1080  49   blue-collar divorced      no     235      no   no  cellular  29
## 1081  41    management  married      no   27696      no   no  cellular  12
## 1082  28    technician  married      no     858     yes   no  cellular  17
## 1083  36    management   single      no    3875     yes   no  cellular  11
## 1084  35      services divorced      no     440     yes   no  cellular   5
## 1085  39    technician  married      no     192     yes  yes   unknown  29
## 1086  32    technician  married      no     344     yes   no  cellular  20
## 1087  50   blue-collar  married      no   12519     yes   no  cellular  21
## 1088  49 self-employed  married      no     294     yes   no   unknown   2
## 1089  40   blue-collar  married      no    4608     yes   no telephone  19
## 1090  41        admin. divorced      no    1634     yes  yes  cellular  12
## 1091  26        admin.   single      no    1327      no   no  cellular  30
## 1092  37    management  married      no     238      no   no  cellular   3
## 1093  50    technician  married      no    -353     yes  yes  cellular  18
## 1094  57       retired   single      no     976     yes   no  cellular   9
## 1095  33    technician divorced      no    1480     yes   no  cellular   5
## 1096  55    management  married      no    1185      no   no   unknown   5
## 1097  39    management   single      no     139      no   no  cellular  22
## 1098  51        admin.  married      no     531     yes   no   unknown   5
## 1099  27 self-employed   single      no     168      no   no  cellular  12
## 1100  80       retired  married      no    8304      no   no telephone   9
## 1101  36    management   single      no     811      no   no  cellular   6
## 1102  44      services  married      no    4786     yes  yes  cellular  12
## 1103  46    technician  married      no    1465     yes   no   unknown  14
## 1104  39   blue-collar  married      no     579     yes  yes  cellular   5
## 1105  31   blue-collar  married      no     591     yes   no   unknown  14
## 1106  59     housemaid  married      no     352      no   no telephone  21
## 1107  59    management  married      no    7049      no   no   unknown  11
## 1108  30    management   single      no    8101     yes   no  cellular  21
## 1109  31    management   single      no       3      no   no  cellular   4
## 1110  66     housemaid  married      no      40      no   no telephone  14
## 1111  53   blue-collar  married      no    4380      no   no telephone  19
## 1112  59 self-employed  married      no    3800      no  yes  cellular   9
## 1113  26   blue-collar  married      no    -219     yes  yes   unknown  15
## 1114  35   blue-collar  married      no    4723     yes   no   unknown  16
## 1115  36    management  married      no    2326     yes   no  cellular  20
## 1116  31    technician   single      no    1166     yes   no   unknown   3
## 1117  30        admin.  married      no     874     yes   no  cellular  22
## 1118  33    management  married      no     307      no   no   unknown  16
## 1119  57    technician  married      no       0      no   no  cellular  16
## 1120  27        admin.   single      no     110     yes   no   unknown  28
## 1121  37     housemaid   single      no    1358      no   no telephone  28
## 1122  47    management   single      no      86      no   no  cellular  30
## 1123  39    management  married      no    1423     yes   no telephone  21
## 1124  32    technician divorced      no    2870      no   no  cellular  18
## 1125  33     housemaid  married      no       0      no   no  cellular   8
## 1126  51  entrepreneur   single      no     440      no   no   unknown  18
## 1127  45    technician   single      no       0      no   no  cellular  18
## 1128  43    technician divorced      no    1413     yes   no telephone  28
## 1129  53     housemaid divorced      no     292      no   no   unknown  12
## 1130  55    technician  married      no     273     yes   no  cellular  29
## 1131  36 self-employed  married      no    1245     yes   no  cellular   9
## 1132  34   blue-collar  married      no    -480     yes  yes  cellular   8
## 1133  37     housemaid   single      no       0      no   no  cellular  28
## 1134  46   blue-collar  married      no     572     yes   no   unknown   3
## 1135  37    management  married      no     247      no   no  cellular   9
## 1136  29    technician  married      no     428      no   no  cellular  14
## 1137  40    management   single      no    1247     yes   no  cellular   9
## 1138  34   blue-collar divorced      no    1125     yes  yes  cellular  19
## 1139  59   blue-collar  married      no    -162     yes  yes   unknown  20
## 1140  41      services  married      no     803     yes   no  cellular   9
## 1141  27        admin.  married      no    4144     yes   no   unknown   4
## 1142  33    management   single      no     372     yes  yes  cellular   6
## 1143  36   blue-collar  married      no     199     yes   no   unknown  12
## 1144  37      services  married      no     -24     yes   no   unknown  27
## 1145  52        admin.  married      no       0      no   no  cellular  22
## 1146  51    management divorced      no     119      no   no   unknown   5
## 1147  32    technician   single      no      28     yes   no  cellular  17
## 1148  45    management  married      no    -191     yes   no  cellular  18
## 1149  38    management  married      no    2656      no   no  cellular   8
## 1150  57       retired divorced     yes       0      no  yes  cellular  24
## 1151  24    management   single      no      66     yes   no   unknown  26
## 1152  46    management  married      no      10     yes   no  cellular  29
## 1153  46    management  married      no     477     yes   no   unknown  20
## 1154  51    management  married      no    -714      no   no  cellular  18
## 1155  48    management  married     yes    -998     yes   no  cellular  18
## 1156  44    management  married      no    6203     yes  yes  cellular  17
## 1157  37   blue-collar   single      no    2390     yes   no  cellular  20
## 1158  35    management   single      no     714     yes   no  cellular  26
## 1159  40  entrepreneur  married      no    2252      no   no   unknown  12
## 1160  35    management   single      no     244     yes   no   unknown  12
## 1161  34        admin.  married      no     445      no   no  cellular  19
## 1162  32   blue-collar  married      no      25     yes   no  cellular   6
## 1163  37    management   single      no     242      no  yes  cellular  28
## 1164  53   blue-collar  married      no     252      no   no  cellular  31
## 1165  56       retired  married      no       5      no   no  cellular  23
## 1166  37        admin.   single      no    1113     yes   no   unknown   9
## 1167  52        admin.  married      no       0      no  yes telephone   9
## 1168  29      services  married      no       3     yes   no  cellular  10
## 1169  56    unemployed  married      no     216      no   no   unknown  19
## 1170  41   blue-collar  married      no    4910     yes   no  cellular   3
## 1171  56    management  married      no    -155     yes   no  cellular  17
## 1172  37     housemaid divorced      no    1040     yes   no  cellular  13
## 1173  55       retired  married      no     991      no   no  cellular  11
## 1174  53    management divorced      no    3158      no   no  cellular  31
## 1175  47      services  married      no     665     yes   no  cellular  20
## 1176  48   blue-collar   single      no     339      no  yes telephone  14
## 1177  79       retired divorced      no    1910      no   no telephone  24
## 1178  58    technician  married      no    -205     yes   no   unknown   3
## 1179  32        admin.   single      no     212      no   no  cellular   7
## 1180  59    management   single      no     181     yes   no   unknown   9
## 1181  34    management   single      no     681      no   no  cellular   6
## 1182  44        admin.  married      no     348     yes  yes  cellular  16
## 1183  48    management  married      no    1167     yes  yes  cellular  26
## 1184  50    management  married      no    8345      no   no   unknown  11
## 1185  43    management  married      no    8167     yes   no   unknown  19
## 1186  34   blue-collar  married      no       0     yes  yes   unknown  20
## 1187  36    technician   single      no    1044     yes   no  cellular  20
## 1188  53    technician  married      no    2242      no   no  cellular  10
## 1189  29        admin.   single      no     345     yes  yes  cellular  30
## 1190  52    technician  married      no     668     yes   no  cellular  31
## 1191  39    management  married      no     151     yes   no   unknown  21
## 1192  45    management  married      no    2897      no   no  cellular   2
## 1193  41    technician   single      no    5365     yes   no  cellular   7
## 1194  39    management  married      no     763     yes   no  cellular  11
## 1195  27       student   single      no     672      no   no  cellular  18
## 1196  37    management  married      no    3723      no   no  cellular  22
## 1197  46   blue-collar  married      no      -3     yes   no  cellular  29
## 1198  40      services  married      no    3164     yes   no  cellular   3
## 1199  57    management divorced      no     429     yes   no  cellular  17
## 1200  26   blue-collar   single      no     474     yes   no  cellular  15
## 1201  28      services   single      no     341     yes   no  cellular  15
## 1202  34   blue-collar  married      no     800      no   no  cellular   5
## 1203  29        admin.   single      no     788     yes   no  cellular  18
## 1204  35   blue-collar  married      no    2708     yes   no   unknown  30
## 1205  59   blue-collar  married      no     202     yes   no   unknown   7
## 1206  54   blue-collar   single      no    1555     yes   no telephone  30
## 1207  32    management  married      no     905      no   no  cellular  12
## 1208  57       retired  married      no    5313      no   no  cellular  16
## 1209  39    unemployed   single      no    -114     yes   no  cellular   3
## 1210  41        admin.   single      no    5219     yes   no  cellular  17
## 1211  31    management   single      no     357     yes   no   unknown  23
## 1212  37    unemployed  married      no      86      no   no  cellular  29
## 1213  52        admin.  married      no    3703     yes   no  cellular  23
## 1214  39    management   single      no     416      no   no  cellular   9
## 1215  23        admin.   single      no       0     yes   no  cellular  17
## 1216  46    management divorced      no     507     yes   no  cellular   1
## 1217  34        admin.   single      no     458     yes   no   unknown  20
## 1218  31   blue-collar divorced      no    -209     yes   no  cellular   8
## 1219  38    technician  married      no    2000     yes   no  cellular   7
## 1220  28    management  married      no      82     yes  yes   unknown  16
## 1221  41        admin.   single      no     882     yes  yes   unknown  28
## 1222  30   blue-collar  married      no     -71     yes   no  cellular   6
## 1223  34    management   single      no    1494     yes   no  cellular  18
## 1224  56        admin. divorced      no     985      no  yes  cellular  18
## 1225  32     housemaid  married      no       7      no  yes   unknown  27
## 1226  39        admin.  married      no     260     yes   no  cellular  17
## 1227  26   blue-collar   single      no      52     yes   no  cellular  20
## 1228  35   blue-collar divorced      no    3547     yes   no  cellular  19
## 1229  30      services   single      no    3485      no   no  cellular   2
## 1230  44   blue-collar  married      no     701      no  yes  cellular  21
## 1231  57       retired  married      no      70     yes  yes   unknown  16
## 1232  52    management  married      no    1392      no   no  cellular  28
## 1233  30    management  married      no     151      no   no  cellular  21
## 1234  41   blue-collar  married      no     946     yes   no   unknown   6
## 1235  61    management  married      no    1471      no   no  cellular  12
## 1236  52    management  married      no    1545      no   no   unknown  20
## 1237  60        admin. divorced      no     791     yes   no   unknown  13
## 1238  50    management  married      no    2130      no   no  cellular  20
## 1239  45   blue-collar  married      no     900     yes   no   unknown   9
## 1240  51    management  married      no    1612     yes   no  cellular  18
## 1241  38    management  married      no    5432     yes  yes  cellular  17
## 1242  47   blue-collar  married      no    1092      no  yes   unknown  30
## 1243  43    management  married      no    1050     yes  yes  cellular  18
## 1244  36    technician  married      no      -8     yes   no   unknown  26
## 1245  54   blue-collar  married      no     781     yes   no   unknown   9
## 1246  38       unknown   single      no       0      no   no  cellular  11
## 1247  56    technician  married      no     203     yes   no  cellular   5
## 1248  31    technician   single      no     102     yes   no telephone  17
## 1249  33    management   single      no       0      no   no  cellular  20
## 1250  57    unemployed  married      no     381      no   no  cellular  29
## 1251  44    management  married      no    -600     yes   no  cellular  18
## 1252  32    management   single      no       0     yes   no  cellular  30
## 1253  35    technician  married      no     944      no   no  cellular   8
## 1254  49      services  married      no     725      no  yes   unknown  14
## 1255  23    management   single      no    2143      no   no  cellular  30
## 1256  49        admin.  married      no     255     yes   no  cellular  30
## 1257  53   blue-collar  married      no      70     yes   no   unknown   5
## 1258  34  entrepreneur  married      no    -506      no   no  cellular  29
## 1259  57   blue-collar  married      no    3109      no   no  cellular   2
## 1260  37      services  married      no      78     yes   no   unknown   7
## 1261  27        admin.  married      no     941     yes   no  cellular  11
## 1262  40      services  married      no      33      no   no   unknown  26
## 1263  38    management  married      no       0     yes   no  cellular  30
## 1264  40   blue-collar  married      no     105     yes   no  cellular  14
## 1265  28   blue-collar   single      no      56     yes   no   unknown  23
## 1266  36 self-employed  married      no    1006     yes   no  cellular  21
## 1267  39   blue-collar  married      no    2366     yes   no  cellular  16
## 1268  40    technician   single      no    1646     yes   no  cellular   4
## 1269  34   blue-collar divorced      no     368      no  yes  cellular   7
## 1270  29       student   single      no     652     yes   no  cellular  22
## 1271  43        admin.   single      no    -247     yes  yes  cellular   2
## 1272  35   blue-collar  married      no       0     yes  yes   unknown  29
## 1273  37    management  married      no    3794      no   no  cellular  18
## 1274  31        admin.  married      no      62      no   no  cellular  17
## 1275  41    management   single      no    1286     yes   no telephone  17
## 1276  36    management  married      no    2309     yes   no  cellular   8
## 1277  33   blue-collar  married      no     249     yes   no  cellular  31
## 1278  30    management   single      no   19358      no   no  cellular  19
## 1279  52   blue-collar  married      no     289     yes   no   unknown  21
## 1280  40    management  married      no       0     yes  yes  cellular  24
## 1281  38      services  married      no      53      no   no  cellular   4
## 1282  60       retired  married      no    2868      no   no   unknown  20
## 1283  32 self-employed  married      no     514     yes   no  cellular  11
## 1284  44    technician  married      no     135     yes   no  cellular   8
## 1285  31 self-employed  married      no      94      no   no  cellular  22
## 1286  29    unemployed   single      no     550      no   no  cellular  29
## 1287  37    management  married      no    5205     yes   no   unknown  23
## 1288  33    technician  married      no    2362     yes   no  cellular  26
## 1289  34    technician   single      no    1313      no   no  cellular  22
## 1290  30    management  married      no    8623      no   no  cellular   8
## 1291  47      services  married      no     543     yes   no   unknown  15
## 1292  41    management divorced      no      47     yes   no   unknown   8
## 1293  58    management  married      no    3658      no   no  cellular   4
## 1294  42 self-employed  married      no     596     yes   no   unknown  19
## 1295  46   blue-collar  married      no     174     yes  yes   unknown   8
## 1296  29    management   single      no     345      no   no  cellular  16
## 1297  32    technician   single      no     723      no   no  cellular  28
## 1298  24        admin.   single      no     507     yes   no   unknown  13
## 1299  28        admin.  married      no     576     yes  yes  cellular  18
## 1300  36    technician divorced      no     515     yes  yes  cellular   8
## 1301  32      services   single      no     406     yes   no   unknown   6
## 1302  40   blue-collar   single      no     322     yes   no  cellular   7
## 1303  48    technician  married      no    2688      no  yes  cellular  26
## 1304  52    management  married      no     193      no   no  cellular  30
## 1305  39    technician divorced      no     394     yes   no   unknown  29
## 1306  32      services   single      no     101     yes   no  cellular  11
## 1307  42 self-employed  married      no    6383      no   no  cellular  27
## 1308  27      services   single      no    1636     yes   no   unknown  28
## 1309  60    management divorced      no       0      no   no  cellular   5
## 1310  24    unemployed  married      no       6      no   no   unknown  17
## 1311  57      services  married      no     668     yes  yes telephone  18
## 1312  39 self-employed  married      no    1492     yes   no  cellular  25
## 1313  30      services   single      no     438     yes   no  cellular  18
## 1314  50    technician  married      no    2313      no   no  cellular   5
## 1315  49    management  married      no       1      no   no telephone   4
## 1316  54   blue-collar  married      no    1223     yes   no  cellular   7
## 1317  49  entrepreneur  married      no     388     yes   no   unknown  16
## 1318  42      services  married      no     120     yes   no  cellular  17
## 1319  42      services  married      no     473     yes   no  cellular  30
## 1320  35   blue-collar  married      no      26     yes   no   unknown   2
## 1321  49        admin.  married      no    -962     yes   no  cellular  19
## 1322  42   blue-collar   single      no     382     yes   no  cellular  13
## 1323  29       student   single      no    2929      no   no  cellular   5
## 1324  42    management divorced      no     764      no  yes  cellular  21
## 1325  35 self-employed   single      no       0     yes  yes  cellular  18
## 1326  52      services  married      no    2257     yes   no   unknown  14
## 1327  48       retired  married     yes    -285      no  yes  cellular  19
## 1328  42      services  married      no     199      no   no  cellular  30
## 1329  51       unknown   single      no       0      no   no   unknown   5
## 1330  48   blue-collar   single      no     574      no   no  cellular  12
## 1331  31    technician   single      no     538     yes   no  cellular  17
## 1332  33   blue-collar divorced      no     176     yes   no   unknown  12
## 1333  62  entrepreneur  married      no    3904      no   no telephone  29
## 1334  29   blue-collar  married      no       1     yes   no   unknown   6
## 1335  28   blue-collar   single      no     431     yes   no  cellular  13
## 1336  37    management  married      no     789     yes  yes  cellular  11
## 1337  34    technician  married      no       1      no  yes   unknown  25
## 1338  42       retired  married      no     127      no  yes  cellular  17
## 1339  32    technician   single      no     502     yes   no telephone  20
## 1340  42    technician  married      no     849      no   no  cellular  13
## 1341  30   blue-collar  married      no    1780     yes   no   unknown  28
## 1342  31   blue-collar  married      no     822     yes   no   unknown  13
## 1343  45   blue-collar  married      no     146     yes  yes   unknown   5
## 1344  54    management  married      no      11      no   no   unknown  14
## 1345  38        admin.  married      no    3632     yes  yes  cellular  13
## 1346  36      services  married      no       0      no   no   unknown  29
## 1347  28        admin.   single      no     230      no   no  cellular  25
## 1348  49    technician  married      no      15      no   no   unknown   6
## 1349  34      services   single      no    3080      no   no  cellular  29
## 1350  52  entrepreneur divorced      no     302      no   no   unknown  19
## 1351  39   blue-collar  married      no       0     yes   no   unknown  26
## 1352  39    management  married      no     197     yes   no  cellular  15
## 1353  71       retired   single      no    1285      no   no telephone  27
## 1354  48   blue-collar  married      no    1143     yes   no  cellular  17
## 1355  27    management   single      no     406      no   no  cellular   9
## 1356  66 self-employed  married      no     147      no   no telephone  12
## 1357  36    management divorced      no      59      no   no  cellular  13
## 1358  49 self-employed  married      no      99     yes  yes  cellular  31
## 1359  51   blue-collar  married      no     814     yes   no  cellular  14
## 1360  46 self-employed  married      no     -80     yes   no   unknown  12
## 1361  54   blue-collar  married      no     175     yes   no  cellular   3
## 1362  57  entrepreneur divorced      no     873      no   no   unknown  17
## 1363  56 self-employed  married      no     350      no   no  cellular   3
## 1364  39   blue-collar  married      no    2805     yes   no   unknown  26
## 1365  61     housemaid  married      no     368      no   no  cellular   8
## 1366  50   blue-collar  married      no    1329     yes  yes telephone   4
## 1367  53   blue-collar divorced      no     235      no   no  cellular  30
## 1368  30   blue-collar  married      no    -166     yes  yes   unknown  13
## 1369  49     housemaid  married      no     360      no   no   unknown  30
## 1370  44      services  married      no   29312      no   no   unknown  13
## 1371  24   blue-collar   single      no    1857     yes   no  cellular   8
## 1372  30        admin.   single      no     110      no   no  cellular  28
## 1373  34   blue-collar  married      no     187     yes   no   unknown  12
## 1374  33      services  married      no      28      no   no  cellular  29
## 1375  27   blue-collar   single      no     100     yes   no  cellular  11
## 1376  42   blue-collar divorced      no      28     yes   no  cellular   8
## 1377  45    unemployed   single      no     382     yes  yes  cellular  18
## 1378  34        admin.  married      no    1183     yes   no  cellular  20
## 1379  36  entrepreneur  married      no     229     yes   no  cellular  28
## 1380  51    management  married      no     346      no   no  cellular  11
## 1381  27    management   single      no     102      no   no   unknown  26
## 1382  45    management  married      no    5888     yes   no   unknown  26
## 1383  34   blue-collar  married      no    3990     yes   no  cellular  24
## 1384  38    management  married      no    7124      no   no   unknown  16
## 1385  53    technician divorced      no     447     yes  yes  cellular  11
## 1386  59       retired divorced      no     914      no   no  cellular  28
## 1387  36   blue-collar  married      no     801     yes  yes  cellular  18
## 1388  33        admin.   single      no     572     yes   no  cellular  14
## 1389  33        admin.   single      no    -371     yes  yes  cellular  18
## 1390  37        admin. divorced      no    -165     yes   no   unknown   3
## 1391  34    technician   single      no     649      no   no  cellular   7
## 1392  35   blue-collar   single      no       0     yes   no  cellular   8
## 1393  27      services  married      no     199      no   no  cellular   4
## 1394  57    unemployed  married      no    7357      no   no  cellular   5
## 1395  33    technician  married      no      48      no   no  cellular  27
## 1396  53       retired  married      no    2269      no   no  cellular  17
## 1397  36   blue-collar   single      no     103     yes   no  cellular  15
## 1398  52    management  married      no    1065     yes  yes   unknown  30
## 1399  31   blue-collar  married      no      99     yes   no  cellular  17
## 1400  30    management   single      no      61     yes   no telephone   5
## 1401  60    management  married      no      79      no   no   unknown  11
## 1402  40      services  married      no    1116     yes   no  cellular  12
## 1403  53    technician  married      no       0      no   no  cellular  22
## 1404  30        admin.   single      no    1018     yes   no  cellular  29
## 1405  26    technician  married      no      47     yes   no   unknown   9
## 1406  30    management   single      no    2995     yes   no  cellular  18
## 1407  24       student   single      no     486      no   no  cellular  26
## 1408  34    management   single      no     127      no   no  cellular  27
## 1409  41        admin.  married      no    4178      no   no   unknown  20
## 1410  31   blue-collar  married      no     360     yes   no   unknown  23
## 1411  39   blue-collar  married      no    1386     yes  yes   unknown   4
## 1412  40 self-employed  married      no    1498      no   no  cellular   4
## 1413  39        admin. divorced      no     458      no   no  cellular  21
## 1414  41    technician divorced      no     258      no   no  cellular  13
## 1415  35    management  married      no    2123     yes   no  cellular  21
## 1416  34    management  married      no      11     yes   no  cellular  18
## 1417  29        admin.  married      no   22171     yes   no  cellular  18
## 1418  58    management  married      no    2729      no   no   unknown  18
## 1419  36    management  married      no      86     yes   no  cellular   3
## 1420  40      services  married      no     771     yes   no  cellular  15
## 1421  35      services  married      no     586     yes  yes  cellular  17
## 1422  34    management  married      no      53     yes  yes  cellular  29
## 1423  45  entrepreneur divorced      no       0     yes   no   unknown  13
## 1424  34   blue-collar  married      no    2137      no   no   unknown   9
## 1425  33        admin.   single      no    1221     yes   no   unknown  23
## 1426  48   blue-collar  married      no     729     yes   no telephone  15
## 1427  34   blue-collar  married      no     -78     yes   no   unknown   9
## 1428  35    technician   single      no     103     yes   no   unknown  26
## 1429  35   blue-collar  married      no       0     yes   no   unknown   6
## 1430  39   blue-collar  married      no     521      no  yes  cellular  10
## 1431  27    management   single      no    2489      no   no  cellular  15
## 1432  36  entrepreneur  married      no     177     yes   no   unknown  12
## 1433  38   blue-collar  married      no    1731     yes  yes  cellular  14
## 1434  51        admin.  married      no     227      no   no  cellular   5
## 1435  35    technician  married      no     128      no  yes  cellular  29
## 1436  37   blue-collar   single      no    1222      no   no   unknown  27
## 1437  59    technician  married      no    4263      no  yes  cellular  20
## 1438  38    technician  married      no    1004     yes   no  cellular  16
## 1439  46   blue-collar  married      no     942      no   no  cellular  18
## 1440  73       retired  married      no    3443      no   no telephone   4
## 1441  24    technician  married      no     691     yes   no   unknown  19
## 1442  51    technician  married      no     180     yes   no  cellular  20
## 1443  50    management  married      no     830      no   no   unknown   2
## 1444  39    technician  married      no     130      no   no  cellular   8
## 1445  52   blue-collar  married      no      33      no  yes  cellular  13
## 1446  46    technician  married      no     179      no  yes   unknown  18
## 1447  34      services   single      no     194     yes  yes  cellular  15
## 1448  36    management   single      no       0     yes  yes  cellular   7
## 1449  46   blue-collar  married      no     624     yes   no  cellular  16
## 1450  32   blue-collar   single      no    3662      no   no telephone  28
## 1451  62   blue-collar  married      no     272      no   no  cellular  11
## 1452  36    management  married      no     190     yes   no  cellular   5
## 1453  51 self-employed  married      no     126     yes   no  cellular  10
## 1454  31  entrepreneur divorced      no    1767      no   no telephone  25
## 1455  45    technician  married      no    1003     yes   no   unknown   4
## 1456  43    technician  married      no    -330     yes  yes  cellular   8
## 1457  49   blue-collar  married      no     457     yes  yes   unknown  28
## 1458  60       retired  married      no    3461      no   no  cellular   3
## 1459  50    technician  married      no    1518      no  yes  cellular  31
## 1460  30      services  married      no      33      no   no  cellular  18
## 1461  46   blue-collar  married      no     310     yes   no  cellular  24
## 1462  44    management  married      no     -68      no  yes  cellular  25
## 1463  45    technician  married      no    2776     yes   no  cellular  27
## 1464  46   blue-collar  married      no     243     yes   no   unknown   3
## 1465  42       unknown   single     yes      61      no   no   unknown  20
## 1466  43   blue-collar   single      no       0      no   no   unknown   9
## 1467  46    management divorced      no       3     yes  yes  cellular   5
## 1468  33   blue-collar  married      no     983      no   no   unknown   8
## 1469  32        admin.   single      no     739     yes   no  cellular  20
## 1470  50   blue-collar  married      no     280     yes   no   unknown  18
## 1471  46      services  married      no     311     yes  yes  cellular  15
## 1472  28     housemaid  married      no       5      no   no  cellular  28
## 1473  38   blue-collar divorced      no    1686     yes   no   unknown  19
## 1474  44   blue-collar   single      no     712     yes  yes  cellular   6
## 1475  24        admin.   single      no     845     yes   no   unknown  13
## 1476  28       student   single      no     949     yes   no   unknown  28
## 1477  29   blue-collar   single      no    3508     yes   no  cellular  17
## 1478  46    technician divorced      no     119     yes   no   unknown  27
## 1479  77       retired  married      no       0      no   no  cellular  27
## 1480  37    technician   single      no     876     yes   no   unknown  23
## 1481  52   blue-collar   single      no     210     yes   no   unknown  12
## 1482  48    management divorced      no    5978      no   no  cellular  28
## 1483  43      services  married      no    2478     yes   no   unknown  12
## 1484  57        admin.  married      no     407     yes  yes  cellular  15
## 1485  34      services  married      no    -211     yes   no   unknown   4
## 1486  37    technician   single      no     181      no   no  cellular   5
## 1487  50   blue-collar  married      no     562     yes   no  cellular   8
## 1488  34    management  married      no     105     yes   no   unknown   6
## 1489  48   blue-collar  married      no     341     yes  yes   unknown  26
## 1490  28      services   single      no    2992     yes   no  cellular  30
## 1491  31        admin.   single      no    1016     yes   no   unknown  20
## 1492  35   blue-collar  married      no    5639     yes   no  cellular  20
## 1493  46    management  married      no      48      no   no   unknown  13
## 1494  33    management  married      no       0     yes   no   unknown   6
## 1495  56    technician  married      no     675     yes   no   unknown  29
## 1496  60       retired divorced      no    1582      no  yes   unknown  18
## 1497  52   blue-collar  married      no    1141     yes   no  cellular  12
## 1498  43    technician   single      no    4990     yes   no  cellular  22
## 1499  29        admin.   single      no     454      no   no telephone  16
## 1500  27        admin.  married      no      73     yes   no  cellular   5
## 1501  50   blue-collar  married      no     253     yes  yes  cellular   5
## 1502  46  entrepreneur  married      no     583     yes   no   unknown  20
## 1503  49        admin.  married      no    5361      no   no  cellular   7
## 1504  27        admin.  married      no     639      no  yes  cellular  14
## 1505  37   blue-collar  married      no     398     yes   no   unknown  19
## 1506  37   blue-collar  married      no    1222     yes   no  cellular   6
## 1507  35    technician  married      no     518     yes   no  cellular  30
## 1508  29   blue-collar   single      no     992     yes  yes   unknown  28
## 1509  30    management  married      no       0      no   no  cellular   7
## 1510  58      services  married      no     307      no   no telephone  25
## 1511  33     housemaid  married      no    2054      no   no  cellular  25
## 1512  33    technician  married      no     105     yes  yes   unknown  20
## 1513  39    management  married      no    3518     yes   no  cellular   8
## 1514  26        admin.  married      no     233     yes   no  cellular  21
## 1515  54    management  married      no    2216     yes   no  cellular  13
## 1516  60    technician  married      no    -247     yes   no telephone  12
## 1517  40   blue-collar  married      no    1386     yes  yes  cellular  20
## 1518  42    technician  married      no     422     yes   no  cellular  16
## 1519  58    management  married      no    1602      no   no  cellular  21
## 1520  56    technician  married      no    1750      no   no  cellular  19
## 1521  45   blue-collar   single      no     695     yes   no  cellular  21
## 1522  61        admin.  married      no    1541      no   no  cellular  20
## 1523  36       unknown   single      no    1070      no   no   unknown   5
## 1524  34    management divorced      no    1173      no  yes  cellular  18
## 1525  33        admin.   single      no   21854     yes   no  cellular  20
## 1526  42    technician  married      no      33      no   no telephone  22
## 1527  35  entrepreneur  married      no    -394     yes   no  cellular  20
## 1528  57    management  married      no    6900      no   no  cellular  23
## 1529  39    management  married      no       0     yes  yes  cellular  17
## 1530  49   blue-collar  married      no     783     yes   no   unknown  12
## 1531  27   blue-collar  married      no     409     yes   no  cellular  18
## 1532  34        admin.   single      no    1880     yes   no   unknown  23
## 1533  30    management   single      no    -383     yes   no  cellular  18
## 1534  36   blue-collar   single      no    1598     yes   no  cellular   5
## 1535  51  entrepreneur  married      no     538      no   no  cellular  18
## 1536  35    technician   single      no    2288      no   no telephone  28
## 1537  30    technician   single      no    1289     yes   no   unknown  21
## 1538  38    management  married      no     484     yes   no  cellular   8
## 1539  43   blue-collar   single      no       2     yes   no  cellular  30
## 1540  55      services divorced      no     935      no   no  cellular  14
## 1541  37   blue-collar  married      no    3370     yes   no  cellular  20
## 1542  32    technician  married      no     587     yes   no   unknown  23
## 1543  36   blue-collar  married      no       0     yes   no  cellular  30
## 1544  31      services  married      no     447      no   no  cellular  19
## 1545  27      services  married      no       8     yes   no   unknown   6
## 1546  30      services  married      no    -932      no   no   unknown  27
## 1547  32   blue-collar  married      no     400      no   no  cellular  20
## 1548  44   blue-collar  married      no    -237     yes   no telephone  10
## 1549  50    management  married      no    1854     yes  yes   unknown   3
## 1550  24        admin.   single      no     454     yes   no  cellular  15
## 1551  41    technician divorced      no    3465     yes   no  cellular  11
## 1552  43   blue-collar  married      no     547      no  yes   unknown   9
## 1553  23        admin.   single      no     897     yes   no  cellular   8
## 1554  35    management  married      no       0     yes   no  cellular  20
## 1555  56   blue-collar  married      no     397     yes   no  cellular  13
## 1556  39   blue-collar  married      no    7653      no   no   unknown  11
## 1557  44    management  married      no     392     yes   no   unknown   9
## 1558  37      services  married      no       0     yes   no  cellular  12
## 1559  33  entrepreneur divorced      no     596      no  yes  cellular   5
## 1560  21       student   single      no     423      no   no telephone  18
## 1561  30    management   single      no    2317     yes   no   unknown  26
## 1562  38   blue-collar divorced      no     595     yes   no  cellular   7
## 1563  35   blue-collar  married      no     994     yes   no   unknown  23
## 1564  51   blue-collar divorced      no     104      no   no  cellular   9
## 1565  35    management  married      no    3168      no   no  cellular  22
## 1566  38      services  married      no    4644     yes   no telephone  18
## 1567  27    management   single      no       3     yes  yes  cellular  22
## 1568  58   blue-collar  married      no    3109      no   no  cellular  29
## 1569  47    technician  married      no    1280      no   no  cellular   8
## 1570  54       retired  married      no       0     yes   no   unknown  13
## 1571  34    management   single      no    1049     yes   no  cellular  11
## 1572  42     housemaid   single      no    5774     yes   no   unknown  15
## 1573  29    management   single      no    1026      no   no  cellular  12
## 1574  35 self-employed  married      no    1820     yes  yes  cellular  29
## 1575  52      services  married      no     911      no   no   unknown  20
## 1576  38 self-employed  married      no    -165     yes   no   unknown  21
## 1577  47    technician  married      no    2106     yes   no   unknown   6
## 1578  34    unemployed  married      no     309      no   no  cellular   5
## 1579  41   blue-collar  married      no       0     yes   no  cellular   3
## 1580  44    management  married      no     368      no   no  cellular   9
## 1581  28      services   single      no      45     yes   no   unknown  16
## 1582  54      services divorced      no       0     yes   no  cellular  16
## 1583  49   blue-collar  married      no   11317     yes   no   unknown  14
## 1584  53    technician  married      no    4930      no  yes  cellular   2
## 1585  43    management  married      no      79      no   no  cellular  26
## 1586  57    unemployed divorced      no    1088      no   no  cellular  29
## 1587  55      services  married      no    -747     yes   no  cellular  15
## 1588  36    unemployed   single      no     605      no   no  cellular  30
## 1589  50       retired  married      no      14      no  yes telephone  23
## 1590  46   blue-collar  married      no     596     yes   no   unknown   3
## 1591  55      services  married      no    1695     yes   no   unknown   3
## 1592  37   blue-collar  married      no    1114     yes  yes  cellular   6
## 1593  31  entrepreneur  married      no     312      no   no  cellular  29
## 1594  54    technician   single      no    3233      no   no   unknown  20
## 1595  36   blue-collar  married      no    1993     yes  yes  cellular  13
## 1596  40  entrepreneur  married      no       0     yes  yes   unknown  15
## 1597  32   blue-collar   single      no      33     yes   no  cellular  18
## 1598  56    management  married      no      31     yes   no  cellular  12
## 1599  39    technician   single      no    1043      no   no  cellular  18
## 1600  45 self-employed  married      no    2278      no   no   unknown  17
## 1601  42    technician  married      no     738      no   no   unknown  20
## 1602  37 self-employed divorced      no    1513      no   no   unknown  30
## 1603  40    technician   single      no      57      no  yes  cellular   6
## 1604  31    management   single      no      59     yes  yes  cellular   6
## 1605  30      services   single      no     399     yes  yes   unknown  23
## 1606  44    management  married      no      27     yes   no   unknown  29
## 1607  49   blue-collar  married      no    1387     yes  yes   unknown   9
## 1608  59    management  married      no    5956      no   no  cellular   3
## 1609  31    management   single      no     291     yes   no  cellular  15
## 1610  32    management   single      no    2223      no   no   unknown   9
## 1611  46   blue-collar  married      no     874      no   no  cellular   6
## 1612  40      services  married      no    5248     yes  yes  cellular  20
## 1613  50    management  married      no       4      no   no  cellular  17
## 1614  52    management  married      no    1177     yes   no   unknown  29
## 1615  31    technician  married      no    4089      no   no  cellular  12
## 1616  31        admin.  married      no      23      no   no  cellular  28
## 1617  34    management  married      no    1778      no   no  cellular   5
## 1618  34    technician  married      no     260     yes   no  cellular  17
## 1619  53    management  married      no       0     yes   no  cellular   9
## 1620  35    management   single      no     578     yes   no  cellular  19
## 1621  35        admin.  married      no     100     yes   no  cellular  14
## 1622  32   blue-collar divorced      no    -156     yes   no  cellular  24
## 1623  39   blue-collar  married      no     660     yes  yes  cellular  20
## 1624  51   blue-collar divorced      no     113      no   no  cellular  15
## 1625  61       retired divorced      no    4243      no   no  cellular  30
## 1626  33    management  married      no     296      no   no  cellular  13
## 1627  25    technician   single      no    1135     yes   no   unknown  12
## 1628  26      services  married      no     104      no   no   unknown  14
## 1629  32        admin.   single      no     184     yes   no   unknown   8
## 1630  27      services divorced      no     397      no  yes  cellular  30
## 1631  32    management  married      no   14611     yes   no  cellular  17
## 1632  52    technician  married      no     945      no   no   unknown  20
## 1633  60       retired  married      no      78      no  yes   unknown  27
## 1634  34    technician  married      no    1524     yes   no  cellular  16
## 1635  37   blue-collar divorced      no      48     yes   no   unknown   8
## 1636  19       student   single      no      60      no   no  cellular  14
## 1637  48    management  married      no    1744      no   no   unknown   9
## 1638  48      services divorced      no    -203     yes   no  cellular  18
## 1639  32   blue-collar divorced      no    -289     yes  yes  cellular  21
## 1640  36    management  married      no    -267      no   no  cellular  21
## 1641  47       unknown  married      no       0      no   no   unknown   6
## 1642  30   blue-collar   single      no     953     yes   no   unknown   2
## 1643  45    technician divorced      no     299     yes   no  cellular  28
## 1644  49   blue-collar  married      no       0      no  yes  cellular   9
## 1645  48   blue-collar  married      no     104      no   no  cellular   8
## 1646  25    technician   single      no      31      no   no  cellular   2
## 1647  54   blue-collar divorced      no    2656     yes   no  cellular  15
## 1648  47   blue-collar  married      no    2642      no   no  cellular  13
## 1649  49    technician divorced      no     790     yes   no  cellular   7
## 1650  28    technician  married      no    1198      no  yes  cellular  10
## 1651  32   blue-collar   single      no    2696     yes   no  cellular  20
## 1652  49    management divorced      no    1253     yes   no  cellular  14
## 1653  55    management  married      no     979      no  yes  cellular   8
## 1654  45        admin.  married      no       0      no   no  cellular  19
## 1655  34    unemployed  married      no     428     yes   no  cellular   7
## 1656  40    management  married      no    8963      no   no  cellular   3
## 1657  35    technician  married      no       2      no   no telephone  28
## 1658  31    technician   single      no    1710     yes   no   unknown  23
## 1659  28      services   single      no     117     yes   no  cellular  11
## 1660  48    technician  married      no       0     yes   no  cellular  21
## 1661  52    management  married      no       0      no   no   unknown   5
## 1662  39     housemaid   single      no    1340      no   no   unknown  18
## 1663  36   blue-collar  married      no     345     yes   no  cellular  20
## 1664  29      services  married      no     -62     yes  yes  cellular  25
## 1665  34        admin.  married      no     920      no   no  cellular  14
## 1666  43    technician   single      no     572      no   no  cellular  17
## 1667  38    technician  married      no       0     yes   no  cellular   4
## 1668  36    management divorced      no    -978     yes   no  cellular  13
## 1669  44   blue-collar  married      no    2185     yes   no   unknown  16
## 1670  56       retired divorced      no    1005      no  yes  cellular  30
## 1671  57 self-employed   single      no    3277      no   no   unknown   5
## 1672  40    technician   single      no     191     yes   no  cellular  18
## 1673  23        admin.   single      no    4681     yes   no   unknown  28
## 1674  36    technician  married      no    -456     yes   no  cellular  11
## 1675  47        admin.   single      no     303     yes  yes  cellular  28
## 1676  48    management   single      no     399      no  yes  cellular   7
## 1677  28    technician   single      no    2000      no   no telephone   3
## 1678  32    management   single      no       0      no   no  cellular  29
## 1679  44    technician  married      no     945     yes   no  cellular   4
## 1680  52     housemaid divorced      no    4306      no   no  cellular  22
## 1681  44 self-employed  married      no     706      no   no   unknown   5
## 1682  45    unemployed  married      no    -407     yes   no  cellular  15
## 1683  48   blue-collar  married      no     865     yes   no  cellular  13
## 1684  28  entrepreneur  married      no     490     yes   no  cellular  17
## 1685  29    management  married      no      20     yes   no  cellular  12
## 1686  27    management   single      no     170      no   no  cellular  29
## 1687  32    management   single      no    1088     yes   no  cellular   6
## 1688  35   blue-collar   single      no    -759     yes   no  cellular  31
## 1689  38  entrepreneur  married      no     898     yes   no  cellular  20
## 1690  32    technician divorced      no     210     yes  yes   unknown   7
## 1691  31      services  married      no    -489     yes  yes  cellular  19
## 1692  41        admin.   single      no       0     yes  yes  cellular   7
## 1693  34    technician  married      no       1      no   no  cellular  22
## 1694  54        admin.  married      no    3965     yes   no   unknown  15
## 1695  30    management  married      no     805      no   no  cellular  10
## 1696  26       student   single      no    1164      no   no  cellular   9
## 1697  39   blue-collar  married      no     481      no   no  cellular   4
## 1698  29      services  married      no    1432      no   no  cellular  22
## 1699  31      services divorced      no    1016     yes   no  cellular   6
## 1700  33   blue-collar  married      no     596     yes   no  cellular  18
## 1701  34   blue-collar  married      no     123     yes   no  cellular   8
## 1702  41    unemployed  married      no    1666      no   no   unknown   9
## 1703  28    technician   single      no     205     yes   no   unknown  12
## 1704  35   blue-collar   single      no    -276     yes   no  cellular  13
## 1705  35   blue-collar   single      no    1253      no   no   unknown  29
## 1706  29    technician   single      no   22008     yes   no   unknown  28
## 1707  30    management  married      no       0     yes   no  cellular   9
## 1708  50   blue-collar  married      no    2590     yes   no telephone  20
## 1709  57     housemaid divorced      no    3767      no   no  cellular   2
## 1710  41   blue-collar  married      no     -56     yes   no  cellular  13
## 1711  32     housemaid  married      no     344     yes   no   unknown   9
## 1712  54      services  married      no    1059      no   no  cellular   7
## 1713  25    management   single      no     667      no   no  cellular  29
## 1714  42    management  married      no    2580     yes   no   unknown  16
## 1715  36   blue-collar  married      no    -231      no  yes  cellular  15
## 1716  41    technician  married      no     767     yes  yes   unknown   6
## 1717  40    unemployed divorced      no    1694      no   no  cellular  12
## 1718  41    technician  married      no     744     yes   no   unknown  14
## 1719  40  entrepreneur  married      no    3676     yes  yes   unknown  15
## 1720  27      services   single      no    9965     yes   no  cellular  22
## 1721  54    management  married      no       0      no   no  cellular  14
## 1722  29        admin.   single      no     422     yes   no  cellular   7
## 1723  39   blue-collar  married      no     507     yes   no   unknown   8
## 1724  33    technician   single      no    -325     yes   no  cellular  15
## 1725  28      services   single      no     129     yes   no  cellular  18
## 1726  36    technician divorced      no     566     yes   no   unknown  20
## 1727  43   blue-collar  married      no     445     yes   no   unknown  15
## 1728  50    management divorced      no       0      no   no  cellular  29
## 1729  49    technician  married      no     808     yes   no  cellular  28
## 1730  34    management  married      no     240     yes   no   unknown  23
## 1731  33    technician divorced     yes      10     yes  yes  cellular  18
## 1732  53    technician  married      no    4807      no   no telephone  19
## 1733  43    unemployed  married      no     519      no   no   unknown  20
## 1734  32    management   single      no     739     yes   no  cellular   2
## 1735  56    management divorced      no      94      no   no   unknown   4
## 1736  26    management   single      no     205      no   no   unknown  26
## 1737  46   blue-collar  married      no     296     yes   no   unknown   4
## 1738  45    technician  married      no    -149     yes   no  cellular  14
## 1739  42   blue-collar   single      no     985      no   no  cellular  20
## 1740  39    management   single      no     113     yes   no telephone  27
## 1741  38    management   single      no    8669     yes   no telephone  20
## 1742  35    technician  married      no    7050      no   no  cellular  11
## 1743  53 self-employed  married      no       1     yes  yes   unknown  23
## 1744  29    management  married      no     246     yes   no   unknown   9
## 1745  36    technician   single      no    -206     yes   no  cellular  14
## 1746  25      services   single      no    -107     yes   no  cellular  14
## 1747  44    management divorced      no     193      no  yes  cellular   8
## 1748  49    technician  married      no      25     yes  yes  cellular  19
## 1749  30    technician   single      no    1286      no   no telephone  28
## 1750  49   blue-collar divorced      no      24     yes   no  cellular  11
## 1751  53 self-employed  married      no    4397     yes   no   unknown  12
## 1752  28  entrepreneur  married      no    4064      no  yes  cellular  11
## 1753  29    management   single      no     307     yes   no  cellular   2
## 1754  28    technician   single      no     183     yes  yes   unknown  28
## 1755  53    management  married      no     490     yes   no   unknown  28
## 1756  35      services divorced      no     877     yes   no  cellular  15
## 1757  32    management  married      no    -383     yes   no   unknown  27
## 1758  26   blue-collar   single      no     123      no  yes  cellular   7
## 1759  34    technician  married      no    4248     yes   no  cellular  20
## 1760  43   blue-collar  married      no       3     yes   no telephone  13
## 1761  32        admin.  married      no     277     yes   no   unknown   3
## 1762  24       student   single      no    1925      no   no  cellular  11
## 1763  50   blue-collar  married      no     -37     yes   no   unknown  12
## 1764  53        admin.   single      no    1178     yes   no   unknown  15
## 1765  51    management  married      no     873      no   no  cellular  29
## 1766  30    technician   single      no      53      no   no  cellular  29
## 1767  54    technician  married      no      25     yes   no telephone   2
## 1768  35   blue-collar   single      no     109     yes   no   unknown   7
## 1769  30    technician   single      no    2832      no   no  cellular  18
## 1770  45      services  married      no     350     yes  yes   unknown  13
## 1771  56       retired  married      no     393      no  yes  cellular  26
## 1772  33    management  married      no    3713     yes   no  cellular  20
## 1773  54      services  married      no     158     yes   no   unknown  19
## 1774  39   blue-collar   single      no      10     yes   no telephone  15
## 1775  29      services   single      no       0      no   no  cellular  17
## 1776  49     housemaid divorced      no     164     yes   no   unknown   9
## 1777  25       student   single      no     722     yes   no   unknown  19
## 1778  40    technician   single      no    1175      no   no  cellular  14
## 1779  52        admin.  married      no     190      no   no  cellular  27
## 1780  35    technician  married     yes     -29     yes  yes   unknown  21
## 1781  43   blue-collar  married      no     582     yes   no telephone  11
## 1782  32   blue-collar  married      no     950     yes  yes  cellular  20
## 1783  55    management  married      no    2537      no   no  cellular  19
## 1784  34      services  married      no       0      no   no   unknown  27
## 1785  60   blue-collar  married      no       0      no   no  cellular  21
## 1786  57        admin.  married      no     567     yes   no  cellular   2
## 1787  58   blue-collar  married      no    1075     yes   no  cellular  18
## 1788  26   blue-collar   single      no     535     yes   no   unknown   9
## 1789  59        admin.  married      no    1001      no   no   unknown   6
## 1790  58      services  married      no     553      no  yes telephone  17
## 1791  49    management  married      no    2187      no   no  cellular  25
## 1792  37      services  married      no    3429     yes  yes  cellular   8
## 1793  47    technician  married      no     179     yes   no  cellular  18
## 1794  39      services divorced      no    -152     yes   no  cellular   3
## 1795  58      services  married      no     818      no   no  cellular  22
## 1796  30 self-employed  married      no     805     yes   no   unknown   1
## 1797  44  entrepreneur  married      no    6649     yes   no  cellular  19
## 1798  27   blue-collar  married      no     556     yes   no  cellular   9
## 1799  42   blue-collar  married      no    1598     yes  yes  cellular  16
## 1800  25    management  married      no     127     yes   no  cellular  18
## 1801  32   blue-collar  married      no     113     yes  yes   unknown  20
## 1802  55    technician  married      no       0     yes   no   unknown  30
## 1803  55      services  married      no    2877      no   no  cellular   9
## 1804  40      services   single      no     326     yes   no  cellular  18
## 1805  35        admin. divorced      no      45     yes   no   unknown  29
## 1806  25    unemployed  married      no     285     yes   no   unknown  29
## 1807  36   blue-collar  married      no    -400     yes  yes  cellular   6
## 1808  32    technician  married      no    6172     yes   no  cellular   4
## 1809  49    technician  married      no    1982     yes  yes  cellular  22
## 1810  56      services  married      no     219     yes   no   unknown   7
## 1811  32    management  married      no    1388     yes   no  cellular  13
## 1812  26 self-employed   single      no    3044     yes  yes  cellular  17
## 1813  33        admin.  married      no       7     yes   no  cellular  20
## 1814  37    technician  married      no     127     yes   no  cellular  25
## 1815  45    technician  married      no    1412     yes   no  cellular  11
## 1816  49     housemaid  married      no      78      no   no telephone  10
## 1817  28        admin.   single      no    1104     yes   no  cellular  28
## 1818  30   blue-collar   single      no     694     yes  yes  cellular  18
## 1819  31    technician  married      no     585     yes   no telephone  11
## 1820  54        admin. divorced      no       0      no   no  cellular  14
## 1821  27   blue-collar  married      no      72     yes   no   unknown  19
## 1822  34    technician  married      no      30      no   no  cellular  19
## 1823  41 self-employed  married      no     305     yes   no  cellular  13
## 1824  58    technician  married      no     589     yes   no  cellular  10
## 1825  31   blue-collar   single      no    5972      no   no telephone  20
## 1826  38    management divorced      no    -980     yes   no   unknown  20
## 1827  30        admin.  married      no      35     yes  yes  cellular  21
## 1828  36    technician  married      no     154     yes   no  cellular  18
## 1829  51    technician  married      no    2506      no   no  cellular  30
## 1830  53   blue-collar  married      no     208      no   no   unknown  20
## 1831  27       student   single      no    3687      no   no  cellular   8
## 1832  25   blue-collar  married      no     -23     yes   no  cellular  25
## 1833  56    technician divorced      no    1593     yes   no  cellular  31
## 1834  43        admin.  married      no     324      no   no  cellular   8
## 1835  28      services   single      no     168     yes   no  cellular   7
## 1836  53       retired divorced      no    -477      no   no  cellular  17
## 1837  28 self-employed   single      no       0     yes   no  cellular  29
## 1838  57    technician divorced      no     114      no   no  cellular  19
## 1839  24       student   single      no     474      no   no  cellular  12
## 1840  51   blue-collar  married      no      19      no   no  cellular  26
## 1841  38      services  married      no     433      no   no   unknown  11
## 1842  32      services   single      no     -23      no   no  cellular  10
## 1843  51    management divorced      no     492      no  yes  cellular  29
## 1844  45   blue-collar  married      no    -149     yes   no   unknown  15
## 1845  33   blue-collar  married      no       0      no   no   unknown   7
## 1846  51      services  married      no       0      no  yes   unknown  26
## 1847  31    technician   single      no     845     yes   no  cellular  22
## 1848  34 self-employed  married      no     191      no   no  cellular   8
## 1849  42      services  married      no    3236      no   no   unknown  18
## 1850  52      services divorced      no    -644      no   no  cellular  18
## 1851  74       retired  married      no    1843      no   no  cellular  15
## 1852  56       unknown  married      no   15088      no   no  cellular  11
## 1853  43 self-employed  married      no   10072      no   no  cellular  12
## 1854  44    technician  married      no       0     yes   no   unknown   5
## 1855  41   blue-collar  married      no    3803     yes   no  cellular  20
## 1856  38   blue-collar   single      no     745     yes   no   unknown  21
## 1857  40    technician   single      no     693      no   no  cellular  30
## 1858  42   blue-collar  married      no    2717     yes  yes  cellular  20
## 1859  48       retired  married      no       4      no  yes  cellular  23
## 1860  55   blue-collar  married      no     660      no   no   unknown   5
## 1861  38   blue-collar   single      no      10     yes   no   unknown   3
## 1862  37    management divorced      no    1775      no   no  cellular  15
## 1863  42    unemployed  married     yes    -581     yes   no  cellular  13
## 1864  42    technician  married      no    4791     yes   no   unknown  30
## 1865  28    technician  married      no     139     yes  yes  cellular   8
## 1866  54      services  married      no    1301     yes   no   unknown  13
## 1867  43    management  married      no    2886      no   no  cellular  20
## 1868  31    management divorced      no    1742     yes   no  cellular  20
## 1869  50  entrepreneur  married     yes     537     yes   no   unknown  20
## 1870  72       retired  married      no     796      no   no  cellular  24
## 1871  54   blue-collar  married      no    1827      no   no  cellular  20
## 1872  57        admin.  married      no    2137      no   no telephone   8
## 1873  42    management  married      no    -700     yes   no   unknown  14
## 1874  47     housemaid   single      no    3232      no   no telephone  16
## 1875  60        admin.  married      no       0      no   no  cellular   5
## 1876  41   blue-collar divorced      no    1498      no   no   unknown  20
## 1877  31 self-employed  married      no       0     yes   no  cellular  30
## 1878  49    technician  married      no    -215     yes   no   unknown  26
## 1879  60     housemaid  married      no     211      no   no  cellular  26
## 1880  36     housemaid  married     yes   -1941     yes   no   unknown  16
## 1881  37    management   single      no     455     yes   no  cellular  13
## 1882  34   blue-collar  married      no    1451     yes   no  cellular   9
## 1883  57    management  married      no    1171      no   no  cellular   8
## 1884  34        admin.  married      no     899     yes   no   unknown  12
## 1885  46      services divorced      no     755      no   no  cellular  28
## 1886  36        admin.  married      no     542     yes   no   unknown  18
## 1887  35    management  married      no    5367      no   no  cellular   2
## 1888  40    management  married      no     270      no   no   unknown  16
## 1889  30    management divorced      no    -274     yes  yes  cellular  19
## 1890  53    management  married      no    2240     yes   no  cellular   2
## 1891  31    technician  married      no     344     yes   no   unknown   7
## 1892  39    management  married      no     575      no   no   unknown   6
## 1893  57        admin. divorced      no   18268     yes   no  cellular  19
## 1894  54    unemployed  married      no    6427     yes   no telephone  19
## 1895  35        admin.  married      no    -488     yes   no   unknown   2
## 1896  34   blue-collar  married      no    1031     yes   no   unknown  29
## 1897  30       student   single      no    -145      no  yes  cellular   8
## 1898  39        admin.  married      no       0      no   no  cellular  17
## 1899  49 self-employed  married      no    1103      no   no  cellular  12
## 1900  58 self-employed  married      no    1187     yes   no  cellular   6
## 1901  37     housemaid  married      no       0     yes   no  cellular  24
## 1902  34      services  married      no     184     yes   no  cellular  18
## 1903  41    technician   single      no      -3      no   no  cellular   8
## 1904  23       student   single      no     556     yes   no  cellular  15
## 1905  47      services  married      no    1496     yes   no   unknown  16
## 1906  35   blue-collar   single      no    1277     yes   no  cellular  20
## 1907  42        admin. divorced      no      24     yes   no  cellular   6
## 1908  49   blue-collar  married      no     352     yes   no   unknown   9
## 1909  37        admin.   single      no     262      no   no  cellular   7
## 1910  31   blue-collar   single      no    4978     yes   no  cellular  12
## 1911  41    technician  married      no    2125     yes  yes  cellular  21
## 1912  36    technician   single      no      98      no   no  cellular  30
## 1913  29   blue-collar   single      no      98      no   no  cellular  10
## 1914  39        admin.  married      no     441      no   no   unknown   6
## 1915  53       retired  married      no     366      no  yes  cellular  16
## 1916  36   blue-collar   single      no     168     yes   no telephone  12
## 1917  33    technician  married      no     180      no   no  cellular   4
## 1918  29   blue-collar   single      no    1166     yes   no   unknown  16
## 1919  43       retired  married      no    7298      no   no   unknown  11
## 1920  32   blue-collar  married      no    1518     yes   no telephone   6
## 1921  44    technician  married      no     851     yes   no  cellular  11
## 1922  50   blue-collar  married      no    2190      no   no   unknown  17
## 1923  37    technician  married      no    4596     yes   no  cellular   7
## 1924  31    technician   single      no    1166     yes   no  cellular  21
## 1925  36   blue-collar  married      no     108     yes   no  cellular   5
## 1926  38   blue-collar  married      no    -152      no   no   unknown  20
## 1927  55   blue-collar divorced      no     962      no  yes telephone  28
## 1928  43    management  married      no    9261     yes   no  cellular  17
## 1929  40   blue-collar  married      no       0     yes   no  cellular  11
## 1930  38    technician   single      no    2442      no   no  cellular  27
## 1931  36    management   single      no    4123      no   no  cellular  11
## 1932  43    management divorced      no    3163     yes   no  cellular  22
## 1933  43      services divorced      no    1040     yes   no   unknown  19
## 1934  33   blue-collar divorced      no     474      no   no  cellular  22
## 1935  30    management   single      no    2186     yes   no   unknown   3
## 1936  54   blue-collar  married      no     844      no   no telephone   5
## 1937  41  entrepreneur  married      no     221     yes   no   unknown  14
## 1938  46     housemaid   single      no   10889      no   no  cellular  19
## 1939  50   blue-collar  married      no     565     yes  yes  cellular  28
## 1940  36   blue-collar  married     yes      13      no  yes  cellular   3
## 1941  43    management divorced      no     481     yes   no  cellular   3
## 1942  32   blue-collar divorced      no       8     yes   no  cellular  16
## 1943  25       student   single      no    2975      no   no  cellular   2
## 1944  33   blue-collar  married      no     331     yes   no  cellular  14
## 1945  41      services  married      no    3992     yes   no telephone  20
## 1946  70  entrepreneur  married      no   15265      no   no  cellular  17
## 1947  37      services  married      no    -224      no   no   unknown  18
## 1948  52    management  married      no    4873      no   no telephone   6
## 1949  31  entrepreneur   single      no     544      no  yes  cellular   5
## 1950  31    technician   single      no    1819     yes   no   unknown  15
## 1951  45    management   single      no     142      no  yes  cellular   6
## 1952  47   blue-collar  married      no    4666      no   no   unknown  14
## 1953  50      services  married      no    5699     yes   no   unknown   5
## 1954  49   blue-collar  married      no      90     yes   no   unknown   7
## 1955  38    management   single      no    2346     yes   no  cellular  28
## 1956  28    management  married      no       3     yes   no  cellular  14
## 1957  42    management  married      no    2608     yes   no   unknown  29
## 1958  30   blue-collar  married      no    -269     yes   no   unknown  27
## 1959  37    management   single      no    1572      no   no  cellular  13
## 1960  58       retired divorced      no     439      no  yes  cellular  10
## 1961  46        admin.   single      no    2889     yes   no  cellular   5
## 1962  33    management   single      no     641     yes   no  cellular   4
## 1963  31 self-employed  married      no       0     yes   no  cellular  20
## 1964  42        admin.   single      no     -76     yes   no   unknown   5
## 1965  35      services   single      no     739     yes   no  cellular   4
## 1966  32    management  married     yes       2      no   no  cellular   8
## 1967  31        admin.   single      no      43      no   no   unknown   1
## 1968  37      services  married      no     -21     yes  yes   unknown  23
## 1969  44  entrepreneur divorced      no     134     yes   no  cellular  12
## 1970  43        admin.  married      no    1138      no   no  cellular  16
## 1971  31    technician   single      no    1109      no   no  cellular   5
## 1972  37      services   single      no    3715     yes   no   unknown  20
## 1973  41    technician  married      no     201      no  yes  cellular  14
## 1974  32   blue-collar  married      no     150     yes   no   unknown   9
## 1975  58    management divorced      no      44     yes   no  cellular  29
## 1976  38    technician divorced     yes    -530     yes   no   unknown  21
## 1977  52        admin.  married      no     199      no   no  cellular  28
## 1978  33      services   single      no    1595     yes   no   unknown  26
## 1979  31    unemployed  married      no     213     yes   no   unknown   9
## 1980  52    management  married      no     258      no   no   unknown  14
## 1981  30      services   single      no    3516     yes   no   unknown  29
## 1982  31    technician   single      no    1626      no   no  cellular   7
## 1983  42    management  married      no     202      no   no   unknown   6
## 1984  43   blue-collar  married     yes    -635     yes   no   unknown  20
## 1985  58    technician   single      no     388      no   no  cellular  19
## 1986  32      services  married      no    1977     yes  yes  cellular  18
## 1987  53       retired  married      no    1778      no   no  cellular  19
## 1988  33        admin.   single      no     395     yes   no   unknown  12
## 1989  47   blue-collar  married      no     -18      no  yes  cellular  22
## 1990  36 self-employed  married      no     254     yes   no telephone  17
## 1991  58  entrepreneur  married      no       0      no  yes  cellular  30
## 1992  35    management  married      no      24     yes   no  cellular   8
## 1993  23       student   single      no     107      no   no  cellular  13
## 1994  37   blue-collar  married      no    2939     yes   no  cellular   4
## 1995  33    management divorced      no     321      no  yes  cellular  30
## 1996  35      services  married      no      31      no  yes  cellular  19
## 1997  57    management  married      no    1832     yes   no  cellular   2
## 1998  36    technician  married      no     696     yes   no  cellular   5
## 1999  31        admin.   single      no    2076      no  yes  cellular  18
## 2000  47       unknown  married      no    1880      no   no   unknown  18
## 2001  45    unemployed   single      no    2249     yes   no  cellular   9
## 2002  37    technician   single      no     971      no   no  cellular  19
## 2003  33        admin. divorced      no     661     yes   no  cellular  11
## 2004  24    management   single      no     507      no   no  cellular   3
## 2005  46   blue-collar  married      no    5461     yes   no  cellular  13
## 2006  43   blue-collar  married      no    1127     yes   no  cellular  17
## 2007  30        admin.  married      no     215      no  yes  cellular   4
## 2008  46        admin.   single      no     849     yes   no   unknown   5
## 2009  47   blue-collar  married      no      17      no   no  cellular   8
## 2010  49    technician  married      no    8422     yes   no  cellular  20
## 2011  50   blue-collar  married      no     378     yes   no  cellular  28
## 2012  61       retired  married      no    1058      no   no  cellular  27
## 2013  31   blue-collar  married      no     251     yes   no   unknown   7
## 2014  31    management  married      no    2344     yes   no  cellular  14
## 2015  48   blue-collar  married      no    5058      no   no   unknown  20
## 2016  28        admin.   single      no    1540     yes   no   unknown   2
## 2017  27    unemployed   single      no    -446     yes   no   unknown  26
## 2018  35        admin.   single      no     777      no  yes  cellular  28
## 2019  43    unemployed  married      no       0     yes   no   unknown   6
## 2020  36    technician  married      no    1508      no   no  cellular  29
## 2021  39    management divorced      no     295      no   no  cellular  28
## 2022  27       student   single      no    2245      no   no  cellular  18
## 2023  34        admin.  married      no      79     yes   no   unknown  23
## 2024  46   blue-collar  married      no    1303      no   no  cellular   4
## 2025  39   blue-collar   single      no      29     yes   no   unknown   7
## 2026  44     housemaid  married      no    3706      no   no   unknown  17
## 2027  35   blue-collar   single      no    4963     yes   no  cellular  14
## 2028  30        admin.  married      no     518     yes   no  cellular   8
## 2029  26    technician  married      no     267     yes   no  cellular  28
## 2030  26       student   single      no     316      no   no  cellular  18
## 2031  28        admin.   single      no     520     yes   no  cellular  15
## 2032  39   blue-collar  married      no     474     yes  yes   unknown  26
## 2033  31   blue-collar  married      no     512     yes   no  cellular  18
## 2034  55    management divorced      no    1633      no   no telephone   2
## 2035  57      services   single      no    2236     yes   no   unknown  14
## 2036  41    technician   single      no    2701     yes   no  cellular   6
## 2037  26   blue-collar   single      no      36      no  yes  cellular  31
## 2038  56    management  married      no     870      no   no  cellular  16
## 2039  42        admin. divorced      no     153     yes   no   unknown  16
## 2040  37    management   single      no    1730      no   no  cellular  19
## 2041  55        admin.   single     yes     986      no  yes  cellular   2
## 2042  23    technician   single      no       4     yes   no  cellular   8
## 2043  35      services divorced      no     440     yes   no   unknown   2
## 2044  34        admin. divorced      no    1186     yes  yes  cellular  18
## 2045  35    technician divorced      no    -281      no   no  cellular   4
## 2046  50   blue-collar divorced      no     388      no   no  cellular   5
## 2047  47 self-employed  married      no    4420     yes  yes  cellular  20
## 2048  43    management   single      no       0      no   no   unknown  20
## 2049  58   blue-collar  married      no     343     yes   no   unknown  26
## 2050  35    management divorced      no     788     yes   no   unknown   7
## 2051  32 self-employed  married      no      67      no   no  cellular   5
## 2052  39   blue-collar  married      no     295     yes   no  cellular   3
## 2053  46   blue-collar  married      no       0     yes   no telephone  11
## 2054  60   blue-collar  married      no      93      no  yes   unknown  27
## 2055  29    management   single      no    1739     yes   no  cellular   3
## 2056  34  entrepreneur  married      no    1076     yes   no  cellular   5
## 2057  34      services  married      no     404     yes   no  cellular   9
## 2058  30        admin.   single      no    4925     yes   no  cellular  21
## 2059  41 self-employed  married      no     323     yes   no  cellular  17
## 2060  55       retired  married      no     868      no   no   unknown  19
## 2061  33    management  married      no    2744     yes   no telephone  19
## 2062  36   blue-collar divorced      no     719     yes   no   unknown  13
## 2063  34       student   single      no    1281      no   no  cellular  30
## 2064  51      services  married      no    -553     yes   no   unknown   4
## 2065  58     housemaid  married      no     497      no   no   unknown  11
## 2066  25 self-employed   single      no     882     yes   no  cellular  13
## 2067  50   blue-collar  married      no    4121     yes  yes  cellular  20
## 2068  50    management  married      no     536      no   no   unknown  20
## 2069  51  entrepreneur  married      no     726     yes  yes  cellular  15
## 2070  56       retired  married      no       0      no   no  cellular  26
## 2071  52        admin.  married      no    2851      no  yes telephone   2
## 2072  41   blue-collar  married      no     232      no   no telephone   8
## 2073  48        admin. divorced      no       0      no  yes  cellular  11
## 2074  36    technician  married      no      98      no   no  cellular   4
## 2075  31    management   single      no   12857     yes   no telephone   4
## 2076  39    management   single      no    1509      no   no  cellular  11
## 2077  45    unemployed  married      no    2040      no   no telephone   2
## 2078  57   blue-collar  married      no    1460      no   no   unknown  13
## 2079  44    management  married      no     170      no   no  cellular   4
## 2080  42    management   single      no     196     yes   no   unknown  12
## 2081  38   blue-collar  married      no    1099     yes   no  cellular  15
## 2082  41     housemaid  married      no     783     yes   no   unknown  30
## 2083  34    technician  married      no    1137      no   no  cellular  29
## 2084  37      services   single      no    -196     yes   no   unknown   7
## 2085  43        admin.   single      no       6      no   no   unknown  16
## 2086  46        admin.  married      no    9319     yes   no  cellular  21
## 2087  41   blue-collar   single      no    1564     yes   no  cellular  12
## 2088  27   blue-collar   single      no     140      no   no telephone  28
## 2089  44   blue-collar  married      no     195     yes   no   unknown  16
## 2090  35   blue-collar  married      no    -461      no   no   unknown  23
## 2091  30    management   single      no       0     yes   no  cellular   2
## 2092  36  entrepreneur  married      no     302     yes   no  cellular  17
## 2093  41       unknown   single      no    1259      no   no   unknown  11
## 2094  61       retired divorced      no    1857     yes   no   unknown  28
## 2095  38    management  married      no    1221     yes   no   unknown   3
## 2096  36    technician  married      no    1731     yes  yes   unknown  28
## 2097  34       student   single      no    1281      no   no  cellular  25
## 2098  46    technician  married      no    9299      no   no  cellular  19
## 2099  31     housemaid   single      no     287     yes   no  cellular  19
## 2100  43    management divorced      no    -173      no  yes  cellular  18
## 2101  37   blue-collar   single      no     240     yes   no   unknown   6
## 2102  37      services  married      no       0     yes  yes   unknown  12
## 2103  56      services  married      no     966      no  yes  cellular  10
## 2104  26    unemployed   single      no     461      no   no  cellular  28
## 2105  42    unemployed  married      no     259     yes   no   unknown  15
## 2106  31    technician  married      no    -720     yes   no   unknown  17
## 2107  39     housemaid  married      no      94      no   no  cellular   6
## 2108  34   blue-collar  married      no     405     yes   no   unknown  21
## 2109  57        admin.  married      no    1218      no   no  cellular  29
## 2110  48    unemployed  married      no    1571     yes   no  cellular  24
## 2111  49    management   single      no       1     yes   no   unknown   6
## 2112  44    technician  married      no    4389      no   no  cellular  29
## 2113  46    technician  married      no    4176     yes   no   unknown  12
## 2114  50    unemployed  married      no     297     yes   no  cellular  31
## 2115  58    technician  married      no    5618     yes   no   unknown  15
## 2116  61       retired  married      no    1257      no   no  cellular  10
## 2117  49   blue-collar  married      no    1350      no   no  cellular  18
## 2118  56      services divorced      no    6101      no   no  cellular  14
## 2119  26       student   single      no     826      no   no  cellular  29
## 2120  44      services  married      no    -230     yes  yes   unknown  27
## 2121  37        admin.  married      no    1207     yes   no telephone   6
## 2122  58   blue-collar  married      no       0      no   no telephone  13
## 2123  30      services   single     yes    -366     yes   no  cellular  18
## 2124  37        admin.  married      no     801      no   no  cellular  11
## 2125  36    technician   single      no     333      no   no  cellular   7
## 2126  59    management  married      no     518      no   no  cellular  11
## 2127  27      services  married      no       0     yes   no  cellular  22
## 2128  42    unemployed  married      no    1270     yes   no   unknown  15
## 2129  36        admin. divorced      no     181     yes   no  cellular   7
## 2130  46    management   single      no     311     yes  yes  cellular  27
## 2131  35    technician   single      no       0      no   no  cellular  14
## 2132  24        admin.   single      no     120     yes   no  cellular  18
## 2133  71       retired divorced      no       0      no   no  cellular  26
## 2134  41   blue-collar  married      no    2717     yes  yes  cellular  24
## 2135  25   blue-collar   single      no    1429     yes   no   unknown  29
## 2136  52 self-employed  married      no    1066     yes   no   unknown  16
## 2137  55   blue-collar  married      no    3485      no   no  cellular  18
## 2138  52        admin.  married      no    4493      no   no  cellular  21
## 2139  29   blue-collar  married      no     415     yes   no  cellular  11
## 2140  44   blue-collar   single      no    1593     yes   no  cellular  19
## 2141  46    management  married      no      21     yes   no  cellular   7
## 2142  39   blue-collar  married      no    3045      no   no  cellular   4
## 2143  28      services   single      no     348     yes   no   unknown  21
## 2144  54    management  married      no     384     yes   no  cellular  12
## 2145  47    technician  married      no      11      no   no  cellular  21
## 2146  42   blue-collar  married      no       0     yes   no  cellular  30
## 2147  40    technician  married      no    -282     yes   no   unknown   6
## 2148  31    management  married      no    1224     yes  yes  cellular  20
## 2149  37 self-employed  married      no    1146      no  yes  cellular   9
## 2150  45      services  married      no      27     yes  yes  cellular  31
## 2151  22      services   single      no     652      no   no telephone  31
## 2152  44        admin.   single      no    2524      no   no   unknown  19
## 2153  59      services  married      no      64     yes  yes telephone  12
## 2154  27        admin.   single      no    3638      no   no  cellular  11
## 2155  34   blue-collar  married      no    -204     yes   no  cellular  14
## 2156  56    management  married      no     208      no  yes telephone  31
## 2157  33      services  married      no    -384     yes   no   unknown  28
## 2158  28       student   single      no    2306      no   no  cellular  29
## 2159  26    management   single      no      45      no   no  cellular  10
## 2160  57    management divorced      no    6468     yes   no  cellular  31
## 2161  52        admin.  married      no    1746      no   no  cellular  30
## 2162  49    technician  married      no     313      no   no  cellular   9
## 2163  44     housemaid  married      no    1109     yes  yes  cellular  29
## 2164  30   blue-collar   single      no     183     yes   no  cellular  18
## 2165  29        admin.   single      no     200     yes   no  cellular  18
## 2166  43      services divorced      no    -145     yes   no  cellular  28
## 2167  35    technician  married      no     150      no   no  cellular  18
## 2168  34   blue-collar   single      no    1599     yes   no  cellular  12
## 2169  34    management  married      no     179     yes   no  cellular  20
## 2170  39  entrepreneur  married      no       4     yes  yes  cellular   2
## 2171  33   blue-collar divorced      no    3546     yes   no   unknown  23
## 2172  33    management  married      no     149     yes  yes  cellular  22
## 2173  41    management divorced      no     276     yes   no   unknown   7
## 2174  40    management  married      no     569      no   no  cellular  20
## 2175  44      services divorced      no      20      no   no   unknown   9
## 2176  56   blue-collar divorced      no      12      no   no  cellular   8
## 2177  35    management  married      no    5057     yes   no   unknown   4
## 2178  31    technician   single      no     830     yes   no  cellular   9
## 2179  32      services   single      no     785      no   no  cellular   3
## 2180  60    management  married      no     358      no   no   unknown  18
## 2181  35    management   single      no    1750     yes   no  cellular  30
## 2182  40        admin.  married      no    1412      no   no  cellular  31
## 2183  37    technician  married      no     720     yes   no  cellular  14
## 2184  35   blue-collar  married      no     914     yes   no   unknown  27
## 2185  58        admin.  married      no    3735      no   no  cellular  17
## 2186  46        admin. divorced      no     289      no  yes  cellular  21
## 2187  37    management  married      no    6771      no   no  cellular   7
## 2188  26       student   single      no     279      no   no  cellular   7
## 2189  28    technician   single      no    4513     yes   no   unknown  27
## 2190  48   blue-collar  married      no     238     yes  yes  cellular   2
## 2191  36    management  married      no   11675     yes   no  cellular  20
## 2192  39    technician  married      no      52      no   no  cellular  12
## 2193  40        admin. divorced      no       6      no   no   unknown  11
## 2194  56    management divorced      no       0      no   no   unknown   6
## 2195  32        admin.   single      no    2692     yes   no  cellular  18
## 2196  34   blue-collar  married      no    6411     yes  yes   unknown   9
## 2197  28    management  married      no     247      no   no  cellular   6
## 2198  46    technician  married      no    2207     yes   no   unknown  16
## 2199  33   blue-collar divorced      no     -53     yes   no   unknown  26
## 2200  51      services divorced      no       0      no   no telephone  30
## 2201  59       retired  married      no       0      no   no   unknown  18
## 2202  28   blue-collar  married      no     -65     yes   no  cellular   4
## 2203  52    unemployed  married      no    1639      no   no  cellular   8
## 2204  30    management   single      no     220     yes   no  cellular   4
## 2205  41    management  married      no     850      no   no   unknown   6
## 2206  37        admin.  married      no      55     yes  yes  cellular  27
## 2207  35 self-employed   single      no     398      no   no  cellular   5
## 2208  50  entrepreneur  married      no    2410      no   no  cellular  21
## 2209  29    management  married      no       0     yes   no  cellular   6
## 2210  54    technician  married      no     415     yes   no   unknown  19
## 2211  27    management   single      no    3104     yes   no   unknown  28
## 2212  32    management divorced      no     530     yes   no  cellular   3
## 2213  39     housemaid  married      no     562      no   no  cellular  12
## 2214  28    technician   single      no     584     yes   no  cellular  13
## 2215  54        admin.  married      no      19      no   no  cellular  26
## 2216  27      services   single      no     167      no  yes  cellular   8
## 2217  35    management  married      no    3161      no   no  cellular   8
## 2218  30    technician  married      no     817     yes   no  cellular  21
## 2219  44  entrepreneur  married      no     242      no  yes  cellular  21
## 2220  24        admin.   single      no      66     yes   no   unknown   3
## 2221  33  entrepreneur   single      no    1481     yes   no  cellular  13
## 2222  46   blue-collar  married      no       5      no   no  cellular  18
## 2223  27    technician   single      no     235     yes   no  cellular  12
## 2224  34    technician   single     yes      -1      no   no  cellular  27
## 2225  55    technician divorced      no    3450      no   no  cellular  11
## 2226  33      services  married      no    4434     yes   no   unknown  20
## 2227  35    technician  married      no      18     yes  yes  cellular  14
## 2228  33    unemployed   single      no     237     yes   no  cellular   4
## 2229  51  entrepreneur  married      no    3188     yes  yes  cellular  19
## 2230  57    technician divorced      no       0     yes   no   unknown  14
## 2231  59        admin.  married      no    1914     yes   no  cellular   7
## 2232  36      services   single      no     461      no   no  cellular  18
## 2233  57    technician  married      no     -40      no  yes  cellular   7
## 2234  46    management  married      no       0      no   no  cellular  27
## 2235  44  entrepreneur  married      no     692      no   no   unknown  18
## 2236  56    management  married      no     154      no   no  cellular  25
## 2237  35    management   single      no    1496     yes   no  cellular  22
## 2238  40  entrepreneur  married      no      70      no   no  cellular  20
## 2239  30        admin.   single      no      52      no  yes  cellular   7
## 2240  31        admin.   single      no      78     yes   no  cellular  11
## 2241  36      services   single      no      72     yes   no   unknown   8
## 2242  32   blue-collar  married      no     143     yes  yes  cellular  18
## 2243  36   blue-collar  married      no    1554     yes   no   unknown  12
## 2244  30       student   single      no      34     yes   no   unknown   6
## 2245  59    unemployed divorced      no    7469      no   no  cellular  22
## 2246  29        admin.  married      no     453     yes   no  cellular  17
## 2247  53        admin. divorced      no    -112      no   no   unknown  19
## 2248  41    unemployed  married      no     121     yes   no   unknown   9
## 2249  24       student   single      no      82     yes   no   unknown   5
## 2250  30    unemployed   single      no    -306     yes   no   unknown   3
## 2251  31      services   single      no       0     yes   no  cellular  17
## 2252  49 self-employed divorced      no    3293      no   no  cellular   8
## 2253  30    unemployed  married      no    1566      no   no  cellular  19
## 2254  43      services  married      no       0     yes   no   unknown  14
## 2255  34   blue-collar  married      no     587     yes   no   unknown   4
## 2256  44    technician  married      no     858      no   no   unknown  30
## 2257  35      services  married      no    2179      no   no  cellular  20
## 2258  36    management   single      no     202      no   no  cellular  13
## 2259  43        admin.  married      no    1625     yes  yes  cellular  21
## 2260  29   blue-collar   single      no     455      no   no telephone  21
## 2261  41        admin.  married      no    3138      no   no  cellular  14
## 2262  35   blue-collar  married      no    -465      no   no  cellular  12
## 2263  57   blue-collar  married      no    4148      no   no   unknown  18
## 2264  43   blue-collar divorced      no     110     yes  yes   unknown   6
## 2265  37    technician  married      no    5287     yes  yes  cellular  19
## 2266  35    technician  married      no    1140     yes   no  cellular  14
## 2267  26   blue-collar  married      no    5795     yes   no  cellular  14
## 2268  37    technician  married      no    1733     yes   no  cellular  12
## 2269  54       retired   single      no     515     yes   no   unknown  17
## 2270  58   blue-collar  married      no       0     yes   no   unknown  19
## 2271  49    management  married      no     322      no   no  cellular   6
## 2272  39    management  married      no    5142      no   no  cellular   3
## 2273  29       student  married      no   10596     yes   no  cellular  12
## 2274  38      services  married      no    5000      no   no  cellular   4
## 2275  56    management divorced      no     -59      no  yes  cellular  28
## 2276  27      services   single      no    9636     yes   no   unknown  28
## 2277  56  entrepreneur  married      no   16125      no   no telephone   7
## 2278  42   blue-collar  married      no    1123     yes   no   unknown  29
## 2279  19       student   single      no     424      no   no  cellular  30
## 2280  44   blue-collar  married      no    1308      no   no  cellular  30
## 2281  31        admin.   single      no     483     yes  yes  cellular  20
## 2282  47    technician divorced      no     442     yes   no  cellular  11
## 2283  42    management  married      no   27696      no   no  cellular  12
## 2284  53        admin. divorced      no    2647     yes   no  cellular   9
## 2285  50   blue-collar  married      no    1203     yes  yes   unknown  28
## 2286  33    management  married      no      91      no   no  cellular  10
## 2287  32    management   single      no     703     yes   no  cellular  17
## 2288  38        admin.  married      no    1209      no   no  cellular  31
## 2289  34        admin. divorced      no     183      no  yes   unknown   4
## 2290  27      services   single      no    -266      no  yes  cellular  10
## 2291  50   blue-collar   single      no     496     yes   no  cellular   8
## 2292  30 self-employed  married     yes   -1083     yes   no  cellular   6
## 2293  33    technician   single      no     318     yes   no  cellular  14
## 2294  58        admin. divorced      no    3058     yes   no telephone  11
## 2295  32    technician   single      no    3818      no   no  cellular  18
## 2296  27   blue-collar  married      no    1535     yes   no  cellular  15
## 2297  24    technician   single      no    -192     yes   no   unknown  13
## 2298  57    management  married      no     929      no   no  cellular  19
## 2299  59    management divorced      no      51      no   no  cellular  28
## 2300  51        admin. divorced      no    2717      no   no   unknown   9
## 2301  46    management  married      no    7331      no   no  cellular  11
## 2302  35    technician   single      no     175     yes   no  cellular  29
## 2303  41    technician   single      no    1147     yes   no   unknown  20
## 2304  40       retired   single      no       0      no   no   unknown   5
## 2305  34   blue-collar  married      no    2720     yes   no  cellular  21
## 2306  30   blue-collar   single      no     445     yes   no  cellular  16
## 2307  33   blue-collar   single      no    4404     yes   no  cellular  20
## 2308  48     housemaid divorced      no    1583      no  yes telephone  18
## 2309  36    management  married      no     332     yes   no  cellular  22
## 2310  30   blue-collar  married      no     313     yes  yes  cellular   6
## 2311  37    unemployed   single      no    1648     yes   no   unknown   5
## 2312  47      services  married      no     459      no   no  cellular  19
## 2313  33   blue-collar  married      no     833     yes  yes  cellular  18
## 2314  24       student   single      no   23878      no   no  cellular  18
## 2315  32      services   single      no    1987     yes   no telephone  15
## 2316  45   blue-collar   single      no     615     yes   no  cellular  15
## 2317  53 self-employed  married      no    -488     yes   no  cellular   6
## 2318  55    management divorced      no     204     yes   no  cellular  11
## 2319  32    management  married      no    -360     yes   no  cellular  21
## 2320  35    technician divorced      no       0      no   no   unknown  21
## 2321  48    technician  married      no    9207      no   no  cellular  18
## 2322  43    technician divorced      no    1612      no   no  cellular  28
## 2323  34    management   single      no    -444     yes  yes  cellular  17
## 2324  58    management  married      no    2360      no   no   unknown  15
## 2325  33    management   single      no     383     yes   no  cellular   9
## 2326  32    unemployed   single      no    8304      no   no  cellular   2
## 2327  43    management  married      no     536     yes   no  cellular  14
## 2328  34   blue-collar  married      no     283      no  yes   unknown   6
## 2329  42  entrepreneur  married      no     718     yes   no  cellular  14
## 2330  47   blue-collar  married     yes      25     yes  yes  cellular   7
## 2331  39   blue-collar  married      no     879     yes   no   unknown  26
## 2332  48       unknown  married      no    2261      no   no   unknown  18
## 2333  24      services   single      no    -141     yes   no   unknown   4
## 2334  36      services  married      no       0     yes   no  cellular   8
## 2335  47    technician divorced      no    4135     yes   no   unknown  14
## 2336  45   blue-collar  married      no     532     yes   no   unknown  14
## 2337  33      services  married      no       0     yes  yes  cellular   7
## 2338  31   blue-collar   single      no    2089     yes   no   unknown  20
## 2339  32    technician   single      no      14     yes  yes  cellular  16
## 2340  47      services  married      no    -835     yes  yes   unknown  25
## 2341  27    technician   single      no       8     yes   no   unknown  20
## 2342  37   blue-collar   single      no   13156     yes   no   unknown  21
## 2343  52        admin.   single      no    2398     yes   no  cellular   3
## 2344  41    technician  married      no      -4      no   no  cellular  20
## 2345  33    technician  married      no    1029     yes   no  cellular   9
## 2346  32   blue-collar   single      no      22      no   no  cellular   7
## 2347  52    technician divorced      no     511      no  yes  cellular  20
## 2348  34        admin.  married      no     798     yes   no  cellular   8
## 2349  61    management  married      no       0     yes   no  cellular  15
## 2350  40   blue-collar divorced      no      71     yes   no  cellular   8
## 2351  30   blue-collar   single      no     327     yes   no telephone  18
## 2352  42    technician   single      no     -15      no   no  cellular  17
## 2353  26        admin.   single      no     338      no   no  cellular  29
## 2354  27    management  married      no    1531     yes   no  cellular  15
## 2355  31    management   single      no     241     yes   no  cellular  24
## 2356  34    technician   single      no    1161     yes   no   unknown  21
## 2357  51    management divorced      no     292      no   no  cellular  26
## 2358  60      services  married      no     594     yes   no  cellular   3
## 2359  32    management   single      no       2     yes   no  cellular  11
## 2360  49   blue-collar divorced      no      39     yes   no  cellular  13
## 2361  38       unknown  married      no     653      no   no telephone  29
## 2362  37   blue-collar  married      no     660     yes  yes   unknown  20
## 2363  45  entrepreneur  married      no     369     yes   no   unknown  19
## 2364  33    unemployed   single      no     170     yes   no   unknown   3
## 2365  55   blue-collar  married      no       0      no   no   unknown  17
## 2366  37    management  married      no    1276      no   no  cellular  14
## 2367  31      services  married      no     356     yes   no   unknown  20
## 2368  32    technician  married      no    -300      no   no  cellular  28
## 2369  34    management   single      no     549      no   no  cellular   6
## 2370  36   blue-collar   single      no    1089     yes   no telephone  11
## 2371  35        admin.   single      no     368     yes   no   unknown  16
## 2372  30    management   single      no     440     yes   no  cellular  11
## 2373  40    management  married      no     373     yes  yes   unknown  13
## 2374  26     housemaid   single     yes   -1006     yes  yes  cellular  21
## 2375  70       retired  married      no    2626      no   no  cellular   2
## 2376  43    management  married      no    3518      no   no  cellular  15
## 2377  29        admin.  married      no     387     yes  yes   unknown  14
## 2378  31        admin. divorced      no    1890     yes   no  cellular  21
## 2379  28    technician  married      no    -302     yes   no  cellular  13
## 2380  53    technician  married      no    6671     yes  yes  cellular  30
## 2381  46        admin.  married      no     186     yes   no  cellular  11
## 2382  30    management   single      no    2344     yes   no  cellular  20
## 2383  26   blue-collar   single      no     102     yes   no   unknown  16
## 2384  47    technician  married      no    1375     yes  yes   unknown   2
## 2385  55    technician   single      no      99     yes   no  cellular  12
## 2386  54        admin.  married      no    4943      no   no  cellular  12
## 2387  41   blue-collar   single      no     925     yes   no telephone  13
## 2388  34        admin.  married      no     396     yes   no  cellular  16
## 2389  30   blue-collar  married      no     365      no   no   unknown   1
## 2390  67       retired  married      no    1443      no   no  cellular   8
## 2391  33   blue-collar   single      no       0      no   no telephone  25
## 2392  35    management  married      no     387     yes   no  cellular  16
## 2393  36        admin.   single      no    5871      no   no  cellular  19
## 2394  55       retired  married      no      39      no   no  cellular  27
## 2395  39    management   single      no    1234      no   no telephone  29
## 2396  55    technician  married      no     240     yes   no  cellular   2
## 2397  37    management  married      no     308     yes   no   unknown   7
## 2398  39    management  married      no     568     yes  yes   unknown  30
## 2399  49        admin.  married      no      82     yes   no   unknown   6
## 2400  48    unemployed  married      no     484      no   no  cellular  18
## 2401  53       retired divorced      no    1126      no   no   unknown  20
## 2402  46    technician  married      no    1740     yes   no  cellular  11
## 2403  48    technician  married      no     454     yes   no  cellular  10
## 2404  50   blue-collar  married      no      26     yes   no  cellular   7
## 2405  38      services  married      no    3259     yes   no   unknown  19
## 2406  30   blue-collar divorced      no    4591     yes   no  cellular  19
## 2407  52      services  married      no    2420     yes   no   unknown  19
## 2408  31   blue-collar  married      no      33      no   no   unknown   4
## 2409  25        admin.  married      no     894     yes   no   unknown  28
## 2410  30  entrepreneur   single      no     999      no   no  cellular  22
## 2411  49   blue-collar  married      no     154     yes   no   unknown   5
## 2412  42   blue-collar  married      no      15     yes   no   unknown   6
## 2413  50    technician  married      no    3176      no   no  cellular   7
## 2414  35    technician  married      no    1364     yes  yes  cellular  20
## 2415  29   blue-collar  married      no    -114     yes   no  cellular  15
## 2416  55   blue-collar  married      no      23      no   no  cellular  13
## 2417  31    management divorced      no     106     yes   no  cellular   5
## 2418  27      services   single      no     430     yes   no   unknown  23
## 2419  29   blue-collar  married      no     844     yes   no   unknown  27
## 2420  57     housemaid divorced      no   11632      no   no telephone  30
## 2421  20       student   single      no     556     yes   no   unknown  27
## 2422  29   blue-collar  married      no    1171     yes   no   unknown  28
## 2423  59   blue-collar  married      no       0     yes  yes  cellular  21
## 2424  37  entrepreneur  married      no       0      no   no  cellular  25
## 2425  46    management  married      no    1489     yes   no   unknown  20
## 2426  42    management  married      no    1773      no   no  cellular   9
## 2427  52    technician  married      no       7      no   no   unknown   6
## 2428  38    technician   single      no       9     yes   no   unknown   6
## 2429  46 self-employed  married      no     156      no   no  cellular  20
## 2430  40    technician divorced      no     348     yes   no  cellular   5
## 2431  41    management  married      no    6526      no   no   unknown  15
## 2432  40    technician  married      no     265      no   no   unknown  18
## 2433  58    management  married      no    1021      no   no   unknown  18
## 2434  47    management  married      no    2010      no   no telephone   4
## 2435  46   blue-collar  married      no     143     yes   no   unknown   7
## 2436  58   blue-collar  married      no     381      no   no  cellular  11
## 2437  48      services   single      no    1499     yes   no  cellular  12
## 2438  42      services  married      no     412     yes   no telephone  19
## 2439  30    management   single      no    1571      no   no  cellular   5
## 2440  48    technician  married     yes     295      no  yes  cellular  17
## 2441  28   blue-collar  married      no       0     yes   no  cellular  15
## 2442  36 self-employed  married      no     188     yes  yes  cellular   4
## 2443  40    management  married      no     472     yes   no   unknown  30
## 2444  51   blue-collar divorced      no     325     yes   no   unknown   6
## 2445  40        admin.  married      no     153     yes   no   unknown  14
## 2446  50    management divorced      no      30      no   no  cellular  20
## 2447  46   blue-collar  married      no     176      no   no   unknown  29
## 2448  40   blue-collar  married      no    2880     yes   no   unknown   6
## 2449  43    technician  married      no     463      no   no   unknown   3
## 2450  37    management  married      no     725      no   no  cellular  26
## 2451  47    management  married     yes       0      no  yes  cellular  22
## 2452  31   blue-collar   single      no       0     yes   no  cellular   7
## 2453  37   blue-collar  married      no     298     yes   no  cellular  31
## 2454  38   blue-collar  married      no     861     yes   no  cellular  11
## 2455  40        admin.  married      no    2591     yes  yes  cellular   7
## 2456  43    technician  married      no     764     yes   no  cellular  14
## 2457  34   blue-collar  married      no    6352     yes   no  cellular   5
## 2458  50    management   single      no     486      no  yes   unknown  11
## 2459  44    technician  married      no       0      no  yes  cellular   4
## 2460  66       retired  married      no    1004      no   no  cellular  28
## 2461  42    technician  married      no     314      no   no  cellular  27
## 2462  54        admin. divorced      no     791      no  yes  cellular  10
## 2463  30        admin. divorced      no     370     yes   no   unknown  15
## 2464  58    management  married      no    7387      no   no telephone  17
## 2465  33    technician  married      no     503      no   no  cellular  29
## 2466  37    management divorced      no      88      no   no  cellular   2
## 2467  34   blue-collar  married      no    -703     yes   no  cellular  18
## 2468  34    management divorced      no     488     yes   no   unknown  16
## 2469  34    management  married      no       0      no   no  cellular   3
## 2470  49   blue-collar  married      no     141      no   no  cellular   6
## 2471  29      services   single      no      95     yes   no   unknown  13
## 2472  46        admin.  married      no      68     yes   no  cellular  27
## 2473  42    management  married      no    1323     yes  yes   unknown  15
## 2474  54        admin.   single      no    3344     yes   no  cellular  14
## 2475  32    management   single      no     697      no   no  cellular   7
## 2476  38    unemployed   single      no    1354     yes   no  cellular  13
## 2477  30    management   single      no    3384      no   no  cellular   4
## 2478  28   blue-collar  married      no      17      no   no   unknown  28
## 2479  61       retired  married      no     483      no   no  cellular  23
## 2480  27    management   single      no     616     yes   no  cellular  22
## 2481  65       retired  married      no    1153      no   no  cellular   3
## 2482  35     housemaid  married      no     113     yes   no  cellular  17
## 2483  56       retired  married      no     102     yes   no telephone  11
## 2484  32    management   single      no    1834     yes   no   unknown   2
## 2485  32    technician  married      no    4790     yes   no  cellular  22
## 2486  37    technician   single      no    3943      no   no  cellular   6
## 2487  35   blue-collar  married      no     378     yes   no   unknown  16
## 2488  37    management  married      no       0     yes   no   unknown  12
## 2489  39   blue-collar   single      no      48      no   no  cellular   3
## 2490  37      services   single      no     608      no   no  cellular  14
## 2491  44   blue-collar  married      no     617     yes   no   unknown  13
## 2492  67       retired   single      no    3377      no   no telephone  23
## 2493  46 self-employed  married      no    2295     yes   no   unknown  11
## 2494  39        admin.   single      no       0      no  yes   unknown  19
## 2495  58 self-employed  married      no    8014     yes   no  cellular  19
## 2496  33        admin.  married      no    2468     yes  yes  cellular   6
## 2497  32        admin.   single      no     642     yes   no  cellular   5
## 2498  42      services  married      no    -437     yes  yes   unknown  27
## 2499  45     housemaid  married      no       0      no   no   unknown   9
## 2500  33    technician   single      no     261     yes   no   unknown  14
## 2501  60       unknown  married      no    2450      no   no   unknown   9
## 2502  50   blue-collar  married      no    1389     yes   no  cellular  17
## 2503  36    management   single      no       0     yes   no   unknown   3
## 2504  31        admin.  married      no    -581     yes   no   unknown   2
## 2505  25        admin.   single      no     285      no   no  cellular   3
## 2506  34        admin.  married      no    1551     yes  yes  cellular   8
## 2507  26       student   single      no     655      no   no  cellular  16
## 2508  31    management  married      no     242     yes   no  cellular   9
## 2509  28    technician   single      no    1026     yes   no  cellular  13
## 2510  42   blue-collar  married     yes    -204     yes   no  cellular  11
## 2511  38      services   single      no    -196     yes   no  cellular   2
## 2512  38   blue-collar  married      no    2283     yes   no  cellular  14
## 2513  53        admin. divorced      no    2687     yes   no  cellular  29
## 2514  43   blue-collar  married      no    1211     yes   no   unknown   6
## 2515  32      services   single      no    2881      no   no  cellular   2
## 2516  49 self-employed divorced      no    3293      no   no  cellular  24
## 2517  46    technician  married      no    1975     yes   no  cellular   8
## 2518  54    unemployed   single      no     380      no   no  cellular  17
## 2519  34    management  married      no    2026     yes   no   unknown  17
## 2520  43    management  married      no       0     yes   no  cellular  17
## 2521  36    management   single      no     112     yes   no  cellular  15
## 2522  33    technician  married      no    -160     yes   no  cellular  21
## 2523  74       retired  married      no       0      no   no telephone  13
## 2524  33        admin.   single      no     555     yes   no  cellular   9
## 2525  23    management  married      no     175     yes   no   unknown  26
## 2526  59    management  married      no     771      no   no telephone  13
## 2527  60       retired  married      no    2196      no   no  cellular  15
## 2528  36      services divorced      no    -330     yes  yes   unknown  27
## 2529  33   blue-collar  married      no     312     yes   no   unknown   4
## 2530  39   blue-collar divorced     yes    -202     yes  yes  cellular  15
## 2531  35    management   single      no     996      no   no   unknown  20
## 2532  40  entrepreneur  married      no    6403      no   no  cellular  22
## 2533  34        admin.  married      no      21      no  yes  cellular   2
## 2534  51   blue-collar  married      no     480     yes   no  cellular  12
## 2535  43    technician   single      no     463     yes   no  cellular  17
## 2536  45    management  married      no    1134      no  yes  cellular   9
## 2537  32      services  married      no      59     yes  yes   unknown   9
## 2538  39       unknown   single      no       0      no   no telephone  28
## 2539  37   blue-collar  married      no      20      no  yes telephone  15
## 2540  29        admin.  married      no     624     yes   no   unknown  12
## 2541  44        admin.   single     yes    -612     yes   no  cellular  31
## 2542  31      services  married      no   11512     yes   no   unknown  21
## 2543  29 self-employed   single      no    3290      no   no  cellular  12
## 2544  49    unemployed  married     yes      11     yes   no telephone  31
## 2545  58      services divorced      no    -158      no   no telephone  18
## 2546  64     housemaid  married      no      67      no   no telephone  25
## 2547  62    management  married      no    7458      no   no  cellular  30
## 2548  59 self-employed  married      no     185      no   no  cellular  22
## 2549  52    technician  married      no     371     yes  yes  cellular  21
## 2550  37      services   single      no     459      no   no telephone  16
## 2551  34  entrepreneur   single     yes    1709      no  yes  cellular  18
## 2552  56   blue-collar  married      no     551      no   no   unknown  29
## 2553  46    management divorced      no     675      no  yes   unknown  12
## 2554  59    management  married      no    4152     yes   no  cellular   1
## 2555  32   blue-collar   single      no    -255      no  yes   unknown   2
## 2556  46    technician divorced      no       0     yes  yes  cellular   8
## 2557  39        admin.  married      no     168     yes   no  cellular  19
## 2558  46   blue-collar  married      no    5393     yes   no  cellular  20
## 2559  44      services  married      no     742      no   no telephone  30
## 2560  35    technician   single      no     744     yes   no  cellular   7
## 2561  54      services  married      no     198     yes   no  cellular  31
## 2562  35    technician divorced      no       0      no   no  cellular  24
## 2563  51  entrepreneur   single      no       0      no   no  cellular  30
## 2564  34      services  married      no    1442      no   no  cellular  11
## 2565  77       retired  married      no    4112      no   no telephone  26
## 2566  45   blue-collar  married      no    4646     yes   no   unknown  13
## 2567  45        admin. divorced      no    1201      no   no  cellular  30
## 2568  46    technician  married      no    1028     yes   no  cellular   2
## 2569  28      services  married      no     462     yes  yes  cellular   5
## 2570  45   blue-collar  married      no     196     yes   no  cellular   2
## 2571  28     housemaid   single      no     781     yes   no  cellular  17
## 2572  29      services  married      no    -597      no   no  cellular   7
## 2573  37      services   single      no     248     yes   no  cellular   8
## 2574  58    unemployed   single      no    1013     yes   no  cellular  30
## 2575  31      services  married      no     338     yes   no  cellular  28
## 2576  40        admin.  married      no     824     yes   no  cellular  17
## 2577  32        admin.   single      no     131     yes   no  cellular  22
## 2578  82       retired  married      no     276      no   no telephone  17
## 2579  29        admin.   single      no      65     yes   no  cellular  14
## 2580  42      services divorced      no     241     yes   no   unknown  19
## 2581  56     housemaid divorced      no    1866      no  yes  cellular   1
## 2582  32   blue-collar  married      no    1914     yes   no  cellular  14
## 2583  54   blue-collar  married      no    1487     yes   no   unknown  14
## 2584  46    technician  married      no       0     yes   no telephone  31
## 2585  31    technician  married      no       0      no   no  cellular  20
## 2586  47   blue-collar  married      no       0      no   no  cellular  26
## 2587  34    management divorced      no      27      no  yes  cellular  19
## 2588  47   blue-collar divorced      no    1480     yes   no  cellular  15
## 2589  35        admin.   single      no     994      no   no  cellular   2
## 2590  38    management  married      no     546      no   no  cellular  22
## 2591  33    management divorced      no     723     yes   no   unknown  27
## 2592  49    technician  married      no    3635     yes   no  cellular   5
## 2593  35    technician  married      no    -288     yes  yes  cellular  30
## 2594  40      services  married      no    1117     yes   no   unknown  13
## 2595  48 self-employed  married      no    1175     yes  yes  cellular  19
## 2596  43        admin.  married      no     323     yes  yes  cellular  12
## 2597  29    management  married      no       1     yes  yes   unknown  16
## 2598  60       retired  married      no       3      no   no   unknown  18
## 2599  39        admin.  married      no     104     yes   no   unknown   6
## 2600  31   blue-collar  married      no     297     yes   no   unknown  12
## 2601  51   blue-collar  married      no    4695      no   no  cellular  29
## 2602  33   blue-collar  married      no     308     yes   no  cellular  13
## 2603  39   blue-collar  married      no     315     yes   no  cellular  15
## 2604  28      services  married      no     376      no  yes telephone  29
## 2605  50   blue-collar  married      no    -581     yes   no  cellular  14
## 2606  77       retired  married      no    2590      no   no telephone  15
## 2607  49    technician  married      no    6138      no   no   unknown  20
## 2608  48        admin.  married      no       3     yes   no   unknown  27
## 2609  34    management  married      no     176      no   no  cellular  18
## 2610  42    technician   single      no     146      no   no  cellular   8
## 2611  49  entrepreneur  married      no     687      no   no  cellular  18
## 2612  56       retired  married      no   16432      no   no  cellular  19
## 2613  29    unemployed  married      no      39      no  yes  cellular  18
## 2614  33      services   single      no     406     yes   no  cellular   5
## 2615  34    management   single      no    1012     yes  yes  cellular  15
## 2616  57    unemployed  married      no     209      no   no   unknown  19
## 2617  42    unemployed  married      no    -523     yes   no  cellular  11
## 2618  54      services  married      no     869      no   no  cellular  14
## 2619  43    management divorced      no      51      no   no  cellular   2
## 2620  52  entrepreneur   single      no    3469     yes   no  cellular  20
## 2621  45   blue-collar  married      no     248     yes   no   unknown   6
## 2622  36    management  married      no     953     yes  yes telephone   4
## 2623  27    management   single      no       0     yes   no  cellular   1
## 2624  47    management   single      no    -246     yes   no  cellular   5
## 2625  37    technician   single      no     363     yes   no  cellular  21
## 2626  34   blue-collar  married      no      41     yes   no  cellular   6
## 2627  59    management  married      no    3428     yes  yes  cellular  19
## 2628  56    management  married      no    1803      no   no  cellular  20
## 2629  50    management  married      no    2717     yes   no  cellular  18
## 2630  59   blue-collar  married      no      99     yes   no  cellular   5
## 2631  45        admin.  married      no    -299     yes   no  cellular   8
## 2632  32    technician  married      no     903     yes   no  cellular  23
## 2633  43   blue-collar  married      no      46     yes   no  cellular  15
## 2634  31      services   single      no      13      no  yes  cellular   6
## 2635  46    technician   single     yes   -1124     yes  yes   unknown   9
## 2636  38   blue-collar   single      no     334     yes   no  cellular  18
## 2637  31    management   single      no      18      no   no  cellular   8
## 2638  43    technician  married      no    1485      no   no  cellular  21
## 2639  58       retired  married      no      69      no   no  cellular  29
## 2640  36    management  married      no     406      no   no  cellular  14
## 2641  33   blue-collar   single      no     127     yes   no   unknown  29
## 2642  30      services   single      no      44      no   no   unknown  16
## 2643  38  entrepreneur   single     yes       0     yes   no  cellular  18
## 2644  48    technician  married      no     504      no  yes  cellular   6
## 2645  35    technician   single      no       2      no   no  cellular  11
## 2646  36   blue-collar  married      no    -417     yes   no   unknown  27
## 2647  41        admin.   single      no    1322     yes   no  cellular  29
## 2648  52    management  married      no    2578      no   no  cellular  17
## 2649  36    management divorced      no    2397      no   no  cellular  25
## 2650  49    management  married      no    1533      no   no  cellular  17
## 2651  42    management  married      no    4014     yes   no  cellular  21
## 2652  55    management  married      no      86      no   no telephone  16
## 2653  52        admin.   single      no    2332      no   no  cellular  29
## 2654  51  entrepreneur  married      no    3404      no   no  cellular  31
## 2655  55    technician  married      no     199      no   no  cellular  11
## 2656  50      services  married      no     901     yes   no   unknown  20
## 2657  48      services   single      no     848     yes   no   unknown  15
## 2658  46    management  married      no     144      no   no  cellular  22
## 2659  36      services  married      no    1746     yes   no   unknown  26
## 2660  34   blue-collar  married      no    -185     yes  yes   unknown  13
## 2661  33  entrepreneur  married      no    3140     yes  yes  cellular  21
## 2662  27    technician   single      no     629     yes  yes   unknown  18
## 2663  32      services  married      no     109     yes   no   unknown   2
## 2664  27    management   single      no     442     yes   no   unknown  28
## 2665  33   blue-collar   single      no    6285     yes   no   unknown   2
## 2666  50    technician  married      no       0     yes   no   unknown   2
## 2667  40   blue-collar  married      no    3316      no   no   unknown  19
## 2668  41    management  married      no    1409      no   no  cellular   5
## 2669  25    technician divorced      no      86      no  yes  cellular   8
## 2670  37   blue-collar  married      no      53     yes   no   unknown  19
## 2671  54 self-employed  married      no     368      no   no  cellular  18
## 2672  39    management  married      no    -468     yes  yes  cellular   8
## 2673  31    management  married      no     777     yes   no  cellular   3
## 2674  30  entrepreneur  married      no    2551     yes   no   unknown   5
## 2675  67       retired   single      no     491      no   no telephone   6
## 2676  46   blue-collar  married      no    2944      no   no   unknown  20
## 2677  26    management   single      no     157     yes   no  cellular  30
## 2678  38        admin.   single      no     245     yes  yes  cellular  17
## 2679  45    management  married      no    1847      no   no   unknown  16
## 2680  40    management   single      no     269     yes   no  cellular  27
## 2681  29    technician   single      no      18      no   no  cellular   3
## 2682  38    management  married      no     465     yes  yes  cellular  15
## 2683  57       retired  married      no    9367      no   no  cellular  14
## 2684  36   blue-collar  married      no     142     yes   no  cellular  17
## 2685  20       student   single      no     291      no   no telephone  11
## 2686  28        admin.   single      no     551      no  yes  cellular   8
## 2687  39    technician divorced      no     807     yes  yes  cellular  13
## 2688  39    technician  married      no     616      no   no telephone   8
## 2689  51    technician  married      no     371     yes  yes  cellular  21
## 2690  37    technician  married      no    6384     yes  yes  cellular   3
## 2691  35        admin.   single      no    2452     yes   no   unknown   5
## 2692  35    management  married      no     972     yes  yes  cellular  25
## 2693  34        admin.  married      no      10      no   no  cellular  21
## 2694  38    technician  married      no     114      no   no  cellular  11
## 2695  34      services  married      no     798     yes   no   unknown   2
## 2696  30    management  married      no    1185     yes   no  cellular  18
## 2697  29      services   single      no     703     yes   no   unknown   7
## 2698  32 self-employed  married      no     102     yes   no  cellular  18
## 2699  40   blue-collar  married      no     874      no   no   unknown  14
## 2700  49   blue-collar  married      no     391     yes   no   unknown   4
## 2701  46  entrepreneur  married      no       0      no   no  cellular   2
## 2702  51 self-employed  married      no     146      no   no  cellular  15
## 2703  46        admin.  married      no     120     yes   no   unknown  14
## 2704  59    management   single      no     671     yes  yes   unknown  15
## 2705  50       retired  married      no       4     yes  yes  cellular  11
## 2706  56    technician  married      no     589     yes   no   unknown  23
## 2707  47    management  married      no    -521     yes   no  cellular   3
## 2708  70       retired divorced      no     482      no   no telephone  14
## 2709  49    management  married      no     470      no   no  cellular  18
## 2710  60       retired  married      no     209      no   no  cellular  14
## 2711  29        admin.   single      no    2083     yes   no   unknown   3
## 2712  34 self-employed  married      no    1545     yes   no  cellular  20
## 2713  53   blue-collar  married      no    4641      no   no   unknown  16
## 2714  52    technician  married      no       0      no   no  cellular   2
## 2715  76       retired  married      no    4112      no   no telephone  23
## 2716  47   blue-collar  married      no     373     yes   no  cellular  11
## 2717  34   blue-collar  married      no   17946     yes   no  cellular   6
## 2718  34   blue-collar   single      no      62     yes   no  cellular  14
## 2719  55    management  married      no    1691     yes   no  cellular  13
## 2720  39    management divorced      no    4692     yes   no telephone  19
## 2721  33    management  married      no     808     yes   no  cellular  19
## 2722  35    management  married      no       0      no   no  cellular  25
## 2723  52    management divorced      no     427      no  yes telephone  20
## 2724  30    management   single      no     604      no  yes  cellular   2
## 2725  31    technician   single      no     754      no   no  cellular   7
## 2726  41   blue-collar  married      no     167      no   no   unknown  20
## 2727  38      services  married      no      15     yes   no  cellular  18
## 2728  37    technician  married      no     332     yes   no  cellular  19
## 2729  35      services divorced      no    -718     yes   no  cellular  21
## 2730  33        admin.   single      no     303      no   no   unknown   8
## 2731  24       student   single      no     834      no   no  cellular   9
## 2732  36   blue-collar  married      no    1023     yes   no  cellular   4
## 2733  38    management   single      no      83      no  yes telephone  15
## 2734  46     housemaid  married      no     184      no   no  cellular   3
## 2735  24   blue-collar  married      no    -254     yes  yes   unknown  27
## 2736  38    technician  married      no    -255     yes  yes  cellular  24
## 2737  43  entrepreneur  married      no     903     yes   no  cellular   7
## 2738  33    technician  married      no    1021     yes   no   unknown   3
## 2739  38        admin.  married      no    4583     yes   no  cellular  17
## 2740  34    management   single      no   13014      no   no  cellular  12
## 2741  26        admin.   single      no     102      no  yes  cellular   8
## 2742  27    management   single      no   12956     yes   no   unknown  29
## 2743  54       retired  married      no    3846     yes  yes   unknown  19
## 2744  62    management  married      no       0      no   no  cellular  13
## 2745  37     housemaid  married      no    2410      no   no  cellular   4
## 2746  25    unemployed  married      no     157     yes   no  cellular  28
## 2747  38    management  married      no    3500     yes   no  cellular  16
## 2748  56    unemployed divorced      no     438      no   no   unknown  20
## 2749  52    unemployed  married      no      94      no   no  cellular  10
## 2750  54        admin.  married      no     140      no   no telephone  27
## 2751  59    management divorced      no      14      no  yes  cellular  28
## 2752  38        admin.  married      no    1839      no   no   unknown  23
## 2753  30    technician   single      no     237     yes   no  cellular   5
## 2754  30       student   single      no      25      no   no telephone  30
## 2755  33   blue-collar  married      no      80     yes   no  cellular  18
## 2756  34    management  married      no     557     yes   no  cellular  29
## 2757  66       unknown divorced      no    1993     yes   no  cellular   6
## 2758  38    technician  married      no     525     yes  yes telephone  18
## 2759  35    technician   single      no      33      no   no  cellular  29
## 2760  31    management  married      no     713     yes   no   unknown   9
## 2761  45   blue-collar  married      no     850      no   no  cellular  19
## 2762  62    management  married      no       0      no   no  cellular   3
## 2763  52   blue-collar  married      no     262      no   no   unknown  18
## 2764  24       student   single      no    1234      no   no telephone  26
## 2765  46        admin.  married      no     154      no   no  cellular  22
## 2766  57    technician  married      no    1276     yes   no  cellular  14
## 2767  37   blue-collar  married      no      95     yes   no  cellular   5
## 2768  56       retired  married      no     728      no   no  cellular  18
## 2769  43   blue-collar  married     yes     128     yes   no  cellular   3
## 2770  43    management  married      no     348      no  yes  cellular  15
## 2771  40    technician  married      no    -396     yes   no   unknown  26
## 2772  56    technician divorced      no     397     yes   no   unknown   8
## 2773  38    technician  married      no     275     yes   no  cellular   3
## 2774  33    management divorced      no    2695     yes   no  cellular  12
## 2775  37  entrepreneur  married      no    1134     yes   no   unknown   9
## 2776  83       retired divorced      no      20      no   no  cellular  27
## 2777  29    technician  married      no    4557      no   no  cellular  28
## 2778  47    technician  married      no    3519      no  yes telephone  22
## 2779  39    management  married      no     794     yes   no  cellular   4
## 2780  48    management  married      no     732      no   no  cellular  13
## 2781  27    unemployed   single      no     799      no   no  cellular   9
## 2782  31    technician  married      no      15      no   no   unknown   2
## 2783  54   blue-collar  married      no     211      no   no  cellular  25
## 2784  40    technician divorced      no       0      no   no  cellular  29
## 2785  39   blue-collar  married      no     281      no   no   unknown  20
## 2786  34   blue-collar   single      no     152     yes   no  cellular  23
## 2787  52    technician  married      no    1785      no   no  cellular  10
## 2788  43   blue-collar  married      no     197     yes   no  cellular  17
## 2789  40    management  married      no      20     yes   no   unknown  19
## 2790  41   blue-collar  married      no    -664     yes  yes  cellular  13
## 2791  56    technician  married      no     225     yes   no   unknown  12
## 2792  39   blue-collar  married      no    2003     yes   no   unknown  21
## 2793  21       student   single      no    1596      no   no  cellular  26
## 2794  50      services  married      no       1      no   no telephone  11
## 2795  32    management  married      no    2172     yes   no  cellular  22
## 2796  30    management   single      no     147      no   no  cellular   9
## 2797  38    management  married      no       0     yes   no   unknown  27
## 2798  34    technician  married      no     -56     yes   no  cellular  13
## 2799  44   blue-collar  married      no     300     yes   no   unknown  13
## 2800  31     housemaid  married      no      25      no   no  cellular  21
## 2801  36  entrepreneur divorced      no     299     yes   no  cellular  18
## 2802  59    management  married      no    5314      no   no  cellular  20
## 2803  29      services   single      no       0     yes   no   unknown  20
## 2804  43   blue-collar  married      no     699     yes  yes  cellular  20
## 2805  51   blue-collar  married      no     303     yes   no   unknown   3
## 2806  30    management  married      no     604      no   no  cellular  25
## 2807  33    technician  married      no       0      no   no   unknown   9
## 2808  31        admin.   single      no       0      no   no  cellular  17
## 2809  34   blue-collar  married      no     205     yes  yes  cellular   7
## 2810  52    unemployed  married      no     255      no  yes  cellular  10
## 2811  44   blue-collar  married      no     476      no   no  cellular  14
## 2812  36 self-employed  married      no     328     yes  yes  cellular  23
## 2813  55    management  married      no       0      no   no   unknown  16
## 2814  57       retired  married      no     523      no  yes  cellular   2
## 2815  41    management  married      no     226      no   no  cellular  28
## 2816  35    management   single      no    1756      no   no  cellular  20
## 2817  50   blue-collar  married      no    2610     yes  yes   unknown  20
## 2818  55        admin. divorced      no     789     yes   no   unknown  13
## 2819  35        admin.  married      no    1055      no   no  cellular   2
## 2820  33    management   single      no     -61      no   no   unknown  28
## 2821  35    management  married      no      93      no   no  cellular   4
## 2822  35 self-employed divorced      no    3443      no   no  cellular  30
## 2823  51     housemaid  married      no    2239      no   no  cellular  27
## 2824  26    technician   single      no    1256      no   no   unknown  26
## 2825  46   blue-collar  married      no      85     yes   no  cellular  17
## 2826  54  entrepreneur  married      no       0      no   no   unknown   9
## 2827  21    technician   single      no     360      no   no  cellular  26
## 2828  45     housemaid  married      no      40     yes   no  cellular   2
## 2829  36   blue-collar divorced      no     107     yes   no  cellular  31
## 2830  65       retired divorced      no     744      no   no  cellular   5
## 2831  26   blue-collar   single      no      96     yes   no   unknown  12
## 2832  46      services  married      no    2420      no   no  cellular  19
## 2833  57    management  married      no    3250      no   no  cellular  20
## 2834  48        admin.  married      no     257     yes   no telephone   8
## 2835  30      services divorced      no      63     yes   no   unknown  29
## 2836  46        admin.  married      no    3145     yes   no  cellular   5
## 2837  28    management  married      no    1480     yes   no  cellular  18
## 2838  35        admin.   single      no    1721      no   no telephone  30
## 2839  30    technician  married      no    -280     yes   no  cellular  17
## 2840  31    technician   single      no      25      no   no  cellular  26
## 2841  23   blue-collar   single      no    8627     yes   no  cellular  15
## 2842  41    unemployed divorced      no     271     yes   no   unknown  19
## 2843  47    technician  married      no   17206     yes   no  cellular  19
## 2844  55     housemaid  married      no     127     yes   no telephone  21
## 2845  44    technician divorced      no      12      no   no  cellular  11
## 2846  38    management  married      no    1074      no   no  cellular   8
## 2847  49    technician   single      no    -188     yes  yes  cellular  17
## 2848  27   blue-collar   single      no     -15     yes  yes  cellular  15
## 2849  57    management  married      no       0     yes  yes   unknown  20
## 2850  30      services   single      no    1788      no   no  cellular   4
## 2851  35    management   single      no     592      no  yes   unknown  14
## 2852  41    technician divorced      no     475     yes   no  cellular  28
## 2853  28   blue-collar  married      no      83     yes   no  cellular  15
## 2854  41   blue-collar  married     yes      76      no  yes  cellular  10
## 2855  37    management   single      no     509     yes   no  cellular   6
## 2856  25      services   single      no      32     yes   no   unknown  16
## 2857  27   blue-collar   single      no    2752     yes   no  cellular  18
## 2858  41    management  married      no     280     yes   no  cellular  27
## 2859  46   blue-collar  married      no    1109     yes   no  cellular  19
## 2860  28        admin.  married      no     -97     yes   no  cellular  13
## 2861  23    technician   single      no     283     yes   no  cellular  22
## 2862  36        admin. divorced      no     543     yes   no  cellular  11
## 2863  45       unknown divorced      no       0      no   no  cellular  21
## 2864  32    technician   single      no     418      no  yes  cellular  14
## 2865  38    technician  married      no     254     yes   no   unknown  27
## 2866  26   blue-collar   single      no       8     yes   no  cellular  13
## 2867  27   blue-collar   single      no     541     yes   no  cellular  12
## 2868  36  entrepreneur  married      no       0     yes   no  cellular   9
## 2869  39 self-employed  married      no    -176     yes   no   unknown  15
## 2870  38  entrepreneur   single      no    -281     yes   no   unknown  27
## 2871  28    technician  married      no    1180     yes   no   unknown  29
## 2872  52        admin.  married      no     692     yes   no  cellular  12
## 2873  35    technician  married      no     118      no   no  cellular   6
## 2874  30    technician   single      no     341      no   no   unknown  23
## 2875  44    management divorced      no      71     yes   no  cellular   7
## 2876  35    technician   single      no     632      no   no  cellular   7
## 2877  30    management   single      no     156     yes   no   unknown   9
## 2878  49        admin.   single      no     981     yes   no telephone  21
## 2879  39   blue-collar  married      no    2952     yes   no   unknown  12
## 2880  47    management   single      no    1187      no   no  cellular  31
## 2881  33   blue-collar   single      no    1794     yes   no  cellular  12
## 2882  18       student   single      no     108      no   no  cellular   8
## 2883  41      services  married      no     450     yes   no  cellular  17
## 2884  44    management  married      no     677     yes   no   unknown  12
## 2885  22     housemaid   single      no     650     yes   no   unknown  12
## 2886  48   blue-collar  married      no    1778     yes   no telephone   8
## 2887  42    technician divorced      no       0     yes   no   unknown  30
## 2888  44        admin.  married      no      26     yes   no  cellular  21
## 2889  39 self-employed  married      no    2165     yes   no  cellular  18
## 2890  25   blue-collar   single      no    1857     yes   no  cellular  13
## 2891  34      services   single      no     258     yes   no   unknown   4
## 2892  32    technician   single      no       0      no   no  cellular  21
## 2893  30        admin.   single      no     873      no   no  cellular   7
## 2894  32      services  married      no     182      no   no  cellular   5
## 2895  33    management  married      no       1     yes  yes  cellular  21
## 2896  33    technician   single      no    1393     yes   no  cellular  18
## 2897  33  entrepreneur  married      no    -886     yes  yes  cellular  25
## 2898  31   blue-collar  married      no    1354     yes  yes  cellular  17
## 2899  40    technician  married      no    4441     yes   no  cellular  20
## 2900  35        admin.   single      no      57     yes   no  cellular  18
## 2901  29 self-employed   single      no     476     yes   no  cellular  18
## 2902  36 self-employed   single      no     351      no   no  cellular  30
## 2903  43     housemaid  married      no    5233      no   no   unknown  18
## 2904  27    management   single      no    2849      no   no  cellular   5
## 2905  37      services divorced      no     731     yes   no  cellular   5
## 2906  37    technician  married      no    1142     yes   no  cellular  17
## 2907  52    management  married      no       0      no   no  cellular  12
## 2908  40    management  married      no     572      no   no  cellular   2
## 2909  34    technician   single      no     124      no   no telephone  14
## 2910  48    technician   single      no     329      no   no  cellular  23
## 2911  40        admin.  married      no       0      no   no  cellular  28
## 2912  50   blue-collar  married      no     289      no   no   unknown   6
## 2913  36    management  married      no     753      no   no  cellular  26
## 2914  35    management  married      no    -126      no   no  cellular  22
## 2915  18       student   single      no     608      no   no  cellular  13
## 2916  26    technician  married      no    2026      no   no  cellular  22
## 2917  26   blue-collar   single      no     311     yes   no  cellular   7
## 2918  56       retired  married      no    5879      no   no   unknown  20
## 2919  57    management  married      no    2155      no  yes  cellular  11
## 2920  53   blue-collar  married      no     148     yes   no  cellular   7
## 2921  38    technician   single      no    1369     yes   no  cellular   3
## 2922  29    management  married      no     147     yes  yes   unknown   7
## 2923  36 self-employed  married      no     506      no   no  cellular   3
## 2924  48    management  married      no   -1080     yes  yes  cellular  18
## 2925  32    technician  married      no    2688      no   no  cellular  14
## 2926  30    management  married      no       0      no   no  cellular  22
## 2927  36   blue-collar  married      no    7265      no   no   unknown  17
## 2928  48    unemployed  married      no   11371     yes   no  cellular  30
## 2929  32    technician   single      no      10      no   no  cellular  19
## 2930  55   blue-collar  married      no    7561      no   no   unknown   6
## 2931  30    management   single      no     119      no   no  cellular  28
## 2932  33    technician  married      no       0     yes   no  cellular   8
## 2933  30    technician   single      no    3096     yes   no  cellular  11
## 2934  38    management  married      no   10357      no   no  cellular  15
## 2935  43   blue-collar  married      no    1559     yes   no   unknown  30
## 2936  52   blue-collar  married      no    2206     yes   no   unknown  15
## 2937  30      services  married      no     683     yes   no  cellular  15
## 2938  34      services   single      no       2     yes   no  cellular  15
## 2939  28    technician   single      no     113      no   no  cellular  13
## 2940  24   blue-collar  married      no     142     yes  yes   unknown  16
## 2941  43   blue-collar  married      no    2047     yes   no   unknown  13
## 2942  36    technician   single      no      97      no   no  cellular  28
## 2943  25 self-employed   single      no     557      no   no telephone   5
## 2944  27      services  married      no       0     yes   no  cellular  17
## 2945  22       student   single      no     948      no   no telephone  25
## 2946  58    management  married      no    -382      no   no telephone   5
## 2947  31    management   single      no     170     yes  yes  cellular   5
## 2948  29  entrepreneur   single      no     404      no   no  cellular  30
## 2949  35     housemaid  married      no     738     yes   no  cellular   5
## 2950  29      services  married      no     549     yes   no   unknown   5
## 2951  32    technician  married      no     901     yes   no   unknown  21
## 2952  30        admin.  married      no     116     yes   no  cellular  31
## 2953  37      services  married      no    1694     yes  yes  cellular  29
## 2954  24      services  married      no    1354     yes  yes  cellular  18
## 2955  29        admin.   single      no    1751      no   no  cellular  30
## 2956  51     housemaid  married      no     294      no   no  cellular  20
## 2957  28   blue-collar  married      no     417     yes  yes  cellular   6
## 2958  25    unemployed  married      no     715      no   no  cellular   4
## 2959  43    technician   single      no     257     yes   no  cellular   2
## 2960  47    management divorced      no    2105      no  yes  cellular  21
## 2961  35     housemaid   single      no    4378      no   no   unknown   9
## 2962  60 self-employed  married      no      46     yes   no   unknown   6
## 2963  35   blue-collar  married      no    1602     yes  yes   unknown  20
## 2964  34      services   single      no      34     yes  yes   unknown  29
## 2965  38    technician   single      no      25     yes   no  cellular   1
## 2966  54    technician  married      no       0      no   no telephone  30
## 2967  48   blue-collar  married      no     264      no   no  cellular   6
## 2968  48 self-employed  married      no    1204     yes   no   unknown  19
## 2969  39    management  married      no       0     yes   no  cellular  11
## 2970  52    technician  married      no     989      no   no  cellular  11
## 2971  42   blue-collar   single      no    4930      no   no   unknown  18
## 2972  53      services divorced      no    -291     yes  yes   unknown   7
## 2973  31   blue-collar  married      no     -45     yes   no   unknown   2
## 2974  47    technician  married      no    1430     yes   no  cellular  24
## 2975  59     housemaid  married      no    1100      no   no  cellular  18
## 2976  38        admin.  married      no       8     yes   no   unknown   7
## 2977  39   blue-collar  married      no    2133     yes  yes   unknown  16
## 2978  35    technician   single      no    7546     yes   no  cellular  28
## 2979  73       retired  married      no     934      no   no  cellular  14
## 2980  45    technician divorced      no     378     yes  yes  cellular  13
## 2981  58    management divorced      no     108      no   no  cellular  12
## 2982  47    management  married      no   -1379     yes   no   unknown  27
## 2983  48    management   single      no     830      no   no  cellular  25
## 2984  39  entrepreneur  married      no       0     yes   no   unknown  15
## 2985  41    technician   single      no     143      no   no  cellular  20
## 2986  29    technician   single      no     740     yes   no   unknown  28
## 2987  58       retired  married      no    1980      no   no  cellular   5
## 2988  53   blue-collar  married      no    1794     yes   no  cellular  17
## 2989  52        admin.  married      no    2281     yes  yes telephone   4
## 2990  33    management   single      no    1973     yes   no   unknown  28
## 2991  36    unemployed   single      no     536      no   no  cellular  19
## 2992  32    management   single      no       3     yes   no   unknown   8
## 2993  81       retired divorced      no       0      no   no telephone  15
## 2994  37      services  married      no     616     yes   no  cellular  17
## 2995  30    management  married      no     623     yes   no   unknown  29
## 2996  20       student   single      no      53      no   no  cellular  11
## 2997  38      services  married      no     -93     yes   no   unknown   3
## 2998  40    technician divorced      no     568     yes   no   unknown  24
## 2999  55   blue-collar  married      no     119      no   no  cellular  29
## 3000  30        admin.  married     yes      23      no  yes  cellular   4
## 3001  55   blue-collar  married      no     663     yes   no  cellular   6
## 3002  30   blue-collar  married      no       0      no  yes  cellular  21
## 3003  47      services  married      no    1160     yes   no   unknown  27
## 3004  30    management   single      no     872     yes   no  cellular  15
## 3005  32   blue-collar  married      no     180     yes   no  cellular  14
## 3006  31    management   single      no      37      no   no  cellular   8
## 3007  52    management  married      no    1339     yes   no  cellular  22
## 3008  36   blue-collar  married      no       6      no   no   unknown  20
## 3009  63       retired  married      no     474      no   no  cellular  25
## 3010  35        admin.  married      no    3187     yes   no  cellular   3
## 3011  32    management   single      no     914     yes   no  cellular  20
## 3012  44   blue-collar  married      no       0     yes   no telephone   5
## 3013  32   blue-collar   single      no    3044     yes   no  cellular  20
## 3014  45   blue-collar  married      no    1003     yes   no  cellular  14
## 3015  41    management divorced      no    3355      no   no  cellular  14
## 3016  44    technician  married      no     964      no   no  cellular  29
## 3017  59    management divorced      no   13308     yes   no   unknown  13
## 3018  31    management  married      no    1755     yes   no   unknown  21
## 3019  39   blue-collar  married      no     467     yes   no  cellular  16
## 3020  40    management divorced      no    3355      no   no  cellular   1
## 3021  36    management   single      no     317      no   no   unknown  16
## 3022  31    technician divorced      no       0      no   no  cellular  29
## 3023  29    management   single      no     722     yes   no telephone  18
## 3024  45   blue-collar  married      no     185      no   no  cellular  18
## 3025  37    technician  married      no     603      no   no   unknown  18
## 3026  24   blue-collar   single      no    -398     yes   no  cellular  18
## 3027  37    management   single      no     105     yes   no  cellular   8
## 3028  30    technician   single      no     985     yes   no  cellular  19
## 3029  33   blue-collar  married      no       0      no   no   unknown  23
## 3030  59   blue-collar  married      no     914      no   no  cellular  11
## 3031  33    management   single      no     417     yes   no  cellular   4
## 3032  40   blue-collar   single      no      29      no   no telephone   7
## 3033  40   blue-collar  married      no    1802     yes   no  cellular  17
## 3034  75 self-employed  married      no    4984      no   no telephone  28
## 3035  34   blue-collar   single      no      47     yes   no  cellular  14
## 3036  24      services   single      no      11     yes   no   unknown  27
## 3037  37   blue-collar   single      no     277     yes   no   unknown   3
## 3038  51    technician divorced      no     548      no   no   unknown  12
## 3039  39        admin.  married      no    2783     yes   no  cellular  12
## 3040  50   blue-collar  married      no       5      no   no   unknown  19
## 3041  35  entrepreneur  married      no     753      no   no  cellular   7
## 3042  29    management   single      no      91     yes   no telephone  28
## 3043  37   blue-collar  married      no    1534     yes   no   unknown   3
## 3044  32    technician   single      no      43      no   no  cellular   5
## 3045  41      services  married      no     373     yes   no   unknown  30
## 3046  32    management   single      no     718     yes   no  cellular  15
## 3047  56   blue-collar  married      no     345     yes   no telephone  22
## 3048  35    management   single      no       4     yes   no   unknown  30
## 3049  37   blue-collar  married      no       0     yes   no   unknown  26
## 3050  31    technician   single      no     319      no  yes  cellular   7
## 3051  36    management  married      no      22      no   no  cellular   2
## 3052  25      services  married      no     806     yes  yes  cellular  15
## 3053  40        admin.   single      no    2360     yes   no  cellular  20
## 3054  57     housemaid  married      no     151     yes   no  cellular  18
## 3055  31    technician   single      no    -348     yes   no  cellular  18
## 3056  53       retired  married      no     136      no   no   unknown  16
## 3057  32      services   single      no      72      no   no  cellular  28
## 3058  33        admin.   single      no   12704     yes   no  cellular  21
## 3059  45      services  married      no    6397     yes   no   unknown   5
## 3060  42    technician  married      no     525      no   no  cellular  17
## 3061  30 self-employed  married      no    1930      no   no  cellular  20
## 3062  28    unemployed   single      no      16      no   no  cellular  12
## 3063  47    technician  married      no     826     yes   no telephone  18
## 3064  27        admin. divorced      no      76     yes   no   unknown   4
## 3065  60     housemaid  married      no       0      no   no telephone   4
## 3066  58  entrepreneur  married      no    1153     yes  yes telephone  12
## 3067  39    management  married      no       0      no   no  cellular  28
## 3068  30   blue-collar   single      no      23     yes   no   unknown   6
## 3069  60        admin. divorced      no     162      no   no   unknown  27
## 3070  42    management  married      no    3841     yes   no  cellular  25
## 3071  59       retired  married      no    2396      no   no  cellular  27
## 3072  38    management  married      no    1617     yes   no  cellular  16
## 3073  30    management  married      no     131     yes   no  cellular  11
## 3074  38   blue-collar divorced      no    -138     yes   no  cellular  18
## 3075  52       retired  married      no     414      no   no  cellular  28
## 3076  33    management   single      no   12686     yes   no  cellular   5
## 3077  50   blue-collar  married      no    -522     yes   no  cellular  13
## 3078  35     housemaid   single      no     608     yes  yes   unknown   2
## 3079  52    unemployed  married      no      -9      no   no   unknown   9
## 3080  41   blue-collar  married      no       0      no   no   unknown   5
## 3081  40    technician divorced      no    1871     yes   no  cellular  17
## 3082  34   blue-collar divorced      no       0     yes   no  cellular   5
## 3083  26        admin.  married      no       0      no   no   unknown  27
## 3084  51    technician  married      no     117      no   no  cellular  18
## 3085  52    management divorced      no     944      no  yes   unknown   9
## 3086  37   blue-collar  married      no       7     yes  yes  cellular   7
## 3087  53   blue-collar  married      no      25      no   no  cellular  22
## 3088  28   blue-collar   single      no    1103     yes   no   unknown   4
## 3089  39      services divorced      no    -718     yes   no   unknown   2
## 3090  26 self-employed   single      no    1393      no   no  cellular   3
## 3091  47      services  married      no     440     yes   no   unknown  12
## 3092  32  entrepreneur  married      no     -25     yes   no  cellular   7
## 3093  35   blue-collar   single      no     448      no  yes  cellular  20
## 3094  35   blue-collar divorced      no       0      no   no  cellular  15
## 3095  31    management   single      no     783     yes   no  cellular   2
## 3096  54     housemaid  married      no     209     yes  yes  cellular  25
## 3097  49   blue-collar  married      no     188     yes   no   unknown  23
## 3098  54   blue-collar  married      no     489     yes  yes  cellular  20
## 3099  33    management  married      no     332     yes  yes  cellular  28
## 3100  38    technician   single      no    1711      no   no  cellular  20
## 3101  34    management   single      no    6766      no   no  cellular  28
## 3102  60    technician  married      no      91      no   no  cellular  27
## 3103  35    technician  married      no    4508     yes   no  cellular  18
## 3104  28    unemployed   single      no    1055      no   no  cellular  28
## 3105  32   blue-collar divorced      no      88     yes   no   unknown   8
## 3106  48    management divorced      no     174      no   no  cellular   6
## 3107  52      services  married      no    1135     yes  yes   unknown  13
## 3108  52    management   single      no     597      no   no  cellular  25
## 3109  38    management   single      no     455     yes   no  cellular  19
## 3110  39    management  married      no    1654      no  yes  cellular  21
## 3111  50  entrepreneur  married      no    5420     yes   no  cellular  17
## 3112  30    management   single      no     424      no   no  cellular  16
## 3113  26  entrepreneur   single      no      81      no   no  cellular  21
## 3114  57    management  married      no       0      no   no   unknown  19
## 3115  42    technician  married      no     613     yes   no  cellular  11
## 3116  32    unemployed   single      no     104      no   no  cellular   4
## 3117  56       retired  married      no      63      no   no  cellular  19
## 3118  49    technician  married      no    -142     yes  yes  cellular  23
## 3119  48   blue-collar divorced      no     -18     yes   no   unknown   8
## 3120  35   blue-collar divorced      no       0     yes   no   unknown   8
## 3121  59    management  married      no    5397      no   no  cellular  23
## 3122  36    technician   single      no      53      no  yes  cellular  18
## 3123  37      services  married      no      50     yes   no   unknown   8
## 3124  31        admin.   single      no     144     yes   no  cellular  21
## 3125  35   blue-collar  married      no    1287     yes   no  cellular  14
## 3126  35    technician  married      no      14     yes   no telephone  18
## 3127  38    management  married      no    -469     yes   no   unknown  16
## 3128  35   blue-collar divorced      no    3102     yes   no  cellular  20
## 3129  32    technician   single      no    1849     yes   no  cellular   7
## 3130  57        admin.  married      no       5      no   no   unknown  20
## 3131  44        admin.  married      no    1206      no   no  cellular  19
## 3132  32 self-employed   single      no     123     yes   no   unknown   9
## 3133  26       student   single      no     -41     yes   no   unknown   8
## 3134  30      services   single      no    1649     yes   no   unknown  23
## 3135  32   blue-collar  married      no    -428     yes   no   unknown  13
## 3136  59       retired  married      no    -411      no   no  cellular  29
## 3137  70       retired  married      no     647      no   no telephone  10
## 3138  30   blue-collar   single      no     334      no   no  cellular  12
## 3139  39  entrepreneur  married      no     580     yes   no   unknown  14
## 3140  27    technician   single      no      41     yes  yes  cellular  25
## 3141  60   blue-collar  married      no     104     yes   no   unknown   5
## 3142  35 self-employed  married      no     980      no   no  cellular   2
## 3143  43    technician divorced      no     -36     yes   no  cellular  17
## 3144  73       retired divorced      no    1092      no   no  cellular   7
## 3145  35    management   single      no      71     yes   no   unknown  21
## 3146  41      services  married      no     510     yes   no   unknown   9
## 3147  33    technician  married      no    1072      no  yes   unknown  29
## 3148  34  entrepreneur  married      no     121     yes   no telephone  18
## 3149  30    technician  married     yes    -315     yes   no   unknown   8
## 3150  34        admin.  married      no     287     yes   no   unknown   2
## 3151  39   blue-collar   single      no     175      no   no  cellular  12
## 3152  44        admin. divorced      no       0      no   no  cellular  14
## 3153  30   blue-collar   single      no     906     yes  yes   unknown  21
## 3154  30    technician  married      no    -280     yes   no  cellular  25
## 3155  44      services  married      no       0     yes  yes  cellular  11
## 3156  49        admin.  married      no    1096     yes   no  cellular  17
## 3157  36    unemployed divorced      no    2178     yes   no  cellular  30
## 3158  31 self-employed  married      no       0     yes   no  cellular  22
## 3159  42   blue-collar divorced      no     103     yes   no  cellular   6
## 3160  58       unknown  married      no      15      no   no  cellular  11
## 3161  31        admin.  married      no    1262     yes   no  cellular  20
## 3162  42    unemployed  married      no    1289      no   no  cellular  15
## 3163  25    technician  married      no     839     yes   no  cellular  18
## 3164  42    management  married      no    1680     yes   no   unknown   6
## 3165  38   blue-collar  married      no    1102     yes   no   unknown  23
## 3166  52    unemployed  married      no    2142      no   no  cellular   8
## 3167  44   blue-collar   single      no    1593     yes   no   unknown  29
## 3168  43    management   single      no     359     yes   no telephone  12
## 3169  36    management  married      no    8277     yes   no  cellular  18
## 3170  25   blue-collar   single      no     335     yes   no   unknown  13
## 3171  45   blue-collar  married      no     -96      no   no  cellular  28
## 3172  28   blue-collar  married      no       0     yes  yes   unknown  17
## 3173  45        admin.  married      no     251     yes   no  cellular   5
## 3174  35    management  married      no     697      no   no  cellular   5
## 3175  43   blue-collar  married      no     245     yes  yes  cellular  12
## 3176  50   blue-collar  married      no     180     yes   no  cellular  16
## 3177  36        admin.   single      no     587     yes   no  cellular  13
## 3178  44   blue-collar  married      no      88     yes   no  cellular   2
## 3179  49        admin.   single      no       0      no   no  cellular  19
## 3180  37     housemaid divorced      no       0     yes  yes  cellular  21
## 3181  42   blue-collar  married      no    1556      no  yes  cellular   8
## 3182  29   blue-collar   single      no     348     yes   no   unknown   9
## 3183  32    technician   single      no     190     yes  yes   unknown   9
## 3184  26       student   single      no    1209     yes   no  cellular   7
## 3185  50    management   single      no    3537      no   no   unknown  24
## 3186  38    management  married      no     590      no   no  cellular  31
## 3187  54   blue-collar  married      no    1291     yes   no   unknown   5
## 3188  34    technician   single      no     612      no   no  cellular  25
## 3189  41      services   single      no     397     yes   no   unknown  20
## 3190  31        admin.   single      no     507     yes   no  cellular  13
## 3191  42    management  married      no     478      no  yes  cellular   8
## 3192  44    management  married      no     -61      no   no  cellular  11
## 3193  24      services  married      no     183     yes   no  cellular  18
## 3194  38    management  married      no     272     yes   no  cellular  24
## 3195  48    technician  married      no     220      no   no  cellular  28
## 3196  36  entrepreneur divorced      no    2996     yes   no  cellular  14
## 3197  49    management  married      no    2005      no   no   unknown  16
## 3198  56     housemaid divorced     yes    1238      no   no   unknown   5
## 3199  71       retired  married      no    2651      no   no  cellular  24
## 3200  47        admin.  married      no    1210      no   no  cellular  26
## 3201  52    management  married      no     583      no   no  cellular  18
## 3202  37      services  married      no     102     yes   no  cellular  31
## 3203  40    management divorced      no     -78     yes   no   unknown  27
## 3204  30      services  married      no    1743     yes   no  cellular   5
## 3205  35    management   single      no       0      no   no  cellular  21
## 3206  38    technician  married      no     508     yes   no  cellular  18
## 3207  52   blue-collar  married      no     779     yes   no   unknown  16
## 3208  49    management  married      no    3840     yes   no   unknown  15
## 3209  59    management   single      no     911      no  yes   unknown   5
## 3210  47      services divorced      no      91     yes   no  cellular  17
## 3211  43   blue-collar  married      no     632     yes   no   unknown  15
## 3212  25    technician   single      no     102      no  yes  cellular   8
## 3213  26   blue-collar   single      no     619     yes  yes   unknown  27
## 3214  45      services  married      no     507      no  yes  cellular  21
## 3215  26    technician   single      no    1216     yes   no  cellular  16
## 3216  67       retired  married      no    4416      no   no  cellular  29
## 3217  32    management  married      no    1544     yes   no  cellular   7
## 3218  83     housemaid  married      no    2140      no   no  cellular   6
## 3219  28   blue-collar  married      no     486     yes   no   unknown   8
## 3220  39   blue-collar  married      no     519     yes  yes   unknown  26
## 3221  41      services  married      no       0     yes  yes  cellular   4
## 3222  47 self-employed  married      no    2830     yes   no telephone  20
## 3223  49    management divorced      no   20727      no   no  cellular  20
## 3224  59   blue-collar  married      no     448      no   no   unknown   8
## 3225  25    management   single      no     145      no   no  cellular   7
## 3226  57   blue-collar  married      no     630     yes   no   unknown  29
## 3227  50   blue-collar  married      no     170     yes  yes   unknown  19
## 3228  26   blue-collar   single      no     339     yes   no   unknown  26
## 3229  42    technician   single      no    1882     yes   no   unknown  15
## 3230  33    management   single      no     206      no   no  cellular  21
## 3231  29   blue-collar  married      no    1280     yes   no   unknown  28
## 3232  55   blue-collar  married      no       0      no   no   unknown  12
## 3233  26    technician   single      no     342      no   no  cellular  14
## 3234  36    unemployed   single      no     577     yes   no   unknown  30
## 3235  31   blue-collar  married      no     457     yes   no  cellular  11
## 3236  38     housemaid divorced      no     216      no   no  cellular   7
## 3237  42    management   single      no    1608      no   no  cellular  28
## 3238  29      services   single      no    1788      no   no  cellular  27
## 3239  34        admin.  married      no      19     yes  yes  cellular  13
## 3240  25       student   single      no      58      no   no  cellular  24
## 3241  27        admin.  married      no    1417     yes   no  cellular  15
## 3242  43 self-employed  married      no      64      no   no   unknown   6
## 3243  41    management   single      no     335      no   no  cellular  30
## 3244  46   blue-collar  married      no    -339     yes  yes  cellular  11
## 3245  38    technician  married      no       0      no   no  cellular  25
## 3246  33      services  married      no     546     yes  yes   unknown   9
## 3247  35  entrepreneur  married      no    2723     yes  yes  cellular   8
## 3248  46   blue-collar  married      no    2121     yes   no   unknown  14
## 3249  32    management  married      no     141      no   no  cellular   2
## 3250  35    technician   single      no     -54     yes   no   unknown  30
## 3251  54 self-employed  married      no     153     yes   no   unknown   5
## 3252  32    technician  married      no       0     yes   no  cellular  18
## 3253  55   blue-collar  married      no    2854     yes   no  cellular   7
## 3254  30        admin.  married      no    1589     yes   no  cellular  18
## 3255  36  entrepreneur  married      no     600      no   no  cellular  21
## 3256  39    unemployed divorced      no     193     yes   no   unknown  15
## 3257  50 self-employed  married      no    4012      no   no  cellular  19
## 3258  56        admin. divorced      no    3337     yes   no telephone  17
## 3259  72       retired  married      no       0      no   no  cellular  28
## 3260  46   blue-collar  married      no     633     yes   no   unknown  12
## 3261  36    technician divorced      no     119      no   no  cellular  23
## 3262  38      services  married      no     497     yes  yes   unknown  19
## 3263  51    technician  married      no     825      no   no  cellular  17
## 3264  32    management  married      no     184     yes   no  cellular  14
## 3265  32   blue-collar  married      no     944      no   no  cellular  13
## 3266  51   blue-collar  married     yes    -283     yes   no   unknown  12
## 3267  31    unemployed   single      no     209     yes   no  cellular   6
## 3268  33    technician divorced      no     751     yes   no  cellular  18
## 3269  38    technician divorced      no    1425     yes   no  cellular  15
## 3270  39   blue-collar  married      no    1254     yes   no  cellular  15
## 3271  33   blue-collar  married      no     327     yes   no  cellular  21
## 3272  46    management divorced      no       0      no   no  cellular  20
## 3273  45       retired divorced      no     261      no   no   unknown   9
## 3274  59       retired  married      no    7586      no   no  cellular  12
## 3275  25   blue-collar   single     yes      15     yes   no telephone   6
## 3276  36   blue-collar   single      no    2390     yes   no   unknown  20
## 3277  33  entrepreneur  married      no     135     yes   no  cellular  17
## 3278  46  entrepreneur  married      no     757      no   no   unknown  16
## 3279  43  entrepreneur  married      no       0     yes   no telephone   6
## 3280  33      services  married      no     260     yes   no  cellular  31
## 3281  46    management  married      no      71     yes   no  cellular  19
## 3282  34    management  married      no      15      no   no  cellular  25
## 3283  44      services   single      no     862     yes   no  cellular   3
## 3284  56      services  married      no     530     yes   no   unknown  20
## 3285  42        admin.  married      no     976     yes   no  cellular  18
## 3286  45    management  married      no    4758     yes   no  cellular   5
## 3287  58        admin.  married      no     879     yes   no   unknown  16
## 3288  30    management  married      no       3     yes   no  cellular  22
## 3289  51   blue-collar  married      no    7816     yes   no   unknown  12
## 3290  53       retired  married      no    1296     yes   no   unknown  17
## 3291  42    technician  married      no     246     yes   no telephone  12
## 3292  33   blue-collar  married      no     478     yes   no  cellular   7
## 3293  32   blue-collar   single      no    3845     yes   no  cellular  18
## 3294  59   blue-collar divorced      no      61     yes   no  cellular  13
## 3295  58    management divorced      no    3498      no   no  cellular  19
## 3296  31    unemployed   single      no     167      no   no  cellular  20
## 3297  69       retired  married      no     324      no   no  cellular   4
## 3298  51   blue-collar   single      no      60      no   no   unknown   3
## 3299  30    technician  married      no     616     yes   no  cellular   6
## 3300  33    unemployed   single      no     617      no   no  cellular   2
## 3301  34        admin.   single      no      18     yes   no  cellular   6
## 3302  48    technician divorced      no    1290      no   no   unknown  16
## 3303  45     housemaid  married      no     360      no   no  cellular   3
## 3304  36   blue-collar  married      no    8135     yes   no   unknown  20
## 3305  39    technician   single      no    1674      no   no  cellular  15
## 3306  58    management  married      no    1016      no   no telephone  11
## 3307  36   blue-collar   single      no    2235     yes   no  cellular  20
## 3308  34      services  married      no    -451     yes  yes  cellular  23
## 3309  36    management   single      no     124     yes   no telephone  24
## 3310  40    management  married      no     752      no  yes   unknown  17
## 3311  33    management   single      no     215     yes   no  cellular  28
## 3312  55       retired  married      no    -185      no  yes telephone   2
## 3313  45 self-employed  married      no    -124      no   no  cellular  25
## 3314  31       student   single      no      93      no   no  cellular  19
## 3315  51      services  married      no     144      no  yes   unknown  27
## 3316  54    technician divorced      no     255     yes   no   unknown  27
## 3317  48       retired  married      no    1591      no   no  cellular  31
## 3318  28        admin. divorced      no     451     yes   no  cellular  13
## 3319  57   blue-collar  married      no     162     yes   no   unknown   6
## 3320  60       retired  married      no     597      no   no  cellular  15
## 3321  51   blue-collar  married      no     230     yes   no  cellular  17
## 3322  47        admin.  married      no      70     yes   no  cellular   5
## 3323  40    management divorced      no     490     yes   no   unknown   7
## 3324  43   blue-collar   single      no   13620     yes   no  cellular  20
## 3325  50    unemployed  married      no    5164      no   no   unknown  12
## 3326  41    technician  married      no    -329      no   no telephone   5
## 3327  30    technician   single      no     419     yes  yes   unknown  28
## 3328  45  entrepreneur  married      no    3133     yes  yes  cellular  10
## 3329  23      services  married      no    2673     yes   no   unknown   5
## 3330  31      services  married      no    1004      no   no  cellular   5
## 3331  25        admin.   single      no     760     yes   no  cellular  27
## 3332  34    management  married      no       0      no   no  cellular  22
## 3333  55   blue-collar  married      no    3957      no  yes  cellular   4
## 3334  29        admin.   single      no     428     yes  yes  cellular   7
## 3335  58 self-employed  married      no     327      no  yes  cellular  14
## 3336  30        admin.  married      no     401      no   no  cellular  19
## 3337  51       unknown  married      no     167      no   no   unknown  18
## 3338  32    management  married      no     258     yes  yes  cellular  18
## 3339  28       student   single      no     970      no   no telephone   4
## 3340  44    management  married      no     839      no   no  cellular   8
## 3341  38     housemaid divorced      no    4312      no   no  cellular  15
## 3342  57       retired  married      no    1408      no   no   unknown  21
## 3343  34    management  married      no     581     yes   no   unknown  29
## 3344  54   blue-collar divorced      no    1145     yes   no  cellular   7
## 3345  33     housemaid  married      no      10     yes   no  cellular  20
## 3346  34    management   single      no      84      no   no  cellular   5
## 3347  55    technician  married      no      77     yes   no   unknown  23
## 3348  52      services  married      no      -1      no  yes   unknown  26
## 3349  38    management  married      no     389     yes   no   unknown   6
## 3350  55        admin.  married      no     183     yes   no   unknown   6
## 3351  45    technician  married      no    1441     yes   no  cellular  18
## 3352  36   blue-collar  married      no     975     yes   no  cellular   7
## 3353  56      services   single      no     -40     yes   no  cellular  15
## 3354  38        admin.  married      no     545      no   no   unknown  12
## 3355  29    management  married      no      55     yes   no  cellular  10
## 3356  30   blue-collar  married      no    5956     yes  yes  cellular  20
## 3357  28      services  married      no    1214      no   no   unknown  28
## 3358  56    management  married      no    7747      no   no   unknown   5
## 3359  49   blue-collar  married      no    3028     yes   no  cellular  12
## 3360  58       retired divorced      no    5253      no   no  cellular   9
## 3361  59       retired  married      no    3382     yes   no   unknown  13
## 3362  36    management   single      no     442     yes  yes  cellular  29
## 3363  53    management  married      no    7067      no   no   unknown   6
## 3364  55   blue-collar  married      no     135     yes   no  cellular  15
## 3365  33   blue-collar divorced      no    -131     yes   no   unknown  16
## 3366  48   blue-collar  married      no     893      no   no  cellular  13
## 3367  32   blue-collar  married      no       0     yes  yes  cellular  28
## 3368  26    management   single      no    1438      no   no  cellular  27
## 3369  56    unemployed divorced      no     282      no   no  cellular  28
## 3370  32   blue-collar   single      no      53     yes   no  cellular  18
## 3371  50      services   single      no     321      no   no telephone  22
## 3372  40  entrepreneur  married      no    1089     yes  yes   unknown  13
## 3373  46      services  married      no     244      no   no  cellular  21
## 3374  36  entrepreneur  married      no     546      no   no  cellular   9
## 3375  48    management  married      no    4006      no   no  cellular  25
## 3376  54     housemaid divorced      no    1241      no   no   unknown  20
## 3377  52    management  married      no     324      no   no  cellular   9
## 3378  38   blue-collar  married      no     190     yes   no telephone  19
## 3379  41   blue-collar  married      no    1885     yes   no  cellular   7
## 3380  37    management  married      no     142      no   no   unknown  20
## 3381  33      services  married      no      39     yes   no   unknown   4
## 3382  54    technician divorced      no    2156     yes   no  cellular   3
## 3383  30    technician  married      no    -287     yes   no  cellular  14
## 3384  45    technician  married      no    2359      no   no  cellular  18
## 3385  68       retired  married      no    1316      no   no telephone   4
## 3386  25      services   single      no    -439     yes   no   unknown  12
## 3387  27   blue-collar  married      no       0      no   no telephone   2
## 3388  44   blue-collar  married      no    1071     yes   no  cellular  11
## 3389  27    management   single      no     831     yes   no  cellular  21
## 3390  29   blue-collar   single      no     445     yes   no   unknown  21
## 3391  37      services   single      no     253     yes  yes   unknown   9
## 3392  52        admin.  married      no    -462     yes   no  cellular   9
## 3393  58       retired  married      no    1241      no   no  cellular  18
## 3394  58    management divorced      no    2986      no   no  cellular  16
## 3395  37   blue-collar  married      no     131     yes   no   unknown   9
## 3396  37   blue-collar  married      no     -29     yes  yes  cellular  15
## 3397  30        admin.   single      no    1223     yes   no  cellular  30
## 3398  34     housemaid   single      no    1408     yes   no   unknown  23
## 3399  26    technician   single      no       7     yes   no  cellular  22
## 3400  55    management   single      no     111      no   no  cellular  16
## 3401  58       retired  married      no     630      no   no   unknown   9
## 3402  40    management divorced      no     823      no   no  cellular  13
## 3403  32    management   single      no    1131     yes   no   unknown  20
## 3404  51        admin.   single      no     895      no   no  cellular  23
## 3405  45  entrepreneur  married      no    4688      no   no  cellular   7
## 3406  57       retired divorced      no     720      no   no telephone  17
## 3407  57       retired  married      no     478      no   no  cellular  30
## 3408  54   blue-collar divorced      no     190     yes   no   unknown  15
## 3409  30    technician  married      no       0     yes   no   unknown  23
## 3410  40      services  married      no    1358      no   no   unknown  19
## 3411  53    management   single      no       0      no   no   unknown  20
## 3412  33    technician  married     yes      72     yes   no   unknown   6
## 3413  40    technician   single      no      34      no   no  cellular  20
## 3414  41    management   single      no    1253      no   no  cellular  21
## 3415  50    management  married      no    2488     yes   no   unknown  29
## 3416  31        admin.   single      no     253     yes   no  cellular  13
## 3417  49        admin.  married      no    1101      no   no  cellular  18
## 3418  41    technician  married      no     634      no   no  cellular   7
## 3419  60    technician  married      no    4243     yes   no  cellular   4
## 3420  34    technician  married      no    2069      no   no  cellular  20
## 3421  32    technician  married      no    1879      no   no   unknown  19
## 3422  53       retired  married      no     357      no   no   unknown  18
## 3423  34   blue-collar  married      no     277      no  yes   unknown   3
## 3424  29        admin.   single      no     171     yes   no   unknown  11
## 3425  38   blue-collar  married      no      35     yes   no   unknown  28
## 3426  31    technician   single      no     127     yes   no  cellular  16
## 3427  37   blue-collar  married      no    5643     yes   no   unknown  21
## 3428  30      services   single      no     148      no  yes  cellular   7
## 3429  32   blue-collar   single      no      18     yes  yes  cellular   6
## 3430  30 self-employed   single      no     280      no   no telephone   5
## 3431  41    technician  married      no     354      no   no  cellular  29
## 3432  47    management  married      no    1493      no   no  cellular  31
## 3433  34    technician   single      no    1866      no   no  cellular   4
## 3434  38   blue-collar  married      no    1165     yes   no  cellular  13
## 3435  41    technician divorced      no    1545      no  yes  cellular  13
## 3436  27    technician   single      no     434     yes   no   unknown  13
## 3437  33       student  married      no     476     yes   no  cellular  12
## 3438  38      services   single      no     322     yes   no   unknown  26
## 3439  41    management  married      no    2031     yes   no   unknown  20
## 3440  37    unemployed divorced      no      74     yes   no   unknown   7
## 3441  26    management   single      no    1720      no   no  cellular   3
## 3442  36      services  married      no       0     yes   no  cellular   6
## 3443  28       student  married      no     327     yes   no  cellular  15
## 3444  59    management  married      no     101      no  yes   unknown   9
## 3445  35    management   single      no    4788     yes   no   unknown   3
## 3446  43       unknown   single      no     181      no   no telephone  28
## 3447  50   blue-collar divorced      no    -333      no  yes  cellular  30
## 3448  24      services   single      no       0      no   no   unknown  16
## 3449  32    technician  married      no     500      no   no  cellular   6
## 3450  41    technician  married      no    1043     yes  yes   unknown  14
## 3451  39    management  married      no     399      no   no  cellular   9
## 3452  50       retired   single      no     208      no   no   unknown   9
## 3453  40    management  married      no    1576     yes  yes   unknown  29
## 3454  50    management  married      no     346      no   no  cellular   4
## 3455  63   blue-collar  married      no     641      no   no  cellular  27
## 3456  31    technician divorced      no     105     yes   no  cellular  16
## 3457  34      services  married      no    1337      no   no  cellular  12
## 3458  28   blue-collar   single      no     121      no   no  cellular   4
## 3459  32    technician  married      no    -410     yes  yes  cellular  12
## 3460  32   blue-collar  married     yes      -1     yes   no   unknown   9
## 3461  52      services  married      no    -585     yes  yes   unknown  27
## 3462  43       unknown  married      no    2113      no   no  cellular  29
## 3463  43    unemployed  married      no      58     yes   no  cellular   9
## 3464  23    management   single      no      85     yes   no   unknown  19
## 3465  47    technician  married      no    1115     yes   no telephone  23
## 3466  52    management  married      no    4173      no  yes  cellular  21
## 3467  37 self-employed  married      no    2203      no  yes  cellular   5
## 3468  31    management   single      no      15      no   no  cellular  11
## 3469  40     housemaid  married      no    4136     yes   no  cellular  11
## 3470  42    management  married      no     261      no   no  cellular  27
## 3471  33   blue-collar  married      no     392     yes   no   unknown  23
## 3472  40       retired   single      no    1400      no   no   unknown  20
## 3473  51    management  married      no     615     yes   no  cellular  17
## 3474  53    unemployed   single      no       4      no   no  cellular  30
## 3475  36    management   single      no     339      no   no  cellular  21
## 3476  34    technician  married      no    1553      no   no  cellular  20
## 3477  30    management  married      no      14      no   no  cellular  24
## 3478  29   blue-collar  married      no     258     yes   no   unknown  26
## 3479  38        admin.  married      no       3     yes  yes   unknown   5
## 3480  41   blue-collar  married      no     620      no   no  cellular  28
## 3481  33    management   single      no     -67     yes   no   unknown   5
## 3482  28      services   single      no     430     yes   no  cellular   8
## 3483  47       unknown  married      no     270      no   no  cellular   6
## 3484  36        admin.   single      no    1328      no   no  cellular  30
## 3485  57   blue-collar  married      no      93     yes   no telephone  17
## 3486  36    management  married      no    1825     yes   no  cellular  14
## 3487  51    technician  married      no     573     yes  yes   unknown  14
## 3488  51   blue-collar  married      no     541      no   no  cellular  11
## 3489  40   blue-collar  married      no    2133     yes  yes  cellular   6
## 3490  45    technician   single      no     410     yes   no   unknown  30
## 3491  52        admin.  married      no    2347      no  yes  cellular  12
## 3492  35  entrepreneur   single      no     145     yes   no  cellular  18
## 3493  33    unemployed  married     yes    -108     yes  yes  cellular  19
## 3494  38        admin. divorced      no     382     yes   no  cellular  17
## 3495  36   blue-collar  married      no      13      no   no   unknown   3
## 3496  75       retired  married      no    3504      no   no telephone   9
## 3497  31        admin.   single      no    1801     yes   no  cellular  12
## 3498  33    management   single      no    1308      no   no  cellular   7
## 3499  31   blue-collar  married      no     136      no   no  cellular  12
## 3500  56    unemployed  married      no      12      no   no  cellular  12
## 3501  37    technician  married      no    -421     yes   no   unknown   6
## 3502  33    management   single      no    1271     yes   no  cellular  15
## 3503  30    technician  married      no    -910     yes   no  cellular  15
## 3504  56      services  married      no    1150      no  yes  cellular  17
## 3505  35   blue-collar  married      no    -102     yes   no  cellular  14
## 3506  56       unknown  married      no     778      no   no   unknown  20
## 3507  58      services  married      no      74      no   no  cellular  29
## 3508  67 self-employed  married      no    1979      no   no  cellular  10
## 3509  38    management  married      no       0     yes   no telephone  12
## 3510  37    management divorced     yes      -1     yes  yes  cellular   7
## 3511  57   blue-collar  married      no    8195     yes   no   unknown  19
## 3512  35  entrepreneur  married      no      24     yes   no   unknown  20
## 3513  27   blue-collar   single      no       1     yes   no  cellular  18
## 3514  33    management  married      no     801      no   no  cellular  19
## 3515  37   blue-collar  married      no    3517     yes   no   unknown  23
## 3516  37    management  married      no     222     yes   no  cellular  20
## 3517  56       retired  married      no    1906      no  yes   unknown  19
## 3518  55        admin.  married      no     128      no   no  cellular  20
## 3519  40   blue-collar  married      no       0     yes   no   unknown   3
## 3520  41   blue-collar  married      no    5560     yes   no  cellular  12
## 3521  27   blue-collar  married      no     613     yes   no   unknown  19
## 3522  49    management  married      no   17432      no   no  cellular  17
## 3523  54    management divorced      no    1692     yes   no  cellular  29
## 3524  42 self-employed  married      no    1385      no   no  cellular  25
## 3525  34    technician   single      no       0      no   no  cellular  28
## 3526  34    technician  married      no     932     yes   no  cellular   4
## 3527  38        admin.  married      no     257     yes   no  cellular  15
## 3528  33  entrepreneur  married     yes     -54      no  yes  cellular   8
## 3529  26   blue-collar  married      no     818      no   no  cellular   9
## 3530  35   blue-collar  married      no    1257     yes   no  cellular  20
## 3531  48    management   single      no      61     yes   no   unknown  28
## 3532  64       retired  married      no     380      no   no  cellular  25
## 3533  31        admin.  married      no    1229      no   no  cellular  12
## 3534  39      services  married      no    1970     yes   no   unknown   8
## 3535  38    management  married      no       0     yes   no   unknown  20
## 3536  40   blue-collar  married      no    2562     yes   no   unknown  15
## 3537  49   blue-collar  married     yes     -98     yes   no  cellular  20
## 3538  36    management  married      no    1604     yes   no   unknown  11
## 3539  51       unknown  married      no    1585      no   no telephone  30
## 3540  58    technician   single      no     409      no  yes  cellular  14
## 3541  33    technician   single      no    2481      no   no  cellular  12
## 3542  28   blue-collar   single      no    2845     yes   no   unknown  12
## 3543  42   blue-collar  married      no    1320      no   no   unknown  15
## 3544  52 self-employed  married      no       9      no  yes   unknown   6
## 3545  54    management divorced      no     496      no   no  cellular  13
## 3546  60       retired divorced      no     514      no   no  cellular  16
## 3547  31        admin.   single      no      40      no   no  cellular   4
## 3548  32   blue-collar   single      no     760     yes   no  cellular  16
## 3549  53        admin.  married      no    1796      no   no telephone   5
## 3550  28 self-employed   single      no       0     yes   no  cellular  21
## 3551  47    technician  married      no     834      no  yes  cellular  21
## 3552  29   blue-collar   single      no    -138     yes  yes   unknown   8
## 3553  78       retired  married      no    3208      no   no telephone  20
## 3554  43  entrepreneur  married      no      59      no   no   unknown  13
## 3555  27        admin.  married      no      73      no   no  cellular  10
## 3556  51   blue-collar  married      no       0     yes   no  cellular  10
## 3557  52   blue-collar  married      no     -27      no   no  cellular  28
## 3558  49 self-employed  married      no     358     yes  yes   unknown  13
## 3559  35      services  married      no    1659     yes   no  cellular   3
## 3560  58      services  married      no    1667     yes  yes   unknown   6
## 3561  36    management  married      no     255      no   no  cellular  25
## 3562  58   blue-collar  married      no    2592     yes   no   unknown  25
## 3563  51     housemaid  married      no    1275      no   no   unknown   6
## 3564  42    technician  married      no    3228      no   no  cellular  21
## 3565  37    management  married      no    2401      no   no  cellular   6
## 3566  44   blue-collar  married      no    3610     yes   no   unknown  29
## 3567  38   blue-collar divorced      no     727     yes   no   unknown  16
## 3568  34   blue-collar  married      no     452     yes   no   unknown  15
## 3569  31    unemployed   single      no    1489     yes   no  cellular   3
## 3570  32      services   single      no      81     yes   no   unknown   7
## 3571  54    management divorced      no    -125      no  yes  cellular   8
## 3572  38   blue-collar   single      no     162     yes   no   unknown   8
## 3573  40     housemaid  married      no     864      no   no  cellular  14
## 3574  30      services   single      no     187     yes   no   unknown  23
## 3575  43  entrepreneur  married      no       0      no   no telephone  24
## 3576  39    management  married      no   21111     yes   no   unknown  26
## 3577  29    management   single      no      21     yes   no  cellular  14
## 3578  46   blue-collar   single      no      76     yes   no   unknown   7
## 3579  28    technician   single      no     154     yes   no  cellular  18
## 3580  50    management  married      no    4654      no   no  cellular  17
## 3581  29    technician   single      no     359     yes   no  cellular   8
## 3582  39   blue-collar  married      no     648     yes   no  cellular  29
## 3583  38    technician  married      no       0     yes   no  cellular  22
## 3584  57    unemployed  married      no    5126     yes   no  cellular   2
## 3585  54 self-employed divorced      no     351     yes   no   unknown   6
## 3586  52      services  married      no     540     yes   no  cellular  11
## 3587  50 self-employed  married      no       0     yes   no telephone  12
## 3588  30    technician   single      no      18      no   no   unknown  19
## 3589  49    management  married      no     350      no   no  cellular  12
## 3590  40        admin.   single      no     419      no  yes  cellular  28
## 3591  42   blue-collar   single      no     419      no   no  cellular   7
## 3592  52    management  married      no    4675      no   no  cellular  12
## 3593  31    technician  married      no    3192     yes   no  cellular   7
## 3594  33 self-employed   single      no    4996      no   no  cellular  20
## 3595  26    technician   single      no     174     yes   no   unknown  30
## 3596  36   blue-collar   single      no     507     yes   no  cellular  22
## 3597  29    management   single      no       0     yes   no  cellular  22
## 3598  42   blue-collar  married      no    1657     yes  yes  cellular  17
## 3599  47    technician  married      no    2394      no  yes   unknown  20
## 3600  33    management   single      no    -298      no   no  cellular  22
## 3601  34        admin.  married      no     -44     yes  yes  cellular  17
## 3602  57    technician  married      no    1070      no   no   unknown  19
## 3603  36   blue-collar  married      no     274     yes   no   unknown  16
## 3604  57        admin.  married      no   16873      no   no  cellular  14
## 3605  36        admin.  married      no     786     yes  yes  cellular  10
## 3606  29    technician   single      no     525     yes   no  cellular  16
## 3607  32    technician   single      no      35      no   no  cellular  28
## 3608  30        admin.   single      no     223     yes   no   unknown   6
## 3609  41        admin.  married      no    -306     yes   no   unknown  15
## 3610  50    management  married      no     463      no  yes  cellular  17
## 3611  50    technician divorced      no     636     yes   no  cellular   6
## 3612  41    unemployed divorced      no     487      no   no  cellular  16
## 3613  36    management  married      no     873     yes   no   unknown  21
## 3614  35    management  married      no     267     yes   no   unknown   7
## 3615  63   blue-collar  married      no     115      no   no telephone  27
## 3616  25    technician   single      no     -55     yes  yes  cellular   7
## 3617  33   blue-collar  married      no       0     yes  yes   unknown  20
## 3618  37      services  married      no    4760     yes   no  cellular  20
## 3619  28  entrepreneur   single      no     219     yes   no   unknown  27
## 3620  43   blue-collar  married      no     232     yes   no telephone   8
## 3621  34   blue-collar  married      no       0     yes   no  cellular  17
## 3622  26    technician   single      no    -525     yes  yes  cellular  22
## 3623  57    technician  married      no      -1      no   no   unknown  14
## 3624  20       student   single      no    1191      no   no  cellular  28
## 3625  52    management  married      no    7192      no   no  cellular   4
## 3626  39      services   single      no     410      no   no   unknown  19
## 3627  32      services  married      no       0     yes   no  cellular  28
## 3628  54        admin.   single      no      15     yes   no  cellular   4
## 3629  39      services  married      no      18     yes  yes  cellular  20
## 3630  31   blue-collar   single      no     530      no  yes  cellular  18
## 3631  25       student   single      no     715      no   no  cellular  26
## 3632  59    technician  married      no     478      no   no  cellular  11
## 3633  39        admin.   single      no     470     yes   no   unknown  20
## 3634  47    technician  married      no      11      no   no  cellular  20
## 3635  22      services   single      no      35     yes   no   unknown  28
## 3636  26    unemployed   single      no    3511      no   no  cellular  30
## 3637  37      services  married      no     655      no   no  cellular  13
## 3638  52      services divorced      no      43     yes  yes  cellular  11
## 3639  28        admin.   single      no     392     yes  yes  cellular   4
## 3640  46      services  married      no       0     yes   no  cellular  22
## 3641  30        admin.   single      no     523      no  yes  cellular   3
## 3642  30    technician  married      no    1338     yes  yes  cellular  10
## 3643  34        admin.   single      no     239      no   no   unknown   5
## 3644  51     housemaid  married      no    1521      no   no   unknown   6
## 3645  46  entrepreneur  married      no       0     yes  yes  cellular   6
## 3646  70       retired  married      no    2815      no   no  cellular  26
## 3647  41    technician  married      no       0      no   no   unknown  20
## 3648  32    technician   single      no       0     yes   no   unknown  21
## 3649  32   blue-collar   single      no      60     yes   no  cellular  28
## 3650  50    management  married      no       0     yes   no  cellular  19
## 3651  38        admin.  married      no     505     yes  yes   unknown  17
## 3652  32        admin.   single      no    8866      no   no  cellular  18
## 3653  30   blue-collar   single      no    1472     yes   no  cellular  20
## 3654  39   blue-collar  married      no     -99      no   no  cellular  17
## 3655  30    technician   single      no    2731     yes   no  cellular  14
## 3656  44  entrepreneur  married      no    -165     yes  yes   unknown   4
## 3657  45   blue-collar  married      no    2128     yes   no   unknown  19
## 3658  56 self-employed  married      no     800      no  yes  cellular   9
## 3659  37    management  married      no    1330     yes   no  cellular  29
## 3660  30   blue-collar  married      no     837     yes   no  cellular  15
## 3661  54      services  married      no       8     yes   no  cellular  14
## 3662  53        admin.  married      no    -375     yes   no   unknown  23
## 3663  27       student   single      no    5169     yes   no  cellular   3
## 3664  36    management  married      no     162     yes   no  cellular   8
## 3665  43  entrepreneur   single      no      42      no   no  cellular   7
## 3666  52     housemaid  married      no     335      no   no  cellular  22
## 3667  48   blue-collar  married      no   10724      no   no   unknown  20
## 3668  39    management   single      no     416      no   no  cellular  23
## 3669  35   blue-collar  married      no    4822     yes   no   unknown  20
## 3670  76       retired divorced      no    3049      no   no  cellular  24
## 3671  40      services  married      no     191     yes   no  cellular  18
## 3672  57       retired  married      no    4908      no   no  cellular  30
## 3673  59   blue-collar  married      no    -546      no   no  cellular  25
## 3674  45     housemaid  married      no     698     yes   no   unknown  17
## 3675  37    technician  married      no     143      no   no  cellular  27
## 3676  28    technician   single      no    -481     yes  yes  cellular   2
## 3677  57    unemployed  married      no    3867     yes   no   unknown  12
## 3678  45   blue-collar  married      no     292     yes   no  cellular  29
## 3679  58     housemaid  married      no    4605      no   no  cellular  11
## 3680  30   blue-collar  married      no    -529     yes   no  cellular  12
## 3681  48   blue-collar  married      no    1738     yes   no  cellular  15
## 3682  61 self-employed  married      no    4162      no   no  cellular  10
## 3683  34    management   single      no     524      no   no   unknown  13
## 3684  43    technician divorced      no     101      no   no  cellular  19
## 3685  44    technician   single      no    2403     yes   no   unknown  30
## 3686  29   blue-collar  married      no      50      no   no  cellular   8
## 3687  37   blue-collar  married      no     357     yes   no  cellular  15
## 3688  41    unemployed divorced      no    1281      no   no  cellular  31
## 3689  34    technician  married      no    1795     yes   no  cellular  29
## 3690  40   blue-collar  married      no      98     yes   no   unknown   2
## 3691  59 self-employed  married      no    2013      no   no  cellular  17
## 3692  35 self-employed  married      no     506      no   no  cellular  27
## 3693  58    management divorced      no    1573     yes  yes  cellular  17
## 3694  20      services   single      no    -103     yes   no   unknown  13
## 3695  55    technician divorced      no     184      no   no   unknown  13
## 3696  51   blue-collar  married      no     955      no  yes  cellular  17
## 3697  31 self-employed   single      no    1788      no   no  cellular  27
## 3698  52    management  married      no     547      no   no  cellular   5
## 3699  31    management   single      no      62     yes   no  cellular  18
## 3700  34   blue-collar  married      no    1575     yes   no   unknown  27
## 3701  32    management   single      no     623      no   no  cellular   6
## 3702  36        admin.   single      no      47      no  yes  cellular   9
## 3703  41   blue-collar  married      no    1293      no   no telephone  31
## 3704  34   blue-collar  married      no    1221     yes   no  cellular   6
## 3705  25   blue-collar   single      no    -143     yes  yes   unknown  27
## 3706  44    unemployed divorced      no     757      no   no   unknown  30
## 3707  52   blue-collar  married      no     -98     yes   no   unknown   7
## 3708  34    management   single      no    -292     yes   no  cellular  11
## 3709  31   blue-collar  married      no     347      no   no telephone  20
## 3710  57        admin.  married      no    5888      no  yes   unknown  11
## 3711  29        admin.   single      no      41     yes   no  cellular  13
## 3712  27    technician   single      no     372     yes  yes  cellular  25
## 3713  37    management divorced      no     481     yes   no  cellular  19
## 3714  35    technician  married      no     650     yes   no  cellular  14
## 3715  59      services  married      no      33     yes   no  cellular  11
## 3716  31        admin.   single      no     358     yes   no   unknown  15
## 3717  56        admin.  married      no     370      no   no  cellular  26
## 3718  30      services   single      no     179     yes   no   unknown  29
## 3719  30        admin.   single      no     239     yes   no  cellular   7
## 3720  32    management  married      no     393      no   no  cellular  28
## 3721  39      services  married      no     949     yes   no  cellular  29
## 3722  46 self-employed  married      no     917      no   no  cellular   9
## 3723  29    management   single      no     765      no   no  cellular  16
## 3724  57    technician  married      no       0      no   no   unknown  20
## 3725  46        admin. divorced      no    -637     yes   no  cellular  17
## 3726  37    unemployed  married      no    3051     yes   no  cellular  20
## 3727  55    management divorced      no    5399      no  yes  cellular  30
## 3728  42   blue-collar  married      no     -10     yes   no   unknown   9
## 3729  53    unemployed  married      no    2248     yes   no  cellular  30
## 3730  40   blue-collar  married      no     718     yes  yes telephone  13
## 3731  32      services   single      no     385     yes   no  cellular  14
## 3732  44    management  married      no    6203     yes  yes   unknown  13
## 3733  60     housemaid  married      no    1043      no   no  cellular  18
## 3734  24       student   single      no    1847      no   no  cellular   9
## 3735  41   blue-collar  married      no     348     yes   no   unknown  14
## 3736  40        admin.  married      no     100     yes   no  cellular   9
## 3737  31   blue-collar  married      no    4728     yes   no  cellular  19
## 3738  35  entrepreneur   single      no      16      no   no  cellular  17
## 3739  32   blue-collar  married      no     157     yes   no   unknown  20
## 3740  32   blue-collar  married      no      14     yes   no   unknown   2
## 3741  39    management  married     yes      47      no   no  cellular  21
## 3742  40   blue-collar   single      no     446     yes   no  cellular   8
## 3743  39   blue-collar divorced      no      94     yes   no   unknown  29
## 3744  36    management divorced      no     563      no   no   unknown  20
## 3745  40    management  married      no    1468      no   no  cellular   8
## 3746  60       retired  married      no      60     yes   no   unknown   5
## 3747  52     housemaid  married      no    1466      no  yes  cellular  20
## 3748  42    technician   single      no    -411     yes   no  cellular  12
## 3749  39    management divorced      no     132     yes   no  cellular   9
## 3750  31   blue-collar  married      no     990     yes  yes  cellular   7
## 3751  57      services  married      no       4      no   no  cellular  21
## 3752  30      services   single      no    3405      no   no  cellular  29
## 3753  30    technician   single      no     106     yes   no  cellular  13
## 3754  69       retired divorced      no    6850      no   no telephone   3
## 3755  39    management   single      no    1877     yes   no   unknown   6
## 3756  27        admin. divorced      no       0      no  yes  cellular  14
## 3757  30  entrepreneur   single      no     -63     yes   no   unknown   3
## 3758  35        admin.  married      no      69     yes  yes   unknown   6
## 3759  41    unemployed  married      no     819      no   no  cellular   9
## 3760  41        admin. divorced      no    2970      no  yes   unknown  27
## 3761  32  entrepreneur  married      no     604      no   no  cellular  29
## 3762  32   blue-collar   single      no    2093      no   no  cellular  24
## 3763  56    unemployed  married      no    2629      no   no  cellular  16
## 3764  28    management   single      no     672      no   no  cellular   4
## 3765  30      services   single      no     862     yes  yes   unknown  20
## 3766  44    management  married      no    3091     yes   no   unknown  17
## 3767  43        admin. divorced      no    3350     yes  yes   unknown  29
## 3768  37    management  married      no     156      no   no  cellular  19
## 3769  27      services   single      no     118     yes  yes   unknown  12
## 3770  48    unemployed  married      no    5462      no   no   unknown   6
## 3771  28    management   single      no     866      no   no  cellular  23
## 3772  41   blue-collar  married      no    2689     yes   no  cellular  15
## 3773  27   blue-collar   single      no    3675      no   no   unknown  12
## 3774  29   blue-collar  married      no       0     yes   no  cellular  16
## 3775  37     housemaid  married      no     589     yes   no  cellular  25
## 3776  39    technician  married      no     697      no   no  cellular  15
## 3777  34    management   single      no    1040     yes   no   unknown  20
## 3778  39    technician  married      no     394      no   no  cellular  11
## 3779  69     housemaid  married      no    1080      no   no  cellular  22
## 3780  39   blue-collar   single      no     254      no   no  cellular  27
## 3781  35        admin.   single      no     663     yes   no  cellular   2
## 3782  34    technician  married     yes      91      no   no  cellular  29
## 3783  35      services   single      no     313     yes   no  cellular  11
## 3784  32   blue-collar  married      no    3166     yes   no  cellular  20
## 3785  33    management   single      no    3655      no   no  cellular  19
## 3786  39   blue-collar  married      no     599     yes   no   unknown   6
## 3787  37     housemaid  married      no    1558      no   no  cellular   6
## 3788  31   blue-collar   single      no     573     yes   no telephone   5
## 3789  37    technician  married      no      41      no   no  cellular  29
## 3790  39   blue-collar  married      no   10483      no   no   unknown   9
## 3791  35   blue-collar  married      no     628     yes   no   unknown  29
## 3792  38      services  married      no     309      no   no   unknown  12
## 3793  37    management   single      no     715     yes   no   unknown  20
## 3794  32        admin. divorced      no     281     yes   no   unknown   8
## 3795  41    management   single      no    4594     yes   no   unknown   4
## 3796  49    technician  married      no    2344     yes   no   unknown  30
## 3797  52    technician  married      no     234      no   no  cellular  17
## 3798  38  entrepreneur  married      no    3249     yes   no   unknown   2
## 3799  57   blue-collar  married      no     668      no   no telephone  17
## 3800  28        admin.   single      no    -103     yes   no   unknown  12
## 3801  46      services  married      no    -780      no  yes  cellular   5
## 3802  47   blue-collar  married      no    1533      no  yes  cellular  18
## 3803  43   blue-collar  married      no     704     yes   no telephone  11
## 3804  35      services  married      no    2918      no  yes  cellular  16
## 3805  30  entrepreneur  married      no    1539     yes  yes   unknown  27
## 3806  39   blue-collar divorced      no     241     yes   no  cellular  18
## 3807  54    technician  married      no      87     yes   no  cellular  12
## 3808  56       retired divorced      no       4      no   no   unknown  17
## 3809  43    management divorced      no    7702      no   no  cellular  22
## 3810  38      services  married      no       0     yes  yes  cellular  11
## 3811  40    technician  married      no     335     yes   no   unknown   2
## 3812  33    management  married      no     271     yes   no  cellular  13
## 3813  27   blue-collar  married      no     373     yes   no   unknown   4
## 3814  43    technician  married      no     629      no   no  cellular   5
## 3815  44    management  married      no      58     yes   no  cellular  14
## 3816  32    management   single      no    2629      no   no  cellular  28
## 3817  52    management  married      no       0      no   no  cellular  30
## 3818  64       retired  married      no     466     yes   no  cellular  18
## 3819  48    technician   single      no     540     yes   no  cellular  17
## 3820  36    technician  married      no    1327      no   no  cellular  29
## 3821  47 self-employed  married      no       0      no   no   unknown  26
## 3822  41      services   single      no      92      no   no  cellular  21
## 3823  38  entrepreneur   single      no     185      no   no  cellular   5
## 3824  35    technician   single      no     399     yes   no  cellular  13
## 3825  40    management divorced      no     290     yes   no   unknown  27
## 3826  38        admin.  married      no    -650      no   no   unknown  16
## 3827  45      services  married      no      22     yes   no   unknown   8
## 3828  30      services  married      no     699     yes   no   unknown  29
## 3829  49    technician  married      no       0      no  yes  cellular  28
## 3830  46        admin.   single      no    1693     yes   no  cellular  20
## 3831  37 self-employed  married      no     804     yes   no  cellular  19
## 3832  36   blue-collar divorced      no    2843      no   no  cellular  14
## 3833  37    management  married      no     393     yes   no  cellular  12
## 3834  53   blue-collar  married      no    3815      no   no   unknown  24
## 3835  38   blue-collar  married      no    4321      no   no  cellular  18
## 3836  39       unknown   single      no       0      no   no   unknown   6
## 3837  35    unemployed   single      no     145      no   no  cellular  17
## 3838  47   blue-collar  married      no    -245     yes  yes   unknown  12
## 3839  32    management   single      no   12686     yes   no   unknown   3
## 3840  35    management  married      no    4943     yes   no  cellular  18
## 3841  42    management  married      no     275      no   no   unknown   5
## 3842  57       retired  married      no     573      no   no   unknown  20
## 3843  38    unemployed  married      no     338      no   no   unknown  19
## 3844  37        admin.  married      no       0     yes   no  cellular  22
## 3845  59       retired  married      no    5521     yes  yes   unknown  13
## 3846  40   blue-collar  married      no     598     yes   no  cellular  31
## 3847  40    technician   single      no    2141      no   no  cellular  18
## 3848  35   blue-collar  married      no     807     yes   no   unknown  29
## 3849  35   blue-collar  married      no    2054     yes   no   unknown  20
## 3850  39    unemployed  married      no    -455     yes   no   unknown  23
## 3851  34    management  married      no     443      no   no  cellular  18
## 3852  33   blue-collar   single      no   15341      no   no  cellular  20
## 3853  38    management   single      no     673     yes   no   unknown   7
## 3854  35    technician   single      no    2144     yes   no  cellular  30
## 3855  44    technician  married      no     584      no   no  cellular  30
## 3856  49    management  married      no    2037      no   no   unknown   5
## 3857  45     housemaid divorced      no     221      no   no   unknown  12
## 3858  30       student   single      no    4468      no   no  cellular   2
## 3859  26        admin.  married      no    -401     yes  yes   unknown   4
## 3860  33      services   single      no    1268     yes   no  cellular   6
## 3861  32    technician   single      no    1107      no   no  cellular  27
## 3862  55        admin.  married      no    1662      no   no  cellular   4
## 3863  34    management  married      no    3301     yes   no  cellular  17
## 3864  48   blue-collar divorced      no     183      no   no   unknown   9
## 3865  46      services  married      no      53      no  yes  cellular  28
## 3866  43    management  married      no      40      no   no  cellular  10
## 3867  33   blue-collar  married      no     372     yes   no   unknown   6
## 3868  47    management   single      no     124      no   no  cellular  29
## 3869  33    management   single      no     417     yes   no  cellular   6
## 3870  30   blue-collar  married      no   10395     yes   no  cellular  20
## 3871  31      services  married     yes      29      no   no  cellular  21
## 3872  31   blue-collar divorced      no       6     yes   no  cellular  29
## 3873  41       retired   single      no    2579      no   no  cellular  27
## 3874  37   blue-collar  married      no     204     yes   no   unknown  21
## 3875  38   blue-collar  married      no       0      no   no   unknown  13
## 3876  32   blue-collar  married      no     783     yes   no   unknown  21
## 3877  40      services  married      no    2469      no  yes   unknown  19
## 3878  55    technician  married      no    3207      no   no  cellular  28
## 3879  53    technician  married      no     -46      no   no  cellular  29
## 3880  42    management  married      no       0      no   no  cellular   6
## 3881  34    management divorced      no     221      no   no  cellular   8
## 3882  46    management  married      no    2466      no   no telephone   1
## 3883  51    management  married      no    2455     yes   no  cellular  21
## 3884  37    management  married      no     708     yes   no  cellular  27
## 3885  54        admin.  married      no    1342     yes   no  cellular   2
## 3886  40    technician  married      no       6     yes   no  cellular  16
## 3887  37   blue-collar   single      no     292      no   no   unknown   8
## 3888  33    management  married      no      62     yes   no  cellular   2
## 3889  44        admin. divorced      no       0      no   no  cellular  17
## 3890  46        admin.  married      no       0     yes   no  cellular  25
## 3891  31    technician   single      no     696      no  yes  cellular  11
## 3892  36    technician  married      no     465      no   no  cellular  14
## 3893  34    technician   single      no       0      no   no  cellular  19
## 3894  27      services  married      no      54     yes   no  cellular  18
## 3895  44   blue-collar   single      no      36     yes   no  cellular  15
## 3896  50        admin. divorced     yes    2405     yes   no  cellular   6
## 3897  27    technician   single      no     555      no   no   unknown  11
## 3898  40    technician   single      no     281     yes   no  cellular  11
## 3899  52    technician   single      no      36     yes   no   unknown  16
## 3900  30    technician  married      no     371      no   no  cellular   7
## 3901  32     housemaid  married      no     216      no  yes  cellular   9
## 3902  48   blue-collar   single      no     244     yes   no  cellular  15
## 3903  33    technician divorced     yes       6      no   no  cellular  22
## 3904  38    technician  married      no     634      no   no   unknown  19
## 3905  25    technician  married      no     776     yes   no   unknown  27
## 3906  31       student   single      no       0      no   no  cellular  22
## 3907  46       unknown   single      no       0      no   no   unknown  17
## 3908  57    management  married      no    7162      no   no  cellular  17
## 3909  27   blue-collar  married      no    -413      no  yes   unknown  27
## 3910  47    technician  married      no       0      no   no telephone  14
## 3911  30   blue-collar   single      no      80     yes  yes  cellular   5
## 3912  35    management   single      no       0      no   no  cellular  21
## 3913  34   blue-collar  married      no     161     yes  yes   unknown  20
## 3914  47    management  married      no       0     yes   no  cellular   4
## 3915  29    technician   single      no     323      no   no  cellular   3
## 3916  26   blue-collar  married      no     624     yes   no  cellular   5
## 3917  34    management  married      no    1557     yes  yes   unknown  13
## 3918  59       retired  married      no      56      no   no   unknown   5
## 3919  38        admin.   single      no    3239      no   no   unknown   5
## 3920  45   blue-collar  married      no    4022     yes   no  cellular  29
## 3921  31    technician   single      no    4979      no  yes  cellular  27
## 3922  31   blue-collar   single      no     509     yes   no   unknown  23
## 3923  48    technician  married      no    1526      no   no  cellular   6
## 3924  30    technician   single      no    2734      no   no  cellular  21
## 3925  53  entrepreneur   single      no      62     yes   no   unknown  30
## 3926  44    technician divorced      no    -865     yes   no  cellular  20
## 3927  30    management  married      no     451      no   no  cellular   5
## 3928  46  entrepreneur  married      no       0     yes  yes  cellular  29
## 3929  28   blue-collar  married      no    1958     yes   no   unknown   3
## 3930  33    management   single     yes      -5      no   no  cellular  18
## 3931  38    technician   single      no      38      no   no   unknown  16
## 3932  33   blue-collar  married      no     240     yes   no   unknown  21
## 3933  52   blue-collar  married      no    2144     yes   no   unknown  30
## 3934  32    technician divorced      no      53      no   no  cellular  22
## 3935  39   blue-collar  married      no    7304     yes   no   unknown  28
## 3936  32    management   single      no     813      no   no  cellular  28
## 3937  55   blue-collar  married      no     828     yes   no   unknown  30
## 3938  51   blue-collar  married      no   21614      no   no  cellular  29
## 3939  82       retired  married      no     278      no   no  cellular  16
## 3940  36   blue-collar  married      no      79     yes  yes  cellular   2
## 3941  55     housemaid  married      no    2152      no   no   unknown  19
## 3942  43   blue-collar  married      no    1311     yes   no   unknown  14
## 3943  33        admin.  married      no    4012      no  yes   unknown   8
## 3944  44    technician  married      no     564     yes   no  cellular  13
## 3945  47      services  married      no       5      no   no  cellular  28
## 3946  36   blue-collar  married      no     141     yes   no   unknown  23
## 3947  32   blue-collar  married      no       4     yes  yes  cellular   8
## 3948  60    technician  married      no    1139      no   no  cellular   6
## 3949  59       retired  married      no    3079      no   no telephone  31
## 3950  33   blue-collar  married     yes    -542     yes   no  cellular   6
## 3951  35      services  married      no     618      no   no  cellular  12
## 3952  48    management  married     yes     -13     yes   no  cellular  15
## 3953  32   blue-collar  married      no    9714     yes   no  cellular  15
## 3954  30      services   single      no    -114     yes   no  cellular  21
## 3955  39    management  married      no    1802      no   no  cellular  20
## 3956  41   blue-collar  married      no    1172     yes   no   unknown  15
## 3957  54    technician divorced      no     447     yes   no   unknown  14
## 3958  84       retired divorced      no    1680      no   no telephone   6
## 3959  47     housemaid   single      no    3232      no   no telephone   6
## 3960  28      services divorced      no      89      no   no   unknown   6
## 3961  32   blue-collar  married      no    5075     yes   no telephone  20
## 3962  55     housemaid divorced      no     603      no   no telephone  31
## 3963  30   blue-collar  married      no     578     yes  yes  cellular  17
## 3964  42    management  married      no    2187     yes   no  cellular  17
## 3965  34    management   single      no    1891     yes   no   unknown   9
## 3966  28    management   single      no     637     yes   no  cellular   4
## 3967  35        admin.  married      no    3863     yes   no  cellular  20
## 3968  34   blue-collar  married      no     152      no   no  cellular  25
## 3969  33    management  married      no     110     yes  yes  cellular  17
## 3970  40    management  married      no   24450      no   no  cellular  25
## 3971  67       retired  married      no     696      no   no telephone   4
## 3972  25    technician divorced      no    2317     yes   no  cellular   7
## 3973  44    management   single      no     295     yes   no   unknown  12
## 3974  32    management   single      no    2551     yes   no  cellular  21
## 3975  28    technician   single      no     280     yes   no   unknown  14
## 3976  28        admin.   single      no      -7      no  yes   unknown  26
## 3977  51    technician  married      no      58     yes   no  cellular  17
## 3978  29    technician   single      no      47     yes   no   unknown  16
## 3979  50    management  married      no    5124     yes   no  cellular  18
## 3980  32   blue-collar   single      no    -578      no   no   unknown   9
## 3981  58   blue-collar  married      no    2516     yes   no  cellular  16
## 3982  24      services  married      no       0     yes   no   unknown  27
## 3983  52    technician  married      no     230     yes  yes  cellular  21
## 3984  33  entrepreneur  married      no      82     yes   no  cellular  18
## 3985  40    management  married      no     542     yes   no  cellular  20
## 3986  37        admin.  married      no    1967      no   no  cellular  27
## 3987  41      services  married      no     471     yes   no  cellular  13
## 3988  32  entrepreneur  married      no    3083      no   no  cellular  22
## 3989  43        admin.  married      no       0     yes   no  cellular  17
## 3990  34        admin.  married      no      75     yes  yes  cellular  25
## 3991  38  entrepreneur  married      no     680     yes   no   unknown  19
## 3992  53    management divorced      no     443      no   no   unknown   9
## 3993  52    management   single      no     556      no   no  cellular  13
## 3994  40    management   single      no     269     yes   no  cellular  15
## 3995  34        admin.  married      no    2552     yes  yes  cellular  25
## 3996  30    management   single      no     112     yes   no   unknown   7
## 3997  37    technician  married      no     135     yes   no  cellular  12
## 3998  36       student   single      no     129      no   no  cellular  28
## 3999  48    unemployed  married      no    1296      no   no  cellular   5
## 4000  45   blue-collar   single     yes       0     yes   no  cellular  14
## 4001  37   blue-collar divorced      no      33     yes   no   unknown   6
## 4002  26       student   single      no     611      no   no  cellular  13
## 4003  48        admin. divorced      no    1180      no   no  cellular  27
## 4004  33    unemployed divorced      no     385      no   no telephone  27
## 4005  24       student  married      no     146      no   no  cellular  26
## 4006  60        admin. divorced      no     663      no  yes  cellular  30
## 4007  35   blue-collar  married      no    1330      no   no  cellular  10
## 4008  57    technician  married      no    3240     yes   no   unknown  14
## 4009  56       retired  married      no      -1     yes   no   unknown   2
## 4010  32  entrepreneur   single      no    1770      no  yes  cellular   4
## 4011  43  entrepreneur  married      no     629     yes   no  cellular   2
## 4012  48      services  married      no   11516      no   no   unknown  11
## 4013  36    technician  married      no    4932     yes   no  cellular  21
## 4014  38       retired   single      no      44      no   no   unknown  29
## 4015  47    management  married      no    1122     yes   no  cellular  20
## 4016  37        admin.  married      no    1123      no  yes   unknown  28
## 4017  53  entrepreneur  married      no    1046     yes  yes  cellular  30
## 4018  30    technician divorced      no    2262     yes   no   unknown  28
## 4019  40    management   single      no    1509      no   no  cellular  15
## 4020  50    management divorced      no     100     yes  yes  cellular  13
## 4021  51    management  married      no    -516     yes   no  cellular  18
## 4022  50    management  married     yes     421      no   no  cellular  20
## 4023  36    technician   single      no     966      no   no  cellular   8
## 4024  50        admin.   single      no     424     yes   no   unknown  12
## 4025  31        admin.  married      no     879     yes   no  cellular  13
## 4026  30    management  married      no     419     yes   no  cellular   4
## 4027  68       retired  married      no    2820      no   no  cellular   3
## 4028  29        admin.  married      no      26     yes   no   unknown  28
## 4029  30   blue-collar  married      no    9194     yes   no   unknown  23
## 4030  36    management  married      no    3770     yes   no  cellular  31
## 4031  39   blue-collar  married      no     292      no   no   unknown  12
## 4032  26 self-employed  married     yes     254     yes  yes  cellular  25
## 4033  52   blue-collar   single      no     359     yes   no  cellular  30
## 4034  33 self-employed  married      no     711     yes   no  cellular  18
## 4035  32    technician   single      no     210     yes   no  cellular  16
## 4036  43    management  married      no     657      no   no   unknown  18
## 4037  50   blue-collar  married      no    9585     yes   no telephone  31
## 4038  55       retired  married      no     103     yes  yes  cellular  17
## 4039  47   blue-collar  married      no    1756     yes   no   unknown  16
## 4040  40        admin.   single      no     739     yes   no   unknown  16
## 4041  41     housemaid  married      no     876      no   no   unknown  19
## 4042  28   blue-collar   single      no    2700      no   no  cellular   3
## 4043  53   blue-collar  married      no     436     yes   no   unknown  29
## 4044  31 self-employed  married      no    1015      no   no  cellular   8
## 4045  32    management divorced      no     222      no  yes  cellular  15
## 4046  35        admin.  married      no     214     yes  yes   unknown   5
## 4047  38        admin. divorced      no     308     yes   no   unknown   6
## 4048  29 self-employed   single      no    5406      no   no   unknown   9
## 4049  34    technician   single      no    1259     yes   no  cellular   6
## 4050  55    management  married      no     621      no  yes  cellular   2
## 4051  33      services  married      no     703      no   no  cellular  18
## 4052  33    technician   single      no     213      no   no  cellular  21
## 4053  45    management divorced      no     959      no   no   unknown  18
## 4054  31    management   single      no    1494      no   no  cellular  13
## 4055  37    technician  married      no    1610      no   no   unknown  16
## 4056  40    management  married      no     185      no   no  cellular  21
## 4057  30    technician  married      no     455     yes   no  cellular  21
## 4058  39    management divorced      no    5009     yes   no  cellular  15
## 4059  50        admin.  married      no     167      no  yes  cellular  19
## 4060  46     housemaid  married      no    1175      no   no  cellular   7
## 4061  34    management   single      no     431      no   no  cellular  16
## 4062  48    management divorced      no    1144     yes   no  cellular  17
## 4063  48   blue-collar divorced      no      65     yes   no  cellular  14
## 4064  27    unemployed   single      no     259     yes   no  cellular  18
## 4065  44      services  married      no       3     yes   no  cellular   7
## 4066  50    management  married      no   11528     yes   no   unknown  30
## 4067  44    management  married      no     167      no   no  cellular  27
## 4068  39    technician  married      no       0      no   no  cellular   6
## 4069  38   blue-collar  married      no    2685      no   no   unknown  20
## 4070  33      services   single      no     310     yes   no  cellular  12
## 4071  48   blue-collar   single      no    1938     yes   no   unknown   4
## 4072  30   blue-collar  married      no    4389     yes   no  cellular  30
## 4073  24    technician   single      no     139      no   no  cellular  14
## 4074  31      services  married      no     288      no   no  cellular  30
## 4075  42   blue-collar  married      no       1      no   no  cellular  15
## 4076  32    management   single      no   19985      no   no  cellular   9
## 4077  59       retired divorced      no     337     yes   no   unknown  15
## 4078  33    unemployed   single      no     177      no   no   unknown   8
## 4079  40   blue-collar  married      no    3462     yes   no  cellular   9
## 4080  28    technician  married      no      58     yes   no  cellular  14
## 4081  35   blue-collar divorced      no     300     yes   no   unknown  13
## 4082  47        admin.   single      no    3531     yes   no  cellular   7
## 4083  44    management  married      no    6945      no   no  cellular  14
## 4084  38    technician  married      no    1997     yes   no  cellular   6
## 4085  52      services  married      no     145      no   no  cellular  22
## 4086  33    technician  married      no    1126     yes   no   unknown   6
## 4087  33        admin. divorced      no    1762     yes   no  cellular  19
## 4088  59    technician  married      no     283      no   no  cellular  25
## 4089  48    technician  married      no     150     yes   no  cellular   9
## 4090  32   blue-collar   single      no       7     yes   no  cellular  13
## 4091  35      services  married      no    1453     yes   no   unknown  28
## 4092  51    management  married      no       0     yes   no  cellular  15
## 4093  48      services   single      no    -139      no   no  cellular  13
## 4094  43   blue-collar  married      no     408     yes   no   unknown  14
## 4095  56    unemployed divorced      no     109      no   no  cellular  15
## 4096  33    management   single      no    -359      no   no telephone  29
## 4097  52    management divorced      no       0     yes  yes  cellular  30
## 4098  38      services  married      no     129     yes   no  cellular   5
## 4099  40 self-employed   single      no    1693     yes   no  cellular  17
## 4100  28 self-employed   single      no     159      no   no  cellular  14
## 4101  29   blue-collar  married      no     486     yes   no  cellular   6
## 4102  26       student   single      no   13887      no   no  cellular  10
## 4103  48    technician  married      no    1637     yes   no   unknown  11
## 4104  45      services   single      no     482     yes  yes   unknown  30
## 4105  24   blue-collar  married      no      32      no   no   unknown  13
## 4106  40      services  married      no     939     yes   no  cellular  22
## 4107  32    management  married      no     376     yes   no  cellular  23
## 4108  42   blue-collar  married      no       0     yes  yes  cellular   7
## 4109  35   blue-collar  married      no     360     yes   no telephone  20
## 4110  31   blue-collar  married      no    9714     yes   no   unknown  19
## 4111  58       retired   single      no     999      no   no  cellular  25
## 4112  37    technician   single      no    1130      no   no  cellular  26
## 4113  34   blue-collar  married      no    1710     yes  yes   unknown  19
## 4114  36   blue-collar  married      no       0     yes   no   unknown   6
## 4115  53        admin.  married      no     234     yes   no telephone  13
## 4116  58   blue-collar  married      no       0      no   no  cellular  26
## 4117  59    technician  married      no     135     yes  yes  cellular  23
## 4118  46   blue-collar   single      no     332      no   no  cellular  30
## 4119  49    technician divorced      no     229      no   no  cellular   8
## 4120  62    management divorced      no    1619      no   no  cellular  19
## 4121  34    technician   single     yes      -2      no  yes  cellular   8
## 4122  34    management  married      no     651      no   no  cellular  20
## 4123  29    technician   single      no     309     yes   no   unknown  13
## 4124  42        admin.  married      no    -150      no  yes  cellular   8
## 4125  57    management  married      no     473      no   no  cellular   1
## 4126  32   blue-collar  married      no     363     yes   no   unknown  13
## 4127  46    management  married      no      37     yes   no  cellular  30
## 4128  49     housemaid  married      no    3376      no   no   unknown   9
## 4129  41   blue-collar  married      no      16      no   no  cellular  29
## 4130  30    management   single      no    3410     yes   no  cellular  18
## 4131  41   blue-collar  married      no     343     yes   no   unknown  14
## 4132  60   blue-collar  married      no    1407     yes   no  cellular  14
## 4133  44    management  married      no   -1746     yes   no   unknown  20
## 4134  43   blue-collar  married      no     953     yes   no   unknown  19
## 4135  41    management  married      no    1468     yes   no  cellular  31
## 4136  52    technician  married      no       0     yes   no  cellular  10
## 4137  51   blue-collar  married      no       0      no   no  cellular   7
## 4138  50   blue-collar divorced      no      31     yes   no   unknown   9
## 4139  30   blue-collar   single      no     546     yes   no   unknown  21
## 4140  41 self-employed  married      no       0      no   no  cellular   8
## 4141  41        admin.  married      no    2661     yes   no telephone  24
## 4142  47    management  married      no      33     yes  yes   unknown  20
## 4143  31    technician  married      no    1197     yes   no   unknown  24
## 4144  40      services divorced      no    5745     yes  yes   unknown  23
## 4145  43    management  married      no     370      no   no  cellular  28
## 4146  42     housemaid divorced      no     314      no   no   unknown   9
## 4147  38   blue-collar   single      no    1012     yes  yes telephone  17
## 4148  38   blue-collar  married      no     566     yes  yes telephone  17
## 4149  40    technician  married      no     826      no   no   unknown  24
## 4150  39   blue-collar  married      no    1096      no   no   unknown  20
## 4151  27        admin.  married      no    1033     yes   no   unknown   9
## 4152  31    management  married      no     392      no   no  cellular  26
## 4153  35    management  married      no     724     yes   no  cellular  18
## 4154  27    technician   single      no    1996     yes   no  cellular   5
## 4155  34    technician  married      no     222     yes   no   unknown  12
## 4156  40      services  married      no      88     yes   no   unknown   9
## 4157  35  entrepreneur   single      no     475      no  yes  cellular  21
## 4158  56       retired   single      no     352      no   no  cellular  19
## 4159  50   blue-collar  married      no      84     yes   no   unknown  29
## 4160  42 self-employed  married      no   21861      no   no   unknown   5
## 4161  27     housemaid  married      no       0      no  yes  cellular  17
## 4162  57   blue-collar divorced      no    1795     yes   no   unknown  19
## 4163  32   blue-collar   single      no    1475     yes   no  cellular  21
## 4164  54 self-employed  married      no    1510      no   no telephone   5
## 4165  59    technician divorced      no    2735      no   no  cellular   3
## 4166  45    technician  married      no    3583     yes   no   unknown  15
## 4167  31    management   single      no     533      no   no  cellular  12
## 4168  47    management  married      no       0      no   no  cellular   4
## 4169  48   blue-collar   single      no    3688     yes   no  cellular  17
## 4170  42        admin. divorced     yes     723      no   no  cellular  20
## 4171  27        admin.   single      no     313      no  yes  cellular   3
## 4172  30    management   single      no    1028      no   no  cellular   4
## 4173  32   blue-collar  married      no    -460     yes  yes  cellular  29
## 4174  42    unemployed divorced      no    1699      no  yes  cellular  17
## 4175  40   blue-collar  married      no     137      no  yes  cellular  10
## 4176  44    management  married      no       0     yes  yes  cellular  18
## 4177  55    unemployed  married      no     549      no   no  cellular  18
## 4178  41    management  married      no     526     yes   no  cellular  15
## 4179  35    management   single      no     824     yes   no  cellular  16
## 4180  41  entrepreneur   single      no     791     yes   no  cellular   5
## 4181  27      services  married      no     311     yes   no  cellular  15
## 4182  32   blue-collar   single      no    1036     yes  yes   unknown  30
## 4183  55    technician  married      no       0      no   no   unknown   6
## 4184  40   blue-collar  married      no     187     yes   no  cellular  15
## 4185  37   blue-collar  married      no     604     yes   no  cellular   7
## 4186  33    management   single      no     896     yes   no  cellular  19
## 4187  30    technician   single      no    2325      no   no  cellular  10
## 4188  36    management  married      no     812      no   no  cellular   7
## 4189  37    technician   single      no    1255     yes   no   unknown  30
## 4190  38   blue-collar  married      no     264     yes   no telephone  31
## 4191  46        admin.   single      no    1544     yes   no   unknown  29
## 4192  52    technician  married      no     337     yes   no  cellular   8
## 4193  27    management  married      no     -41     yes   no   unknown  16
## 4194  43   blue-collar  married      no    -509     yes   no   unknown   6
## 4195  31    management   single      no     933     yes   no  cellular   9
## 4196  44       retired  married      no    2692      no   no   unknown  12
## 4197  39   blue-collar  married      no       0     yes   no  cellular  30
## 4198  26 self-employed   single      no    1153      no   no  cellular   4
## 4199  34    management   single      no      14     yes   no telephone   4
## 4200  36    technician  married      no    2473      no   no  cellular  28
## 4201  34    management   single      no       0     yes   no   unknown   2
## 4202  39    technician  married      no       0     yes   no   unknown   5
## 4203  35      services  married      no     764      no   no  cellular  12
## 4204  30 self-employed  married      no    -517     yes  yes  cellular  22
## 4205  52   blue-collar  married      no      60      no  yes  cellular  26
## 4206  54   blue-collar  married      no      95      no   no  cellular  25
## 4207  35      services  married      no     181     yes   no  cellular  31
## 4208  61    management  married      no     997      no   no  cellular  22
## 4209  41    management  married      no    1199     yes   no  cellular  18
## 4210  40    technician divorced      no     237      no   no  cellular  25
## 4211  64       retired  married      no     493      no   no  cellular  17
## 4212  46    technician divorced      no     477     yes   no   unknown   6
## 4213  28       student   single      no     221     yes   no  cellular  15
## 4214  42    technician   single      no      -1      no   no  cellular  29
## 4215  35    management  married      no     481      no   no  cellular  13
## 4216  38   blue-collar  married      no     292     yes  yes   unknown   6
## 4217  45    technician divorced      no     159     yes   no   unknown  26
## 4218  36    management divorced      no    5195     yes   no   unknown   2
## 4219  41   blue-collar  married      no    -692     yes   no  cellular  16
## 4220  43    management divorced      no       0     yes   no   unknown   8
## 4221  36    management  married      no    3874      no   no  cellular  25
## 4222  41      services  married      no     108     yes  yes   unknown  13
## 4223  23       student   single      no       0      no   no  cellular   7
## 4224  46     housemaid  married      no    1000      no   no  cellular  18
## 4225  40        admin.  married      no      67      no  yes   unknown  20
## 4226  30   blue-collar  married      no     136      no   no  cellular  18
## 4227  47    technician divorced      no      48      no   no   unknown  27
## 4228  62       retired  married      no    2557     yes   no  cellular  14
## 4229  47        admin.  married      no    1934      no  yes  cellular  14
## 4230  36    management  married      no       0     yes  yes  cellular  14
## 4231  35    management  married      no     802     yes   no  cellular   6
## 4232  46   blue-collar  married      no     -27     yes   no  cellular  11
## 4233  31        admin.   single      no    4129      no   no  cellular   2
## 4234  25   blue-collar  married      no    -306     yes   no   unknown  20
## 4235  59       retired  married     yes      -1      no   no  cellular   5
## 4236  30      services  married      no    1286     yes  yes  cellular  17
## 4237  52      services  married      no    2618     yes   no  cellular  21
## 4238  31    technician   single      no     418      no   no  cellular   7
## 4239  54       retired  married      no    1379      no   no   unknown  11
## 4240  41      services  married      no     572     yes   no  cellular  11
## 4241  45    management  married      no    2953     yes  yes  cellular   5
## 4242  45   blue-collar   single      no    -100     yes   no  cellular   9
## 4243  37   blue-collar  married      no     704     yes   no  cellular  31
## 4244  36    technician  married      no      99     yes  yes  cellular  17
## 4245  41    unemployed  married      no     183     yes   no  cellular  29
## 4246  49  entrepreneur divorced     yes    -736      no   no  cellular  31
## 4247  26    technician   single     yes    -454      no  yes  cellular  18
## 4248  23        admin.   single      no     290     yes   no   unknown  12
## 4249  35      services  married      no    1359      no   no   unknown  17
## 4250  41   blue-collar   single      no     363     yes   no   unknown   8
## 4251  40        admin.  married      no    3138      no   no  cellular  12
## 4252  45   blue-collar  married      no     185      no   no  cellular  25
## 4253  42    technician divorced      no     611     yes   no  cellular  16
## 4254  38   blue-collar  married      no       0      no   no   unknown   6
## 4255  46        admin.  married      no     547      no  yes  cellular   4
## 4256  34      services   single      no     528     yes   no  cellular   2
## 4257  26    management divorced      no     667      no   no telephone  19
## 4258  35        admin.  married     yes      76      no  yes   unknown  17
## 4259  30    unemployed   single     yes    -770     yes   no   unknown  28
## 4260  40    technician   single      no     445     yes   no  cellular  24
## 4261  37    unemployed  married      no     117      no   no  cellular  12
## 4262  49    technician divorced      no       7     yes  yes  cellular  17
## 4263  27    technician  married      no    2735     yes   no  cellular  29
## 4264  40      services   single      no     546     yes   no   unknown   6
## 4265  33    management divorced      no    1897     yes  yes   unknown   2
## 4266  53   blue-collar divorced      no    -376     yes   no  cellular   9
## 4267  58    technician  married      no    1692     yes   no telephone  17
## 4268  52      services  married      no    1625      no   no  cellular   8
## 4269  42    technician  married      no    2030     yes  yes  cellular   9
## 4270  57       retired  married      no     592      no  yes  cellular  28
## 4271  42    management   single      no     100      no   no  cellular   7
## 4272  32    technician  married      no    8023      no   no  cellular  17
## 4273  34    management   single      no   11350     yes   no  cellular  20
## 4274  76       retired divorced      no      86      no   no  cellular  12
## 4275  33        admin.   single      no     892     yes   no   unknown  21
## 4276  35    management   single      no     747      no   no  cellular   4
## 4277  35    technician  married      no    1067      no  yes  cellular  12
## 4278  33   blue-collar   single      no     433     yes   no  cellular  15
## 4279  54        admin.  married      no    5084     yes  yes  cellular   8
## 4280  58       retired   single      no    6570      no   no  cellular  21
## 4281  37 self-employed  married      no    2260     yes   no   unknown  30
## 4282  39      services   single      no     300     yes  yes   unknown  28
## 4283  41    management divorced      no    1064      no   no  cellular  25
## 4284  56      services  married      no      17      no  yes  cellular  25
## 4285  31        admin.   single      no    5527     yes   no   unknown  21
## 4286  46    technician  married      no     718     yes   no  cellular   6
## 4287  35    management  married      no    1613     yes   no  cellular  18
## 4288  50    unemployed  married      no     -13     yes   no   unknown  14
## 4289  57    technician  married      no    3082     yes  yes  cellular  20
## 4290  58        admin.  married      no    1142      no   no telephone   4
## 4291  37        admin.  married      no    1415     yes   no  cellular  12
## 4292  33    technician  married      no     804      no  yes telephone  18
## 4293  34  entrepreneur  married      no     145     yes  yes  cellular  18
## 4294  37      services  married      no     692     yes   no telephone  20
## 4295  34    management   single      no    2343      no   no telephone  21
## 4296  48    technician divorced      no     791      no   no  cellular   7
## 4297  29        admin.  married      no     795     yes  yes  cellular  10
## 4298  59     housemaid  married      no       0      no   no telephone  27
## 4299  59       retired  married      no    -119     yes   no   unknown   6
## 4300  43    management divorced      no     350     yes   no   unknown   4
## 4301  38   blue-collar  married      no       0     yes   no  cellular  17
## 4302  67    management  married      no     694      no   no  cellular   7
## 4303  40      services   single      no     224     yes   no  cellular  17
## 4304  30   blue-collar  married      no     282     yes  yes   unknown  23
## 4305  31        admin.  married      no     799     yes   no  cellular   7
## 4306  50    unemployed divorced      no      64      no   no  cellular  31
## 4307  26       unknown divorced      no    -295     yes   no  cellular   7
## 4308  44    technician  married      no    2981     yes  yes  cellular  22
## 4309  32    management   single      no    -252     yes   no  cellular  15
## 4310  53    management  married      no   32464      no   no  cellular  19
## 4311  26   blue-collar   single      no    -887     yes   no  cellular  18
## 4312  38    technician divorced      no     273     yes   no   unknown  20
## 4313  26      services   single      no     212     yes   no  cellular  15
## 4314  44        admin.  married      no    1248     yes  yes  cellular   8
## 4315  58       retired  married      no     188      no   no  cellular  14
## 4316  42    technician  married      no    1812     yes   no  cellular  31
## 4317  54    management  married      no    2895     yes   no  cellular   9
## 4318  53   blue-collar  married      no     392      no   no  cellular  26
## 4319  46    technician  married      no     363     yes   no  cellular   6
## 4320  41  entrepreneur  married      no     373      no   no   unknown  16
## 4321  43        admin.   single      no      87     yes   no   unknown   7
## 4322  29    unemployed   single      no     670     yes   no   unknown  26
## 4323  51       retired  married      no    2525      no   no   unknown  11
## 4324  50      services  married      no    1501      no   no  cellular  21
## 4325  41   blue-collar  married      no     389     yes   no   unknown  16
## 4326  30    management   single      no    4889      no   no  cellular  11
## 4327  38   blue-collar  married      no     625     yes  yes  cellular  11
## 4328  48    management   single      no      86      no   no  cellular  28
## 4329  55    technician  married      no       0      no   no  cellular  29
## 4330  38    technician divorced      no    1294     yes   no   unknown  29
## 4331  43        admin.  married      no    -879     yes   no   unknown  20
## 4332  25   blue-collar   single      no    1857     yes   no  cellular  12
## 4333  36    unemployed divorced      no    1366      no  yes  cellular   2
## 4334  30   blue-collar  married      no     194     yes   no  cellular   8
## 4335  42      services   single      no    3403     yes   no  cellular  30
## 4336  48    technician  married      no    1152     yes   no  cellular  21
## 4337  43   blue-collar  married      no    1335     yes   no   unknown   6
## 4338  37    management  married      no       0     yes   no  cellular  14
## 4339  38    management   single      no    -145     yes   no  cellular  21
## 4340  38    technician  married      no     751     yes   no  cellular   3
## 4341  55   blue-collar  married      no     431     yes   no   unknown  12
## 4342  52   blue-collar  married      no    1319      no   no telephone  30
## 4343  28        admin.   single      no    1507      no   no  cellular   7
## 4344  33    management   single      no     215     yes   no  cellular  27
## 4345  30    unemployed   single      no     306      no   no   unknown  26
## 4346  42      services   single      no       0     yes   no  cellular  14
## 4347  29      services  married      no      19     yes   no  cellular  29
## 4348  45        admin.  married      no    5511      no   no  cellular   2
## 4349  49    management  married      no     362     yes   no   unknown   4
## 4350  33    technician   single      no    2412     yes   no  cellular  14
## 4351  53   blue-collar  married      no     111      no   no   unknown  20
## 4352  40   blue-collar  married      no    -450     yes   no  cellular  15
## 4353  29   blue-collar  married      no     457     yes   no  cellular  20
## 4354  56       retired  married      no     307      no  yes  cellular   8
## 4355  36        admin.  married      no     231     yes  yes   unknown   6
## 4356  49   blue-collar divorced      no   10613      no  yes  cellular   4
## 4357  38   blue-collar  married      no     376     yes   no   unknown   7
## 4358  28        admin.   single      no    3029     yes   no  cellular  18
## 4359  30    technician  married      no    8351      no   no  cellular  11
## 4360  33    technician   single      no     555      no  yes  cellular   4
## 4361  52     housemaid  married      no    2337     yes   no  cellular  24
## 4362  37   blue-collar   single      no       0     yes  yes  cellular  22
## 4363  59    technician  married      no     -91      no   no   unknown  25
## 4364  44    technician  married      no    8938     yes   no   unknown   3
## 4365  32    technician divorced      no    2558      no   no   unknown   5
## 4366  59      services  married      no     108      no   no  cellular  11
## 4367  31   blue-collar  married      no    2929     yes   no  cellular  20
## 4368  26      services   single      no       0      no   no  cellular  29
## 4369  52    technician  married      no   22755     yes   no   unknown  29
## 4370  43    management  married      no    2987      no   no  cellular  11
## 4371  36    technician  married      no     911     yes  yes  cellular   4
## 4372  58    management  married      no    1517     yes   no telephone  29
## 4373  39        admin.  married      no    1108      no   no  cellular  21
## 4374  55   blue-collar   single      no      39     yes   no   unknown  26
## 4375  35    management  married      no    2123     yes   no  cellular  20
## 4376  26      services   single     yes      74      no   no  cellular   8
## 4377  30    management   single      no     162     yes   no   unknown  20
## 4378  36    management  married      no     393     yes   no  cellular  30
## 4379  41        admin.  married      no    2498      no   no  cellular  12
## 4380  34   blue-collar  married      no    1221     yes   no  cellular   5
## 4381  45   blue-collar  married      no     665      no   no   unknown   9
## 4382  51    technician divorced      no    4596      no   no  cellular   8
## 4383  47    management  married      no    2889      no   no telephone  29
## 4384  36   blue-collar  married      no    -318     yes   no  cellular  14
## 4385  41    technician  married      no     871     yes   no   unknown   6
## 4386  63    technician  married      no     973      no   no  cellular  25
## 4387  39        admin.  married      no    1022     yes  yes  cellular  28
## 4388  39    management  married      no     551      no  yes  cellular   7
## 4389  30    technician   single      no       5      no   no  cellular  19
## 4390  47      services divorced      no     164      no   no   unknown   5
## 4391  29   blue-collar  married      no       0     yes   no   unknown  13
## 4392  60    technician  married      no       0      no   no  cellular  19
## 4393  46   blue-collar  married      no       7      no   no   unknown  17
## 4394  36    management   single      no     515     yes   no  cellular  21
## 4395  53       retired  married      no    1139     yes   no  cellular  18
## 4396  49      services  married      no    4713     yes   no telephone  21
## 4397  37        admin.   single      no    3049     yes  yes   unknown  29
## 4398  33        admin. divorced      no     140     yes   no   unknown   8
## 4399  62       retired  married      no     298      no   no  cellular  17
## 4400  31    technician  married      no    4315     yes   no   unknown  21
## 4401  30      services   single      no     -97     yes   no   unknown   4
## 4402  41     housemaid  married      no      39      no   no  cellular  21
## 4403  37    management  married      no     784     yes   no  cellular   9
## 4404  39   blue-collar   single      no    1672     yes   no  cellular  20
## 4405  31   blue-collar   single      no      17     yes   no  cellular  12
## 4406  34        admin.  married      no     507     yes   no   unknown   6
## 4407  34    technician   single      no    2047     yes   no  cellular  28
## 4408  28      services   single      no    1820     yes   no  cellular   5
## 4409  43        admin.  married      no    -150      no  yes  cellular  21
## 4410  51   blue-collar  married      no    1238      no   no   unknown  18
## 4411  46     housemaid  married      no      75      no   no   unknown   9
## 4412  26   blue-collar   single      no     191     yes   no  cellular   6
## 4413  40 self-employed  married      no       2      no   no  cellular  22
## 4414  46   blue-collar  married      no     292     yes   no  cellular  20
## 4415  51    management   single      no    5341      no   no  cellular  30
## 4416  31   blue-collar  married      no      99     yes   no  cellular  29
## 4417  37        admin.  married      no     190     yes   no   unknown   5
## 4418  42    technician  married      no    -556     yes   no  cellular  19
## 4419  27        admin.  married      no     133     yes  yes   unknown   9
## 4420  53 self-employed  married      no     167     yes   no  cellular   7
## 4421  35        admin.  married      no    1145     yes   no  cellular   2
## 4422  28   blue-collar   single      no     369     yes   no   unknown  23
## 4423  30    management   single      no    3259     yes   no  cellular  23
## 4424  59       retired  married      no      82      no   no  cellular  28
## 4425  30        admin.   single      no     270      no   no  cellular  30
## 4426  30   blue-collar  married      no     187     yes   no   unknown  26
## 4427  41    management  married      no     -98     yes  yes  cellular  23
## 4428  43   blue-collar  married      no    7727     yes   no   unknown  15
## 4429  33      services  married      no     740      no  yes   unknown  30
## 4430  48       unknown  married      no       3      no   no  cellular  19
## 4431  36 self-employed   single      no       0     yes   no  cellular  30
## 4432  35    technician  married      no     328     yes   no  cellular  22
## 4433  31        admin.  married      no     223      no   no  cellular   6
## 4434  48    technician   single      no     469      no  yes  cellular   9
## 4435  60       retired  married      no     878      no   no  cellular  13
## 4436  35 self-employed   single      no     353      no   no  cellular  12
## 4437  50    technician  married      no     349     yes   no telephone  28
## 4438  53   blue-collar divorced      no    -473     yes   no   unknown  28
## 4439  27        admin.   single      no    3672     yes   no  cellular  15
## 4440  32   blue-collar  married      no    2198      no   no  cellular  15
## 4441  76       retired  married      no    2223      no   no telephone   4
## 4442  44    management divorced      no    5773      no   no   unknown  23
## 4443  40    management  married      no    1308      no   no telephone   3
## 4444  34    technician  married      no    3160     yes   no  cellular  13
## 4445  33      services  married      no     233      no   no  cellular  29
## 4446  33   blue-collar  married      no    1464     yes   no   unknown  23
## 4447  56     housemaid  married      no    1922     yes   no  cellular  24
## 4448  47     housemaid  married      no     333      no   no telephone  21
## 4449  30        admin.   single      no     726      no   no  cellular  29
## 4450  48    technician  married      no    1939     yes  yes  cellular   6
## 4451  40   blue-collar divorced      no    4168     yes   no  cellular  29
## 4452  56       retired divorced      no    -154     yes   no   unknown  27
## 4453  36 self-employed   single      no    3560      no   no  cellular  18
## 4454  54    management  married      no    1411      no   no  cellular  12
## 4455  47   blue-collar  married      no     209      no   no  cellular  27
## 4456  56    management  married      no      73     yes   no  cellular   8
## 4457  47      services  married      no     439     yes   no  cellular  20
## 4458  34   blue-collar  married      no       0     yes  yes  cellular   5
## 4459  32        admin.   single      no       1      no   no  cellular   2
## 4460  41    management  married      no       4     yes   no  cellular  15
## 4461  48        admin.  married      no    1800     yes   no   unknown  18
## 4462  34    technician   single      no    1227      no   no telephone  17
## 4463  36    management  married      no    1041     yes   no  cellular  14
## 4464  36   blue-collar  married      no     106     yes   no  cellular  29
## 4465  37   blue-collar  married      no     693      no   no  cellular  20
## 4466  46  entrepreneur  married      no       0      no  yes  cellular  18
## 4467  41    management  married      no     456     yes   no  cellular  11
## 4468  33   blue-collar   single      no     179      no   no  cellular  14
## 4469  58   blue-collar divorced      no     474     yes  yes  cellular  18
## 4470  31       student   single      no     430      no   no  cellular   5
## 4471  31    management   single      no     874     yes   no  cellular   7
## 4472  34    management  married      no     271     yes   no  cellular  15
## 4473  48  entrepreneur  married      no       0     yes   no  cellular  17
## 4474  42   blue-collar   single      no      22     yes   no  cellular  14
## 4475  40    technician  married      no     286      no   no  cellular  30
## 4476  36    management  married      no      10      no  yes   unknown  28
## 4477  46    technician  married      no     536     yes   no   unknown  16
## 4478  66  entrepreneur  married      no       0      no   no telephone  12
## 4479  30    technician   single      no    1572     yes  yes   unknown  23
## 4480  46   blue-collar   single      no     324     yes   no   unknown  30
## 4481  62    management  married      no    2785      no   no  cellular   6
## 4482  48   blue-collar  married      no       0      no   no  cellular  19
## 4483  32    management  married      no      92      no   no   unknown   3
## 4484  57    management  married      no     163      no   no  cellular   6
## 4485  36        admin. divorced      no     289     yes  yes  cellular  28
## 4486  38    management divorced      no    6368     yes   no  cellular   4
## 4487  41      services divorced      no     308      no   no  cellular  31
## 4488  48    technician   single      no    1245      no   no  cellular  13
## 4489  57       retired  married      no    1335      no   no  cellular  19
## 4490  46    management divorced      no     233     yes  yes  cellular  14
## 4491  67       retired  married      no     258      no   no  cellular  17
## 4492  35    management  married      no     674      no   no  cellular   8
## 4493  57        admin.  married      no    2038      no   no  cellular   9
## 4494  40    technician  married      no       0      no   no  cellular  15
## 4495  45        admin.  married      no     476      no   no  cellular   6
## 4496  31    technician   single      no       0      no   no  cellular  29
## 4497  45        admin.  married      no    1435     yes   no  cellular  11
## 4498  43   blue-collar  married      no     601     yes   no  cellular  16
## 4499  52   blue-collar  married      no     372     yes   no  cellular   8
## 4500  53    technician  married      no     284      no   no  cellular   1
## 4501  32    technician   single      no     705      no   no  cellular  17
## 4502  52   blue-collar  married      no     655     yes  yes  cellular  31
## 4503  40      services  married      no       0     yes  yes  cellular   2
## 4504  43  entrepreneur  married      no     641     yes  yes   unknown   2
## 4505  32    technician  married      no       2     yes  yes  cellular   8
## 4506  48        admin. divorced      no     771     yes   no   unknown   2
## 4507  45   blue-collar  married      no     644     yes   no telephone  12
## 4508  51        admin.  married      no     194      no  yes  cellular  22
## 4509  33   blue-collar  married      no    1050     yes   no   unknown  26
## 4510  32    management   single      no     863     yes   no   unknown  20
## 4511  35      services  married      no     372     yes   no  cellular  11
## 4512  31    management  married      no    3739      no   no  cellular  11
## 4513  43   blue-collar  married      no       0     yes  yes   unknown  29
## 4514  34   blue-collar divorced      no       0      no  yes   unknown  21
## 4515  29        admin.   single      no    1448      no   no  cellular  10
## 4516  38    technician  married      no      79     yes   no  cellular  20
## 4517  39        admin.  married      no      70     yes   no  cellular  31
## 4518  42        admin.  married      no    1133     yes   no  cellular   4
## 4519  54 self-employed  married      no      66     yes   no telephone  12
## 4520  45   blue-collar  married      no     -60      no   no  cellular  31
## 4521  32    technician   single      no     703     yes   no  cellular   3
##      month duration campaign pdays previous poutcome y education
## 1      jan      375        2    -1        0  unknown 0     upper
## 2      jun      392        3    -1        0  unknown 0     upper
## 3      feb      315        2   180        6  failure 1     upper
## 4      may      309        1   306        4  success 1     upper
## 5      may       67        4    -1        0  unknown 0     upper
## 6      may      125        1    -1        0  unknown 0     upper
## 7      aug      182        2    37        2  failure 0     upper
## 8      may      185        1   370        3  failure 0   primary
## 9      nov      296        2    -1        0  unknown 0     upper
## 10     nov       80        1    -1        0  unknown 0     upper
## 11     feb      236        2   272        1  failure 0     upper
## 12     jun      199        4    -1        0  unknown 0   primary
## 13     aug      182        2    99        1  failure 1     upper
## 14     nov      250        1   155        2  failure 0   primary
## 15     may       12        5    -1        0  unknown 0     upper
## 16     jun      446        1    -1        0  unknown 0     upper
## 17     aug       89       23    -1        0  unknown 0   primary
## 18     jun        7        3    -1        0  unknown 0   unknown
## 19     jul      130        8    -1        0  unknown 0     upper
## 20     aug      110        4    -1        0  unknown 0     upper
## 21     aug       51        3    -1        0  unknown 0     upper
## 22     jul       42        1    -1        0  unknown 0     upper
## 23     may       33        2    -1        0  unknown 0   unknown
## 24     nov      112        1    -1        0  unknown 0     upper
## 25     may      352        3    -1        0  unknown 0     upper
## 26     nov      167        1    -1        0  unknown 0     upper
## 27     aug       97        4    -1        0  unknown 0     upper
## 28     jul      148        2    -1        0  unknown 0     upper
## 29     nov      312        3    -1        0  unknown 0     upper
## 30     may       73        1    -1        0  unknown 0     upper
## 31     jun      244        2    -1        0  unknown 1     upper
## 32     jun      835        2    -1        0  unknown 0   primary
## 33     feb       22        6   196        6  failure 0     upper
## 34     jun      135        2    -1        0  unknown 0     upper
## 35     may      168        2    -1        0  unknown 0     upper
## 36     feb      765        2    -1        0  unknown 0     upper
## 37     apr       96        4   314        8    other 0   primary
## 38     apr      334        2    -1        0  unknown 1     upper
## 39     jul       46       21    -1        0  unknown 0   primary
## 40     may       95        1    -1        0  unknown 0   primary
## 41     may      305        5   349        7    other 0   primary
## 42     may      206        1    -1        0  unknown 0     upper
## 43     aug      106        2    -1        0  unknown 0     upper
## 44     may      248        1    -1        0  unknown 0     upper
## 45     apr       53        1   346        1  failure 0     upper
## 46     aug      189        4    -1        0  unknown 0     upper
## 47     nov       44        1    -1        0  unknown 0     upper
## 48     apr      149        2    -1        0  unknown 0   primary
## 49     sep      368        1    -1        0  unknown 0   primary
## 50     may      139        4    -1        0  unknown 0   primary
## 51     may     1623        1    -1        0  unknown 1   unknown
## 52     aug      342        5    -1        0  unknown 0     upper
## 53     aug      106        2    -1        0  unknown 0     upper
## 54     may      113        2    -1        0  unknown 0     upper
## 55     may      181        1    -1        0  unknown 0     upper
## 56     aug      265        4    -1        0  unknown 0     upper
## 57     apr      400        1    -1        0  unknown 1     upper
## 58     aug      158        9    -1        0  unknown 0     upper
## 59     jan      100        1   170        4  failure 0     upper
## 60     jun      517        3    -1        0  unknown 0     upper
## 61     may       49        2    -1        0  unknown 0   primary
## 62     jul      428        1    -1        0  unknown 0     upper
## 63     may      381        1   342        7  failure 0     upper
## 64     jun      179        1    -1        0  unknown 0     upper
## 65     may       44        1    -1        0  unknown 0     upper
## 66     may      578        1   364        1    other 0     upper
## 67     jun      139        2    -1        0  unknown 0     upper
## 68     may      211        2    -1        0  unknown 0     upper
## 69     may      290        2   370        1  failure 0     upper
## 70     nov      618        2    -1        0  unknown 0   primary
## 71     apr      424        1   138        1  failure 0     upper
## 72     nov      209        2   180        1    other 0     upper
## 73     feb      164        2   262        2  failure 0   primary
## 74     jan      814        1    -1        0  unknown 0   primary
## 75     jul       92        1    -1        0  unknown 0     upper
## 76     may      231        1    -1        0  unknown 0     upper
## 77     jan      309        1   197       13    other 0     upper
## 78     nov      319        3    -1        0  unknown 0     upper
## 79     nov      189        1    -1        0  unknown 0   primary
## 80     aug       54        5    86        3  failure 0     upper
## 81     jun      149        1    -1        0  unknown 0     upper
## 82     jan      143        1    -1        0  unknown 1     upper
## 83     jul      134        1    -1        0  unknown 0   primary
## 84     oct       54        1    -1        0  unknown 0     upper
## 85     jul      901        2    -1        0  unknown 1   primary
## 86     aug      140        2    -1        0  unknown 0     upper
## 87     may      155        6    -1        0  unknown 0     upper
## 88     may      204        3    -1        0  unknown 0     upper
## 89     jul      625        1    -1        0  unknown 1     upper
## 90     may      860        2    -1        0  unknown 0     upper
## 91     may       16        4   273        7    other 0     upper
## 92     jun      169        2    -1        0  unknown 0   unknown
## 93     apr      239        1   276        6  failure 0     upper
## 94     sep      228        1   185        1  failure 0   primary
## 95     oct      513        1    -1        0  unknown 1   primary
## 96     may      152        3    -1        0  unknown 0     upper
## 97     nov      352        3    -1        0  unknown 0     upper
## 98     nov      203        2    -1        0  unknown 0     upper
## 99     nov       34        1   124        6  failure 0   primary
## 100    may      190        5    -1        0  unknown 0     upper
## 101    may      324        1    -1        0  unknown 0     upper
## 102    jul      231        2    -1        0  unknown 0     upper
## 103    jul      203        1    -1        0  unknown 0     upper
## 104    apr      411        1    -1        0  unknown 0     upper
## 105    may      113        1    -1        0  unknown 0   primary
## 106    jun       89        3    -1        0  unknown 0     upper
## 107    may      379        1    -1        0  unknown 0   primary
## 108    jun      174        1    -1        0  unknown 0     upper
## 109    may      674        2   250        4  failure 0     upper
## 110    may      313        3    -1        0  unknown 0     upper
## 111    may       51        1    -1        0  unknown 0   primary
## 112    may      200        4    -1        0  unknown 0     upper
## 113    aug      714        1    -1        0  unknown 1     upper
## 114    may      193        8    -1        0  unknown 0   unknown
## 115    may      827        1   329        9  failure 0     upper
## 116    jul      126        4    -1        0  unknown 0   primary
## 117    aug      127        1    -1        0  unknown 0     upper
## 118    apr       98        1    -1        0  unknown 0     upper
## 119    nov       41        2   123        3  failure 0     upper
## 120    may       71        1    -1        0  unknown 0     upper
## 121    jul      254        2    -1        0  unknown 0     upper
## 122    apr      201        2    -1        0  unknown 0     upper
## 123    aug      205        5    -1        0  unknown 0     upper
## 124    aug       98       19    -1        0  unknown 0   primary
## 125    apr      111        1    -1        0  unknown 0     upper
## 126    may       97        1    -1        0  unknown 0     upper
## 127    aug      185        2    -1        0  unknown 0     upper
## 128    apr      100        2    -1        0  unknown 0     upper
## 129    may       99        2    -1        0  unknown 0     upper
## 130    may      360        2    -1        0  unknown 0     upper
## 131    may       23        1   359        3  failure 0     upper
## 132    nov      108        1    -1        0  unknown 0     upper
## 133    may      184        1   167        6  failure 0     upper
## 134    jun      757        2    -1        0  unknown 0     upper
## 135    jun      240        1   307       10    other 0     upper
## 136    may      322        2    -1        0  unknown 0   primary
## 137    may      168        4    -1        0  unknown 0     upper
## 138    may      192        1    -1        0  unknown 0     upper
## 139    nov       92        1   188        1  failure 0     upper
## 140    may       43        1   367        2  success 0     upper
## 141    jun       66        5    -1        0  unknown 0     upper
## 142    feb      344        2    -1        0  unknown 0     upper
## 143    may      163        1    -1        0  unknown 0     upper
## 144    may      183        1   361        1  failure 0     upper
## 145    may       11        8    -1        0  unknown 0     upper
## 146    aug     1471        7    -1        0  unknown 1   primary
## 147    aug       70        8    -1        0  unknown 0     upper
## 148    may       88        3    -1        0  unknown 0     upper
## 149    aug      781        2    -1        0  unknown 0     upper
## 150    may       58        2    -1        0  unknown 0     upper
## 151    nov       55        2    -1        0  unknown 0     upper
## 152    may      181        2   255        5  failure 0     upper
## 153    jan      119        2    -1        0  unknown 0     upper
## 154    jul      163        1    -1        0  unknown 0     upper
## 155    may      140        2    -1        0  unknown 0     upper
## 156    jul      151        2    -1        0  unknown 0     upper
## 157    nov      752        3    -1        0  unknown 0     upper
## 158    may      167        4    -1        0  unknown 0   primary
## 159    feb       89        1    -1        0  unknown 0   primary
## 160    may      275        4    -1        0  unknown 0     upper
## 161    nov      347        4   189        2  success 1     upper
## 162    jan      461        2   204        2  failure 0     upper
## 163    feb       74        1    -1        0  unknown 0     upper
## 164    may       86        1    -1        0  unknown 0   unknown
## 165    mar      116        1    -1        0  unknown 1     upper
## 166    aug      507        1   181        2  success 1     upper
## 167    feb      835        3    -1        0  unknown 1     upper
## 168    oct      355        1   180        5  failure 1   primary
## 169    nov      322        1    -1        0  unknown 1     upper
## 170    jul      348        2    -1        0  unknown 0     upper
## 171    may      336       10    -1        0  unknown 0   primary
## 172    may      275        1   370        2  failure 0   primary
## 173    jul      863       10    -1        0  unknown 0     upper
## 174    may      180        1    -1        0  unknown 0     upper
## 175    dec     1141        1   209        1    other 1     upper
## 176    may      805        2    -1        0  unknown 0     upper
## 177    jul     1877        1    -1        0  unknown 1   primary
## 178    aug      121        1    -1        0  unknown 0     upper
## 179    jun      174        1    -1        0  unknown 0     upper
## 180    nov      130        3   188        2    other 0   unknown
## 181    jul      119        1    -1        0  unknown 0     upper
## 182    sep      217        2   188        3    other 0   primary
## 183    aug       96        2    -1        0  unknown 0     upper
## 184    aug       81        2    -1        0  unknown 0     upper
## 185    feb      150        3   270        2  failure 0     upper
## 186    jul      399        8    -1        0  unknown 0   primary
## 187    nov       66        1    -1        0  unknown 0     upper
## 188    may      100        1    -1        0  unknown 0     upper
## 189    jul      196        2    -1        0  unknown 0     upper
## 190    may      121        1    -1        0  unknown 0     upper
## 191    apr      138        2   263        7  failure 0   primary
## 192    jul      123        2    -1        0  unknown 0     upper
## 193    jul       92        2    -1        0  unknown 0     upper
## 194    feb       89        2    -1        0  unknown 0     upper
## 195    aug      304        3    -1        0  unknown 1     upper
## 196    jan      533        1    92        1  success 1   primary
## 197    mar      233        1    -1        0  unknown 0     upper
## 198    jul      117        1    -1        0  unknown 0     upper
## 199    may      244        4    -1        0  unknown 0     upper
## 200    jan       90        1    -1        0  unknown 0   unknown
## 201    may      250        1    -1        0  unknown 0   primary
## 202    jul      355        2    -1        0  unknown 1     upper
## 203    may      336        1    89        5  failure 1     upper
## 204    feb      118        4   210        3  failure 1     upper
## 205    jan      253        1    -1        0  unknown 0     upper
## 206    aug       75        1    -1        0  unknown 0     upper
## 207    may      139        1    -1        0  unknown 0     upper
## 208    aug       43        2    -1        0  unknown 0   primary
## 209    jun       53        2    -1        0  unknown 0     upper
## 210    jul      270        1    -1        0  unknown 0     upper
## 211    nov       65        1   131        1  failure 0     upper
## 212    jul      167        2    -1        0  unknown 0     upper
## 213    dec      155        1   120        3  success 1     upper
## 214    apr      479        1    -1        0  unknown 0     upper
## 215    aug      250        2   187        2  success 1     upper
## 216    aug       80        2    -1        0  unknown 0     upper
## 217    may     1183        1    -1        0  unknown 1     upper
## 218    jan      418        2    -1        0  unknown 0     upper
## 219    jul      340        1    -1        0  unknown 0     upper
## 220    may      468        1    -1        0  unknown 0     upper
## 221    apr      777        2    -1        0  unknown 0     upper
## 222    jul       18       44    -1        0  unknown 0   primary
## 223    may      114        4   364       22    other 0     upper
## 224    aug       15       20    -1        0  unknown 0     upper
## 225    jun      167        1    -1        0  unknown 0   primary
## 226    may      396        5    -1        0  unknown 1     upper
## 227    may      159        4    -1        0  unknown 0     upper
## 228    aug      430        4    -1        0  unknown 0   primary
## 229    may      189        2    -1        0  unknown 0     upper
## 230    nov      142        2    -1        0  unknown 0   primary
## 231    apr      268        1    -1        0  unknown 0   unknown
## 232    jan       80        2    -1        0  unknown 0   primary
## 233    may      233        3    -1        0  unknown 0   primary
## 234    jun      208        4    -1        0  unknown 0     upper
## 235    nov       79        3    -1        0  unknown 0     upper
## 236    jul      118        1    -1        0  unknown 0   primary
## 237    aug       73        4    -1        0  unknown 0     upper
## 238    may      175        2    -1        0  unknown 0     upper
## 239    nov      165        1    -1        0  unknown 0     upper
## 240    jul      122       13    -1        0  unknown 0     upper
## 241    jul      125        3    -1        0  unknown 0   primary
## 242    may       23        4    -1        0  unknown 0   primary
## 243    may      557        4    -1        0  unknown 0   unknown
## 244    may      528        5    -1        0  unknown 1     upper
## 245    nov      420        2    -1        0  unknown 0     upper
## 246    may      151        1    -1        0  unknown 0     upper
## 247    may      407        2    -1        0  unknown 0     upper
## 248    nov      104        2    28        2  success 0     upper
## 249    may      351        1    -1        0  unknown 0   primary
## 250    jul      357        1    -1        0  unknown 0     upper
## 251    jul      255        3    -1        0  unknown 0     upper
## 252    apr      426        3   323        3  failure 0     upper
## 253    feb      204        1    -1        0  unknown 0     upper
## 254    may      418        8    -1        0  unknown 0     upper
## 255    oct      184        1    91        2  failure 1     upper
## 256    jun       72        1    -1        0  unknown 0     upper
## 257    jun      237        2    -1        0  unknown 0     upper
## 258    jul      163        3    -1        0  unknown 0     upper
## 259    jun      153        4    -1        0  unknown 0     upper
## 260    jun        8        3    -1        0  unknown 0   primary
## 261    jun      399        1    -1        0  unknown 0   primary
## 262    may      185        2   165        2  failure 0   primary
## 263    sep      379        3    -1        0  unknown 0     upper
## 264    may      370        1    -1        0  unknown 0     upper
## 265    apr      401        2    -1        0  unknown 0     upper
## 266    jun       14        2    -1        0  unknown 0     upper
## 267    may       85        1   168        2  failure 0   unknown
## 268    may      230        2    -1        0  unknown 0   primary
## 269    jun       66        1    -1        0  unknown 0   primary
## 270    may      236        1   287        2  failure 0     upper
## 271    feb      138        3     5        1    other 0   primary
## 272    jul      784        1    -1        0  unknown 1     upper
## 273    aug      103        6    -1        0  unknown 0     upper
## 274    aug      165        3    -1        0  unknown 0     upper
## 275    may      325        2    -1        0  unknown 0     upper
## 276    jun       75        4    -1        0  unknown 0     upper
## 277    jun      157        2    -1        0  unknown 0   primary
## 278    aug      297        2    -1        0  unknown 0     upper
## 279    may       13        5    -1        0  unknown 0     upper
## 280    may      177        2   345        3    other 0   primary
## 281    aug       62        7    -1        0  unknown 0     upper
## 282    may      834        6    -1        0  unknown 0     upper
## 283    jun     1446        1    -1        0  unknown 1     upper
## 284    jul      482        2    -1        0  unknown 0   unknown
## 285    mar      432        1    -1        0  unknown 0     upper
## 286    may      173        3    -1        0  unknown 0   primary
## 287    jun      157        2    -1        0  unknown 0     upper
## 288    jul       95        1    -1        0  unknown 0     upper
## 289    may      196        3   265        2  failure 0     upper
## 290    apr      728        1    -1        0  unknown 0   primary
## 291    nov        7        8   185        1  failure 0     upper
## 292    may      203        1    -1        0  unknown 0     upper
## 293    jan      169        2    -1        0  unknown 1     upper
## 294    aug       65        4    -1        0  unknown 0     upper
## 295    nov       66        1    -1        0  unknown 0     upper
## 296    may      161        1    -1        0  unknown 0     upper
## 297    may       63        5   370        1    other 0   primary
## 298    nov      104        3   139        6  failure 0     upper
## 299    jul      180       10    -1        0  unknown 0     upper
## 300    jul      961        1    -1        0  unknown 1     upper
## 301    jul      306        2    -1        0  unknown 0     upper
## 302    aug       58        8    -1        0  unknown 0     upper
## 303    apr      551        1    -1        0  unknown 0     upper
## 304    jun       81        2    -1        0  unknown 0     upper
## 305    apr      150        1    -1        0  unknown 0     upper
## 306    apr      332        2   317        3  failure 0     upper
## 307    mar      117        1    91        1  success 0   primary
## 308    may      275        2    -1        0  unknown 0     upper
## 309    nov      150        4    -1        0  unknown 0     upper
## 310    may      121        1    -1        0  unknown 0     upper
## 311    may      183        4    -1        0  unknown 0     upper
## 312    oct      386        1   184        1    other 0   primary
## 313    may       17        7    -1        0  unknown 0     upper
## 314    may       72        3    -1        0  unknown 0     upper
## 315    sep      133        3    -1        0  unknown 0     upper
## 316    jul      278        2    -1        0  unknown 0     upper
## 317    jun      113        1   109        1  failure 0     upper
## 318    jul     1056        2    -1        0  unknown 1     upper
## 319    may      190        3    -1        0  unknown 0     upper
## 320    apr       57        1    -1        0  unknown 0     upper
## 321    aug       50        4    -1        0  unknown 0   primary
## 322    may      184        1   351        1  failure 0     upper
## 323    aug       35       31    -1        0  unknown 0     upper
## 324    jul       81        4    -1        0  unknown 0   primary
## 325    nov      120        2    -1        0  unknown 0     upper
## 326    jul      309        1    -1        0  unknown 1     upper
## 327    jul      119        2    -1        0  unknown 0     upper
## 328    may      206        4    -1        0  unknown 0     upper
## 329    jul       92        3    -1        0  unknown 0     upper
## 330    jul      204        2    -1        0  unknown 0   primary
## 331    feb      176        3    -1        0  unknown 0   primary
## 332    aug       11        1    -1        0  unknown 0     upper
## 333    jul      407       11    -1        0  unknown 0   primary
## 334    may      212        3    -1        0  unknown 0   primary
## 335    may     1357        4   374        2  failure 1     upper
## 336    may      867        1    -1        0  unknown 1     upper
## 337    may      182        4    -1        0  unknown 0     upper
## 338    aug       65        3    -1        0  unknown 0   primary
## 339    may      265        1   290        2  failure 0   primary
## 340    jun      116        3    -1        0  unknown 0     upper
## 341    nov       88        6   113       13    other 0     upper
## 342    feb      228        1    -1        0  unknown 0     upper
## 343    nov      369        1    -1        0  unknown 0     upper
## 344    jun       52        1    -1        0  unknown 0     upper
## 345    aug      107        6    -1        0  unknown 0     upper
## 346    aug       82        2    -1        0  unknown 0     upper
## 347    may      767        2    -1        0  unknown 1     upper
## 348    may      313        2    -1        0  unknown 0     upper
## 349    jul       17       19    -1        0  unknown 0     upper
## 350    mar      834        1    -1        0  unknown 1   primary
## 351    may      178        1    -1        0  unknown 0     upper
## 352    apr      108        1    -1        0  unknown 0     upper
## 353    jul      200        5    -1        0  unknown 0     upper
## 354    may      147        1    -1        0  unknown 0     upper
## 355    nov      102        1    -1        0  unknown 0     upper
## 356    may      202        1    -1        0  unknown 0     upper
## 357    feb       93        2   274        2  failure 0     upper
## 358    may      777        2    -1        0  unknown 0     upper
## 359    jul      225        2    -1        0  unknown 0     upper
## 360    may       32        1    -1        0  unknown 0     upper
## 361    may      263        1    -1        0  unknown 0     upper
## 362    feb      466        4    -1        0  unknown 1     upper
## 363    jul      838        3    -1        0  unknown 1     upper
## 364    feb      288        1    -1        0  unknown 0   primary
## 365    nov      223        2   186        3    other 0     upper
## 366    aug      183        5    -1        0  unknown 0     upper
## 367    may      536        1    -1        0  unknown 0     upper
## 368    aug      324        4    -1        0  unknown 0     upper
## 369    nov      266        2    -1        0  unknown 0     upper
## 370    may       98        2    -1        0  unknown 0     upper
## 371    may      135        2    -1        0  unknown 0     upper
## 372    jul      326       11    -1        0  unknown 0   primary
## 373    may       98        2    -1        0  unknown 0     upper
## 374    may      195        3   359        1  failure 0   primary
## 375    nov      149        1   170        2  failure 0     upper
## 376    jul       64        1    -1        0  unknown 0     upper
## 377    aug      272        2    -1        0  unknown 0     upper
## 378    may       38        3    -1        0  unknown 0     upper
## 379    may      185        1   178        1  failure 0     upper
## 380    jun      152        5    -1        0  unknown 0     upper
## 381    aug      709       11    -1        0  unknown 0     upper
## 382    jul     1187        3    -1        0  unknown 0     upper
## 383    may      703        4    -1        0  unknown 1     upper
## 384    may       62        2    -1        0  unknown 0     upper
## 385    may      384        1    -1        0  unknown 0   primary
## 386    may       34       12   347        5    other 0     upper
## 387    jan      280        1    -1        0  unknown 0     upper
## 388    jul      362        8    -1        0  unknown 1     upper
## 389    jun      250        3    -1        0  unknown 0     upper
## 390    nov       59        1    -1        0  unknown 0     upper
## 391    may      541        1    -1        0  unknown 0     upper
## 392    feb      361        2   258        1    other 0   primary
## 393    feb      394        3   189        1  success 1     upper
## 394    jul       70        1    -1        0  unknown 0     upper
## 395    may       20        2    -1        0  unknown 0   unknown
## 396    jul     1389        2    -1        0  unknown 0     upper
## 397    jun      215        3    -1        0  unknown 0     upper
## 398    may      178        2   270        8    other 0     upper
## 399    jul      218        4    -1        0  unknown 0     upper
## 400    nov      664        3    -1        0  unknown 1     upper
## 401    jul      244        2    -1        0  unknown 0     upper
## 402    may      109        1   359        8  failure 0     upper
## 403    may       76        2   348        1  failure 0     upper
## 404    nov      598        4    -1        0  unknown 0   primary
## 405    jun      805        2    -1        0  unknown 0   primary
## 406    jul      335        1    -1        0  unknown 0     upper
## 407    sep      202        1    -1        0  unknown 1     upper
## 408    aug      214        8    -1        0  unknown 0     upper
## 409    may      278        1    -1        0  unknown 0     upper
## 410    jul       58        1    -1        0  unknown 0     upper
## 411    aug       83        6    -1        0  unknown 0     upper
## 412    may      291        1   337        1  failure 0     upper
## 413    may      128        1    -1        0  unknown 0     upper
## 414    jun      431        2    -1        0  unknown 0   unknown
## 415    nov      262        3    -1        0  unknown 0     upper
## 416    aug      152        2    -1        0  unknown 0   unknown
## 417    may       98        1    -1        0  unknown 0     upper
## 418    jun      718       13    -1        0  unknown 0   unknown
## 419    jul      285        2    -1        0  unknown 0     upper
## 420    feb      246        1   259        2  failure 0     upper
## 421    jun       20        1    -1        0  unknown 0     upper
## 422    jul       41        9    -1        0  unknown 0   unknown
## 423    jun       73        3    -1        0  unknown 0     upper
## 424    feb      237        2    -1        0  unknown 0   unknown
## 425    jan      592        1    -1        0  unknown 0     upper
## 426    aug      622        1    -1        0  unknown 1     upper
## 427    feb      427        4    -1        0  unknown 0   unknown
## 428    jul      646        2    -1        0  unknown 0     upper
## 429    nov       26        1   101       11    other 0     upper
## 430    nov      519        2    -1        0  unknown 0     upper
## 431    apr      205        1    -1        0  unknown 0   primary
## 432    jul      146        1    91        6  failure 0     upper
## 433    may      104        1    -1        0  unknown 0     upper
## 434    may      105        2    -1        0  unknown 0     upper
## 435    aug      110        4    -1        0  unknown 0   primary
## 436    may      138        2    -1        0  unknown 0     upper
## 437    jan      134        1    91        1  success 1     upper
## 438    feb     1423        3    -1        0  unknown 0     upper
## 439    aug      298        2   300        1    other 0   primary
## 440    aug      139        4    -1        0  unknown 0   primary
## 441    jun      368        1    -1        0  unknown 0     upper
## 442    may      546        2    -1        0  unknown 0     upper
## 443    sep      103        1    91        2  failure 0     upper
## 444    may     1259        2   333       18  failure 0     upper
## 445    jun      267       11    -1        0  unknown 0   primary
## 446    may      156        3    -1        0  unknown 0     upper
## 447    jul       46        3    -1        0  unknown 0     upper
## 448    may       38        3    -1        0  unknown 0     upper
## 449    may      368        2    -1        0  unknown 0     upper
## 450    jun      201        3    -1        0  unknown 0     upper
## 451    aug      205        4    -1        0  unknown 0     upper
## 452    aug      140       11    -1        0  unknown 0     upper
## 453    feb      170        2    -1        0  unknown 0     upper
## 454    may      198        2    -1        0  unknown 0     upper
## 455    aug      143        4    -1        0  unknown 0     upper
## 456    may     1434        2   356        4  failure 0     upper
## 457    may      472        1    -1        0  unknown 0   primary
## 458    jul       18        2    -1        0  unknown 0     upper
## 459    may      158        3   354        1  failure 0     upper
## 460    nov      366        6    -1        0  unknown 0     upper
## 461    jul       70        9    -1        0  unknown 0   primary
## 462    apr      142        3   150        3  failure 0     upper
## 463    may       64        2   364        3  failure 0   unknown
## 464    nov      296        1    -1        0  unknown 0     upper
## 465    aug      112        2    -1        0  unknown 0     upper
## 466    nov      182        2    -1        0  unknown 0     upper
## 467    feb      136        3    -1        0  unknown 1   primary
## 468    nov       80        1    -1        0  unknown 0     upper
## 469    jul     1013       29    -1        0  unknown 1     upper
## 470    may      448        4    -1        0  unknown 0     upper
## 471    aug      146        3    -1        0  unknown 0     upper
## 472    jul      174        1    -1        0  unknown 0   primary
## 473    jul       29        4    -1        0  unknown 0   primary
## 474    may      202        2    -1        0  unknown 0     upper
## 475    aug      189        4    -1        0  unknown 0     upper
## 476    jul      144        2    -1        0  unknown 0     upper
## 477    may      112        1    -1        0  unknown 0     upper
## 478    jul       94        2    -1        0  unknown 0   primary
## 479    may       58        5    -1        0  unknown 0     upper
## 480    may      911        2    -1        0  unknown 1     upper
## 481    aug      308        1   459        1  success 1   primary
## 482    may      331        5    -1        0  unknown 1     upper
## 483    jun      249        5    -1        0  unknown 0   primary
## 484    jul      171        2    -1        0  unknown 0     upper
## 485    may      123        5    -1        0  unknown 0     upper
## 486    feb      251        1   186        3  success 1     upper
## 487    apr      706        2    -1        0  unknown 0     upper
## 488    oct      110        1   106        2  failure 0     upper
## 489    jun       90        4    -1        0  unknown 0     upper
## 490    aug      204        4    -1        0  unknown 0     upper
## 491    oct      157        1    -1        0  unknown 0     upper
## 492    feb      415        1    -1        0  unknown 1     upper
## 493    mar      558        1    -1        0  unknown 0     upper
## 494    apr       18        5   335        9    other 0     upper
## 495    jun      342        1    -1        0  unknown 0   primary
## 496    jul      159        2    -1        0  unknown 0     upper
## 497    apr      518        2   261        2  failure 0     upper
## 498    apr       59        1    -1        0  unknown 0     upper
## 499    may      159        2   278        4  failure 0     upper
## 500    jul       82        2    -1        0  unknown 0     upper
## 501    may      169        2    -1        0  unknown 0     upper
## 502    may        9       10   330       10    other 0     upper
## 503    may      155        2    -1        0  unknown 0     upper
## 504    apr      517        1   255        1  failure 0     upper
## 505    jun      110        1    -1        0  unknown 0   primary
## 506    may      189        3   348        3  failure 0     upper
## 507    aug      441        2    -1        0  unknown 0   primary
## 508    aug       95        4    -1        0  unknown 0     upper
## 509    may      158        2    -1        0  unknown 0     upper
## 510    jan       82        2    -1        0  unknown 0   primary
## 511    may      141        1   343        3  failure 0     upper
## 512    jun      813        4    -1        0  unknown 1     upper
## 513    may      255        1    -1        0  unknown 0     upper
## 514    jun       10       19    -1        0  unknown 0     upper
## 515    apr      306        2    -1        0  unknown 1     upper
## 516    may      322        5    -1        0  unknown 0   primary
## 517    may       26        1    -1        0  unknown 0     upper
## 518    may      944        3    -1        0  unknown 0     upper
## 519    jun      270        2   377        3  success 0     upper
## 520    jan      168        2   205        1  failure 0   primary
## 521    aug       90        4    -1        0  unknown 0   primary
## 522    may      191        1   342        2  failure 0     upper
## 523    oct       99        2   185        3  failure 0     upper
## 524    may       77        2    -1        0  unknown 0     upper
## 525    aug      117        2    -1        0  unknown 0     upper
## 526    may       52        9    -1        0  unknown 0     upper
## 527    nov      119        1   157        2  failure 0     upper
## 528    apr      166        5   181        5  failure 0   primary
## 529    aug      338        2   104        1  success 1     upper
## 530    may      109        2    -1        0  unknown 0     upper
## 531    aug      296        3    -1        0  unknown 0     upper
## 532    may      348        3    -1        0  unknown 0   primary
## 533    may      133        2   363        5  failure 0   primary
## 534    may      170        2    -1        0  unknown 0     upper
## 535    jul      189        3    -1        0  unknown 0     upper
## 536    jan      130        1     2        1    other 0     upper
## 537    feb      254        2    -1        0  unknown 0     upper
## 538    nov      681        4    -1        0  unknown 1     upper
## 539    aug     1099        4    -1        0  unknown 0     upper
## 540    aug      220        3    -1        0  unknown 0     upper
## 541    nov      271        5    -1        0  unknown 0     upper
## 542    may       86        1    -1        0  unknown 1   unknown
## 543    aug       49        2    -1        0  unknown 0     upper
## 544    nov      808        2    -1        0  unknown 1     upper
## 545    jul     1039        2    -1        0  unknown 1     upper
## 546    aug       59        3    -1        0  unknown 0     upper
## 547    jul      209        2    -1        0  unknown 0     upper
## 548    may      208        1    -1        0  unknown 0   primary
## 549    may       98        1    -1        0  unknown 0     upper
## 550    jul      123        1    -1        0  unknown 0     upper
## 551    nov       14        7    -1        0  unknown 0     upper
## 552    may      492        6    -1        0  unknown 0     upper
## 553    may      118        1    -1        0  unknown 0     upper
## 554    nov      235        2    -1        0  unknown 0     upper
## 555    jun      643        1    -1        0  unknown 0   primary
## 556    jul      250        2   181        4  success 1     upper
## 557    may     1272        1    -1        0  unknown 1     upper
## 558    may      100        3    -1        0  unknown 0     upper
## 559    nov      462        3    -1        0  unknown 0     upper
## 560    jul       24        1    -1        0  unknown 0     upper
## 561    jan      931        1    -1        0  unknown 1     upper
## 562    apr      190        1   335        1    other 0     upper
## 563    aug      133        4    -1        0  unknown 0     upper
## 564    feb      227        2    -1        0  unknown 1     upper
## 565    nov      357        3    93        5  success 1     upper
## 566    jun      183        3    -1        0  unknown 0     upper
## 567    jul      281        1    -1        0  unknown 0     upper
## 568    jun      239        4    -1        0  unknown 1     upper
## 569    apr      152        1    -1        0  unknown 0     upper
## 570    nov     1268        2    -1        0  unknown 0     upper
## 571    nov       73        1    -1        0  unknown 0     upper
## 572    may      202        2    -1        0  unknown 0     upper
## 573    may      247        1    -1        0  unknown 0     upper
## 574    jul      418        3    -1        0  unknown 0     upper
## 575    may      373        4    -1        0  unknown 0     upper
## 576    jun       14        6    -1        0  unknown 0     upper
## 577    nov      108        1    -1        0  unknown 0     upper
## 578    jan      624        2    -1        0  unknown 0     upper
## 579    may      278        1    -1        0  unknown 0   primary
## 580    may      177        3   343        1    other 0     upper
## 581    jul      191        1    -1        0  unknown 0     upper
## 582    may      235        6    -1        0  unknown 0   primary
## 583    jun      637        6    -1        0  unknown 1     upper
## 584    apr      660        1   191        1  failure 1   primary
## 585    aug       57        1    -1        0  unknown 0     upper
## 586    may      307        2    -1        0  unknown 0     upper
## 587    jul      165        5    -1        0  unknown 0     upper
## 588    aug      140        9    -1        0  unknown 0     upper
## 589    may       11        1    -1        0  unknown 0   primary
## 590    may      228        2   297        1    other 0     upper
## 591    may      210        1    -1        0  unknown 0     upper
## 592    jul      321        4    -1        0  unknown 1     upper
## 593    may      423        1   349        1  failure 0     upper
## 594    may      210        3    -1        0  unknown 0   primary
## 595    oct      825        1   183        4  success 1     upper
## 596    may      224        4    -1        0  unknown 0     upper
## 597    feb       51        1    -1        0  unknown 0     upper
## 598    aug      121        2    -1        0  unknown 0     upper
## 599    jun      206        1    99        1  failure 0     upper
## 600    jun      142       11    -1        0  unknown 0     upper
## 601    jun       41        5    -1        0  unknown 0     upper
## 602    nov       53        1    31        1  failure 0     upper
## 603    may      120        1    -1        0  unknown 0     upper
## 604    jul      200        4    -1        0  unknown 0   primary
## 605    nov       84        2    -1        0  unknown 0     upper
## 606    jul      226        1    -1        0  unknown 0     upper
## 607    nov      112        1    -1        0  unknown 0     upper
## 608    may      274        2    -1        0  unknown 0     upper
## 609    aug      417        4    -1        0  unknown 0     upper
## 610    apr      266        2    -1        0  unknown 0     upper
## 611    feb      453        2   273        2  failure 0     upper
## 612    jul      203        2    -1        0  unknown 0     upper
## 613    may      140        5    -1        0  unknown 0     upper
## 614    feb      403        2    -1        0  unknown 0     upper
## 615    feb       99        1   102        6  success 1     upper
## 616    may      322        1    -1        0  unknown 0   primary
## 617    aug      259        1    35        1  failure 0     upper
## 618    may      290        2    -1        0  unknown 0   primary
## 619    jun      438        5    -1        0  unknown 0     upper
## 620    apr       93        4    -1        0  unknown 0     upper
## 621    feb       74        1    24        1  failure 0     upper
## 622    feb      363        2    -1        0  unknown 0     upper
## 623    aug       90        1    68        1  success 0     upper
## 624    aug       69        2    -1        0  unknown 0     upper
## 625    jul      236        4    -1        0  unknown 0   unknown
## 626    nov      182        2    -1        0  unknown 0     upper
## 627    nov       41        1    -1        0  unknown 0     upper
## 628    nov      631        1    -1        0  unknown 0     upper
## 629    may      103        5    -1        0  unknown 0     upper
## 630    may      579        2   295        1  success 1     upper
## 631    may      164        2    -1        0  unknown 0     upper
## 632    jul      189        3    -1        0  unknown 0     upper
## 633    feb      277        1    -1        0  unknown 0     upper
## 634    jul      136        5    -1        0  unknown 0     upper
## 635    may      329        1   168        2  success 0     upper
## 636    aug      419        3    -1        0  unknown 0     upper
## 637    jun      119        1    -1        0  unknown 0     upper
## 638    jun       36        7    -1        0  unknown 0   primary
## 639    jul      155        2    -1        0  unknown 0     upper
## 640    jul      139        1    -1        0  unknown 0     upper
## 641    jul      152        5    -1        0  unknown 0     upper
## 642    jun       12       14    -1        0  unknown 0     upper
## 643    may       88        2    -1        0  unknown 0     upper
## 644    nov      116        4   154        1  failure 0     upper
## 645    may      443        1    -1        0  unknown 0     upper
## 646    may      214        1   305        1    other 1     upper
## 647    feb      110        2    64        2  success 1     upper
## 648    jul      101        2    -1        0  unknown 0     upper
## 649    nov      177        2    -1        0  unknown 0     upper
## 650    jul      289        1    -1        0  unknown 0     upper
## 651    feb      362        2   169        2  failure 0     upper
## 652    may      738        7    -1        0  unknown 0     upper
## 653    may      128        2    -1        0  unknown 0     upper
## 654    jan       76        1    -1        0  unknown 0     upper
## 655    aug      175        2    -1        0  unknown 0     upper
## 656    aug      206        2    -1        0  unknown 0     upper
## 657    may      205        8    -1        0  unknown 0     upper
## 658    may      152        3    -1        0  unknown 0     upper
## 659    aug      542        1    78        5  failure 0     upper
## 660    may       85        3    -1        0  unknown 0   unknown
## 661    may      172        1    -1        0  unknown 0     upper
## 662    apr      149        1    84        7  success 0     upper
## 663    jul      151        1    -1        0  unknown 0     upper
## 664    nov      233        1    -1        0  unknown 0     upper
## 665    apr      396        3    -1        0  unknown 1     upper
## 666    may       49        1    -1        0  unknown 0     upper
## 667    may      201        1    -1        0  unknown 0     upper
## 668    jun      285        4    -1        0  unknown 0     upper
## 669    aug      125        1    -1        0  unknown 0     upper
## 670    may      206        1    -1        0  unknown 0     upper
## 671    jul       36        4    -1        0  unknown 0     upper
## 672    nov      635        3   170        2  failure 0     upper
## 673    aug      314        4    -1        0  unknown 0     upper
## 674    apr      474        2    -1        0  unknown 0     upper
## 675    jun      277        1    -1        0  unknown 0     upper
## 676    jun       64        1    -1        0  unknown 0     upper
## 677    nov      376        1    -1        0  unknown 0     upper
## 678    feb      158        2    92        5  success 1     upper
## 679    aug      115        5    -1        0  unknown 0   primary
## 680    may      148        6   308        1  failure 0     upper
## 681    nov      114        1    -1        0  unknown 0   primary
## 682    jun       92        2    -1        0  unknown 0     upper
## 683    jan       62        1    -1        0  unknown 0     upper
## 684    aug      314        4    -1        0  unknown 0     upper
## 685    may      104        3    -1        0  unknown 0     upper
## 686    may      186        1    -1        0  unknown 0     upper
## 687    mar      273        2   182        1  success 1   unknown
## 688    aug      102        7    -1        0  unknown 0     upper
## 689    may      246        2   370        2  success 0     upper
## 690    aug      138        2    -1        0  unknown 0     upper
## 691    jun       64        1    -1        0  unknown 0     upper
## 692    jul      546        2   784        3  failure 1     upper
## 693    aug     1503        2    -1        0  unknown 1     upper
## 694    aug      220        1    -1        0  unknown 0     upper
## 695    aug      585        4    -1        0  unknown 0     upper
## 696    may      270        1    -1        0  unknown 0     upper
## 697    jul      295        1    -1        0  unknown 0   primary
## 698    feb       48        5    -1        0  unknown 0     upper
## 699    jun      186        1    -1        0  unknown 0     upper
## 700    apr      246        2   334        3    other 0     upper
## 701    may      247        1    -1        0  unknown 0     upper
## 702    jul      136        1    -1        0  unknown 0     upper
## 703    aug      149       14    -1        0  unknown 0     upper
## 704    may       70        1    -1        0  unknown 0     upper
## 705    may       84        5    -1        0  unknown 0     upper
## 706    jul      251        3    -1        0  unknown 0     upper
## 707    jul       57        2    -1        0  unknown 0     upper
## 708    jul      219        2    -1        0  unknown 0     upper
## 709    may      164        1    -1        0  unknown 0     upper
## 710    jun      126        1    -1        0  unknown 0   unknown
## 711    jul       74        5    -1        0  unknown 0     upper
## 712    may      266        2   168        1  failure 0     upper
## 713    jul      194        2    -1        0  unknown 0     upper
## 714    may       81        4    -1        0  unknown 0   primary
## 715    feb       56        1   274        2  failure 0     upper
## 716    feb      138        2    -1        0  unknown 0     upper
## 717    jun       61        3    -1        0  unknown 0     upper
## 718    jun      160        3    -1        0  unknown 0     upper
## 719    may        8        7    -1        0  unknown 0     upper
## 720    may      128        2    -1        0  unknown 0     upper
## 721    feb      232        1   211        1  failure 0     upper
## 722    jun      264        1    -1        0  unknown 0   primary
## 723    nov      356        1    -1        0  unknown 0     upper
## 724    nov      271        1   184        1  failure 0     upper
## 725    apr        6        6   328        8  failure 0     upper
## 726    may       74        7    -1        0  unknown 0   unknown
## 727    oct      424        1   515        1  failure 1     upper
## 728    aug      312        3    -1        0  unknown 0     upper
## 729    may       87        5    -1        0  unknown 0     upper
## 730    may      204        2    -1        0  unknown 0     upper
## 731    may      408        2    -1        0  unknown 0     upper
## 732    jul      413        1   181        3  success 1   primary
## 733    jun      124        1   105        1  failure 0     upper
## 734    may      797        2    -1        0  unknown 0   primary
## 735    may      180        1    -1        0  unknown 0   primary
## 736    jun     2028        1    -1        0  unknown 1     upper
## 737    apr      203        1    -1        0  unknown 0     upper
## 738    feb      162        2   184        1  failure 0     upper
## 739    apr      856        3    -1        0  unknown 0     upper
## 740    aug      135        6    -1        0  unknown 0     upper
## 741    may       38        3    -1        0  unknown 0   primary
## 742    aug      256        4    -1        0  unknown 0     upper
## 743    aug       59        6    -1        0  unknown 0     upper
## 744    aug      304        6    -1        0  unknown 0     upper
## 745    aug      128        2    -1        0  unknown 0     upper
## 746    jun      474        3    95        3    other 1     upper
## 747    may       59        3    -1        0  unknown 0     upper
## 748    jan      510        2    -1        0  unknown 0     upper
## 749    may       52        8    -1        0  unknown 0     upper
## 750    may      389        1    -1        0  unknown 0   primary
## 751    aug      232        4    -1        0  unknown 0     upper
## 752    apr      233        3    -1        0  unknown 0     upper
## 753    nov      298        2    82        4    other 0     upper
## 754    nov      287        3   117        2    other 0     upper
## 755    may       58        1    -1        0  unknown 0     upper
## 756    jul     1426        3    -1        0  unknown 1     upper
## 757    sep      285        3    81        3  failure 1     upper
## 758    feb       10        5    -1        0  unknown 0     upper
## 759    jun      243        1    -1        0  unknown 0     upper
## 760    jan      180        1    -1        0  unknown 0     upper
## 761    may       93        2    -1        0  unknown 0     upper
## 762    aug      229        4    -1        0  unknown 0     upper
## 763    apr      313        3    -1        0  unknown 1     upper
## 764    jul      140        3    -1        0  unknown 0     upper
## 765    may       95        4    -1        0  unknown 0     upper
## 766    aug      132        1    -1        0  unknown 0     upper
## 767    may      210        3    -1        0  unknown 0     upper
## 768    jun       99        5    -1        0  unknown 0   primary
## 769    jul      393        3    -1        0  unknown 0     upper
## 770    aug       31        9    -1        0  unknown 0   unknown
## 771    apr      239        2   259        2  failure 0     upper
## 772    jun      496        3    -1        0  unknown 0     upper
## 773    aug      454        4    -1        0  unknown 0   primary
## 774    apr      155        9    -1        0  unknown 0   unknown
## 775    may      183        3    -1        0  unknown 0     upper
## 776    may      318        1    -1        0  unknown 0     upper
## 777    may      316        1    -1        0  unknown 0     upper
## 778    apr      246        1   317        1  failure 0     upper
## 779    jul       90        1    -1        0  unknown 0     upper
## 780    jul       28        2    -1        0  unknown 0     upper
## 781    jul      185        1    -1        0  unknown 0   primary
## 782    aug      885        5    -1        0  unknown 0     upper
## 783    may      435        2    -1        0  unknown 0     upper
## 784    nov      140        1    -1        0  unknown 0     upper
## 785    mar      271        2    -1        0  unknown 1   primary
## 786    sep      120        3    -1        0  unknown 0     upper
## 787    may       80        2    -1        0  unknown 0     upper
## 788    feb      331        1    -1        0  unknown 0     upper
## 789    may      171        6    -1        0  unknown 0     upper
## 790    jun      276        1    -1        0  unknown 0     upper
## 791    jun      162        3    -1        0  unknown 0     upper
## 792    may       70        1    -1        0  unknown 0     upper
## 793    jun      592        4    -1        0  unknown 1     upper
## 794    may      165        1    56        3  failure 0     upper
## 795    jun      179        1    -1        0  unknown 0     upper
## 796    aug      232        2    -1        0  unknown 0     upper
## 797    may       78        1    -1        0  unknown 0     upper
## 798    aug      114        3    -1        0  unknown 0     upper
## 799    may      136        2    -1        0  unknown 0     upper
## 800    jul     1390        2    -1        0  unknown 0     upper
## 801    may      152        1    -1        0  unknown 0   primary
## 802    aug       74        2    -1        0  unknown 0     upper
## 803    jul      119        2    -1        0  unknown 0     upper
## 804    may      286        1   252        3  failure 0     upper
## 805    nov      226        1    94        4  success 1     upper
## 806    aug       54        3    -1        0  unknown 0   unknown
## 807    feb      122        1    92        5  success 1     upper
## 808    feb      105        1    -1        0  unknown 0     upper
## 809    jan      414        2   192        3  failure 0     upper
## 810    may      126        3    -1        0  unknown 0     upper
## 811    jul       91        1    -1        0  unknown 0     upper
## 812    jan       41        1   184        7  failure 0     upper
## 813    may      943        2    -1        0  unknown 1     upper
## 814    apr      332        2   335        1  failure 0     upper
## 815    may      501        4    -1        0  unknown 0     upper
## 816    jul      486        2    -1        0  unknown 0     upper
## 817    jun       69        3    -1        0  unknown 0     upper
## 818    jul      228        2    -1        0  unknown 0     upper
## 819    nov      199        1   275        3  success 0     upper
## 820    jun      141        1    -1        0  unknown 0     upper
## 821    may      117        1    -1        0  unknown 0     upper
## 822    aug      302        4    -1        0  unknown 0     upper
## 823    nov       83        1   102        2  failure 0     upper
## 824    may       57        5    -1        0  unknown 0     upper
## 825    jul      185        2    -1        0  unknown 0     upper
## 826    may      233        3    -1        0  unknown 0   primary
## 827    may      110        3    -1        0  unknown 0     upper
## 828    may      174        2    -1        0  unknown 0     upper
## 829    may      248        2    -1        0  unknown 0     upper
## 830    jul       38       18    -1        0  unknown 0     upper
## 831    may      306        1    -1        0  unknown 0     upper
## 832    jan      185        2    92        3  success 0     upper
## 833    nov      161        2    -1        0  unknown 0     upper
## 834    may      432        1    -1        0  unknown 0     upper
## 835    jun      790        3    -1        0  unknown 0     upper
## 836    may       86        3    -1        0  unknown 0     upper
## 837    jun      130        6    -1        0  unknown 0     upper
## 838    jun      330        1    -1        0  unknown 0     upper
## 839    jun       56        1    -1        0  unknown 0     upper
## 840    feb       11        6   231        9  failure 0   unknown
## 841    may      240        3   370        1  failure 0     upper
## 842    may      277        2   343        2  failure 0   primary
## 843    aug       59        6    -1        0  unknown 0     upper
## 844    may       82        4    -1        0  unknown 0     upper
## 845    may      742        4    -1        0  unknown 1   primary
## 846    may      305        2    -1        0  unknown 0     upper
## 847    nov      318        1    -1        0  unknown 0     upper
## 848    aug       81        2    -1        0  unknown 0     upper
## 849    may      748        3    -1        0  unknown 1     upper
## 850    may      308        1    -1        0  unknown 0   primary
## 851    nov      331        2    -1        0  unknown 1     upper
## 852    jan      491        1    -1        0  unknown 0   unknown
## 853    apr      144        2    -1        0  unknown 0     upper
## 854    jul      415        2   342        1    other 1     upper
## 855    may      930        1    -1        0  unknown 1     upper
## 856    may      120        2    -1        0  unknown 0     upper
## 857    may      133        1    97        1  success 1     upper
## 858    aug       83        5    -1        0  unknown 0   primary
## 859    mar      102        2   184        2  failure 0     upper
## 860    jan      207        2    -1        0  unknown 0     upper
## 861    may      285        1    -1        0  unknown 0     upper
## 862    aug       95        2    -1        0  unknown 0     upper
## 863    feb      124        2     9        2    other 0   primary
## 864    jun      447        2    96        1  success 1     upper
## 865    jun      256        2    -1        0  unknown 0     upper
## 866    aug      188        5    -1        0  unknown 0   primary
## 867    jun      479        1    -1        0  unknown 1     upper
## 868    jun      136        3    -1        0  unknown 0     upper
## 869    jul     1121        1    -1        0  unknown 1     upper
## 870    feb       73        1   252        1  failure 0     upper
## 871    may      144        4    -1        0  unknown 0     upper
## 872    jun      211        5    -1        0  unknown 0   primary
## 873    nov       51        1    -1        0  unknown 0     upper
## 874    feb      167        1   263        3    other 0     upper
## 875    jul       51        2    -1        0  unknown 0     upper
## 876    may      326        3   357       15    other 0   primary
## 877    may      101        1   362        5    other 0     upper
## 878    jul      174        1   199        3  failure 0     upper
## 879    apr      292        4   247        1    other 0   unknown
## 880    feb      171        2   193        2    other 0     upper
## 881    jul      312        1    -1        0  unknown 0     upper
## 882    nov       58        1   127        1  failure 0     upper
## 883    jun       35        6    -1        0  unknown 0     upper
## 884    jul      256        2   181        3  success 0   primary
## 885    aug       66        4    -1        0  unknown 0     upper
## 886    jun      192        1    93        7    other 1     upper
## 887    jul      255        2    -1        0  unknown 0     upper
## 888    jun      136        5    94       30  failure 0     upper
## 889    jun      351        6    -1        0  unknown 0     upper
## 890    jul      123        3    -1        0  unknown 0     upper
## 891    aug      121        2    -1        0  unknown 0     upper
## 892    may      161        2    -1        0  unknown 0     upper
## 893    may      229        2   294        1    other 0     upper
## 894    may      396        4    -1        0  unknown 0     upper
## 895    may       88        2    -1        0  unknown 0   primary
## 896    may      223        2    -1        0  unknown 0     upper
## 897    may       13        3    -1        0  unknown 0     upper
## 898    may      244        2    -1        0  unknown 0     upper
## 899    may      274        1    -1        0  unknown 0   primary
## 900    aug      144       18    -1        0  unknown 0     upper
## 901    may      125        5    -1        0  unknown 0     upper
## 902    may      347        2    -1        0  unknown 0     upper
## 903    jun      869        2    -1        0  unknown 0     upper
## 904    jun      174        3    -1        0  unknown 0     upper
## 905    jul      276        8    97       12    other 1   unknown
## 906    jan      339        2    -1        0  unknown 0     upper
## 907    jun       96        2    -1        0  unknown 0     upper
## 908    jul       61        6    -1        0  unknown 0   primary
## 909    jul      632       18    -1        0  unknown 0     upper
## 910    jun      109        2    -1        0  unknown 0   primary
## 911    feb      280        2    -1        0  unknown 0     upper
## 912    aug      339        2    -1        0  unknown 0     upper
## 913    aug      211        7    -1        0  unknown 0     upper
## 914    apr      165        2   327        3  failure 1   primary
## 915    jun      354       17    -1        0  unknown 0     upper
## 916    apr      122        4   238       12    other 0   primary
## 917    nov      110        1    -1        0  unknown 0     upper
## 918    may      918        1    -1        0  unknown 0     upper
## 919    may      145        1    -1        0  unknown 1     upper
## 920    nov      319        1   105        2    other 0     upper
## 921    feb       61        1    -1        0  unknown 0     upper
## 922    aug      633        1   182        2    other 1     upper
## 923    jul      345        5    -1        0  unknown 0     upper
## 924    apr      114        2   304        2  failure 0   primary
## 925    may      119        1    -1        0  unknown 0     upper
## 926    may     1062        1    -1        0  unknown 0     upper
## 927    may      687        2   343        1  failure 1     upper
## 928    aug      103        1   105        2  success 0     upper
## 929    jun      335        3    -1        0  unknown 0   unknown
## 930    oct      185        2    -1        0  unknown 0     upper
## 931    apr      341        1    -1        0  unknown 0     upper
## 932    nov      254        5    -1        0  unknown 1     upper
## 933    jun      180        1    -1        0  unknown 0     upper
## 934    apr      337        2    -1        0  unknown 0     upper
## 935    nov       99        1   151        2  failure 0     upper
## 936    jul      323        1    -1        0  unknown 0     upper
## 937    jul      222        1    -1        0  unknown 0   primary
## 938    nov      105        1   179        2  failure 0     upper
## 939    aug      117        4    -1        0  unknown 0     upper
## 940    apr      207        1   308        2  failure 0     upper
## 941    oct      323        1    -1        0  unknown 1     upper
## 942    jul      275        4    -1        0  unknown 0     upper
## 943    apr      309        2    -1        0  unknown 0     upper
## 944    may      225        1    -1        0  unknown 0     upper
## 945    jul      316        4    -1        0  unknown 1     upper
## 946    may      473        2    -1        0  unknown 0     upper
## 947    may      393        2    -1        0  unknown 0   primary
## 948    jul      227        8    -1        0  unknown 0     upper
## 949    may      609        1    -1        0  unknown 1     upper
## 950    may      189        1    -1        0  unknown 0   primary
## 951    may      323        1    -1        0  unknown 0     upper
## 952    nov      113        1    -1        0  unknown 0     upper
## 953    feb      432        1    -1        0  unknown 0     upper
## 954    apr       43        3    -1        0  unknown 0   primary
## 955    may      489        1    -1        0  unknown 0     upper
## 956    jul      362        2    -1        0  unknown 0     upper
## 957    apr      101        1    -1        0  unknown 0     upper
## 958    nov      179        1    -1        0  unknown 0     upper
## 959    may        8        4   300        5  failure 0   primary
## 960    feb      389        1    -1        0  unknown 0   unknown
## 961    jul       64        1    -1        0  unknown 0   primary
## 962    may      223        9     4        1  success 0     upper
## 963    feb      151        1    -1        0  unknown 0     upper
## 964    may      354        1    -1        0  unknown 0     upper
## 965    feb      253        1    -1        0  unknown 0     upper
## 966    nov       15        1    -1        0  unknown 0     upper
## 967    jun      459        3    -1        0  unknown 0   primary
## 968    jun      193        2    -1        0  unknown 0   primary
## 969    jul      345        1    -1        0  unknown 0     upper
## 970    jan      389        3    -1        0  unknown 0     upper
## 971    jan      305        2   261        2  failure 0   primary
## 972    apr       96        3   330        1    other 0     upper
## 973    jul      465        6    -1        0  unknown 0   primary
## 974    feb       39        1    -1        0  unknown 0     upper
## 975    apr      368        1   336        2  failure 0     upper
## 976    jul      112        1    -1        0  unknown 0     upper
## 977    apr       26        4   150        5  failure 0   primary
## 978    jul      163        2    -1        0  unknown 0     upper
## 979    may      132        1    -1        0  unknown 0     upper
## 980    jan       67        1    -1        0  unknown 0     upper
## 981    may      634        2    -1        0  unknown 0   primary
## 982    apr      174        2    -1        0  unknown 0     upper
## 983    may      157        4   367        1  failure 0     upper
## 984    may      421        3    -1        0  unknown 0     upper
## 985    may      104        3   371        2  failure 0     upper
## 986    jun      355        1    -1        0  unknown 0     upper
## 987    nov      401        1    -1        0  unknown 0     upper
## 988    jun      772        1    -1        0  unknown 0     upper
## 989    may      268        1    -1        0  unknown 0     upper
## 990    apr      532        1    -1        0  unknown 1     upper
## 991    aug      256        2    -1        0  unknown 0     upper
## 992    jul      605        6    -1        0  unknown 0     upper
## 993    aug       92        2    -1        0  unknown 0     upper
## 994    jun      298        3    -1        0  unknown 0     upper
## 995    nov      614        1    -1        0  unknown 1     upper
## 996    nov      113        1    -1        0  unknown 0     upper
## 997    may       45        1    -1        0  unknown 0   primary
## 998    jan      259        1   259        9  failure 0     upper
## 999    may       10        5    -1        0  unknown 0   primary
## 1000   may      218        1    -1        0  unknown 0     upper
## 1001   may        6        2    -1        0  unknown 0   primary
## 1002   nov      543        1    -1        0  unknown 1     upper
## 1003   feb      105        7   188        2  failure 0   primary
## 1004   nov      369        1   191        1  failure 0     upper
## 1005   jul      220        2    -1        0  unknown 0   primary
## 1006   apr      297        1    -1        0  unknown 0     upper
## 1007   jul      103        3    -1        0  unknown 0     upper
## 1008   jun       63        1    -1        0  unknown 0     upper
## 1009   jun      677        3    -1        0  unknown 1     upper
## 1010   may      133        2    -1        0  unknown 0     upper
## 1011   nov      433        1   113        1  failure 0     upper
## 1012   may       91        3   361        1  failure 0     upper
## 1013   nov      501        1    -1        0  unknown 0     upper
## 1014   aug      153        2    -1        0  unknown 0     upper
## 1015   jul      771        1    -1        0  unknown 0     upper
## 1016   may      233        1    -1        0  unknown 0   primary
## 1017   jun      979        9    -1        0  unknown 0     upper
## 1018   may      201        1   345        1    other 0     upper
## 1019   may      188        1    -1        0  unknown 0     upper
## 1020   aug      398        2    -1        0  unknown 0     upper
## 1021   apr      271        1   187        1  failure 0     upper
## 1022   aug      112        1    -1        0  unknown 0   unknown
## 1023   feb      450        3    -1        0  unknown 0     upper
## 1024   may      165        3    -1        0  unknown 0   unknown
## 1025   aug      152        2    -1        0  unknown 0     upper
## 1026   may      959        3   174        7    other 1     upper
## 1027   jul      262        1    -1        0  unknown 0     upper
## 1028   may      161        2    -1        0  unknown 0     upper
## 1029   may      253        2    -1        0  unknown 0     upper
## 1030   may      204        3    -1        0  unknown 0     upper
## 1031   may      242        1    -1        0  unknown 0     upper
## 1032   may      102        2    -1        0  unknown 0     upper
## 1033   may       60        5   371        2  failure 0     upper
## 1034   jun      263        8    -1        0  unknown 0   primary
## 1035   nov      169        1    -1        0  unknown 0     upper
## 1036   nov      214        3    -1        0  unknown 0     upper
## 1037   jan       81        1    -1        0  unknown 0     upper
## 1038   jul      110        3    -1        0  unknown 0   unknown
## 1039   aug      384        6    -1        0  unknown 0     upper
## 1040   aug      188        4    -1        0  unknown 0     upper
## 1041   may      282        2    -1        0  unknown 0     upper
## 1042   may      601        3    -1        0  unknown 1     upper
## 1043   may     1287        2    -1        0  unknown 0     upper
## 1044   may       33        5    -1        0  unknown 0     upper
## 1045   jul      455        1    -1        0  unknown 1     upper
## 1046   apr      241        2   317        1  failure 0     upper
## 1047   apr      158        2   329        1  failure 0     upper
## 1048   may       75        1    -1        0  unknown 0     upper
## 1049   jul       86        3    -1        0  unknown 0     upper
## 1050   jan      121        1   190        2  failure 0     upper
## 1051   jul      185        1    -1        0  unknown 0     upper
## 1052   may       90        1    -1        0  unknown 0   primary
## 1053   apr       61        3    -1        0  unknown 0   primary
## 1054   feb       48        7    -1        0  unknown 0   unknown
## 1055   jul      206        6    -1        0  unknown 0     upper
## 1056   may      670        4   346        1  failure 1     upper
## 1057   may      249        4   332        3  failure 0   unknown
## 1058   may      236        1    -1        0  unknown 0     upper
## 1059   apr      358        2    -1        0  unknown 0     upper
## 1060   nov      154        3   189        1  failure 0     upper
## 1061   may      125        2    -1        0  unknown 0     upper
## 1062   aug      117        2    -1        0  unknown 0     upper
## 1063   jul      337        1    -1        0  unknown 0     upper
## 1064   may      380        2   355        1  failure 0     upper
## 1065   jun      130        1    -1        0  unknown 0   primary
## 1066   jul      354        1    -1        0  unknown 0     upper
## 1067   aug       42        1    -1        0  unknown 0     upper
## 1068   may     1207        1    -1        0  unknown 1     upper
## 1069   may      240        2   343        5  failure 0   primary
## 1070   nov      295        2    -1        0  unknown 0     upper
## 1071   jun      416        3    -1        0  unknown 0     upper
## 1072   may      229        2   355        1  failure 0     upper
## 1073   may      208        1    -1        0  unknown 0     upper
## 1074   nov      193        1    -1        0  unknown 0     upper
## 1075   may      158        2    -1        0  unknown 0     upper
## 1076   jul       70        2    -1        0  unknown 0     upper
## 1077   jul      145        4    -1        0  unknown 0     upper
## 1078   may      309        2    -1        0  unknown 0   primary
## 1079   may      249        3    -1        0  unknown 0     upper
## 1080   jan      626        1    -1        0  unknown 0   primary
## 1081   feb      138        2   184        3  success 1     upper
## 1082   jul      602        1    -1        0  unknown 0     upper
## 1083   may      212        1    -1        0  unknown 0     upper
## 1084   feb      103        1   248        1  failure 0     upper
## 1085   may      217        5    -1        0  unknown 0     upper
## 1086   nov      179        1   197        1  failure 0     upper
## 1087   nov      615        3    34        1  failure 1   primary
## 1088   jun      230        3    -1        0  unknown 0     upper
## 1089   nov      111        2   156        1  failure 0   primary
## 1090   may       16        5    -1        0  unknown 0     upper
## 1091   mar      171        4    -1        0  unknown 0     upper
## 1092   feb      185        1    92        1  success 1     upper
## 1093   nov      162        1   175        2  failure 0     upper
## 1094   jul       98        1    -1        0  unknown 0     upper
## 1095   may      223        1    -1        0  unknown 0     upper
## 1096   may      677        1    -1        0  unknown 0   unknown
## 1097   aug      109        2    -1        0  unknown 0     upper
## 1098   may      267        2    -1        0  unknown 0     upper
## 1099   nov      123        1   196        1  success 1     upper
## 1100   jun      712        1    64       12  failure 1     upper
## 1101   mar      229        1    -1        0  unknown 1     upper
## 1102   may      267        1    -1        0  unknown 0     upper
## 1103   may       86        2    -1        0  unknown 0     upper
## 1104   may       98        4    -1        0  unknown 0   primary
## 1105   may      287        3    -1        0  unknown 0   primary
## 1106   jul      132       10    -1        0  unknown 0   primary
## 1107   jun      647        2    -1        0  unknown 0     upper
## 1108   nov       49        1    -1        0  unknown 0     upper
## 1109   feb      406        2    -1        0  unknown 0     upper
## 1110   oct      290        2    -1        0  unknown 1   primary
## 1111   aug      223        7    -1        0  unknown 0     upper
## 1112   jul       70        1    -1        0  unknown 0     upper
## 1113   may      311        5    -1        0  unknown 0   primary
## 1114   jun       57        8    -1        0  unknown 0     upper
## 1115   nov        7        5    -1        0  unknown 0     upper
## 1116   jun      207        1    -1        0  unknown 0     upper
## 1117   jul       93        2    -1        0  unknown 0     upper
## 1118   may      806        4    -1        0  unknown 0     upper
## 1119   jul      214        1    -1        0  unknown 0   primary
## 1120   may      135        1    -1        0  unknown 0     upper
## 1121   jan      119        1    -1        0  unknown 0     upper
## 1122   apr      387        3    87        1  success 1     upper
## 1123   jul      733        3    -1        0  unknown 1     upper
## 1124   aug       91        4    -1        0  unknown 0     upper
## 1125   aug      138        2    -1        0  unknown 0   primary
## 1126   jun      392        1    -1        0  unknown 0     upper
## 1127   aug      773        4    -1        0  unknown 1     upper
## 1128   jul       75        3    -1        0  unknown 0     upper
## 1129   jun       92        2    -1        0  unknown 0     upper
## 1130   jan       84        3   183        3  failure 0     upper
## 1131   feb        8        7   248        9  success 0     upper
## 1132   jul      225        1    -1        0  unknown 0   primary
## 1133   jan      399        1    -1        0  unknown 0   primary
## 1134   jun      288        2    -1        0  unknown 0     upper
## 1135   jul      366        1    -1        0  unknown 0   unknown
## 1136   jul      131        4    -1        0  unknown 0     upper
## 1137   jul      157        1    -1        0  unknown 0     upper
## 1138   nov      141        2    -1        0  unknown 0     upper
## 1139   jun      122        1    -1        0  unknown 0     upper
## 1140   apr      592        4   316        3  failure 1     upper
## 1141   jun      132        1    -1        0  unknown 0     upper
## 1142   may      155        1    -1        0  unknown 0     upper
## 1143   may      165        4    -1        0  unknown 0   primary
## 1144   may      147        1    -1        0  unknown 0     upper
## 1145   apr       91        2   275        1  failure 0     upper
## 1146   jun      112        2    -1        0  unknown 0     upper
## 1147   apr      598        1   150        1  failure 0     upper
## 1148   jul      178        3    -1        0  unknown 0     upper
## 1149   jul      230        2    -1        0  unknown 0     upper
## 1150   jul      125        2    -1        0  unknown 0   primary
## 1151   may      109        2    -1        0  unknown 0     upper
## 1152   jul      122        7    -1        0  unknown 0     upper
## 1153   may      128        6    -1        0  unknown 0     upper
## 1154   jul       83        2    -1        0  unknown 0     upper
## 1155   nov      173        1    -1        0  unknown 0     upper
## 1156   nov       58        1   188        1  failure 0     upper
## 1157   apr       20        2   335       12  failure 0     upper
## 1158   aug      135       22    -1        0  unknown 0     upper
## 1159   jun      144        1    -1        0  unknown 0     upper
## 1160   may      225        1    -1        0  unknown 0     upper
## 1161   aug      256        2    -1        0  unknown 0     upper
## 1162   may       28        2   345        3    other 0     upper
## 1163   jul      124        3    -1        0  unknown 0   unknown
## 1164   jul      727        4    -1        0  unknown 1   primary
## 1165   jul      122        3    -1        0  unknown 0     upper
## 1166   may      237        1    -1        0  unknown 0     upper
## 1167   jul       60        1    -1        0  unknown 0     upper
## 1168   jul      183        1    -1        0  unknown 0     upper
## 1169   jun       77        1    -1        0  unknown 0     upper
## 1170   apr     1090        1    -1        0  unknown 0     upper
## 1171   nov      282        1    -1        0  unknown 0   primary
## 1172   may      199        1   173        2  failure 0     upper
## 1173   jul      593        2    -1        0  unknown 0     upper
## 1174   jul      126       23    -1        0  unknown 0     upper
## 1175   aug      251        3    -1        0  unknown 0     upper
## 1176   jul      123        4    -1        0  unknown 0     upper
## 1177   feb       98        2    -1        0  unknown 0   primary
## 1178   jun      497        2    -1        0  unknown 0   unknown
## 1179   jul      830        5    -1        0  unknown 1     upper
## 1180   may      485        1    -1        0  unknown 0     upper
## 1181   aug      637        2    -1        0  unknown 1     upper
## 1182   feb      170        2    -1        0  unknown 1     upper
## 1183   jan      122        4    50        4    other 0     upper
## 1184   jun      561        1    -1        0  unknown 0   unknown
## 1185   may      114        2    -1        0  unknown 0   primary
## 1186   jun       34       29    -1        0  unknown 0   primary
## 1187   aug       15       19    -1        0  unknown 0     upper
## 1188   jul      154       14    -1        0  unknown 0   unknown
## 1189   jul       98       13    -1        0  unknown 0     upper
## 1190   jul      212        4    -1        0  unknown 0   unknown
## 1191   may      692        1    -1        0  unknown 0     upper
## 1192   jul      301        2    88        5  failure 0     upper
## 1193   may      412        2    -1        0  unknown 0     upper
## 1194   may      877        7   300        2    other 1     upper
## 1195   mar      236        2    -1        0  unknown 0     upper
## 1196   may      354        1    -1        0  unknown 1     upper
## 1197   jan       79        2   265        2  failure 0     upper
## 1198   apr      329        2    -1        0  unknown 0     upper
## 1199   jul      245        1    -1        0  unknown 0     upper
## 1200   may      504        2    -1        0  unknown 0     upper
## 1201   may      437        3   347        3    other 1     upper
## 1202   apr      144        1    -1        0  unknown 1     upper
## 1203   jul      264        2    -1        0  unknown 0     upper
## 1204   may      178        2    -1        0  unknown 0   primary
## 1205   may      173        1    -1        0  unknown 0     upper
## 1206   jan      258        5   248        2  failure 0   unknown
## 1207   feb      666        4    -1        0  unknown 1     upper
## 1208   dec      283        2   196        1  success 1     upper
## 1209   feb      372        1    -1        0  unknown 1     upper
## 1210   apr       46        4    -1        0  unknown 0     upper
## 1211   may       77        3    -1        0  unknown 0     upper
## 1212   jan     1424        1    -1        0  unknown 0     upper
## 1213   jul      152        1    -1        0  unknown 0     upper
## 1214   jul      427        1    -1        0  unknown 0     upper
## 1215   apr      171        2    -1        0  unknown 0     upper
## 1216   apr     1196        1    -1        0  unknown 1     upper
## 1217   may      211        1    -1        0  unknown 0     upper
## 1218   may      154        3   367        2  failure 0     upper
## 1219   may      198        2    -1        0  unknown 0     upper
## 1220   may      225        1    -1        0  unknown 0     upper
## 1221   may      145        2    -1        0  unknown 0     upper
## 1222   may      165        2    -1        0  unknown 0     upper
## 1223   nov      596        1   182        1    other 1     upper
## 1224   aug      150        2    -1        0  unknown 0     upper
## 1225   jun      110        1    -1        0  unknown 0   primary
## 1226   apr      146        1   281        1  failure 0     upper
## 1227   apr      271        1   300        2  success 0   primary
## 1228   nov      289        1    -1        0  unknown 0     upper
## 1229   feb      142        2    -1        0  unknown 0     upper
## 1230   nov      103        1   141        2  failure 0     upper
## 1231   may      186        5    -1        0  unknown 0   primary
## 1232   jan     1121        2   205        3  failure 0     upper
## 1233   aug      121        1    -1        0  unknown 0     upper
## 1234   may      325        1    -1        0  unknown 0     upper
## 1235   aug      331        2    -1        0  unknown 0     upper
## 1236   jun      115        4    -1        0  unknown 0     upper
## 1237   may      144        1    -1        0  unknown 0   unknown
## 1238   aug      203        4    -1        0  unknown 0     upper
## 1239   jun      213        1    -1        0  unknown 0   primary
## 1240   nov       61        2   131        1  failure 0     upper
## 1241   apr      707        1   149        2  failure 0     upper
## 1242   may       41        8    -1        0  unknown 0   primary
## 1243   jul       67       11    -1        0  unknown 0     upper
## 1244   may      180        2    -1        0  unknown 0     upper
## 1245   may      103        2    -1        0  unknown 0   primary
## 1246   sep      260        3    95        3  success 1     upper
## 1247   aug      335        3    -1        0  unknown 0     upper
## 1248   apr      460        2   345        2  failure 0     upper
## 1249   aug      291        1    -1        0  unknown 0     upper
## 1250   jan      126        1    -1        0  unknown 0   unknown
## 1251   aug      360        1    -1        0  unknown 0     upper
## 1252   apr      370        3    -1        0  unknown 1     upper
## 1253   aug      351        2    -1        0  unknown 0     upper
## 1254   jul       70        1    -1        0  unknown 0     upper
## 1255   mar      180        2    -1        0  unknown 1     upper
## 1256   mar       96        6    -1        0  unknown 0     upper
## 1257   may      611        2    -1        0  unknown 0     upper
## 1258   aug       19       16    -1        0  unknown 0   unknown
## 1259   jun      482        2    -1        0  unknown 1   primary
## 1260   may      295        2    -1        0  unknown 0     upper
## 1261   jul      124        1    -1        0  unknown 0     upper
## 1262   may       70        3    -1        0  unknown 0   primary
## 1263   apr      571        1    -1        0  unknown 1     upper
## 1264   may      143        2   370        2  failure 0   primary
## 1265   may       66        1    -1        0  unknown 0     upper
## 1266   nov       89        2    -1        0  unknown 0     upper
## 1267   apr     1007        3   325        4  failure 0   primary
## 1268   aug      173        1    92        5  success 1     upper
## 1269   jul     2201        1    -1        0  unknown 0     upper
## 1270   jul      285        1    -1        0  unknown 0     upper
## 1271   feb      751        2    76        4  failure 1     upper
## 1272   may      543        1    -1        0  unknown 1     upper
## 1273   aug      147        1   379        1  failure 0     upper
## 1274   apr      346        2    -1        0  unknown 0     upper
## 1275   nov      661        4    -1        0  unknown 0     upper
## 1276   jul      268        2    -1        0  unknown 0     upper
## 1277   jul       61        4    -1        0  unknown 0     upper
## 1278   nov      258        2    -1        0  unknown 0     upper
## 1279   may       45       13    -1        0  unknown 0     upper
## 1280   jul       53        1    -1        0  unknown 0     upper
## 1281   feb      226        1    -1        0  unknown 0     upper
## 1282   jun       42        7    -1        0  unknown 0     upper
## 1283   jul      812        1    -1        0  unknown 1     upper
## 1284   may      262        3    -1        0  unknown 0     upper
## 1285   aug      579        2    -1        0  unknown 1     upper
## 1286   jan      801        1    -1        0  unknown 1   primary
## 1287   may      493        2    -1        0  unknown 0     upper
## 1288   aug      271        4    -1        0  unknown 0     upper
## 1289   jul      427        2    94        4  failure 0     upper
## 1290   apr      163        3    -1        0  unknown 0     upper
## 1291   may      141        1    -1        0  unknown 0     upper
## 1292   may      160        1    -1        0  unknown 0     upper
## 1293   may       55        2    -1        0  unknown 0   unknown
## 1294   may       66        9    -1        0  unknown 0     upper
## 1295   may      108        3    -1        0  unknown 0   primary
## 1296   sep      106        1    -1        0  unknown 0   unknown
## 1297   aug       68       27    -1        0  unknown 0     upper
## 1298   may      210        3    -1        0  unknown 0     upper
## 1299   may       20        6    -1        0  unknown 0     upper
## 1300   may      104        4   252        3  failure 0     upper
## 1301   may      227        1    -1        0  unknown 0     upper
## 1302   may      201        1    -1        0  unknown 0     upper
## 1303   aug      610        2    -1        0  unknown 0     upper
## 1304   apr      381        1   269        1  failure 1     upper
## 1305   may      184        1    -1        0  unknown 0     upper
## 1306   may      369        1    -1        0  unknown 0     upper
## 1307   aug      111        5    -1        0  unknown 0     upper
## 1308   may      282        2    -1        0  unknown 0     upper
## 1309   aug      603        3    -1        0  unknown 1     upper
## 1310   jun       21        1    -1        0  unknown 0     upper
## 1311   may       12        5    -1        0  unknown 0     upper
## 1312   jul     1106        1    -1        0  unknown 0     upper
## 1313   may       98        1   178        1  failure 0     upper
## 1314   aug      553        1    -1        0  unknown 1     upper
## 1315   may     1076        3   175        1  success 1     upper
## 1316   may      369        1    -1        0  unknown 0     upper
## 1317   jun      142        2    -1        0  unknown 0     upper
## 1318   apr      179        1    -1        0  unknown 0     upper
## 1319   jan       54        1    -1        0  unknown 0   primary
## 1320   jun      277        2    -1        0  unknown 0     upper
## 1321   aug      295        2    -1        0  unknown 0     upper
## 1322   may      294        1    -1        0  unknown 0     upper
## 1323   may      232        1    89        4    other 1   unknown
## 1324   nov      127        3    -1        0  unknown 0     upper
## 1325   may      185        1    -1        0  unknown 0     upper
## 1326   may      203        1    -1        0  unknown 0     upper
## 1327   nov      157        1    -1        0  unknown 0   primary
## 1328   jan      217        2    -1        0  unknown 0     upper
## 1329   jun      409        1    -1        0  unknown 0   unknown
## 1330   may      328        2    -1        0  unknown 0     upper
## 1331   apr      660        3    -1        0  unknown 0     upper
## 1332   may      157        5    -1        0  unknown 0     upper
## 1333   jan      403        2    -1        0  unknown 1     upper
## 1334   may      215        1    -1        0  unknown 0     upper
## 1335   may       68        2   363        2  failure 0   primary
## 1336   aug       93        1   190        2    other 0     upper
## 1337   jun       53        1    -1        0  unknown 0     upper
## 1338   jul      199        2    -1        0  unknown 0   primary
## 1339   nov      442        4    -1        0  unknown 0     upper
## 1340   aug      403        2    -1        0  unknown 0     upper
## 1341   may      116       12    -1        0  unknown 0     upper
## 1342   may      185        6    -1        0  unknown 0     upper
## 1343   jun       22       15    -1        0  unknown 0     upper
## 1344   may      452        2    -1        0  unknown 0     upper
## 1345   may      323        1    -1        0  unknown 0     upper
## 1346   may      752        2    -1        0  unknown 0     upper
## 1347   jul      118        3    -1        0  unknown 0     upper
## 1348   may       92        2    -1        0  unknown 0   unknown
## 1349   jan       27        1    -1        0  unknown 0     upper
## 1350   jun      169        2    -1        0  unknown 0     upper
## 1351   may      470        1    -1        0  unknown 0   unknown
## 1352   may      193        1    -1        0  unknown 0   primary
## 1353   jul      195        2    -1        0  unknown 0     upper
## 1354   apr      264        1   317        1  failure 0     upper
## 1355   feb      269        9    -1        0  unknown 0     upper
## 1356   jan      411        1    -1        0  unknown 1     upper
## 1357   aug      526        2    -1        0  unknown 1     upper
## 1358   aug       83        1    -1        0  unknown 0     upper
## 1359   may       17        8    -1        0  unknown 0     upper
## 1360   may      112        2    -1        0  unknown 0     upper
## 1361   feb       94        4   271        4  failure 0     upper
## 1362   jun      441        3    -1        0  unknown 0     upper
## 1363   feb       83        3    -1        0  unknown 0     upper
## 1364   may      102       23    -1        0  unknown 0   primary
## 1365   aug       62        3    -1        0  unknown 0   primary
## 1366   jul      141        2    -1        0  unknown 0     upper
## 1367   jul      241        2    -1        0  unknown 0   primary
## 1368   may      255        5    -1        0  unknown 0     upper
## 1369   jun        6        1    -1        0  unknown 0   primary
## 1370   may      226        1    -1        0  unknown 0     upper
## 1371   oct      147        1    92        5    other 1     upper
## 1372   jul      132        4    -1        0  unknown 0     upper
## 1373   may      379        2    -1        0  unknown 0     upper
## 1374   aug       73        2    -1        0  unknown 0     upper
## 1375   may      177        4   367        1  failure 0     upper
## 1376   may      213        5    -1        0  unknown 0   primary
## 1377   may      182        1    -1        0  unknown 0     upper
## 1378   apr      575        2    -1        0  unknown 0     upper
## 1379   jul      258        2    -1        0  unknown 0     upper
## 1380   aug      237        1   180        6  success 1     upper
## 1381   jul        9        1    -1        0  unknown 0     upper
## 1382   may       45        5    -1        0  unknown 0     upper
## 1383   jul      633        7    -1        0  unknown 0     upper
## 1384   jun      301        6    -1        0  unknown 0     upper
## 1385   jul      108        1    -1        0  unknown 0     upper
## 1386   jan      192        1    -1        0  unknown 0     upper
## 1387   nov      250        2    -1        0  unknown 0     upper
## 1388   apr      344        1    74        2  failure 1     upper
## 1389   may      221        2   350        4    other 0     upper
## 1390   jun       48        2    -1        0  unknown 0     upper
## 1391   aug      124        3    -1        0  unknown 0     upper
## 1392   may      237        1   368        1    other 0     upper
## 1393   feb      108        2   195        6  failure 0     upper
## 1394   feb      604        1    -1        0  unknown 0     upper
## 1395   aug       34       14    -1        0  unknown 0     upper
## 1396   nov     1091        2   150        1  success 1     upper
## 1397   may      200        5    -1        0  unknown 0     upper
## 1398   may      159        1    -1        0  unknown 0     upper
## 1399   apr      193        2   322        1    other 0   primary
## 1400   may       36        7   165        5    other 0     upper
## 1401   jun       48        3    -1        0  unknown 0     upper
## 1402   may      350        5   286        2  failure 0     upper
## 1403   aug       77        9    -1        0  unknown 0     upper
## 1404   jan       58        1    -1        0  unknown 0     upper
## 1405   may      282        2    -1        0  unknown 0     upper
## 1406   nov      329        1    -1        0  unknown 0     upper
## 1407   feb      281        2   270        2    other 0     upper
## 1408   aug       63        6    -1        0  unknown 0     upper
## 1409   jun      168        2    -1        0  unknown 0     upper
## 1410   may      395        1    -1        0  unknown 0     upper
## 1411   jun      193        2    -1        0  unknown 0     upper
## 1412   feb       62        1    -1        0  unknown 0     upper
## 1413   nov      744        2    -1        0  unknown 0     upper
## 1414   aug      104        6    -1        0  unknown 0     upper
## 1415   jul      249        3    -1        0  unknown 0     upper
## 1416   nov      123        1   124        1  failure 0     upper
## 1417   may       44        1   355        3  failure 0     upper
## 1418   jun      188        1    -1        0  unknown 0     upper
## 1419   sep      104        1   380        3  failure 0     upper
## 1420   may      173        4    -1        0  unknown 0     upper
## 1421   apr       96        2   344        2  failure 0     upper
## 1422   aug      256        2    -1        0  unknown 0     upper
## 1423   may      170        1    -1        0  unknown 0     upper
## 1424   may      245        4    -1        0  unknown 0     upper
## 1425   may      245        1    -1        0  unknown 0     upper
## 1426   jul      277        1    -1        0  unknown 0     upper
## 1427   may      198        1    -1        0  unknown 0   primary
## 1428   may      290        2    -1        0  unknown 0     upper
## 1429   may      154        2    -1        0  unknown 0   primary
## 1430   jul      149        1    -1        0  unknown 0   primary
## 1431   jul      323        2   163        2    other 1     upper
## 1432   may       63        5    -1        0  unknown 0   primary
## 1433   may      162        2   350        4  failure 0     upper
## 1434   aug      231        1    -1        0  unknown 0     upper
## 1435   jan      456        1   205        2    other 0     upper
## 1436   may      212        2    -1        0  unknown 0     upper
## 1437   nov      426        2    -1        0  unknown 0     upper
## 1438   apr      444        2    -1        0  unknown 0     upper
## 1439   nov      240        3   119        2  failure 0     upper
## 1440   sep      770        3    -1        0  unknown 1   unknown
## 1441   jun       93        2    -1        0  unknown 0     upper
## 1442   aug      154        2    -1        0  unknown 0     upper
## 1443   jul       60        2    -1        0  unknown 0     upper
## 1444   jul      202        2    -1        0  unknown 0     upper
## 1445   may      204        1   331        3  success 0     upper
## 1446   jun      129        1    -1        0  unknown 0     upper
## 1447   apr      149        1   268        2    other 0     upper
## 1448   aug      122        5    -1        0  unknown 0     upper
## 1449   apr      201        1    -1        0  unknown 0     upper
## 1450   jan      309        1    -1        0  unknown 0     upper
## 1451   aug      146        1   286        2  failure 1     upper
## 1452   feb      217        1    -1        0  unknown 0     upper
## 1453   jul      412        1    -1        0  unknown 0     upper
## 1454   jul      395        6    -1        0  unknown 0     upper
## 1455   jun       71        1    -1        0  unknown 0     upper
## 1456   may      105        1    -1        0  unknown 0     upper
## 1457   may      189        2    -1        0  unknown 0     upper
## 1458   feb      128        2    -1        0  unknown 0     upper
## 1459   jul      321        2    -1        0  unknown 0     upper
## 1460   nov       36        1    -1        0  unknown 0     upper
## 1461   jul       58        2    -1        0  unknown 0     upper
## 1462   aug      121        4    -1        0  unknown 0     upper
## 1463   jul      287        2   181        1  success 1     upper
## 1464   jun      310        4    -1        0  unknown 0     upper
## 1465   jun      115        1    -1        0  unknown 0   unknown
## 1466   may       71        3    -1        0  unknown 0   primary
## 1467   aug      328        1    -1        0  unknown 0     upper
## 1468   sep        9        1    -1        0  unknown 0     upper
## 1469   nov       91        3    -1        0  unknown 0     upper
## 1470   jun       61       23    -1        0  unknown 0   primary
## 1471   jul      232        3    -1        0  unknown 0     upper
## 1472   jan       30        1    -1        0  unknown 0   primary
## 1473   jun        9       28    -1        0  unknown 0     upper
## 1474   apr      740        3    -1        0  unknown 1     upper
## 1475   may      105        1    -1        0  unknown 0     upper
## 1476   may     1730        1    -1        0  unknown 1     upper
## 1477   apr      462        1    -1        0  unknown 0   primary
## 1478   may      106        1    -1        0  unknown 0     upper
## 1479   sep      990        4    -1        0  unknown 0     upper
## 1480   may      213        4    -1        0  unknown 0     upper
## 1481   may      154        1    -1        0  unknown 0   primary
## 1482   jan       58        1    -1        0  unknown 0     upper
## 1483   jun      157        1    -1        0  unknown 0     upper
## 1484   may      166        3    -1        0  unknown 0     upper
## 1485   jun       16        8    -1        0  unknown 0     upper
## 1486   aug      140        1    -1        0  unknown 0     upper
## 1487   apr      280        2    -1        0  unknown 0     upper
## 1488   may      314        3    -1        0  unknown 0     upper
## 1489   jun      251        3    -1        0  unknown 0     upper
## 1490   jan      337        4    -1        0  unknown 0     upper
## 1491   jun        9        5    -1        0  unknown 0     upper
## 1492   nov      945        2    -1        0  unknown 1     upper
## 1493   may      120        1    -1        0  unknown 0     upper
## 1494   may      290        1    -1        0  unknown 0     upper
## 1495   may      137        1    -1        0  unknown 0   primary
## 1496   jun      159        1    -1        0  unknown 0   primary
## 1497   may       22        5    -1        0  unknown 0   primary
## 1498   aug       88       10    -1        0  unknown 0     upper
## 1499   jul      127       11    -1        0  unknown 0     upper
## 1500   feb      140        1    -1        0  unknown 0     upper
## 1501   may      475        2    -1        0  unknown 0     upper
## 1502   may      137        2    -1        0  unknown 0     upper
## 1503   aug       70        1    -1        0  unknown 0     upper
## 1504   jul      243        3    -1        0  unknown 0     upper
## 1505   may      206        1    -1        0  unknown 0     upper
## 1506   may      206        1    -1        0  unknown 0   primary
## 1507   apr      616        1    -1        0  unknown 1     upper
## 1508   may      456        2    -1        0  unknown 0     upper
## 1509   aug       74        1    -1        0  unknown 0     upper
## 1510   mar      282        2    -1        0  unknown 0     upper
## 1511   aug      472        6    -1        0  unknown 1   primary
## 1512   may      360        1    -1        0  unknown 0     upper
## 1513   may      440        1    -1        0  unknown 0     upper
## 1514   jul      236        3    -1        0  unknown 0     upper
## 1515   oct      167        1    -1        0  unknown 0     upper
## 1516   may      472        2   351        1  failure 0     upper
## 1517   apr      396        3   151        4    other 0     upper
## 1518   jul      400        1    -1        0  unknown 0     upper
## 1519   nov     1032       10   115        3  failure 0     upper
## 1520   aug      629        7    -1        0  unknown 0     upper
## 1521   jul      167        1    -1        0  unknown 0   primary
## 1522   oct       59        1   104        3  failure 0     upper
## 1523   jun      346        3    -1        0  unknown 0   unknown
## 1524   jul       93        1    -1        0  unknown 0     upper
## 1525   nov      215        2    -1        0  unknown 0     upper
## 1526   jul      158        5    -1        0  unknown 0     upper
## 1527   nov      217        3    -1        0  unknown 0   primary
## 1528   oct      255        4   185        2  failure 1   primary
## 1529   jul      301        1    -1        0  unknown 0     upper
## 1530   may      166        4    -1        0  unknown 0     upper
## 1531   may      525        1    -1        0  unknown 1   unknown
## 1532   may      297        1    -1        0  unknown 0     upper
## 1533   may      170        1    -1        0  unknown 0     upper
## 1534   feb      208        1    -1        0  unknown 0     upper
## 1535   nov     1122        4    -1        0  unknown 1   primary
## 1536   may       32        2    -1        0  unknown 0     upper
## 1537   may     1697        2    -1        0  unknown 1     upper
## 1538   aug      173        8    -1        0  unknown 0     upper
## 1539   jul      783        3    -1        0  unknown 0   primary
## 1540   jul       65        2    -1        0  unknown 0     upper
## 1541   nov      156        4    -1        0  unknown 0   primary
## 1542   may      203        1    -1        0  unknown 0     upper
## 1543   jul      184        6    -1        0  unknown 0     upper
## 1544   mar      220        3    -1        0  unknown 1     upper
## 1545   may       88        3    -1        0  unknown 0     upper
## 1546   may      349        3    -1        0  unknown 0     upper
## 1547   oct       76        2    -1        0  unknown 0   primary
## 1548   jul       73        1    -1        0  unknown 0   primary
## 1549   jun      119        2    -1        0  unknown 0     upper
## 1550   jun      139        1    -1        0  unknown 0     upper
## 1551   aug      389        4    -1        0  unknown 0     upper
## 1552   jun       96        6    -1        0  unknown 0   primary
## 1553   feb      190        2   280        8  failure 1     upper
## 1554   nov      197        4    30        1  failure 0     upper
## 1555   aug      240        2    -1        0  unknown 0   primary
## 1556   jun      165        2    -1        0  unknown 0     upper
## 1557   may      124        2    -1        0  unknown 0     upper
## 1558   may      631        1   344        1  success 0   primary
## 1559   feb      308        1   213        1    other 0   primary
## 1560   jan      287        5   285        5  success 1   primary
## 1561   may      260        5    -1        0  unknown 0     upper
## 1562   may      245        3    -1        0  unknown 0     upper
## 1563   may     1349        8    -1        0  unknown 1   primary
## 1564   jul       71        1    -1        0  unknown 0     upper
## 1565   aug       24       30    -1        0  unknown 0     upper
## 1566   nov       55        2    -1        0  unknown 0   unknown
## 1567   jul      506        1    -1        0  unknown 0     upper
## 1568   jun      295        1   287        4  success 1   primary
## 1569   may       51        1    -1        0  unknown 0   primary
## 1570   may      106        1    -1        0  unknown 0   primary
## 1571   jul       55        1    -1        0  unknown 0     upper
## 1572   may       54        2    -1        0  unknown 0   primary
## 1573   feb      138        2    92        2  success 1     upper
## 1574   jan      120        1    -1        0  unknown 0     upper
## 1575   jun       29        2    -1        0  unknown 0   primary
## 1576   may      230        2    -1        0  unknown 0     upper
## 1577   may      168        1    -1        0  unknown 0   unknown
## 1578   feb      578        1    -1        0  unknown 1   primary
## 1579   feb      182        2    -1        0  unknown 0     upper
## 1580   jul       73        3    -1        0  unknown 0     upper
## 1581   may      345        1    -1        0  unknown 0     upper
## 1582   apr      263        1    -1        0  unknown 0   unknown
## 1583   may      208        1    -1        0  unknown 0   primary
## 1584   feb      228        2    -1        0  unknown 0     upper
## 1585   may      640        1    -1        0  unknown 1     upper
## 1586   jul     1697        1    -1        0  unknown 0     upper
## 1587   may      265        7    -1        0  unknown 0   primary
## 1588   jan      410        2    -1        0  unknown 0     upper
## 1589   jul       83        4    -1        0  unknown 0   primary
## 1590   jun      404       13    -1        0  unknown 0   primary
## 1591   jun       69        2    -1        0  unknown 0     upper
## 1592   may      133        1    -1        0  unknown 0     upper
## 1593   jan      468        2    -1        0  unknown 0     upper
## 1594   jun       17        3    -1        0  unknown 0     upper
## 1595   may      174        1   359        2    other 0   primary
## 1596   may      435        1    -1        0  unknown 0     upper
## 1597   may      125        1   368        4  failure 0     upper
## 1598   may      215        2    -1        0  unknown 0   primary
## 1599   aug      195       10    -1        0  unknown 0     upper
## 1600   nov     1735        2    -1        0  unknown 0     upper
## 1601   jun       20        3    -1        0  unknown 0     upper
## 1602   may      510        1    -1        0  unknown 0     upper
## 1603   aug      102        4    -1        0  unknown 0     upper
## 1604   may     1347        2   363        1  failure 1     upper
## 1605   may      158        3    -1        0  unknown 0     upper
## 1606   may      158        1    -1        0  unknown 0     upper
## 1607   may      161        2    -1        0  unknown 0   primary
## 1608   feb      541        1    -1        0  unknown 0     upper
## 1609   may       48        1    -1        0  unknown 0     upper
## 1610   dec       10        1    -1        0  unknown 0     upper
## 1611   aug      996        1    -1        0  unknown 1   primary
## 1612   nov      194        4   188        8    other 0     upper
## 1613   nov      223        1    96        2  failure 0     upper
## 1614   may      473        1    -1        0  unknown 0     upper
## 1615   aug      433        3    -1        0  unknown 0     upper
## 1616   aug      322        7    -1        0  unknown 0     upper
## 1617   feb       99        1    93        3  success 0     upper
## 1618   apr       20        2   238        2  failure 0     upper
## 1619   jul      296        1    -1        0  unknown 0     upper
## 1620   nov      112        1    -1        0  unknown 0     upper
## 1621   may      171        4    -1        0  unknown 0     upper
## 1622   jul      129        2    -1        0  unknown 0   primary
## 1623   nov      180        1   185        2  failure 0     upper
## 1624   may       71        3    -1        0  unknown 0     upper
## 1625   apr      315        1   182        2  success 1     upper
## 1626   aug      142        4    -1        0  unknown 0     upper
## 1627   may      396        3    -1        0  unknown 0     upper
## 1628   may        7        1    -1        0  unknown 0     upper
## 1629   may      230        4    -1        0  unknown 0     upper
## 1630   jul      192        3    -1        0  unknown 0     upper
## 1631   jul       67        1    -1        0  unknown 0     upper
## 1632   jun       16        8    -1        0  unknown 0     upper
## 1633   jun      151        2    -1        0  unknown 0     upper
## 1634   apr      399        1    -1        0  unknown 0     upper
## 1635   may      133        2    -1        0  unknown 0     upper
## 1636   aug      253        1    -1        0  unknown 0   unknown
## 1637   jun      181        1    -1        0  unknown 0   primary
## 1638   may      156        5   297        1    other 0     upper
## 1639   jul      808        5    -1        0  unknown 0     upper
## 1640   jul      368        2    -1        0  unknown 0     upper
## 1641   jun      466        2    -1        0  unknown 0   unknown
## 1642   jun      747        2    -1        0  unknown 1     upper
## 1643   jan      368        1    -1        0  unknown 0     upper
## 1644   jul      625        1    -1        0  unknown 1     upper
## 1645   aug      103        4    -1        0  unknown 0   primary
## 1646   aug      300        3    -1        0  unknown 0     upper
## 1647   apr     1187        2   320        2  success 0   primary
## 1648   aug      310        2    -1        0  unknown 0   primary
## 1649   aug      324        3    -1        0  unknown 0     upper
## 1650   jul       57        3    -1        0  unknown 0     upper
## 1651   nov      564        2   183        1  failure 0     upper
## 1652   may       83        2    -1        0  unknown 0     upper
## 1653   jul      123        1    -1        0  unknown 0     upper
## 1654   aug      145       10    -1        0  unknown 0     upper
## 1655   apr      221        2   267        3    other 0     upper
## 1656   jun      203        2    -1        0  unknown 0     upper
## 1657   jan      653        3    -1        0  unknown 0     upper
## 1658   may      385        1    -1        0  unknown 0     upper
## 1659   may      133        1    -1        0  unknown 0     upper
## 1660   jul      112        1    -1        0  unknown 0     upper
## 1661   jun       85        3    -1        0  unknown 0   primary
## 1662   jun      113        2    -1        0  unknown 0   primary
## 1663   apr      223        1    -1        0  unknown 0   primary
## 1664   jul      126        1    -1        0  unknown 0     upper
## 1665   may      526        3   179        3  success 1     upper
## 1666   nov       80        2    -1        0  unknown 0   unknown
## 1667   aug       71        1    -1        0  unknown 0     upper
## 1668   may       62        3    -1        0  unknown 0     upper
## 1669   may      698        1    -1        0  unknown 0     upper
## 1670   jul       69        4    -1        0  unknown 0     upper
## 1671   jun      127        4    -1        0  unknown 0     upper
## 1672   may       19        4   374        1    other 0     upper
## 1673   may      507        2    -1        0  unknown 0     upper
## 1674   jul      252        1    -1        0  unknown 0     upper
## 1675   jul      152        4    -1        0  unknown 0     upper
## 1676   aug      126        1    -1        0  unknown 0     upper
## 1677   feb      226        2    -1        0  unknown 0     upper
## 1678   aug      255        2    -1        0  unknown 0     upper
## 1679   aug      190        1    -1        0  unknown 0     upper
## 1680   jul      107        2    -1        0  unknown 0     upper
## 1681   nov      204        1    -1        0  unknown 1     upper
## 1682   may      320        3   371        2  failure 0     upper
## 1683   may       78        2    -1        0  unknown 0     upper
## 1684   apr      728        1   316        3    other 0     upper
## 1685   may      418        1    -1        0  unknown 0     upper
## 1686   jan       76        2    -1        0  unknown 0     upper
## 1687   apr      317        1   363        2  success 1     upper
## 1688   jul      142        2    -1        0  unknown 0   primary
## 1689   nov       80        5   198        2  failure 0     upper
## 1690   may      188        2    -1        0  unknown 0     upper
## 1691   nov      392        3    -1        0  unknown 0     upper
## 1692   jul      166        1    -1        0  unknown 0     upper
## 1693   jul      344        3    -1        0  unknown 0     upper
## 1694   may      138        2    -1        0  unknown 0   unknown
## 1695   aug      134        3   194        1  failure 0     upper
## 1696   jul      116        1   301        1    other 0     upper
## 1697   feb       38        8    -1        0  unknown 0     upper
## 1698   jul      728        8    -1        0  unknown 0     upper
## 1699   may       20        1   342        1  failure 0     upper
## 1700   nov       77        1   127        3  failure 0     upper
## 1701   jul      218        3    -1        0  unknown 0     upper
## 1702   jun      291        3    -1        0  unknown 0     upper
## 1703   may       92        3    -1        0  unknown 0     upper
## 1704   may      850        1    -1        0  unknown 1   primary
## 1705   may     2260        2    -1        0  unknown 0     upper
## 1706   may      139        2    -1        0  unknown 0     upper
## 1707   jul      127        1    -1        0  unknown 0     upper
## 1708   nov      281        2   195        6  failure 0   primary
## 1709   feb       19        6    -1        0  unknown 0     upper
## 1710   apr      137        1   333        2    other 0     upper
## 1711   may       85        2    -1        0  unknown 0   primary
## 1712   aug      147        3    -1        0  unknown 0   primary
## 1713   oct      408        2    -1        0  unknown 0     upper
## 1714   jun      154        3    -1        0  unknown 0     upper
## 1715   jul      779        2    -1        0  unknown 0     upper
## 1716   may      204        1    -1        0  unknown 0     upper
## 1717   aug      473        6    -1        0  unknown 1     upper
## 1718   may      125        1    -1        0  unknown 0     upper
## 1719   may      101        1    -1        0  unknown 0   primary
## 1720   jul      662        1    -1        0  unknown 0     upper
## 1721   aug      260        7    -1        0  unknown 0     upper
## 1722   may      103        1   363        1  failure 0     upper
## 1723   may      136        2    -1        0  unknown 0     upper
## 1724   jul      159        6    -1        0  unknown 0     upper
## 1725   may       32        2    -1        0  unknown 0     upper
## 1726   may      129        2    -1        0  unknown 0     upper
## 1727   sep      173        1    -1        0  unknown 0   primary
## 1728   aug      128        2    -1        0  unknown 0     upper
## 1729   jan     1232        1    -1        0  unknown 1     upper
## 1730   may      260        3    -1        0  unknown 0     upper
## 1731   nov      167        5    -1        0  unknown 0     upper
## 1732   feb      255        3    -1        0  unknown 0     upper
## 1733   jun      973        2    -1        0  unknown 1   primary
## 1734   feb      266        2    -1        0  unknown 0     upper
## 1735   jul      121        1    -1        0  unknown 0     upper
## 1736   may      111        1    -1        0  unknown 0     upper
## 1737   jun       92        2    -1        0  unknown 0   primary
## 1738   jul      287        2    -1        0  unknown 0     upper
## 1739   nov      141        2    -1        0  unknown 0     upper
## 1740   aug       23        9    -1        0  unknown 0     upper
## 1741   apr        5        3   150        6  failure 0     upper
## 1742   aug      222        3   182        4  success 1     upper
## 1743   may      178        1    -1        0  unknown 0     upper
## 1744   may       45        1    -1        0  unknown 0     upper
## 1745   may      419        1   360        4  failure 0     upper
## 1746   may      156        1    -1        0  unknown 0     upper
## 1747   jul      104        2    -1        0  unknown 0     upper
## 1748   aug       51        2    -1        0  unknown 0     upper
## 1749   aug       44       12    -1        0  unknown 0     upper
## 1750   may      701        1   362        1  success 1   primary
## 1751   jun      252        1    -1        0  unknown 0     upper
## 1752   may       93        2    -1        0  unknown 0     upper
## 1753   jun      690        1    -1        0  unknown 1     upper
## 1754   may       62        2    -1        0  unknown 0     upper
## 1755   may      103        2    -1        0  unknown 0     upper
## 1756   apr       61        3    -1        0  unknown 0     upper
## 1757   may      241        1    -1        0  unknown 0     upper
## 1758   jul      209        1    -1        0  unknown 0     upper
## 1759   apr      627        5    -1        0  unknown 0     upper
## 1760   may       26        1   174        2  failure 0     upper
## 1761   jun      231       12    -1        0  unknown 0     upper
## 1762   aug     1363        1    -1        0  unknown 1     upper
## 1763   may       78        3    -1        0  unknown 0   primary
## 1764   may      295        2    -1        0  unknown 0     upper
## 1765   jan      273        1    -1        0  unknown 0     upper
## 1766   apr      375        1    -1        0  unknown 1     upper
## 1767   mar       88        3    -1        0  unknown 0     upper
## 1768   may       83        2    -1        0  unknown 0   primary
## 1769   aug      350        6    -1        0  unknown 0     upper
## 1770   may      146        1    -1        0  unknown 0     upper
## 1771   jul      183        1   221        2  failure 1     upper
## 1772   nov      175        1    -1        0  unknown 0     upper
## 1773   may      198        1    -1        0  unknown 0     upper
## 1774   may       23        3   346       10  failure 0   unknown
## 1775   jul       58        1    -1        0  unknown 0     upper
## 1776   may     1080        5    -1        0  unknown 0   primary
## 1777   jun      172        1    -1        0  unknown 0     upper
## 1778   apr      184        1    -1        0  unknown 1     upper
## 1779   aug      276        3    -1        0  unknown 0     upper
## 1780   may      208        3    -1        0  unknown 0     upper
## 1781   may      544        3    -1        0  unknown 0   primary
## 1782   apr      219        4    -1        0  unknown 0     upper
## 1783   aug       97        5    -1        0  unknown 0     upper
## 1784   may       56        2    -1        0  unknown 0     upper
## 1785   aug      111        2    -1        0  unknown 0     upper
## 1786   feb       87        2   265        3    other 0     upper
## 1787   may       42        1    -1        0  unknown 0     upper
## 1788   jun       21       37    -1        0  unknown 0   primary
## 1789   jun      175        2    -1        0  unknown 0     upper
## 1790   jul      109        3    -1        0  unknown 0     upper
## 1791   nov       92        2    -1        0  unknown 0     upper
## 1792   may      151        4   171       11    other 0     upper
## 1793   may       55        1    -1        0  unknown 0     upper
## 1794   apr      179        3    -1        0  unknown 0     upper
## 1795   aug      283        1    -1        0  unknown 0     upper
## 1796   sep       20        1   478        2    other 0     upper
## 1797   nov      354        2    -1        0  unknown 0     upper
## 1798   feb       11        7    -1        0  unknown 0     upper
## 1799   apr     1463        2    -1        0  unknown 1     upper
## 1800   may      695        2    -1        0  unknown 0     upper
## 1801   may      235        2    -1        0  unknown 0     upper
## 1802   may      119        2    -1        0  unknown 0     upper
## 1803   aug      305        1    91        2    other 0     upper
## 1804   nov      124        1   175        1  failure 0     upper
## 1805   may      167        1    -1        0  unknown 0     upper
## 1806   may      859        2    -1        0  unknown 0     upper
## 1807   may      362        2   307        1  failure 0   unknown
## 1808   feb       93        1    -1        0  unknown 0     upper
## 1809   aug       73       15    -1        0  unknown 0     upper
## 1810   may      130        4    -1        0  unknown 0   primary
## 1811   aug      102        1   105        1  success 0     upper
## 1812   apr      550        1   325        1    other 0     upper
## 1813   nov      203        1    -1        0  unknown 0     upper
## 1814   aug      192        1   193        1  success 1     upper
## 1815   may      764        4    -1        0  unknown 0     upper
## 1816   jul      139        1    -1        0  unknown 0   primary
## 1817   jul       73        7    -1        0  unknown 0     upper
## 1818   may      599        1   306        4  success 0   unknown
## 1819   nov      133        1    -1        0  unknown 0     upper
## 1820   jul      191        3    -1        0  unknown 0   unknown
## 1821   may      105        1    -1        0  unknown 0     upper
## 1822   aug      193        2    -1        0  unknown 0     upper
## 1823   may      174        2    -1        0  unknown 0     upper
## 1824   feb      511        3   183        6  success 1     upper
## 1825   nov       59        1    -1        0  unknown 0   primary
## 1826   may       91        1    -1        0  unknown 0     upper
## 1827   nov       91        2    -1        0  unknown 0     upper
## 1828   nov      231        1    96        2    other 0     upper
## 1829   nov      210        3    -1        0  unknown 0     upper
## 1830   jun      333       15    -1        0  unknown 0     upper
## 1831   apr      335        2    -1        0  unknown 0     upper
## 1832   jul      936        1    -1        0  unknown 0     upper
## 1833   jul      434        4    -1        0  unknown 0     upper
## 1834   aug      629        4    -1        0  unknown 0     upper
## 1835   may      128        1    -1        0  unknown 0     upper
## 1836   jul      235        2    -1        0  unknown 0     upper
## 1837   jan      379        1   192        1  failure 0     upper
## 1838   aug      281        2    -1        0  unknown 0     upper
## 1839   aug      249        1   104        1  success 0   primary
## 1840   aug       26       10    -1        0  unknown 0   primary
## 1841   jun      148        1    -1        0  unknown 0     upper
## 1842   jul      182        1    -1        0  unknown 0     upper
## 1843   jul       54        7    -1        0  unknown 0     upper
## 1844   may      644        2    -1        0  unknown 0     upper
## 1845   may      107        1    -1        0  unknown 0     upper
## 1846   jun      565        3    -1        0  unknown 0     upper
## 1847   oct      168        2    -1        0  unknown 0     upper
## 1848   jul       59        1    -1        0  unknown 0     upper
## 1849   jun      521       11    -1        0  unknown 0     upper
## 1850   aug      119        3    -1        0  unknown 0   primary
## 1851   mar      192        1   185        2  success 1     upper
## 1852   aug      179        4    -1        0  unknown 0   unknown
## 1853   may       98        1    77        5  failure 0     upper
## 1854   may      225        2    -1        0  unknown 0     upper
## 1855   nov      611        3    -1        0  unknown 0   primary
## 1856   may      281       15    -1        0  unknown 0     upper
## 1857   jan      427        1    -1        0  unknown 0     upper
## 1858   apr      181        2   270        2  failure 0     upper
## 1859   jul       70        5    -1        0  unknown 0     upper
## 1860   jun      348        1    -1        0  unknown 0     upper
## 1861   jun      266       10    -1        0  unknown 0   unknown
## 1862   jul      514        5    -1        0  unknown 1     upper
## 1863   may      224        1   370        2  failure 0   primary
## 1864   may       88        2    -1        0  unknown 0     upper
## 1865   apr       72        1    -1        0  unknown 0     upper
## 1866   may      173        1    -1        0  unknown 0     upper
## 1867   nov      230        1    -1        0  unknown 0     upper
## 1868   apr      156        1    -1        0  unknown 0     upper
## 1869   jun       11       15    -1        0  unknown 0   primary
## 1870   apr      173        2    -1        0  unknown 0   primary
## 1871   apr      167        1   350        1  failure 0   unknown
## 1872   jul      132        7    -1        0  unknown 0     upper
## 1873   may      110        1    -1        0  unknown 0     upper
## 1874   mar      294        1   274        2  failure 0     upper
## 1875   aug      202        1    -1        0  unknown 0     upper
## 1876   jun       10        2    -1        0  unknown 0   primary
## 1877   jul     1037       24    -1        0  unknown 0     upper
## 1878   may      155        2    -1        0  unknown 0     upper
## 1879   feb      480        2   189        1  failure 0   primary
## 1880   jun      505        1    -1        0  unknown 0     upper
## 1881   aug      904        6    -1        0  unknown 1     upper
## 1882   apr      765        3    -1        0  unknown 0   primary
## 1883   aug      448        5    -1        0  unknown 0     upper
## 1884   nov      114        1   170        3  failure 1     upper
## 1885   jan      246        1    -1        0  unknown 0     upper
## 1886   jun      604        6    -1        0  unknown 0     upper
## 1887   jun       80        1    92        1  failure 0     upper
## 1888   jun      362        3    -1        0  unknown 0     upper
## 1889   aug      166        2    -1        0  unknown 0     upper
## 1890   jun      282        2   385        1  success 1   unknown
## 1891   may      123        1    -1        0  unknown 0     upper
## 1892   jun      109        1    -1        0  unknown 0     upper
## 1893   nov       68        1    -1        0  unknown 0     upper
## 1894   nov       53        1    -1        0  unknown 0   primary
## 1895   jun       97        4    -1        0  unknown 0     upper
## 1896   may      751        3    -1        0  unknown 1   primary
## 1897   jul      154        1    -1        0  unknown 0   unknown
## 1898   nov      106        1    -1        0  unknown 0   primary
## 1899   aug      428        2    -1        0  unknown 0     upper
## 1900   may      228        2    -1        0  unknown 0   unknown
## 1901   jul      347        5    -1        0  unknown 0   primary
## 1902   nov       87        1    -1        0  unknown 0     upper
## 1903   jul      413        1    -1        0  unknown 0     upper
## 1904   may      170        2    -1        0  unknown 0     upper
## 1905   may      211        2    -1        0  unknown 0   primary
## 1906   apr      143        4    -1        0  unknown 0   primary
## 1907   may      219        2    -1        0  unknown 0     upper
## 1908   may      188        2    -1        0  unknown 0   primary
## 1909   aug      305        1   179        5    other 0     upper
## 1910   may      313        1    -1        0  unknown 0     upper
## 1911   nov      285        3   116        4  failure 0     upper
## 1912   jan      771        1    -1        0  unknown 1     upper
## 1913   aug      170        2    -1        0  unknown 0     upper
## 1914   jun      101        2    -1        0  unknown 0     upper
## 1915   jul      171        6    -1        0  unknown 0     upper
## 1916   may       52        1    -1        0  unknown 0     upper
## 1917   aug      561        1   435        3  failure 1     upper
## 1918   may       33        1    -1        0  unknown 0     upper
## 1919   jun       36        2    -1        0  unknown 0   primary
## 1920   feb       35        3    -1        0  unknown 0   primary
## 1921   jul       47        2    -1        0  unknown 0     upper
## 1922   jun      269        1    -1        0  unknown 0   primary
## 1923   may      218        2   211        4  success 0     upper
## 1924   nov      119        2   171        1  failure 0     upper
## 1925   may      348        1    -1        0  unknown 0     upper
## 1926   may      100        1    -1        0  unknown 0     upper
## 1927   jan       88        2    -1        0  unknown 0   primary
## 1928   apr      273        2   254        2  failure 0     upper
## 1929   may       54        1    -1        0  unknown 0     upper
## 1930   may      161        1   100        3  success 0     upper
## 1931   aug      146        2    -1        0  unknown 0     upper
## 1932   jul      211        3    -1        0  unknown 0     upper
## 1933   may      552        3    -1        0  unknown 1     upper
## 1934   jul      400        2    -1        0  unknown 0     upper
## 1935   jun      366        1    -1        0  unknown 0     upper
## 1936   feb        8        7   189       18    other 0     upper
## 1937   may       57        2    -1        0  unknown 0     upper
## 1938   oct      167        3    -1        0  unknown 0   primary
## 1939   aug       36        3    -1        0  unknown 0   primary
## 1940   feb      150        4    -1        0  unknown 0     upper
## 1941   jun      187        1    20        1    other 1     upper
## 1942   jul      226        1    -1        0  unknown 0     upper
## 1943   sep      799        2    -1        0  unknown 1     upper
## 1944   may      178        7   365        5    other 0     upper
## 1945   nov      281        2    -1        0  unknown 0     upper
## 1946   aug      551        2    -1        0  unknown 0     upper
## 1947   jun      332        2    -1        0  unknown 0   unknown
## 1948   feb      381        6   213        9  failure 0     upper
## 1949   feb      401        2     8        3    other 0     upper
## 1950   may      226        2    -1        0  unknown 0     upper
## 1951   aug       99        4    -1        0  unknown 0     upper
## 1952   may      451        3    -1        0  unknown 0   primary
## 1953   may      381        2    -1        0  unknown 0     upper
## 1954   may      127        1    -1        0  unknown 0     upper
## 1955   jan      315        1    -1        0  unknown 0     upper
## 1956   sep      112        2    24        2    other 0     upper
## 1957   may      201        1    -1        0  unknown 0     upper
## 1958   may      293        2    -1        0  unknown 0     upper
## 1959   may      499        3    -1        0  unknown 0     upper
## 1960   jul       48        2    -1        0  unknown 0     upper
## 1961   may      494        1    -1        0  unknown 1     upper
## 1962   feb      147        1   253        7    other 0     upper
## 1963   nov       23        1    -1        0  unknown 0     upper
## 1964   may      787        1    -1        0  unknown 0     upper
## 1965   feb      605        1    -1        0  unknown 0   primary
## 1966   jul       82        1    -1        0  unknown 0     upper
## 1967   jul      484        1    -1        0  unknown 0     upper
## 1968   may       61        2    -1        0  unknown 0     upper
## 1969   may       78        5    -1        0  unknown 0     upper
## 1970   apr      132        2    -1        0  unknown 0     upper
## 1971   feb      642        1   167        2  failure 1     upper
## 1972   jun        6       17    -1        0  unknown 0   primary
## 1973   jul       53        8    -1        0  unknown 0     upper
## 1974   may     1178        4    -1        0  unknown 0     upper
## 1975   jan      147        1   195        1    other 0     upper
## 1976   may      236        1    -1        0  unknown 0     upper
## 1977   jan      978        2   189        1    other 0     upper
## 1978   may      296        1    -1        0  unknown 0     upper
## 1979   may      479        2    -1        0  unknown 0   primary
## 1980   may      188        1    -1        0  unknown 0     upper
## 1981   may      447        4    -1        0  unknown 0     upper
## 1982   may      356        2   286        3  failure 0     upper
## 1983   jun      136        1    -1        0  unknown 0     upper
## 1984   may       37        9    -1        0  unknown 0   primary
## 1985   nov       96        1    -1        0  unknown 0     upper
## 1986   may       44        4    -1        0  unknown 0     upper
## 1987   nov      186        2    -1        0  unknown 0     upper
## 1988   may       95        8    -1        0  unknown 0     upper
## 1989   aug      155        2    -1        0  unknown 0     upper
## 1990   jul      202        5    -1        0  unknown 0     upper
## 1991   jan      540        1     2        2    other 0     upper
## 1992   apr      169        1   231        2  failure 0     upper
## 1993   apr      256        5   181        2  success 1     upper
## 1994   may      191        3    -1        0  unknown 0   primary
## 1995   jul      151       10    -1        0  unknown 0     upper
## 1996   nov      131        3   133        3  failure 0   primary
## 1997   nov      131        2    -1        0  unknown 0     upper
## 1998   feb      590        5    -1        0  unknown 0     upper
## 1999   nov      178        1   127        7    other 0     upper
## 2000   jun       64        2    -1        0  unknown 0   unknown
## 2001   feb      247        5    -1        0  unknown 0   primary
## 2002   aug      120        6    -1        0  unknown 0     upper
## 2003   aug      108        1    99        7  failure 0     upper
## 2004   jul      257        1    -1        0  unknown 1     upper
## 2005   may      562        2   174        2  success 0   primary
## 2006   apr      126        3   345        2    other 0     upper
## 2007   jul       95        2    -1        0  unknown 0     upper
## 2008   jun      508        2    -1        0  unknown 1     upper
## 2009   aug      121        2    -1        0  unknown 0   primary
## 2010   nov      166        3    -1        0  unknown 0     upper
## 2011   jan      155        1    -1        0  unknown 0     upper
## 2012   apr      159        3    -1        0  unknown 1     upper
## 2013   may      212        2    -1        0  unknown 0   primary
## 2014   aug      221        6    -1        0  unknown 0     upper
## 2015   may      169        4    -1        0  unknown 0     upper
## 2016   jun      442       11    -1        0  unknown 0     upper
## 2017   may      120        1    -1        0  unknown 0     upper
## 2018   may       85        1    -1        0  unknown 0     upper
## 2019   may      245        1    -1        0  unknown 0     upper
## 2020   jan      187        2   185        8  failure 0     upper
## 2021   aug       68        2    -1        0  unknown 0     upper
## 2022   jan      163        1    -1        0  unknown 0     upper
## 2023   may       83        1    -1        0  unknown 0     upper
## 2024   aug      174        1    -1        0  unknown 0   primary
## 2025   may      214        2    -1        0  unknown 0     upper
## 2026   jun      209        3    -1        0  unknown 0   primary
## 2027   may      456        1   300        1  failure 1     upper
## 2028   may      127        1    -1        0  unknown 0     upper
## 2029   jul      817        2    -1        0  unknown 1     upper
## 2030   oct      375        2    -1        0  unknown 0     upper
## 2031   jun       29        1    -1        0  unknown 0     upper
## 2032   may      219        4    -1        0  unknown 0     upper
## 2033   may      109        2    -1        0  unknown 0     upper
## 2034   jun      128        1    -1        0  unknown 0     upper
## 2035   may       73        2    -1        0  unknown 0     upper
## 2036   feb      278        4    -1        0  unknown 0   unknown
## 2037   jul       34       32    -1        0  unknown 0   primary
## 2038   nov      257        1    -1        0  unknown 1   primary
## 2039   may      844        1    -1        0  unknown 1     upper
## 2040   mar      167        1    -1        0  unknown 1     upper
## 2041   feb       12        3    -1        0  unknown 0     upper
## 2042   may      763        1    -1        0  unknown 1     upper
## 2043   jun      101        1    -1        0  unknown 0     upper
## 2044   nov      131        1    -1        0  unknown 0     upper
## 2045   aug      148        1    -1        0  unknown 0     upper
## 2046   feb      701        1    -1        0  unknown 0   primary
## 2047   nov      454        1    -1        0  unknown 1     upper
## 2048   jun      280        1    -1        0  unknown 0   primary
## 2049   may      265        4    -1        0  unknown 0     upper
## 2050   may      297        3    -1        0  unknown 0     upper
## 2051   aug      153        1    -1        0  unknown 0     upper
## 2052   feb      254        1    -1        0  unknown 0   unknown
## 2053   may       30        4   304        2    other 0   primary
## 2054   may      125        4    -1        0  unknown 0   primary
## 2055   jun      114        1    -1        0  unknown 0     upper
## 2056   feb      136       10    -1        0  unknown 1     upper
## 2057   apr      208       12   337        1  failure 0     upper
## 2058   nov       86        1    -1        0  unknown 0     upper
## 2059   apr      949        2   254        6    other 1     upper
## 2060   jun      207        1    -1        0  unknown 0   primary
## 2061   nov      103        1    -1        0  unknown 0     upper
## 2062   may     1052        1    -1        0  unknown 0     upper
## 2063   apr      109        1    -1        0  unknown 0   unknown
## 2064   jun      149        8    -1        0  unknown 0   primary
## 2065   jun      138        5    -1        0  unknown 0     upper
## 2066   may      341        1    -1        0  unknown 0     upper
## 2067   apr      184        2   151        1  failure 0   primary
## 2068   jun       75        3    -1        0  unknown 0     upper
## 2069   apr       87        2    -1        0  unknown 0   primary
## 2070   jan      413        2    -1        0  unknown 0     upper
## 2071   feb       35        1    -1        0  unknown 0     upper
## 2072   jul      104        3    -1        0  unknown 0     upper
## 2073   jul      487        3    -1        0  unknown 0     upper
## 2074   feb      146        1    -1        0  unknown 0     upper
## 2075   may      483        4    87        2  success 1     upper
## 2076   nov      248        1    -1        0  unknown 0     upper
## 2077   feb      803        1    -1        0  unknown 1     upper
## 2078   may       91        2    -1        0  unknown 0   primary
## 2079   jun       94        1    -1        0  unknown 0     upper
## 2080   may      325        3    -1        0  unknown 0     upper
## 2081   may       22        5    -1        0  unknown 0   primary
## 2082   may      130        2    -1        0  unknown 0     upper
## 2083   jan      383        2   206        1    other 0     upper
## 2084   may      207        1    -1        0  unknown 0     upper
## 2085   may      244        1    -1        0  unknown 0     upper
## 2086   nov       31        7    -1        0  unknown 0     upper
## 2087   may      493       10   362        1    other 0     upper
## 2088   jan      183        2    -1        0  unknown 0   primary
## 2089   may      541        5    -1        0  unknown 0   primary
## 2090   may      339        1    -1        0  unknown 0     upper
## 2091   apr      293        2   314        2  failure 0     upper
## 2092   apr      112        1    -1        0  unknown 0     upper
## 2093   jun      177        8    -1        0  unknown 0   unknown
## 2094   may      173        4    -1        0  unknown 0     upper
## 2095   jun      258        1    -1        0  unknown 0     upper
## 2096   may      207        1    -1        0  unknown 0     upper
## 2097   aug      279        1   117        1  failure 0   unknown
## 2098   jul     1148        1   276        2    other 1     upper
## 2099   nov      182        1    -1        0  unknown 0     upper
## 2100   aug      119        7    -1        0  unknown 0     upper
## 2101   may      246        1    -1        0  unknown 0     upper
## 2102   jun      137        1    -1        0  unknown 0   primary
## 2103   jul       68        1    -1        0  unknown 0   primary
## 2104   jan      214        1    -1        0  unknown 0     upper
## 2105   may      155        6    -1        0  unknown 0   primary
## 2106   jun      638       16    -1        0  unknown 0     upper
## 2107   aug      181        2    -1        0  unknown 0     upper
## 2108   may      103        1    -1        0  unknown 0     upper
## 2109   aug      214        7    -1        0  unknown 0     upper
## 2110   feb      104        3    -1        0  unknown 0     upper
## 2111   jun       59        3    -1        0  unknown 0     upper
## 2112   jul       33        1    -1        0  unknown 0   primary
## 2113   jun      153        6    -1        0  unknown 0     upper
## 2114   jul       29       10    -1        0  unknown 0     upper
## 2115   may      113        1    -1        0  unknown 0     upper
## 2116   feb      503        1    -1        0  unknown 1     upper
## 2117   aug       22        2    -1        0  unknown 0     upper
## 2118   apr      422        4    -1        0  unknown 0     upper
## 2119   jan      177        1    -1        0  unknown 0   unknown
## 2120   may       99        1    -1        0  unknown 0     upper
## 2121   apr     1353        2   138        2  success 1     upper
## 2122   aug      181        1    -1        0  unknown 0   primary
## 2123   jul      516        1    -1        0  unknown 1     upper
## 2124   aug      331        7    -1        0  unknown 0     upper
## 2125   aug       44        2    -1        0  unknown 0     upper
## 2126   aug      230        2    -1        0  unknown 0     upper
## 2127   jul     1608       13    -1        0  unknown 1     upper
## 2128   may      192        1    -1        0  unknown 0     upper
## 2129   may      271        2    -1        0  unknown 0     upper
## 2130   oct       96        1   158        1  failure 0     upper
## 2131   jan      187        7    -1        0  unknown 1     upper
## 2132   may      145        1    -1        0  unknown 0     upper
## 2133   feb      771        1   171        1  success 1     upper
## 2134   jul      559        2    -1        0  unknown 0     upper
## 2135   may      187        3    -1        0  unknown 0     upper
## 2136   may       65        3    -1        0  unknown 0     upper
## 2137   aug      625        4    -1        0  unknown 1   primary
## 2138   nov      268        3    -1        0  unknown 0     upper
## 2139   may      128        3    -1        0  unknown 0     upper
## 2140   nov      201        2   174        3  success 0   primary
## 2141   may      124        1   338        2  failure 0     upper
## 2142   feb      260        2    -1        0  unknown 0     upper
## 2143   may       86        2    -1        0  unknown 0     upper
## 2144   may       30        7    -1        0  unknown 0     upper
## 2145   aug      184        3    -1        0  unknown 0     upper
## 2146   jan       82        2    -1        0  unknown 0     upper
## 2147   jun      223        3    -1        0  unknown 0     upper
## 2148   nov       75        2   119        2  success 0     upper
## 2149   jul       80        1    -1        0  unknown 0     upper
## 2150   jul       43        2    -1        0  unknown 0     upper
## 2151   aug      139        1    -1        0  unknown 0     upper
## 2152   jun       82        1    -1        0  unknown 0     upper
## 2153   may      370        2    -1        0  unknown 0   primary
## 2154   jul      271        5    -1        0  unknown 0     upper
## 2155   may       61        6    -1        0  unknown 0   primary
## 2156   jul       84        6    -1        0  unknown 0     upper
## 2157   may      513        2    -1        0  unknown 0     upper
## 2158   oct      140        2    -1        0  unknown 0     upper
## 2159   jul     1187        3    -1        0  unknown 1     upper
## 2160   mar      684        4    -1        0  unknown 0     upper
## 2161   jul      142        9    -1        0  unknown 0     upper
## 2162   jul      115        2    -1        0  unknown 0     upper
## 2163   jul      176        4    -1        0  unknown 0   primary
## 2164   jul      610        1    -1        0  unknown 1     upper
## 2165   may      261        1    -1        0  unknown 0     upper
## 2166   jul       68        3    -1        0  unknown 0     upper
## 2167   aug      242        5    -1        0  unknown 0     upper
## 2168   may       59        3    -1        0  unknown 0     upper
## 2169   nov      184        1    -1        0  unknown 0     upper
## 2170   feb      871        4    -1        0  unknown 0     upper
## 2171   may      777        2    -1        0  unknown 1     upper
## 2172   jul      153        1    -1        0  unknown 0     upper
## 2173   may       60        1    -1        0  unknown 0     upper
## 2174   aug      129        2    -1        0  unknown 0     upper
## 2175   jun       98        1    -1        0  unknown 0     upper
## 2176   jul      226        1    -1        0  unknown 0   primary
## 2177   jun      193       10    -1        0  unknown 0     upper
## 2178   feb      150        3    -1        0  unknown 0     upper
## 2179   jun      273        1    -1        0  unknown 0     upper
## 2180   jun       74        2    -1        0  unknown 0     upper
## 2181   apr      687        1     9        3  success 1     upper
## 2182   jul       48        3    -1        0  unknown 0     upper
## 2183   may      365        6    36        3  failure 0     upper
## 2184   may      374        9    -1        0  unknown 0   primary
## 2185   nov       91        2    -1        0  unknown 0     upper
## 2186   jul       76        3    -1        0  unknown 0     upper
## 2187   sep      337        1   186        1  success 1     upper
## 2188   may      239        3    -1        0  unknown 0     upper
## 2189   may      167        3    -1        0  unknown 0     upper
## 2190   jun      118        2    81        1  success 0     upper
## 2191   nov       48        1    -1        0  unknown 0     upper
## 2192   aug       96        2    -1        0  unknown 0     upper
## 2193   jun      140        1    -1        0  unknown 0     upper
## 2194   jun      463        4    -1        0  unknown 0     upper
## 2195   may       99        2    -1        0  unknown 0   unknown
## 2196   may      226        2    -1        0  unknown 0     upper
## 2197   feb     1192        3    -1        0  unknown 0     upper
## 2198   may      243        3    -1        0  unknown 0     upper
## 2199   may      369        1    -1        0  unknown 0   primary
## 2200   jul      273        4    -1        0  unknown 0     upper
## 2201   jun     1009        1    -1        0  unknown 0   primary
## 2202   may       90        4    -1        0  unknown 0   primary
## 2203   aug       93        1    -1        0  unknown 0     upper
## 2204   may      233        2    -1        0  unknown 0     upper
## 2205   jun      262        2    -1        0  unknown 0     upper
## 2206   apr       99        1   329        4    other 0     upper
## 2207   jul      101        3    -1        0  unknown 0     upper
## 2208   nov       65        1    -1        0  unknown 0     upper
## 2209   may      667        2    -1        0  unknown 1     upper
## 2210   jun       34       31    -1        0  unknown 0     upper
## 2211   may      160        2    -1        0  unknown 0     upper
## 2212   apr      170        1    -1        0  unknown 0     upper
## 2213   aug      234        2    -1        0  unknown 0   primary
## 2214   may      354        1   370        2  failure 0     upper
## 2215   aug      131        2    -1        0  unknown 0     upper
## 2216   jul      606        2    -1        0  unknown 0     upper
## 2217   aug      433        2    -1        0  unknown 0     upper
## 2218   nov      208        3    91        4  failure 0     upper
## 2219   jul      100        4    -1        0  unknown 0     upper
## 2220   jun      825        1    -1        0  unknown 0     upper
## 2221   may      172        3   173        1    other 0     upper
## 2222   aug       71        3    -1        0  unknown 0     upper
## 2223   may       13        5    -1        0  unknown 0     upper
## 2224   aug      787       13    -1        0  unknown 0     upper
## 2225   aug      110        1    -1        0  unknown 0     upper
## 2226   may      265        1    -1        0  unknown 0     upper
## 2227   may       62        2    -1        0  unknown 0     upper
## 2228   feb     1052        2    -1        0  unknown 0     upper
## 2229   nov      339        3    -1        0  unknown 0     upper
## 2230   may      360        2    -1        0  unknown 0     upper
## 2231   jul      126        3    -1        0  unknown 0     upper
## 2232   nov      434        2    -1        0  unknown 0     upper
## 2233   jul       88        1    -1        0  unknown 0     upper
## 2234   aug       38        6    -1        0  unknown 0     upper
## 2235   jun       73        4    -1        0  unknown 0     upper
## 2236   aug      454        6    -1        0  unknown 0     upper
## 2237   aug       73        4    -1        0  unknown 0     upper
## 2238   nov       57        1    -1        0  unknown 0     upper
## 2239   jul      422        1    -1        0  unknown 0     upper
## 2240   may      360        1   370        1    other 0     upper
## 2241   may       80        1    -1        0  unknown 0     upper
## 2242   may       90        1    -1        0  unknown 0     upper
## 2243   may      325        4    -1        0  unknown 0     upper
## 2244   may      289        1    -1        0  unknown 0     upper
## 2245   feb      287        1   130        1  failure 0     upper
## 2246   jul      384        4    -1        0  unknown 0     upper
## 2247   jun      394        1    -1        0  unknown 0     upper
## 2248   may      390        2    -1        0  unknown 0     upper
## 2249   may      204        2    -1        0  unknown 0     upper
## 2250   jun      275        1    -1        0  unknown 0     upper
## 2251   apr      815        2    -1        0  unknown 0     upper
## 2252   mar      111        3   585        6    other 0     upper
## 2253   nov       73        1    -1        0  unknown 0     upper
## 2254   may      260        3    -1        0  unknown 0     upper
## 2255   jun       77        8    -1        0  unknown 0     upper
## 2256   may      567        2    -1        0  unknown 0     upper
## 2257   apr      207        1    -1        0  unknown 0     upper
## 2258   aug      150        4    -1        0  unknown 0     upper
## 2259   jul       56        1    -1        0  unknown 0     upper
## 2260   apr      403        1    -1        0  unknown 1     upper
## 2261   sep      409        1   398        1  failure 1     upper
## 2262   may      158        1   351        1  failure 0   unknown
## 2263   jun      340        3    -1        0  unknown 0   unknown
## 2264   may      448        1    -1        0  unknown 0     upper
## 2265   nov      599        4   100        2  failure 0     upper
## 2266   jul       69        2    -1        0  unknown 0     upper
## 2267   may     1094        2    -1        0  unknown 1     upper
## 2268   may      524        3   326        1    other 0     upper
## 2269   jun      205        1    -1        0  unknown 0     upper
## 2270   jun      573        1    -1        0  unknown 0   primary
## 2271   aug       72        4    -1        0  unknown 0     upper
## 2272   jun      157        1    -1        0  unknown 0     upper
## 2273   apr      143        1    -1        0  unknown 0     upper
## 2274   dec      720        5   536        5  failure 0     upper
## 2275   jul      127        6    -1        0  unknown 0     upper
## 2276   may      184        2    -1        0  unknown 0     upper
## 2277   may      202        2   167        1  failure 0     upper
## 2278   may      105        3    -1        0  unknown 0   unknown
## 2279   jun      121        3   195        2    other 0     upper
## 2280   jan      334        1    -1        0  unknown 0     upper
## 2281   apr      159        2    -1        0  unknown 0     upper
## 2282   may       85        1    -1        0  unknown 0   unknown
## 2283   may      176        2    89        5  success 1     upper
## 2284   apr      494        1    -1        0  unknown 0     upper
## 2285   may       66        7    -1        0  unknown 0   primary
## 2286   jul      526        1    -1        0  unknown 0     upper
## 2287   apr      200        3    -1        0  unknown 0     upper
## 2288   jul       98        5    -1        0  unknown 0     upper
## 2289   jul       88        1    -1        0  unknown 0     upper
## 2290   jul      162        6    -1        0  unknown 0     upper
## 2291   may      108        1    -1        0  unknown 0   primary
## 2292   may      401        1   336        2  failure 0     upper
## 2293   apr      401        1    -1        0  unknown 0     upper
## 2294   may      114        1   368        1  failure 0     upper
## 2295   aug      100        4    -1        0  unknown 0     upper
## 2296   may      238        1    -1        0  unknown 0   primary
## 2297   may      125        1    -1        0  unknown 0     upper
## 2298   aug      387        8    -1        0  unknown 0     upper
## 2299   aug      129        2    -1        0  unknown 0     upper
## 2300   jun      559        2    -1        0  unknown 0     upper
## 2301   sep      658        4    95        2    other 1     upper
## 2302   jan      219        1   246        1  failure 0     upper
## 2303   jun       17       10    -1        0  unknown 0     upper
## 2304   may      136        2    -1        0  unknown 0   primary
## 2305   nov      147        2   179        3  failure 0   primary
## 2306   apr      218        1   330        2  failure 0     upper
## 2307   nov      766        3    -1        0  unknown 0     upper
## 2308   jul      494        2    -1        0  unknown 0   primary
## 2309   may      566        7    -1        0  unknown 0     upper
## 2310   may      311        3   364        1  failure 0     upper
## 2311   jun      166        2    -1        0  unknown 0   primary
## 2312   aug      599        3    -1        0  unknown 0     upper
## 2313   nov       62        6    -1        0  unknown 0     upper
## 2314   feb      185        1    -1        0  unknown 1     upper
## 2315   may       36        2   176        2  failure 0     upper
## 2316   may      133        1    -1        0  unknown 0     upper
## 2317   may      207        1   342        1  failure 0     upper
## 2318   jul     1973        2    -1        0  unknown 1     upper
## 2319   jul      176        4    -1        0  unknown 0     upper
## 2320   may      162        1    -1        0  unknown 0     upper
## 2321   aug      445        3    -1        0  unknown 0     upper
## 2322   aug      119        2    95        3  success 0     upper
## 2323   apr      129        2   148        4    other 0     upper
## 2324   may      177        3    -1        0  unknown 0     upper
## 2325   jul      125        1    -1        0  unknown 0     upper
## 2326   aug      486        1   286        2  failure 0     upper
## 2327   may      167        4    -1        0  unknown 0     upper
## 2328   may      199        1    -1        0  unknown 0     upper
## 2329   may      201        2   365        2  failure 0     upper
## 2330   jul      142        3    -1        0  unknown 0   primary
## 2331   may      102        2    -1        0  unknown 0   primary
## 2332   jun      445        3    -1        0  unknown 0   unknown
## 2333   jun      654        2    -1        0  unknown 0     upper
## 2334   may      346        1   368        1  failure 0     upper
## 2335   may      283        8    -1        0  unknown 0     upper
## 2336   may      137        2    -1        0  unknown 0   primary
## 2337   apr      487        1    -1        0  unknown 0     upper
## 2338   may       34        1    -1        0  unknown 0     upper
## 2339   apr      429        1    -1        0  unknown 0     upper
## 2340   jun      231        1    -1        0  unknown 0     upper
## 2341   may      777        3    -1        0  unknown 0     upper
## 2342   may      240        1    -1        0  unknown 0     upper
## 2343   nov      412        1    -1        0  unknown 1     upper
## 2344   aug      171        6    -1        0  unknown 0     upper
## 2345   feb      345        5    -1        0  unknown 0     upper
## 2346   jul      280        1    -1        0  unknown 0     upper
## 2347   aug       98        4    -1        0  unknown 0     upper
## 2348   mar      284        2    -1        0  unknown 0     upper
## 2349   apr      114        1    -1        0  unknown 0     upper
## 2350   may      225        1    -1        0  unknown 0   primary
## 2351   may       21        2    -1        0  unknown 0     upper
## 2352   nov       89        1   145        1  failure 0     upper
## 2353   jan      245        1    92        3  success 0     upper
## 2354   may      187        1   367        4  failure 0     upper
## 2355   jul      241        3    -1        0  unknown 0     upper
## 2356   may      192        1    -1        0  unknown 0     upper
## 2357   aug      146        9    -1        0  unknown 0     upper
## 2358   feb       35        7   265        5    other 0     upper
## 2359   sep      100        2    -1        0  unknown 1     upper
## 2360   may       27        5    -1        0  unknown 0   unknown
## 2361   aug       17       18    -1        0  unknown 0   unknown
## 2362   may      170        2    -1        0  unknown 0   primary
## 2363   may      182        2    -1        0  unknown 0     upper
## 2364   jun      327        1    -1        0  unknown 0   unknown
## 2365   jun      285        1    -1        0  unknown 0   primary
## 2366   aug      156        2    -1        0  unknown 1     upper
## 2367   jun      228        5    -1        0  unknown 0     upper
## 2368   aug      226        9    -1        0  unknown 0     upper
## 2369   oct     1246        2    -1        0  unknown 1     upper
## 2370   may       75        4    -1        0  unknown 0     upper
## 2371   may      218        3    -1        0  unknown 0     upper
## 2372   sep      129        2    -1        0  unknown 0     upper
## 2373   may      518        1    -1        0  unknown 0     upper
## 2374   jul      222        1    -1        0  unknown 0   primary
## 2375   sep      140        2    -1        0  unknown 1     upper
## 2376   jun      181        2    -1        0  unknown 1     upper
## 2377   may       49        1    -1        0  unknown 0     upper
## 2378   jul      588        1    -1        0  unknown 0     upper
## 2379   may      152        4   366        3  failure 0     upper
## 2380   jul       72        9    -1        0  unknown 0     upper
## 2381   may      643        2    -1        0  unknown 0     upper
## 2382   oct      316        2    92        3  failure 0     upper
## 2383   may       46        1    -1        0  unknown 0   primary
## 2384   jun      218        2    -1        0  unknown 0   primary
## 2385   may      300        1   370        3  failure 0     upper
## 2386   aug      145       11    -1        0  unknown 0     upper
## 2387   may       43        1    -1        0  unknown 0     upper
## 2388   jul      101        3    -1        0  unknown 0     upper
## 2389   jul      381        4    -1        0  unknown 0     upper
## 2390   apr      245        1    -1        0  unknown 1     upper
## 2391   jul      511        1    -1        0  unknown 0     upper
## 2392   jul      254        2    -1        0  unknown 0     upper
## 2393   aug      321        2    -1        0  unknown 0     upper
## 2394   aug      281        5    -1        0  unknown 0     upper
## 2395   jul       64        4    -1        0  unknown 0     upper
## 2396   aug      108        3   277        1  success 1   unknown
## 2397   may       96        3    -1        0  unknown 0     upper
## 2398   may      206        3    -1        0  unknown 0     upper
## 2399   may      310        1    -1        0  unknown 0     upper
## 2400   nov      399        1    -1        0  unknown 0   primary
## 2401   jun       92        3    -1        0  unknown 0   primary
## 2402   may      333        1    -1        0  unknown 0     upper
## 2403   jul      114        1    -1        0  unknown 0     upper
## 2404   may      245        5   366        2  failure 0     upper
## 2405   may      241        1    -1        0  unknown 0     upper
## 2406   nov       89        1   175        1    other 0     upper
## 2407   may      215        3    -1        0  unknown 0     upper
## 2408   jul      165        2    -1        0  unknown 0     upper
## 2409   may      328        1    -1        0  unknown 0     upper
## 2410   may      157        3    -1        0  unknown 0     upper
## 2411   may      357        1    -1        0  unknown 0   unknown
## 2412   may      230        1    -1        0  unknown 0   primary
## 2413   aug      670        1    -1        0  unknown 1     upper
## 2414   apr       25        2    -1        0  unknown 0     upper
## 2415   may      132        2   359        2  failure 0     upper
## 2416   aug      123        2    -1        0  unknown 0   unknown
## 2417   feb       67        2   202        1  failure 0     upper
## 2418   may      116        2    -1        0  unknown 0     upper
## 2419   may      157        2    -1        0  unknown 0     upper
## 2420   apr       71        2    -1        0  unknown 0   unknown
## 2421   may       15       10    -1        0  unknown 0     upper
## 2422   may      565        2    -1        0  unknown 0     upper
## 2423   aug      140        5    -1        0  unknown 0   primary
## 2424   may      163        1    -1        0  unknown 0   primary
## 2425   jun      375        5    -1        0  unknown 0     upper
## 2426   apr      311        1   336        1  failure 0     upper
## 2427   may      203        2    -1        0  unknown 0   unknown
## 2428   may      185        3    -1        0  unknown 0     upper
## 2429   apr      268        1    -1        0  unknown 0     upper
## 2430   aug      142        2    -1        0  unknown 0     upper
## 2431   may      334        3    -1        0  unknown 0     upper
## 2432   jun     1365        4    -1        0  unknown 0     upper
## 2433   nov      205        1    -1        0  unknown 0   primary
## 2434   may      222        6    -1        0  unknown 0     upper
## 2435   may      279        1    -1        0  unknown 0   primary
## 2436   nov       79        4    -1        0  unknown 0     upper
## 2437   may       17        7    -1        0  unknown 0   primary
## 2438   nov      142        4   169        5  failure 0     upper
## 2439   aug      996        2    -1        0  unknown 0     upper
## 2440   nov      190        2    -1        0  unknown 0     upper
## 2441   may        6        4    -1        0  unknown 0     upper
## 2442   may     1046        3   333        2  success 1     upper
## 2443   may       85        2    -1        0  unknown 0   primary
## 2444   may      254        2    -1        0  unknown 0   primary
## 2445   may      159        2    -1        0  unknown 0     upper
## 2446   aug       76        2    -1        0  unknown 0     upper
## 2447   may      131        1    -1        0  unknown 0     upper
## 2448   may      145        2    -1        0  unknown 0   primary
## 2449   jun      268        1    -1        0  unknown 0     upper
## 2450   aug      162       13    -1        0  unknown 0     upper
## 2451   aug      644        9    -1        0  unknown 0     upper
## 2452   may      113        2   345        1    other 0     upper
## 2453   jul       10        6    -1        0  unknown 0     upper
## 2454   may      565        2    -1        0  unknown 0     upper
## 2455   apr      389        1   266        2    other 0     upper
## 2456   jul      557        5    -1        0  unknown 0     upper
## 2457   may      338        4   288        2    other 0   primary
## 2458   jan       28        1    -1        0  unknown 0     upper
## 2459   feb      351        2    -1        0  unknown 0     upper
## 2460   apr      154        1   182        1  success 0   primary
## 2461   aug       11       22    -1        0  unknown 0     upper
## 2462   jul       66        1    -1        0  unknown 0     upper
## 2463   may      160        1    -1        0  unknown 0     upper
## 2464   nov       85        1    -1        0  unknown 0     upper
## 2465   aug       91        2    -1        0  unknown 0     upper
## 2466   feb      608        1    -1        0  unknown 0     upper
## 2467   may      160        2    -1        0  unknown 0   primary
## 2468   may        4        2    -1        0  unknown 0     upper
## 2469   jul      122        1    72        1  failure 0     upper
## 2470   aug      275        1    -1        0  unknown 0     upper
## 2471   may      266        2    -1        0  unknown 0   primary
## 2472   aug      267        3    -1        0  unknown 0     upper
## 2473   may      193        5    -1        0  unknown 0     upper
## 2474   may       12        8    -1        0  unknown 0     upper
## 2475   aug      119        1    99        3  failure 0     upper
## 2476   may      364        2   343        4  failure 0     upper
## 2477   jun      578        2    -1        0  unknown 1     upper
## 2478   may        8        4    -1        0  unknown 0     upper
## 2479   apr      164        1    -1        0  unknown 0     upper
## 2480   may      685        1   101        1    other 1     upper
## 2481   feb      224        1    -1        0  unknown 0     upper
## 2482   jul      923        2    -1        0  unknown 1   primary
## 2483   may      267        1   369        1  failure 0     upper
## 2484   jun      159        1    -1        0  unknown 0     upper
## 2485   jul      314        2    -1        0  unknown 0     upper
## 2486   apr     1138        2   138        1  failure 1     upper
## 2487   may      427        3    -1        0  unknown 0   primary
## 2488   may      346        4    -1        0  unknown 0     upper
## 2489   jun      539        1    -1        0  unknown 1     upper
## 2490   may      380        3    -1        0  unknown 0     upper
## 2491   may      227        2    -1        0  unknown 0   primary
## 2492   apr       77        2    -1        0  unknown 0     upper
## 2493   jun      138        1    -1        0  unknown 0   primary
## 2494   jun      142        1    -1        0  unknown 0     upper
## 2495   nov      697        2   184        3  failure 0     upper
## 2496   may       84        1   282        4  failure 0     upper
## 2497   feb       52        1   253        2  failure 0     upper
## 2498   may      318        1    -1        0  unknown 0     upper
## 2499   jun      100        1    -1        0  unknown 0     upper
## 2500   may      622        1    -1        0  unknown 0     upper
## 2501   jul      297        5    -1        0  unknown 0     upper
## 2502   apr      300        3   302        3  failure 0   unknown
## 2503   jun      174        1    -1        0  unknown 0     upper
## 2504   jun      562        3    -1        0  unknown 0     upper
## 2505   jul      658        3    -1        0  unknown 1     upper
## 2506   jul      188        2    82        4    other 0     upper
## 2507   sep      190        1    -1        0  unknown 1     upper
## 2508   jun      106        4    -1        0  unknown 0     upper
## 2509   may      101        3    -1        0  unknown 0     upper
## 2510   may       34        1   361        7  failure 0     upper
## 2511   feb       60        1   271        1  failure 0     upper
## 2512   jul      221        3    -1        0  unknown 0     upper
## 2513   jan      373        1    -1        0  unknown 0     upper
## 2514   may      208        3    -1        0  unknown 0   primary
## 2515   jul      356        1    -1        0  unknown 1     upper
## 2516   may      260        1    77        9  failure 0     upper
## 2517   aug       41        2    -1        0  unknown 0     upper
## 2518   nov      696        2    -1        0  unknown 1     upper
## 2519   jun      100        8    -1        0  unknown 0   primary
## 2520   nov      360        2    -1        0  unknown 0     upper
## 2521   jul       83        2    -1        0  unknown 0     upper
## 2522   jul      898        5    -1        0  unknown 0     upper
## 2523   aug      562        2    -1        0  unknown 1   primary
## 2524   sep      204        1   365        1  success 1     upper
## 2525   may      796        1    -1        0  unknown 0     upper
## 2526   may      125        2   370        3  failure 0     upper
## 2527   jun      318        3    -1        0  unknown 0     upper
## 2528   may      207        2    -1        0  unknown 0     upper
## 2529   jun      151        2    -1        0  unknown 0     upper
## 2530   may      157        4    -1        0  unknown 0     upper
## 2531   jun       17        2    -1        0  unknown 0     upper
## 2532   sep      208        2    -1        0  unknown 1     upper
## 2533   jun      269        1    92        2  failure 0     upper
## 2534   may      189        1   326        5  failure 0   primary
## 2535   nov      266        2    -1        0  unknown 0     upper
## 2536   feb      102        4    -1        0  unknown 0     upper
## 2537   may      202        2    -1        0  unknown 0     upper
## 2538   jan       28        1    -1        0  unknown 0   unknown
## 2539   jul      469        4    -1        0  unknown 0   primary
## 2540   may      246        1    -1        0  unknown 0   primary
## 2541   jul      297        1    -1        0  unknown 0   unknown
## 2542   may      179        1    -1        0  unknown 0     upper
## 2543   may      430        1    50        3  success 1     upper
## 2544   jul      166        8    -1        0  unknown 0   primary
## 2545   jul       11        3    -1        0  unknown 0     upper
## 2546   aug      153        1    -1        0  unknown 0   primary
## 2547   oct      212        2    -1        0  unknown 1     upper
## 2548   jun      177        5   138        1  failure 0     upper
## 2549   apr      224        2   182        1  success 1     upper
## 2550   jul       61       14    -1        0  unknown 0     upper
## 2551   nov      288        1    -1        0  unknown 0     upper
## 2552   may       27        1    -1        0  unknown 0   primary
## 2553   jun      190        2    -1        0  unknown 0     upper
## 2554   oct       67        6   141       13  failure 0     upper
## 2555   jul      957        3    -1        0  unknown 0     upper
## 2556   may      306        1   262        1    other 0     upper
## 2557   nov      183        1    -1        0  unknown 0     upper
## 2558   nov      997        2    -1        0  unknown 0   primary
## 2559   jul       77        5    -1        0  unknown 0     upper
## 2560   apr     1096        1    -1        0  unknown 0   primary
## 2561   jul       69        3    -1        0  unknown 0   primary
## 2562   jul      262        2    -1        0  unknown 0     upper
## 2563   jan      643        1    -1        0  unknown 0     upper
## 2564   dec      234        1    -1        0  unknown 0     upper
## 2565   jan     1616        1    95        2  success 1     upper
## 2566   may      118        1    -1        0  unknown 0     upper
## 2567   jul      652        2    -1        0  unknown 0     upper
## 2568   feb       96        2   208        1  failure 0     upper
## 2569   feb      410        1    -1        0  unknown 0     upper
## 2570   feb       91        1    -1        0  unknown 0     upper
## 2571   apr       52        1    -1        0  unknown 0     upper
## 2572   jul      500        2    -1        0  unknown 0     upper
## 2573   apr      417        2    57        3  failure 0     upper
## 2574   jul      341        5    -1        0  unknown 0     upper
## 2575   jan      155        1    -1        0  unknown 0     upper
## 2576   apr      359        1    -1        0  unknown 0     upper
## 2577   jun      522        1   183        2  success 1     upper
## 2578   aug      199        1    -1        0  unknown 1     upper
## 2579   may        9        6    -1        0  unknown 0     upper
## 2580   jun      405        2    -1        0  unknown 0     upper
## 2581   oct      760        1    -1        0  unknown 0     upper
## 2582   may      532        1   358        1  failure 0     upper
## 2583   may      302       16    -1        0  unknown 0     upper
## 2584   jul      181        2    -1        0  unknown 0     upper
## 2585   aug      117        4    -1        0  unknown 0     upper
## 2586   aug       71        4    -1        0  unknown 0   primary
## 2587   nov      190        1    -1        0  unknown 0     upper
## 2588   may      144        1   365        1  failure 0     upper
## 2589   feb       75        2    -1        0  unknown 0     upper
## 2590   aug       82        2    -1        0  unknown 0     upper
## 2591   may      246        1    -1        0  unknown 0     upper
## 2592   aug      171        2    -1        0  unknown 0     upper
## 2593   apr      126        3    -1        0  unknown 0     upper
## 2594   may      280        1    -1        0  unknown 0   primary
## 2595   nov       62        1    -1        0  unknown 0     upper
## 2596   may       43        3   369        2  failure 0     upper
## 2597   may       49        1    -1        0  unknown 0     upper
## 2598   jun      227        1    -1        0  unknown 0   primary
## 2599   may      412        1    -1        0  unknown 0     upper
## 2600   may      480        1    -1        0  unknown 0     upper
## 2601   aug        8       10    -1        0  unknown 0     upper
## 2602   may      147        2    -1        0  unknown 0     upper
## 2603   may      259        3   353        3  failure 0   primary
## 2604   jul       49        4    -1        0  unknown 0     upper
## 2605   may      877        2   345        5  failure 0     upper
## 2606   feb      112        5    94       15  success 0   primary
## 2607   jun      100        3    -1        0  unknown 0     upper
## 2608   may      148        4    -1        0  unknown 0   primary
## 2609   aug       61        4    -1        0  unknown 0     upper
## 2610   aug      229        2    -1        0  unknown 0     upper
## 2611   aug       65        6    -1        0  unknown 0     upper
## 2612   feb      702        2   189        2  failure 0   primary
## 2613   jul      184        3    -1        0  unknown 0     upper
## 2614   feb       61        1   275        1  failure 0     upper
## 2615   may      109        3    -1        0  unknown 0     upper
## 2616   jun      453        1    -1        0  unknown 0     upper
## 2617   may      327        2    -1        0  unknown 0     upper
## 2618   aug      152        2    -1        0  unknown 0     upper
## 2619   feb      430        1    -1        0  unknown 1     upper
## 2620   nov      653        1    -1        0  unknown 1     upper
## 2621   may       88        5    -1        0  unknown 0   unknown
## 2622   may      354        2   335        3    other 0     upper
## 2623   apr      124        1    -1        0  unknown 0     upper
## 2624   may      145        1   365        2  failure 0     upper
## 2625   nov       39        4   182        3  failure 0     upper
## 2626   may       34        9    -1        0  unknown 0   unknown
## 2627   nov      103        1    -1        0  unknown 0   unknown
## 2628   nov      305        2    -1        0  unknown 0     upper
## 2629   nov      188        1    -1        0  unknown 0     upper
## 2630   feb       43        1   261        3  failure 0   primary
## 2631   may      154        2   350        1  failure 0   unknown
## 2632   jun      181        1   320        1    other 0     upper
## 2633   may       38        7   332        6  failure 0   primary
## 2634   feb     1019        2    -1        0  unknown 1     upper
## 2635   may      206        2    -1        0  unknown 0     upper
## 2636   jul      541        7    -1        0  unknown 0     upper
## 2637   aug       82        2    -1        0  unknown 0     upper
## 2638   aug      180        2    -1        0  unknown 0     upper
## 2639   aug       76        8    -1        0  unknown 0   primary
## 2640   aug      123        2    -1        0  unknown 0     upper
## 2641   may     1059        2    -1        0  unknown 1   primary
## 2642   jun      108        2    -1        0  unknown 0     upper
## 2643   nov      120        1    -1        0  unknown 0     upper
## 2644   aug      227        3    -1        0  unknown 0     upper
## 2645   aug      239        4    -1        0  unknown 0     upper
## 2646   may      597        3    -1        0  unknown 0   unknown
## 2647   jan       58        1   266        1  failure 0     upper
## 2648   nov      412        1    -1        0  unknown 0     upper
## 2649   aug       93        9    -1        0  unknown 0     upper
## 2650   nov      324        1   172        1  failure 0     upper
## 2651   nov      149        4   186        1    other 0     upper
## 2652   jun       64        1    -1        0  unknown 0     upper
## 2653   jul      108        2    -1        0  unknown 0     upper
## 2654   jul       44        7    -1        0  unknown 0   unknown
## 2655   aug      151        1    -1        0  unknown 0     upper
## 2656   jun        8        6    -1        0  unknown 0     upper
## 2657   may       98        1    -1        0  unknown 0   primary
## 2658   aug       79        4    -1        0  unknown 0     upper
## 2659   may       99        1    -1        0  unknown 0     upper
## 2660   may      276        1    -1        0  unknown 0     upper
## 2661   nov        7        5    -1        0  unknown 0     upper
## 2662   jun      680        2    -1        0  unknown 0     upper
## 2663   jun      364       13    -1        0  unknown 0     upper
## 2664   may      212        1    -1        0  unknown 0     upper
## 2665   jun      689        3    -1        0  unknown 0     upper
## 2666   jun      171        2    -1        0  unknown 0     upper
## 2667   jun      102        3    -1        0  unknown 0     upper
## 2668   aug      138        1    -1        0  unknown 0     upper
## 2669   jul      483        2    -1        0  unknown 0     upper
## 2670   may      467        4    -1        0  unknown 0   primary
## 2671   nov       74        2   110        4  failure 0     upper
## 2672   aug       88        2    -1        0  unknown 0     upper
## 2673   feb      245        4    -1        0  unknown 0     upper
## 2674   jun      142        2    -1        0  unknown 0     upper
## 2675   feb      110        1    -1        0  unknown 0   primary
## 2676   jun       20        5    -1        0  unknown 0     upper
## 2677   jan       78        2    -1        0  unknown 0     upper
## 2678   apr       71        2   345        2  success 0     upper
## 2679   jun       77        5    -1        0  unknown 0     upper
## 2680   aug       97        4    -1        0  unknown 0     upper
## 2681   feb      206        3    -1        0  unknown 0     upper
## 2682   jul      156        4    -1        0  unknown 0     upper
## 2683   may      700        4    92        7  success 1   primary
## 2684   apr      251        1    -1        0  unknown 0     upper
## 2685   may      172        5   371        5  failure 0     upper
## 2686   jul      161        1    -1        0  unknown 0     upper
## 2687   may       69        1   260        6  failure 0     upper
## 2688   dec      170        1    -1        0  unknown 0     upper
## 2689   oct      287        1    -1        0  unknown 1     upper
## 2690   jun      254        1    96        2  failure 0     upper
## 2691   jun       91        2    -1        0  unknown 0     upper
## 2692   jul       23       16    -1        0  unknown 0     upper
## 2693   aug       90        1    91        1  failure 0     upper
## 2694   jul      117        3    -1        0  unknown 0     upper
## 2695   jun      304        2    -1        0  unknown 0     upper
## 2696   nov      342        2   120        4  failure 0     upper
## 2697   may      129        5    -1        0  unknown 0     upper
## 2698   jul      560        1    -1        0  unknown 1   primary
## 2699   may       75        1    -1        0  unknown 0   unknown
## 2700   jun      245        1    -1        0  unknown 0   primary
## 2701   feb       64        1    -1        0  unknown 0   primary
## 2702   jul      132        3    -1        0  unknown 0     upper
## 2703   may       20       11    -1        0  unknown 0     upper
## 2704   may      157        5    -1        0  unknown 0     upper
## 2705   may       67        1    -1        0  unknown 0     upper
## 2706   oct      518        1   147        2  success 1     upper
## 2707   apr      148        2    -1        0  unknown 0     upper
## 2708   jan      372        1   196        2  success 1   primary
## 2709   nov       79        1    -1        0  unknown 0     upper
## 2710   aug      391        3   106        1  failure 1   unknown
## 2711   jun       94        2    -1        0  unknown 0   unknown
## 2712   nov      895        1   183        2  failure 0     upper
## 2713   jun      356        2    -1        0  unknown 0   primary
## 2714   jun      541        3    -1        0  unknown 1     upper
## 2715   oct      282        2    -1        0  unknown 1     upper
## 2716   may      480        2    -1        0  unknown 0   primary
## 2717   may      258        9    -1        0  unknown 0   primary
## 2718   may      105        1    -1        0  unknown 0     upper
## 2719   may      358        2   174        1  failure 0   primary
## 2720   nov      214        2   174        2  success 0     upper
## 2721   aug       12       16    -1        0  unknown 0     upper
## 2722   aug      484        4    -1        0  unknown 0     upper
## 2723   nov       36        3    -1        0  unknown 0     upper
## 2724   feb      475        1    -1        0  unknown 0     upper
## 2725   aug      145        2    -1        0  unknown 0     upper
## 2726   jun       48        1    -1        0  unknown 0     upper
## 2727   may      233        1    -1        0  unknown 0   unknown
## 2728   nov      342        2    -1        0  unknown 0     upper
## 2729   nov       47        1    -1        0  unknown 0     upper
## 2730   may      149        1    -1        0  unknown 0     upper
## 2731   sep      679        1    -1        0  unknown 1     upper
## 2732   feb      184        2    -1        0  unknown 0   unknown
## 2733   jul       32        7    -1        0  unknown 0     upper
## 2734   jun      167        1    -1        0  unknown 0     upper
## 2735   may      290        2    -1        0  unknown 0     upper
## 2736   jul       63        1    -1        0  unknown 0     upper
## 2737   apr      197        1    -1        0  unknown 0     upper
## 2738   jun      361        3    -1        0  unknown 0     upper
## 2739   nov      191        2    -1        0  unknown 0   unknown
## 2740   feb      637        1   183        1  success 1     upper
## 2741   jul      658        2    -1        0  unknown 1     upper
## 2742   may      789        3    -1        0  unknown 1     upper
## 2743   jun      216        2    -1        0  unknown 0     upper
## 2744   oct       78        3    -1        0  unknown 0     upper
## 2745   aug      315        1    -1        0  unknown 0   primary
## 2746   jul       33       31    -1        0  unknown 0     upper
## 2747   jul      406        4    -1        0  unknown 0     upper
## 2748   jun      139        2    -1        0  unknown 0   primary
## 2749   feb      153        1    92       13  success 1     upper
## 2750   oct      521        2    -1        0  unknown 0   unknown
## 2751   jul      114        2    -1        0  unknown 0     upper
## 2752   may       63        2    -1        0  unknown 0     upper
## 2753   may       39        1    -1        0  unknown 0     upper
## 2754   apr       44        1    -1        0  unknown 0     upper
## 2755   may      126        1    -1        0  unknown 0   primary
## 2756   jan      354        1   197        1  failure 0     upper
## 2757   jul      117        4    -1        0  unknown 0   unknown
## 2758   may       15        7   178        1    other 0     upper
## 2759   aug      300        2    -1        0  unknown 0     upper
## 2760   may     1534        2    -1        0  unknown 0     upper
## 2761   aug      211        2    -1        0  unknown 0   unknown
## 2762   sep      299        1    -1        0  unknown 1     upper
## 2763   jun     1062        4    -1        0  unknown 0     upper
## 2764   oct      280        2    97        3  success 0     upper
## 2765   aug       58        2    -1        0  unknown 0     upper
## 2766   jul      103        4    -1        0  unknown 0   primary
## 2767   feb      415        2   272        2  failure 0   primary
## 2768   nov      163        2   110       15  failure 0     upper
## 2769   feb       71        1    -1        0  unknown 0     upper
## 2770   jul       88        3    -1        0  unknown 0     upper
## 2771   may      127        1    -1        0  unknown 0     upper
## 2772   may      185        7    -1        0  unknown 0     upper
## 2773   apr      277        2   333        1  failure 0     upper
## 2774   aug      711        3    -1        0  unknown 0     upper
## 2775   jun      142        3    -1        0  unknown 0   unknown
## 2776   nov       65        3    -1        0  unknown 0   primary
## 2777   jan      103        2    -1        0  unknown 0     upper
## 2778   may      152        1    -1        0  unknown 0     upper
## 2779   feb       71        1   243        3  failure 0     upper
## 2780   aug      255        1    -1        0  unknown 0     upper
## 2781   feb      106        4    -1        0  unknown 0   primary
## 2782   jun      389        1    -1        0  unknown 0     upper
## 2783   aug      160        6    -1        0  unknown 0   primary
## 2784   aug      299        3    -1        0  unknown 0     upper
## 2785   jun       78        7    -1        0  unknown 0     upper
## 2786   jul      112        1    -1        0  unknown 0     upper
## 2787   nov      133        3    89        1  failure 0     upper
## 2788   nov       48        2    -1        0  unknown 0   primary
## 2789   jun      106        2    -1        0  unknown 0     upper
## 2790   may      185        4    -1        0  unknown 0     upper
## 2791   jun       71       12    -1        0  unknown 0     upper
## 2792   may      229        2    -1        0  unknown 0   primary
## 2793   aug      115        1    93        2  failure 0   primary
## 2794   aug       80       10    -1        0  unknown 0     upper
## 2795   aug      306        4    -1        0  unknown 0     upper
## 2796   sep      234        1   100        1  failure 1     upper
## 2797   may      233        2    -1        0  unknown 0     upper
## 2798   may      197        2    -1        0  unknown 0     upper
## 2799   may      297        3    -1        0  unknown 0   primary
## 2800   aug      169        5    -1        0  unknown 0   primary
## 2801   nov      583        2    -1        0  unknown 0     upper
## 2802   nov      116        2    -1        0  unknown 0     upper
## 2803   may      227        9    -1        0  unknown 0     upper
## 2804   nov     1258        2   122        2    other 1     upper
## 2805   jun       87        7    -1        0  unknown 0   primary
## 2806   aug      132        2    -1        0  unknown 0     upper
## 2807   may      120        1    -1        0  unknown 0     upper
## 2808   nov      173        1    -1        0  unknown 0     upper
## 2809   jul      309        1    -1        0  unknown 0     upper
## 2810   jul      374        3    -1        0  unknown 0   primary
## 2811   jul      173        6    -1        0  unknown 0     upper
## 2812   jul      136        1    -1        0  unknown 0     upper
## 2813   jun      607        2    -1        0  unknown 0     upper
## 2814   feb       49        6    -1        0  unknown 0     upper
## 2815   jan      227        1    -1        0  unknown 0     upper
## 2816   aug      195        1    -1        0  unknown 1     upper
## 2817   may      181        6    -1        0  unknown 0   primary
## 2818   may      434        2    -1        0  unknown 0   unknown
## 2819   mar       59        2    -1        0  unknown 0   unknown
## 2820   may       50        2    -1        0  unknown 0     upper
## 2821   may      198        2    88        1    other 0     upper
## 2822   jul      409        4    -1        0  unknown 0     upper
## 2823   may     1576        1    -1        0  unknown 0     upper
## 2824   may      404        1    -1        0  unknown 0     upper
## 2825   apr       70        1   344        1  failure 0   primary
## 2826   jun       96        1    -1        0  unknown 0     upper
## 2827   may      131        2    -1        0  unknown 1   unknown
## 2828   feb       68        1    -1        0  unknown 0     upper
## 2829   jul      134        2    -1        0  unknown 0     upper
## 2830   jul      182        1    -1        0  unknown 0     upper
## 2831   may      181        2    -1        0  unknown 0     upper
## 2832   nov      405        2    -1        0  unknown 0     upper
## 2833   aug      162        3    -1        0  unknown 0     upper
## 2834   may      186        4   358       11  failure 0     upper
## 2835   may       96        5    -1        0  unknown 0     upper
## 2836   may       28        1    -1        0  unknown 0     upper
## 2837   may      143        1    -1        0  unknown 0     upper
## 2838   jan      103        3    -1        0  unknown 0     upper
## 2839   apr      609        2   266        2  failure 0     upper
## 2840   aug      265       16    -1        0  unknown 0     upper
## 2841   may      169        1   346        1  failure 0   primary
## 2842   jun      196        2    -1        0  unknown 0     upper
## 2843   aug      125        4    -1        0  unknown 0     upper
## 2844   jul     1130        8    -1        0  unknown 1     upper
## 2845   aug      295        3    -1        0  unknown 0     upper
## 2846   aug      153        8    -1        0  unknown 0     upper
## 2847   nov      454        1    -1        0  unknown 1     upper
## 2848   may      212        4   312        6    other 0   unknown
## 2849   may      107        2    -1        0  unknown 0     upper
## 2850   aug      288        1   181        2  failure 1     upper
## 2851   may      192        1    -1        0  unknown 0     upper
## 2852   aug       49        7    -1        0  unknown 0     upper
## 2853   may      224        1    -1        0  unknown 0     upper
## 2854   jul      439        1    -1        0  unknown 0   primary
## 2855   may      133        1    -1        0  unknown 0     upper
## 2856   may      124        1    -1        0  unknown 0     upper
## 2857   may      165        2    -1        0  unknown 0     upper
## 2858   feb       87        2    -1        0  unknown 1     upper
## 2859   aug      221       12    -1        0  unknown 0     upper
## 2860   may      129        1    -1        0  unknown 0     upper
## 2861   sep      175        1   184        2  success 1     upper
## 2862   may       66        3    -1        0  unknown 0     upper
## 2863   apr      278        3    -1        0  unknown 1   unknown
## 2864   jul      138        3    -1        0  unknown 0     upper
## 2865   may      359        6    -1        0  unknown 0     upper
## 2866   may      167        1    -1        0  unknown 0     upper
## 2867   may      341        1    -1        0  unknown 0     upper
## 2868   apr      339        1    -1        0  unknown 0     upper
## 2869   may      156       13    -1        0  unknown 0     upper
## 2870   may       85       16    -1        0  unknown 0     upper
## 2871   may      637        3    -1        0  unknown 0     upper
## 2872   aug      129        9    -1        0  unknown 0     upper
## 2873   aug      358        2    -1        0  unknown 0     upper
## 2874   feb       20        1    -1        0  unknown 0     upper
## 2875   aug      142        2    -1        0  unknown 0     upper
## 2876   aug      141        1    -1        0  unknown 0     upper
## 2877   jun      174        9    -1        0  unknown 0     upper
## 2878   nov       10        3    -1        0  unknown 0     upper
## 2879   jun      307        2    -1        0  unknown 0   unknown
## 2880   jul     1739        7    -1        0  unknown 0     upper
## 2881   may      360        1   173        1    other 0     upper
## 2882   sep      169        1    -1        0  unknown 1   unknown
## 2883   apr      122        1   338        2  failure 0   primary
## 2884   jun      130        2    -1        0  unknown 0     upper
## 2885   may      181        4    -1        0  unknown 0     upper
## 2886   may      267        3    -1        0  unknown 0   primary
## 2887   may      115        6    -1        0  unknown 0     upper
## 2888   jul      105       10    -1        0  unknown 0     upper
## 2889   nov      213        1    -1        0  unknown 0   primary
## 2890   jul      195        2    91       10  success 1     upper
## 2891   jun      131        2    -1        0  unknown 0     upper
## 2892   aug      126        2    -1        0  unknown 0     upper
## 2893   oct      301        1   216        2  failure 0     upper
## 2894   feb      277        1   169        2  failure 0     upper
## 2895   jul      551        8    -1        0  unknown 0     upper
## 2896   jul     1127        3    -1        0  unknown 1     upper
## 2897   aug      103        6    -1        0  unknown 0     upper
## 2898   nov      222        2    -1        0  unknown 0     upper
## 2899   nov      153        2   183        2  failure 0     upper
## 2900   may      173        1    -1        0  unknown 0     upper
## 2901   may      427        1    -1        0  unknown 1     upper
## 2902   apr       78        1    84        1  failure 0     upper
## 2903   jun      108        2    -1        0  unknown 0     upper
## 2904   feb      335        1    -1        0  unknown 0     upper
## 2905   may      160        1    -1        0  unknown 0     upper
## 2906   jul      309        2    -1        0  unknown 0     upper
## 2907   aug      106        2    -1        0  unknown 0     upper
## 2908   feb      133        3     5        2    other 0     upper
## 2909   aug       31        2    -1        0  unknown 0     upper
## 2910   jul      711        1    -1        0  unknown 0     upper
## 2911   jul      496        2   182       11  success 1     upper
## 2912   jun       73        1    -1        0  unknown 0     upper
## 2913   may       71        5    40        4  failure 0     upper
## 2914   aug       82        2    -1        0  unknown 0     upper
## 2915   nov      210        1    93        1  success 1   primary
## 2916   may       43        1    -1        0  unknown 0     upper
## 2917   may      798        2    -1        0  unknown 1     upper
## 2918   jun      237        3    -1        0  unknown 0     upper
## 2919   aug       82        2    -1        0  unknown 0     upper
## 2920   may       66        1   359        1  failure 0     upper
## 2921   feb      841        3    -1        0  unknown 0     upper
## 2922   may      376        2    -1        0  unknown 0     upper
## 2923   nov      217        1    70        2  failure 1     upper
## 2924   nov       76        3    -1        0  unknown 0     upper
## 2925   oct      216        1    57        1  failure 1     upper
## 2926   aug       78        2    -1        0  unknown 0     upper
## 2927   jun      243        1    -1        0  unknown 0     upper
## 2928   apr      249        1    86        3  failure 0     upper
## 2929   aug      190        2    -1        0  unknown 0     upper
## 2930   jun      685        3    -1        0  unknown 1   unknown
## 2931   jan      430        1    -1        0  unknown 0     upper
## 2932   may      206        1    -1        0  unknown 0     upper
## 2933   aug      272        4    -1        0  unknown 0     upper
## 2934   may      103        3    -1        0  unknown 0     upper
## 2935   may      123        1    -1        0  unknown 0     upper
## 2936   may      875        5    -1        0  unknown 0     upper
## 2937   may       66        1    -1        0  unknown 0     upper
## 2938   may      153        2    -1        0  unknown 1     upper
## 2939   aug      204        3   105        1  failure 1     upper
## 2940   may      300        1    -1        0  unknown 0     upper
## 2941   may      163        2    -1        0  unknown 0   primary
## 2942   aug       69       17    -1        0  unknown 0     upper
## 2943   aug      813        2    -1        0  unknown 0     upper
## 2944   jul      991        5    -1        0  unknown 1     upper
## 2945   feb      169        1   191        3  success 1     upper
## 2946   feb      398        4   189       12  success 0     upper
## 2947   may      168        1   265        2  failure 0     upper
## 2948   jan      413        3    -1        0  unknown 0     upper
## 2949   may       81        9    -1        0  unknown 0     upper
## 2950   jun       61        2    -1        0  unknown 0   primary
## 2951   may      102        3    -1        0  unknown 0     upper
## 2952   jul       15       19    -1        0  unknown 0     upper
## 2953   jan      404        2   251        6  failure 0     upper
## 2954   may      239        2    -1        0  unknown 0     upper
## 2955   jan      150        1    -1        0  unknown 0     upper
## 2956   nov      640        1    -1        0  unknown 0     upper
## 2957   may      523        2   363        2  failure 0     upper
## 2958   may      254        4    -1        0  unknown 0     upper
## 2959   feb       64        2    -1        0  unknown 0     upper
## 2960   jul      363        1    -1        0  unknown 0     upper
## 2961   jun      376        3    -1        0  unknown 0   unknown
## 2962   may      202        4    -1        0  unknown 0   primary
## 2963   may      171        1    -1        0  unknown 0     upper
## 2964   may      333        3    -1        0  unknown 0     upper
## 2965   jun      232        2    -1        0  unknown 1     upper
## 2966   apr      766        3    84        3  success 1     upper
## 2967   feb      439        2    -1        0  unknown 0     upper
## 2968   jun       53        1    -1        0  unknown 0   primary
## 2969   may      112        1    -1        0  unknown 0     upper
## 2970   aug      356        1    -1        0  unknown 0     upper
## 2971   jun      973        1    -1        0  unknown 1   primary
## 2972   may      591        1    -1        0  unknown 1   primary
## 2973   jun      184        1    -1        0  unknown 0     upper
## 2974   jul      120       11    -1        0  unknown 0     upper
## 2975   aug      147       10    -1        0  unknown 0   primary
## 2976   may      125        1    -1        0  unknown 0     upper
## 2977   may      179        1    -1        0  unknown 0   primary
## 2978   dec      137        1   122        3  failure 0     upper
## 2979   sep      961        5    -1        0  unknown 1   primary
## 2980   may       67        2    -1        0  unknown 0     upper
## 2981   aug      231        4    -1        0  unknown 0     upper
## 2982   may      114        3    -1        0  unknown 0     upper
## 2983   aug      961        4    -1        0  unknown 1     upper
## 2984   may      171       10    -1        0  unknown 0     upper
## 2985   aug      744        7    -1        0  unknown 0     upper
## 2986   may      194        3    -1        0  unknown 0     upper
## 2987   jun      255        1    -1        0  unknown 1   primary
## 2988   apr      557        1    -1        0  unknown 0   primary
## 2989   feb       82        1   244        1  failure 0   primary
## 2990   may      151        8    -1        0  unknown 0     upper
## 2991   nov      520        1    -1        0  unknown 0     upper
## 2992   may      161        1    -1        0  unknown 0     upper
## 2993   oct      172        1    -1        0  unknown 0   primary
## 2994   apr       18        1    -1        0  unknown 0     upper
## 2995   may      512        5    -1        0  unknown 0     upper
## 2996   aug      203        1    -1        0  unknown 0     upper
## 2997   jun      263        1    -1        0  unknown 0   primary
## 2998   oct      112        1    -1        0  unknown 1     upper
## 2999   jan      118        1    -1        0  unknown 0   primary
## 3000   feb      149        2    -1        0  unknown 0     upper
## 3001   may      230        1    -1        0  unknown 0   primary
## 3002   nov      718        1    -1        0  unknown 0     upper
## 3003   jun       59        4    -1        0  unknown 0     upper
## 3004   may       61        1   298        2  failure 0     upper
## 3005   apr      179        1   334        1    other 0     upper
## 3006   aug      669        2    -1        0  unknown 1     upper
## 3007   aug      343        5    -1        0  unknown 0     upper
## 3008   jun       41        7    -1        0  unknown 0   unknown
## 3009   jan      423        1    -1        0  unknown 1     upper
## 3010   apr      445        1   135        3  failure 0     upper
## 3011   apr      224        1    -1        0  unknown 0     upper
## 3012   may      408        2   350        1  failure 0   primary
## 3013   apr      533        1    -1        0  unknown 0     upper
## 3014   may      444        1    -1        0  unknown 0     upper
## 3015   oct      181        2   500        1  failure 0     upper
## 3016   jul      158        2    -1        0  unknown 0     upper
## 3017   may      131        1    -1        0  unknown 0   primary
## 3018   may      588        2    -1        0  unknown 0     upper
## 3019   apr      232        1   335        1  failure 0   primary
## 3020   jun      212        1    -1        0  unknown 0     upper
## 3021   jun      348        1    -1        0  unknown 0     upper
## 3022   jan      138        2   164        4    other 0     upper
## 3023   may       81        4    -1        0  unknown 0     upper
## 3024   aug       34       14    -1        0  unknown 0   primary
## 3025   jun      339        2    -1        0  unknown 0     upper
## 3026   may       14        3   355        4    other 0     upper
## 3027   may      349        1    -1        0  unknown 0     upper
## 3028   feb       88        2    -1        0  unknown 0     upper
## 3029   may      211        3    -1        0  unknown 0     upper
## 3030   aug      139        8    -1        0  unknown 0   primary
## 3031   may      170        2    87        1  failure 0     upper
## 3032   jul      118        2    -1        0  unknown 0   unknown
## 3033   apr      326        1   319        1  failure 0   primary
## 3034   oct      509        1    -1        0  unknown 1   unknown
## 3035   apr      232        1   147        2  failure 0     upper
## 3036   jun      114        4    -1        0  unknown 0     upper
## 3037   jun       87        6    -1        0  unknown 0     upper
## 3038   jun      138        2    -1        0  unknown 0   primary
## 3039   may      131        2    -1        0  unknown 0     upper
## 3040   jun      170        7    -1        0  unknown 0     upper
## 3041   aug      187        4    -1        0  unknown 0     upper
## 3042   jul      426        4    -1        0  unknown 0     upper
## 3043   jun      126        4    -1        0  unknown 0   primary
## 3044   aug      159        1    -1        0  unknown 0     upper
## 3045   may      240        2    -1        0  unknown 0   primary
## 3046   jun       95        1    -1        0  unknown 1     upper
## 3047   jul      605        1    -1        0  unknown 0     upper
## 3048   may      449        1    -1        0  unknown 0     upper
## 3049   may       24        1    -1        0  unknown 0   primary
## 3050   aug      446        1    -1        0  unknown 0     upper
## 3051   oct       91        2    -1        0  unknown 0     upper
## 3052   may      193        2    -1        0  unknown 0     upper
## 3053   apr       15        2    -1        0  unknown 0     upper
## 3054   may       14        4    -1        0  unknown 0   primary
## 3055   may      410        1    -1        0  unknown 0     upper
## 3056   jun      254        1    -1        0  unknown 0     upper
## 3057   jul       88        9    -1        0  unknown 0     upper
## 3058   nov      246        2    -1        0  unknown 0     upper
## 3059   jun      117        2    -1        0  unknown 0     upper
## 3060   nov      172        3    -1        0  unknown 0     upper
## 3061   nov       80        1    -1        0  unknown 0     upper
## 3062   aug      119        4    -1        0  unknown 0     upper
## 3063   nov      195        3   112        8    other 0     upper
## 3064   jun      236        1    -1        0  unknown 0     upper
## 3065   aug      153        1     1        7  success 0     upper
## 3066   may      206        6   337        6  failure 0   primary
## 3067   jan      224        2    -1        0  unknown 0     upper
## 3068   jun       36       24    -1        0  unknown 0     upper
## 3069   may       74        1    -1        0  unknown 0     upper
## 3070   jul      720        2    -1        0  unknown 0     upper
## 3071   aug     1040        6    -1        0  unknown 1     upper
## 3072   apr      691        1    -1        0  unknown 0     upper
## 3073   aug      384        6    -1        0  unknown 1     upper
## 3074   may      644        1    -1        0  unknown 0     upper
## 3075   jan      207        3    -1        0  unknown 0     upper
## 3076   may      470        2   166        2  failure 0     upper
## 3077   may      863        3    -1        0  unknown 1   primary
## 3078   jun      227        1    -1        0  unknown 0     upper
## 3079   jun      123        1    -1        0  unknown 0     upper
## 3080   jun       85        2    -1        0  unknown 0     upper
## 3081   nov       64        1    -1        0  unknown 0     upper
## 3082   may      150        1    -1        0  unknown 0     upper
## 3083   may      755        1    -1        0  unknown 0     upper
## 3084   feb      442        2    -1        0  unknown 1     upper
## 3085   jun      119        1    -1        0  unknown 0     upper
## 3086   may      336        1    -1        0  unknown 0     upper
## 3087   aug      528        2    -1        0  unknown 1     upper
## 3088   jun       14       11    -1        0  unknown 0     upper
## 3089   jun       90        4    -1        0  unknown 0     upper
## 3090   jul      194        1    -1        0  unknown 0     upper
## 3091   jun       91        1    -1        0  unknown 0     upper
## 3092   may      243        2    -1        0  unknown 0     upper
## 3093   nov     1031        6    -1        0  unknown 0     upper
## 3094   jul      129        2    -1        0  unknown 0     upper
## 3095   feb      221        2   272        1  failure 0     upper
## 3096   jul       97        1    -1        0  unknown 0     upper
## 3097   may      181       16    -1        0  unknown 0     upper
## 3098   apr      280        4   287        3    other 0   primary
## 3099   jan      706        1    -1        0  unknown 0     upper
## 3100   apr      379        3   202        1  success 1     upper
## 3101   aug      210        5    -1        0  unknown 0     upper
## 3102   aug      105        4    -1        0  unknown 0     upper
## 3103   nov      854        1    -1        0  unknown 1     upper
## 3104   jan      196        1    -1        0  unknown 0     upper
## 3105   may       17        3    -1        0  unknown 0   primary
## 3106   aug      290        2    -1        0  unknown 0     upper
## 3107   may      514        5    -1        0  unknown 0     upper
## 3108   aug       84        4    -1        0  unknown 0     upper
## 3109   feb      255        2   555        6  success 1     upper
## 3110   nov      151        1    -1        0  unknown 0     upper
## 3111   nov       73        1    -1        0  unknown 0     upper
## 3112   apr      298        4    -1        0  unknown 1     upper
## 3113   jul      262        3    -1        0  unknown 0     upper
## 3114   may      455        1    -1        0  unknown 0   primary
## 3115   may      432        2    -1        0  unknown 0     upper
## 3116   feb      233        3    -1        0  unknown 0     upper
## 3117   aug      122        2    -1        0  unknown 0   primary
## 3118   jul       73        4    -1        0  unknown 0     upper
## 3119   may       11        1    -1        0  unknown 0   primary
## 3120   may      477        1    -1        0  unknown 0     upper
## 3121   sep      244        1    92        3  success 1     upper
## 3122   aug       64        7    -1        0  unknown 0     upper
## 3123   may      352        3    -1        0  unknown 0     upper
## 3124   nov       51        2   140       11  failure 0     upper
## 3125   jul      330        2    -1        0  unknown 0     upper
## 3126   nov       23        1    -1        0  unknown 0     upper
## 3127   jun      209       12    -1        0  unknown 0     upper
## 3128   nov      138        1    -1        0  unknown 0     upper
## 3129   may      155        1    -1        0  unknown 0     upper
## 3130   jun      165        2    -1        0  unknown 0   unknown
## 3131   nov      180        3    -1        0  unknown 0     upper
## 3132   may      278        1    -1        0  unknown 0     upper
## 3133   may      229        2    -1        0  unknown 0   unknown
## 3134   may      206        1    -1        0  unknown 0     upper
## 3135   may      518        1    -1        0  unknown 0     upper
## 3136   jan      225        1    -1        0  unknown 0   primary
## 3137   mar      152        1   348        1  failure 0   unknown
## 3138   aug      188        1    -1        0  unknown 0   primary
## 3139   may      323        4    -1        0  unknown 0     upper
## 3140   jul      803        1    -1        0  unknown 0     upper
## 3141   may       22        1    -1        0  unknown 0   unknown
## 3142   aug      428        2   336        6  failure 0     upper
## 3143   nov      190        1   104        1  failure 0     upper
## 3144   aug      390        2    -1        0  unknown 0     upper
## 3145   may      836       12    -1        0  unknown 0     upper
## 3146   may      231        2    -1        0  unknown 0     upper
## 3147   may      144        2    -1        0  unknown 0     upper
## 3148   may       57        6    -1        0  unknown 0     upper
## 3149   may      201        2    -1        0  unknown 0   unknown
## 3150   jun      149        8    -1        0  unknown 0     upper
## 3151   may       17        1   365        2    other 0     upper
## 3152   apr     1594        1   148        1  failure 1     upper
## 3153   may      218        7    -1        0  unknown 0     upper
## 3154   jul      246        2    -1        0  unknown 0     upper
## 3155   may      161        1    -1        0  unknown 0     upper
## 3156   apr      609        1   303        5  failure 0     upper
## 3157   jul       74        2    -1        0  unknown 0     upper
## 3158   jul      392        2    -1        0  unknown 0     upper
## 3159   feb      170        1    -1        0  unknown 0   primary
## 3160   aug       57        2    -1        0  unknown 0   primary
## 3161   apr       74        2    -1        0  unknown 0     upper
## 3162   jul      250        4   415        2  failure 1     upper
## 3163   may      700        3    -1        0  unknown 1     upper
## 3164   may      765        1    -1        0  unknown 0     upper
## 3165   may      159        3    -1        0  unknown 0     upper
## 3166   aug      104        2    -1        0  unknown 0     upper
## 3167   may      828        3    -1        0  unknown 1   primary
## 3168   may      899        3    -1        0  unknown 0     upper
## 3169   nov      613        1    -1        0  unknown 0     upper
## 3170   may      164        1    -1        0  unknown 0     upper
## 3171   jan      517        2    -1        0  unknown 0     upper
## 3172   jun      273       27    -1        0  unknown 0   primary
## 3173   may      304        2   259        2  failure 0     upper
## 3174   jun       57        2   304        1  failure 0     upper
## 3175   may      112        4   369        2    other 0   unknown
## 3176   apr      105        2    -1        0  unknown 0   primary
## 3177   apr      239        3    -1        0  unknown 0     upper
## 3178   jul      275        1    -1        0  unknown 1     upper
## 3179   nov      325        2    -1        0  unknown 0     upper
## 3180   nov      158        7    -1        0  unknown 0   primary
## 3181   jul      113        1    -1        0  unknown 0   primary
## 3182   may      185        2    -1        0  unknown 0     upper
## 3183   may      352        1    -1        0  unknown 0     upper
## 3184   may       57        4    -1        0  unknown 0     upper
## 3185   oct      305        1    -1        0  unknown 1     upper
## 3186   jul       49        2    -1        0  unknown 0     upper
## 3187   may      266        1    -1        0  unknown 0     upper
## 3188   may       91        1    -1        0  unknown 0     upper
## 3189   may       19       15    -1        0  unknown 0     upper
## 3190   may       65        2   299        3    other 0     upper
## 3191   jul      165        1    -1        0  unknown 0     upper
## 3192   aug     1015        1    -1        0  unknown 0     upper
## 3193   may      453        4    -1        0  unknown 0     upper
## 3194   jul       62        1    -1        0  unknown 0     upper
## 3195   jan       73        1    -1        0  unknown 0     upper
## 3196   may      104        1    -1        0  unknown 0     upper
## 3197   jun       81        4    -1        0  unknown 0     upper
## 3198   jun     1558        1    -1        0  unknown 1   primary
## 3199   aug       73        3   200        2  failure 0     upper
## 3200   oct      604        1    91        4  failure 1     upper
## 3201   aug       61        1    84        1  failure 0     upper
## 3202   jul      107        3    -1        0  unknown 0     upper
## 3203   may       67        4    -1        0  unknown 0     upper
## 3204   feb      192        4    -1        0  unknown 0     upper
## 3205   aug      163        1    -1        0  unknown 0     upper
## 3206   nov      722        3   175        2  failure 0     upper
## 3207   may       30        3    -1        0  unknown 0   primary
## 3208   may      146        4    -1        0  unknown 0     upper
## 3209   jun      172        2    -1        0  unknown 0     upper
## 3210   apr      473        2   339        1  failure 0   primary
## 3211   may      440        2    -1        0  unknown 0   primary
## 3212   jul      574        2    -1        0  unknown 1     upper
## 3213   may      305        1    -1        0  unknown 0   primary
## 3214   nov      304        2    -1        0  unknown 0     upper
## 3215   apr      472        2    -1        0  unknown 0     upper
## 3216   sep      245        3    -1        0  unknown 1   primary
## 3217   may      265        1    -1        0  unknown 0     upper
## 3218   sep      109        3   276        8    other 0   primary
## 3219   may      180        1    -1        0  unknown 0   unknown
## 3220   may      117        1    -1        0  unknown 0   primary
## 3221   jun      352        2   122        2  failure 1     upper
## 3222   nov      713        6    -1        0  unknown 0     upper
## 3223   nov       88        2    -1        0  unknown 0     upper
## 3224   jun      198        1   651        7    other 0     upper
## 3225   aug      121        1    -1        0  unknown 0     upper
## 3226   may       52        1    -1        0  unknown 0   primary
## 3227   may      234       13    -1        0  unknown 0     upper
## 3228   may      165        5    -1        0  unknown 0     upper
## 3229   may       87        1    -1        0  unknown 0     upper
## 3230   aug      231        3    -1        0  unknown 0     upper
## 3231   may      629        2    -1        0  unknown 0   primary
## 3232   jun      614        2    -1        0  unknown 1     upper
## 3233   oct      133        2    -1        0  unknown 0     upper
## 3234   may      155        1    -1        0  unknown 0     upper
## 3235   may      236        1    -1        0  unknown 0     upper
## 3236   jul       97        3    -1        0  unknown 0     upper
## 3237   aug       13       21    -1        0  unknown 0     upper
## 3238   oct      353        1    -1        0  unknown 1     upper
## 3239   oct       98        1    -1        0  unknown 0     upper
## 3240   jul      139        5    -1        0  unknown 1     upper
## 3241   may      143        2   343        3  failure 0     upper
## 3242   jun      230        2    -1        0  unknown 0     upper
## 3243   jul       44        4    -1        0  unknown 0   unknown
## 3244   may      182        2    -1        0  unknown 0   primary
## 3245   aug      431        5    -1        0  unknown 0     upper
## 3246   may      253        1    -1        0  unknown 0     upper
## 3247   aug      275        4    -1        0  unknown 0     upper
## 3248   may      160        1    -1        0  unknown 0     upper
## 3249   feb       64        2    -1        0  unknown 0     upper
## 3250   may       70        2    -1        0  unknown 0     upper
## 3251   jun       40        1    -1        0  unknown 0     upper
## 3252   aug      143        4    -1        0  unknown 0     upper
## 3253   may      312        1    -1        0  unknown 0     upper
## 3254   nov       51        4    -1        0  unknown 0     upper
## 3255   jul      538        1    -1        0  unknown 0   primary
## 3256   may       73        1    -1        0  unknown 0     upper
## 3257   nov      690        3    -1        0  unknown 0     upper
## 3258   nov       99        3    -1        0  unknown 0     upper
## 3259   jun      348        6    94        6  failure 0   primary
## 3260   may      236       10    -1        0  unknown 0   primary
## 3261   jul      127        8    -1        0  unknown 0     upper
## 3262   may       88        5    -1        0  unknown 0     upper
## 3263   nov      977        3    -1        0  unknown 1     upper
## 3264   jul      238        3    -1        0  unknown 0     upper
## 3265   may      231        2   362        1    other 0     upper
## 3266   may       38        4    -1        0  unknown 0   primary
## 3267   may      193        1    -1        0  unknown 0     upper
## 3268   nov      237        1    -1        0  unknown 0     upper
## 3269   jul      347        4    -1        0  unknown 0     upper
## 3270   may      133        1   353        5    other 0     upper
## 3271   jul       81        1    -1        0  unknown 0     upper
## 3272   aug       50        2    -1        0  unknown 0     upper
## 3273   jun      123        1    -1        0  unknown 0   primary
## 3274   aug      632        6    -1        0  unknown 0   unknown
## 3275   may       44        1    -1        0  unknown 0     upper
## 3276   may      446       12    -1        0  unknown 0     upper
## 3277   apr      114        1   345        2  failure 0     upper
## 3278   jun      382        3    -1        0  unknown 0     upper
## 3279   may      167        3    -1        0  unknown 0     upper
## 3280   mar      248        1    -1        0  unknown 0     upper
## 3281   aug      220        4    -1        0  unknown 0     upper
## 3282   aug      184        7    -1        0  unknown 0     upper
## 3283   apr      582        2    -1        0  unknown 0     upper
## 3284   may       51        7    -1        0  unknown 0     upper
## 3285   jul       69        7    -1        0  unknown 0     upper
## 3286   may      632        5   287        6  success 0   primary
## 3287   may      242        7    -1        0  unknown 0   primary
## 3288   jul       67        9    -1        0  unknown 0     upper
## 3289   may       76        2    -1        0  unknown 0     upper
## 3290   jun      115        1    -1        0  unknown 0     upper
## 3291   may      360        2    -1        0  unknown 0     upper
## 3292   may      349        1   338        1  failure 0     upper
## 3293   nov      459        3    -1        0  unknown 0     upper
## 3294   may       61        1    -1        0  unknown 0     upper
## 3295   nov      175        1    -1        0  unknown 0   unknown
## 3296   nov      316        1    -1        0  unknown 0   unknown
## 3297   feb      136        4    -1        0  unknown 1   primary
## 3298   jul       93        1    -1        0  unknown 0   primary
## 3299   may       19        1    -1        0  unknown 0     upper
## 3300   feb      620        2    -1        0  unknown 0     upper
## 3301   may      285        1   288       17    other 0     upper
## 3302   jun       58        1    -1        0  unknown 0     upper
## 3303   nov      215        1    -1        0  unknown 1     upper
## 3304   may      522        1    -1        0  unknown 0   primary
## 3305   may       12       10   178        1  failure 0     upper
## 3306   mar       78        2    91        1  failure 0     upper
## 3307   nov      287        2    -1        0  unknown 0     upper
## 3308   jul      498        1    -1        0  unknown 0     upper
## 3309   jul      308        4    -1        0  unknown 0     upper
## 3310   jun      717        1    -1        0  unknown 0     upper
## 3311   jan      144        1    -1        0  unknown 0     upper
## 3312   feb      463        2    -1        0  unknown 0     upper
## 3313   aug      343        4    -1        0  unknown 0     upper
## 3314   nov      584        2    -1        0  unknown 0     upper
## 3315   jun      153        2    -1        0  unknown 0     upper
## 3316   jun      140        2    -1        0  unknown 0     upper
## 3317   jul      217        4    -1        0  unknown 0   primary
## 3318   may      302        1   301        1  success 1     upper
## 3319   may      155        2    -1        0  unknown 0   primary
## 3320   jul      981        1    -1        0  unknown 1     upper
## 3321   nov      174        1   195        1  failure 0   primary
## 3322   apr      144        4   374        2  success 1     upper
## 3323   may      477        2    -1        0  unknown 0     upper
## 3324   nov      128        1    -1        0  unknown 0   primary
## 3325   jun      117        5    -1        0  unknown 0     upper
## 3326   feb       13        8   238        9    other 0     upper
## 3327   may      299        3    -1        0  unknown 0     upper
## 3328   jul      804        1    -1        0  unknown 1   unknown
## 3329   jun       81        2    -1        0  unknown 0     upper
## 3330   feb       96        6    -1        0  unknown 0     upper
## 3331   feb       58        2    -1        0  unknown 0     upper
## 3332   jul       81        2    -1        0  unknown 0     upper
## 3333   feb       79        2    -1        0  unknown 0   primary
## 3334   may       54        1   345        2  failure 0     upper
## 3335   jul      145        2    -1        0  unknown 0     upper
## 3336   nov       50        1    -1        0  unknown 0     upper
## 3337   jun      205        4    -1        0  unknown 0   unknown
## 3338   nov      197        1    -1        0  unknown 0     upper
## 3339   aug      297        1    -1        0  unknown 0     upper
## 3340   nov      240        1    40        2    other 0     upper
## 3341   may       67        4   175        6  failure 0     upper
## 3342   may      202        6    -1        0  unknown 0     upper
## 3343   may      182        1    -1        0  unknown 0     upper
## 3344   may      178        3    -1        0  unknown 0     upper
## 3345   apr      129        1   322        2  failure 0     upper
## 3346   feb      231        1    -1        0  unknown 0     upper
## 3347   jun      364        2    -1        0  unknown 0     upper
## 3348   jun      138        3    -1        0  unknown 0     upper
## 3349   may      262        1    -1        0  unknown 0     upper
## 3350   may      150        1    -1        0  unknown 0     upper
## 3351   nov       93        1   113        2    other 0     upper
## 3352   may      186        2   295        1  failure 0     upper
## 3353   may      311        1   368        2  failure 1     upper
## 3354   jun      436        1    -1        0  unknown 0     upper
## 3355   jul      235        1    -1        0  unknown 0     upper
## 3356   nov      405        1   139        1  failure 0   primary
## 3357   may      582        1    -1        0  unknown 0     upper
## 3358   jun      103        2    -1        0  unknown 0   primary
## 3359   may      216        2   259        3    other 0   primary
## 3360   apr      162        4   295        3  failure 0     upper
## 3361   may      806        1    -1        0  unknown 0     upper
## 3362   jul      102        3    -1        0  unknown 0     upper
## 3363   jun       82        3    -1        0  unknown 0     upper
## 3364   may      641        6    -1        0  unknown 0   primary
## 3365   may      145        1    -1        0  unknown 0     upper
## 3366   aug       62        2    -1        0  unknown 0     upper
## 3367   jan      117        2    -1        0  unknown 0     upper
## 3368   apr      321        1   449        1    other 1     upper
## 3369   jan      156        2    -1        0  unknown 0   primary
## 3370   nov      276        1   195        1  failure 0     upper
## 3371   aug       90       11    -1        0  unknown 0     upper
## 3372   may      195        5    -1        0  unknown 0     upper
## 3373   aug      139        2    -1        0  unknown 0     upper
## 3374   feb      297        3    -1        0  unknown 0     upper
## 3375   jul       51        4    -1        0  unknown 0     upper
## 3376   jun       17        5    -1        0  unknown 0     upper
## 3377   jul       81        1    -1        0  unknown 0   primary
## 3378   nov      623        1   175        1    other 1   primary
## 3379   apr      158        2    -1        0  unknown 0     upper
## 3380   jun      553        2    -1        0  unknown 0     upper
## 3381   jun       66        4    -1        0  unknown 0     upper
## 3382   feb      261        1   195        4  failure 1     upper
## 3383   jul      244        3    -1        0  unknown 0     upper
## 3384   aug      199        7    -1        0  unknown 0     upper
## 3385   mar       92        5    -1        0  unknown 0     upper
## 3386   may      293        1    -1        0  unknown 0     upper
## 3387   feb       45        1    -1        0  unknown 0   primary
## 3388   may      143        3   357        1  failure 0     upper
## 3389   jul      369        1    -1        0  unknown 0     upper
## 3390   may      139        2    -1        0  unknown 0     upper
## 3391   may      280        1    -1        0  unknown 0     upper
## 3392   feb      172        5    -1        0  unknown 0     upper
## 3393   aug      194        2    -1        0  unknown 1   primary
## 3394   sep      414        1    91        5    other 1   unknown
## 3395   may      137        2    -1        0  unknown 0     upper
## 3396   may       25        1   350        5    other 0   primary
## 3397   jul      112        5    -1        0  unknown 0     upper
## 3398   may      245        1    -1        0  unknown 0     upper
## 3399   jul      188        2    -1        0  unknown 0     upper
## 3400   apr      117        1    -1        0  unknown 0   unknown
## 3401   jun      443        2    -1        0  unknown 0     upper
## 3402   aug      159        4    -1        0  unknown 0     upper
## 3403   may      267        2    -1        0  unknown 0     upper
## 3404   jul      638        2    -1        0  unknown 1     upper
## 3405   jul      112       10    -1        0  unknown 0     upper
## 3406   feb      202        4    -1        0  unknown 1   primary
## 3407   apr       70        1    84        1  failure 0     upper
## 3408   may      196        2    -1        0  unknown 0   primary
## 3409   may      541        2    -1        0  unknown 0     upper
## 3410   jun       96        1    -1        0  unknown 0     upper
## 3411   jun       94        7    -1        0  unknown 0     upper
## 3412   may      623        1    -1        0  unknown 0     upper
## 3413   aug       66        3    -1        0  unknown 0     upper
## 3414   jul     1134        5    -1        0  unknown 1     upper
## 3415   may       91        2    -1        0  unknown 0     upper
## 3416   may       82        5   355        4  failure 0     upper
## 3417   aug       29        3    -1        0  unknown 0   unknown
## 3418   aug      122        2    -1        0  unknown 0     upper
## 3419   feb      387        1   251        1  failure 0   primary
## 3420   aug      328        2    -1        0  unknown 0     upper
## 3421   may      115        1    -1        0  unknown 0   unknown
## 3422   jun      154        2    -1        0  unknown 0     upper
## 3423   jul      225        2    -1        0  unknown 0     upper
## 3424   jun       83       10    -1        0  unknown 0     upper
## 3425   may      130        2    -1        0  unknown 0     upper
## 3426   jul      122        1    -1        0  unknown 0     upper
## 3427   may      295        1    -1        0  unknown 0   primary
## 3428   jul      482        3    -1        0  unknown 0     upper
## 3429   may      305        1    -1        0  unknown 0   primary
## 3430   may       92        3    -1        0  unknown 0     upper
## 3431   jul       95        5    -1        0  unknown 0     upper
## 3432   jul       89        5    -1        0  unknown 0     upper
## 3433   nov       95        1    -1        0  unknown 0     upper
## 3434   aug      784        3    94       10  failure 1     upper
## 3435   aug      183        2    -1        0  unknown 0     upper
## 3436   jan      127        1    -1        0  unknown 0     upper
## 3437   aug      113        1    -1        0  unknown 0     upper
## 3438   may       61        1    -1        0  unknown 0     upper
## 3439   jun        7        3    -1        0  unknown 0     upper
## 3440   may      150        1    -1        0  unknown 0     upper
## 3441   feb      383        1    -1        0  unknown 0     upper
## 3442   may      215        3   280        3  failure 0     upper
## 3443   may      104        3    -1        0  unknown 0     upper
## 3444   jun       29        1   686        2  failure 0     upper
## 3445   jun      227        1    -1        0  unknown 0     upper
## 3446   jan       41        1    -1        0  unknown 0   unknown
## 3447   jul      208        2    -1        0  unknown 0   primary
## 3448   may      280        1    -1        0  unknown 0     upper
## 3449   aug      105        6    -1        0  unknown 0     upper
## 3450   may      225        1    -1        0  unknown 0     upper
## 3451   apr      504        1    -1        0  unknown 0     upper
## 3452   jun       51        1    -1        0  unknown 0   primary
## 3453   may      253        3    -1        0  unknown 0     upper
## 3454   may       76        2    87        1  success 0     upper
## 3455   may      417        2    -1        0  unknown 1     upper
## 3456   jul       72        1    -1        0  unknown 0     upper
## 3457   aug      255        2   104        1  success 1     upper
## 3458   feb      542        2    -1        0  unknown 0     upper
## 3459   may      179        3    -1        0  unknown 0     upper
## 3460   may      653        1    -1        0  unknown 1     upper
## 3461   may      201        2    -1        0  unknown 0   primary
## 3462   jul       33        2    -1        0  unknown 0   primary
## 3463   feb       48        4    -1        0  unknown 0     upper
## 3464   may      109        2    -1        0  unknown 0     upper
## 3465   jul       18        9    -1        0  unknown 0     upper
## 3466   nov      159        2    -1        0  unknown 0     upper
## 3467   feb        9        8    -1        0  unknown 0     upper
## 3468   aug      119        2    -1        0  unknown 0     upper
## 3469   may      508        3   173        5  failure 0     upper
## 3470   may      207        5    -1        0  unknown 0     upper
## 3471   may      302        1    -1        0  unknown 0   primary
## 3472   jun       20        7    -1        0  unknown 0     upper
## 3473   apr       97        1    -1        0  unknown 0     upper
## 3474   jul      259        3    -1        0  unknown 0     upper
## 3475   nov        6        6    -1        0  unknown 0     upper
## 3476   aug      200        2    -1        0  unknown 0     upper
## 3477   jul       90        2    -1        0  unknown 0     upper
## 3478   may      130        1    -1        0  unknown 0   primary
## 3479   jun      124        2    -1        0  unknown 0   primary
## 3480   jan      314        1    -1        0  unknown 0   primary
## 3481   may      364        1    -1        0  unknown 0     upper
## 3482   may      158        2   350        2  failure 0     upper
## 3483   aug      467        2    -1        0  unknown 0   unknown
## 3484   jul       69        9    -1        0  unknown 0     upper
## 3485   apr      137        1    -1        0  unknown 0   primary
## 3486   may       24        1   346        1  failure 0     upper
## 3487   may      231        1    -1        0  unknown 0   unknown
## 3488   aug      663        3    -1        0  unknown 1   primary
## 3489   apr      377        3   325        1  failure 0   primary
## 3490   may      891        4    -1        0  unknown 1     upper
## 3491   aug      603        3    -1        0  unknown 0     upper
## 3492   jul      799        2    -1        0  unknown 1     upper
## 3493   nov      286        3    -1        0  unknown 0     upper
## 3494   apr      397        1    -1        0  unknown 0     upper
## 3495   jun      284        1    -1        0  unknown 0     upper
## 3496   aug      195        1    -1        0  unknown 0   primary
## 3497   may      306        1    -1        0  unknown 0     upper
## 3498   aug      194        6    -1        0  unknown 0     upper
## 3499   may      228        2   267        1  failure 1     upper
## 3500   oct      511        3   187        1  failure 1     upper
## 3501   may      183        5    -1        0  unknown 0     upper
## 3502   apr      636        3   330        1  failure 1     upper
## 3503   may      124        2   298        1  failure 0     upper
## 3504   nov      107        1   117        3  failure 0     upper
## 3505   jul      334        3    -1        0  unknown 0     upper
## 3506   jun       32        4    -1        0  unknown 0   unknown
## 3507   aug      105        2    -1        0  unknown 0     upper
## 3508   sep      105        2    -1        0  unknown 0     upper
## 3509   dec      136        1    -1        0  unknown 0     upper
## 3510   may      101        1   349        1  failure 0     upper
## 3511   may      160        2    -1        0  unknown 0     upper
## 3512   may       81        1    -1        0  unknown 0     upper
## 3513   jul      320        2    -1        0  unknown 0     upper
## 3514   aug      133        4    -1        0  unknown 0     upper
## 3515   may      445        1    -1        0  unknown 0   primary
## 3516   apr      115        2    -1        0  unknown 0     upper
## 3517   jun       45        9    -1        0  unknown 0   primary
## 3518   aug      359        2    -1        0  unknown 0     upper
## 3519   jun      329        3    -1        0  unknown 0   primary
## 3520   may      280        2   335        3  failure 0   primary
## 3521   may       65        3    -1        0  unknown 0     upper
## 3522   nov      102        1    -1        0  unknown 0     upper
## 3523   jul      299        5    -1        0  unknown 0     upper
## 3524   aug       15       19    -1        0  unknown 0     upper
## 3525   aug       54        4    -1        0  unknown 0     upper
## 3526   jun      218        1    -1        0  unknown 0     upper
## 3527   may       10        5    -1        0  unknown 0     upper
## 3528   jul       42        1    -1        0  unknown 0     upper
## 3529   jul      226        2    -1        0  unknown 0     upper
## 3530   apr       93        3   329        7  failure 0     upper
## 3531   may      198        1    -1        0  unknown 0     upper
## 3532   aug      479        1    -1        0  unknown 1     upper
## 3533   apr      176        1    -1        0  unknown 1     upper
## 3534   jun       30        1   404        2  success 0     upper
## 3535   jun      211        2    -1        0  unknown 0     upper
## 3536   may      487        4    -1        0  unknown 0   primary
## 3537   nov      182        2    -1        0  unknown 0   primary
## 3538   jun       47        3    -1        0  unknown 0     upper
## 3539   oct      152        4    -1        0  unknown 0   unknown
## 3540   jul      643        2    -1        0  unknown 0     upper
## 3541   aug      104        2    -1        0  unknown 0     upper
## 3542   may      182        2    -1        0  unknown 0     upper
## 3543   may      301        4    -1        0  unknown 0   primary
## 3544   jun       44        1    -1        0  unknown 0     upper
## 3545   jan      452        3    -1        0  unknown 1     upper
## 3546   mar      263        1   124        9    other 1     upper
## 3547   aug      158        1   104        2  failure 0     upper
## 3548   apr      445        1   148        2    other 0     upper
## 3549   jun      145        1    -1        0  unknown 0     upper
## 3550   jul      479        1    -1        0  unknown 0     upper
## 3551   nov      902        1   133        2    other 1     upper
## 3552   may      271        5    -1        0  unknown 0     upper
## 3553   may      351        3    -1        0  unknown 1   unknown
## 3554   may      437        2    -1        0  unknown 0     upper
## 3555   feb      159        1    -1        0  unknown 1     upper
## 3556   jul      324        1    -1        0  unknown 0   primary
## 3557   aug       51        8    -1        0  unknown 0   primary
## 3558   may      176        3    -1        0  unknown 0     upper
## 3559   feb      149        3   215        1  failure 0     upper
## 3560   may       85        1    -1        0  unknown 0     upper
## 3561   aug      242        6    95        4  success 1     upper
## 3562   jun      249        1    -1        0  unknown 0     upper
## 3563   jun       92        1    -1        0  unknown 0   primary
## 3564   nov      133        1    -1        0  unknown 0     upper
## 3565   aug      203        7    -1        0  unknown 0     upper
## 3566   may       23       15    -1        0  unknown 0     upper
## 3567   jun      119        2    -1        0  unknown 0     upper
## 3568   may       90        3    -1        0  unknown 0     upper
## 3569   feb      678        1    -1        0  unknown 0     upper
## 3570   may      126        5    -1        0  unknown 0     upper
## 3571   aug      107        2    -1        0  unknown 0     upper
## 3572   may      200        2    -1        0  unknown 0   primary
## 3573   aug       36        2    -1        0  unknown 0     upper
## 3574   may      110        1    -1        0  unknown 0     upper
## 3575   jul      122       12    -1        0  unknown 0     upper
## 3576   may      695        4    -1        0  unknown 0     upper
## 3577   may      107        4   371        3  failure 0     upper
## 3578   may      245        2    -1        0  unknown 0     upper
## 3579   feb      416        2    -1        0  unknown 1     upper
## 3580   nov      251        2    -1        0  unknown 0     upper
## 3581   jul      604        1    -1        0  unknown 0     upper
## 3582   jan       85        2   240        1  failure 0     upper
## 3583   jul     1545        1    -1        0  unknown 1     upper
## 3584   feb      113        2    -1        0  unknown 0   primary
## 3585   jun      642        2    -1        0  unknown 1   primary
## 3586   may      154        2   340        2  failure 0     upper
## 3587   may      352        2   175       11    other 0     upper
## 3588   may      798        1    -1        0  unknown 0     upper
## 3589   aug      238        6    -1        0  unknown 0     upper
## 3590   jul      100       16    -1        0  unknown 0     upper
## 3591   jul       88        3    -1        0  unknown 0     upper
## 3592   feb      181        3    -1        0  unknown 1     upper
## 3593   sep      179        1   186        2  failure 0     upper
## 3594   nov      230        1    -1        0  unknown 0     upper
## 3595   may       67        2    -1        0  unknown 0     upper
## 3596   may      210        1    -1        0  unknown 0     upper
## 3597   jul      403        7    -1        0  unknown 0     upper
## 3598   nov      155        1    -1        0  unknown 0     upper
## 3599   jun       61        2    -1        0  unknown 0     upper
## 3600   aug      168        2    -1        0  unknown 0     upper
## 3601   apr      759        2    -1        0  unknown 0     upper
## 3602   jun       73        1    -1        0  unknown 0     upper
## 3603   jun      686       11    -1        0  unknown 1     upper
## 3604   oct      219        3   372        1  failure 0     upper
## 3605   jul      148        1    -1        0  unknown 0     upper
## 3606   apr      228        2    -1        0  unknown 0     upper
## 3607   aug      199        6    -1        0  unknown 0     upper
## 3608   jun      862       11    -1        0  unknown 1     upper
## 3609   may      500        1    -1        0  unknown 1   primary
## 3610   nov      141        3    -1        0  unknown 0     upper
## 3611   may      127        2   254       23    other 0     upper
## 3612   nov      163        1   200        1  failure 0   primary
## 3613   may      210        1    -1        0  unknown 0     upper
## 3614   may      192        1    -1        0  unknown 0     upper
## 3615   apr      325        1   180        7  failure 1   primary
## 3616   jul      242        1    -1        0  unknown 0     upper
## 3617   may      114        1    -1        0  unknown 0     upper
## 3618   nov      187        2    -1        0  unknown 0     upper
## 3619   may      257        1    -1        0  unknown 0     upper
## 3620   may      128        8   324        7    other 0     upper
## 3621   nov      301        1    -1        0  unknown 0     upper
## 3622   jul      417        1    -1        0  unknown 0     upper
## 3623   may      850        2    -1        0  unknown 1     upper
## 3624   sep      500        2   228        1  failure 0     upper
## 3625   aug     1486        1    -1        0  unknown 1     upper
## 3626   jun      266        4    -1        0  unknown 0     upper
## 3627   jul       36        5    -1        0  unknown 0     upper
## 3628   feb       93        1    -1        0  unknown 0     upper
## 3629   apr      155        1   154        2  failure 0     upper
## 3630   nov      251        2    -1        0  unknown 0     upper
## 3631   may      217        1    -1        0  unknown 0     upper
## 3632   aug      108        5    -1        0  unknown 0     upper
## 3633   jun       44        2    -1        0  unknown 0     upper
## 3634   aug      162        2    -1        0  unknown 0     upper
## 3635   may      106        3    -1        0  unknown 0   primary
## 3636   apr      439        2    -1        0  unknown 1     upper
## 3637   may      272        1   342        2    other 0     upper
## 3638   may      131        2    -1        0  unknown 0     upper
## 3639   feb      214        2   259        2  failure 0     upper
## 3640   jun      154        1   124        1    other 0     upper
## 3641   mar       83        1    -1        0  unknown 1     upper
## 3642   jul       81        6    -1        0  unknown 0     upper
## 3643   oct        6        1    -1        0  unknown 0     upper
## 3644   jun       24        1    -1        0  unknown 0   primary
## 3645   may       37        1    -1        0  unknown 0     upper
## 3646   apr      125        2   182        1  failure 0     upper
## 3647   jun       95        1    -1        0  unknown 0     upper
## 3648   may      250        2    -1        0  unknown 0     upper
## 3649   jul      136        2    -1        0  unknown 0   primary
## 3650   nov      122        2    -1        0  unknown 0     upper
## 3651   jun       48        2    -1        0  unknown 0     upper
## 3652   mar      278        2    -1        0  unknown 1     upper
## 3653   nov      769        4    -1        0  unknown 0     upper
## 3654   jul      260        1    -1        0  unknown 0     upper
## 3655   apr      314        1    -1        0  unknown 0   primary
## 3656   jun      184        2    -1        0  unknown 0     upper
## 3657   may      149        4    -1        0  unknown 0   primary
## 3658   jul      170        1    -1        0  unknown 0     upper
## 3659   jan       41        2   261        1  failure 0     upper
## 3660   apr      190        2    -1        0  unknown 0   primary
## 3661   may      143        1    -1        0  unknown 0   primary
## 3662   may       24        1    -1        0  unknown 0     upper
## 3663   sep      431        1   466        3  success 1     upper
## 3664   aug       75        2    -1        0  unknown 0     upper
## 3665   jul      285        1    -1        0  unknown 0     upper
## 3666   aug      217        5    -1        0  unknown 0   primary
## 3667   jun      238        3    -1        0  unknown 0     upper
## 3668   oct       56        4    -1        0  unknown 0     upper
## 3669   may      843        2    -1        0  unknown 1   unknown
## 3670   mar      170        3    -1        0  unknown 1   primary
## 3671   may      201        2   293        6    other 0     upper
## 3672   jan      868        1    -1        0  unknown 0   primary
## 3673   aug     1152        6    -1        0  unknown 1   primary
## 3674   jun      160        4    -1        0  unknown 0     upper
## 3675   aug       57        6    -1        0  unknown 0     upper
## 3676   feb      100        1    -1        0  unknown 0     upper
## 3677   may       71        2    -1        0  unknown 0     upper
## 3678   aug      961        4    -1        0  unknown 0   primary
## 3679   sep      339        1    38        1  failure 0   primary
## 3680   may      416        4    -1        0  unknown 0     upper
## 3681   apr      349        1    -1        0  unknown 0     upper
## 3682   nov      185        1    -1        0  unknown 0     upper
## 3683   aug        9        1    -1        0  unknown 0     upper
## 3684   aug      173        3    -1        0  unknown 0     upper
## 3685   may      158        1    -1        0  unknown 0     upper
## 3686   jul      185        2    -1        0  unknown 0   primary
## 3687   may       14        2   344        3    other 0   primary
## 3688   jul       45        3    -1        0  unknown 0     upper
## 3689   aug      201        2    -1        0  unknown 0     upper
## 3690   jun      193        5    -1        0  unknown 0   primary
## 3691   nov      409        2    -1        0  unknown 1     upper
## 3692   apr      144        1    -1        0  unknown 0     upper
## 3693   nov      279        1    -1        0  unknown 0     upper
## 3694   may      180        1    -1        0  unknown 0     upper
## 3695   may       18        1    -1        0  unknown 0     upper
## 3696   dec      221        3    -1        0  unknown 1     upper
## 3697   aug      212       15    -1        0  unknown 0     upper
## 3698   aug      112        2    -1        0  unknown 0     upper
## 3699   may      175        1   293        5  failure 0     upper
## 3700   may      148        3    -1        0  unknown 0     upper
## 3701   jul      335        3   194        2  failure 1     upper
## 3702   jul       36        6    -1        0  unknown 0     upper
## 3703   jul      350       15    -1        0  unknown 0     upper
## 3704   may      182        1    90        8  failure 0     upper
## 3705   may       90        1    -1        0  unknown 0     upper
## 3706   may      498        4    -1        0  unknown 0   primary
## 3707   may      423        1    -1        0  unknown 0     upper
## 3708   aug      111        2    -1        0  unknown 0     upper
## 3709   nov       21        1    -1        0  unknown 0   primary
## 3710   jun      288        3    -1        0  unknown 0     upper
## 3711   aug      148        2    -1        0  unknown 1     upper
## 3712   jul      728        2    -1        0  unknown 1     upper
## 3713   aug       97        6    -1        0  unknown 0     upper
## 3714   may      241        2   349        2  failure 0     upper
## 3715   may      138        1    -1        0  unknown 0     upper
## 3716   may      124        2    -1        0  unknown 0     upper
## 3717   aug      128       12    -1        0  unknown 0     upper
## 3718   may      286        3    -1        0  unknown 0     upper
## 3719   may      115        3    -1        0  unknown 0     upper
## 3720   jan      458        2    -1        0  unknown 0     upper
## 3721   jul       75        8    -1        0  unknown 0     upper
## 3722   jul      389        5    -1        0  unknown 0     upper
## 3723   nov      238        1    -1        0  unknown 1     upper
## 3724   jun       45        4    -1        0  unknown 0     upper
## 3725   nov      153        1    -1        0  unknown 0     upper
## 3726   nov      303        4    -1        0  unknown 0   primary
## 3727   apr      124        1    28        3  failure 0     upper
## 3728   may      291        4    -1        0  unknown 0   primary
## 3729   jul      122        1    -1        0  unknown 0     upper
## 3730   nov       72        1    -1        0  unknown 0     upper
## 3731   may      247        2    -1        0  unknown 0     upper
## 3732   may      129        1    -1        0  unknown 0     upper
## 3733   aug     1364        4    -1        0  unknown 0   primary
## 3734   dec      390        1    -1        0  unknown 0     upper
## 3735   may      423        2    -1        0  unknown 0   primary
## 3736   feb       38        8    -1        0  unknown 0     upper
## 3737   nov      114        1   183        3    other 0   primary
## 3738   nov      158        2    -1        0  unknown 0     upper
## 3739   may      315        1    -1        0  unknown 0     upper
## 3740   jun      171        1    -1        0  unknown 0     upper
## 3741   nov       28        3   158        3  failure 0     upper
## 3742   apr      594        4   331        1  failure 0   primary
## 3743   may      430        1    -1        0  unknown 0     upper
## 3744   jun       10        4    -1        0  unknown 0     upper
## 3745   aug       63        2    -1        0  unknown 0     upper
## 3746   may      219        1    -1        0  unknown 0   primary
## 3747   nov      150        1    -1        0  unknown 0   primary
## 3748   may       78        5   292        3  failure 0     upper
## 3749   feb      170        2    -1        0  unknown 0     upper
## 3750   may       92        1    -1        0  unknown 0     upper
## 3751   jul       84        1    -1        0  unknown 0     upper
## 3752   jan      276        2    -1        0  unknown 0     upper
## 3753   may      119        3    -1        0  unknown 0     upper
## 3754   sep     2055        1    -1        0  unknown 0     upper
## 3755   may      185        1    -1        0  unknown 0     upper
## 3756   jul      227        4    -1        0  unknown 0     upper
## 3757   jun       94        1    -1        0  unknown 0     upper
## 3758   may      235        2    -1        0  unknown 0     upper
## 3759   feb      244        3    -1        0  unknown 0   primary
## 3760   jun      169        2    -1        0  unknown 0     upper
## 3761   jan      270        1    -1        0  unknown 0     upper
## 3762   sep      224        2   444        1  failure 1     upper
## 3763   jul      293        2    -1        0  unknown 0     upper
## 3764   may      174        1    -1        0  unknown 0     upper
## 3765   may      550        2    -1        0  unknown 0     upper
## 3766   jun      331        4    -1        0  unknown 0     upper
## 3767   may      488        1    -1        0  unknown 0     upper
## 3768   nov      366        3    -1        0  unknown 1     upper
## 3769   may       53        1    -1        0  unknown 0     upper
## 3770   jun       29        4    -1        0  unknown 0   primary
## 3771   mar      191        2    -1        0  unknown 1     upper
## 3772   apr      135        1    -1        0  unknown 1     upper
## 3773   may      101        2    -1        0  unknown 0     upper
## 3774   jul      186        4    -1        0  unknown 0     upper
## 3775   jul      335        2    -1        0  unknown 0     upper
## 3776   jun      108        1    -1        0  unknown 0     upper
## 3777   may       96        2    -1        0  unknown 0     upper
## 3778   aug      218        2    -1        0  unknown 0     upper
## 3779   apr      164        2    -1        0  unknown 0   primary
## 3780   may      128        4    -1        0  unknown 0     upper
## 3781   apr      359        3    -1        0  unknown 0     upper
## 3782   aug       67        4    -1        0  unknown 0     upper
## 3783   may      195        2   301        3  failure 0     upper
## 3784   nov      418        3    -1        0  unknown 0     upper
## 3785   aug      183       20    -1        0  unknown 0     upper
## 3786   jun       53        1    -1        0  unknown 0     upper
## 3787   aug      499        2    -1        0  unknown 0     upper
## 3788   feb       58        1   269        2  failure 0     upper
## 3789   aug      127        5    -1        0  unknown 0     upper
## 3790   jun      218        1    -1        0  unknown 0     upper
## 3791   may      455        2    -1        0  unknown 0     upper
## 3792   jun      160        2    -1        0  unknown 0     upper
## 3793   may      247        2    -1        0  unknown 0   unknown
## 3794   may      231        4    -1        0  unknown 0     upper
## 3795   jun      393       11    -1        0  unknown 0     upper
## 3796   may      371        2    -1        0  unknown 0     upper
## 3797   nov      255        1    -1        0  unknown 1     upper
## 3798   jun      384        1    -1        0  unknown 0     upper
## 3799   nov      508        4    -1        0  unknown 0     upper
## 3800   may      252        4    -1        0  unknown 0     upper
## 3801   feb      128        1    -1        0  unknown 0     upper
## 3802   nov      273        2    96        4  failure 0   primary
## 3803   may       28        2   306        1  failure 0     upper
## 3804   jul      815        2   407        3  success 1     upper
## 3805   may      166        9    -1        0  unknown 0     upper
## 3806   jul      117        2    -1        0  unknown 0     upper
## 3807   may       20        8   350        9  failure 0     upper
## 3808   jun      135        1    -1        0  unknown 0     upper
## 3809   may      460        1    95        2  success 1   unknown
## 3810   may      125        2   304        2  failure 0     upper
## 3811   jun      140        3    -1        0  unknown 0     upper
## 3812   nov      182        2    91        2  success 1     upper
## 3813   jun       49        1    -1        0  unknown 0     upper
## 3814   aug      196        1    -1        0  unknown 0     upper
## 3815   jul       72        3    -1        0  unknown 0     upper
## 3816   aug       77        4    -1        0  unknown 0     upper
## 3817   jul      249        3    -1        0  unknown 0     upper
## 3818   oct      526        1    -1        0  unknown 1     upper
## 3819   apr      106        1    -1        0  unknown 0     upper
## 3820   oct      174        2    -1        0  unknown 0     upper
## 3821   jun      174        8    -1        0  unknown 0     upper
## 3822   nov      372        1    -1        0  unknown 1     upper
## 3823   feb      360        1    -1        0  unknown 0     upper
## 3824   may      496        2   345        3  failure 1     upper
## 3825   may      184        1    -1        0  unknown 0     upper
## 3826   may      317        1    -1        0  unknown 0     upper
## 3827   may      209        3    -1        0  unknown 0     upper
## 3828   may      544        1    -1        0  unknown 0     upper
## 3829   jul       67        5   252        1  failure 0     upper
## 3830   oct      427        1    -1        0  unknown 1     upper
## 3831   nov       94        1   170        1    other 0     upper
## 3832   aug      186        1    -1        0  unknown 1     upper
## 3833   aug       62        2   104        2  success 0     upper
## 3834   jun      237        3    -1        0  unknown 0     upper
## 3835   may      252        1    85        6  failure 0     upper
## 3836   jun      188        1    -1        0  unknown 0     upper
## 3837   jul      354        1    -1        0  unknown 0     upper
## 3838   jun       67        4    -1        0  unknown 0   primary
## 3839   jun       54        1    -1        0  unknown 0     upper
## 3840   nov      295        1   124        2  failure 0     upper
## 3841   may      408        2    -1        0  unknown 0   unknown
## 3842   jun       53       11    -1        0  unknown 0     upper
## 3843   jun      219        2    -1        0  unknown 0   primary
## 3844   jul      185        1    -1        0  unknown 0     upper
## 3845   may       94        1    -1        0  unknown 0   primary
## 3846   jul       90        5    -1        0  unknown 0     upper
## 3847   nov      107        3    -1        0  unknown 0     upper
## 3848   may     1185        3    -1        0  unknown 0     upper
## 3849   may      447        1    -1        0  unknown 0     upper
## 3850   may      542        2    -1        0  unknown 0     upper
## 3851   jun      235        3    -1        0  unknown 1     upper
## 3852   apr      335        1   334        3  failure 0     upper
## 3853   may      184        1    -1        0  unknown 0     upper
## 3854   jan      146        2   262        2  failure 0     upper
## 3855   jun       78        1    -1        0  unknown 0     upper
## 3856   oct       10        1    -1        0  unknown 0     upper
## 3857   jun       93        1    -1        0  unknown 0   primary
## 3858   feb      204        1    -1        0  unknown 1   unknown
## 3859   jul      246        1    -1        0  unknown 0     upper
## 3860   may      451        1   350        1    other 0     upper
## 3861   aug      113        8    -1        0  unknown 0     upper
## 3862   jun       94        2    -1        0  unknown 1     upper
## 3863   jun      485        2   227        4  failure 1     upper
## 3864   jun      940        1    -1        0  unknown 1   primary
## 3865   jul       31        3    -1        0  unknown 0     upper
## 3866   feb      147        1    -1        0  unknown 1     upper
## 3867   may      132        2    -1        0  unknown 0     upper
## 3868   aug       14       15    -1        0  unknown 0     upper
## 3869   feb       83        1    -1        0  unknown 0     upper
## 3870   nov      121        1    -1        0  unknown 0     upper
## 3871   nov      240        3    -1        0  unknown 0     upper
## 3872   jan      821        1    -1        0  unknown 0     upper
## 3873   jul      235        1   287        1  failure 0   primary
## 3874   may      161        4    -1        0  unknown 0   primary
## 3875   may      209        2    -1        0  unknown 0   primary
## 3876   may      923        3    -1        0  unknown 1     upper
## 3877   jun      202        2    -1        0  unknown 0   primary
## 3878   jan      158        2   153       12  failure 0     upper
## 3879   jan       87        2    -1        0  unknown 0     upper
## 3880   aug       81        3    -1        0  unknown 0     upper
## 3881   aug      150        2    -1        0  unknown 0     upper
## 3882   apr      216        3   370        1  failure 1   unknown
## 3883   jul      553        1    -1        0  unknown 1     upper
## 3884   feb       32        4   225        3  failure 0     upper
## 3885   apr       80        1    -1        0  unknown 0     upper
## 3886   jul      464        1    -1        0  unknown 0     upper
## 3887   sep        9        1    -1        0  unknown 0     upper
## 3888   feb      102        1   264        1  failure 0     upper
## 3889   nov       57        1    -1        0  unknown 0     upper
## 3890   jul       49        1    -1        0  unknown 0   unknown
## 3891   jul      184        2    -1        0  unknown 0     upper
## 3892   aug       85        1    -1        0  unknown 0     upper
## 3893   aug      130        2    -1        0  unknown 0     upper
## 3894   may       97        1   370        1  failure 0     upper
## 3895   may      551        1   371        2  failure 1   primary
## 3896   may      114        1   287        8  failure 0     upper
## 3897   jun      240        9    -1        0  unknown 0   unknown
## 3898   may        7       11   360        2    other 0     upper
## 3899   may      335        1    -1        0  unknown 0     upper
## 3900   aug      124        2    -1        0  unknown 0     upper
## 3901   jul       71        6    -1        0  unknown 0     upper
## 3902   may       54        5    -1        0  unknown 0   primary
## 3903   aug      239        2    -1        0  unknown 0     upper
## 3904   jun      211        2    -1        0  unknown 0     upper
## 3905   may      290        1    -1        0  unknown 0   unknown
## 3906   sep      173        1    -1        0  unknown 0     upper
## 3907   jun      156        4    -1        0  unknown 0     upper
## 3908   nov       83        1    -1        0  unknown 0     upper
## 3909   jun      422        6    -1        0  unknown 1   primary
## 3910   jul       81        2    -1        0  unknown 0     upper
## 3911   may      145        1   337        4  failure 0     upper
## 3912   aug      183        8    -1        0  unknown 0     upper
## 3913   may      177        1    -1        0  unknown 0   primary
## 3914   mar      194        2   181        3  failure 0     upper
## 3915   feb      118        1    -1        0  unknown 0     upper
## 3916   feb      188        1   247        4    other 0     upper
## 3917   may      213        1    -1        0  unknown 0     upper
## 3918   jun      396        1    -1        0  unknown 0     upper
## 3919   jun      817        2    -1        0  unknown 1     upper
## 3920   jan      244        3    -1        0  unknown 0     upper
## 3921   aug       33        2    -1        0  unknown 0     upper
## 3922   may      183        1    -1        0  unknown 0     upper
## 3923   aug      273        2    -1        0  unknown 0     upper
## 3924   nov      459        3    -1        0  unknown 1     upper
## 3925   may     1044        5    -1        0  unknown 1     upper
## 3926   apr      334        1    -1        0  unknown 0     upper
## 3927   may      173        1   274        3  failure 0     upper
## 3928   jul       54       16    -1        0  unknown 0     upper
## 3929   jun      196        1    -1        0  unknown 0     upper
## 3930   aug      127        4    -1        0  unknown 0     upper
## 3931   jun       64        1    -1        0  unknown 0     upper
## 3932   may      373        3    -1        0  unknown 0   primary
## 3933   may       60        1    -1        0  unknown 0   primary
## 3934   aug      671        2    -1        0  unknown 1     upper
## 3935   may      216        1    -1        0  unknown 0   primary
## 3936   aug      114        7    -1        0  unknown 0     upper
## 3937   may      246        1    -1        0  unknown 0   primary
## 3938   aug       47       20    -1        0  unknown 0   primary
## 3939   feb      223        7    -1        0  unknown 0     upper
## 3940   jun       74        2    -1        0  unknown 0     upper
## 3941   jun      922        2    -1        0  unknown 1   primary
## 3942   may      746        1    -1        0  unknown 0     upper
## 3943   may      337        4    -1        0  unknown 0     upper
## 3944   may       88        2    -1        0  unknown 0     upper
## 3945   aug      169        1    -1        0  unknown 0     upper
## 3946   may      106        3    -1        0  unknown 0     upper
## 3947   jul      173        1    -1        0  unknown 0     upper
## 3948   feb       67        2   207        2  failure 0     upper
## 3949   jul       19        2    -1        0  unknown 0   primary
## 3950   may      116        2    -1        0  unknown 0   primary
## 3951   aug      293        1   104        1  success 1   unknown
## 3952   may       20        6   291        2    other 0     upper
## 3953   may     1237        2   361        2  failure 0     upper
## 3954   jul      396        2    -1        0  unknown 0     upper
## 3955   oct       92        1   336        1  failure 0     upper
## 3956   may      153        1    -1        0  unknown 0   primary
## 3957   may      146        4    -1        0  unknown 0     upper
## 3958   sep      113        5    97        3    other 0   primary
## 3959   oct      541        1   204        3  failure 0     upper
## 3960   may      174        2    -1        0  unknown 0     upper
## 3961   nov       90        2    -1        0  unknown 0     upper
## 3962   jul       91        2    -1        0  unknown 0   unknown
## 3963   apr       71        2   317        1  failure 0     upper
## 3964   nov      525        3    -1        0  unknown 1     upper
## 3965   may      162        5    -1        0  unknown 0     upper
## 3966   feb      324        1    -1        0  unknown 0     upper
## 3967   nov      239        1    -1        0  unknown 0     upper
## 3968   oct      275        1    -1        0  unknown 0     upper
## 3969   apr      125        4    -1        0  unknown 0     upper
## 3970   aug       73        2    -1        0  unknown 0     upper
## 3971   may       77        2    -1        0  unknown 0   unknown
## 3972   may      273        4    -1        0  unknown 0     upper
## 3973   may      103        8    -1        0  unknown 0     upper
## 3974   jul      638        3    -1        0  unknown 1     upper
## 3975   may      142        3    -1        0  unknown 0     upper
## 3976   jun     3183        2    -1        0  unknown 1     upper
## 3977   nov       79        1   129        2  failure 0     upper
## 3978   may      111       11    -1        0  unknown 0     upper
## 3979   aug      111        2    -1        0  unknown 0     upper
## 3980   may      115        1    -1        0  unknown 0     upper
## 3981   jul      303        1    -1        0  unknown 0   unknown
## 3982   may      299        1    -1        0  unknown 0     upper
## 3983   nov       89        4    -1        0  unknown 0     upper
## 3984   nov       63        2    -1        0  unknown 0   primary
## 3985   nov     1816        1    -1        0  unknown 0     upper
## 3986   may      242        1   212        1  success 1     upper
## 3987   may      954        2   293        4  success 1     upper
## 3988   jun      271        2    -1        0  unknown 0   primary
## 3989   jul      674        3    -1        0  unknown 0     upper
## 3990   may      111        1    -1        0  unknown 0     upper
## 3991   may      144        2    -1        0  unknown 0     upper
## 3992   jun      422        1    -1        0  unknown 0   primary
## 3993   aug      733        6    -1        0  unknown 0     upper
## 3994   may       11        8    -1        0  unknown 0     upper
## 3995   sep       74        1    -1        0  unknown 0     upper
## 3996   may      245        1    -1        0  unknown 0     upper
## 3997   may      268        3    -1        0  unknown 0     upper
## 3998   jan      918        1    93        1  success 1     upper
## 3999   mar      119        1    -1        0  unknown 0   primary
## 4000   may       17        7   287       13    other 0     upper
## 4001   jun      326        1    -1        0  unknown 0     upper
## 4002   aug      138        2    69        3  failure 0     upper
## 4003   jan      142        1   238        3    other 1     upper
## 4004   aug       29       28    -1        0  unknown 0     upper
## 4005   may      147        1    40        1  failure 0   unknown
## 4006   jan      385        3   197        1    other 0     upper
## 4007   jul      901        1    -1        0  unknown 1     upper
## 4008   may      129        2    -1        0  unknown 0     upper
## 4009   jun       45        1    -1        0  unknown 0     upper
## 4010   feb      206        2   188        6  failure 0   primary
## 4011   feb       70        3   265        4    other 0   primary
## 4012   jun      399        8    -1        0  unknown 0     upper
## 4013   nov      273        5    -1        0  unknown 0     upper
## 4014   may      148        1    -1        0  unknown 0     upper
## 4015   apr      222        5    -1        0  unknown 0   primary
## 4016   may      138        1    -1        0  unknown 0     upper
## 4017   jul       50       20    -1        0  unknown 0     upper
## 4018   may      102        2    -1        0  unknown 0     upper
## 4019   mar      144        2   124        1  failure 0     upper
## 4020   may      157        1   299        3  failure 0     upper
## 4021   nov      120        2   187        2  failure 0     upper
## 4022   nov       22        5    -1        0  unknown 0     upper
## 4023   oct      135        2    91       13  failure 0     upper
## 4024   may       72        2    -1        0  unknown 0     upper
## 4025   may      394        1    -1        0  unknown 1     upper
## 4026   jun      194        1    -1        0  unknown 1     upper
## 4027   dec      154        1    97        2  failure 1     upper
## 4028   may       45        1    -1        0  unknown 0     upper
## 4029   may      178        2    -1        0  unknown 0   primary
## 4030   jul      150        4    -1        0  unknown 0     upper
## 4031   jun      394        1    -1        0  unknown 0   primary
## 4032   jul      335        1    -1        0  unknown 0     upper
## 4033   jul      444        2    -1        0  unknown 0     upper
## 4034   may       90        2    -1        0  unknown 0     upper
## 4035   jul      298        2    -1        0  unknown 0     upper
## 4036   jun      367        1    -1        0  unknown 0     upper
## 4037   jul      182        6    -1        0  unknown 0     upper
## 4038   nov       57        1    -1        0  unknown 0     upper
## 4039   may      207        1    -1        0  unknown 0   primary
## 4040   may      132        1    -1        0  unknown 0     upper
## 4041   jun       78        1    -1        0  unknown 0     upper
## 4042   feb      337        4    -1        0  unknown 0     upper
## 4043   may      154        1    -1        0  unknown 0   primary
## 4044   aug      112        2    -1        0  unknown 0     upper
## 4045   jul      820        4    -1        0  unknown 1     upper
## 4046   jun      247        1    -1        0  unknown 0     upper
## 4047   may      102        1    -1        0  unknown 0     upper
## 4048   may      530        2    -1        0  unknown 0     upper
## 4049   may      379        2   169        1  failure 0     upper
## 4050   feb      114        1   208        1  failure 0   primary
## 4051   nov      160        2    -1        0  unknown 0     upper
## 4052   aug      152        2    -1        0  unknown 0     upper
## 4053   jun       74        1    -1        0  unknown 0     upper
## 4054   aug      275       12    -1        0  unknown 0     upper
## 4055   jun      140        2    -1        0  unknown 0     upper
## 4056   aug      310        2    -1        0  unknown 0     upper
## 4057   nov      758        1    -1        0  unknown 1     upper
## 4058   jul     1083        2    -1        0  unknown 0     upper
## 4059   nov       47        1   133        1  failure 0     upper
## 4060   aug      181        2    -1        0  unknown 0   primary
## 4061   jul      401        1    -1        0  unknown 0     upper
## 4062   nov       78        1    -1        0  unknown 0     upper
## 4063   may      146        1   370        1  failure 0     upper
## 4064   may       12        2    -1        0  unknown 0     upper
## 4065   may      228        1    -1        0  unknown 0   primary
## 4066   may       57        1    -1        0  unknown 0     upper
## 4067   apr       96        2    -1        0  unknown 0     upper
## 4068   aug       84        4    -1        0  unknown 0     upper
## 4069   jun       22       12    -1        0  unknown 0     upper
## 4070   may       54        2   371        1  failure 0     upper
## 4071   jun      407        1    -1        0  unknown 0   primary
## 4072   apr       82        6    -1        0  unknown 0     upper
## 4073   apr      259        1    -1        0  unknown 0     upper
## 4074   jan      164        1    -1        0  unknown 0     upper
## 4075   jul      462        1    -1        0  unknown 0     upper
## 4076   feb      616        5    -1        0  unknown 0     upper
## 4077   may      118        4    -1        0  unknown 0     upper
## 4078   may       75        4    -1        0  unknown 0     upper
## 4079   feb      171        3   277        4    other 0   primary
## 4080   may       16        6   351        1  failure 0     upper
## 4081   may      945        2    -1        0  unknown 1   primary
## 4082   jul       49        6    -1        0  unknown 0     upper
## 4083   aug      114        3    -1        0  unknown 0     upper
## 4084   apr       90       10    -1        0  unknown 0     upper
## 4085   aug      205        4    -1        0  unknown 0     upper
## 4086   sep       11        1   490        5    other 0     upper
## 4087   nov      146        2    -1        0  unknown 0     upper
## 4088   aug      272        4    -1        0  unknown 0     upper
## 4089   feb      168        2   203        7  failure 0     upper
## 4090   may      109        1    -1        0  unknown 0   primary
## 4091   may      199        1    -1        0  unknown 0     upper
## 4092   may       60        1   343        7  failure 0     upper
## 4093   may       75        2    -1        0  unknown 0   primary
## 4094   sep        6        1   838        3    other 0     upper
## 4095   jul      924        4    -1        0  unknown 0   primary
## 4096   aug       59        2    -1        0  unknown 0     upper
## 4097   jul      278        3    -1        0  unknown 0     upper
## 4098   may      205        2    -1        0  unknown 0     upper
## 4099   nov      353        1    -1        0  unknown 0     upper
## 4100   oct      246        2   420        2    other 1     upper
## 4101   may      422        1   363        1  failure 0   unknown
## 4102   sep      199        4    -1        0  unknown 0     upper
## 4103   jun      305       10    -1        0  unknown 0     upper
## 4104   may      637        2    -1        0  unknown 0     upper
## 4105   may      264        3    -1        0  unknown 0     upper
## 4106   jul       87        3    -1        0  unknown 0     upper
## 4107   mar      248        4    -1        0  unknown 1     upper
## 4108   may      209        2    -1        0  unknown 0   primary
## 4109   apr       24        1   152        3  failure 0     upper
## 4110   may      182        2    -1        0  unknown 0     upper
## 4111   jul      188        6    -1        0  unknown 0   primary
## 4112   feb      152        1    -1        0  unknown 1     upper
## 4113   may      187        3    -1        0  unknown 0     upper
## 4114   may      337        1    -1        0  unknown 0     upper
## 4115   may       53        7    -1        0  unknown 0   primary
## 4116   aug      168        4    -1        0  unknown 0   primary
## 4117   jul      416        4    -1        0  unknown 1     upper
## 4118   jan       11        4    -1        0  unknown 0     upper
## 4119   aug      219        2    -1        0  unknown 0     upper
## 4120   oct      534        1    -1        0  unknown 0     upper
## 4121   jul      283        1    -1        0  unknown 0     upper
## 4122   aug      160        4    -1        0  unknown 0     upper
## 4123   may      214        1    -1        0  unknown 0     upper
## 4124   jul      249        3    -1        0  unknown 0     upper
## 4125   jun      295        1    -1        0  unknown 1     upper
## 4126   may      431        1    -1        0  unknown 0     upper
## 4127   jul      239        4    -1        0  unknown 0     upper
## 4128   jun      119        3    -1        0  unknown 0   primary
## 4129   jan      553        2    -1        0  unknown 0     upper
## 4130   may      140        1    -1        0  unknown 0     upper
## 4131   may       89        7    -1        0  unknown 0     upper
## 4132   may      112        1   370        1  failure 0     upper
## 4133   jun      218        1    -1        0  unknown 0     upper
## 4134   may      135        1    -1        0  unknown 0   primary
## 4135   mar      237        3    -1        0  unknown 1     upper
## 4136   mar      164        1    -1        0  unknown 0     upper
## 4137   aug      228        6    -1        0  unknown 0   primary
## 4138   may      237        3    -1        0  unknown 0   primary
## 4139   may      396        1    -1        0  unknown 0   primary
## 4140   aug      197        2    -1        0  unknown 0     upper
## 4141   jul      258        1    -1        0  unknown 0     upper
## 4142   jun       14       25    -1        0  unknown 0     upper
## 4143   jun      351        3    -1        0  unknown 0     upper
## 4144   may       37        1    -1        0  unknown 0     upper
## 4145   aug      142        5    -1        0  unknown 0     upper
## 4146   jun      249        2    -1        0  unknown 0     upper
## 4147   nov       69        1    -1        0  unknown 0     upper
## 4148   apr      318        2   332        6    other 0     upper
## 4149   feb      174        1   267        2    other 0     upper
## 4150   may      246        3    -1        0  unknown 0   unknown
## 4151   may     1713        1    -1        0  unknown 0     upper
## 4152   aug      119        3    -1        0  unknown 0     upper
## 4153   oct      102        3    96        3  success 0     upper
## 4154   may      345        1    -1        0  unknown 0     upper
## 4155   may      149        6    -1        0  unknown 0     upper
## 4156   jun       78        2    -1        0  unknown 0   unknown
## 4157   jul      936        4    -1        0  unknown 0     upper
## 4158   nov      198        1    -1        0  unknown 0     upper
## 4159   may      179        1    -1        0  unknown 0   primary
## 4160   jun      486        2    -1        0  unknown 0     upper
## 4161   jul       72        1    -1        0  unknown 0     upper
## 4162   jun      818        1    -1        0  unknown 0     upper
## 4163   nov      209        5    -1        0  unknown 0     upper
## 4164   jun      800        2    -1        0  unknown 0     upper
## 4165   feb      213        2    -1        0  unknown 0     upper
## 4166   may      191        1    -1        0  unknown 0     upper
## 4167   nov       90        3    93        6  success 1     upper
## 4168   aug      491        1    -1        0  unknown 0     upper
## 4169   apr      422        1    -1        0  unknown 0   primary
## 4170   nov      298        2   112        2    other 0     upper
## 4171   sep      167        1    93        3  success 0     upper
## 4172   feb     1294        2    -1        0  unknown 1     upper
## 4173   jan      131        2   206        6    other 0     upper
## 4174   jul      207        2    -1        0  unknown 0   primary
## 4175   jul      214        1    -1        0  unknown 0   primary
## 4176   nov       54        1    -1        0  unknown 0     upper
## 4177   aug       43        5    -1        0  unknown 0     upper
## 4178   may      229        5   268        4  failure 0     upper
## 4179   apr      693        2    -1        0  unknown 0     upper
## 4180   feb      215        1    80        1    other 0     upper
## 4181   may       50        1   352        1  failure 0     upper
## 4182   may       62        2    -1        0  unknown 0     upper
## 4183   may      160        3    -1        0  unknown 0     upper
## 4184   may       53        3    -1        0  unknown 0     upper
## 4185   oct      371        1   495        1  failure 1     upper
## 4186   nov      577        1    -1        0  unknown 0     upper
## 4187   nov      134        1    92        8  success 0     upper
## 4188   aug       99        4    -1        0  unknown 0     upper
## 4189   may      224        2    -1        0  unknown 0     upper
## 4190   jul       15        2    -1        0  unknown 0     upper
## 4191   may      609        1    -1        0  unknown 0     upper
## 4192   may      247        1   261        4  failure 0     upper
## 4193   may       24        1    -1        0  unknown 0     upper
## 4194   may      124        1    -1        0  unknown 0     upper
## 4195   jul      134        1    -1        0  unknown 0     upper
## 4196   jun      583        1    -1        0  unknown 0     upper
## 4197   jul       61        3    -1        0  unknown 0     upper
## 4198   may      238        3    -1        0  unknown 0     upper
## 4199   may       47        1    -1        0  unknown 0     upper
## 4200   aug      965        4    -1        0  unknown 1     upper
## 4201   jun       83        1    -1        0  unknown 0     upper
## 4202   may      203        1    -1        0  unknown 0     upper
## 4203   may      706        3    -1        0  unknown 0   primary
## 4204   aug      123        2    -1        0  unknown 0     upper
## 4205   aug      196        2    -1        0  unknown 0     upper
## 4206   jul      302        1    -1        0  unknown 0   primary
## 4207   jul        5        3    -1        0  unknown 0     upper
## 4208   jun      269        1   104        1  success 1     upper
## 4209   nov      286        1    -1        0  unknown 0     upper
## 4210   aug       87        5    -1        0  unknown 0     upper
## 4211   apr      108        1    -1        0  unknown 0   primary
## 4212   may      114        1    -1        0  unknown 0     upper
## 4213   may      176        1    -1        0  unknown 0     upper
## 4214   jan      259        1    -1        0  unknown 0     upper
## 4215   aug       73        2    -1        0  unknown 0     upper
## 4216   jun       84        2    -1        0  unknown 0     upper
## 4217   may       66        3    -1        0  unknown 0     upper
## 4218   jun       55       25    -1        0  unknown 0     upper
## 4219   apr      370        3   282        2  failure 0   primary
## 4220   may      123        2    -1        0  unknown 0     upper
## 4221   aug      425        6    -1        0  unknown 0     upper
## 4222   may       83        7    -1        0  unknown 0     upper
## 4223   aug      217        1    99        7  success 1     upper
## 4224   aug       96       11    -1        0  unknown 0     upper
## 4225   jun       70        5    -1        0  unknown 0     upper
## 4226   aug      101        1    -1        0  unknown 0     upper
## 4227   may       27        2    -1        0  unknown 0     upper
## 4228   sep      211        1   216        7  success 1     upper
## 4229   may      225        1   364        1  failure 0     upper
## 4230   jul      119        2    -1        0  unknown 0     upper
## 4231   may      686        2    -1        0  unknown 1     upper
## 4232   may      254        1    -1        0  unknown 0     upper
## 4233   mar      105        1   182        1  failure 0     upper
## 4234   jun      534        3    -1        0  unknown 0     upper
## 4235   aug      229        2    -1        0  unknown 0   primary
## 4236   jul      544        1    -1        0  unknown 0     upper
## 4237   nov       73        2    -1        0  unknown 0   primary
## 4238   aug       67        6    -1        0  unknown 0     upper
## 4239   jun      136        1    -1        0  unknown 0   primary
## 4240   may      188        1    -1        0  unknown 0     upper
## 4241   feb      388        1    -1        0  unknown 0     upper
## 4242   jul       93        1    -1        0  unknown 0     upper
## 4243   jul      183        2    -1        0  unknown 0   primary
## 4244   nov       57        1    -1        0  unknown 0     upper
## 4245   jul      271        1    -1        0  unknown 0   primary
## 4246   jul      305        6    -1        0  unknown 0   primary
## 4247   jul      652        2    -1        0  unknown 0     upper
## 4248   may      163        4    -1        0  unknown 0     upper
## 4249   jun      585        2    -1        0  unknown 0     upper
## 4250   may      183        3    -1        0  unknown 0     upper
## 4251   aug      238        1    -1        0  unknown 0     upper
## 4252   aug       78        4    -1        0  unknown 0   primary
## 4253   apr      804        2   262        5  failure 0     upper
## 4254   jun      361        1    -1        0  unknown 0     upper
## 4255   aug      114        2    -1        0  unknown 0     upper
## 4256   sep      121        3   100        5    other 1     upper
## 4257   jun      177        2    -1        0  unknown 0     upper
## 4258   jun      107        1    -1        0  unknown 0     upper
## 4259   may       87        1    -1        0  unknown 0     upper
## 4260   jul      631        1    -1        0  unknown 0     upper
## 4261   aug      144        4    -1        0  unknown 0     upper
## 4262   nov       50        1    -1        0  unknown 0     upper
## 4263   jan      205        1    -1        0  unknown 0     upper
## 4264   jun      219        1    -1        0  unknown 0     upper
## 4265   jun      197        1    -1        0  unknown 0     upper
## 4266   feb       90        2    -1        0  unknown 0     upper
## 4267   jul      517        5    -1        0  unknown 0     upper
## 4268   aug      459        2    -1        0  unknown 1   primary
## 4269   jul      196        1    -1        0  unknown 0     upper
## 4270   jul       87        5    -1        0  unknown 0   primary
## 4271   aug       64        2    -1        0  unknown 0     upper
## 4272   aug      219        1    84        2  failure 0     upper
## 4273   nov      159        1    -1        0  unknown 0     upper
## 4274   aug      192        1    -1        0  unknown 0   primary
## 4275   may      151        1    -1        0  unknown 0     upper
## 4276   aug       91        1     1        6    other 0     upper
## 4277   aug      179        6    -1        0  unknown 0     upper
## 4278   may       54        4    -1        0  unknown 0   primary
## 4279   jul       69        1    -1        0  unknown 0     upper
## 4280   jul      106        3    -1        0  unknown 0   primary
## 4281   may      370        3    -1        0  unknown 0     upper
## 4282   may      180        2    -1        0  unknown 0     upper
## 4283   aug       81        4    -1        0  unknown 0     upper
## 4284   aug      342        5    -1        0  unknown 0     upper
## 4285   may      132        1    -1        0  unknown 0     upper
## 4286   feb       80        2   268        1  failure 0   primary
## 4287   nov       95        1    -1        0  unknown 0     upper
## 4288   may      554        1    -1        0  unknown 0     upper
## 4289   apr      267        2   294        3  failure 0     upper
## 4290   feb       82        3    -1        0  unknown 0     upper
## 4291   may      214        2    -1        0  unknown 0     upper
## 4292   aug      212        2    -1        0  unknown 0     upper
## 4293   jul      127       10    -1        0  unknown 0     upper
## 4294   nov       42        1    -1        0  unknown 0     upper
## 4295   nov       39        9    -1        0  unknown 0     upper
## 4296   aug      219        2    -1        0  unknown 0     upper
## 4297   jul      270        2    -1        0  unknown 0     upper
## 4298   oct      376        1    81        3  failure 0     upper
## 4299   may      289        1    -1        0  unknown 0   primary
## 4300   jun      128        1    -1        0  unknown 0     upper
## 4301   nov       78        2   193        2  failure 0   primary
## 4302   jul      250        1    -1        0  unknown 0     upper
## 4303   apr      875        2    -1        0  unknown 1     upper
## 4304   may      148        2    -1        0  unknown 0     upper
## 4305   may      556        3    -1        0  unknown 0     upper
## 4306   jul       81        6    -1        0  unknown 0     upper
## 4307   may      556        1    -1        0  unknown 0     upper
## 4308   may      106        1   101        2  failure 0     upper
## 4309   may      250        1    -1        0  unknown 0     upper
## 4310   nov      135        4    -1        0  unknown 0     upper
## 4311   may      827        2    -1        0  unknown 1   primary
## 4312   may      314        2    -1        0  unknown 0     upper
## 4313   may      144        2   352        1    other 0     upper
## 4314   may      428        3    -1        0  unknown 0     upper
## 4315   aug      141        2    -1        0  unknown 0     upper
## 4316   jul       84        2    -1        0  unknown 0     upper
## 4317   feb       20        2   256        1  failure 0     upper
## 4318   aug       95        6    -1        0  unknown 0     upper
## 4319   aug      209        3    -1        0  unknown 0     upper
## 4320   jun       87        3    -1        0  unknown 0     upper
## 4321   may      328        2    -1        0  unknown 0   unknown
## 4322   sep        6        1    -1        0  unknown 0     upper
## 4323   jun      184        2    -1        0  unknown 0   primary
## 4324   aug      946        4    -1        0  unknown 1     upper
## 4325   jun       87        6    -1        0  unknown 0   primary
## 4326   aug      545        2    -1        0  unknown 1     upper
## 4327   may      210        1    -1        0  unknown 0     upper
## 4328   jun      281        3   186        6    other 1     upper
## 4329   jul      316        2    -1        0  unknown 0     upper
## 4330   may      565        1    -1        0  unknown 0     upper
## 4331   jun      199        4    -1        0  unknown 0     upper
## 4332   oct      187        1    91       12  success 1     upper
## 4333   feb      131        1    -1        0  unknown 0     upper
## 4334   may      475        3    -1        0  unknown 0     upper
## 4335   apr      160        1    -1        0  unknown 0     upper
## 4336   jul      168        5    -1        0  unknown 0     upper
## 4337   may      371        2    -1        0  unknown 0     upper
## 4338   jul      122        2    -1        0  unknown 0     upper
## 4339   jul       54        2    -1        0  unknown 0     upper
## 4340   apr      125        1    -1        0  unknown 0     upper
## 4341   may       68        2    -1        0  unknown 0   primary
## 4342   apr       37        2    -1        0  unknown 0     upper
## 4343   jul       92        1    -1        0  unknown 0     upper
## 4344   mar      101        1    -1        0  unknown 0     upper
## 4345   may      372       14    -1        0  unknown 0     upper
## 4346   may       67        7   177        1    other 0     upper
## 4347   jul      327        6    -1        0  unknown 0     upper
## 4348   jul      272        1    -1        0  unknown 1   unknown
## 4349   jun       84        2    -1        0  unknown 0     upper
## 4350   may       91        1   356        2    other 0     upper
## 4351   jun       39        3    -1        0  unknown 0   unknown
## 4352   may      181        1    -1        0  unknown 0     upper
## 4353   apr       72        3   341        1    other 0     upper
## 4354   jul      175        1    -1        0  unknown 0     upper
## 4355   jun      136        6    -1        0  unknown 0     upper
## 4356   feb     1226        1    -1        0  unknown 1     upper
## 4357   may     1521        1    -1        0  unknown 0     upper
## 4358   may       58        6    -1        0  unknown 0     upper
## 4359   aug      345        3    -1        0  unknown 0     upper
## 4360   jul      425        2    -1        0  unknown 0     upper
## 4361   nov      190        3    91       11  failure 0   unknown
## 4362   jul      118        1    -1        0  unknown 0   primary
## 4363   jun      157        1    -1        0  unknown 0     upper
## 4364   jun       94       18    -1        0  unknown 0     upper
## 4365   may      148        2    -1        0  unknown 0     upper
## 4366   aug      120        4    -1        0  unknown 0     upper
## 4367   apr      237        3   150        3  failure 0   primary
## 4368   jul      165       23    -1        0  unknown 0     upper
## 4369   may       70        2    -1        0  unknown 0     upper
## 4370   mar      103        3    -1        0  unknown 0     upper
## 4371   may      275        3    -1        0  unknown 0     upper
## 4372   jul        7        5    -1        0  unknown 0     upper
## 4373   apr      204        1    -1        0  unknown 1     upper
## 4374   may      128        5    -1        0  unknown 0   primary
## 4375   apr       54        1   273        3  failure 0     upper
## 4376   jul      362        1    -1        0  unknown 0     upper
## 4377   may      186        4    -1        0  unknown 0     upper
## 4378   apr      555        2    -1        0  unknown 1     upper
## 4379   aug      411        1    -1        0  unknown 1     upper
## 4380   feb      210        2   274        6  failure 0     upper
## 4381   jun      183        2    -1        0  unknown 0   primary
## 4382   aug      334        5    -1        0  unknown 0     upper
## 4383   jul      259       12    -1        0  unknown 0     upper
## 4384   jul      135        2    -1        0  unknown 0     upper
## 4385   may      145        1    -1        0  unknown 0     upper
## 4386   feb      318        1   388        1  success 1     upper
## 4387   jan      123        2    -1        0  unknown 0     upper
## 4388   jul      107        5    -1        0  unknown 0   primary
## 4389   aug      120        6    -1        0  unknown 0     upper
## 4390   may      212        1    -1        0  unknown 0     upper
## 4391   may       53        1    -1        0  unknown 0   primary
## 4392   aug       83        2    -1        0  unknown 0     upper
## 4393   jun      110        2    -1        0  unknown 0     upper
## 4394   nov       14        7    -1        0  unknown 0     upper
## 4395   nov      180        1   186        6  failure 0     upper
## 4396   nov       33        1    -1        0  unknown 0   primary
## 4397   may      153        1    -1        0  unknown 0     upper
## 4398   may      139        1    -1        0  unknown 0     upper
## 4399   nov      709        2    -1        0  unknown 1     upper
## 4400   may      359        1    -1        0  unknown 0     upper
## 4401   jun      126        2    -1        0  unknown 0     upper
## 4402   aug      299        4    -1        0  unknown 0   primary
## 4403   feb       41        3    -1        0  unknown 0     upper
## 4404   apr      462        1   648        1  failure 1     upper
## 4405   may      296        1    -1        0  unknown 0     upper
## 4406   may      190        1    -1        0  unknown 0     upper
## 4407   jul       57        5    -1        0  unknown 0     upper
## 4408   feb      134        2   203        1  success 0     upper
## 4409   nov       62        2   136        3  failure 0     upper
## 4410   jun       48       10    -1        0  unknown 0   primary
## 4411   jun      302        1    -1        0  unknown 0   primary
## 4412   may      550        1    -1        0  unknown 1     upper
## 4413   aug      197        5    -1        0  unknown 0     upper
## 4414   apr      386        2   234        4  failure 0   primary
## 4415   apr      184        2    -1        0  unknown 0     upper
## 4416   jan      653        3    -1        0  unknown 0     upper
## 4417   may       92        2    -1        0  unknown 0     upper
## 4418   nov      101        1    -1        0  unknown 0     upper
## 4419   may      338        4    -1        0  unknown 0     upper
## 4420   may       84        1   343        1    other 0     upper
## 4421   feb       82        2    -1        0  unknown 0     upper
## 4422   may      411        3    -1        0  unknown 0     upper
## 4423   jul      495        1    -1        0  unknown 0     upper
## 4424   aug      308        6    -1        0  unknown 0     upper
## 4425   apr      437        1    80        1  success 1     upper
## 4426   may      272        6    -1        0  unknown 0     upper
## 4427   jul      244        1    -1        0  unknown 0     upper
## 4428   may      302        8    -1        0  unknown 0   primary
## 4429   jun      266        3    -1        0  unknown 0     upper
## 4430   aug      104        2    -1        0  unknown 0   unknown
## 4431   apr      204        1    -1        0  unknown 0     upper
## 4432   jul      654        2    -1        0  unknown 1     upper
## 4433   may      297        1    -1        0  unknown 0     upper
## 4434   jul      313        1    -1        0  unknown 0     upper
## 4435   aug      106        2    -1        0  unknown 0   unknown
## 4436   aug      582        1    -1        0  unknown 1     upper
## 4437   jul       27       17    -1        0  unknown 0     upper
## 4438   may      249        2    -1        0  unknown 0   unknown
## 4439   may      157        2   351        5  failure 0     upper
## 4440   may      463        1   175        4  failure 0   primary
## 4441   feb      429        1    -1        0  unknown 1   primary
## 4442   may      597        6    -1        0  unknown 1     upper
## 4443   feb     1776        2    -1        0  unknown 1     upper
## 4444   aug      726        1    -1        0  unknown 0     upper
## 4445   aug      155        2    -1        0  unknown 0     upper
## 4446   may      588        3    -1        0  unknown 1     upper
## 4447   jul      247        2    -1        0  unknown 0     upper
## 4448   nov        8        5   137        1  failure 0     upper
## 4449   jan      103        1    -1        0  unknown 0     upper
## 4450   aug      163        2    -1        0  unknown 0     upper
## 4451   jan       91        1   223        3  failure 0   primary
## 4452   may      127        1    -1        0  unknown 0   primary
## 4453   nov      658        3   169        2  failure 0     upper
## 4454   aug       56        2    -1        0  unknown 0     upper
## 4455   aug       77        6    -1        0  unknown 0   primary
## 4456   may      122        1   368        2  failure 0     upper
## 4457   aug      156       12    -1        0  unknown 0     upper
## 4458   feb      293        6    -1        0  unknown 0     upper
## 4459   feb       75        1   208        1  failure 0     upper
## 4460   jul       63        2    -1        0  unknown 0     upper
## 4461   jun      103        1    -1        0  unknown 0     upper
## 4462   aug      122        1   109        1    other 0     upper
## 4463   may      480        2    -1        0  unknown 0     upper
## 4464   jul      171       13    -1        0  unknown 0   primary
## 4465   nov       59        2    -1        0  unknown 0     upper
## 4466   jul      115        1    -1        0  unknown 0     upper
## 4467   aug      734        4    -1        0  unknown 1     upper
## 4468   jul      244        7    -1        0  unknown 0     upper
## 4469   jul       85        1    -1        0  unknown 0   primary
## 4470   feb      129        4    -1        0  unknown 0     upper
## 4471   may       98        1   170        2  failure 0     upper
## 4472   feb      308        1    94        4  success 1     upper
## 4473   apr       74        2    -1        0  unknown 0     upper
## 4474   may      116        4   365        1  failure 0   primary
## 4475   jul      106        4    -1        0  unknown 0     upper
## 4476   may      310        2    -1        0  unknown 0     upper
## 4477   jun      750        2    -1        0  unknown 1     upper
## 4478   aug      701        1    -1        0  unknown 0   primary
## 4479   may      209        3    -1        0  unknown 0     upper
## 4480   may      293        6    -1        0  unknown 0     upper
## 4481   jul      270        3    -1        0  unknown 1     upper
## 4482   aug      112        7    -1        0  unknown 0     upper
## 4483   jul      116        1    -1        0  unknown 0     upper
## 4484   aug       83        3    -1        0  unknown 0     upper
## 4485   aug       67        3   280        4  failure 0     upper
## 4486   may      922        4    -1        0  unknown 1     upper
## 4487   jul       73        1    -1        0  unknown 0   primary
## 4488   oct      169        1   134        1    other 0     upper
## 4489   nov      902        2    -1        0  unknown 0   primary
## 4490   may       57        4    -1        0  unknown 0     upper
## 4491   dec      221        1    -1        0  unknown 0   primary
## 4492   aug       87        2    -1        0  unknown 0     upper
## 4493   aug      628        1   182        2  failure 1   unknown
## 4494   apr      431        2    -1        0  unknown 0     upper
## 4495   aug      356        1   364        1    other 1     upper
## 4496   aug       35       14    -1        0  unknown 0     upper
## 4497   aug      201        1   103        1  failure 0     upper
## 4498   apr      792        2    -1        0  unknown 0   primary
## 4499   may      478        1    -1        0  unknown 0     upper
## 4500   jun      781        1    -1        0  unknown 1     upper
## 4501   jun      544        1    -1        0  unknown 1     upper
## 4502   jul      155        3    -1        0  unknown 0   primary
## 4503   feb      226        2    -1        0  unknown 0     upper
## 4504   jun      251        4    -1        0  unknown 0     upper
## 4505   jul      143        1    -1        0  unknown 0     upper
## 4506   jun      133        1    -1        0  unknown 0     upper
## 4507   may      422        2    -1        0  unknown 0   primary
## 4508   jul       71        2    -1        0  unknown 0     upper
## 4509   may      304        4    -1        0  unknown 0   primary
## 4510   may      264        1    -1        0  unknown 0     upper
## 4511   jul      230        1    -1        0  unknown 0     upper
## 4512   aug      117        3    -1        0  unknown 0     upper
## 4513   may      242        1    -1        0  unknown 0     upper
## 4514   may      339        1    -1        0  unknown 0     upper
## 4515   mar      217        1   184        7    other 0     upper
## 4516   aug      209        2    -1        0  unknown 0     upper
## 4517   jul       13       11    -1        0  unknown 0     upper
## 4518   feb      161        4   212        3  failure 0     upper
## 4519   may      246        2    -1        0  unknown 0     upper
## 4520   jul      110        4    -1        0  unknown 0   primary
## 4521   feb      489        2   271        2  success 0     upper
##      education_upper education_unknown education_primary
## 1                  1                 0                 0
## 2                  1                 0                 0
## 3                  1                 0                 0
## 4                  1                 0                 0
## 5                  1                 0                 0
## 6                  1                 0                 0
## 7                  1                 0                 0
## 8                  0                 0                 1
## 9                  1                 0                 0
## 10                 1                 0                 0
## 11                 1                 0                 0
## 12                 0                 0                 1
## 13                 1                 0                 0
## 14                 0                 0                 1
## 15                 1                 0                 0
## 16                 1                 0                 0
## 17                 0                 0                 1
## 18                 0                 1                 0
## 19                 1                 0                 0
## 20                 1                 0                 0
## 21                 1                 0                 0
## 22                 1                 0                 0
## 23                 0                 1                 0
## 24                 1                 0                 0
## 25                 1                 0                 0
## 26                 1                 0                 0
## 27                 1                 0                 0
## 28                 1                 0                 0
## 29                 1                 0                 0
## 30                 1                 0                 0
## 31                 1                 0                 0
## 32                 0                 0                 1
## 33                 1                 0                 0
## 34                 1                 0                 0
## 35                 1                 0                 0
## 36                 1                 0                 0
## 37                 0                 0                 1
## 38                 1                 0                 0
## 39                 0                 0                 1
## 40                 0                 0                 1
## 41                 0                 0                 1
## 42                 1                 0                 0
## 43                 1                 0                 0
## 44                 1                 0                 0
## 45                 1                 0                 0
## 46                 1                 0                 0
## 47                 1                 0                 0
## 48                 0                 0                 1
## 49                 0                 0                 1
## 50                 0                 0                 1
## 51                 0                 1                 0
## 52                 1                 0                 0
## 53                 1                 0                 0
## 54                 1                 0                 0
## 55                 1                 0                 0
## 56                 1                 0                 0
## 57                 1                 0                 0
## 58                 1                 0                 0
## 59                 1                 0                 0
## 60                 1                 0                 0
## 61                 0                 0                 1
## 62                 1                 0                 0
## 63                 1                 0                 0
## 64                 1                 0                 0
## 65                 1                 0                 0
## 66                 1                 0                 0
## 67                 1                 0                 0
## 68                 1                 0                 0
## 69                 1                 0                 0
## 70                 0                 0                 1
## 71                 1                 0                 0
## 72                 1                 0                 0
## 73                 0                 0                 1
## 74                 0                 0                 1
## 75                 1                 0                 0
## 76                 1                 0                 0
## 77                 1                 0                 0
## 78                 1                 0                 0
## 79                 0                 0                 1
## 80                 1                 0                 0
## 81                 1                 0                 0
## 82                 1                 0                 0
## 83                 0                 0                 1
## 84                 1                 0                 0
## 85                 0                 0                 1
## 86                 1                 0                 0
## 87                 1                 0                 0
## 88                 1                 0                 0
## 89                 1                 0                 0
## 90                 1                 0                 0
## 91                 1                 0                 0
## 92                 0                 1                 0
## 93                 1                 0                 0
## 94                 0                 0                 1
## 95                 0                 0                 1
## 96                 1                 0                 0
## 97                 1                 0                 0
## 98                 1                 0                 0
## 99                 0                 0                 1
## 100                1                 0                 0
## 101                1                 0                 0
## 102                1                 0                 0
## 103                1                 0                 0
## 104                1                 0                 0
## 105                0                 0                 1
## 106                1                 0                 0
## 107                0                 0                 1
## 108                1                 0                 0
## 109                1                 0                 0
## 110                1                 0                 0
## 111                0                 0                 1
## 112                1                 0                 0
## 113                1                 0                 0
## 114                0                 1                 0
## 115                1                 0                 0
## 116                0                 0                 1
## 117                1                 0                 0
## 118                1                 0                 0
## 119                1                 0                 0
## 120                1                 0                 0
## 121                1                 0                 0
## 122                1                 0                 0
## 123                1                 0                 0
## 124                0                 0                 1
## 125                1                 0                 0
## 126                1                 0                 0
## 127                1                 0                 0
## 128                1                 0                 0
## 129                1                 0                 0
## 130                1                 0                 0
## 131                1                 0                 0
## 132                1                 0                 0
## 133                1                 0                 0
## 134                1                 0                 0
## 135                1                 0                 0
## 136                0                 0                 1
## 137                1                 0                 0
## 138                1                 0                 0
## 139                1                 0                 0
## 140                1                 0                 0
## 141                1                 0                 0
## 142                1                 0                 0
## 143                1                 0                 0
## 144                1                 0                 0
## 145                1                 0                 0
## 146                0                 0                 1
## 147                1                 0                 0
## 148                1                 0                 0
## 149                1                 0                 0
## 150                1                 0                 0
## 151                1                 0                 0
## 152                1                 0                 0
## 153                1                 0                 0
## 154                1                 0                 0
## 155                1                 0                 0
## 156                1                 0                 0
## 157                1                 0                 0
## 158                0                 0                 1
## 159                0                 0                 1
## 160                1                 0                 0
## 161                1                 0                 0
## 162                1                 0                 0
## 163                1                 0                 0
## 164                0                 1                 0
## 165                1                 0                 0
## 166                1                 0                 0
## 167                1                 0                 0
## 168                0                 0                 1
## 169                1                 0                 0
## 170                1                 0                 0
## 171                0                 0                 1
## 172                0                 0                 1
## 173                1                 0                 0
## 174                1                 0                 0
## 175                1                 0                 0
## 176                1                 0                 0
## 177                0                 0                 1
## 178                1                 0                 0
## 179                1                 0                 0
## 180                0                 1                 0
## 181                1                 0                 0
## 182                0                 0                 1
## 183                1                 0                 0
## 184                1                 0                 0
## 185                1                 0                 0
## 186                0                 0                 1
## 187                1                 0                 0
## 188                1                 0                 0
## 189                1                 0                 0
## 190                1                 0                 0
## 191                0                 0                 1
## 192                1                 0                 0
## 193                1                 0                 0
## 194                1                 0                 0
## 195                1                 0                 0
## 196                0                 0                 1
## 197                1                 0                 0
## 198                1                 0                 0
## 199                1                 0                 0
## 200                0                 1                 0
## 201                0                 0                 1
## 202                1                 0                 0
## 203                1                 0                 0
## 204                1                 0                 0
## 205                1                 0                 0
## 206                1                 0                 0
## 207                1                 0                 0
## 208                0                 0                 1
## 209                1                 0                 0
## 210                1                 0                 0
## 211                1                 0                 0
## 212                1                 0                 0
## 213                1                 0                 0
## 214                1                 0                 0
## 215                1                 0                 0
## 216                1                 0                 0
## 217                1                 0                 0
## 218                1                 0                 0
## 219                1                 0                 0
## 220                1                 0                 0
## 221                1                 0                 0
## 222                0                 0                 1
## 223                1                 0                 0
## 224                1                 0                 0
## 225                0                 0                 1
## 226                1                 0                 0
## 227                1                 0                 0
## 228                0                 0                 1
## 229                1                 0                 0
## 230                0                 0                 1
## 231                0                 1                 0
## 232                0                 0                 1
## 233                0                 0                 1
## 234                1                 0                 0
## 235                1                 0                 0
## 236                0                 0                 1
## 237                1                 0                 0
## 238                1                 0                 0
## 239                1                 0                 0
## 240                1                 0                 0
## 241                0                 0                 1
## 242                0                 0                 1
## 243                0                 1                 0
## 244                1                 0                 0
## 245                1                 0                 0
## 246                1                 0                 0
## 247                1                 0                 0
## 248                1                 0                 0
## 249                0                 0                 1
## 250                1                 0                 0
## 251                1                 0                 0
## 252                1                 0                 0
## 253                1                 0                 0
## 254                1                 0                 0
## 255                1                 0                 0
## 256                1                 0                 0
## 257                1                 0                 0
## 258                1                 0                 0
## 259                1                 0                 0
## 260                0                 0                 1
## 261                0                 0                 1
## 262                0                 0                 1
## 263                1                 0                 0
## 264                1                 0                 0
## 265                1                 0                 0
## 266                1                 0                 0
## 267                0                 1                 0
## 268                0                 0                 1
## 269                0                 0                 1
## 270                1                 0                 0
## 271                0                 0                 1
## 272                1                 0                 0
## 273                1                 0                 0
## 274                1                 0                 0
## 275                1                 0                 0
## 276                1                 0                 0
## 277                0                 0                 1
## 278                1                 0                 0
## 279                1                 0                 0
## 280                0                 0                 1
## 281                1                 0                 0
## 282                1                 0                 0
## 283                1                 0                 0
## 284                0                 1                 0
## 285                1                 0                 0
## 286                0                 0                 1
## 287                1                 0                 0
## 288                1                 0                 0
## 289                1                 0                 0
## 290                0                 0                 1
## 291                1                 0                 0
## 292                1                 0                 0
## 293                1                 0                 0
## 294                1                 0                 0
## 295                1                 0                 0
## 296                1                 0                 0
## 297                0                 0                 1
## 298                1                 0                 0
## 299                1                 0                 0
## 300                1                 0                 0
## 301                1                 0                 0
## 302                1                 0                 0
## 303                1                 0                 0
## 304                1                 0                 0
## 305                1                 0                 0
## 306                1                 0                 0
## 307                0                 0                 1
## 308                1                 0                 0
## 309                1                 0                 0
## 310                1                 0                 0
## 311                1                 0                 0
## 312                0                 0                 1
## 313                1                 0                 0
## 314                1                 0                 0
## 315                1                 0                 0
## 316                1                 0                 0
## 317                1                 0                 0
## 318                1                 0                 0
## 319                1                 0                 0
## 320                1                 0                 0
## 321                0                 0                 1
## 322                1                 0                 0
## 323                1                 0                 0
## 324                0                 0                 1
## 325                1                 0                 0
## 326                1                 0                 0
## 327                1                 0                 0
## 328                1                 0                 0
## 329                1                 0                 0
## 330                0                 0                 1
## 331                0                 0                 1
## 332                1                 0                 0
## 333                0                 0                 1
## 334                0                 0                 1
## 335                1                 0                 0
## 336                1                 0                 0
## 337                1                 0                 0
## 338                0                 0                 1
## 339                0                 0                 1
## 340                1                 0                 0
## 341                1                 0                 0
## 342                1                 0                 0
## 343                1                 0                 0
## 344                1                 0                 0
## 345                1                 0                 0
## 346                1                 0                 0
## 347                1                 0                 0
## 348                1                 0                 0
## 349                1                 0                 0
## 350                0                 0                 1
## 351                1                 0                 0
## 352                1                 0                 0
## 353                1                 0                 0
## 354                1                 0                 0
## 355                1                 0                 0
## 356                1                 0                 0
## 357                1                 0                 0
## 358                1                 0                 0
## 359                1                 0                 0
## 360                1                 0                 0
## 361                1                 0                 0
## 362                1                 0                 0
## 363                1                 0                 0
## 364                0                 0                 1
## 365                1                 0                 0
## 366                1                 0                 0
## 367                1                 0                 0
## 368                1                 0                 0
## 369                1                 0                 0
## 370                1                 0                 0
## 371                1                 0                 0
## 372                0                 0                 1
## 373                1                 0                 0
## 374                0                 0                 1
## 375                1                 0                 0
## 376                1                 0                 0
## 377                1                 0                 0
## 378                1                 0                 0
## 379                1                 0                 0
## 380                1                 0                 0
## 381                1                 0                 0
## 382                1                 0                 0
## 383                1                 0                 0
## 384                1                 0                 0
## 385                0                 0                 1
## 386                1                 0                 0
## 387                1                 0                 0
## 388                1                 0                 0
## 389                1                 0                 0
## 390                1                 0                 0
## 391                1                 0                 0
## 392                0                 0                 1
## 393                1                 0                 0
## 394                1                 0                 0
## 395                0                 1                 0
## 396                1                 0                 0
## 397                1                 0                 0
## 398                1                 0                 0
## 399                1                 0                 0
## 400                1                 0                 0
## 401                1                 0                 0
## 402                1                 0                 0
## 403                1                 0                 0
## 404                0                 0                 1
## 405                0                 0                 1
## 406                1                 0                 0
## 407                1                 0                 0
## 408                1                 0                 0
## 409                1                 0                 0
## 410                1                 0                 0
## 411                1                 0                 0
## 412                1                 0                 0
## 413                1                 0                 0
## 414                0                 1                 0
## 415                1                 0                 0
## 416                0                 1                 0
## 417                1                 0                 0
## 418                0                 1                 0
## 419                1                 0                 0
## 420                1                 0                 0
## 421                1                 0                 0
## 422                0                 1                 0
## 423                1                 0                 0
## 424                0                 1                 0
## 425                1                 0                 0
## 426                1                 0                 0
## 427                0                 1                 0
## 428                1                 0                 0
## 429                1                 0                 0
## 430                1                 0                 0
## 431                0                 0                 1
## 432                1                 0                 0
## 433                1                 0                 0
## 434                1                 0                 0
## 435                0                 0                 1
## 436                1                 0                 0
## 437                1                 0                 0
## 438                1                 0                 0
## 439                0                 0                 1
## 440                0                 0                 1
## 441                1                 0                 0
## 442                1                 0                 0
## 443                1                 0                 0
## 444                1                 0                 0
## 445                0                 0                 1
## 446                1                 0                 0
## 447                1                 0                 0
## 448                1                 0                 0
## 449                1                 0                 0
## 450                1                 0                 0
## 451                1                 0                 0
## 452                1                 0                 0
## 453                1                 0                 0
## 454                1                 0                 0
## 455                1                 0                 0
## 456                1                 0                 0
## 457                0                 0                 1
## 458                1                 0                 0
## 459                1                 0                 0
## 460                1                 0                 0
## 461                0                 0                 1
## 462                1                 0                 0
## 463                0                 1                 0
## 464                1                 0                 0
## 465                1                 0                 0
## 466                1                 0                 0
## 467                0                 0                 1
## 468                1                 0                 0
## 469                1                 0                 0
## 470                1                 0                 0
## 471                1                 0                 0
## 472                0                 0                 1
## 473                0                 0                 1
## 474                1                 0                 0
## 475                1                 0                 0
## 476                1                 0                 0
## 477                1                 0                 0
## 478                0                 0                 1
## 479                1                 0                 0
## 480                1                 0                 0
## 481                0                 0                 1
## 482                1                 0                 0
## 483                0                 0                 1
## 484                1                 0                 0
## 485                1                 0                 0
## 486                1                 0                 0
## 487                1                 0                 0
## 488                1                 0                 0
## 489                1                 0                 0
## 490                1                 0                 0
## 491                1                 0                 0
## 492                1                 0                 0
## 493                1                 0                 0
## 494                1                 0                 0
## 495                0                 0                 1
## 496                1                 0                 0
## 497                1                 0                 0
## 498                1                 0                 0
## 499                1                 0                 0
## 500                1                 0                 0
## 501                1                 0                 0
## 502                1                 0                 0
## 503                1                 0                 0
## 504                1                 0                 0
## 505                0                 0                 1
## 506                1                 0                 0
## 507                0                 0                 1
## 508                1                 0                 0
## 509                1                 0                 0
## 510                0                 0                 1
## 511                1                 0                 0
## 512                1                 0                 0
## 513                1                 0                 0
## 514                1                 0                 0
## 515                1                 0                 0
## 516                0                 0                 1
## 517                1                 0                 0
## 518                1                 0                 0
## 519                1                 0                 0
## 520                0                 0                 1
## 521                0                 0                 1
## 522                1                 0                 0
## 523                1                 0                 0
## 524                1                 0                 0
## 525                1                 0                 0
## 526                1                 0                 0
## 527                1                 0                 0
## 528                0                 0                 1
## 529                1                 0                 0
## 530                1                 0                 0
## 531                1                 0                 0
## 532                0                 0                 1
## 533                0                 0                 1
## 534                1                 0                 0
## 535                1                 0                 0
## 536                1                 0                 0
## 537                1                 0                 0
## 538                1                 0                 0
## 539                1                 0                 0
## 540                1                 0                 0
## 541                1                 0                 0
## 542                0                 1                 0
## 543                1                 0                 0
## 544                1                 0                 0
## 545                1                 0                 0
## 546                1                 0                 0
## 547                1                 0                 0
## 548                0                 0                 1
## 549                1                 0                 0
## 550                1                 0                 0
## 551                1                 0                 0
## 552                1                 0                 0
## 553                1                 0                 0
## 554                1                 0                 0
## 555                0                 0                 1
## 556                1                 0                 0
## 557                1                 0                 0
## 558                1                 0                 0
## 559                1                 0                 0
## 560                1                 0                 0
## 561                1                 0                 0
## 562                1                 0                 0
## 563                1                 0                 0
## 564                1                 0                 0
## 565                1                 0                 0
## 566                1                 0                 0
## 567                1                 0                 0
## 568                1                 0                 0
## 569                1                 0                 0
## 570                1                 0                 0
## 571                1                 0                 0
## 572                1                 0                 0
## 573                1                 0                 0
## 574                1                 0                 0
## 575                1                 0                 0
## 576                1                 0                 0
## 577                1                 0                 0
## 578                1                 0                 0
## 579                0                 0                 1
## 580                1                 0                 0
## 581                1                 0                 0
## 582                0                 0                 1
## 583                1                 0                 0
## 584                0                 0                 1
## 585                1                 0                 0
## 586                1                 0                 0
## 587                1                 0                 0
## 588                1                 0                 0
## 589                0                 0                 1
## 590                1                 0                 0
## 591                1                 0                 0
## 592                1                 0                 0
## 593                1                 0                 0
## 594                0                 0                 1
## 595                1                 0                 0
## 596                1                 0                 0
## 597                1                 0                 0
## 598                1                 0                 0
## 599                1                 0                 0
## 600                1                 0                 0
## 601                1                 0                 0
## 602                1                 0                 0
## 603                1                 0                 0
## 604                0                 0                 1
## 605                1                 0                 0
## 606                1                 0                 0
## 607                1                 0                 0
## 608                1                 0                 0
## 609                1                 0                 0
## 610                1                 0                 0
## 611                1                 0                 0
## 612                1                 0                 0
## 613                1                 0                 0
## 614                1                 0                 0
## 615                1                 0                 0
## 616                0                 0                 1
## 617                1                 0                 0
## 618                0                 0                 1
## 619                1                 0                 0
## 620                1                 0                 0
## 621                1                 0                 0
## 622                1                 0                 0
## 623                1                 0                 0
## 624                1                 0                 0
## 625                0                 1                 0
## 626                1                 0                 0
## 627                1                 0                 0
## 628                1                 0                 0
## 629                1                 0                 0
## 630                1                 0                 0
## 631                1                 0                 0
## 632                1                 0                 0
## 633                1                 0                 0
## 634                1                 0                 0
## 635                1                 0                 0
## 636                1                 0                 0
## 637                1                 0                 0
## 638                0                 0                 1
## 639                1                 0                 0
## 640                1                 0                 0
## 641                1                 0                 0
## 642                1                 0                 0
## 643                1                 0                 0
## 644                1                 0                 0
## 645                1                 0                 0
## 646                1                 0                 0
## 647                1                 0                 0
## 648                1                 0                 0
## 649                1                 0                 0
## 650                1                 0                 0
## 651                1                 0                 0
## 652                1                 0                 0
## 653                1                 0                 0
## 654                1                 0                 0
## 655                1                 0                 0
## 656                1                 0                 0
## 657                1                 0                 0
## 658                1                 0                 0
## 659                1                 0                 0
## 660                0                 1                 0
## 661                1                 0                 0
## 662                1                 0                 0
## 663                1                 0                 0
## 664                1                 0                 0
## 665                1                 0                 0
## 666                1                 0                 0
## 667                1                 0                 0
## 668                1                 0                 0
## 669                1                 0                 0
## 670                1                 0                 0
## 671                1                 0                 0
## 672                1                 0                 0
## 673                1                 0                 0
## 674                1                 0                 0
## 675                1                 0                 0
## 676                1                 0                 0
## 677                1                 0                 0
## 678                1                 0                 0
## 679                0                 0                 1
## 680                1                 0                 0
## 681                0                 0                 1
## 682                1                 0                 0
## 683                1                 0                 0
## 684                1                 0                 0
## 685                1                 0                 0
## 686                1                 0                 0
## 687                0                 1                 0
## 688                1                 0                 0
## 689                1                 0                 0
## 690                1                 0                 0
## 691                1                 0                 0
## 692                1                 0                 0
## 693                1                 0                 0
## 694                1                 0                 0
## 695                1                 0                 0
## 696                1                 0                 0
## 697                0                 0                 1
## 698                1                 0                 0
## 699                1                 0                 0
## 700                1                 0                 0
## 701                1                 0                 0
## 702                1                 0                 0
## 703                1                 0                 0
## 704                1                 0                 0
## 705                1                 0                 0
## 706                1                 0                 0
## 707                1                 0                 0
## 708                1                 0                 0
## 709                1                 0                 0
## 710                0                 1                 0
## 711                1                 0                 0
## 712                1                 0                 0
## 713                1                 0                 0
## 714                0                 0                 1
## 715                1                 0                 0
## 716                1                 0                 0
## 717                1                 0                 0
## 718                1                 0                 0
## 719                1                 0                 0
## 720                1                 0                 0
## 721                1                 0                 0
## 722                0                 0                 1
## 723                1                 0                 0
## 724                1                 0                 0
## 725                1                 0                 0
## 726                0                 1                 0
## 727                1                 0                 0
## 728                1                 0                 0
## 729                1                 0                 0
## 730                1                 0                 0
## 731                1                 0                 0
## 732                0                 0                 1
## 733                1                 0                 0
## 734                0                 0                 1
## 735                0                 0                 1
## 736                1                 0                 0
## 737                1                 0                 0
## 738                1                 0                 0
## 739                1                 0                 0
## 740                1                 0                 0
## 741                0                 0                 1
## 742                1                 0                 0
## 743                1                 0                 0
## 744                1                 0                 0
## 745                1                 0                 0
## 746                1                 0                 0
## 747                1                 0                 0
## 748                1                 0                 0
## 749                1                 0                 0
## 750                0                 0                 1
## 751                1                 0                 0
## 752                1                 0                 0
## 753                1                 0                 0
## 754                1                 0                 0
## 755                1                 0                 0
## 756                1                 0                 0
## 757                1                 0                 0
## 758                1                 0                 0
## 759                1                 0                 0
## 760                1                 0                 0
## 761                1                 0                 0
## 762                1                 0                 0
## 763                1                 0                 0
## 764                1                 0                 0
## 765                1                 0                 0
## 766                1                 0                 0
## 767                1                 0                 0
## 768                0                 0                 1
## 769                1                 0                 0
## 770                0                 1                 0
## 771                1                 0                 0
## 772                1                 0                 0
## 773                0                 0                 1
## 774                0                 1                 0
## 775                1                 0                 0
## 776                1                 0                 0
## 777                1                 0                 0
## 778                1                 0                 0
## 779                1                 0                 0
## 780                1                 0                 0
## 781                0                 0                 1
## 782                1                 0                 0
## 783                1                 0                 0
## 784                1                 0                 0
## 785                0                 0                 1
## 786                1                 0                 0
## 787                1                 0                 0
## 788                1                 0                 0
## 789                1                 0                 0
## 790                1                 0                 0
## 791                1                 0                 0
## 792                1                 0                 0
## 793                1                 0                 0
## 794                1                 0                 0
## 795                1                 0                 0
## 796                1                 0                 0
## 797                1                 0                 0
## 798                1                 0                 0
## 799                1                 0                 0
## 800                1                 0                 0
## 801                0                 0                 1
## 802                1                 0                 0
## 803                1                 0                 0
## 804                1                 0                 0
## 805                1                 0                 0
## 806                0                 1                 0
## 807                1                 0                 0
## 808                1                 0                 0
## 809                1                 0                 0
## 810                1                 0                 0
## 811                1                 0                 0
## 812                1                 0                 0
## 813                1                 0                 0
## 814                1                 0                 0
## 815                1                 0                 0
## 816                1                 0                 0
## 817                1                 0                 0
## 818                1                 0                 0
## 819                1                 0                 0
## 820                1                 0                 0
## 821                1                 0                 0
## 822                1                 0                 0
## 823                1                 0                 0
## 824                1                 0                 0
## 825                1                 0                 0
## 826                0                 0                 1
## 827                1                 0                 0
## 828                1                 0                 0
## 829                1                 0                 0
## 830                1                 0                 0
## 831                1                 0                 0
## 832                1                 0                 0
## 833                1                 0                 0
## 834                1                 0                 0
## 835                1                 0                 0
## 836                1                 0                 0
## 837                1                 0                 0
## 838                1                 0                 0
## 839                1                 0                 0
## 840                0                 1                 0
## 841                1                 0                 0
## 842                0                 0                 1
## 843                1                 0                 0
## 844                1                 0                 0
## 845                0                 0                 1
## 846                1                 0                 0
## 847                1                 0                 0
## 848                1                 0                 0
## 849                1                 0                 0
## 850                0                 0                 1
## 851                1                 0                 0
## 852                0                 1                 0
## 853                1                 0                 0
## 854                1                 0                 0
## 855                1                 0                 0
## 856                1                 0                 0
## 857                1                 0                 0
## 858                0                 0                 1
## 859                1                 0                 0
## 860                1                 0                 0
## 861                1                 0                 0
## 862                1                 0                 0
## 863                0                 0                 1
## 864                1                 0                 0
## 865                1                 0                 0
## 866                0                 0                 1
## 867                1                 0                 0
## 868                1                 0                 0
## 869                1                 0                 0
## 870                1                 0                 0
## 871                1                 0                 0
## 872                0                 0                 1
## 873                1                 0                 0
## 874                1                 0                 0
## 875                1                 0                 0
## 876                0                 0                 1
## 877                1                 0                 0
## 878                1                 0                 0
## 879                0                 1                 0
## 880                1                 0                 0
## 881                1                 0                 0
## 882                1                 0                 0
## 883                1                 0                 0
## 884                0                 0                 1
## 885                1                 0                 0
## 886                1                 0                 0
## 887                1                 0                 0
## 888                1                 0                 0
## 889                1                 0                 0
## 890                1                 0                 0
## 891                1                 0                 0
## 892                1                 0                 0
## 893                1                 0                 0
## 894                1                 0                 0
## 895                0                 0                 1
## 896                1                 0                 0
## 897                1                 0                 0
## 898                1                 0                 0
## 899                0                 0                 1
## 900                1                 0                 0
## 901                1                 0                 0
## 902                1                 0                 0
## 903                1                 0                 0
## 904                1                 0                 0
## 905                0                 1                 0
## 906                1                 0                 0
## 907                1                 0                 0
## 908                0                 0                 1
## 909                1                 0                 0
## 910                0                 0                 1
## 911                1                 0                 0
## 912                1                 0                 0
## 913                1                 0                 0
## 914                0                 0                 1
## 915                1                 0                 0
## 916                0                 0                 1
## 917                1                 0                 0
## 918                1                 0                 0
## 919                1                 0                 0
## 920                1                 0                 0
## 921                1                 0                 0
## 922                1                 0                 0
## 923                1                 0                 0
## 924                0                 0                 1
## 925                1                 0                 0
## 926                1                 0                 0
## 927                1                 0                 0
## 928                1                 0                 0
## 929                0                 1                 0
## 930                1                 0                 0
## 931                1                 0                 0
## 932                1                 0                 0
## 933                1                 0                 0
## 934                1                 0                 0
## 935                1                 0                 0
## 936                1                 0                 0
## 937                0                 0                 1
## 938                1                 0                 0
## 939                1                 0                 0
## 940                1                 0                 0
## 941                1                 0                 0
## 942                1                 0                 0
## 943                1                 0                 0
## 944                1                 0                 0
## 945                1                 0                 0
## 946                1                 0                 0
## 947                0                 0                 1
## 948                1                 0                 0
## 949                1                 0                 0
## 950                0                 0                 1
## 951                1                 0                 0
## 952                1                 0                 0
## 953                1                 0                 0
## 954                0                 0                 1
## 955                1                 0                 0
## 956                1                 0                 0
## 957                1                 0                 0
## 958                1                 0                 0
## 959                0                 0                 1
## 960                0                 1                 0
## 961                0                 0                 1
## 962                1                 0                 0
## 963                1                 0                 0
## 964                1                 0                 0
## 965                1                 0                 0
## 966                1                 0                 0
## 967                0                 0                 1
## 968                0                 0                 1
## 969                1                 0                 0
## 970                1                 0                 0
## 971                0                 0                 1
## 972                1                 0                 0
## 973                0                 0                 1
## 974                1                 0                 0
## 975                1                 0                 0
## 976                1                 0                 0
## 977                0                 0                 1
## 978                1                 0                 0
## 979                1                 0                 0
## 980                1                 0                 0
## 981                0                 0                 1
## 982                1                 0                 0
## 983                1                 0                 0
## 984                1                 0                 0
## 985                1                 0                 0
## 986                1                 0                 0
## 987                1                 0                 0
## 988                1                 0                 0
## 989                1                 0                 0
## 990                1                 0                 0
## 991                1                 0                 0
## 992                1                 0                 0
## 993                1                 0                 0
## 994                1                 0                 0
## 995                1                 0                 0
## 996                1                 0                 0
## 997                0                 0                 1
## 998                1                 0                 0
## 999                0                 0                 1
## 1000               1                 0                 0
## 1001               0                 0                 1
## 1002               1                 0                 0
## 1003               0                 0                 1
## 1004               1                 0                 0
## 1005               0                 0                 1
## 1006               1                 0                 0
## 1007               1                 0                 0
## 1008               1                 0                 0
## 1009               1                 0                 0
## 1010               1                 0                 0
## 1011               1                 0                 0
## 1012               1                 0                 0
## 1013               1                 0                 0
## 1014               1                 0                 0
## 1015               1                 0                 0
## 1016               0                 0                 1
## 1017               1                 0                 0
## 1018               1                 0                 0
## 1019               1                 0                 0
## 1020               1                 0                 0
## 1021               1                 0                 0
## 1022               0                 1                 0
## 1023               1                 0                 0
## 1024               0                 1                 0
## 1025               1                 0                 0
## 1026               1                 0                 0
## 1027               1                 0                 0
## 1028               1                 0                 0
## 1029               1                 0                 0
## 1030               1                 0                 0
## 1031               1                 0                 0
## 1032               1                 0                 0
## 1033               1                 0                 0
## 1034               0                 0                 1
## 1035               1                 0                 0
## 1036               1                 0                 0
## 1037               1                 0                 0
## 1038               0                 1                 0
## 1039               1                 0                 0
## 1040               1                 0                 0
## 1041               1                 0                 0
## 1042               1                 0                 0
## 1043               1                 0                 0
## 1044               1                 0                 0
## 1045               1                 0                 0
## 1046               1                 0                 0
## 1047               1                 0                 0
## 1048               1                 0                 0
## 1049               1                 0                 0
## 1050               1                 0                 0
## 1051               1                 0                 0
## 1052               0                 0                 1
## 1053               0                 0                 1
## 1054               0                 1                 0
## 1055               1                 0                 0
## 1056               1                 0                 0
## 1057               0                 1                 0
## 1058               1                 0                 0
## 1059               1                 0                 0
## 1060               1                 0                 0
## 1061               1                 0                 0
## 1062               1                 0                 0
## 1063               1                 0                 0
## 1064               1                 0                 0
## 1065               0                 0                 1
## 1066               1                 0                 0
## 1067               1                 0                 0
## 1068               1                 0                 0
## 1069               0                 0                 1
## 1070               1                 0                 0
## 1071               1                 0                 0
## 1072               1                 0                 0
## 1073               1                 0                 0
## 1074               1                 0                 0
## 1075               1                 0                 0
## 1076               1                 0                 0
## 1077               1                 0                 0
## 1078               0                 0                 1
## 1079               1                 0                 0
## 1080               0                 0                 1
## 1081               1                 0                 0
## 1082               1                 0                 0
## 1083               1                 0                 0
## 1084               1                 0                 0
## 1085               1                 0                 0
## 1086               1                 0                 0
## 1087               0                 0                 1
## 1088               1                 0                 0
## 1089               0                 0                 1
## 1090               1                 0                 0
## 1091               1                 0                 0
## 1092               1                 0                 0
## 1093               1                 0                 0
## 1094               1                 0                 0
## 1095               1                 0                 0
## 1096               0                 1                 0
## 1097               1                 0                 0
## 1098               1                 0                 0
## 1099               1                 0                 0
## 1100               1                 0                 0
## 1101               1                 0                 0
## 1102               1                 0                 0
## 1103               1                 0                 0
## 1104               0                 0                 1
## 1105               0                 0                 1
## 1106               0                 0                 1
## 1107               1                 0                 0
## 1108               1                 0                 0
## 1109               1                 0                 0
## 1110               0                 0                 1
## 1111               1                 0                 0
## 1112               1                 0                 0
## 1113               0                 0                 1
## 1114               1                 0                 0
## 1115               1                 0                 0
## 1116               1                 0                 0
## 1117               1                 0                 0
## 1118               1                 0                 0
## 1119               0                 0                 1
## 1120               1                 0                 0
## 1121               1                 0                 0
## 1122               1                 0                 0
## 1123               1                 0                 0
## 1124               1                 0                 0
## 1125               0                 0                 1
## 1126               1                 0                 0
## 1127               1                 0                 0
## 1128               1                 0                 0
## 1129               1                 0                 0
## 1130               1                 0                 0
## 1131               1                 0                 0
## 1132               0                 0                 1
## 1133               0                 0                 1
## 1134               1                 0                 0
## 1135               0                 1                 0
## 1136               1                 0                 0
## 1137               1                 0                 0
## 1138               1                 0                 0
## 1139               1                 0                 0
## 1140               1                 0                 0
## 1141               1                 0                 0
## 1142               1                 0                 0
## 1143               0                 0                 1
## 1144               1                 0                 0
## 1145               1                 0                 0
## 1146               1                 0                 0
## 1147               1                 0                 0
## 1148               1                 0                 0
## 1149               1                 0                 0
## 1150               0                 0                 1
## 1151               1                 0                 0
## 1152               1                 0                 0
## 1153               1                 0                 0
## 1154               1                 0                 0
## 1155               1                 0                 0
## 1156               1                 0                 0
## 1157               1                 0                 0
## 1158               1                 0                 0
## 1159               1                 0                 0
## 1160               1                 0                 0
## 1161               1                 0                 0
## 1162               1                 0                 0
## 1163               0                 1                 0
## 1164               0                 0                 1
## 1165               1                 0                 0
## 1166               1                 0                 0
## 1167               1                 0                 0
## 1168               1                 0                 0
## 1169               1                 0                 0
## 1170               1                 0                 0
## 1171               0                 0                 1
## 1172               1                 0                 0
## 1173               1                 0                 0
## 1174               1                 0                 0
## 1175               1                 0                 0
## 1176               1                 0                 0
## 1177               0                 0                 1
## 1178               0                 1                 0
## 1179               1                 0                 0
## 1180               1                 0                 0
## 1181               1                 0                 0
## 1182               1                 0                 0
## 1183               1                 0                 0
## 1184               0                 1                 0
## 1185               0                 0                 1
## 1186               0                 0                 1
## 1187               1                 0                 0
## 1188               0                 1                 0
## 1189               1                 0                 0
## 1190               0                 1                 0
## 1191               1                 0                 0
## 1192               1                 0                 0
## 1193               1                 0                 0
## 1194               1                 0                 0
## 1195               1                 0                 0
## 1196               1                 0                 0
## 1197               1                 0                 0
## 1198               1                 0                 0
## 1199               1                 0                 0
## 1200               1                 0                 0
## 1201               1                 0                 0
## 1202               1                 0                 0
## 1203               1                 0                 0
## 1204               0                 0                 1
## 1205               1                 0                 0
## 1206               0                 1                 0
## 1207               1                 0                 0
## 1208               1                 0                 0
## 1209               1                 0                 0
## 1210               1                 0                 0
## 1211               1                 0                 0
## 1212               1                 0                 0
## 1213               1                 0                 0
## 1214               1                 0                 0
## 1215               1                 0                 0
## 1216               1                 0                 0
## 1217               1                 0                 0
## 1218               1                 0                 0
## 1219               1                 0                 0
## 1220               1                 0                 0
## 1221               1                 0                 0
## 1222               1                 0                 0
## 1223               1                 0                 0
## 1224               1                 0                 0
## 1225               0                 0                 1
## 1226               1                 0                 0
## 1227               0                 0                 1
## 1228               1                 0                 0
## 1229               1                 0                 0
## 1230               1                 0                 0
## 1231               0                 0                 1
## 1232               1                 0                 0
## 1233               1                 0                 0
## 1234               1                 0                 0
## 1235               1                 0                 0
## 1236               1                 0                 0
## 1237               0                 1                 0
## 1238               1                 0                 0
## 1239               0                 0                 1
## 1240               1                 0                 0
## 1241               1                 0                 0
## 1242               0                 0                 1
## 1243               1                 0                 0
## 1244               1                 0                 0
## 1245               0                 0                 1
## 1246               1                 0                 0
## 1247               1                 0                 0
## 1248               1                 0                 0
## 1249               1                 0                 0
## 1250               0                 1                 0
## 1251               1                 0                 0
## 1252               1                 0                 0
## 1253               1                 0                 0
## 1254               1                 0                 0
## 1255               1                 0                 0
## 1256               1                 0                 0
## 1257               1                 0                 0
## 1258               0                 1                 0
## 1259               0                 0                 1
## 1260               1                 0                 0
## 1261               1                 0                 0
## 1262               0                 0                 1
## 1263               1                 0                 0
## 1264               0                 0                 1
## 1265               1                 0                 0
## 1266               1                 0                 0
## 1267               0                 0                 1
## 1268               1                 0                 0
## 1269               1                 0                 0
## 1270               1                 0                 0
## 1271               1                 0                 0
## 1272               1                 0                 0
## 1273               1                 0                 0
## 1274               1                 0                 0
## 1275               1                 0                 0
## 1276               1                 0                 0
## 1277               1                 0                 0
## 1278               1                 0                 0
## 1279               1                 0                 0
## 1280               1                 0                 0
## 1281               1                 0                 0
## 1282               1                 0                 0
## 1283               1                 0                 0
## 1284               1                 0                 0
## 1285               1                 0                 0
## 1286               0                 0                 1
## 1287               1                 0                 0
## 1288               1                 0                 0
## 1289               1                 0                 0
## 1290               1                 0                 0
## 1291               1                 0                 0
## 1292               1                 0                 0
## 1293               0                 1                 0
## 1294               1                 0                 0
## 1295               0                 0                 1
## 1296               0                 1                 0
## 1297               1                 0                 0
## 1298               1                 0                 0
## 1299               1                 0                 0
## 1300               1                 0                 0
## 1301               1                 0                 0
## 1302               1                 0                 0
## 1303               1                 0                 0
## 1304               1                 0                 0
## 1305               1                 0                 0
## 1306               1                 0                 0
## 1307               1                 0                 0
## 1308               1                 0                 0
## 1309               1                 0                 0
## 1310               1                 0                 0
## 1311               1                 0                 0
## 1312               1                 0                 0
## 1313               1                 0                 0
## 1314               1                 0                 0
## 1315               1                 0                 0
## 1316               1                 0                 0
## 1317               1                 0                 0
## 1318               1                 0                 0
## 1319               0                 0                 1
## 1320               1                 0                 0
## 1321               1                 0                 0
## 1322               1                 0                 0
## 1323               0                 1                 0
## 1324               1                 0                 0
## 1325               1                 0                 0
## 1326               1                 0                 0
## 1327               0                 0                 1
## 1328               1                 0                 0
## 1329               0                 1                 0
## 1330               1                 0                 0
## 1331               1                 0                 0
## 1332               1                 0                 0
## 1333               1                 0                 0
## 1334               1                 0                 0
## 1335               0                 0                 1
## 1336               1                 0                 0
## 1337               1                 0                 0
## 1338               0                 0                 1
## 1339               1                 0                 0
## 1340               1                 0                 0
## 1341               1                 0                 0
## 1342               1                 0                 0
## 1343               1                 0                 0
## 1344               1                 0                 0
## 1345               1                 0                 0
## 1346               1                 0                 0
## 1347               1                 0                 0
## 1348               0                 1                 0
## 1349               1                 0                 0
## 1350               1                 0                 0
## 1351               0                 1                 0
## 1352               0                 0                 1
## 1353               1                 0                 0
## 1354               1                 0                 0
## 1355               1                 0                 0
## 1356               1                 0                 0
## 1357               1                 0                 0
## 1358               1                 0                 0
## 1359               1                 0                 0
## 1360               1                 0                 0
## 1361               1                 0                 0
## 1362               1                 0                 0
## 1363               1                 0                 0
## 1364               0                 0                 1
## 1365               0                 0                 1
## 1366               1                 0                 0
## 1367               0                 0                 1
## 1368               1                 0                 0
## 1369               0                 0                 1
## 1370               1                 0                 0
## 1371               1                 0                 0
## 1372               1                 0                 0
## 1373               1                 0                 0
## 1374               1                 0                 0
## 1375               1                 0                 0
## 1376               0                 0                 1
## 1377               1                 0                 0
## 1378               1                 0                 0
## 1379               1                 0                 0
## 1380               1                 0                 0
## 1381               1                 0                 0
## 1382               1                 0                 0
## 1383               1                 0                 0
## 1384               1                 0                 0
## 1385               1                 0                 0
## 1386               1                 0                 0
## 1387               1                 0                 0
## 1388               1                 0                 0
## 1389               1                 0                 0
## 1390               1                 0                 0
## 1391               1                 0                 0
## 1392               1                 0                 0
## 1393               1                 0                 0
## 1394               1                 0                 0
## 1395               1                 0                 0
## 1396               1                 0                 0
## 1397               1                 0                 0
## 1398               1                 0                 0
## 1399               0                 0                 1
## 1400               1                 0                 0
## 1401               1                 0                 0
## 1402               1                 0                 0
## 1403               1                 0                 0
## 1404               1                 0                 0
## 1405               1                 0                 0
## 1406               1                 0                 0
## 1407               1                 0                 0
## 1408               1                 0                 0
## 1409               1                 0                 0
## 1410               1                 0                 0
## 1411               1                 0                 0
## 1412               1                 0                 0
## 1413               1                 0                 0
## 1414               1                 0                 0
## 1415               1                 0                 0
## 1416               1                 0                 0
## 1417               1                 0                 0
## 1418               1                 0                 0
## 1419               1                 0                 0
## 1420               1                 0                 0
## 1421               1                 0                 0
## 1422               1                 0                 0
## 1423               1                 0                 0
## 1424               1                 0                 0
## 1425               1                 0                 0
## 1426               1                 0                 0
## 1427               0                 0                 1
## 1428               1                 0                 0
## 1429               0                 0                 1
## 1430               0                 0                 1
## 1431               1                 0                 0
## 1432               0                 0                 1
## 1433               1                 0                 0
## 1434               1                 0                 0
## 1435               1                 0                 0
## 1436               1                 0                 0
## 1437               1                 0                 0
## 1438               1                 0                 0
## 1439               1                 0                 0
## 1440               0                 1                 0
## 1441               1                 0                 0
## 1442               1                 0                 0
## 1443               1                 0                 0
## 1444               1                 0                 0
## 1445               1                 0                 0
## 1446               1                 0                 0
## 1447               1                 0                 0
## 1448               1                 0                 0
## 1449               1                 0                 0
## 1450               1                 0                 0
## 1451               1                 0                 0
## 1452               1                 0                 0
## 1453               1                 0                 0
## 1454               1                 0                 0
## 1455               1                 0                 0
## 1456               1                 0                 0
## 1457               1                 0                 0
## 1458               1                 0                 0
## 1459               1                 0                 0
## 1460               1                 0                 0
## 1461               1                 0                 0
## 1462               1                 0                 0
## 1463               1                 0                 0
## 1464               1                 0                 0
## 1465               0                 1                 0
## 1466               0                 0                 1
## 1467               1                 0                 0
## 1468               1                 0                 0
## 1469               1                 0                 0
## 1470               0                 0                 1
## 1471               1                 0                 0
## 1472               0                 0                 1
## 1473               1                 0                 0
## 1474               1                 0                 0
## 1475               1                 0                 0
## 1476               1                 0                 0
## 1477               0                 0                 1
## 1478               1                 0                 0
## 1479               1                 0                 0
## 1480               1                 0                 0
## 1481               0                 0                 1
## 1482               1                 0                 0
## 1483               1                 0                 0
## 1484               1                 0                 0
## 1485               1                 0                 0
## 1486               1                 0                 0
## 1487               1                 0                 0
## 1488               1                 0                 0
## 1489               1                 0                 0
## 1490               1                 0                 0
## 1491               1                 0                 0
## 1492               1                 0                 0
## 1493               1                 0                 0
## 1494               1                 0                 0
## 1495               0                 0                 1
## 1496               0                 0                 1
## 1497               0                 0                 1
## 1498               1                 0                 0
## 1499               1                 0                 0
## 1500               1                 0                 0
## 1501               1                 0                 0
## 1502               1                 0                 0
## 1503               1                 0                 0
## 1504               1                 0                 0
## 1505               1                 0                 0
## 1506               0                 0                 1
## 1507               1                 0                 0
## 1508               1                 0                 0
## 1509               1                 0                 0
## 1510               1                 0                 0
## 1511               0                 0                 1
## 1512               1                 0                 0
## 1513               1                 0                 0
## 1514               1                 0                 0
## 1515               1                 0                 0
## 1516               1                 0                 0
## 1517               1                 0                 0
## 1518               1                 0                 0
## 1519               1                 0                 0
## 1520               1                 0                 0
## 1521               0                 0                 1
## 1522               1                 0                 0
## 1523               0                 1                 0
## 1524               1                 0                 0
## 1525               1                 0                 0
## 1526               1                 0                 0
## 1527               0                 0                 1
## 1528               0                 0                 1
## 1529               1                 0                 0
## 1530               1                 0                 0
## 1531               0                 1                 0
## 1532               1                 0                 0
## 1533               1                 0                 0
## 1534               1                 0                 0
## 1535               0                 0                 1
## 1536               1                 0                 0
## 1537               1                 0                 0
## 1538               1                 0                 0
## 1539               0                 0                 1
## 1540               1                 0                 0
## 1541               0                 0                 1
## 1542               1                 0                 0
## 1543               1                 0                 0
## 1544               1                 0                 0
## 1545               1                 0                 0
## 1546               1                 0                 0
## 1547               0                 0                 1
## 1548               0                 0                 1
## 1549               1                 0                 0
## 1550               1                 0                 0
## 1551               1                 0                 0
## 1552               0                 0                 1
## 1553               1                 0                 0
## 1554               1                 0                 0
## 1555               0                 0                 1
## 1556               1                 0                 0
## 1557               1                 0                 0
## 1558               0                 0                 1
## 1559               0                 0                 1
## 1560               0                 0                 1
## 1561               1                 0                 0
## 1562               1                 0                 0
## 1563               0                 0                 1
## 1564               1                 0                 0
## 1565               1                 0                 0
## 1566               0                 1                 0
## 1567               1                 0                 0
## 1568               0                 0                 1
## 1569               0                 0                 1
## 1570               0                 0                 1
## 1571               1                 0                 0
## 1572               0                 0                 1
## 1573               1                 0                 0
## 1574               1                 0                 0
## 1575               0                 0                 1
## 1576               1                 0                 0
## 1577               0                 1                 0
## 1578               0                 0                 1
## 1579               1                 0                 0
## 1580               1                 0                 0
## 1581               1                 0                 0
## 1582               0                 1                 0
## 1583               0                 0                 1
## 1584               1                 0                 0
## 1585               1                 0                 0
## 1586               1                 0                 0
## 1587               0                 0                 1
## 1588               1                 0                 0
## 1589               0                 0                 1
## 1590               0                 0                 1
## 1591               1                 0                 0
## 1592               1                 0                 0
## 1593               1                 0                 0
## 1594               1                 0                 0
## 1595               0                 0                 1
## 1596               1                 0                 0
## 1597               1                 0                 0
## 1598               0                 0                 1
## 1599               1                 0                 0
## 1600               1                 0                 0
## 1601               1                 0                 0
## 1602               1                 0                 0
## 1603               1                 0                 0
## 1604               1                 0                 0
## 1605               1                 0                 0
## 1606               1                 0                 0
## 1607               0                 0                 1
## 1608               1                 0                 0
## 1609               1                 0                 0
## 1610               1                 0                 0
## 1611               0                 0                 1
## 1612               1                 0                 0
## 1613               1                 0                 0
## 1614               1                 0                 0
## 1615               1                 0                 0
## 1616               1                 0                 0
## 1617               1                 0                 0
## 1618               1                 0                 0
## 1619               1                 0                 0
## 1620               1                 0                 0
## 1621               1                 0                 0
## 1622               0                 0                 1
## 1623               1                 0                 0
## 1624               1                 0                 0
## 1625               1                 0                 0
## 1626               1                 0                 0
## 1627               1                 0                 0
## 1628               1                 0                 0
## 1629               1                 0                 0
## 1630               1                 0                 0
## 1631               1                 0                 0
## 1632               1                 0                 0
## 1633               1                 0                 0
## 1634               1                 0                 0
## 1635               1                 0                 0
## 1636               0                 1                 0
## 1637               0                 0                 1
## 1638               1                 0                 0
## 1639               1                 0                 0
## 1640               1                 0                 0
## 1641               0                 1                 0
## 1642               1                 0                 0
## 1643               1                 0                 0
## 1644               1                 0                 0
## 1645               0                 0                 1
## 1646               1                 0                 0
## 1647               0                 0                 1
## 1648               0                 0                 1
## 1649               1                 0                 0
## 1650               1                 0                 0
## 1651               1                 0                 0
## 1652               1                 0                 0
## 1653               1                 0                 0
## 1654               1                 0                 0
## 1655               1                 0                 0
## 1656               1                 0                 0
## 1657               1                 0                 0
## 1658               1                 0                 0
## 1659               1                 0                 0
## 1660               1                 0                 0
## 1661               0                 0                 1
## 1662               0                 0                 1
## 1663               0                 0                 1
## 1664               1                 0                 0
## 1665               1                 0                 0
## 1666               0                 1                 0
## 1667               1                 0                 0
## 1668               1                 0                 0
## 1669               1                 0                 0
## 1670               1                 0                 0
## 1671               1                 0                 0
## 1672               1                 0                 0
## 1673               1                 0                 0
## 1674               1                 0                 0
## 1675               1                 0                 0
## 1676               1                 0                 0
## 1677               1                 0                 0
## 1678               1                 0                 0
## 1679               1                 0                 0
## 1680               1                 0                 0
## 1681               1                 0                 0
## 1682               1                 0                 0
## 1683               1                 0                 0
## 1684               1                 0                 0
## 1685               1                 0                 0
## 1686               1                 0                 0
## 1687               1                 0                 0
## 1688               0                 0                 1
## 1689               1                 0                 0
## 1690               1                 0                 0
## 1691               1                 0                 0
## 1692               1                 0                 0
## 1693               1                 0                 0
## 1694               0                 1                 0
## 1695               1                 0                 0
## 1696               1                 0                 0
## 1697               1                 0                 0
## 1698               1                 0                 0
## 1699               1                 0                 0
## 1700               1                 0                 0
## 1701               1                 0                 0
## 1702               1                 0                 0
## 1703               1                 0                 0
## 1704               0                 0                 1
## 1705               1                 0                 0
## 1706               1                 0                 0
## 1707               1                 0                 0
## 1708               0                 0                 1
## 1709               1                 0                 0
## 1710               1                 0                 0
## 1711               0                 0                 1
## 1712               0                 0                 1
## 1713               1                 0                 0
## 1714               1                 0                 0
## 1715               1                 0                 0
## 1716               1                 0                 0
## 1717               1                 0                 0
## 1718               1                 0                 0
## 1719               0                 0                 1
## 1720               1                 0                 0
## 1721               1                 0                 0
## 1722               1                 0                 0
## 1723               1                 0                 0
## 1724               1                 0                 0
## 1725               1                 0                 0
## 1726               1                 0                 0
## 1727               0                 0                 1
## 1728               1                 0                 0
## 1729               1                 0                 0
## 1730               1                 0                 0
## 1731               1                 0                 0
## 1732               1                 0                 0
## 1733               0                 0                 1
## 1734               1                 0                 0
## 1735               1                 0                 0
## 1736               1                 0                 0
## 1737               0                 0                 1
## 1738               1                 0                 0
## 1739               1                 0                 0
## 1740               1                 0                 0
## 1741               1                 0                 0
## 1742               1                 0                 0
## 1743               1                 0                 0
## 1744               1                 0                 0
## 1745               1                 0                 0
## 1746               1                 0                 0
## 1747               1                 0                 0
## 1748               1                 0                 0
## 1749               1                 0                 0
## 1750               0                 0                 1
## 1751               1                 0                 0
## 1752               1                 0                 0
## 1753               1                 0                 0
## 1754               1                 0                 0
## 1755               1                 0                 0
## 1756               1                 0                 0
## 1757               1                 0                 0
## 1758               1                 0                 0
## 1759               1                 0                 0
## 1760               1                 0                 0
## 1761               1                 0                 0
## 1762               1                 0                 0
## 1763               0                 0                 1
## 1764               1                 0                 0
## 1765               1                 0                 0
## 1766               1                 0                 0
## 1767               1                 0                 0
## 1768               0                 0                 1
## 1769               1                 0                 0
## 1770               1                 0                 0
## 1771               1                 0                 0
## 1772               1                 0                 0
## 1773               1                 0                 0
## 1774               0                 1                 0
## 1775               1                 0                 0
## 1776               0                 0                 1
## 1777               1                 0                 0
## 1778               1                 0                 0
## 1779               1                 0                 0
## 1780               1                 0                 0
## 1781               0                 0                 1
## 1782               1                 0                 0
## 1783               1                 0                 0
## 1784               1                 0                 0
## 1785               1                 0                 0
## 1786               1                 0                 0
## 1787               1                 0                 0
## 1788               0                 0                 1
## 1789               1                 0                 0
## 1790               1                 0                 0
## 1791               1                 0                 0
## 1792               1                 0                 0
## 1793               1                 0                 0
## 1794               1                 0                 0
## 1795               1                 0                 0
## 1796               1                 0                 0
## 1797               1                 0                 0
## 1798               1                 0                 0
## 1799               1                 0                 0
## 1800               1                 0                 0
## 1801               1                 0                 0
## 1802               1                 0                 0
## 1803               1                 0                 0
## 1804               1                 0                 0
## 1805               1                 0                 0
## 1806               1                 0                 0
## 1807               0                 1                 0
## 1808               1                 0                 0
## 1809               1                 0                 0
## 1810               0                 0                 1
## 1811               1                 0                 0
## 1812               1                 0                 0
## 1813               1                 0                 0
## 1814               1                 0                 0
## 1815               1                 0                 0
## 1816               0                 0                 1
## 1817               1                 0                 0
## 1818               0                 1                 0
## 1819               1                 0                 0
## 1820               0                 1                 0
## 1821               1                 0                 0
## 1822               1                 0                 0
## 1823               1                 0                 0
## 1824               1                 0                 0
## 1825               0                 0                 1
## 1826               1                 0                 0
## 1827               1                 0                 0
## 1828               1                 0                 0
## 1829               1                 0                 0
## 1830               1                 0                 0
## 1831               1                 0                 0
## 1832               1                 0                 0
## 1833               1                 0                 0
## 1834               1                 0                 0
## 1835               1                 0                 0
## 1836               1                 0                 0
## 1837               1                 0                 0
## 1838               1                 0                 0
## 1839               0                 0                 1
## 1840               0                 0                 1
## 1841               1                 0                 0
## 1842               1                 0                 0
## 1843               1                 0                 0
## 1844               1                 0                 0
## 1845               1                 0                 0
## 1846               1                 0                 0
## 1847               1                 0                 0
## 1848               1                 0                 0
## 1849               1                 0                 0
## 1850               0                 0                 1
## 1851               1                 0                 0
## 1852               0                 1                 0
## 1853               1                 0                 0
## 1854               1                 0                 0
## 1855               0                 0                 1
## 1856               1                 0                 0
## 1857               1                 0                 0
## 1858               1                 0                 0
## 1859               1                 0                 0
## 1860               1                 0                 0
## 1861               0                 1                 0
## 1862               1                 0                 0
## 1863               0                 0                 1
## 1864               1                 0                 0
## 1865               1                 0                 0
## 1866               1                 0                 0
## 1867               1                 0                 0
## 1868               1                 0                 0
## 1869               0                 0                 1
## 1870               0                 0                 1
## 1871               0                 1                 0
## 1872               1                 0                 0
## 1873               1                 0                 0
## 1874               1                 0                 0
## 1875               1                 0                 0
## 1876               0                 0                 1
## 1877               1                 0                 0
## 1878               1                 0                 0
## 1879               0                 0                 1
## 1880               1                 0                 0
## 1881               1                 0                 0
## 1882               0                 0                 1
## 1883               1                 0                 0
## 1884               1                 0                 0
## 1885               1                 0                 0
## 1886               1                 0                 0
## 1887               1                 0                 0
## 1888               1                 0                 0
## 1889               1                 0                 0
## 1890               0                 1                 0
## 1891               1                 0                 0
## 1892               1                 0                 0
## 1893               1                 0                 0
## 1894               0                 0                 1
## 1895               1                 0                 0
## 1896               0                 0                 1
## 1897               0                 1                 0
## 1898               0                 0                 1
## 1899               1                 0                 0
## 1900               0                 1                 0
## 1901               0                 0                 1
## 1902               1                 0                 0
## 1903               1                 0                 0
## 1904               1                 0                 0
## 1905               0                 0                 1
## 1906               0                 0                 1
## 1907               1                 0                 0
## 1908               0                 0                 1
## 1909               1                 0                 0
## 1910               1                 0                 0
## 1911               1                 0                 0
## 1912               1                 0                 0
## 1913               1                 0                 0
## 1914               1                 0                 0
## 1915               1                 0                 0
## 1916               1                 0                 0
## 1917               1                 0                 0
## 1918               1                 0                 0
## 1919               0                 0                 1
## 1920               0                 0                 1
## 1921               1                 0                 0
## 1922               0                 0                 1
## 1923               1                 0                 0
## 1924               1                 0                 0
## 1925               1                 0                 0
## 1926               1                 0                 0
## 1927               0                 0                 1
## 1928               1                 0                 0
## 1929               1                 0                 0
## 1930               1                 0                 0
## 1931               1                 0                 0
## 1932               1                 0                 0
## 1933               1                 0                 0
## 1934               1                 0                 0
## 1935               1                 0                 0
## 1936               1                 0                 0
## 1937               1                 0                 0
## 1938               0                 0                 1
## 1939               0                 0                 1
## 1940               1                 0                 0
## 1941               1                 0                 0
## 1942               1                 0                 0
## 1943               1                 0                 0
## 1944               1                 0                 0
## 1945               1                 0                 0
## 1946               1                 0                 0
## 1947               0                 1                 0
## 1948               1                 0                 0
## 1949               1                 0                 0
## 1950               1                 0                 0
## 1951               1                 0                 0
## 1952               0                 0                 1
## 1953               1                 0                 0
## 1954               1                 0                 0
## 1955               1                 0                 0
## 1956               1                 0                 0
## 1957               1                 0                 0
## 1958               1                 0                 0
## 1959               1                 0                 0
## 1960               1                 0                 0
## 1961               1                 0                 0
## 1962               1                 0                 0
## 1963               1                 0                 0
## 1964               1                 0                 0
## 1965               0                 0                 1
## 1966               1                 0                 0
## 1967               1                 0                 0
## 1968               1                 0                 0
## 1969               1                 0                 0
## 1970               1                 0                 0
## 1971               1                 0                 0
## 1972               0                 0                 1
## 1973               1                 0                 0
## 1974               1                 0                 0
## 1975               1                 0                 0
## 1976               1                 0                 0
## 1977               1                 0                 0
## 1978               1                 0                 0
## 1979               0                 0                 1
## 1980               1                 0                 0
## 1981               1                 0                 0
## 1982               1                 0                 0
## 1983               1                 0                 0
## 1984               0                 0                 1
## 1985               1                 0                 0
## 1986               1                 0                 0
## 1987               1                 0                 0
## 1988               1                 0                 0
## 1989               1                 0                 0
## 1990               1                 0                 0
## 1991               1                 0                 0
## 1992               1                 0                 0
## 1993               1                 0                 0
## 1994               0                 0                 1
## 1995               1                 0                 0
## 1996               0                 0                 1
## 1997               1                 0                 0
## 1998               1                 0                 0
## 1999               1                 0                 0
## 2000               0                 1                 0
## 2001               0                 0                 1
## 2002               1                 0                 0
## 2003               1                 0                 0
## 2004               1                 0                 0
## 2005               0                 0                 1
## 2006               1                 0                 0
## 2007               1                 0                 0
## 2008               1                 0                 0
## 2009               0                 0                 1
## 2010               1                 0                 0
## 2011               1                 0                 0
## 2012               1                 0                 0
## 2013               0                 0                 1
## 2014               1                 0                 0
## 2015               1                 0                 0
## 2016               1                 0                 0
## 2017               1                 0                 0
## 2018               1                 0                 0
## 2019               1                 0                 0
## 2020               1                 0                 0
## 2021               1                 0                 0
## 2022               1                 0                 0
## 2023               1                 0                 0
## 2024               0                 0                 1
## 2025               1                 0                 0
## 2026               0                 0                 1
## 2027               1                 0                 0
## 2028               1                 0                 0
## 2029               1                 0                 0
## 2030               1                 0                 0
## 2031               1                 0                 0
## 2032               1                 0                 0
## 2033               1                 0                 0
## 2034               1                 0                 0
## 2035               1                 0                 0
## 2036               0                 1                 0
## 2037               0                 0                 1
## 2038               0                 0                 1
## 2039               1                 0                 0
## 2040               1                 0                 0
## 2041               1                 0                 0
## 2042               1                 0                 0
## 2043               1                 0                 0
## 2044               1                 0                 0
## 2045               1                 0                 0
## 2046               0                 0                 1
## 2047               1                 0                 0
## 2048               0                 0                 1
## 2049               1                 0                 0
## 2050               1                 0                 0
## 2051               1                 0                 0
## 2052               0                 1                 0
## 2053               0                 0                 1
## 2054               0                 0                 1
## 2055               1                 0                 0
## 2056               1                 0                 0
## 2057               1                 0                 0
## 2058               1                 0                 0
## 2059               1                 0                 0
## 2060               0                 0                 1
## 2061               1                 0                 0
## 2062               1                 0                 0
## 2063               0                 1                 0
## 2064               0                 0                 1
## 2065               1                 0                 0
## 2066               1                 0                 0
## 2067               0                 0                 1
## 2068               1                 0                 0
## 2069               0                 0                 1
## 2070               1                 0                 0
## 2071               1                 0                 0
## 2072               1                 0                 0
## 2073               1                 0                 0
## 2074               1                 0                 0
## 2075               1                 0                 0
## 2076               1                 0                 0
## 2077               1                 0                 0
## 2078               0                 0                 1
## 2079               1                 0                 0
## 2080               1                 0                 0
## 2081               0                 0                 1
## 2082               1                 0                 0
## 2083               1                 0                 0
## 2084               1                 0                 0
## 2085               1                 0                 0
## 2086               1                 0                 0
## 2087               1                 0                 0
## 2088               0                 0                 1
## 2089               0                 0                 1
## 2090               1                 0                 0
## 2091               1                 0                 0
## 2092               1                 0                 0
## 2093               0                 1                 0
## 2094               1                 0                 0
## 2095               1                 0                 0
## 2096               1                 0                 0
## 2097               0                 1                 0
## 2098               1                 0                 0
## 2099               1                 0                 0
## 2100               1                 0                 0
## 2101               1                 0                 0
## 2102               0                 0                 1
## 2103               0                 0                 1
## 2104               1                 0                 0
## 2105               0                 0                 1
## 2106               1                 0                 0
## 2107               1                 0                 0
## 2108               1                 0                 0
## 2109               1                 0                 0
## 2110               1                 0                 0
## 2111               1                 0                 0
## 2112               0                 0                 1
## 2113               1                 0                 0
## 2114               1                 0                 0
## 2115               1                 0                 0
## 2116               1                 0                 0
## 2117               1                 0                 0
## 2118               1                 0                 0
## 2119               0                 1                 0
## 2120               1                 0                 0
## 2121               1                 0                 0
## 2122               0                 0                 1
## 2123               1                 0                 0
## 2124               1                 0                 0
## 2125               1                 0                 0
## 2126               1                 0                 0
## 2127               1                 0                 0
## 2128               1                 0                 0
## 2129               1                 0                 0
## 2130               1                 0                 0
## 2131               1                 0                 0
## 2132               1                 0                 0
## 2133               1                 0                 0
## 2134               1                 0                 0
## 2135               1                 0                 0
## 2136               1                 0                 0
## 2137               0                 0                 1
## 2138               1                 0                 0
## 2139               1                 0                 0
## 2140               0                 0                 1
## 2141               1                 0                 0
## 2142               1                 0                 0
## 2143               1                 0                 0
## 2144               1                 0                 0
## 2145               1                 0                 0
## 2146               1                 0                 0
## 2147               1                 0                 0
## 2148               1                 0                 0
## 2149               1                 0                 0
## 2150               1                 0                 0
## 2151               1                 0                 0
## 2152               1                 0                 0
## 2153               0                 0                 1
## 2154               1                 0                 0
## 2155               0                 0                 1
## 2156               1                 0                 0
## 2157               1                 0                 0
## 2158               1                 0                 0
## 2159               1                 0                 0
## 2160               1                 0                 0
## 2161               1                 0                 0
## 2162               1                 0                 0
## 2163               0                 0                 1
## 2164               1                 0                 0
## 2165               1                 0                 0
## 2166               1                 0                 0
## 2167               1                 0                 0
## 2168               1                 0                 0
## 2169               1                 0                 0
## 2170               1                 0                 0
## 2171               1                 0                 0
## 2172               1                 0                 0
## 2173               1                 0                 0
## 2174               1                 0                 0
## 2175               1                 0                 0
## 2176               0                 0                 1
## 2177               1                 0                 0
## 2178               1                 0                 0
## 2179               1                 0                 0
## 2180               1                 0                 0
## 2181               1                 0                 0
## 2182               1                 0                 0
## 2183               1                 0                 0
## 2184               0                 0                 1
## 2185               1                 0                 0
## 2186               1                 0                 0
## 2187               1                 0                 0
## 2188               1                 0                 0
## 2189               1                 0                 0
## 2190               1                 0                 0
## 2191               1                 0                 0
## 2192               1                 0                 0
## 2193               1                 0                 0
## 2194               1                 0                 0
## 2195               0                 1                 0
## 2196               1                 0                 0
## 2197               1                 0                 0
## 2198               1                 0                 0
## 2199               0                 0                 1
## 2200               1                 0                 0
## 2201               0                 0                 1
## 2202               0                 0                 1
## 2203               1                 0                 0
## 2204               1                 0                 0
## 2205               1                 0                 0
## 2206               1                 0                 0
## 2207               1                 0                 0
## 2208               1                 0                 0
## 2209               1                 0                 0
## 2210               1                 0                 0
## 2211               1                 0                 0
## 2212               1                 0                 0
## 2213               0                 0                 1
## 2214               1                 0                 0
## 2215               1                 0                 0
## 2216               1                 0                 0
## 2217               1                 0                 0
## 2218               1                 0                 0
## 2219               1                 0                 0
## 2220               1                 0                 0
## 2221               1                 0                 0
## 2222               1                 0                 0
## 2223               1                 0                 0
## 2224               1                 0                 0
## 2225               1                 0                 0
## 2226               1                 0                 0
## 2227               1                 0                 0
## 2228               1                 0                 0
## 2229               1                 0                 0
## 2230               1                 0                 0
## 2231               1                 0                 0
## 2232               1                 0                 0
## 2233               1                 0                 0
## 2234               1                 0                 0
## 2235               1                 0                 0
## 2236               1                 0                 0
## 2237               1                 0                 0
## 2238               1                 0                 0
## 2239               1                 0                 0
## 2240               1                 0                 0
## 2241               1                 0                 0
## 2242               1                 0                 0
## 2243               1                 0                 0
## 2244               1                 0                 0
## 2245               1                 0                 0
## 2246               1                 0                 0
## 2247               1                 0                 0
## 2248               1                 0                 0
## 2249               1                 0                 0
## 2250               1                 0                 0
## 2251               1                 0                 0
## 2252               1                 0                 0
## 2253               1                 0                 0
## 2254               1                 0                 0
## 2255               1                 0                 0
## 2256               1                 0                 0
## 2257               1                 0                 0
## 2258               1                 0                 0
## 2259               1                 0                 0
## 2260               1                 0                 0
## 2261               1                 0                 0
## 2262               0                 1                 0
## 2263               0                 1                 0
## 2264               1                 0                 0
## 2265               1                 0                 0
## 2266               1                 0                 0
## 2267               1                 0                 0
## 2268               1                 0                 0
## 2269               1                 0                 0
## 2270               0                 0                 1
## 2271               1                 0                 0
## 2272               1                 0                 0
## 2273               1                 0                 0
## 2274               1                 0                 0
## 2275               1                 0                 0
## 2276               1                 0                 0
## 2277               1                 0                 0
## 2278               0                 1                 0
## 2279               1                 0                 0
## 2280               1                 0                 0
## 2281               1                 0                 0
## 2282               0                 1                 0
## 2283               1                 0                 0
## 2284               1                 0                 0
## 2285               0                 0                 1
## 2286               1                 0                 0
## 2287               1                 0                 0
## 2288               1                 0                 0
## 2289               1                 0                 0
## 2290               1                 0                 0
## 2291               0                 0                 1
## 2292               1                 0                 0
## 2293               1                 0                 0
## 2294               1                 0                 0
## 2295               1                 0                 0
## 2296               0                 0                 1
## 2297               1                 0                 0
## 2298               1                 0                 0
## 2299               1                 0                 0
## 2300               1                 0                 0
## 2301               1                 0                 0
## 2302               1                 0                 0
## 2303               1                 0                 0
## 2304               0                 0                 1
## 2305               0                 0                 1
## 2306               1                 0                 0
## 2307               1                 0                 0
## 2308               0                 0                 1
## 2309               1                 0                 0
## 2310               1                 0                 0
## 2311               0                 0                 1
## 2312               1                 0                 0
## 2313               1                 0                 0
## 2314               1                 0                 0
## 2315               1                 0                 0
## 2316               1                 0                 0
## 2317               1                 0                 0
## 2318               1                 0                 0
## 2319               1                 0                 0
## 2320               1                 0                 0
## 2321               1                 0                 0
## 2322               1                 0                 0
## 2323               1                 0                 0
## 2324               1                 0                 0
## 2325               1                 0                 0
## 2326               1                 0                 0
## 2327               1                 0                 0
## 2328               1                 0                 0
## 2329               1                 0                 0
## 2330               0                 0                 1
## 2331               0                 0                 1
## 2332               0                 1                 0
## 2333               1                 0                 0
## 2334               1                 0                 0
## 2335               1                 0                 0
## 2336               0                 0                 1
## 2337               1                 0                 0
## 2338               1                 0                 0
## 2339               1                 0                 0
## 2340               1                 0                 0
## 2341               1                 0                 0
## 2342               1                 0                 0
## 2343               1                 0                 0
## 2344               1                 0                 0
## 2345               1                 0                 0
## 2346               1                 0                 0
## 2347               1                 0                 0
## 2348               1                 0                 0
## 2349               1                 0                 0
## 2350               0                 0                 1
## 2351               1                 0                 0
## 2352               1                 0                 0
## 2353               1                 0                 0
## 2354               1                 0                 0
## 2355               1                 0                 0
## 2356               1                 0                 0
## 2357               1                 0                 0
## 2358               1                 0                 0
## 2359               1                 0                 0
## 2360               0                 1                 0
## 2361               0                 1                 0
## 2362               0                 0                 1
## 2363               1                 0                 0
## 2364               0                 1                 0
## 2365               0                 0                 1
## 2366               1                 0                 0
## 2367               1                 0                 0
## 2368               1                 0                 0
## 2369               1                 0                 0
## 2370               1                 0                 0
## 2371               1                 0                 0
## 2372               1                 0                 0
## 2373               1                 0                 0
## 2374               0                 0                 1
## 2375               1                 0                 0
## 2376               1                 0                 0
## 2377               1                 0                 0
## 2378               1                 0                 0
## 2379               1                 0                 0
## 2380               1                 0                 0
## 2381               1                 0                 0
## 2382               1                 0                 0
## 2383               0                 0                 1
## 2384               0                 0                 1
## 2385               1                 0                 0
## 2386               1                 0                 0
## 2387               1                 0                 0
## 2388               1                 0                 0
## 2389               1                 0                 0
## 2390               1                 0                 0
## 2391               1                 0                 0
## 2392               1                 0                 0
## 2393               1                 0                 0
## 2394               1                 0                 0
## 2395               1                 0                 0
## 2396               0                 1                 0
## 2397               1                 0                 0
## 2398               1                 0                 0
## 2399               1                 0                 0
## 2400               0                 0                 1
## 2401               0                 0                 1
## 2402               1                 0                 0
## 2403               1                 0                 0
## 2404               1                 0                 0
## 2405               1                 0                 0
## 2406               1                 0                 0
## 2407               1                 0                 0
## 2408               1                 0                 0
## 2409               1                 0                 0
## 2410               1                 0                 0
## 2411               0                 1                 0
## 2412               0                 0                 1
## 2413               1                 0                 0
## 2414               1                 0                 0
## 2415               1                 0                 0
## 2416               0                 1                 0
## 2417               1                 0                 0
## 2418               1                 0                 0
## 2419               1                 0                 0
## 2420               0                 1                 0
## 2421               1                 0                 0
## 2422               1                 0                 0
## 2423               0                 0                 1
## 2424               0                 0                 1
## 2425               1                 0                 0
## 2426               1                 0                 0
## 2427               0                 1                 0
## 2428               1                 0                 0
## 2429               1                 0                 0
## 2430               1                 0                 0
## 2431               1                 0                 0
## 2432               1                 0                 0
## 2433               0                 0                 1
## 2434               1                 0                 0
## 2435               0                 0                 1
## 2436               1                 0                 0
## 2437               0                 0                 1
## 2438               1                 0                 0
## 2439               1                 0                 0
## 2440               1                 0                 0
## 2441               1                 0                 0
## 2442               1                 0                 0
## 2443               0                 0                 1
## 2444               0                 0                 1
## 2445               1                 0                 0
## 2446               1                 0                 0
## 2447               1                 0                 0
## 2448               0                 0                 1
## 2449               1                 0                 0
## 2450               1                 0                 0
## 2451               1                 0                 0
## 2452               1                 0                 0
## 2453               1                 0                 0
## 2454               1                 0                 0
## 2455               1                 0                 0
## 2456               1                 0                 0
## 2457               0                 0                 1
## 2458               1                 0                 0
## 2459               1                 0                 0
## 2460               0                 0                 1
## 2461               1                 0                 0
## 2462               1                 0                 0
## 2463               1                 0                 0
## 2464               1                 0                 0
## 2465               1                 0                 0
## 2466               1                 0                 0
## 2467               0                 0                 1
## 2468               1                 0                 0
## 2469               1                 0                 0
## 2470               1                 0                 0
## 2471               0                 0                 1
## 2472               1                 0                 0
## 2473               1                 0                 0
## 2474               1                 0                 0
## 2475               1                 0                 0
## 2476               1                 0                 0
## 2477               1                 0                 0
## 2478               1                 0                 0
## 2479               1                 0                 0
## 2480               1                 0                 0
## 2481               1                 0                 0
## 2482               0                 0                 1
## 2483               1                 0                 0
## 2484               1                 0                 0
## 2485               1                 0                 0
## 2486               1                 0                 0
## 2487               0                 0                 1
## 2488               1                 0                 0
## 2489               1                 0                 0
## 2490               1                 0                 0
## 2491               0                 0                 1
## 2492               1                 0                 0
## 2493               0                 0                 1
## 2494               1                 0                 0
## 2495               1                 0                 0
## 2496               1                 0                 0
## 2497               1                 0                 0
## 2498               1                 0                 0
## 2499               1                 0                 0
## 2500               1                 0                 0
## 2501               1                 0                 0
## 2502               0                 1                 0
## 2503               1                 0                 0
## 2504               1                 0                 0
## 2505               1                 0                 0
## 2506               1                 0                 0
## 2507               1                 0                 0
## 2508               1                 0                 0
## 2509               1                 0                 0
## 2510               1                 0                 0
## 2511               1                 0                 0
## 2512               1                 0                 0
## 2513               1                 0                 0
## 2514               0                 0                 1
## 2515               1                 0                 0
## 2516               1                 0                 0
## 2517               1                 0                 0
## 2518               1                 0                 0
## 2519               0                 0                 1
## 2520               1                 0                 0
## 2521               1                 0                 0
## 2522               1                 0                 0
## 2523               0                 0                 1
## 2524               1                 0                 0
## 2525               1                 0                 0
## 2526               1                 0                 0
## 2527               1                 0                 0
## 2528               1                 0                 0
## 2529               1                 0                 0
## 2530               1                 0                 0
## 2531               1                 0                 0
## 2532               1                 0                 0
## 2533               1                 0                 0
## 2534               0                 0                 1
## 2535               1                 0                 0
## 2536               1                 0                 0
## 2537               1                 0                 0
## 2538               0                 1                 0
## 2539               0                 0                 1
## 2540               0                 0                 1
## 2541               0                 1                 0
## 2542               1                 0                 0
## 2543               1                 0                 0
## 2544               0                 0                 1
## 2545               1                 0                 0
## 2546               0                 0                 1
## 2547               1                 0                 0
## 2548               1                 0                 0
## 2549               1                 0                 0
## 2550               1                 0                 0
## 2551               1                 0                 0
## 2552               0                 0                 1
## 2553               1                 0                 0
## 2554               1                 0                 0
## 2555               1                 0                 0
## 2556               1                 0                 0
## 2557               1                 0                 0
## 2558               0                 0                 1
## 2559               1                 0                 0
## 2560               0                 0                 1
## 2561               0                 0                 1
## 2562               1                 0                 0
## 2563               1                 0                 0
## 2564               1                 0                 0
## 2565               1                 0                 0
## 2566               1                 0                 0
## 2567               1                 0                 0
## 2568               1                 0                 0
## 2569               1                 0                 0
## 2570               1                 0                 0
## 2571               1                 0                 0
## 2572               1                 0                 0
## 2573               1                 0                 0
## 2574               1                 0                 0
## 2575               1                 0                 0
## 2576               1                 0                 0
## 2577               1                 0                 0
## 2578               1                 0                 0
## 2579               1                 0                 0
## 2580               1                 0                 0
## 2581               1                 0                 0
## 2582               1                 0                 0
## 2583               1                 0                 0
## 2584               1                 0                 0
## 2585               1                 0                 0
## 2586               0                 0                 1
## 2587               1                 0                 0
## 2588               1                 0                 0
## 2589               1                 0                 0
## 2590               1                 0                 0
## 2591               1                 0                 0
## 2592               1                 0                 0
## 2593               1                 0                 0
## 2594               0                 0                 1
## 2595               1                 0                 0
## 2596               1                 0                 0
## 2597               1                 0                 0
## 2598               0                 0                 1
## 2599               1                 0                 0
## 2600               1                 0                 0
## 2601               1                 0                 0
## 2602               1                 0                 0
## 2603               0                 0                 1
## 2604               1                 0                 0
## 2605               1                 0                 0
## 2606               0                 0                 1
## 2607               1                 0                 0
## 2608               0                 0                 1
## 2609               1                 0                 0
## 2610               1                 0                 0
## 2611               1                 0                 0
## 2612               0                 0                 1
## 2613               1                 0                 0
## 2614               1                 0                 0
## 2615               1                 0                 0
## 2616               1                 0                 0
## 2617               1                 0                 0
## 2618               1                 0                 0
## 2619               1                 0                 0
## 2620               1                 0                 0
## 2621               0                 1                 0
## 2622               1                 0                 0
## 2623               1                 0                 0
## 2624               1                 0                 0
## 2625               1                 0                 0
## 2626               0                 1                 0
## 2627               0                 1                 0
## 2628               1                 0                 0
## 2629               1                 0                 0
## 2630               0                 0                 1
## 2631               0                 1                 0
## 2632               1                 0                 0
## 2633               0                 0                 1
## 2634               1                 0                 0
## 2635               1                 0                 0
## 2636               1                 0                 0
## 2637               1                 0                 0
## 2638               1                 0                 0
## 2639               0                 0                 1
## 2640               1                 0                 0
## 2641               0                 0                 1
## 2642               1                 0                 0
## 2643               1                 0                 0
## 2644               1                 0                 0
## 2645               1                 0                 0
## 2646               0                 1                 0
## 2647               1                 0                 0
## 2648               1                 0                 0
## 2649               1                 0                 0
## 2650               1                 0                 0
## 2651               1                 0                 0
## 2652               1                 0                 0
## 2653               1                 0                 0
## 2654               0                 1                 0
## 2655               1                 0                 0
## 2656               1                 0                 0
## 2657               0                 0                 1
## 2658               1                 0                 0
## 2659               1                 0                 0
## 2660               1                 0                 0
## 2661               1                 0                 0
## 2662               1                 0                 0
## 2663               1                 0                 0
## 2664               1                 0                 0
## 2665               1                 0                 0
## 2666               1                 0                 0
## 2667               1                 0                 0
## 2668               1                 0                 0
## 2669               1                 0                 0
## 2670               0                 0                 1
## 2671               1                 0                 0
## 2672               1                 0                 0
## 2673               1                 0                 0
## 2674               1                 0                 0
## 2675               0                 0                 1
## 2676               1                 0                 0
## 2677               1                 0                 0
## 2678               1                 0                 0
## 2679               1                 0                 0
## 2680               1                 0                 0
## 2681               1                 0                 0
## 2682               1                 0                 0
## 2683               0                 0                 1
## 2684               1                 0                 0
## 2685               1                 0                 0
## 2686               1                 0                 0
## 2687               1                 0                 0
## 2688               1                 0                 0
## 2689               1                 0                 0
## 2690               1                 0                 0
## 2691               1                 0                 0
## 2692               1                 0                 0
## 2693               1                 0                 0
## 2694               1                 0                 0
## 2695               1                 0                 0
## 2696               1                 0                 0
## 2697               1                 0                 0
## 2698               0                 0                 1
## 2699               0                 1                 0
## 2700               0                 0                 1
## 2701               0                 0                 1
## 2702               1                 0                 0
## 2703               1                 0                 0
## 2704               1                 0                 0
## 2705               1                 0                 0
## 2706               1                 0                 0
## 2707               1                 0                 0
## 2708               0                 0                 1
## 2709               1                 0                 0
## 2710               0                 1                 0
## 2711               0                 1                 0
## 2712               1                 0                 0
## 2713               0                 0                 1
## 2714               1                 0                 0
## 2715               1                 0                 0
## 2716               0                 0                 1
## 2717               0                 0                 1
## 2718               1                 0                 0
## 2719               0                 0                 1
## 2720               1                 0                 0
## 2721               1                 0                 0
## 2722               1                 0                 0
## 2723               1                 0                 0
## 2724               1                 0                 0
## 2725               1                 0                 0
## 2726               1                 0                 0
## 2727               0                 1                 0
## 2728               1                 0                 0
## 2729               1                 0                 0
## 2730               1                 0                 0
## 2731               1                 0                 0
## 2732               0                 1                 0
## 2733               1                 0                 0
## 2734               1                 0                 0
## 2735               1                 0                 0
## 2736               1                 0                 0
## 2737               1                 0                 0
## 2738               1                 0                 0
## 2739               0                 1                 0
## 2740               1                 0                 0
## 2741               1                 0                 0
## 2742               1                 0                 0
## 2743               1                 0                 0
## 2744               1                 0                 0
## 2745               0                 0                 1
## 2746               1                 0                 0
## 2747               1                 0                 0
## 2748               0                 0                 1
## 2749               1                 0                 0
## 2750               0                 1                 0
## 2751               1                 0                 0
## 2752               1                 0                 0
## 2753               1                 0                 0
## 2754               1                 0                 0
## 2755               0                 0                 1
## 2756               1                 0                 0
## 2757               0                 1                 0
## 2758               1                 0                 0
## 2759               1                 0                 0
## 2760               1                 0                 0
## 2761               0                 1                 0
## 2762               1                 0                 0
## 2763               1                 0                 0
## 2764               1                 0                 0
## 2765               1                 0                 0
## 2766               0                 0                 1
## 2767               0                 0                 1
## 2768               1                 0                 0
## 2769               1                 0                 0
## 2770               1                 0                 0
## 2771               1                 0                 0
## 2772               1                 0                 0
## 2773               1                 0                 0
## 2774               1                 0                 0
## 2775               0                 1                 0
## 2776               0                 0                 1
## 2777               1                 0                 0
## 2778               1                 0                 0
## 2779               1                 0                 0
## 2780               1                 0                 0
## 2781               0                 0                 1
## 2782               1                 0                 0
## 2783               0                 0                 1
## 2784               1                 0                 0
## 2785               1                 0                 0
## 2786               1                 0                 0
## 2787               1                 0                 0
## 2788               0                 0                 1
## 2789               1                 0                 0
## 2790               1                 0                 0
## 2791               1                 0                 0
## 2792               0                 0                 1
## 2793               0                 0                 1
## 2794               1                 0                 0
## 2795               1                 0                 0
## 2796               1                 0                 0
## 2797               1                 0                 0
## 2798               1                 0                 0
## 2799               0                 0                 1
## 2800               0                 0                 1
## 2801               1                 0                 0
## 2802               1                 0                 0
## 2803               1                 0                 0
## 2804               1                 0                 0
## 2805               0                 0                 1
## 2806               1                 0                 0
## 2807               1                 0                 0
## 2808               1                 0                 0
## 2809               1                 0                 0
## 2810               0                 0                 1
## 2811               1                 0                 0
## 2812               1                 0                 0
## 2813               1                 0                 0
## 2814               1                 0                 0
## 2815               1                 0                 0
## 2816               1                 0                 0
## 2817               0                 0                 1
## 2818               0                 1                 0
## 2819               0                 1                 0
## 2820               1                 0                 0
## 2821               1                 0                 0
## 2822               1                 0                 0
## 2823               1                 0                 0
## 2824               1                 0                 0
## 2825               0                 0                 1
## 2826               1                 0                 0
## 2827               0                 1                 0
## 2828               1                 0                 0
## 2829               1                 0                 0
## 2830               1                 0                 0
## 2831               1                 0                 0
## 2832               1                 0                 0
## 2833               1                 0                 0
## 2834               1                 0                 0
## 2835               1                 0                 0
## 2836               1                 0                 0
## 2837               1                 0                 0
## 2838               1                 0                 0
## 2839               1                 0                 0
## 2840               1                 0                 0
## 2841               0                 0                 1
## 2842               1                 0                 0
## 2843               1                 0                 0
## 2844               1                 0                 0
## 2845               1                 0                 0
## 2846               1                 0                 0
## 2847               1                 0                 0
## 2848               0                 1                 0
## 2849               1                 0                 0
## 2850               1                 0                 0
## 2851               1                 0                 0
## 2852               1                 0                 0
## 2853               1                 0                 0
## 2854               0                 0                 1
## 2855               1                 0                 0
## 2856               1                 0                 0
## 2857               1                 0                 0
## 2858               1                 0                 0
## 2859               1                 0                 0
## 2860               1                 0                 0
## 2861               1                 0                 0
## 2862               1                 0                 0
## 2863               0                 1                 0
## 2864               1                 0                 0
## 2865               1                 0                 0
## 2866               1                 0                 0
## 2867               1                 0                 0
## 2868               1                 0                 0
## 2869               1                 0                 0
## 2870               1                 0                 0
## 2871               1                 0                 0
## 2872               1                 0                 0
## 2873               1                 0                 0
## 2874               1                 0                 0
## 2875               1                 0                 0
## 2876               1                 0                 0
## 2877               1                 0                 0
## 2878               1                 0                 0
## 2879               0                 1                 0
## 2880               1                 0                 0
## 2881               1                 0                 0
## 2882               0                 1                 0
## 2883               0                 0                 1
## 2884               1                 0                 0
## 2885               1                 0                 0
## 2886               0                 0                 1
## 2887               1                 0                 0
## 2888               1                 0                 0
## 2889               0                 0                 1
## 2890               1                 0                 0
## 2891               1                 0                 0
## 2892               1                 0                 0
## 2893               1                 0                 0
## 2894               1                 0                 0
## 2895               1                 0                 0
## 2896               1                 0                 0
## 2897               1                 0                 0
## 2898               1                 0                 0
## 2899               1                 0                 0
## 2900               1                 0                 0
## 2901               1                 0                 0
## 2902               1                 0                 0
## 2903               1                 0                 0
## 2904               1                 0                 0
## 2905               1                 0                 0
## 2906               1                 0                 0
## 2907               1                 0                 0
## 2908               1                 0                 0
## 2909               1                 0                 0
## 2910               1                 0                 0
## 2911               1                 0                 0
## 2912               1                 0                 0
## 2913               1                 0                 0
## 2914               1                 0                 0
## 2915               0                 0                 1
## 2916               1                 0                 0
## 2917               1                 0                 0
## 2918               1                 0                 0
## 2919               1                 0                 0
## 2920               1                 0                 0
## 2921               1                 0                 0
## 2922               1                 0                 0
## 2923               1                 0                 0
## 2924               1                 0                 0
## 2925               1                 0                 0
## 2926               1                 0                 0
## 2927               1                 0                 0
## 2928               1                 0                 0
## 2929               1                 0                 0
## 2930               0                 1                 0
## 2931               1                 0                 0
## 2932               1                 0                 0
## 2933               1                 0                 0
## 2934               1                 0                 0
## 2935               1                 0                 0
## 2936               1                 0                 0
## 2937               1                 0                 0
## 2938               1                 0                 0
## 2939               1                 0                 0
## 2940               1                 0                 0
## 2941               0                 0                 1
## 2942               1                 0                 0
## 2943               1                 0                 0
## 2944               1                 0                 0
## 2945               1                 0                 0
## 2946               1                 0                 0
## 2947               1                 0                 0
## 2948               1                 0                 0
## 2949               1                 0                 0
## 2950               0                 0                 1
## 2951               1                 0                 0
## 2952               1                 0                 0
## 2953               1                 0                 0
## 2954               1                 0                 0
## 2955               1                 0                 0
## 2956               1                 0                 0
## 2957               1                 0                 0
## 2958               1                 0                 0
## 2959               1                 0                 0
## 2960               1                 0                 0
## 2961               0                 1                 0
## 2962               0                 0                 1
## 2963               1                 0                 0
## 2964               1                 0                 0
## 2965               1                 0                 0
## 2966               1                 0                 0
## 2967               1                 0                 0
## 2968               0                 0                 1
## 2969               1                 0                 0
## 2970               1                 0                 0
## 2971               0                 0                 1
## 2972               0                 0                 1
## 2973               1                 0                 0
## 2974               1                 0                 0
## 2975               0                 0                 1
## 2976               1                 0                 0
## 2977               0                 0                 1
## 2978               1                 0                 0
## 2979               0                 0                 1
## 2980               1                 0                 0
## 2981               1                 0                 0
## 2982               1                 0                 0
## 2983               1                 0                 0
## 2984               1                 0                 0
## 2985               1                 0                 0
## 2986               1                 0                 0
## 2987               0                 0                 1
## 2988               0                 0                 1
## 2989               0                 0                 1
## 2990               1                 0                 0
## 2991               1                 0                 0
## 2992               1                 0                 0
## 2993               0                 0                 1
## 2994               1                 0                 0
## 2995               1                 0                 0
## 2996               1                 0                 0
## 2997               0                 0                 1
## 2998               1                 0                 0
## 2999               0                 0                 1
## 3000               1                 0                 0
## 3001               0                 0                 1
## 3002               1                 0                 0
## 3003               1                 0                 0
## 3004               1                 0                 0
## 3005               1                 0                 0
## 3006               1                 0                 0
## 3007               1                 0                 0
## 3008               0                 1                 0
## 3009               1                 0                 0
## 3010               1                 0                 0
## 3011               1                 0                 0
## 3012               0                 0                 1
## 3013               1                 0                 0
## 3014               1                 0                 0
## 3015               1                 0                 0
## 3016               1                 0                 0
## 3017               0                 0                 1
## 3018               1                 0                 0
## 3019               0                 0                 1
## 3020               1                 0                 0
## 3021               1                 0                 0
## 3022               1                 0                 0
## 3023               1                 0                 0
## 3024               0                 0                 1
## 3025               1                 0                 0
## 3026               1                 0                 0
## 3027               1                 0                 0
## 3028               1                 0                 0
## 3029               1                 0                 0
## 3030               0                 0                 1
## 3031               1                 0                 0
## 3032               0                 1                 0
## 3033               0                 0                 1
## 3034               0                 1                 0
## 3035               1                 0                 0
## 3036               1                 0                 0
## 3037               1                 0                 0
## 3038               0                 0                 1
## 3039               1                 0                 0
## 3040               1                 0                 0
## 3041               1                 0                 0
## 3042               1                 0                 0
## 3043               0                 0                 1
## 3044               1                 0                 0
## 3045               0                 0                 1
## 3046               1                 0                 0
## 3047               1                 0                 0
## 3048               1                 0                 0
## 3049               0                 0                 1
## 3050               1                 0                 0
## 3051               1                 0                 0
## 3052               1                 0                 0
## 3053               1                 0                 0
## 3054               0                 0                 1
## 3055               1                 0                 0
## 3056               1                 0                 0
## 3057               1                 0                 0
## 3058               1                 0                 0
## 3059               1                 0                 0
## 3060               1                 0                 0
## 3061               1                 0                 0
## 3062               1                 0                 0
## 3063               1                 0                 0
## 3064               1                 0                 0
## 3065               1                 0                 0
## 3066               0                 0                 1
## 3067               1                 0                 0
## 3068               1                 0                 0
## 3069               1                 0                 0
## 3070               1                 0                 0
## 3071               1                 0                 0
## 3072               1                 0                 0
## 3073               1                 0                 0
## 3074               1                 0                 0
## 3075               1                 0                 0
## 3076               1                 0                 0
## 3077               0                 0                 1
## 3078               1                 0                 0
## 3079               1                 0                 0
## 3080               1                 0                 0
## 3081               1                 0                 0
## 3082               1                 0                 0
## 3083               1                 0                 0
## 3084               1                 0                 0
## 3085               1                 0                 0
## 3086               1                 0                 0
## 3087               1                 0                 0
## 3088               1                 0                 0
## 3089               1                 0                 0
## 3090               1                 0                 0
## 3091               1                 0                 0
## 3092               1                 0                 0
## 3093               1                 0                 0
## 3094               1                 0                 0
## 3095               1                 0                 0
## 3096               1                 0                 0
## 3097               1                 0                 0
## 3098               0                 0                 1
## 3099               1                 0                 0
## 3100               1                 0                 0
## 3101               1                 0                 0
## 3102               1                 0                 0
## 3103               1                 0                 0
## 3104               1                 0                 0
## 3105               0                 0                 1
## 3106               1                 0                 0
## 3107               1                 0                 0
## 3108               1                 0                 0
## 3109               1                 0                 0
## 3110               1                 0                 0
## 3111               1                 0                 0
## 3112               1                 0                 0
## 3113               1                 0                 0
## 3114               0                 0                 1
## 3115               1                 0                 0
## 3116               1                 0                 0
## 3117               0                 0                 1
## 3118               1                 0                 0
## 3119               0                 0                 1
## 3120               1                 0                 0
## 3121               1                 0                 0
## 3122               1                 0                 0
## 3123               1                 0                 0
## 3124               1                 0                 0
## 3125               1                 0                 0
## 3126               1                 0                 0
## 3127               1                 0                 0
## 3128               1                 0                 0
## 3129               1                 0                 0
## 3130               0                 1                 0
## 3131               1                 0                 0
## 3132               1                 0                 0
## 3133               0                 1                 0
## 3134               1                 0                 0
## 3135               1                 0                 0
## 3136               0                 0                 1
## 3137               0                 1                 0
## 3138               0                 0                 1
## 3139               1                 0                 0
## 3140               1                 0                 0
## 3141               0                 1                 0
## 3142               1                 0                 0
## 3143               1                 0                 0
## 3144               1                 0                 0
## 3145               1                 0                 0
## 3146               1                 0                 0
## 3147               1                 0                 0
## 3148               1                 0                 0
## 3149               0                 1                 0
## 3150               1                 0                 0
## 3151               1                 0                 0
## 3152               1                 0                 0
## 3153               1                 0                 0
## 3154               1                 0                 0
## 3155               1                 0                 0
## 3156               1                 0                 0
## 3157               1                 0                 0
## 3158               1                 0                 0
## 3159               0                 0                 1
## 3160               0                 0                 1
## 3161               1                 0                 0
## 3162               1                 0                 0
## 3163               1                 0                 0
## 3164               1                 0                 0
## 3165               1                 0                 0
## 3166               1                 0                 0
## 3167               0                 0                 1
## 3168               1                 0                 0
## 3169               1                 0                 0
## 3170               1                 0                 0
## 3171               1                 0                 0
## 3172               0                 0                 1
## 3173               1                 0                 0
## 3174               1                 0                 0
## 3175               0                 1                 0
## 3176               0                 0                 1
## 3177               1                 0                 0
## 3178               1                 0                 0
## 3179               1                 0                 0
## 3180               0                 0                 1
## 3181               0                 0                 1
## 3182               1                 0                 0
## 3183               1                 0                 0
## 3184               1                 0                 0
## 3185               1                 0                 0
## 3186               1                 0                 0
## 3187               1                 0                 0
## 3188               1                 0                 0
## 3189               1                 0                 0
## 3190               1                 0                 0
## 3191               1                 0                 0
## 3192               1                 0                 0
## 3193               1                 0                 0
## 3194               1                 0                 0
## 3195               1                 0                 0
## 3196               1                 0                 0
## 3197               1                 0                 0
## 3198               0                 0                 1
## 3199               1                 0                 0
## 3200               1                 0                 0
## 3201               1                 0                 0
## 3202               1                 0                 0
## 3203               1                 0                 0
## 3204               1                 0                 0
## 3205               1                 0                 0
## 3206               1                 0                 0
## 3207               0                 0                 1
## 3208               1                 0                 0
## 3209               1                 0                 0
## 3210               0                 0                 1
## 3211               0                 0                 1
## 3212               1                 0                 0
## 3213               0                 0                 1
## 3214               1                 0                 0
## 3215               1                 0                 0
## 3216               0                 0                 1
## 3217               1                 0                 0
## 3218               0                 0                 1
## 3219               0                 1                 0
## 3220               0                 0                 1
## 3221               1                 0                 0
## 3222               1                 0                 0
## 3223               1                 0                 0
## 3224               1                 0                 0
## 3225               1                 0                 0
## 3226               0                 0                 1
## 3227               1                 0                 0
## 3228               1                 0                 0
## 3229               1                 0                 0
## 3230               1                 0                 0
## 3231               0                 0                 1
## 3232               1                 0                 0
## 3233               1                 0                 0
## 3234               1                 0                 0
## 3235               1                 0                 0
## 3236               1                 0                 0
## 3237               1                 0                 0
## 3238               1                 0                 0
## 3239               1                 0                 0
## 3240               1                 0                 0
## 3241               1                 0                 0
## 3242               1                 0                 0
## 3243               0                 1                 0
## 3244               0                 0                 1
## 3245               1                 0                 0
## 3246               1                 0                 0
## 3247               1                 0                 0
## 3248               1                 0                 0
## 3249               1                 0                 0
## 3250               1                 0                 0
## 3251               1                 0                 0
## 3252               1                 0                 0
## 3253               1                 0                 0
## 3254               1                 0                 0
## 3255               0                 0                 1
## 3256               1                 0                 0
## 3257               1                 0                 0
## 3258               1                 0                 0
## 3259               0                 0                 1
## 3260               0                 0                 1
## 3261               1                 0                 0
## 3262               1                 0                 0
## 3263               1                 0                 0
## 3264               1                 0                 0
## 3265               1                 0                 0
## 3266               0                 0                 1
## 3267               1                 0                 0
## 3268               1                 0                 0
## 3269               1                 0                 0
## 3270               1                 0                 0
## 3271               1                 0                 0
## 3272               1                 0                 0
## 3273               0                 0                 1
## 3274               0                 1                 0
## 3275               1                 0                 0
## 3276               1                 0                 0
## 3277               1                 0                 0
## 3278               1                 0                 0
## 3279               1                 0                 0
## 3280               1                 0                 0
## 3281               1                 0                 0
## 3282               1                 0                 0
## 3283               1                 0                 0
## 3284               1                 0                 0
## 3285               1                 0                 0
## 3286               0                 0                 1
## 3287               0                 0                 1
## 3288               1                 0                 0
## 3289               1                 0                 0
## 3290               1                 0                 0
## 3291               1                 0                 0
## 3292               1                 0                 0
## 3293               1                 0                 0
## 3294               1                 0                 0
## 3295               0                 1                 0
## 3296               0                 1                 0
## 3297               0                 0                 1
## 3298               0                 0                 1
## 3299               1                 0                 0
## 3300               1                 0                 0
## 3301               1                 0                 0
## 3302               1                 0                 0
## 3303               1                 0                 0
## 3304               0                 0                 1
## 3305               1                 0                 0
## 3306               1                 0                 0
## 3307               1                 0                 0
## 3308               1                 0                 0
## 3309               1                 0                 0
## 3310               1                 0                 0
## 3311               1                 0                 0
## 3312               1                 0                 0
## 3313               1                 0                 0
## 3314               1                 0                 0
## 3315               1                 0                 0
## 3316               1                 0                 0
## 3317               0                 0                 1
## 3318               1                 0                 0
## 3319               0                 0                 1
## 3320               1                 0                 0
## 3321               0                 0                 1
## 3322               1                 0                 0
## 3323               1                 0                 0
## 3324               0                 0                 1
## 3325               1                 0                 0
## 3326               1                 0                 0
## 3327               1                 0                 0
## 3328               0                 1                 0
## 3329               1                 0                 0
## 3330               1                 0                 0
## 3331               1                 0                 0
## 3332               1                 0                 0
## 3333               0                 0                 1
## 3334               1                 0                 0
## 3335               1                 0                 0
## 3336               1                 0                 0
## 3337               0                 1                 0
## 3338               1                 0                 0
## 3339               1                 0                 0
## 3340               1                 0                 0
## 3341               1                 0                 0
## 3342               1                 0                 0
## 3343               1                 0                 0
## 3344               1                 0                 0
## 3345               1                 0                 0
## 3346               1                 0                 0
## 3347               1                 0                 0
## 3348               1                 0                 0
## 3349               1                 0                 0
## 3350               1                 0                 0
## 3351               1                 0                 0
## 3352               1                 0                 0
## 3353               1                 0                 0
## 3354               1                 0                 0
## 3355               1                 0                 0
## 3356               0                 0                 1
## 3357               1                 0                 0
## 3358               0                 0                 1
## 3359               0                 0                 1
## 3360               1                 0                 0
## 3361               1                 0                 0
## 3362               1                 0                 0
## 3363               1                 0                 0
## 3364               0                 0                 1
## 3365               1                 0                 0
## 3366               1                 0                 0
## 3367               1                 0                 0
## 3368               1                 0                 0
## 3369               0                 0                 1
## 3370               1                 0                 0
## 3371               1                 0                 0
## 3372               1                 0                 0
## 3373               1                 0                 0
## 3374               1                 0                 0
## 3375               1                 0                 0
## 3376               1                 0                 0
## 3377               0                 0                 1
## 3378               0                 0                 1
## 3379               1                 0                 0
## 3380               1                 0                 0
## 3381               1                 0                 0
## 3382               1                 0                 0
## 3383               1                 0                 0
## 3384               1                 0                 0
## 3385               1                 0                 0
## 3386               1                 0                 0
## 3387               0                 0                 1
## 3388               1                 0                 0
## 3389               1                 0                 0
## 3390               1                 0                 0
## 3391               1                 0                 0
## 3392               1                 0                 0
## 3393               0                 0                 1
## 3394               0                 1                 0
## 3395               1                 0                 0
## 3396               0                 0                 1
## 3397               1                 0                 0
## 3398               1                 0                 0
## 3399               1                 0                 0
## 3400               0                 1                 0
## 3401               1                 0                 0
## 3402               1                 0                 0
## 3403               1                 0                 0
## 3404               1                 0                 0
## 3405               1                 0                 0
## 3406               0                 0                 1
## 3407               1                 0                 0
## 3408               0                 0                 1
## 3409               1                 0                 0
## 3410               1                 0                 0
## 3411               1                 0                 0
## 3412               1                 0                 0
## 3413               1                 0                 0
## 3414               1                 0                 0
## 3415               1                 0                 0
## 3416               1                 0                 0
## 3417               0                 1                 0
## 3418               1                 0                 0
## 3419               0                 0                 1
## 3420               1                 0                 0
## 3421               0                 1                 0
## 3422               1                 0                 0
## 3423               1                 0                 0
## 3424               1                 0                 0
## 3425               1                 0                 0
## 3426               1                 0                 0
## 3427               0                 0                 1
## 3428               1                 0                 0
## 3429               0                 0                 1
## 3430               1                 0                 0
## 3431               1                 0                 0
## 3432               1                 0                 0
## 3433               1                 0                 0
## 3434               1                 0                 0
## 3435               1                 0                 0
## 3436               1                 0                 0
## 3437               1                 0                 0
## 3438               1                 0                 0
## 3439               1                 0                 0
## 3440               1                 0                 0
## 3441               1                 0                 0
## 3442               1                 0                 0
## 3443               1                 0                 0
## 3444               1                 0                 0
## 3445               1                 0                 0
## 3446               0                 1                 0
## 3447               0                 0                 1
## 3448               1                 0                 0
## 3449               1                 0                 0
## 3450               1                 0                 0
## 3451               1                 0                 0
## 3452               0                 0                 1
## 3453               1                 0                 0
## 3454               1                 0                 0
## 3455               1                 0                 0
## 3456               1                 0                 0
## 3457               1                 0                 0
## 3458               1                 0                 0
## 3459               1                 0                 0
## 3460               1                 0                 0
## 3461               0                 0                 1
## 3462               0                 0                 1
## 3463               1                 0                 0
## 3464               1                 0                 0
## 3465               1                 0                 0
## 3466               1                 0                 0
## 3467               1                 0                 0
## 3468               1                 0                 0
## 3469               1                 0                 0
## 3470               1                 0                 0
## 3471               0                 0                 1
## 3472               1                 0                 0
## 3473               1                 0                 0
## 3474               1                 0                 0
## 3475               1                 0                 0
## 3476               1                 0                 0
## 3477               1                 0                 0
## 3478               0                 0                 1
## 3479               0                 0                 1
## 3480               0                 0                 1
## 3481               1                 0                 0
## 3482               1                 0                 0
## 3483               0                 1                 0
## 3484               1                 0                 0
## 3485               0                 0                 1
## 3486               1                 0                 0
## 3487               0                 1                 0
## 3488               0                 0                 1
## 3489               0                 0                 1
## 3490               1                 0                 0
## 3491               1                 0                 0
## 3492               1                 0                 0
## 3493               1                 0                 0
## 3494               1                 0                 0
## 3495               1                 0                 0
## 3496               0                 0                 1
## 3497               1                 0                 0
## 3498               1                 0                 0
## 3499               1                 0                 0
## 3500               1                 0                 0
## 3501               1                 0                 0
## 3502               1                 0                 0
## 3503               1                 0                 0
## 3504               1                 0                 0
## 3505               1                 0                 0
## 3506               0                 1                 0
## 3507               1                 0                 0
## 3508               1                 0                 0
## 3509               1                 0                 0
## 3510               1                 0                 0
## 3511               1                 0                 0
## 3512               1                 0                 0
## 3513               1                 0                 0
## 3514               1                 0                 0
## 3515               0                 0                 1
## 3516               1                 0                 0
## 3517               0                 0                 1
## 3518               1                 0                 0
## 3519               0                 0                 1
## 3520               0                 0                 1
## 3521               1                 0                 0
## 3522               1                 0                 0
## 3523               1                 0                 0
## 3524               1                 0                 0
## 3525               1                 0                 0
## 3526               1                 0                 0
## 3527               1                 0                 0
## 3528               1                 0                 0
## 3529               1                 0                 0
## 3530               1                 0                 0
## 3531               1                 0                 0
## 3532               1                 0                 0
## 3533               1                 0                 0
## 3534               1                 0                 0
## 3535               1                 0                 0
## 3536               0                 0                 1
## 3537               0                 0                 1
## 3538               1                 0                 0
## 3539               0                 1                 0
## 3540               1                 0                 0
## 3541               1                 0                 0
## 3542               1                 0                 0
## 3543               0                 0                 1
## 3544               1                 0                 0
## 3545               1                 0                 0
## 3546               1                 0                 0
## 3547               1                 0                 0
## 3548               1                 0                 0
## 3549               1                 0                 0
## 3550               1                 0                 0
## 3551               1                 0                 0
## 3552               1                 0                 0
## 3553               0                 1                 0
## 3554               1                 0                 0
## 3555               1                 0                 0
## 3556               0                 0                 1
## 3557               0                 0                 1
## 3558               1                 0                 0
## 3559               1                 0                 0
## 3560               1                 0                 0
## 3561               1                 0                 0
## 3562               1                 0                 0
## 3563               0                 0                 1
## 3564               1                 0                 0
## 3565               1                 0                 0
## 3566               1                 0                 0
## 3567               1                 0                 0
## 3568               1                 0                 0
## 3569               1                 0                 0
## 3570               1                 0                 0
## 3571               1                 0                 0
## 3572               0                 0                 1
## 3573               1                 0                 0
## 3574               1                 0                 0
## 3575               1                 0                 0
## 3576               1                 0                 0
## 3577               1                 0                 0
## 3578               1                 0                 0
## 3579               1                 0                 0
## 3580               1                 0                 0
## 3581               1                 0                 0
## 3582               1                 0                 0
## 3583               1                 0                 0
## 3584               0                 0                 1
## 3585               0                 0                 1
## 3586               1                 0                 0
## 3587               1                 0                 0
## 3588               1                 0                 0
## 3589               1                 0                 0
## 3590               1                 0                 0
## 3591               1                 0                 0
## 3592               1                 0                 0
## 3593               1                 0                 0
## 3594               1                 0                 0
## 3595               1                 0                 0
## 3596               1                 0                 0
## 3597               1                 0                 0
## 3598               1                 0                 0
## 3599               1                 0                 0
## 3600               1                 0                 0
## 3601               1                 0                 0
## 3602               1                 0                 0
## 3603               1                 0                 0
## 3604               1                 0                 0
## 3605               1                 0                 0
## 3606               1                 0                 0
## 3607               1                 0                 0
## 3608               1                 0                 0
## 3609               0                 0                 1
## 3610               1                 0                 0
## 3611               1                 0                 0
## 3612               0                 0                 1
## 3613               1                 0                 0
## 3614               1                 0                 0
## 3615               0                 0                 1
## 3616               1                 0                 0
## 3617               1                 0                 0
## 3618               1                 0                 0
## 3619               1                 0                 0
## 3620               1                 0                 0
## 3621               1                 0                 0
## 3622               1                 0                 0
## 3623               1                 0                 0
## 3624               1                 0                 0
## 3625               1                 0                 0
## 3626               1                 0                 0
## 3627               1                 0                 0
## 3628               1                 0                 0
## 3629               1                 0                 0
## 3630               1                 0                 0
## 3631               1                 0                 0
## 3632               1                 0                 0
## 3633               1                 0                 0
## 3634               1                 0                 0
## 3635               0                 0                 1
## 3636               1                 0                 0
## 3637               1                 0                 0
## 3638               1                 0                 0
## 3639               1                 0                 0
## 3640               1                 0                 0
## 3641               1                 0                 0
## 3642               1                 0                 0
## 3643               1                 0                 0
## 3644               0                 0                 1
## 3645               1                 0                 0
## 3646               1                 0                 0
## 3647               1                 0                 0
## 3648               1                 0                 0
## 3649               0                 0                 1
## 3650               1                 0                 0
## 3651               1                 0                 0
## 3652               1                 0                 0
## 3653               1                 0                 0
## 3654               1                 0                 0
## 3655               0                 0                 1
## 3656               1                 0                 0
## 3657               0                 0                 1
## 3658               1                 0                 0
## 3659               1                 0                 0
## 3660               0                 0                 1
## 3661               0                 0                 1
## 3662               1                 0                 0
## 3663               1                 0                 0
## 3664               1                 0                 0
## 3665               1                 0                 0
## 3666               0                 0                 1
## 3667               1                 0                 0
## 3668               1                 0                 0
## 3669               0                 1                 0
## 3670               0                 0                 1
## 3671               1                 0                 0
## 3672               0                 0                 1
## 3673               0                 0                 1
## 3674               1                 0                 0
## 3675               1                 0                 0
## 3676               1                 0                 0
## 3677               1                 0                 0
## 3678               0                 0                 1
## 3679               0                 0                 1
## 3680               1                 0                 0
## 3681               1                 0                 0
## 3682               1                 0                 0
## 3683               1                 0                 0
## 3684               1                 0                 0
## 3685               1                 0                 0
## 3686               0                 0                 1
## 3687               0                 0                 1
## 3688               1                 0                 0
## 3689               1                 0                 0
## 3690               0                 0                 1
## 3691               1                 0                 0
## 3692               1                 0                 0
## 3693               1                 0                 0
## 3694               1                 0                 0
## 3695               1                 0                 0
## 3696               1                 0                 0
## 3697               1                 0                 0
## 3698               1                 0                 0
## 3699               1                 0                 0
## 3700               1                 0                 0
## 3701               1                 0                 0
## 3702               1                 0                 0
## 3703               1                 0                 0
## 3704               1                 0                 0
## 3705               1                 0                 0
## 3706               0                 0                 1
## 3707               1                 0                 0
## 3708               1                 0                 0
## 3709               0                 0                 1
## 3710               1                 0                 0
## 3711               1                 0                 0
## 3712               1                 0                 0
## 3713               1                 0                 0
## 3714               1                 0                 0
## 3715               1                 0                 0
## 3716               1                 0                 0
## 3717               1                 0                 0
## 3718               1                 0                 0
## 3719               1                 0                 0
## 3720               1                 0                 0
## 3721               1                 0                 0
## 3722               1                 0                 0
## 3723               1                 0                 0
## 3724               1                 0                 0
## 3725               1                 0                 0
## 3726               0                 0                 1
## 3727               1                 0                 0
## 3728               0                 0                 1
## 3729               1                 0                 0
## 3730               1                 0                 0
## 3731               1                 0                 0
## 3732               1                 0                 0
## 3733               0                 0                 1
## 3734               1                 0                 0
## 3735               0                 0                 1
## 3736               1                 0                 0
## 3737               0                 0                 1
## 3738               1                 0                 0
## 3739               1                 0                 0
## 3740               1                 0                 0
## 3741               1                 0                 0
## 3742               0                 0                 1
## 3743               1                 0                 0
## 3744               1                 0                 0
## 3745               1                 0                 0
## 3746               0                 0                 1
## 3747               0                 0                 1
## 3748               1                 0                 0
## 3749               1                 0                 0
## 3750               1                 0                 0
## 3751               1                 0                 0
## 3752               1                 0                 0
## 3753               1                 0                 0
## 3754               1                 0                 0
## 3755               1                 0                 0
## 3756               1                 0                 0
## 3757               1                 0                 0
## 3758               1                 0                 0
## 3759               0                 0                 1
## 3760               1                 0                 0
## 3761               1                 0                 0
## 3762               1                 0                 0
## 3763               1                 0                 0
## 3764               1                 0                 0
## 3765               1                 0                 0
## 3766               1                 0                 0
## 3767               1                 0                 0
## 3768               1                 0                 0
## 3769               1                 0                 0
## 3770               0                 0                 1
## 3771               1                 0                 0
## 3772               1                 0                 0
## 3773               1                 0                 0
## 3774               1                 0                 0
## 3775               1                 0                 0
## 3776               1                 0                 0
## 3777               1                 0                 0
## 3778               1                 0                 0
## 3779               0                 0                 1
## 3780               1                 0                 0
## 3781               1                 0                 0
## 3782               1                 0                 0
## 3783               1                 0                 0
## 3784               1                 0                 0
## 3785               1                 0                 0
## 3786               1                 0                 0
## 3787               1                 0                 0
## 3788               1                 0                 0
## 3789               1                 0                 0
## 3790               1                 0                 0
## 3791               1                 0                 0
## 3792               1                 0                 0
## 3793               0                 1                 0
## 3794               1                 0                 0
## 3795               1                 0                 0
## 3796               1                 0                 0
## 3797               1                 0                 0
## 3798               1                 0                 0
## 3799               1                 0                 0
## 3800               1                 0                 0
## 3801               1                 0                 0
## 3802               0                 0                 1
## 3803               1                 0                 0
## 3804               1                 0                 0
## 3805               1                 0                 0
## 3806               1                 0                 0
## 3807               1                 0                 0
## 3808               1                 0                 0
## 3809               0                 1                 0
## 3810               1                 0                 0
## 3811               1                 0                 0
## 3812               1                 0                 0
## 3813               1                 0                 0
## 3814               1                 0                 0
## 3815               1                 0                 0
## 3816               1                 0                 0
## 3817               1                 0                 0
## 3818               1                 0                 0
## 3819               1                 0                 0
## 3820               1                 0                 0
## 3821               1                 0                 0
## 3822               1                 0                 0
## 3823               1                 0                 0
## 3824               1                 0                 0
## 3825               1                 0                 0
## 3826               1                 0                 0
## 3827               1                 0                 0
## 3828               1                 0                 0
## 3829               1                 0                 0
## 3830               1                 0                 0
## 3831               1                 0                 0
## 3832               1                 0                 0
## 3833               1                 0                 0
## 3834               1                 0                 0
## 3835               1                 0                 0
## 3836               1                 0                 0
## 3837               1                 0                 0
## 3838               0                 0                 1
## 3839               1                 0                 0
## 3840               1                 0                 0
## 3841               0                 1                 0
## 3842               1                 0                 0
## 3843               0                 0                 1
## 3844               1                 0                 0
## 3845               0                 0                 1
## 3846               1                 0                 0
## 3847               1                 0                 0
## 3848               1                 0                 0
## 3849               1                 0                 0
## 3850               1                 0                 0
## 3851               1                 0                 0
## 3852               1                 0                 0
## 3853               1                 0                 0
## 3854               1                 0                 0
## 3855               1                 0                 0
## 3856               1                 0                 0
## 3857               0                 0                 1
## 3858               0                 1                 0
## 3859               1                 0                 0
## 3860               1                 0                 0
## 3861               1                 0                 0
## 3862               1                 0                 0
## 3863               1                 0                 0
## 3864               0                 0                 1
## 3865               1                 0                 0
## 3866               1                 0                 0
## 3867               1                 0                 0
## 3868               1                 0                 0
## 3869               1                 0                 0
## 3870               1                 0                 0
## 3871               1                 0                 0
## 3872               1                 0                 0
## 3873               0                 0                 1
## 3874               0                 0                 1
## 3875               0                 0                 1
## 3876               1                 0                 0
## 3877               0                 0                 1
## 3878               1                 0                 0
## 3879               1                 0                 0
## 3880               1                 0                 0
## 3881               1                 0                 0
## 3882               0                 1                 0
## 3883               1                 0                 0
## 3884               1                 0                 0
## 3885               1                 0                 0
## 3886               1                 0                 0
## 3887               1                 0                 0
## 3888               1                 0                 0
## 3889               1                 0                 0
## 3890               0                 1                 0
## 3891               1                 0                 0
## 3892               1                 0                 0
## 3893               1                 0                 0
## 3894               1                 0                 0
## 3895               0                 0                 1
## 3896               1                 0                 0
## 3897               0                 1                 0
## 3898               1                 0                 0
## 3899               1                 0                 0
## 3900               1                 0                 0
## 3901               1                 0                 0
## 3902               0                 0                 1
## 3903               1                 0                 0
## 3904               1                 0                 0
## 3905               0                 1                 0
## 3906               1                 0                 0
## 3907               1                 0                 0
## 3908               1                 0                 0
## 3909               0                 0                 1
## 3910               1                 0                 0
## 3911               1                 0                 0
## 3912               1                 0                 0
## 3913               0                 0                 1
## 3914               1                 0                 0
## 3915               1                 0                 0
## 3916               1                 0                 0
## 3917               1                 0                 0
## 3918               1                 0                 0
## 3919               1                 0                 0
## 3920               1                 0                 0
## 3921               1                 0                 0
## 3922               1                 0                 0
## 3923               1                 0                 0
## 3924               1                 0                 0
## 3925               1                 0                 0
## 3926               1                 0                 0
## 3927               1                 0                 0
## 3928               1                 0                 0
## 3929               1                 0                 0
## 3930               1                 0                 0
## 3931               1                 0                 0
## 3932               0                 0                 1
## 3933               0                 0                 1
## 3934               1                 0                 0
## 3935               0                 0                 1
## 3936               1                 0                 0
## 3937               0                 0                 1
## 3938               0                 0                 1
## 3939               1                 0                 0
## 3940               1                 0                 0
## 3941               0                 0                 1
## 3942               1                 0                 0
## 3943               1                 0                 0
## 3944               1                 0                 0
## 3945               1                 0                 0
## 3946               1                 0                 0
## 3947               1                 0                 0
## 3948               1                 0                 0
## 3949               0                 0                 1
## 3950               0                 0                 1
## 3951               0                 1                 0
## 3952               1                 0                 0
## 3953               1                 0                 0
## 3954               1                 0                 0
## 3955               1                 0                 0
## 3956               0                 0                 1
## 3957               1                 0                 0
## 3958               0                 0                 1
## 3959               1                 0                 0
## 3960               1                 0                 0
## 3961               1                 0                 0
## 3962               0                 1                 0
## 3963               1                 0                 0
## 3964               1                 0                 0
## 3965               1                 0                 0
## 3966               1                 0                 0
## 3967               1                 0                 0
## 3968               1                 0                 0
## 3969               1                 0                 0
## 3970               1                 0                 0
## 3971               0                 1                 0
## 3972               1                 0                 0
## 3973               1                 0                 0
## 3974               1                 0                 0
## 3975               1                 0                 0
## 3976               1                 0                 0
## 3977               1                 0                 0
## 3978               1                 0                 0
## 3979               1                 0                 0
## 3980               1                 0                 0
## 3981               0                 1                 0
## 3982               1                 0                 0
## 3983               1                 0                 0
## 3984               0                 0                 1
## 3985               1                 0                 0
## 3986               1                 0                 0
## 3987               1                 0                 0
## 3988               0                 0                 1
## 3989               1                 0                 0
## 3990               1                 0                 0
## 3991               1                 0                 0
## 3992               0                 0                 1
## 3993               1                 0                 0
## 3994               1                 0                 0
## 3995               1                 0                 0
## 3996               1                 0                 0
## 3997               1                 0                 0
## 3998               1                 0                 0
## 3999               0                 0                 1
## 4000               1                 0                 0
## 4001               1                 0                 0
## 4002               1                 0                 0
## 4003               1                 0                 0
## 4004               1                 0                 0
## 4005               0                 1                 0
## 4006               1                 0                 0
## 4007               1                 0                 0
## 4008               1                 0                 0
## 4009               1                 0                 0
## 4010               0                 0                 1
## 4011               0                 0                 1
## 4012               1                 0                 0
## 4013               1                 0                 0
## 4014               1                 0                 0
## 4015               0                 0                 1
## 4016               1                 0                 0
## 4017               1                 0                 0
## 4018               1                 0                 0
## 4019               1                 0                 0
## 4020               1                 0                 0
## 4021               1                 0                 0
## 4022               1                 0                 0
## 4023               1                 0                 0
## 4024               1                 0                 0
## 4025               1                 0                 0
## 4026               1                 0                 0
## 4027               1                 0                 0
## 4028               1                 0                 0
## 4029               0                 0                 1
## 4030               1                 0                 0
## 4031               0                 0                 1
## 4032               1                 0                 0
## 4033               1                 0                 0
## 4034               1                 0                 0
## 4035               1                 0                 0
## 4036               1                 0                 0
## 4037               1                 0                 0
## 4038               1                 0                 0
## 4039               0                 0                 1
## 4040               1                 0                 0
## 4041               1                 0                 0
## 4042               1                 0                 0
## 4043               0                 0                 1
## 4044               1                 0                 0
## 4045               1                 0                 0
## 4046               1                 0                 0
## 4047               1                 0                 0
## 4048               1                 0                 0
## 4049               1                 0                 0
## 4050               0                 0                 1
## 4051               1                 0                 0
## 4052               1                 0                 0
## 4053               1                 0                 0
## 4054               1                 0                 0
## 4055               1                 0                 0
## 4056               1                 0                 0
## 4057               1                 0                 0
## 4058               1                 0                 0
## 4059               1                 0                 0
## 4060               0                 0                 1
## 4061               1                 0                 0
## 4062               1                 0                 0
## 4063               1                 0                 0
## 4064               1                 0                 0
## 4065               0                 0                 1
## 4066               1                 0                 0
## 4067               1                 0                 0
## 4068               1                 0                 0
## 4069               1                 0                 0
## 4070               1                 0                 0
## 4071               0                 0                 1
## 4072               1                 0                 0
## 4073               1                 0                 0
## 4074               1                 0                 0
## 4075               1                 0                 0
## 4076               1                 0                 0
## 4077               1                 0                 0
## 4078               1                 0                 0
## 4079               0                 0                 1
## 4080               1                 0                 0
## 4081               0                 0                 1
## 4082               1                 0                 0
## 4083               1                 0                 0
## 4084               1                 0                 0
## 4085               1                 0                 0
## 4086               1                 0                 0
## 4087               1                 0                 0
## 4088               1                 0                 0
## 4089               1                 0                 0
## 4090               0                 0                 1
## 4091               1                 0                 0
## 4092               1                 0                 0
## 4093               0                 0                 1
## 4094               1                 0                 0
## 4095               0                 0                 1
## 4096               1                 0                 0
## 4097               1                 0                 0
## 4098               1                 0                 0
## 4099               1                 0                 0
## 4100               1                 0                 0
## 4101               0                 1                 0
## 4102               1                 0                 0
## 4103               1                 0                 0
## 4104               1                 0                 0
## 4105               1                 0                 0
## 4106               1                 0                 0
## 4107               1                 0                 0
## 4108               0                 0                 1
## 4109               1                 0                 0
## 4110               1                 0                 0
## 4111               0                 0                 1
## 4112               1                 0                 0
## 4113               1                 0                 0
## 4114               1                 0                 0
## 4115               0                 0                 1
## 4116               0                 0                 1
## 4117               1                 0                 0
## 4118               1                 0                 0
## 4119               1                 0                 0
## 4120               1                 0                 0
## 4121               1                 0                 0
## 4122               1                 0                 0
## 4123               1                 0                 0
## 4124               1                 0                 0
## 4125               1                 0                 0
## 4126               1                 0                 0
## 4127               1                 0                 0
## 4128               0                 0                 1
## 4129               1                 0                 0
## 4130               1                 0                 0
## 4131               1                 0                 0
## 4132               1                 0                 0
## 4133               1                 0                 0
## 4134               0                 0                 1
## 4135               1                 0                 0
## 4136               1                 0                 0
## 4137               0                 0                 1
## 4138               0                 0                 1
## 4139               0                 0                 1
## 4140               1                 0                 0
## 4141               1                 0                 0
## 4142               1                 0                 0
## 4143               1                 0                 0
## 4144               1                 0                 0
## 4145               1                 0                 0
## 4146               1                 0                 0
## 4147               1                 0                 0
## 4148               1                 0                 0
## 4149               1                 0                 0
## 4150               0                 1                 0
## 4151               1                 0                 0
## 4152               1                 0                 0
## 4153               1                 0                 0
## 4154               1                 0                 0
## 4155               1                 0                 0
## 4156               0                 1                 0
## 4157               1                 0                 0
## 4158               1                 0                 0
## 4159               0                 0                 1
## 4160               1                 0                 0
## 4161               1                 0                 0
## 4162               1                 0                 0
## 4163               1                 0                 0
## 4164               1                 0                 0
## 4165               1                 0                 0
## 4166               1                 0                 0
## 4167               1                 0                 0
## 4168               1                 0                 0
## 4169               0                 0                 1
## 4170               1                 0                 0
## 4171               1                 0                 0
## 4172               1                 0                 0
## 4173               1                 0                 0
## 4174               0                 0                 1
## 4175               0                 0                 1
## 4176               1                 0                 0
## 4177               1                 0                 0
## 4178               1                 0                 0
## 4179               1                 0                 0
## 4180               1                 0                 0
## 4181               1                 0                 0
## 4182               1                 0                 0
## 4183               1                 0                 0
## 4184               1                 0                 0
## 4185               1                 0                 0
## 4186               1                 0                 0
## 4187               1                 0                 0
## 4188               1                 0                 0
## 4189               1                 0                 0
## 4190               1                 0                 0
## 4191               1                 0                 0
## 4192               1                 0                 0
## 4193               1                 0                 0
## 4194               1                 0                 0
## 4195               1                 0                 0
## 4196               1                 0                 0
## 4197               1                 0                 0
## 4198               1                 0                 0
## 4199               1                 0                 0
## 4200               1                 0                 0
## 4201               1                 0                 0
## 4202               1                 0                 0
## 4203               0                 0                 1
## 4204               1                 0                 0
## 4205               1                 0                 0
## 4206               0                 0                 1
## 4207               1                 0                 0
## 4208               1                 0                 0
## 4209               1                 0                 0
## 4210               1                 0                 0
## 4211               0                 0                 1
## 4212               1                 0                 0
## 4213               1                 0                 0
## 4214               1                 0                 0
## 4215               1                 0                 0
## 4216               1                 0                 0
## 4217               1                 0                 0
## 4218               1                 0                 0
## 4219               0                 0                 1
## 4220               1                 0                 0
## 4221               1                 0                 0
## 4222               1                 0                 0
## 4223               1                 0                 0
## 4224               1                 0                 0
## 4225               1                 0                 0
## 4226               1                 0                 0
## 4227               1                 0                 0
## 4228               1                 0                 0
## 4229               1                 0                 0
## 4230               1                 0                 0
## 4231               1                 0                 0
## 4232               1                 0                 0
## 4233               1                 0                 0
## 4234               1                 0                 0
## 4235               0                 0                 1
## 4236               1                 0                 0
## 4237               0                 0                 1
## 4238               1                 0                 0
## 4239               0                 0                 1
## 4240               1                 0                 0
## 4241               1                 0                 0
## 4242               1                 0                 0
## 4243               0                 0                 1
## 4244               1                 0                 0
## 4245               0                 0                 1
## 4246               0                 0                 1
## 4247               1                 0                 0
## 4248               1                 0                 0
## 4249               1                 0                 0
## 4250               1                 0                 0
## 4251               1                 0                 0
## 4252               0                 0                 1
## 4253               1                 0                 0
## 4254               1                 0                 0
## 4255               1                 0                 0
## 4256               1                 0                 0
## 4257               1                 0                 0
## 4258               1                 0                 0
## 4259               1                 0                 0
## 4260               1                 0                 0
## 4261               1                 0                 0
## 4262               1                 0                 0
## 4263               1                 0                 0
## 4264               1                 0                 0
## 4265               1                 0                 0
## 4266               1                 0                 0
## 4267               1                 0                 0
## 4268               0                 0                 1
## 4269               1                 0                 0
## 4270               0                 0                 1
## 4271               1                 0                 0
## 4272               1                 0                 0
## 4273               1                 0                 0
## 4274               0                 0                 1
## 4275               1                 0                 0
## 4276               1                 0                 0
## 4277               1                 0                 0
## 4278               0                 0                 1
## 4279               1                 0                 0
## 4280               0                 0                 1
## 4281               1                 0                 0
## 4282               1                 0                 0
## 4283               1                 0                 0
## 4284               1                 0                 0
## 4285               1                 0                 0
## 4286               0                 0                 1
## 4287               1                 0                 0
## 4288               1                 0                 0
## 4289               1                 0                 0
## 4290               1                 0                 0
## 4291               1                 0                 0
## 4292               1                 0                 0
## 4293               1                 0                 0
## 4294               1                 0                 0
## 4295               1                 0                 0
## 4296               1                 0                 0
## 4297               1                 0                 0
## 4298               1                 0                 0
## 4299               0                 0                 1
## 4300               1                 0                 0
## 4301               0                 0                 1
## 4302               1                 0                 0
## 4303               1                 0                 0
## 4304               1                 0                 0
## 4305               1                 0                 0
## 4306               1                 0                 0
## 4307               1                 0                 0
## 4308               1                 0                 0
## 4309               1                 0                 0
## 4310               1                 0                 0
## 4311               0                 0                 1
## 4312               1                 0                 0
## 4313               1                 0                 0
## 4314               1                 0                 0
## 4315               1                 0                 0
## 4316               1                 0                 0
## 4317               1                 0                 0
## 4318               1                 0                 0
## 4319               1                 0                 0
## 4320               1                 0                 0
## 4321               0                 1                 0
## 4322               1                 0                 0
## 4323               0                 0                 1
## 4324               1                 0                 0
## 4325               0                 0                 1
## 4326               1                 0                 0
## 4327               1                 0                 0
## 4328               1                 0                 0
## 4329               1                 0                 0
## 4330               1                 0                 0
## 4331               1                 0                 0
## 4332               1                 0                 0
## 4333               1                 0                 0
## 4334               1                 0                 0
## 4335               1                 0                 0
## 4336               1                 0                 0
## 4337               1                 0                 0
## 4338               1                 0                 0
## 4339               1                 0                 0
## 4340               1                 0                 0
## 4341               0                 0                 1
## 4342               1                 0                 0
## 4343               1                 0                 0
## 4344               1                 0                 0
## 4345               1                 0                 0
## 4346               1                 0                 0
## 4347               1                 0                 0
## 4348               0                 1                 0
## 4349               1                 0                 0
## 4350               1                 0                 0
## 4351               0                 1                 0
## 4352               1                 0                 0
## 4353               1                 0                 0
## 4354               1                 0                 0
## 4355               1                 0                 0
## 4356               1                 0                 0
## 4357               1                 0                 0
## 4358               1                 0                 0
## 4359               1                 0                 0
## 4360               1                 0                 0
## 4361               0                 1                 0
## 4362               0                 0                 1
## 4363               1                 0                 0
## 4364               1                 0                 0
## 4365               1                 0                 0
## 4366               1                 0                 0
## 4367               0                 0                 1
## 4368               1                 0                 0
## 4369               1                 0                 0
## 4370               1                 0                 0
## 4371               1                 0                 0
## 4372               1                 0                 0
## 4373               1                 0                 0
## 4374               0                 0                 1
## 4375               1                 0                 0
## 4376               1                 0                 0
## 4377               1                 0                 0
## 4378               1                 0                 0
## 4379               1                 0                 0
## 4380               1                 0                 0
## 4381               0                 0                 1
## 4382               1                 0                 0
## 4383               1                 0                 0
## 4384               1                 0                 0
## 4385               1                 0                 0
## 4386               1                 0                 0
## 4387               1                 0                 0
## 4388               0                 0                 1
## 4389               1                 0                 0
## 4390               1                 0                 0
## 4391               0                 0                 1
## 4392               1                 0                 0
## 4393               1                 0                 0
## 4394               1                 0                 0
## 4395               1                 0                 0
## 4396               0                 0                 1
## 4397               1                 0                 0
## 4398               1                 0                 0
## 4399               1                 0                 0
## 4400               1                 0                 0
## 4401               1                 0                 0
## 4402               0                 0                 1
## 4403               1                 0                 0
## 4404               1                 0                 0
## 4405               1                 0                 0
## 4406               1                 0                 0
## 4407               1                 0                 0
## 4408               1                 0                 0
## 4409               1                 0                 0
## 4410               0                 0                 1
## 4411               0                 0                 1
## 4412               1                 0                 0
## 4413               1                 0                 0
## 4414               0                 0                 1
## 4415               1                 0                 0
## 4416               1                 0                 0
## 4417               1                 0                 0
## 4418               1                 0                 0
## 4419               1                 0                 0
## 4420               1                 0                 0
## 4421               1                 0                 0
## 4422               1                 0                 0
## 4423               1                 0                 0
## 4424               1                 0                 0
## 4425               1                 0                 0
## 4426               1                 0                 0
## 4427               1                 0                 0
## 4428               0                 0                 1
## 4429               1                 0                 0
## 4430               0                 1                 0
## 4431               1                 0                 0
## 4432               1                 0                 0
## 4433               1                 0                 0
## 4434               1                 0                 0
## 4435               0                 1                 0
## 4436               1                 0                 0
## 4437               1                 0                 0
## 4438               0                 1                 0
## 4439               1                 0                 0
## 4440               0                 0                 1
## 4441               0                 0                 1
## 4442               1                 0                 0
## 4443               1                 0                 0
## 4444               1                 0                 0
## 4445               1                 0                 0
## 4446               1                 0                 0
## 4447               1                 0                 0
## 4448               1                 0                 0
## 4449               1                 0                 0
## 4450               1                 0                 0
## 4451               0                 0                 1
## 4452               0                 0                 1
## 4453               1                 0                 0
## 4454               1                 0                 0
## 4455               0                 0                 1
## 4456               1                 0                 0
## 4457               1                 0                 0
## 4458               1                 0                 0
## 4459               1                 0                 0
## 4460               1                 0                 0
## 4461               1                 0                 0
## 4462               1                 0                 0
## 4463               1                 0                 0
## 4464               0                 0                 1
## 4465               1                 0                 0
## 4466               1                 0                 0
## 4467               1                 0                 0
## 4468               1                 0                 0
## 4469               0                 0                 1
## 4470               1                 0                 0
## 4471               1                 0                 0
## 4472               1                 0                 0
## 4473               1                 0                 0
## 4474               0                 0                 1
## 4475               1                 0                 0
## 4476               1                 0                 0
## 4477               1                 0                 0
## 4478               0                 0                 1
## 4479               1                 0                 0
## 4480               1                 0                 0
## 4481               1                 0                 0
## 4482               1                 0                 0
## 4483               1                 0                 0
## 4484               1                 0                 0
## 4485               1                 0                 0
## 4486               1                 0                 0
## 4487               0                 0                 1
## 4488               1                 0                 0
## 4489               0                 0                 1
## 4490               1                 0                 0
## 4491               0                 0                 1
## 4492               1                 0                 0
## 4493               0                 1                 0
## 4494               1                 0                 0
## 4495               1                 0                 0
## 4496               1                 0                 0
## 4497               1                 0                 0
## 4498               0                 0                 1
## 4499               1                 0                 0
## 4500               1                 0                 0
## 4501               1                 0                 0
## 4502               0                 0                 1
## 4503               1                 0                 0
## 4504               1                 0                 0
## 4505               1                 0                 0
## 4506               1                 0                 0
## 4507               0                 0                 1
## 4508               1                 0                 0
## 4509               0                 0                 1
## 4510               1                 0                 0
## 4511               1                 0                 0
## 4512               1                 0                 0
## 4513               1                 0                 0
## 4514               1                 0                 0
## 4515               1                 0                 0
## 4516               1                 0                 0
## 4517               1                 0                 0
## 4518               1                 0                 0
## 4519               1                 0                 0
## 4520               0                 0                 1
## 4521               1                 0                 0&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;quantile-binning&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Quantile Binning&lt;/h3&gt;
&lt;p&gt;Quantile binning aims to bin the data into roughly equal groups using quantiles.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;bins &amp;lt;- rbin_quantiles(mbank, y, age, 10)
bins&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Binning Summary
## -----------------------------
## Method               Quantile 
## Response             y 
## Predictor            age 
## Bins                 10 
## Count                4521 
## Goods                517 
## Bads                 4004 
## Entropy              0.5 
## Information Value    0.12 
## 
## 
##    cut_point bin_count good bad          woe           iv   entropy
## 1       &amp;lt; 29       410   71 339 -0.483686036 2.547353e-02 0.6649069
## 2       &amp;lt; 31       313   41 272 -0.154776266 1.760055e-03 0.5601482
## 3       &amp;lt; 34       567   55 512  0.183985174 3.953685e-03 0.4594187
## 4       &amp;lt; 36       396   45 351  0.007117468 4.425063e-06 0.5107878
## 5       &amp;lt; 39       519   47 472  0.259825118 7.008270e-03 0.4383322
## 6       &amp;lt; 42       431   33 398  0.442938178 1.575567e-02 0.3899626
## 7       &amp;lt; 46       449   47 402  0.099298221 9.423907e-04 0.4836486
## 8       &amp;lt; 51       521   40 481  0.439981550 1.881380e-02 0.3907140
## 9       &amp;lt; 56       445   49 396  0.042587647 1.756117e-04 0.5002548
## 10     &amp;gt;= 56       470   89 381 -0.592843261 4.564428e-02 0.7001343&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;plot-2&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Plot&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(bins)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-12-introducing-rbin_files/figure-html/quantile_plot-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;winsorized-binning&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Winsorized Binning&lt;/h3&gt;
&lt;p&gt;Winsorized binning is similar to equal length binning except that both tails
are cut off to obtain a smooth binning result. This technique is often used
to remove outliers during the data pre-processing stage. For Winsorized
binning, the Winsorized statistics are computed first. After the minimum and
maximum have been found, the split points are calculated the same way as in
equal length binning.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;bins &amp;lt;- rbin_winsorize(mbank, y, age, 10, winsor_rate = 0.05)
bins&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Binning Summary
## ------------------------------
## Method               Winsorize 
## Response             y 
## Predictor            age 
## Bins                 10 
## Count                4521 
## Goods                517 
## Bads                 4004 
## Entropy              0.51 
## Information Value    0.1 
## 
## 
##    cut_point bin_count good bad        woe           iv   entropy
## 1     &amp;lt; 30.2       723  112 611 -0.3504082 0.0224390979 0.6219926
## 2     &amp;lt; 33.4       567   55 512  0.1839852 0.0039536848 0.4594187
## 3     &amp;lt; 36.6       573   58 515  0.1367176 0.0022470488 0.4728562
## 4     &amp;lt; 39.8       497   44 453  0.2846962 0.0079801719 0.4315480
## 5       &amp;lt; 43       396   37 359  0.2253982 0.0040782670 0.4478305
## 6     &amp;lt; 46.2       461   43 418  0.2272751 0.0048235624 0.4473095
## 7     &amp;lt; 49.4       281   22 259  0.4187793 0.0092684760 0.3961315
## 8     &amp;lt; 52.6       309   32 277  0.1112753 0.0008106706 0.4801796
## 9     &amp;lt; 55.8       244   25 219  0.1231896 0.0007809490 0.4767424
## 10   &amp;gt;= 55.8       470   89 381 -0.5928433 0.0456442813 0.7001343&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;plot-3&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Plot&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(bins)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-03-12-introducing-rbin_files/figure-html/winsorize_plot-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;learning-more&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Learning More&lt;/h3&gt;
&lt;p&gt;The &lt;a href=&#34;https://rbin.rsquaredacademy.com/&#34;&gt;rbin website&lt;/a&gt; includes
comprehensive documentation on using the package, including the following
article that gives a brief introduction to rbin:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://rbin.rsquaredacademy.com/articles/introduction.html&#34;&gt;Introduction to rbin&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;feedback&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Feedback&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;rbin&lt;/strong&gt; has been on CRAN for a few months now while we were fixing bugs and
making the API stable. All feedback is welcome. Issues (bugs and feature
requests) can be posted to &lt;a href=&#34;https://github.com/rsquaredacademy/rbin/issues&#34;&gt;github tracker&lt;/a&gt;.
For help with code or other related questions, feel free to reach out to us
at &lt;a href=&#34;mailto:pkgs@rsquaredacademy.com&#34; class=&#34;email&#34;&gt;pkgs@rsquaredacademy.com&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Getting Help in R</title>
      <link>https://blog.rsquaredacademy.com/getting-help-in-r-updated/</link>
      <pubDate>Tue, 05 Mar 2019 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/getting-help-in-r-updated/</guid>
      <description>&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/help_banner.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In this post, we will learn about the different methods of getting help in R.
Often, we get stuck while doing some analysis as either we do not know the
correct function to use or its syntax. It is important for anyone who is new
to R to know the right place to look for help. There are two ways to look for
help in R:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;built in help system&lt;/li&gt;
&lt;li&gt;online&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the first section, we will look at various online resources that can
supplement the built in help system. In the second section, we will look at
various ways to access the built in help system of R. Let us get started!&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;online-resources&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Online Resources&lt;/h2&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/ZgU6ICh2YzI&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;div id=&#34;r-bloggers&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;R Bloggers&lt;/h3&gt;
&lt;p&gt;&lt;a href=&#34;https://www.r-bloggers.com/&#34;&gt;R Bloggers&lt;/a&gt; aggregates blogs written in English from across the globe. This is the first place you want to visit if you want help with R, data analysis, visualization and machine learning. There are blogs on a wide range of topics and the latest content is delivered to your inbox if you subscribe. If you are a blogger yourself, share it with th R community by adding your blog to R Bloggers.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/r-bloggers.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;stack-overflow&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Stack Overflow&lt;/h3&gt;
&lt;p&gt;&lt;a href=&#34;https://stackoverflow.com/questions/tagged/r&#34;&gt;Stack Overflow&lt;/a&gt; is a great place to visit if you are having trouble with R code or packages. Chances are high that someone has already encountered the same or similar problem and you can use the answers given by R experts. In case you have encountered a new problem or issue, you can ask for help by providing a reproducible example of your analysis along with the R code. Use the &lt;a href=&#34;http://reprex.tidyverse.org/&#34;&gt;reprex&lt;/a&gt; package to create reproducible examples.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/stack-overflow.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;twitter&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Twitter&lt;/h3&gt;
&lt;p&gt;The R community is very active on Twitter and there are lot of R experts who are willing to help those who are new to R. Use the hashtag &lt;a href=&#34;https://twitter.com/search?q=%23rstats&#34;&gt;#rstats&lt;/a&gt; if you are asking for help or guidance on Twitter.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/twitter.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;rstudio-community&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;RStudio Community&lt;/h3&gt;
&lt;p&gt;&lt;a href=&#34;https://community.rstudio.com/&#34;&gt;RStudio Community&lt;/a&gt; is similar to Stack Overflow. You can ask questions
related to RStudio, Shiny, tidyverse and other RStudio products.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/rstudio.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;r4ds-community&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;r4ds Community&lt;/h3&gt;
&lt;p&gt;An online learning community that brings learners and mentors on a single platform. You can learn more about the
community &lt;a href=&#34;http://www.rfordatasci.com/&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/r4ds.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;rstudio-resources&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;RStudio Resources&lt;/h3&gt;
&lt;p&gt;&lt;a href=&#34;https://resources.rstudio.com/&#34;&gt;RStudio&lt;/a&gt; has very good resources including cheatsheets, webinars and blogs.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;reddit&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Reddit&lt;/h3&gt;
&lt;p&gt;&lt;a href=&#34;https://www.reddit.com/r/rstats/&#34;&gt;Reddit&lt;/a&gt; is another place where you can look for help. The discussions are moderated by R experts. There are subreddits for &lt;a href=&#34;https://www.reddit.com/r/rstats/&#34;&gt;Rstats&lt;/a&gt;, &lt;a href=&#34;https://www.reddit.com/r/Rlanguage/&#34;&gt;Rlanguage&lt;/a&gt;, &lt;a href=&#34;https://www.reddit.com/r/rshiny/&#34;&gt;Rstudio&lt;/a&gt; and &lt;a href=&#34;https://www.reddit.com/r/RStudio/&#34;&gt;Rshiny&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/reddit.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;r-weekly&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;R Weekly&lt;/h3&gt;
&lt;p&gt;Visit &lt;a href=&#34;https://rweekly.org/&#34;&gt;RWeekly&lt;/a&gt; to get regular updates about the R community. You can find information about new packages, blogs, conferences, workshops, tutorials and R jobs.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/r-weekly.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;r-user-groups&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;R User Groups&lt;/h3&gt;
&lt;p&gt;There are several R User Groups active across the globe. You can find the list &lt;a href=&#34;https://jumpingrivers.github.io/meetingsR/r-user-groups.html&#34;&gt;here&lt;/a&gt;. Join the local user group to meet, discuss and learn from other R enthusiasts and experts.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/user-group.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data-helpers&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data Helpers&lt;/h3&gt;
&lt;p&gt;&lt;a href=&#34;http://www.datahelpers.org/&#34;&gt;Data Helpers&lt;/a&gt; is a list of data analysts, scientists and engineers willing to offer guidance put together by &lt;a href=&#34;https://twitter.com/AngeBassa/&#34;&gt;Angela Bassa&lt;/a&gt;. Visit the website to learn more about how you can approach for help and guidance.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;internal&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Internal&lt;/h2&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/gwpFCPDa8Tw&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;p&gt;In this section, we will look at the following functions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;help.start()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;help()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;?&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;??&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;help.search()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;demo()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;example()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;library()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;vignette()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;browseVignettes()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;help.start&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;help.start&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;help.start()&lt;/code&gt; function opens the documetation page in your browser. Here you can find manuals, reference and other materials.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;help.start()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## starting httpd help server ... done&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## If nothing happens, you should open
## &amp;#39;http://127.0.0.1:19951/doc/html/index.html&amp;#39; yourself&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;help&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;help&lt;/h3&gt;
&lt;p&gt;Use &lt;code&gt;help()&lt;/code&gt; to access the documentation of functions and data sets. &lt;code&gt;?&lt;/code&gt; is a shortcut for &lt;code&gt;help()&lt;/code&gt; and returns the same information.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;help(plot)
?plot&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;help.search&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;help.search&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;help.search()&lt;/code&gt; will search all sources of documentation and return those that match the search string. &lt;code&gt;??&lt;/code&gt; is a shortcut for &lt;code&gt;help.search()&lt;/code&gt; and returns the same information.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;help.search(&amp;#39;regression&amp;#39;)
??regression&lt;/code&gt;&lt;/pre&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/Y9lcHOT7tJc&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;/div&gt;
&lt;div id=&#34;demo&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;demo&lt;/h3&gt;
&lt;p&gt;demo displays an interactive demonstration of certain topics provided in a R package. Typing &lt;code&gt;demo()&lt;/code&gt; in the console will list the demos available in all the R packages installed.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;demo()
demo(scoping)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 
##  demo(scoping)
##  ---- ~~~~~~~
## 
## &amp;gt; ## Here is a little example which shows a fundamental difference between
## &amp;gt; ## R and S.  It is a little example from Abelson and Sussman which models
## &amp;gt; ## the way in which bank accounts work.    It shows how R functions can
## &amp;gt; ## encapsulate state information.
## &amp;gt; ##
## &amp;gt; ## When invoked, &amp;quot;open.account&amp;quot; defines and returns three functions
## &amp;gt; ## in a list.  Because the variable &amp;quot;total&amp;quot; exists in the environment
## &amp;gt; ## where these functions are defined they have access to its value.
## &amp;gt; ## This is even true when &amp;quot;open.account&amp;quot; has returned.  The only way
## &amp;gt; ## to access the value of &amp;quot;total&amp;quot; is through the accessor functions
## &amp;gt; ## withdraw, deposit and balance.  Separate accounts maintain their
## &amp;gt; ## own balances.
## &amp;gt; ##
## &amp;gt; ## This is a very nifty way of creating &amp;quot;closures&amp;quot; and a little thought
## &amp;gt; ## will show you that there are many ways of using this in statistics.
## &amp;gt; 
## &amp;gt; #  Copyright (C) 1997-8 The R Core Team
## &amp;gt; 
## &amp;gt; open.account &amp;lt;- function(total) {
## + 
## +     list(
## +     deposit = function(amount) {
## +         if(amount &amp;lt;= 0)
## +         stop(&amp;quot;Deposits must be positive!\n&amp;quot;)
## +         total &amp;lt;&amp;lt;- total + amount
## +         cat(amount,&amp;quot;deposited. Your balance is&amp;quot;, total, &amp;quot;\n\n&amp;quot;)
## +     },
## +     withdraw = function(amount) {
## +         if(amount &amp;gt; total)
## +         stop(&amp;quot;You don&amp;#39;t have that much money!\n&amp;quot;)
## +         total &amp;lt;&amp;lt;- total - amount
## +         cat(amount,&amp;quot;withdrawn.  Your balance is&amp;quot;, total, &amp;quot;\n\n&amp;quot;)
## +     },
## +     balance = function() {
## +         cat(&amp;quot;Your balance is&amp;quot;, total, &amp;quot;\n\n&amp;quot;)
## +     }
## +     )
## + }
## 
## &amp;gt; ross &amp;lt;- open.account(100)
## 
## &amp;gt; robert &amp;lt;- open.account(200)
## 
## &amp;gt; ross$withdraw(30)
## 30 withdrawn.  Your balance is 70 
## 
## 
## &amp;gt; ross$balance()
## Your balance is 70 
## 
## 
## &amp;gt; robert$balance()
## Your balance is 200 
## 
## 
## &amp;gt; ross$deposit(50)
## 50 deposited. Your balance is 120 
## 
## 
## &amp;gt; ross$balance()
## Your balance is 120 
## 
## 
## &amp;gt; try(ross$withdraw(500)) # no way..
## Error in ross$withdraw(500) : You don&amp;#39;t have that much money!&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;example&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;example&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;example()&lt;/code&gt; displays examples of the specified topic if available.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;example(&amp;#39;mean&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## mean&amp;gt; x &amp;lt;- c(0:10, 50)
## 
## mean&amp;gt; xm &amp;lt;- mean(x)
## 
## mean&amp;gt; c(xm, mean(x, trim = 0.10))
## [1] 8.75 5.50&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;package-documentation&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Package Documentation&lt;/h2&gt;
&lt;div id=&#34;library&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;library&lt;/h3&gt;
&lt;p&gt;Access the documentation of a package using &lt;code&gt;help()&lt;/code&gt; inside &lt;code&gt;library()&lt;/code&gt;. The package need not be installed for accessing the documentation.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(help = &amp;#39;ggplot2&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;vignette&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;vignette&lt;/h3&gt;
&lt;p&gt;A vignette is a long form guide to a R package. You can access the vignettes available using &lt;code&gt;vignette()&lt;/code&gt;. It will display alist of vignettes available in installed packages.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vignette()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To access a specific vignette from a package, specify the name of the vignette and the package.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vignette(&amp;#39;dplyr&amp;#39;, package = &amp;#39;dplyr&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: vignette &amp;#39;dplyr&amp;#39; not found&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;browsevignettes&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;browseVignettes&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;browseVignettes()&lt;/code&gt; is another way to access the vignettes in installed packages. It will list the vignettes in each package along with links to the web page and R code.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;browseVignettes()&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;rsitesearch&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;RsiteSearch&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;RsiteSearch()&lt;/code&gt; will search for a specified topics in help pages, vignettes and task views using the search engine at this &lt;a href=&#34;http://search.r-project.org/&#34;&gt;link&lt;/a&gt; and return the result in a browser.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;RSiteSearch(&amp;#39;glm&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## A search query has been submitted to http://search.r-project.org
## The results page should open in your browser shortly&lt;/code&gt;&lt;/pre&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;//www.youtube.com/embed/FsgJbDxsuT0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Summary&lt;/h2&gt;
&lt;p&gt;To sum it up, the R community is very beginner friendly and we hope you will
find all the above resources, both internal help system and online resources
useful.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Logistic regression in R using blorr package</title>
      <link>https://blog.rsquaredacademy.com/introducing-blorr/</link>
      <pubDate>Tue, 26 Feb 2019 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/introducing-blorr/</guid>
      <description>&lt;p&gt;We are pleased to introduce the &lt;strong&gt;blorr&lt;/strong&gt; package, a set of tools for building and
validating binary logistic regression models in R, designed keeping in mind
beginner/intermediate R users. The package includes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;comprehensive regression output&lt;/li&gt;
&lt;li&gt;variable selection procedures&lt;/li&gt;
&lt;li&gt;bivariate analysis, model fit statistics and model validation tools&lt;/li&gt;
&lt;li&gt;various plots and underlying data&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you know how to build models using &lt;code&gt;glm()&lt;/code&gt;, you will find &lt;strong&gt;blorr&lt;/strong&gt; very
useful. Most of the functions use an object of class &lt;code&gt;glm&lt;/code&gt; as input. So you
just need to build a model using &lt;code&gt;glm()&lt;/code&gt; and then pass it onto the functions in
&lt;strong&gt;blorr&lt;/strong&gt;. Once you have picked up enough knowledge of R, you can move on to
more intuitive approach offered by tidymodels etc. as they offer more
flexibility, which &lt;strong&gt;blorr&lt;/strong&gt; does not.&lt;/p&gt;
&lt;div id=&#34;installation&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Installation&lt;/h2&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Install release version from CRAN
install.packages(&amp;quot;blorr&amp;quot;)

# Install development version from GitHub
# install.packages(&amp;quot;devtools&amp;quot;)
devtools::install_github(&amp;quot;rsquaredacademy/blorr&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;shiny-app&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Shiny App&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;blorr&lt;/strong&gt; includes a shiny app which can be launched using&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;blr_launch_app()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or try the live version &lt;a href=&#34;https://www.rsquaredcomputing.com/blorr/&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Read on to learn more about the features of &lt;strong&gt;blorr&lt;/strong&gt;, or see the
&lt;a href=&#34;https://blorr.rsquaredacademy.com/&#34;&gt;blorr website&lt;/a&gt; for
detailed documentation on using the package.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data&lt;/h2&gt;
&lt;p&gt;To demonstrate the features of blorr, we will use the bank marketing data set.
The data is related with direct marketing campaigns of a Portuguese banking
institution. The marketing campaigns were based on phone calls. Often, more
than one contact to the same client was required, in order to access if the
product (bank term deposit) would be (‘yes’) or not (‘no’) subscribed. It
contains a random sample (~4k) of the original data set which can be found
at &lt;a href=&#34;https://archive.ics.uci.edu/ml/datasets/bank+marketing&#34; class=&#34;uri&#34;&gt;https://archive.ics.uci.edu/ml/datasets/bank+marketing&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;bivariate-analysis&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Bivariate Analysis&lt;/h2&gt;
&lt;p&gt;Let us begin with careful bivariate analysis of each possible variable and the
outcome variable. We will use information value and likelihood ratio chi square
test for selecting the initial set of predictors for our model. The bivariate
analysis is currently avialable for categorical predictors only.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;blr_bivariate_analysis(bank_marketing, y, job, marital, education, default, 
  housing, loan, contact, poutcome)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                           Bivariate Analysis                           
## ----------------------------------------------------------------------
## Variable     Information Value    LR Chi Square    LR DF    LR p-value 
## ----------------------------------------------------------------------
##    job             0.16              75.2690        11        0.0000   
##  marital           0.05              21.6821         2        0.0000   
## education          0.05              25.0466         3        0.0000   
##  default           0.02              6.0405          1        0.0140   
##  housing           0.16              72.2813         1        0.0000   
##   loan             0.06              26.6615         1        0.0000   
##  contact           0.31             124.3834         2        0.0000   
## poutcome           0.53             270.6450         3        0.0000   
## ----------------------------------------------------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;weight-of-evidence-information-value&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Weight of Evidence &amp;amp; Information Value&lt;/h3&gt;
&lt;p&gt;Weight of evidence (WoE) is used to assess the relative risk of di¤erent
attributes for a characteristic and as a means to transform characteristics
into variables. It is also a very useful tool for binning. The WoE for any
group with average odds is zero. A negative WoE indicates that the proportion
of defaults is higher for that attribute than the overall proportion and
indicates higher risk.&lt;/p&gt;
&lt;p&gt;The information value is used to rank order variables in terms of their
predictive power. A high information value indicates a high ability to
discriminate. Values for the information value will always be positive and may
be above 3 when assessing highly predictive characteristics. Characteristics
with information values less than 0:10 are typically viewed as weak, while
values over 0.30 are sought after.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;blr_woe_iv(bank_marketing, job, y)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                                Weight of Evidence                                
## --------------------------------------------------------------------------------
##    levels        count_0s    count_1s    dist_0s    dist_1s        woe      iv   
## --------------------------------------------------------------------------------
##  management        809         130          0.20       0.25      -0.22     0.01  
##  technician        682          79          0.17       0.15       0.11     0.00  
## entrepreneur       139          12          0.03       0.02       0.40     0.00  
##  blue-collar       937          73          0.23       0.14       0.51     0.05  
##    unknown          29          2           0.01       0.00       0.61     0.00  
##    retired         152          47          0.04       0.09      -0.87     0.05  
##    admin.          433          61          0.11       0.12      -0.09     0.00  
##   services         392          39          0.10       0.08       0.26     0.01  
## self-employed      132          22          0.03       0.04      -0.26     0.00  
##  unemployed        126          15          0.03       0.03       0.08     0.00  
##   housemaid        110          12          0.03       0.02       0.17     0.00  
##    student          63          25          0.02       0.05      -1.13     0.04  
## --------------------------------------------------------------------------------
## 
##       Information Value       
## -----------------------------
## Variable    Information Value 
## -----------------------------
##   job            0.1594       
## -----------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;plot&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Plot&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;k &amp;lt;- blr_woe_iv(bank_marketing, job, y)
plot(k)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-26-introducing-blorr_files/figure-html/woeplot-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;multiple-variables&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Multiple Variables&lt;/h4&gt;
&lt;p&gt;We can generate the weight of evidence and information value for multiple
variables using &lt;code&gt;blr_woe_iv_stats()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;blr_woe_iv_stats(bank_marketing, y, job, marital, education)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Variable: job
## 
##                                Weight of Evidence                                
## --------------------------------------------------------------------------------
##    levels        count_0s    count_1s    dist_0s    dist_1s        woe      iv   
## --------------------------------------------------------------------------------
##  management        809         130          0.20       0.25      -0.22     0.01  
##  technician        682          79          0.17       0.15       0.11     0.00  
## entrepreneur       139          12          0.03       0.02       0.40     0.00  
##  blue-collar       937          73          0.23       0.14       0.51     0.05  
##    unknown          29          2           0.01       0.00       0.61     0.00  
##    retired         152          47          0.04       0.09      -0.87     0.05  
##    admin.          433          61          0.11       0.12      -0.09     0.00  
##   services         392          39          0.10       0.08       0.26     0.01  
## self-employed      132          22          0.03       0.04      -0.26     0.00  
##  unemployed        126          15          0.03       0.03       0.08     0.00  
##   housemaid        110          12          0.03       0.02       0.17     0.00  
##    student          63          25          0.02       0.05      -1.13     0.04  
## --------------------------------------------------------------------------------
## 
##       Information Value       
## -----------------------------
## Variable    Information Value 
## -----------------------------
##   job            0.1594       
## -----------------------------
## 
## 
## Variable: marital
## 
##                             Weight of Evidence                              
## ---------------------------------------------------------------------------
##  levels     count_0s    count_1s    dist_0s    dist_1s        woe      iv   
## ---------------------------------------------------------------------------
## married       2467        273          0.62       0.53       0.15     0.01  
##  single       1079        191          0.27       0.37      -0.32     0.03  
## divorced      458          53          0.11       0.10       0.11     0.00  
## ---------------------------------------------------------------------------
## 
##       Information Value       
## -----------------------------
## Variable    Information Value 
## -----------------------------
## marital          0.0464       
## -----------------------------
## 
## 
## Variable: education
## 
##                              Weight of Evidence                              
## ----------------------------------------------------------------------------
##  levels      count_0s    count_1s    dist_0s    dist_1s        woe      iv   
## ----------------------------------------------------------------------------
## tertiary       1104        195          0.28       0.38      -0.31     0.03  
## secondary      2121        231          0.53       0.45       0.17     0.01  
##  unknown       154          25          0.04       0.05      -0.23     0.00  
##  primary       625          66          0.16       0.13       0.20     0.01  
## ----------------------------------------------------------------------------
## 
##       Information Value        
## ------------------------------
## Variable     Information Value 
## ------------------------------
## education         0.0539       
## ------------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;blr_woe_iv()&lt;/code&gt; and &lt;code&gt;blr_woe_iv_stats()&lt;/code&gt; are currently avialable for categorical
predictors only.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;stepwise-selection&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Stepwise Selection&lt;/h2&gt;
&lt;p&gt;For the initial/ first cut model, all the independent variables are put into
the model. Our goal is to include a limited number of independent variables
(5-15) which are all significant, without sacrificing too much on the model
performance. The rationale behind not-including too many variables is that the
model would be over fitted and would become unstable when tested on the
validation sample. The variable reduction is done using forward or backward
or stepwise variable selection procedures. We will use &lt;code&gt;blr_step_aic_both()&lt;/code&gt;
to shortlist predictors for our model.&lt;/p&gt;
&lt;div id=&#34;model&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Model&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;model &amp;lt;- glm(y ~ ., data = bank_marketing, family = binomial(link = &amp;#39;logit&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;selection-summary&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Selection Summary&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;blr_step_aic_both(model)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Stepwise Selection Method 
## -------------------------
## 
## Candidate Terms: 
## 
## 1 . age 
## 2 . job 
## 3 . marital 
## 4 . education 
## 5 . default 
## 6 . balance 
## 7 . housing 
## 8 . loan 
## 9 . contact 
## 10 . day 
## 11 . month 
## 12 . duration 
## 13 . campaign 
## 14 . pdays 
## 15 . previous 
## 16 . poutcome 
## 
## 
## Variables Entered/Removed: 
## 
## - duration added 
## - poutcome added 
## - month added 
## - contact added 
## - housing added 
## - loan added 
## - campaign added 
## - marital added 
## - education added 
## - age added 
## 
## No more variables to be added or removed.&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 
##                      Stepwise Summary                      
## ---------------------------------------------------------
## Variable      Method       AIC         BIC       Deviance 
## ---------------------------------------------------------
## duration     addition    2674.384    2687.217    2670.384 
## poutcome     addition    2396.014    2428.097    2386.014 
## month        addition    2274.109    2376.773    2242.109 
## contact      addition    2207.884    2323.381    2171.884 
## housing      addition    2184.550    2306.463    2146.550 
## loan         addition    2171.972    2300.302    2131.972 
## campaign     addition    2164.164    2298.910    2122.164 
## marital      addition    2158.524    2306.103    2112.524 
## education    addition    2155.837    2322.666    2103.837 
## age          addition    2154.272    2327.517    2100.272 
## ---------------------------------------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;plot-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Plot&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;model %&amp;gt;%
  blr_step_aic_both() %&amp;gt;%
  plot()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Stepwise Selection Method 
## -------------------------
## 
## Candidate Terms: 
## 
## 1 . age 
## 2 . job 
## 3 . marital 
## 4 . education 
## 5 . default 
## 6 . balance 
## 7 . housing 
## 8 . loan 
## 9 . contact 
## 10 . day 
## 11 . month 
## 12 . duration 
## 13 . campaign 
## 14 . pdays 
## 15 . previous 
## 16 . poutcome 
## 
## 
## Variables Entered/Removed: 
## 
## - duration added 
## - poutcome added 
## - month added 
## - contact added 
## - housing added 
## - loan added 
## - campaign added 
## - marital added 
## - education added 
## - age added 
## 
## No more variables to be added or removed.&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-26-introducing-blorr_files/figure-html/stepwise3-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;regression-output&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Regression Output&lt;/h2&gt;
&lt;div id=&#34;model-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Model&lt;/h3&gt;
&lt;p&gt;We can use bivariate analysis and stepwise selection procedure to shortlist
predictors and build the model using the &lt;code&gt;glm()&lt;/code&gt;. The predictors used in the
below model are for illustration purposes and not necessarily shortlisted
from the bivariate analysis and variable selection procedures.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;model &amp;lt;- glm(y ~  age + duration + previous + housing + default +
             loan + poutcome + job + marital, data = bank_marketing, 
             family = binomial(link = &amp;#39;logit&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Use &lt;code&gt;blr_regress()&lt;/code&gt; to generate comprehensive regression output. It accepts
either of the following&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;model built using &lt;code&gt;glm()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;model formula and data&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;using-model&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Using Model&lt;/h4&gt;
&lt;p&gt;Let us look at the output generated from &lt;code&gt;blr_regress()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;blr_regress(model)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                              Model Overview                              
## ------------------------------------------------------------------------
## Data Set    Resp Var    Obs.    Df. Model    Df. Residual    Convergence 
## ------------------------------------------------------------------------
##   data         y        4521      4520           4498           TRUE     
## ------------------------------------------------------------------------
## 
##                     Response Summary                     
## --------------------------------------------------------
## Outcome        Frequency        Outcome        Frequency 
## --------------------------------------------------------
##    0             4004              1              517    
## --------------------------------------------------------
## 
##                      Maximum Likelihood Estimates                       
## -----------------------------------------------------------------------
##    Parameter        DF    Estimate    Std. Error    z value     Pr(&amp;gt;|z|) 
## -----------------------------------------------------------------------
##   (Intercept)       1     -5.1347        0.3728    -13.7729      0.0000 
##       age           1      0.0096        0.0067      1.4299      0.1528 
##     duration        1      0.0042         2e-04     20.7853      0.0000 
##     previous        1     -0.0357        0.0392     -0.9089      0.3634 
##    housingno        1      0.7894        0.1232      6.4098      0.0000 
##    defaultyes       1     -0.8691        0.6919     -1.2562      0.2091 
##      loanno         1      0.6598        0.1945      3.3925       7e-04 
## poutcomefailure     1      0.6085        0.2012      3.0248      0.0025 
##  poutcomeother      1      1.1354        0.2700      4.2057      0.0000 
## poutcomesuccess     1      3.2481        0.2462     13.1913      0.0000 
##  jobtechnician      1     -0.2713        0.1806     -1.5019      0.1331 
## jobentrepreneur     1     -0.7041        0.3809     -1.8486      0.0645 
##  jobblue-collar     1     -0.6132        0.1867     -3.2851      0.0010 
##    jobunknown       1     -0.9932        0.8226     -1.2073      0.2273 
##    jobretired       1      0.3197        0.2729      1.1713      0.2415 
##    jobadmin.        1      0.1120        0.2001      0.5599      0.5755 
##   jobservices       1     -0.1750        0.2265     -0.7728      0.4397 
## jobself-employed    1     -0.1408        0.3009     -0.4680      0.6398 
##  jobunemployed      1     -0.6581        0.3432     -1.9174      0.0552 
##   jobhousemaid      1     -0.7456        0.3932     -1.8963      0.0579 
##    jobstudent       1      0.1927        0.3433      0.5613      0.5746 
##  maritalsingle      1      0.5451        0.1387      3.9299       1e-04 
## maritaldivorced     1     -0.1989        0.1986     -1.0012      0.3167 
## -----------------------------------------------------------------------
## 
##  Association of Predicted Probabilities and Observed Responses  
## ---------------------------------------------------------------
## % Concordant          0.8886          Somers&amp;#39; D        0.7773   
## % Discordant          0.1114          Gamma            0.7773   
## % Tied                0.0000          Tau-a            0.1575   
## Pairs                2070068          c                0.8886   
## ---------------------------------------------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you want to examine the odds ratio estimates, set &lt;code&gt;odd_conf_limit&lt;/code&gt; to &lt;code&gt;TRUE&lt;/code&gt;.
The odds ratio estimates are not explicitly computed as we observed considerable
increase in computation time when dealing with large data sets.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;using-formula&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Using Formula&lt;/h4&gt;
&lt;p&gt;Let us use the model formula and the data set to generate the above results.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;blr_regress(y ~  age + duration + previous + housing + default +
             loan + poutcome + job + marital, data = bank_marketing)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                              Model Overview                              
## ------------------------------------------------------------------------
## Data Set    Resp Var    Obs.    Df. Model    Df. Residual    Convergence 
## ------------------------------------------------------------------------
##   data         y        4521      4520           4498           TRUE     
## ------------------------------------------------------------------------
## 
##                     Response Summary                     
## --------------------------------------------------------
## Outcome        Frequency        Outcome        Frequency 
## --------------------------------------------------------
##    0             4004              1              517    
## --------------------------------------------------------
## 
##                      Maximum Likelihood Estimates                       
## -----------------------------------------------------------------------
##    Parameter        DF    Estimate    Std. Error    z value     Pr(&amp;gt;|z|) 
## -----------------------------------------------------------------------
##   (Intercept)       1     -5.1347        0.3728    -13.7729      0.0000 
##       age           1      0.0096        0.0067      1.4299      0.1528 
##     duration        1      0.0042         2e-04     20.7853      0.0000 
##     previous        1     -0.0357        0.0392     -0.9089      0.3634 
##    housingno        1      0.7894        0.1232      6.4098      0.0000 
##    defaultyes       1     -0.8691        0.6919     -1.2562      0.2091 
##      loanno         1      0.6598        0.1945      3.3925       7e-04 
## poutcomefailure     1      0.6085        0.2012      3.0248      0.0025 
##  poutcomeother      1      1.1354        0.2700      4.2057      0.0000 
## poutcomesuccess     1      3.2481        0.2462     13.1913      0.0000 
##  jobtechnician      1     -0.2713        0.1806     -1.5019      0.1331 
## jobentrepreneur     1     -0.7041        0.3809     -1.8486      0.0645 
##  jobblue-collar     1     -0.6132        0.1867     -3.2851      0.0010 
##    jobunknown       1     -0.9932        0.8226     -1.2073      0.2273 
##    jobretired       1      0.3197        0.2729      1.1713      0.2415 
##    jobadmin.        1      0.1120        0.2001      0.5599      0.5755 
##   jobservices       1     -0.1750        0.2265     -0.7728      0.4397 
## jobself-employed    1     -0.1408        0.3009     -0.4680      0.6398 
##  jobunemployed      1     -0.6581        0.3432     -1.9174      0.0552 
##   jobhousemaid      1     -0.7456        0.3932     -1.8963      0.0579 
##    jobstudent       1      0.1927        0.3433      0.5613      0.5746 
##  maritalsingle      1      0.5451        0.1387      3.9299       1e-04 
## maritaldivorced     1     -0.1989        0.1986     -1.0012      0.3167 
## -----------------------------------------------------------------------
## 
##  Association of Predicted Probabilities and Observed Responses  
## ---------------------------------------------------------------
## % Concordant          0.8886          Somers&amp;#39; D        0.7773   
## % Discordant          0.1114          Gamma            0.7773   
## % Tied                0.0000          Tau-a            0.1575   
## Pairs                2070068          c                0.8886   
## ---------------------------------------------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;model-fit-statistics&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Model Fit Statistics&lt;/h2&gt;
&lt;p&gt;Model fit statistics are available to assess how well the model fits the data
and to compare two different models.The output includes likelihood ratio test,
AIC, BIC and a host of pseudo r-squared measures. You can read more about
pseudo r-squared at &lt;a href=&#34;https://stats.idre.ucla.edu/other/mult-pkg/faq/general/faq-what-are-pseudo-r-squareds/&#34; class=&#34;uri&#34;&gt;https://stats.idre.ucla.edu/other/mult-pkg/faq/general/faq-what-are-pseudo-r-squareds/&lt;/a&gt;.&lt;/p&gt;
&lt;div id=&#34;single-model&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Single Model&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;blr_model_fit_stats(model)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                                Model Fit Statistics                                
## ----------------------------------------------------------------------------------
## Log-Lik Intercept Only:     -1607.330    Log-Lik Full Model:             -1123.340 
## Deviance(4498):              2246.679    LR(22):                           967.980 
##                                          Prob &amp;gt; LR:                          0.000 
## MCFadden&amp;#39;s R2                   0.301    McFadden&amp;#39;s Adj R2:                  0.287 
## ML (Cox-Snell) R2:              0.193    Cragg-Uhler(Nagelkerke) R2:         0.379 
## McKelvey &amp;amp; Zavoina&amp;#39;s R2:        0.388    Efron&amp;#39;s R2:                         0.278 
## Count R2:                       0.904    Adj Count R2:                       0.157 
## BIC:                         2440.259    AIC:                             2292.679 
## ----------------------------------------------------------------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;model-validation&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Model Validation&lt;/h2&gt;
&lt;div id=&#34;hosmer-lemeshow-test&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Hosmer Lemeshow Test&lt;/h3&gt;
&lt;p&gt;Hosmer and Lemeshow developed a goodness-of-fit test for logistic regression
models with binary responses. The test involves dividing the data into
approximately ten groups of roughly equal size based on the percentiles of the
estimated probabilities. The observations are sorted in increasing order of
their estimated probability of having an even outcome. The discrepancies
between the observed and expected number of observations in these groups are
summarized by the Pearson chi-square statistic, which is then compared to
chi-square distribution with t degrees of freedom, where t is the number of
groups minus 2. Lower values of Goodness-of-fit are preferred.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;blr_test_hosmer_lemeshow(model)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##            Partition for the Hosmer &amp;amp; Lemeshow Test            
## --------------------------------------------------------------
##                         def = 1                 def = 0        
## Group    Total    Observed    Expected    Observed    Expected 
## --------------------------------------------------------------
##   1       453        2          5.14        451        447.86  
##   2       452        3          8.63        449        443.37  
##   3       452        4         11.88        448        440.12  
##   4       452        7         15.29        445        436.71  
##   5       452        14        19.39        438        432.61  
##   6       452        10        24.97        442        427.03  
##   7       452        31        33.65        421        418.35  
##   8       452        62        49.74        390        402.26  
##   9       452       128        88.10        324        363.90  
##  10       452       256        260.21       196        191.79  
## --------------------------------------------------------------
## 
##      Goodness of Fit Test      
## ------------------------------
## Chi-Square    DF    Pr &amp;gt; ChiSq 
## ------------------------------
##  52.9942      8       0.0000   
## ------------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;gains-table-lift-chart&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Gains Table &amp;amp; Lift Chart&lt;/h3&gt;
&lt;p&gt;A lift curve is a graphical representation of the % of cumulative events
captured at a specific cut-off. The cut-off can be a particular decile or a
percentile. Similar, to rank ordering procedure, the data is in descending
order of the scores and is then grouped into deciles/percentiles. The
cumulative number of observations and events are then computed for each
decile/percentile. The lift curve is the created using the cumulative %
population as the x-axis and the cumulative percentage of events as the y-axis.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;blr_gains_table(model)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    decile total   1   0       ks  tp   tn   fp  fn sensitivity specificity
## 1       1   452 256 196 44.62134 256 3808  196 261    49.51644    95.10490
## 2       2   452 128 324 61.28765 384 3484  520 133    74.27466    87.01299
## 3       3   452  62 390 63.53965 446 3094  910  71    86.26692    77.27273
## 4       4   452  31 421 59.02130 477 2673 1331  40    92.26306    66.75824
## 5       5   452  10 442 49.91657 487 2231 1773  30    94.19729    55.71928
## 6       6   452  14 438 41.68544 501 1793 2211  16    96.90522    44.78022
## 7       7   452   7 445 31.92552 508 1348 2656   9    98.25919    33.66633
## 8       8   452   4 448 21.51040 512  900 3104   5    99.03288    22.47752
## 9       9   452   3 449 10.87689 515  451 3553   2    99.61315    11.26374
## 10     10   453   2 451  0.00000 517    0 4004   0   100.00000     0.00000
##    accuracy
## 1  89.89162
## 2  85.55629
## 3  78.30126
## 4  69.67485
## 5  60.11944
## 6  50.74099
## 7  41.05286
## 8  31.23203
## 9  21.36695
## 10 11.43552&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;lift-chart&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Lift Chart&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;model %&amp;gt;%
    blr_gains_table() %&amp;gt;%
    plot()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-26-introducing-blorr_files/figure-html/val7-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;roc-curve&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;ROC Curve&lt;/h3&gt;
&lt;p&gt;ROC curve is a graphical representation of the validity of cut-offs for a
logistic regression model. The ROC curve is plotted using the sensitivity and
specificity for all possible cut-offs, i.e., all the probability scores. The
graph is plotted using sensitivity on the y-axis and 1-specificity on the
x-axis. Any point on the ROC curve represents a sensitivity X (1-specificity)
measure corresponding to a cut-off. The area under the ROC curve is used as a
validation measure for the model – the bigger the area the better is the model.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;model %&amp;gt;%
    blr_gains_table() %&amp;gt;%
  blr_roc_curve()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-26-introducing-blorr_files/figure-html/val2-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;ks-chart&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;KS Chart&lt;/h3&gt;
&lt;p&gt;The KS Statistic is again a measure of model efficiency, and it is created
using the lift curve. The lift curve is created to plot % events. If we also
plot % non-events on the same scale, with % population at x-axis, we would get
another curve. The maximum distance between the lift curve for events and that
for non-events is termed as KS. For a good model, KS should be big (&amp;gt;=0.3) and
should occur as close to the event rate as possible.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;model %&amp;gt;%
    blr_gains_table() %&amp;gt;%
  blr_ks_chart()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-26-introducing-blorr_files/figure-html/val3-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;decile-lift-chart&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Decile Lift Chart&lt;/h3&gt;
&lt;p&gt;The decile lift chart displays the lift over the global mean event rate for
each decile. For a model with good discriminatory power, the top deciles should
have an event/conversion rate greater than the global mean.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;model %&amp;gt;%
  blr_gains_table() %&amp;gt;%
  blr_decile_lift_chart()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-26-introducing-blorr_files/figure-html/val9-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;capture-rate-by-decile&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Capture Rate by Decile&lt;/h3&gt;
&lt;p&gt;If the model has good discriminatory power, the top deciles should have a higher
event/conversion rate compared to the bottom deciles.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;model %&amp;gt;%
  blr_gains_table() %&amp;gt;%
  blr_decile_capture_rate()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-26-introducing-blorr_files/figure-html/val8-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;lorenz-curve&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Lorenz Curve&lt;/h3&gt;
&lt;p&gt;The Lorenz curve is a simple graphic device which illustrates the degree of
inequality in the distribution of thevariable concerned. It is a visual
representation of inequality used to measure the discriminatory power of the
predictive model.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;blr_lorenz_curve(model)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-26-introducing-blorr_files/figure-html/val4-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;residual-influence-diagnostics&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Residual &amp;amp; Influence Diagnostics&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;blorr&lt;/strong&gt; can generate 22 plots for residual, influence and leverage diagnostics.&lt;/p&gt;
&lt;div id=&#34;influence-diagnostics&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Influence Diagnostics&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;blr_plot_diag_influence(model)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-26-introducing-blorr_files/figure-html/infl-1.png&#34; width=&#34;768&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;leverage-diagnostics&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Leverage Diagnostics&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;blr_plot_diag_leverage(model)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-26-introducing-blorr_files/figure-html/lev-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;fitted-values-diagnostics&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Fitted Values Diagnostics&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;blr_plot_diag_fit(model)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-26-introducing-blorr_files/figure-html/fit-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;learning-more&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Learning More&lt;/h2&gt;
&lt;p&gt;The &lt;a href=&#34;https://blorr.rsquaredacademy.com/index.html&#34;&gt;blorr website&lt;/a&gt; includes
comprehensive documentation on using the package, including the following
&lt;a href=&#34;https://blorr.rsquaredacademy.com/articles/introduction.html&#34;&gt;article&lt;/a&gt;
that covers various aspects of using blorr.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;feedback&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Feedback&lt;/h2&gt;
&lt;p&gt;All feedback is welcome. Issues (bugs and feature
requests) can be posted to &lt;a href=&#34;https://github.com/rsquaredacademy/blorr/issues&#34;&gt;github tracker&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Descriptive/Summary Statistics with descriptr</title>
      <link>https://blog.rsquaredacademy.com/introducing-descriptr/</link>
      <pubDate>Wed, 20 Feb 2019 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/introducing-descriptr/</guid>
      <description>&lt;p&gt;We are pleased to introduce the &lt;strong&gt;descriptr&lt;/strong&gt; package, a set of tools for
generating descriptive/summary statistics.&lt;/p&gt;
&lt;div id=&#34;installation&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Installation&lt;/h2&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Install release version from CRAN
install.packages(&amp;quot;descriptr&amp;quot;)

# Install development version from GitHub
# install.packages(&amp;quot;devtools&amp;quot;)
devtools::install_github(&amp;quot;rsquaredacademy/descriptr&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;shiny-app&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Shiny App&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;descriptr&lt;/strong&gt; includes a shiny app which can be launched using&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_launch_shiny_app()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or try the live version &lt;a href=&#34;https://www.rsquaredcomputing.com/descriptr/&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Read on to learn more about the features of &lt;strong&gt;descriptr&lt;/strong&gt;, or see the
&lt;a href=&#34;https://descriptr.rsquaredacademy.com/&#34;&gt;descriptr website&lt;/a&gt; for
detailed documentation on using the package.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data&lt;/h2&gt;
&lt;p&gt;We have modified the &lt;code&gt;mtcars&lt;/code&gt; data to create a new data set &lt;code&gt;mtcarz&lt;/code&gt;. The only
difference between the two data sets is related to the variable types.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str(mtcarz)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## &amp;#39;data.frame&amp;#39;:    32 obs. of  11 variables:
##  $ mpg : num  21 21 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 ...
##  $ cyl : Factor w/ 3 levels &amp;quot;4&amp;quot;,&amp;quot;6&amp;quot;,&amp;quot;8&amp;quot;: 2 2 1 2 3 2 3 1 1 2 ...
##  $ disp: num  160 160 108 258 360 ...
##  $ hp  : num  110 110 93 110 175 105 245 62 95 123 ...
##  $ drat: num  3.9 3.9 3.85 3.08 3.15 2.76 3.21 3.69 3.92 3.92 ...
##  $ wt  : num  2.62 2.88 2.32 3.21 3.44 ...
##  $ qsec: num  16.5 17 18.6 19.4 17 ...
##  $ vs  : Factor w/ 2 levels &amp;quot;0&amp;quot;,&amp;quot;1&amp;quot;: 1 1 2 2 1 2 1 2 2 2 ...
##  $ am  : Factor w/ 2 levels &amp;quot;0&amp;quot;,&amp;quot;1&amp;quot;: 2 2 2 1 1 1 1 1 1 1 ...
##  $ gear: Factor w/ 3 levels &amp;quot;3&amp;quot;,&amp;quot;4&amp;quot;,&amp;quot;5&amp;quot;: 2 2 2 1 1 1 1 2 2 2 ...
##  $ carb: Factor w/ 6 levels &amp;quot;1&amp;quot;,&amp;quot;2&amp;quot;,&amp;quot;3&amp;quot;,&amp;quot;4&amp;quot;,..: 4 4 1 1 2 1 4 2 2 4 ...&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;data-screening&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data Screening&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;ds_screener()&lt;/code&gt; function will screen a data set and return the following:
- Column/Variable Names
- Data Type
- Levels (in case of categorical data)
- Number of missing observations
- % of missing observations&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_screener(mtcarz)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## -----------------------------------------------------------------------
## |  Column Name  |  Data Type  |  Levels   |  Missing  |  Missing (%)  |
## -----------------------------------------------------------------------
## |      mpg      |   numeric   |    NA     |     0     |       0       |
## |      cyl      |   factor    |   4 6 8   |     0     |       0       |
## |     disp      |   numeric   |    NA     |     0     |       0       |
## |      hp       |   numeric   |    NA     |     0     |       0       |
## |     drat      |   numeric   |    NA     |     0     |       0       |
## |      wt       |   numeric   |    NA     |     0     |       0       |
## |     qsec      |   numeric   |    NA     |     0     |       0       |
## |      vs       |   factor    |    0 1    |     0     |       0       |
## |      am       |   factor    |    0 1    |     0     |       0       |
## |     gear      |   factor    |   3 4 5   |     0     |       0       |
## |     carb      |   factor    |1 2 3 4 6 8|     0     |       0       |
## -----------------------------------------------------------------------
## 
##  Overall Missing Values           0 
##  Percentage of Missing Values     0 %
##  Rows with Missing Values         0 
##  Columns With Missing Values      0&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;continuous-data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Continuous Data&lt;/h2&gt;
&lt;div id=&#34;summary-statistics&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary Statistics&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;ds_summary_stats()&lt;/code&gt; function returns a comprehensive set of statistics
including measures of location, variation, symmetry and extreme observations.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_summary_stats(mtcarz, mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## --------------------------------- Variable: mpg --------------------------------
## 
##                         Univariate Analysis                          
## 
##  N                       32.00      Variance                36.32 
##  Missing                  0.00      Std Deviation            6.03 
##  Mean                    20.09      Range                   23.50 
##  Median                  19.20      Interquartile Range      7.38 
##  Mode                    10.40      Uncorrected SS       14042.31 
##  Trimmed Mean            19.95      Corrected SS          1126.05 
##  Skewness                 0.67      Coeff Variation         30.00 
##  Kurtosis                -0.02      Std Error Mean           1.07 
## 
##                               Quantiles                               
## 
##               Quantile                            Value                
## 
##              Max                                  33.90                
##              99%                                  33.44                
##              95%                                  31.30                
##              90%                                  30.09                
##              Q3                                   22.80                
##              Median                               19.20                
##              Q1                                   15.43                
##              10%                                  14.34                
##              5%                                   12.00                
##              1%                                   10.40                
##              Min                                  10.40                
## 
##                             Extreme Values                            
## 
##                 Low                                High                
## 
##   Obs                        Value       Obs                        Value 
##   15                         10.4        20                         33.9  
##   16                         10.4        18                         32.4  
##   24                         13.3        19                         30.4  
##    7                         14.3        28                         30.4  
##   17                         14.7        26                         27.3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can pass multiple variables as shown below:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_summary_stats(mtcarz, mpg, disp)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## --------------------------------- Variable: mpg --------------------------------
## 
##                         Univariate Analysis                          
## 
##  N                       32.00      Variance                36.32 
##  Missing                  0.00      Std Deviation            6.03 
##  Mean                    20.09      Range                   23.50 
##  Median                  19.20      Interquartile Range      7.38 
##  Mode                    10.40      Uncorrected SS       14042.31 
##  Trimmed Mean            19.95      Corrected SS          1126.05 
##  Skewness                 0.67      Coeff Variation         30.00 
##  Kurtosis                -0.02      Std Error Mean           1.07 
## 
##                               Quantiles                               
## 
##               Quantile                            Value                
## 
##              Max                                  33.90                
##              99%                                  33.44                
##              95%                                  31.30                
##              90%                                  30.09                
##              Q3                                   22.80                
##              Median                               19.20                
##              Q1                                   15.43                
##              10%                                  14.34                
##              5%                                   12.00                
##              1%                                   10.40                
##              Min                                  10.40                
## 
##                             Extreme Values                            
## 
##                 Low                                High                
## 
##   Obs                        Value       Obs                        Value 
##   15                         10.4        20                         33.9  
##   16                         10.4        18                         32.4  
##   24                         13.3        19                         30.4  
##    7                         14.3        28                         30.4  
##   17                         14.7        26                         27.3  
## 
## 
## 
## -------------------------------- Variable: disp --------------------------------
## 
##                           Univariate Analysis                            
## 
##  N                         32.00      Variance               15360.80 
##  Missing                    0.00      Std Deviation            123.94 
##  Mean                     230.72      Range                    400.90 
##  Median                   196.30      Interquartile Range      205.18 
##  Mode                     275.80      Uncorrected SS       2179627.47 
##  Trimmed Mean             228.00      Corrected SS          476184.79 
##  Skewness                   0.42      Coeff Variation           53.72 
##  Kurtosis                  -1.07      Std Error Mean            21.91 
## 
##                                 Quantiles                                 
## 
##                Quantile                              Value                 
## 
##               Max                                    472.00                
##               99%                                    468.28                
##               95%                                    449.00                
##               90%                                    396.00                
##               Q3                                     326.00                
##               Median                                 196.30                
##               Q1                                     120.83                
##               10%                                    80.61                 
##               5%                                     77.35                 
##               1%                                     72.53                 
##               Min                                    71.10                 
## 
##                               Extreme Values                              
## 
##                  Low                                  High                 
## 
##   Obs                          Value       Obs                          Value 
##   20                           71.1        15                            472  
##   19                           75.7        16                            460  
##   18                           78.7        17                            440  
##   26                            79         25                            400  
##   28                           95.1         5                            360&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you do not specify any variables, it will detect all the continuous
variables in the data set and return summary statistics for each of them.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;frequency-distribution&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Frequency Distribution&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;ds_freq_table()&lt;/code&gt; function creates frequency tables for continuous variables.
The default number of intervals is 5.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_freq_table(mtcarz, mpg, 4)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                                 Variable: mpg                                 
## |---------------------------------------------------------------------------|
## |      Bins       | Frequency | Cum Frequency |   Percent    | Cum Percent  |
## |---------------------------------------------------------------------------|
## |  10.4  -  16.3  |    10     |      10       |    31.25     |    31.25     |
## |---------------------------------------------------------------------------|
## |  16.3  -  22.1  |    13     |      23       |    40.62     |    71.88     |
## |---------------------------------------------------------------------------|
## |  22.1  -   28   |     5     |      28       |    15.62     |     87.5     |
## |---------------------------------------------------------------------------|
## |   28   -  33.9  |     4     |      32       |     12.5     |     100      |
## |---------------------------------------------------------------------------|
## |      Total      |    32     |       -       |    100.00    |      -       |
## |---------------------------------------------------------------------------|&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;histogram&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Histogram&lt;/h4&gt;
&lt;p&gt;A &lt;code&gt;plot()&lt;/code&gt; method has been defined which will generate a histogram.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;k &amp;lt;- ds_freq_table(mtcarz, mpg, 4)
plot(k)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-19-introducing-descriptr_files/figure-html/fcont_hist-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;auto-summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Auto Summary&lt;/h3&gt;
&lt;p&gt;If you want to view summary statistics and frequency tables of all or subset of
variables in a data set, use &lt;code&gt;ds_auto_summary()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_auto_summary_stats(mtcarz, disp, mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## -------------------------------- Variable: disp --------------------------------
## 
## ------------------------------ Summary Statistics ------------------------------
## 
## -------------------------------- Variable: disp --------------------------------
## 
##                           Univariate Analysis                            
## 
##  N                         32.00      Variance               15360.80 
##  Missing                    0.00      Std Deviation            123.94 
##  Mean                     230.72      Range                    400.90 
##  Median                   196.30      Interquartile Range      205.18 
##  Mode                     275.80      Uncorrected SS       2179627.47 
##  Trimmed Mean             228.00      Corrected SS          476184.79 
##  Skewness                   0.42      Coeff Variation           53.72 
##  Kurtosis                  -1.07      Std Error Mean            21.91 
## 
##                                 Quantiles                                 
## 
##                Quantile                              Value                 
## 
##               Max                                    472.00                
##               99%                                    468.28                
##               95%                                    449.00                
##               90%                                    396.00                
##               Q3                                     326.00                
##               Median                                 196.30                
##               Q1                                     120.83                
##               10%                                    80.61                 
##               5%                                     77.35                 
##               1%                                     72.53                 
##               Min                                    71.10                 
## 
##                               Extreme Values                              
## 
##                  Low                                  High                 
## 
##   Obs                          Value       Obs                          Value 
##   20                           71.1        15                            472  
##   19                           75.7        16                            460  
##   18                           78.7        17                            440  
##   26                            79         25                            400  
##   28                           95.1         5                            360  
## 
## 
## 
## NULL
## 
## 
## ---------------------------- Frequency Distribution ----------------------------
## 
##                                Variable: disp                                 
## |---------------------------------------------------------------------------|
## |      Bins       | Frequency | Cum Frequency |   Percent    | Cum Percent  |
## |---------------------------------------------------------------------------|
## |  71.1  - 151.3  |    12     |      12       |     37.5     |     37.5     |
## |---------------------------------------------------------------------------|
## | 151.3  - 231.5  |     5     |      17       |    15.62     |    53.12     |
## |---------------------------------------------------------------------------|
## | 231.5  - 311.6  |     6     |      23       |    18.75     |    71.88     |
## |---------------------------------------------------------------------------|
## | 311.6  - 391.8  |     5     |      28       |    15.62     |     87.5     |
## |---------------------------------------------------------------------------|
## | 391.8  -  472   |     4     |      32       |     12.5     |     100      |
## |---------------------------------------------------------------------------|
## |      Total      |    32     |       -       |    100.00    |      -       |
## |---------------------------------------------------------------------------|
## 
## 
## -------------------------------- Variable: mpg --------------------------------
## 
## ------------------------------ Summary Statistics ------------------------------
## 
## --------------------------------- Variable: mpg --------------------------------
## 
##                         Univariate Analysis                          
## 
##  N                       32.00      Variance                36.32 
##  Missing                  0.00      Std Deviation            6.03 
##  Mean                    20.09      Range                   23.50 
##  Median                  19.20      Interquartile Range      7.38 
##  Mode                    10.40      Uncorrected SS       14042.31 
##  Trimmed Mean            19.95      Corrected SS          1126.05 
##  Skewness                 0.67      Coeff Variation         30.00 
##  Kurtosis                -0.02      Std Error Mean           1.07 
## 
##                               Quantiles                               
## 
##               Quantile                            Value                
## 
##              Max                                  33.90                
##              99%                                  33.44                
##              95%                                  31.30                
##              90%                                  30.09                
##              Q3                                   22.80                
##              Median                               19.20                
##              Q1                                   15.43                
##              10%                                  14.34                
##              5%                                   12.00                
##              1%                                   10.40                
##              Min                                  10.40                
## 
##                             Extreme Values                            
## 
##                 Low                                High                
## 
##   Obs                        Value       Obs                        Value 
##   15                         10.4        20                         33.9  
##   16                         10.4        18                         32.4  
##   24                         13.3        19                         30.4  
##    7                         14.3        28                         30.4  
##   17                         14.7        26                         27.3  
## 
## 
## 
## NULL
## 
## 
## ---------------------------- Frequency Distribution ----------------------------
## 
##                               Variable: mpg                               
## |-----------------------------------------------------------------------|
## |    Bins     | Frequency | Cum Frequency |   Percent    | Cum Percent  |
## |-----------------------------------------------------------------------|
## | 10.4 - 15.1 |     6     |       6       |    18.75     |    18.75     |
## |-----------------------------------------------------------------------|
## | 15.1 - 19.8 |    12     |      18       |     37.5     |    56.25     |
## |-----------------------------------------------------------------------|
## | 19.8 - 24.5 |     8     |      26       |      25      |    81.25     |
## |-----------------------------------------------------------------------|
## | 24.5 - 29.2 |     2     |      28       |     6.25     |     87.5     |
## |-----------------------------------------------------------------------|
## | 29.2 - 33.9 |     4     |      32       |     12.5     |     100      |
## |-----------------------------------------------------------------------|
## |    Total    |    32     |       -       |    100.00    |      -       |
## |-----------------------------------------------------------------------|&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;group-summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Group Summary&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;ds_group_summary()&lt;/code&gt; function returns descriptive statistics of a continuous
variable for the different levels of a categorical variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;k &amp;lt;- ds_group_summary(mtcarz, cyl, mpg)
k&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                                        mpg by cyl                                         
## -----------------------------------------------------------------------------------------
## |     Statistic/Levels|                    4|                    6|                    8|
## -----------------------------------------------------------------------------------------
## |                  Obs|                   11|                    7|                   14|
## |              Minimum|                 21.4|                 17.8|                 10.4|
## |              Maximum|                 33.9|                 21.4|                 19.2|
## |                 Mean|                26.66|                19.74|                 15.1|
## |               Median|                   26|                 19.7|                 15.2|
## |                 Mode|                 22.8|                   21|                 10.4|
## |       Std. Deviation|                 4.51|                 1.45|                 2.56|
## |             Variance|                20.34|                 2.11|                 6.55|
## |             Skewness|                 0.35|                -0.26|                -0.46|
## |             Kurtosis|                -1.43|                -1.83|                 0.33|
## |       Uncorrected SS|              8023.83|              2741.14|              3277.34|
## |         Corrected SS|               203.39|                12.68|                 85.2|
## |      Coeff Variation|                16.91|                 7.36|                16.95|
## |      Std. Error Mean|                 1.36|                 0.55|                 0.68|
## |                Range|                 12.5|                  3.6|                  8.8|
## |  Interquartile Range|                  7.6|                 2.35|                 1.85|
## -----------------------------------------------------------------------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;ds_group_summary()&lt;/code&gt; returns a tibble which can be used for further analysis.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;k$tidy_stats&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 x 15
##   cyl   length   min   max  mean median  mode    sd variance skewness kurtosis
## * &amp;lt;fct&amp;gt;  &amp;lt;int&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt;
## 1 4         11  21.4  33.9  26.7   26    22.8  4.51    20.3     0.348   -1.43 
## 2 6          7  17.8  21.4  19.7   19.7  21    1.45     2.11   -0.259   -1.83 
## 3 8         14  10.4  19.2  15.1   15.2  10.4  2.56     6.55   -0.456    0.330
## # ... with 4 more variables: coeff_var &amp;lt;dbl&amp;gt;, std_error &amp;lt;dbl&amp;gt;, range &amp;lt;dbl&amp;gt;,
## #   iqr &amp;lt;dbl&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;box-plot&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Box Plot&lt;/h4&gt;
&lt;p&gt;A &lt;code&gt;plot()&lt;/code&gt; method has been defined for comparing distributions.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;k &amp;lt;- ds_group_summary(mtcarz, cyl, mpg)
plot(k)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-19-introducing-descriptr_files/figure-html/gsum_boxplot-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;multiple-variables&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Multiple Variables&lt;/h3&gt;
&lt;p&gt;If you want grouped summary statistics for multiple variables in a data set, use
&lt;code&gt;ds_auto_group_summary()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_auto_group_summary(mtcarz, cyl, gear, mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                                        mpg by cyl                                         
## -----------------------------------------------------------------------------------------
## |     Statistic/Levels|                    4|                    6|                    8|
## -----------------------------------------------------------------------------------------
## |                  Obs|                   11|                    7|                   14|
## |              Minimum|                 21.4|                 17.8|                 10.4|
## |              Maximum|                 33.9|                 21.4|                 19.2|
## |                 Mean|                26.66|                19.74|                 15.1|
## |               Median|                   26|                 19.7|                 15.2|
## |                 Mode|                 22.8|                   21|                 10.4|
## |       Std. Deviation|                 4.51|                 1.45|                 2.56|
## |             Variance|                20.34|                 2.11|                 6.55|
## |             Skewness|                 0.35|                -0.26|                -0.46|
## |             Kurtosis|                -1.43|                -1.83|                 0.33|
## |       Uncorrected SS|              8023.83|              2741.14|              3277.34|
## |         Corrected SS|               203.39|                12.68|                 85.2|
## |      Coeff Variation|                16.91|                 7.36|                16.95|
## |      Std. Error Mean|                 1.36|                 0.55|                 0.68|
## |                Range|                 12.5|                  3.6|                  8.8|
## |  Interquartile Range|                  7.6|                 2.35|                 1.85|
## -----------------------------------------------------------------------------------------
## 
## 
## 
##                                        mpg by gear                                        
## -----------------------------------------------------------------------------------------
## |     Statistic/Levels|                    3|                    4|                    5|
## -----------------------------------------------------------------------------------------
## |                  Obs|                   15|                   12|                    5|
## |              Minimum|                 10.4|                 17.8|                   15|
## |              Maximum|                 21.5|                 33.9|                 30.4|
## |                 Mean|                16.11|                24.53|                21.38|
## |               Median|                 15.5|                 22.8|                 19.7|
## |                 Mode|                 10.4|                   21|                   15|
## |       Std. Deviation|                 3.37|                 5.28|                 6.66|
## |             Variance|                11.37|                27.84|                44.34|
## |             Skewness|                -0.09|                  0.7|                 0.56|
## |             Kurtosis|                -0.38|                -0.77|                -1.83|
## |       Uncorrected SS|              4050.52|               7528.9|              2462.89|
## |         Corrected SS|               159.15|               306.29|               177.37|
## |      Coeff Variation|                20.93|                21.51|                31.15|
## |      Std. Error Mean|                 0.87|                 1.52|                 2.98|
## |                Range|                 11.1|                 16.1|                 15.4|
## |  Interquartile Range|                  3.9|                 7.08|                 10.2|
## -----------------------------------------------------------------------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;multiple-variable-statistics&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Multiple Variable Statistics&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;ds_tidy_stats()&lt;/code&gt; function returns summary/descriptive statistics for
variables in a data frame/tibble.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_tidy_stats(mtcarz, mpg, disp, hp)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 x 16
##   vars    min   max  mean t_mean median  mode range variance  stdev  skew
## * &amp;lt;chr&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;
## 1 disp   71.1 472   231.   228    196.  276.  401.   15361.  124.   0.420
## 2 hp     52   335   147.   144.   123   110   283     4701.   68.6  0.799
## 3 mpg    10.4  33.9  20.1   20.0   19.2  10.4  23.5     36.3   6.03 0.672
## # ... with 5 more variables: kurtosis &amp;lt;dbl&amp;gt;, coeff_var &amp;lt;dbl&amp;gt;, q1 &amp;lt;dbl&amp;gt;,
## #   q3 &amp;lt;dbl&amp;gt;, iqrange &amp;lt;dbl&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;measures&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Measures&lt;/h3&gt;
&lt;p&gt;If you want to view the measure of location, variation, symmetry, percentiles
and extreme observations as tibbles, use the below functions. All of them,
except for &lt;code&gt;ds_extreme_obs()&lt;/code&gt; will work with single or multiple variables. If
you do not specify the variables, they will return the results for all the
continuous variables in the data set.&lt;/p&gt;
&lt;div id=&#34;measures-of-location&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Measures of Location&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_measures_location(mtcarz)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 6 x 5
##   var     mean trim_mean median   mode
##   &amp;lt;chr&amp;gt;  &amp;lt;dbl&amp;gt;     &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;
## 1 disp  231.      228    196.   276.  
## 2 drat    3.60      3.58   3.70   3.07
## 3 hp    147.      144.   123    110   
## 4 mpg    20.1      20.0   19.2   10.4 
## 5 qsec   17.8      17.8   17.7   17.0 
## 6 wt      3.22      3.20   3.32   3.44&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;measures-of-variation&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Measures of Variation&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_measures_variation(mtcarz)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 6 x 7
##   var    range     iqr  variance      sd coeff_var std_error
##   &amp;lt;chr&amp;gt;  &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;     &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;     &amp;lt;dbl&amp;gt;     &amp;lt;dbl&amp;gt;
## 1 disp  401.   205.    15361.    124.         53.7   21.9   
## 2 drat    2.17   0.840     0.286   0.535      14.9    0.0945
## 3 hp    283     83.5    4701.     68.6        46.7   12.1   
## 4 mpg    23.5    7.38     36.3     6.03       30.0    1.07  
## 5 qsec    8.40   2.01      3.19    1.79       10.0    0.316 
## 6 wt      3.91   1.03      0.957   0.978      30.4    0.173&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;measures-of-symmetry&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Measures of Symmetry&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_measures_symmetry(mtcarz)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 6 x 3
##   var   skewness kurtosis
##   &amp;lt;chr&amp;gt;    &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt;
## 1 disp     0.420  -1.07  
## 2 drat     0.293  -0.450 
## 3 hp       0.799   0.275 
## 4 mpg      0.672  -0.0220
## 5 qsec     0.406   0.865 
## 6 wt       0.466   0.417&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;percentiles&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Percentiles&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_percentiles(mtcarz)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 6 x 12
##   var     min  per1  per5 per10     q1 median     q3  per95  per90  per99    max
##   &amp;lt;chr&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;
## 1 disp  71.1  72.5  77.4  80.6  121.   196.   326    449    396.   468.   472   
## 2 drat   2.76  2.76  2.85  3.01   3.08   3.70   3.92   4.31   4.21   4.78   4.93
## 3 hp    52    55.1  63.6  66     96.5  123    180    254.   244.   313.   335   
## 4 mpg   10.4  10.4  12.0  14.3   15.4   19.2   22.8   31.3   30.1   33.4   33.9 
## 5 qsec  14.5  14.5  15.0  15.5   16.9   17.7   18.9   20.1   20.0   22.1   22.9 
## 6 wt     1.51  1.54  1.74  1.96   2.58   3.32   3.61   5.29   4.05   5.40   5.42&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;categorical-data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Categorical Data&lt;/h2&gt;
&lt;div id=&#34;cross-tabulation&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Cross Tabulation&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;ds_cross_table()&lt;/code&gt; function creates two way tables of categorical variables.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_cross_table(mtcarz, cyl, gear)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##     Cell Contents
##  |---------------|
##  |     Frequency |
##  |       Percent |
##  |       Row Pct |
##  |       Col Pct |
##  |---------------|
## 
##  Total Observations:  32 
## 
## ----------------------------------------------------------------------------
## |              |                           gear                            |
## ----------------------------------------------------------------------------
## |          cyl |            3 |            4 |            5 |    Row Total |
## ----------------------------------------------------------------------------
## |            4 |            1 |            8 |            2 |           11 |
## |              |        0.031 |         0.25 |        0.062 |              |
## |              |         0.09 |         0.73 |         0.18 |         0.34 |
## |              |         0.07 |         0.67 |          0.4 |              |
## ----------------------------------------------------------------------------
## |            6 |            2 |            4 |            1 |            7 |
## |              |        0.062 |        0.125 |        0.031 |              |
## |              |         0.29 |         0.57 |         0.14 |         0.22 |
## |              |         0.13 |         0.33 |          0.2 |              |
## ----------------------------------------------------------------------------
## |            8 |           12 |            0 |            2 |           14 |
## |              |        0.375 |            0 |        0.062 |              |
## |              |         0.86 |            0 |         0.14 |         0.44 |
## |              |          0.8 |            0 |          0.4 |              |
## ----------------------------------------------------------------------------
## | Column Total |           15 |           12 |            5 |           32 |
## |              |        0.468 |        0.375 |        0.155 |              |
## ----------------------------------------------------------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you want the above result as a tibble, use &lt;code&gt;ds_twoway_table()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_twoway_table(mtcarz, cyl, gear)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Joining, by = c(&amp;quot;cyl&amp;quot;, &amp;quot;gear&amp;quot;, &amp;quot;count&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 8 x 6
##   cyl   gear  count percent row_percent col_percent
##   &amp;lt;fct&amp;gt; &amp;lt;fct&amp;gt; &amp;lt;int&amp;gt;   &amp;lt;dbl&amp;gt;       &amp;lt;dbl&amp;gt;       &amp;lt;dbl&amp;gt;
## 1 4     3         1  0.0312      0.0909      0.0667
## 2 4     4         8  0.25        0.727       0.667 
## 3 4     5         2  0.0625      0.182       0.4   
## 4 6     3         2  0.0625      0.286       0.133 
## 5 6     4         4  0.125       0.571       0.333 
## 6 6     5         1  0.0312      0.143       0.2   
## 7 8     3        12  0.375       0.857       0.8   
## 8 8     5         2  0.0625      0.143       0.4&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A &lt;code&gt;plot()&lt;/code&gt; method has been defined which will generate:&lt;/p&gt;
&lt;div id=&#34;grouped-bar-plots&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Grouped Bar Plots&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;k &amp;lt;- ds_cross_table(mtcarz, cyl, gear)
plot(k)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-19-introducing-descriptr_files/figure-html/cross_group-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;stacked-bar-plots&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Stacked Bar Plots&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;k &amp;lt;- ds_cross_table(mtcarz, cyl, gear)
plot(k, stacked = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-19-introducing-descriptr_files/figure-html/cross_stack-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;proportional-bar-plots&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Proportional Bar Plots&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;k &amp;lt;- ds_cross_table(mtcarz, cyl, gear)
plot(k, proportional = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-19-introducing-descriptr_files/figure-html/cross_prop-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;frequency-table&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Frequency Table&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;ds_freq_table()&lt;/code&gt; function creates frequency tables.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_freq_table(mtcarz, cyl)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                              Variable: cyl                              
## -----------------------------------------------------------------------
## Levels     Frequency    Cum Frequency       Percent        Cum Percent  
## -----------------------------------------------------------------------
##    4          11             11              34.38            34.38    
## -----------------------------------------------------------------------
##    6           7             18              21.88            56.25    
## -----------------------------------------------------------------------
##    8          14             32              43.75             100     
## -----------------------------------------------------------------------
##  Total        32              -             100.00              -      
## -----------------------------------------------------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A &lt;code&gt;plot()&lt;/code&gt; method has been defined which will create a bar plot.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;k &amp;lt;- ds_freq_table(mtcarz, cyl)
plot(k)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-19-introducing-descriptr_files/figure-html/ftable_bar-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;multiple-one-way-tables&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Multiple One Way Tables&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;ds_auto_freq_table()&lt;/code&gt; function creates multiple one way tables by creating a
frequency table for each categorical variable in a data set. You can also
specify a subset of variables if you do not want all the variables in the data
set to be used.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_auto_freq_table(mtcarz)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                              Variable: cyl                              
## -----------------------------------------------------------------------
## Levels     Frequency    Cum Frequency       Percent        Cum Percent  
## -----------------------------------------------------------------------
##    4          11             11              34.38            34.38    
## -----------------------------------------------------------------------
##    6           7             18              21.88            56.25    
## -----------------------------------------------------------------------
##    8          14             32              43.75             100     
## -----------------------------------------------------------------------
##  Total        32              -             100.00              -      
## -----------------------------------------------------------------------
## 
##                              Variable: vs                               
## -----------------------------------------------------------------------
## Levels     Frequency    Cum Frequency       Percent        Cum Percent  
## -----------------------------------------------------------------------
##    0          18             18              56.25            56.25    
## -----------------------------------------------------------------------
##    1          14             32              43.75             100     
## -----------------------------------------------------------------------
##  Total        32              -             100.00              -      
## -----------------------------------------------------------------------
## 
##                              Variable: am                               
## -----------------------------------------------------------------------
## Levels     Frequency    Cum Frequency       Percent        Cum Percent  
## -----------------------------------------------------------------------
##    0          19             19              59.38            59.38    
## -----------------------------------------------------------------------
##    1          13             32              40.62             100     
## -----------------------------------------------------------------------
##  Total        32              -             100.00              -      
## -----------------------------------------------------------------------
## 
##                             Variable: gear                              
## -----------------------------------------------------------------------
## Levels     Frequency    Cum Frequency       Percent        Cum Percent  
## -----------------------------------------------------------------------
##    3          15             15              46.88            46.88    
## -----------------------------------------------------------------------
##    4          12             27              37.5             84.38    
## -----------------------------------------------------------------------
##    5           5             32              15.62             100     
## -----------------------------------------------------------------------
##  Total        32              -             100.00              -      
## -----------------------------------------------------------------------
## 
##                             Variable: carb                              
## -----------------------------------------------------------------------
## Levels     Frequency    Cum Frequency       Percent        Cum Percent  
## -----------------------------------------------------------------------
##    1           7              7              21.88            21.88    
## -----------------------------------------------------------------------
##    2          10             17              31.25            53.12    
## -----------------------------------------------------------------------
##    3           3             20              9.38             62.5     
## -----------------------------------------------------------------------
##    4          10             30              31.25            93.75    
## -----------------------------------------------------------------------
##    6           1             31              3.12             96.88    
## -----------------------------------------------------------------------
##    8           1             32              3.12              100     
## -----------------------------------------------------------------------
##  Total        32              -             100.00              -      
## -----------------------------------------------------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;multiple-two-way-tables&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Multiple Two Way Tables&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;ds_auto_cross_table()&lt;/code&gt; function creates multiple two way tables by creating a
cross table for each unique pair of categorical variables in a data set. You
can also specify a subset of variables if you do not want all the variables in
the data set to be used.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_auto_cross_table(mtcarz, cyl, gear, am)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##     Cell Contents
##  |---------------|
##  |     Frequency |
##  |       Percent |
##  |       Row Pct |
##  |       Col Pct |
##  |---------------|
## 
##  Total Observations:  32 
## 
##                                 cyl vs gear                                 
## ----------------------------------------------------------------------------
## |              |                           gear                            |
## ----------------------------------------------------------------------------
## |          cyl |            3 |            4 |            5 |    Row Total |
## ----------------------------------------------------------------------------
## |            4 |            1 |            8 |            2 |           11 |
## |              |        0.031 |         0.25 |        0.062 |              |
## |              |         0.09 |         0.73 |         0.18 |         0.34 |
## |              |         0.07 |         0.67 |          0.4 |              |
## ----------------------------------------------------------------------------
## |            6 |            2 |            4 |            1 |            7 |
## |              |        0.062 |        0.125 |        0.031 |              |
## |              |         0.29 |         0.57 |         0.14 |         0.22 |
## |              |         0.13 |         0.33 |          0.2 |              |
## ----------------------------------------------------------------------------
## |            8 |           12 |            0 |            2 |           14 |
## |              |        0.375 |            0 |        0.062 |              |
## |              |         0.86 |            0 |         0.14 |         0.44 |
## |              |          0.8 |            0 |          0.4 |              |
## ----------------------------------------------------------------------------
## | Column Total |           15 |           12 |            5 |           32 |
## |              |        0.468 |        0.375 |        0.155 |              |
## ----------------------------------------------------------------------------
## 
## 
##                          cyl vs am                           
## -------------------------------------------------------------
## |              |                     am                     |
## -------------------------------------------------------------
## |          cyl |            0 |            1 |    Row Total |
## -------------------------------------------------------------
## |            4 |            3 |            8 |           11 |
## |              |        0.094 |         0.25 |              |
## |              |         0.27 |         0.73 |         0.34 |
## |              |         0.16 |         0.62 |              |
## -------------------------------------------------------------
## |            6 |            4 |            3 |            7 |
## |              |        0.125 |        0.094 |              |
## |              |         0.57 |         0.43 |         0.22 |
## |              |         0.21 |         0.23 |              |
## -------------------------------------------------------------
## |            8 |           12 |            2 |           14 |
## |              |        0.375 |        0.062 |              |
## |              |         0.86 |         0.14 |         0.44 |
## |              |         0.63 |         0.15 |              |
## -------------------------------------------------------------
## | Column Total |           19 |           13 |           32 |
## |              |        0.594 |        0.406 |              |
## -------------------------------------------------------------
## 
## 
##                          gear vs am                          
## -------------------------------------------------------------
## |              |                     am                     |
## -------------------------------------------------------------
## |         gear |            0 |            1 |    Row Total |
## -------------------------------------------------------------
## |            3 |           15 |            0 |           15 |
## |              |        0.469 |            0 |              |
## |              |            1 |            0 |         0.47 |
## |              |         0.79 |            0 |              |
## -------------------------------------------------------------
## |            4 |            4 |            8 |           12 |
## |              |        0.125 |         0.25 |              |
## |              |         0.33 |         0.67 |         0.38 |
## |              |         0.21 |         0.62 |              |
## -------------------------------------------------------------
## |            5 |            0 |            5 |            5 |
## |              |            0 |        0.156 |              |
## |              |            0 |            1 |         0.16 |
## |              |            0 |         0.38 |              |
## -------------------------------------------------------------
## | Column Total |           19 |           13 |           32 |
## |              |        0.594 |        0.406 |              |
## -------------------------------------------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;visualization&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Visualization&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;descriptr&lt;/strong&gt; can help visualize multiple variables by automatically
detecting their data types.&lt;/p&gt;
&lt;div id=&#34;continuous-data-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Continuous Data&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_plot_scatter(mtcarz, mpg, disp, hp)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-19-introducing-descriptr_files/figure-html/scatter-1.png&#34; width=&#34;672&#34; /&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-19-introducing-descriptr_files/figure-html/scatter-2.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;categorical-data-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Categorical Data&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_plot_bar_stacked(mtcarz, cyl, gear, am)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-19-introducing-descriptr_files/figure-html/bar_stacked-1.png&#34; width=&#34;672&#34; /&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-19-introducing-descriptr_files/figure-html/bar_stacked-2.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;learning-more&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Learning More&lt;/h2&gt;
&lt;p&gt;The &lt;a href=&#34;https://descriptr.rsquaredacademy.com/index.html&#34;&gt;descriptr website&lt;/a&gt; includes
comprehensive documentation on using the package, including the following
articles that cover various aspects of using rfm:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href=&#34;https://descriptr.rsquaredacademy.com/articles/continuous-data.html&#34;&gt;Continuous Data&lt;/a&gt; - for
summarizing continuous data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href=&#34;https://descriptr.rsquaredacademy.com/articles/categorical-data.html&#34;&gt;Categorical Data&lt;/a&gt; - for
summarizing categorical data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href=&#34;https://descriptr.rsquaredacademy.com/articles/visualization.html&#34;&gt;Visualization&lt;/a&gt; - for
generating different types of plots.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;feedback&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Feedback&lt;/h2&gt;
&lt;p&gt;All feedback is welcome. Issues (bugs and feature
requests) can be posted to &lt;a href=&#34;https://github.com/rsquaredacademy/descriptr/issues&#34;&gt;github tracker&lt;/a&gt;.
For help with code or other related questions, feel free to reach me &lt;a href=&#34;mailto:hebbali.aravind@gmail.com&#34; class=&#34;email&#34;&gt;hebbali.aravind@gmail.com&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Descriptive/Summary Statistics with descriptr</title>
      <link>https://blog.rsquaredacademy.com/introducing-descriptr/</link>
      <pubDate>Wed, 20 Feb 2019 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/introducing-descriptr/</guid>
      <description>&lt;p&gt;We are pleased to introduce the &lt;strong&gt;descriptr&lt;/strong&gt; package, a set of tools for
generating descriptive/summary statistics.&lt;/p&gt;
&lt;div id=&#34;installation&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Installation&lt;/h2&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Install release version from CRAN
install.packages(&amp;quot;descriptr&amp;quot;)

# Install development version from GitHub
# install.packages(&amp;quot;devtools&amp;quot;)
devtools::install_github(&amp;quot;rsquaredacademy/descriptr&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;shiny-app&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Shiny App&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;descriptr&lt;/strong&gt; includes a shiny app which can be launched using&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_launch_shiny_app()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or try the live version &lt;a href=&#34;https://www.rsquaredcomputing.com/descriptr/&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Read on to learn more about the features of &lt;strong&gt;descriptr&lt;/strong&gt;, or see the
&lt;a href=&#34;https://descriptr.rsquaredacademy.com/&#34;&gt;descriptr website&lt;/a&gt; for
detailed documentation on using the package.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data&lt;/h2&gt;
&lt;p&gt;We have modified the &lt;code&gt;mtcars&lt;/code&gt; data to create a new data set &lt;code&gt;mtcarz&lt;/code&gt;. The only
difference between the two data sets is related to the variable types.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str(mtcarz)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## &amp;#39;data.frame&amp;#39;:    32 obs. of  11 variables:
##  $ mpg : num  21 21 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 ...
##  $ cyl : Factor w/ 3 levels &amp;quot;4&amp;quot;,&amp;quot;6&amp;quot;,&amp;quot;8&amp;quot;: 2 2 1 2 3 2 3 1 1 2 ...
##  $ disp: num  160 160 108 258 360 ...
##  $ hp  : num  110 110 93 110 175 105 245 62 95 123 ...
##  $ drat: num  3.9 3.9 3.85 3.08 3.15 2.76 3.21 3.69 3.92 3.92 ...
##  $ wt  : num  2.62 2.88 2.32 3.21 3.44 ...
##  $ qsec: num  16.5 17 18.6 19.4 17 ...
##  $ vs  : Factor w/ 2 levels &amp;quot;0&amp;quot;,&amp;quot;1&amp;quot;: 1 1 2 2 1 2 1 2 2 2 ...
##  $ am  : Factor w/ 2 levels &amp;quot;0&amp;quot;,&amp;quot;1&amp;quot;: 2 2 2 1 1 1 1 1 1 1 ...
##  $ gear: Factor w/ 3 levels &amp;quot;3&amp;quot;,&amp;quot;4&amp;quot;,&amp;quot;5&amp;quot;: 2 2 2 1 1 1 1 2 2 2 ...
##  $ carb: Factor w/ 6 levels &amp;quot;1&amp;quot;,&amp;quot;2&amp;quot;,&amp;quot;3&amp;quot;,&amp;quot;4&amp;quot;,..: 4 4 1 1 2 1 4 2 2 4 ...&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;data-screening&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data Screening&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;ds_screener()&lt;/code&gt; function will screen a data set and return the following:
- Column/Variable Names
- Data Type
- Levels (in case of categorical data)
- Number of missing observations
- % of missing observations&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_screener(mtcarz)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## -----------------------------------------------------------------------
## |  Column Name  |  Data Type  |  Levels   |  Missing  |  Missing (%)  |
## -----------------------------------------------------------------------
## |      mpg      |   numeric   |    NA     |     0     |       0       |
## |      cyl      |   factor    |   4 6 8   |     0     |       0       |
## |     disp      |   numeric   |    NA     |     0     |       0       |
## |      hp       |   numeric   |    NA     |     0     |       0       |
## |     drat      |   numeric   |    NA     |     0     |       0       |
## |      wt       |   numeric   |    NA     |     0     |       0       |
## |     qsec      |   numeric   |    NA     |     0     |       0       |
## |      vs       |   factor    |    0 1    |     0     |       0       |
## |      am       |   factor    |    0 1    |     0     |       0       |
## |     gear      |   factor    |   3 4 5   |     0     |       0       |
## |     carb      |   factor    |1 2 3 4 6 8|     0     |       0       |
## -----------------------------------------------------------------------
## 
##  Overall Missing Values           0 
##  Percentage of Missing Values     0 %
##  Rows with Missing Values         0 
##  Columns With Missing Values      0&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;continuous-data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Continuous Data&lt;/h2&gt;
&lt;div id=&#34;summary-statistics&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary Statistics&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;ds_summary_stats()&lt;/code&gt; function returns a comprehensive set of statistics
including measures of location, variation, symmetry and extreme observations.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_summary_stats(mtcarz, mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## --------------------------------- Variable: mpg --------------------------------
## 
##                         Univariate Analysis                          
## 
##  N                       32.00      Variance                36.32 
##  Missing                  0.00      Std Deviation            6.03 
##  Mean                    20.09      Range                   23.50 
##  Median                  19.20      Interquartile Range      7.38 
##  Mode                    10.40      Uncorrected SS       14042.31 
##  Trimmed Mean            19.95      Corrected SS          1126.05 
##  Skewness                 0.67      Coeff Variation         30.00 
##  Kurtosis                -0.02      Std Error Mean           1.07 
## 
##                               Quantiles                               
## 
##               Quantile                            Value                
## 
##              Max                                  33.90                
##              99%                                  33.44                
##              95%                                  31.30                
##              90%                                  30.09                
##              Q3                                   22.80                
##              Median                               19.20                
##              Q1                                   15.43                
##              10%                                  14.34                
##              5%                                   12.00                
##              1%                                   10.40                
##              Min                                  10.40                
## 
##                             Extreme Values                            
## 
##                 Low                                High                
## 
##   Obs                        Value       Obs                        Value 
##   15                         10.4        20                         33.9  
##   16                         10.4        18                         32.4  
##   24                         13.3        19                         30.4  
##    7                         14.3        28                         30.4  
##   17                         14.7        26                         27.3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can pass multiple variables as shown below:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_summary_stats(mtcarz, mpg, disp)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## --------------------------------- Variable: mpg --------------------------------
## 
##                         Univariate Analysis                          
## 
##  N                       32.00      Variance                36.32 
##  Missing                  0.00      Std Deviation            6.03 
##  Mean                    20.09      Range                   23.50 
##  Median                  19.20      Interquartile Range      7.38 
##  Mode                    10.40      Uncorrected SS       14042.31 
##  Trimmed Mean            19.95      Corrected SS          1126.05 
##  Skewness                 0.67      Coeff Variation         30.00 
##  Kurtosis                -0.02      Std Error Mean           1.07 
## 
##                               Quantiles                               
## 
##               Quantile                            Value                
## 
##              Max                                  33.90                
##              99%                                  33.44                
##              95%                                  31.30                
##              90%                                  30.09                
##              Q3                                   22.80                
##              Median                               19.20                
##              Q1                                   15.43                
##              10%                                  14.34                
##              5%                                   12.00                
##              1%                                   10.40                
##              Min                                  10.40                
## 
##                             Extreme Values                            
## 
##                 Low                                High                
## 
##   Obs                        Value       Obs                        Value 
##   15                         10.4        20                         33.9  
##   16                         10.4        18                         32.4  
##   24                         13.3        19                         30.4  
##    7                         14.3        28                         30.4  
##   17                         14.7        26                         27.3  
## 
## 
## 
## -------------------------------- Variable: disp --------------------------------
## 
##                           Univariate Analysis                            
## 
##  N                         32.00      Variance               15360.80 
##  Missing                    0.00      Std Deviation            123.94 
##  Mean                     230.72      Range                    400.90 
##  Median                   196.30      Interquartile Range      205.18 
##  Mode                     275.80      Uncorrected SS       2179627.47 
##  Trimmed Mean             228.00      Corrected SS          476184.79 
##  Skewness                   0.42      Coeff Variation           53.72 
##  Kurtosis                  -1.07      Std Error Mean            21.91 
## 
##                                 Quantiles                                 
## 
##                Quantile                              Value                 
## 
##               Max                                    472.00                
##               99%                                    468.28                
##               95%                                    449.00                
##               90%                                    396.00                
##               Q3                                     326.00                
##               Median                                 196.30                
##               Q1                                     120.83                
##               10%                                    80.61                 
##               5%                                     77.35                 
##               1%                                     72.53                 
##               Min                                    71.10                 
## 
##                               Extreme Values                              
## 
##                  Low                                  High                 
## 
##   Obs                          Value       Obs                          Value 
##   20                           71.1        15                            472  
##   19                           75.7        16                            460  
##   18                           78.7        17                            440  
##   26                            79         25                            400  
##   28                           95.1         5                            360&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you do not specify any variables, it will detect all the continuous
variables in the data set and return summary statistics for each of them.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;frequency-distribution&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Frequency Distribution&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;ds_freq_table()&lt;/code&gt; function creates frequency tables for continuous variables.
The default number of intervals is 5.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_freq_table(mtcarz, mpg, 4)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                                 Variable: mpg                                 
## |---------------------------------------------------------------------------|
## |      Bins       | Frequency | Cum Frequency |   Percent    | Cum Percent  |
## |---------------------------------------------------------------------------|
## |  10.4  -  16.3  |    10     |      10       |    31.25     |    31.25     |
## |---------------------------------------------------------------------------|
## |  16.3  -  22.1  |    13     |      23       |    40.62     |    71.88     |
## |---------------------------------------------------------------------------|
## |  22.1  -   28   |     5     |      28       |    15.62     |     87.5     |
## |---------------------------------------------------------------------------|
## |   28   -  33.9  |     4     |      32       |     12.5     |     100      |
## |---------------------------------------------------------------------------|
## |      Total      |    32     |       -       |    100.00    |      -       |
## |---------------------------------------------------------------------------|&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;histogram&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Histogram&lt;/h4&gt;
&lt;p&gt;A &lt;code&gt;plot()&lt;/code&gt; method has been defined which will generate a histogram.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;k &amp;lt;- ds_freq_table(mtcarz, mpg, 4)
plot(k)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-20-introducing-descriptr_files/figure-html/fcont_hist-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;auto-summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Auto Summary&lt;/h3&gt;
&lt;p&gt;If you want to view summary statistics and frequency tables of all or subset of
variables in a data set, use &lt;code&gt;ds_auto_summary()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_auto_summary_stats(mtcarz, disp, mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## -------------------------------- Variable: disp --------------------------------
## 
## ------------------------------ Summary Statistics ------------------------------
## 
## -------------------------------- Variable: disp --------------------------------
## 
##                           Univariate Analysis                            
## 
##  N                         32.00      Variance               15360.80 
##  Missing                    0.00      Std Deviation            123.94 
##  Mean                     230.72      Range                    400.90 
##  Median                   196.30      Interquartile Range      205.18 
##  Mode                     275.80      Uncorrected SS       2179627.47 
##  Trimmed Mean             228.00      Corrected SS          476184.79 
##  Skewness                   0.42      Coeff Variation           53.72 
##  Kurtosis                  -1.07      Std Error Mean            21.91 
## 
##                                 Quantiles                                 
## 
##                Quantile                              Value                 
## 
##               Max                                    472.00                
##               99%                                    468.28                
##               95%                                    449.00                
##               90%                                    396.00                
##               Q3                                     326.00                
##               Median                                 196.30                
##               Q1                                     120.83                
##               10%                                    80.61                 
##               5%                                     77.35                 
##               1%                                     72.53                 
##               Min                                    71.10                 
## 
##                               Extreme Values                              
## 
##                  Low                                  High                 
## 
##   Obs                          Value       Obs                          Value 
##   20                           71.1        15                            472  
##   19                           75.7        16                            460  
##   18                           78.7        17                            440  
##   26                            79         25                            400  
##   28                           95.1         5                            360  
## 
## 
## 
## NULL
## 
## 
## ---------------------------- Frequency Distribution ----------------------------
## 
##                                Variable: disp                                 
## |---------------------------------------------------------------------------|
## |      Bins       | Frequency | Cum Frequency |   Percent    | Cum Percent  |
## |---------------------------------------------------------------------------|
## |  71.1  - 151.3  |    12     |      12       |     37.5     |     37.5     |
## |---------------------------------------------------------------------------|
## | 151.3  - 231.5  |     5     |      17       |    15.62     |    53.12     |
## |---------------------------------------------------------------------------|
## | 231.5  - 311.6  |     6     |      23       |    18.75     |    71.88     |
## |---------------------------------------------------------------------------|
## | 311.6  - 391.8  |     5     |      28       |    15.62     |     87.5     |
## |---------------------------------------------------------------------------|
## | 391.8  -  472   |     4     |      32       |     12.5     |     100      |
## |---------------------------------------------------------------------------|
## |      Total      |    32     |       -       |    100.00    |      -       |
## |---------------------------------------------------------------------------|
## 
## 
## -------------------------------- Variable: mpg --------------------------------
## 
## ------------------------------ Summary Statistics ------------------------------
## 
## --------------------------------- Variable: mpg --------------------------------
## 
##                         Univariate Analysis                          
## 
##  N                       32.00      Variance                36.32 
##  Missing                  0.00      Std Deviation            6.03 
##  Mean                    20.09      Range                   23.50 
##  Median                  19.20      Interquartile Range      7.38 
##  Mode                    10.40      Uncorrected SS       14042.31 
##  Trimmed Mean            19.95      Corrected SS          1126.05 
##  Skewness                 0.67      Coeff Variation         30.00 
##  Kurtosis                -0.02      Std Error Mean           1.07 
## 
##                               Quantiles                               
## 
##               Quantile                            Value                
## 
##              Max                                  33.90                
##              99%                                  33.44                
##              95%                                  31.30                
##              90%                                  30.09                
##              Q3                                   22.80                
##              Median                               19.20                
##              Q1                                   15.43                
##              10%                                  14.34                
##              5%                                   12.00                
##              1%                                   10.40                
##              Min                                  10.40                
## 
##                             Extreme Values                            
## 
##                 Low                                High                
## 
##   Obs                        Value       Obs                        Value 
##   15                         10.4        20                         33.9  
##   16                         10.4        18                         32.4  
##   24                         13.3        19                         30.4  
##    7                         14.3        28                         30.4  
##   17                         14.7        26                         27.3  
## 
## 
## 
## NULL
## 
## 
## ---------------------------- Frequency Distribution ----------------------------
## 
##                               Variable: mpg                               
## |-----------------------------------------------------------------------|
## |    Bins     | Frequency | Cum Frequency |   Percent    | Cum Percent  |
## |-----------------------------------------------------------------------|
## | 10.4 - 15.1 |     6     |       6       |    18.75     |    18.75     |
## |-----------------------------------------------------------------------|
## | 15.1 - 19.8 |    12     |      18       |     37.5     |    56.25     |
## |-----------------------------------------------------------------------|
## | 19.8 - 24.5 |     8     |      26       |      25      |    81.25     |
## |-----------------------------------------------------------------------|
## | 24.5 - 29.2 |     2     |      28       |     6.25     |     87.5     |
## |-----------------------------------------------------------------------|
## | 29.2 - 33.9 |     4     |      32       |     12.5     |     100      |
## |-----------------------------------------------------------------------|
## |    Total    |    32     |       -       |    100.00    |      -       |
## |-----------------------------------------------------------------------|&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;group-summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Group Summary&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;ds_group_summary()&lt;/code&gt; function returns descriptive statistics of a continuous
variable for the different levels of a categorical variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;k &amp;lt;- ds_group_summary(mtcarz, cyl, mpg)
k&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                                        mpg by cyl                                         
## -----------------------------------------------------------------------------------------
## |     Statistic/Levels|                    4|                    6|                    8|
## -----------------------------------------------------------------------------------------
## |                  Obs|                   11|                    7|                   14|
## |              Minimum|                 21.4|                 17.8|                 10.4|
## |              Maximum|                 33.9|                 21.4|                 19.2|
## |                 Mean|                26.66|                19.74|                 15.1|
## |               Median|                   26|                 19.7|                 15.2|
## |                 Mode|                 22.8|                   21|                 10.4|
## |       Std. Deviation|                 4.51|                 1.45|                 2.56|
## |             Variance|                20.34|                 2.11|                 6.55|
## |             Skewness|                 0.35|                -0.26|                -0.46|
## |             Kurtosis|                -1.43|                -1.83|                 0.33|
## |       Uncorrected SS|              8023.83|              2741.14|              3277.34|
## |         Corrected SS|               203.39|                12.68|                 85.2|
## |      Coeff Variation|                16.91|                 7.36|                16.95|
## |      Std. Error Mean|                 1.36|                 0.55|                 0.68|
## |                Range|                 12.5|                  3.6|                  8.8|
## |  Interquartile Range|                  7.6|                 2.35|                 1.85|
## -----------------------------------------------------------------------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;ds_group_summary()&lt;/code&gt; returns a tibble which can be used for further analysis.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;k$tidy_stats&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 x 15
##   cyl   length   min   max  mean median  mode    sd variance skewness kurtosis
## * &amp;lt;fct&amp;gt;  &amp;lt;int&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt;
## 1 4         11  21.4  33.9  26.7   26    22.8  4.51    20.3     0.348   -1.43 
## 2 6          7  17.8  21.4  19.7   19.7  21    1.45     2.11   -0.259   -1.83 
## 3 8         14  10.4  19.2  15.1   15.2  10.4  2.56     6.55   -0.456    0.330
## # ... with 4 more variables: coeff_var &amp;lt;dbl&amp;gt;, std_error &amp;lt;dbl&amp;gt;, range &amp;lt;dbl&amp;gt;,
## #   iqr &amp;lt;dbl&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;box-plot&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Box Plot&lt;/h4&gt;
&lt;p&gt;A &lt;code&gt;plot()&lt;/code&gt; method has been defined for comparing distributions.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;k &amp;lt;- ds_group_summary(mtcarz, cyl, mpg)
plot(k)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-20-introducing-descriptr_files/figure-html/gsum_boxplot-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;multiple-variables&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Multiple Variables&lt;/h3&gt;
&lt;p&gt;If you want grouped summary statistics for multiple variables in a data set, use
&lt;code&gt;ds_auto_group_summary()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_auto_group_summary(mtcarz, cyl, gear, mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                                        mpg by cyl                                         
## -----------------------------------------------------------------------------------------
## |     Statistic/Levels|                    4|                    6|                    8|
## -----------------------------------------------------------------------------------------
## |                  Obs|                   11|                    7|                   14|
## |              Minimum|                 21.4|                 17.8|                 10.4|
## |              Maximum|                 33.9|                 21.4|                 19.2|
## |                 Mean|                26.66|                19.74|                 15.1|
## |               Median|                   26|                 19.7|                 15.2|
## |                 Mode|                 22.8|                   21|                 10.4|
## |       Std. Deviation|                 4.51|                 1.45|                 2.56|
## |             Variance|                20.34|                 2.11|                 6.55|
## |             Skewness|                 0.35|                -0.26|                -0.46|
## |             Kurtosis|                -1.43|                -1.83|                 0.33|
## |       Uncorrected SS|              8023.83|              2741.14|              3277.34|
## |         Corrected SS|               203.39|                12.68|                 85.2|
## |      Coeff Variation|                16.91|                 7.36|                16.95|
## |      Std. Error Mean|                 1.36|                 0.55|                 0.68|
## |                Range|                 12.5|                  3.6|                  8.8|
## |  Interquartile Range|                  7.6|                 2.35|                 1.85|
## -----------------------------------------------------------------------------------------
## 
## 
## 
##                                        mpg by gear                                        
## -----------------------------------------------------------------------------------------
## |     Statistic/Levels|                    3|                    4|                    5|
## -----------------------------------------------------------------------------------------
## |                  Obs|                   15|                   12|                    5|
## |              Minimum|                 10.4|                 17.8|                   15|
## |              Maximum|                 21.5|                 33.9|                 30.4|
## |                 Mean|                16.11|                24.53|                21.38|
## |               Median|                 15.5|                 22.8|                 19.7|
## |                 Mode|                 10.4|                   21|                   15|
## |       Std. Deviation|                 3.37|                 5.28|                 6.66|
## |             Variance|                11.37|                27.84|                44.34|
## |             Skewness|                -0.09|                  0.7|                 0.56|
## |             Kurtosis|                -0.38|                -0.77|                -1.83|
## |       Uncorrected SS|              4050.52|               7528.9|              2462.89|
## |         Corrected SS|               159.15|               306.29|               177.37|
## |      Coeff Variation|                20.93|                21.51|                31.15|
## |      Std. Error Mean|                 0.87|                 1.52|                 2.98|
## |                Range|                 11.1|                 16.1|                 15.4|
## |  Interquartile Range|                  3.9|                 7.08|                 10.2|
## -----------------------------------------------------------------------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;multiple-variable-statistics&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Multiple Variable Statistics&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;ds_tidy_stats()&lt;/code&gt; function returns summary/descriptive statistics for
variables in a data frame/tibble.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_tidy_stats(mtcarz, mpg, disp, hp)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 x 16
##   vars    min   max  mean t_mean median  mode range variance  stdev  skew
## * &amp;lt;chr&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;
## 1 disp   71.1 472   231.   228    196.  276.  401.   15361.  124.   0.420
## 2 hp     52   335   147.   144.   123   110   283     4701.   68.6  0.799
## 3 mpg    10.4  33.9  20.1   20.0   19.2  10.4  23.5     36.3   6.03 0.672
## # ... with 5 more variables: kurtosis &amp;lt;dbl&amp;gt;, coeff_var &amp;lt;dbl&amp;gt;, q1 &amp;lt;dbl&amp;gt;,
## #   q3 &amp;lt;dbl&amp;gt;, iqrange &amp;lt;dbl&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;measures&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Measures&lt;/h3&gt;
&lt;p&gt;If you want to view the measure of location, variation, symmetry, percentiles
and extreme observations as tibbles, use the below functions. All of them,
except for &lt;code&gt;ds_extreme_obs()&lt;/code&gt; will work with single or multiple variables. If
you do not specify the variables, they will return the results for all the
continuous variables in the data set.&lt;/p&gt;
&lt;div id=&#34;measures-of-location&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Measures of Location&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_measures_location(mtcarz)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 6 x 5
##   var     mean trim_mean median   mode
##   &amp;lt;chr&amp;gt;  &amp;lt;dbl&amp;gt;     &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;
## 1 disp  231.      228    196.   276.  
## 2 drat    3.60      3.58   3.70   3.07
## 3 hp    147.      144.   123    110   
## 4 mpg    20.1      20.0   19.2   10.4 
## 5 qsec   17.8      17.8   17.7   17.0 
## 6 wt      3.22      3.20   3.32   3.44&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;measures-of-variation&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Measures of Variation&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_measures_variation(mtcarz)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 6 x 7
##   var    range     iqr  variance      sd coeff_var std_error
##   &amp;lt;chr&amp;gt;  &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;     &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;     &amp;lt;dbl&amp;gt;     &amp;lt;dbl&amp;gt;
## 1 disp  401.   205.    15361.    124.         53.7   21.9   
## 2 drat    2.17   0.840     0.286   0.535      14.9    0.0945
## 3 hp    283     83.5    4701.     68.6        46.7   12.1   
## 4 mpg    23.5    7.38     36.3     6.03       30.0    1.07  
## 5 qsec    8.40   2.01      3.19    1.79       10.0    0.316 
## 6 wt      3.91   1.03      0.957   0.978      30.4    0.173&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;measures-of-symmetry&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Measures of Symmetry&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_measures_symmetry(mtcarz)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 6 x 3
##   var   skewness kurtosis
##   &amp;lt;chr&amp;gt;    &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt;
## 1 disp     0.420  -1.07  
## 2 drat     0.293  -0.450 
## 3 hp       0.799   0.275 
## 4 mpg      0.672  -0.0220
## 5 qsec     0.406   0.865 
## 6 wt       0.466   0.417&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;percentiles&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Percentiles&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_percentiles(mtcarz)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 6 x 12
##   var     min  per1  per5 per10     q1 median     q3  per95  per90  per99    max
##   &amp;lt;chr&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;
## 1 disp  71.1  72.5  77.4  80.6  121.   196.   326    449    396.   468.   472   
## 2 drat   2.76  2.76  2.85  3.01   3.08   3.70   3.92   4.31   4.21   4.78   4.93
## 3 hp    52    55.1  63.6  66     96.5  123    180    254.   244.   313.   335   
## 4 mpg   10.4  10.4  12.0  14.3   15.4   19.2   22.8   31.3   30.1   33.4   33.9 
## 5 qsec  14.5  14.5  15.0  15.5   16.9   17.7   18.9   20.1   20.0   22.1   22.9 
## 6 wt     1.51  1.54  1.74  1.96   2.58   3.32   3.61   5.29   4.05   5.40   5.42&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;categorical-data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Categorical Data&lt;/h2&gt;
&lt;div id=&#34;cross-tabulation&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Cross Tabulation&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;ds_cross_table()&lt;/code&gt; function creates two way tables of categorical variables.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_cross_table(mtcarz, cyl, gear)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##     Cell Contents
##  |---------------|
##  |     Frequency |
##  |       Percent |
##  |       Row Pct |
##  |       Col Pct |
##  |---------------|
## 
##  Total Observations:  32 
## 
## ----------------------------------------------------------------------------
## |              |                           gear                            |
## ----------------------------------------------------------------------------
## |          cyl |            3 |            4 |            5 |    Row Total |
## ----------------------------------------------------------------------------
## |            4 |            1 |            8 |            2 |           11 |
## |              |        0.031 |         0.25 |        0.062 |              |
## |              |         0.09 |         0.73 |         0.18 |         0.34 |
## |              |         0.07 |         0.67 |          0.4 |              |
## ----------------------------------------------------------------------------
## |            6 |            2 |            4 |            1 |            7 |
## |              |        0.062 |        0.125 |        0.031 |              |
## |              |         0.29 |         0.57 |         0.14 |         0.22 |
## |              |         0.13 |         0.33 |          0.2 |              |
## ----------------------------------------------------------------------------
## |            8 |           12 |            0 |            2 |           14 |
## |              |        0.375 |            0 |        0.062 |              |
## |              |         0.86 |            0 |         0.14 |         0.44 |
## |              |          0.8 |            0 |          0.4 |              |
## ----------------------------------------------------------------------------
## | Column Total |           15 |           12 |            5 |           32 |
## |              |        0.468 |        0.375 |        0.155 |              |
## ----------------------------------------------------------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you want the above result as a tibble, use &lt;code&gt;ds_twoway_table()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_twoway_table(mtcarz, cyl, gear)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Joining, by = c(&amp;quot;cyl&amp;quot;, &amp;quot;gear&amp;quot;, &amp;quot;count&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 8 x 6
##   cyl   gear  count percent row_percent col_percent
##   &amp;lt;fct&amp;gt; &amp;lt;fct&amp;gt; &amp;lt;int&amp;gt;   &amp;lt;dbl&amp;gt;       &amp;lt;dbl&amp;gt;       &amp;lt;dbl&amp;gt;
## 1 4     3         1  0.0312      0.0909      0.0667
## 2 4     4         8  0.25        0.727       0.667 
## 3 4     5         2  0.0625      0.182       0.4   
## 4 6     3         2  0.0625      0.286       0.133 
## 5 6     4         4  0.125       0.571       0.333 
## 6 6     5         1  0.0312      0.143       0.2   
## 7 8     3        12  0.375       0.857       0.8   
## 8 8     5         2  0.0625      0.143       0.4&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A &lt;code&gt;plot()&lt;/code&gt; method has been defined which will generate:&lt;/p&gt;
&lt;div id=&#34;grouped-bar-plots&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Grouped Bar Plots&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;k &amp;lt;- ds_cross_table(mtcarz, cyl, gear)
plot(k)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-20-introducing-descriptr_files/figure-html/cross_group-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;stacked-bar-plots&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Stacked Bar Plots&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;k &amp;lt;- ds_cross_table(mtcarz, cyl, gear)
plot(k, stacked = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-20-introducing-descriptr_files/figure-html/cross_stack-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;proportional-bar-plots&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Proportional Bar Plots&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;k &amp;lt;- ds_cross_table(mtcarz, cyl, gear)
plot(k, proportional = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-20-introducing-descriptr_files/figure-html/cross_prop-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;frequency-table&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Frequency Table&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;ds_freq_table()&lt;/code&gt; function creates frequency tables.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_freq_table(mtcarz, cyl)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                              Variable: cyl                              
## -----------------------------------------------------------------------
## Levels     Frequency    Cum Frequency       Percent        Cum Percent  
## -----------------------------------------------------------------------
##    4          11             11              34.38            34.38    
## -----------------------------------------------------------------------
##    6           7             18              21.88            56.25    
## -----------------------------------------------------------------------
##    8          14             32              43.75             100     
## -----------------------------------------------------------------------
##  Total        32              -             100.00              -      
## -----------------------------------------------------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A &lt;code&gt;plot()&lt;/code&gt; method has been defined which will create a bar plot.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;k &amp;lt;- ds_freq_table(mtcarz, cyl)
plot(k)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-20-introducing-descriptr_files/figure-html/ftable_bar-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;multiple-one-way-tables&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Multiple One Way Tables&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;ds_auto_freq_table()&lt;/code&gt; function creates multiple one way tables by creating a
frequency table for each categorical variable in a data set. You can also
specify a subset of variables if you do not want all the variables in the data
set to be used.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_auto_freq_table(mtcarz)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                              Variable: cyl                              
## -----------------------------------------------------------------------
## Levels     Frequency    Cum Frequency       Percent        Cum Percent  
## -----------------------------------------------------------------------
##    4          11             11              34.38            34.38    
## -----------------------------------------------------------------------
##    6           7             18              21.88            56.25    
## -----------------------------------------------------------------------
##    8          14             32              43.75             100     
## -----------------------------------------------------------------------
##  Total        32              -             100.00              -      
## -----------------------------------------------------------------------
## 
##                              Variable: vs                               
## -----------------------------------------------------------------------
## Levels     Frequency    Cum Frequency       Percent        Cum Percent  
## -----------------------------------------------------------------------
##    0          18             18              56.25            56.25    
## -----------------------------------------------------------------------
##    1          14             32              43.75             100     
## -----------------------------------------------------------------------
##  Total        32              -             100.00              -      
## -----------------------------------------------------------------------
## 
##                              Variable: am                               
## -----------------------------------------------------------------------
## Levels     Frequency    Cum Frequency       Percent        Cum Percent  
## -----------------------------------------------------------------------
##    0          19             19              59.38            59.38    
## -----------------------------------------------------------------------
##    1          13             32              40.62             100     
## -----------------------------------------------------------------------
##  Total        32              -             100.00              -      
## -----------------------------------------------------------------------
## 
##                             Variable: gear                              
## -----------------------------------------------------------------------
## Levels     Frequency    Cum Frequency       Percent        Cum Percent  
## -----------------------------------------------------------------------
##    3          15             15              46.88            46.88    
## -----------------------------------------------------------------------
##    4          12             27              37.5             84.38    
## -----------------------------------------------------------------------
##    5           5             32              15.62             100     
## -----------------------------------------------------------------------
##  Total        32              -             100.00              -      
## -----------------------------------------------------------------------
## 
##                             Variable: carb                              
## -----------------------------------------------------------------------
## Levels     Frequency    Cum Frequency       Percent        Cum Percent  
## -----------------------------------------------------------------------
##    1           7              7              21.88            21.88    
## -----------------------------------------------------------------------
##    2          10             17              31.25            53.12    
## -----------------------------------------------------------------------
##    3           3             20              9.38             62.5     
## -----------------------------------------------------------------------
##    4          10             30              31.25            93.75    
## -----------------------------------------------------------------------
##    6           1             31              3.12             96.88    
## -----------------------------------------------------------------------
##    8           1             32              3.12              100     
## -----------------------------------------------------------------------
##  Total        32              -             100.00              -      
## -----------------------------------------------------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;multiple-two-way-tables&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Multiple Two Way Tables&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;ds_auto_cross_table()&lt;/code&gt; function creates multiple two way tables by creating a
cross table for each unique pair of categorical variables in a data set. You
can also specify a subset of variables if you do not want all the variables in
the data set to be used.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_auto_cross_table(mtcarz, cyl, gear, am)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##     Cell Contents
##  |---------------|
##  |     Frequency |
##  |       Percent |
##  |       Row Pct |
##  |       Col Pct |
##  |---------------|
## 
##  Total Observations:  32 
## 
##                                 cyl vs gear                                 
## ----------------------------------------------------------------------------
## |              |                           gear                            |
## ----------------------------------------------------------------------------
## |          cyl |            3 |            4 |            5 |    Row Total |
## ----------------------------------------------------------------------------
## |            4 |            1 |            8 |            2 |           11 |
## |              |        0.031 |         0.25 |        0.062 |              |
## |              |         0.09 |         0.73 |         0.18 |         0.34 |
## |              |         0.07 |         0.67 |          0.4 |              |
## ----------------------------------------------------------------------------
## |            6 |            2 |            4 |            1 |            7 |
## |              |        0.062 |        0.125 |        0.031 |              |
## |              |         0.29 |         0.57 |         0.14 |         0.22 |
## |              |         0.13 |         0.33 |          0.2 |              |
## ----------------------------------------------------------------------------
## |            8 |           12 |            0 |            2 |           14 |
## |              |        0.375 |            0 |        0.062 |              |
## |              |         0.86 |            0 |         0.14 |         0.44 |
## |              |          0.8 |            0 |          0.4 |              |
## ----------------------------------------------------------------------------
## | Column Total |           15 |           12 |            5 |           32 |
## |              |        0.468 |        0.375 |        0.155 |              |
## ----------------------------------------------------------------------------
## 
## 
##                          cyl vs am                           
## -------------------------------------------------------------
## |              |                     am                     |
## -------------------------------------------------------------
## |          cyl |            0 |            1 |    Row Total |
## -------------------------------------------------------------
## |            4 |            3 |            8 |           11 |
## |              |        0.094 |         0.25 |              |
## |              |         0.27 |         0.73 |         0.34 |
## |              |         0.16 |         0.62 |              |
## -------------------------------------------------------------
## |            6 |            4 |            3 |            7 |
## |              |        0.125 |        0.094 |              |
## |              |         0.57 |         0.43 |         0.22 |
## |              |         0.21 |         0.23 |              |
## -------------------------------------------------------------
## |            8 |           12 |            2 |           14 |
## |              |        0.375 |        0.062 |              |
## |              |         0.86 |         0.14 |         0.44 |
## |              |         0.63 |         0.15 |              |
## -------------------------------------------------------------
## | Column Total |           19 |           13 |           32 |
## |              |        0.594 |        0.406 |              |
## -------------------------------------------------------------
## 
## 
##                          gear vs am                          
## -------------------------------------------------------------
## |              |                     am                     |
## -------------------------------------------------------------
## |         gear |            0 |            1 |    Row Total |
## -------------------------------------------------------------
## |            3 |           15 |            0 |           15 |
## |              |        0.469 |            0 |              |
## |              |            1 |            0 |         0.47 |
## |              |         0.79 |            0 |              |
## -------------------------------------------------------------
## |            4 |            4 |            8 |           12 |
## |              |        0.125 |         0.25 |              |
## |              |         0.33 |         0.67 |         0.38 |
## |              |         0.21 |         0.62 |              |
## -------------------------------------------------------------
## |            5 |            0 |            5 |            5 |
## |              |            0 |        0.156 |              |
## |              |            0 |            1 |         0.16 |
## |              |            0 |         0.38 |              |
## -------------------------------------------------------------
## | Column Total |           19 |           13 |           32 |
## |              |        0.594 |        0.406 |              |
## -------------------------------------------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;visualization&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Visualization&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;descriptr&lt;/strong&gt; can help visualize multiple variables by automatically
detecting their data types.&lt;/p&gt;
&lt;div id=&#34;continuous-data-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Continuous Data&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_plot_scatter(mtcarz, mpg, disp, hp)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-20-introducing-descriptr_files/figure-html/scatter-1.png&#34; width=&#34;672&#34; /&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-20-introducing-descriptr_files/figure-html/scatter-2.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;categorical-data-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Categorical Data&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ds_plot_bar_stacked(mtcarz, cyl, gear, am)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-20-introducing-descriptr_files/figure-html/bar_stacked-1.png&#34; width=&#34;672&#34; /&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-20-introducing-descriptr_files/figure-html/bar_stacked-2.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;learning-more&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Learning More&lt;/h2&gt;
&lt;p&gt;The &lt;a href=&#34;https://descriptr.rsquaredacademy.com/index.html&#34;&gt;descriptr website&lt;/a&gt; includes
comprehensive documentation on using the package, including the following
articles that cover various aspects of using rfm:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href=&#34;https://descriptr.rsquaredacademy.com/articles/continuous-data.html&#34;&gt;Continuous Data&lt;/a&gt; - for
summarizing continuous data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href=&#34;https://descriptr.rsquaredacademy.com/articles/categorical-data.html&#34;&gt;Categorical Data&lt;/a&gt; - for
summarizing categorical data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href=&#34;https://descriptr.rsquaredacademy.com/articles/visualization.html&#34;&gt;Visualization&lt;/a&gt; - for
generating different types of plots.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;feedback&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Feedback&lt;/h2&gt;
&lt;p&gt;All feedback is welcome. Issues (bugs and feature
requests) can be posted to &lt;a href=&#34;https://github.com/rsquaredacademy/descriptr/issues&#34;&gt;github tracker&lt;/a&gt;.
For help with code or other related questions, feel free to reach me &lt;a href=&#34;mailto:hebbali.aravind@gmail.com&#34; class=&#34;email&#34;&gt;hebbali.aravind@gmail.com&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>RFM Analysis in R</title>
      <link>https://blog.rsquaredacademy.com/introducing-rfm/</link>
      <pubDate>Tue, 12 Feb 2019 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/introducing-rfm/</guid>
      <description>&lt;script src=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/kePrint/kePrint.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/htmlwidgets/htmlwidgets.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/jquery/jquery.min.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/datatables-css/datatables-crosstalk.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/datatables-binding/datatables.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/dt-core/css/jquery.dataTables.min.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;link href=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/dt-core/css/jquery.dataTables.extra.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/dt-core/js/jquery.dataTables.min.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/nouislider/jquery.nouislider.min.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/nouislider/jquery.nouislider.min.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/selectize/selectize.bootstrap3.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/selectize/selectize.min.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/crosstalk/css/crosstalk.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://blog.rsquaredacademy.com/rmarkdown-libs/crosstalk/js/crosstalk.min.js&#34;&gt;&lt;/script&gt;


&lt;p&gt;We are pleased to announce the &lt;strong&gt;rfm&lt;/strong&gt; package, a set of tools for recency,
frequency and monetary value analysis, designed keeping in mind
beginner/intermediate R users. It can handle:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;transaction level data&lt;/li&gt;
&lt;li&gt;customer level data&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;installation&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Installation&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Install release version from CRAN
install.packages(&amp;quot;rfm&amp;quot;)

# Install development version from GitHub
# install.packages(&amp;quot;devtools&amp;quot;)
devtools::install_github(&amp;quot;rsquaredacademy/rfm&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;shiny-app&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Shiny App&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;rfm&lt;/strong&gt; includes a shiny app which can be launched using&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rfm_launch_app()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or try the live version &lt;a href=&#34;https://www.rsquaredcomputing.com/rfm/&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Read on to learn more about the features of &lt;strong&gt;rfm&lt;/strong&gt;, or see the
&lt;a href=&#34;https://rfm.rsquaredacademy.com/&#34;&gt;rfm website&lt;/a&gt; for
detailed documentation on using the package.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;RFM&lt;/strong&gt; (recency, frequency, monetary) analysis is a behavior based technique used to segment customers by examining their transaction history such as&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;how recently a customer has purchased (recency)&lt;/li&gt;
&lt;li&gt;how often they purchase (frequency)&lt;/li&gt;
&lt;li&gt;how much the customer spends (monetary)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It is based on the marketing axiom that &lt;strong&gt;80% of your business comes from 20% of your customers&lt;/strong&gt;. RFM helps to identify customers who are more likely to respond to promotions by segmenting them into various categories.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data&lt;/h2&gt;
&lt;p&gt;To calculate the RFM score for each customer we need transaction data which should include the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a unique customer id&lt;/li&gt;
&lt;li&gt;date of transaction/order&lt;/li&gt;
&lt;li&gt;transaction/order amount&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;rfm&lt;/code&gt; includes a sample data set &lt;code&gt;rfm_data_orders&lt;/code&gt; which includes the above details:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rfm_data_orders&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 4,906 x 3
##    customer_id         order_date revenue
##    &amp;lt;chr&amp;gt;               &amp;lt;date&amp;gt;       &amp;lt;dbl&amp;gt;
##  1 Mr. Brion Stark Sr. 2004-12-20      32
##  2 Ethyl Botsford      2005-05-02      36
##  3 Hosteen Jacobi      2004-03-06     116
##  4 Mr. Edw Frami       2006-03-15      99
##  5 Josef Lemke         2006-08-14      76
##  6 Julisa Halvorson    2005-05-28      56
##  7 Judyth Lueilwitz    2005-03-09     108
##  8 Mr. Mekhi Goyette   2005-09-23     183
##  9 Hansford Moen PhD   2005-09-07      30
## 10 Fount Flatley       2006-04-12      13
## # ... with 4,896 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;rfm-score&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;RFM Score&lt;/h2&gt;
&lt;p&gt;So how is the RFM score computed for each customer? The below steps explain the process:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A recency score is assigned to each customer based on date of most recent purchase. The score is generated by binning the recency values into a number of categories (default is 5). For example, if you use four categories, the customers with the most recent purchase dates receive a recency ranking of 4, and those with purchase dates in the distant past receive a recency ranking of 1.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A frequency ranking is assigned in a similar way. Customers with high purchase frequency are assigned a higher score (4 or 5) and those with lowest frequency are assigned a score 1.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Monetary score is assigned on the basis of the total revenue generated by the customer in the period under consideration for the analysis. Customers with highest revenue/order amount are assigned a higher score while those with lowest revenue are assigned a score of 1.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A fourth score, RFM score is generated which is simply the three individual scores concatenated into a single value.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The customers with the highest RFM scores are most likely to respond to an offer. Now that we have understood how the RFM score is computed, it is time to put it into practice. Use &lt;code&gt;rfm_table_order()&lt;/code&gt; to generate the score for each customer from the sample data set &lt;code&gt;rfm_data_orders&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;rfm_table_order()&lt;/code&gt; takes 8 inputs:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;data&lt;/code&gt;: a data set with
&lt;ul&gt;
&lt;li&gt;unique customer id&lt;/li&gt;
&lt;li&gt;date of transaction&lt;/li&gt;
&lt;li&gt;and amount&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;customer_id&lt;/code&gt;: name of the customer id column&lt;/li&gt;
&lt;li&gt;&lt;code&gt;order_date&lt;/code&gt;: name of the transaction date column&lt;/li&gt;
&lt;li&gt;&lt;code&gt;revenue&lt;/code&gt;: name of the transaction amount column&lt;/li&gt;
&lt;li&gt;&lt;code&gt;analysis_date&lt;/code&gt;: date of analysis&lt;/li&gt;
&lt;li&gt;&lt;code&gt;recency_bins&lt;/code&gt;: number of rankings for recency score (default is 5)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;frequency_bins&lt;/code&gt;: number of rankings for frequency score (default is 5)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;monetary_bins&lt;/code&gt;: number of rankings for monetary score (default is 5)&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;rfm-table&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;RFM Table&lt;/h2&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;analysis_date &amp;lt;- lubridate::as_date(&amp;quot;2006-12-31&amp;quot;, tz = &amp;quot;UTC&amp;quot;)
rfm_result &amp;lt;- rfm_table_order(rfm_data_orders, customer_id, order_date, revenue, analysis_date)
rfm_result&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: `tz` argument is ignored by `as_date()`&lt;/code&gt;&lt;/pre&gt;
&lt;table class=&#34;table&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
customer_id
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
date_most_recent
&lt;/th&gt;
&lt;th style=&#34;text-align:right;&#34;&gt;
recency_days
&lt;/th&gt;
&lt;th style=&#34;text-align:right;&#34;&gt;
transaction_count
&lt;/th&gt;
&lt;th style=&#34;text-align:right;&#34;&gt;
amount
&lt;/th&gt;
&lt;th style=&#34;text-align:right;&#34;&gt;
recency_score
&lt;/th&gt;
&lt;th style=&#34;text-align:right;&#34;&gt;
frequency_score
&lt;/th&gt;
&lt;th style=&#34;text-align:right;&#34;&gt;
monetary_score
&lt;/th&gt;
&lt;th style=&#34;text-align:right;&#34;&gt;
rfm_score
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Abbey O’Reilly DVM
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2006-06-09
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
205
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
6
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
472
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
3
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
4
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
3
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
343
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Add Senger
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2006-08-13
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
140
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
3
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
340
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
4
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
1
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
2
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
412
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Aden Lesch Sr. 
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2006-06-20
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
194
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
4
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
405
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
3
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
2
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
3
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
323
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Admiral Senger
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2006-08-21
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
132
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
5
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
448
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
4
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
3
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
3
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
433
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Agness O’Keefe
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2006-10-02
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
90
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
9
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
843
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
5
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
5
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
5
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
555
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Aileen Barton
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2006-10-08
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
84
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
9
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
763
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
5
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
5
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
5
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
555
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Ailene Hermann
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2006-03-25
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
281
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
8
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
699
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
3
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
5
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
5
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
355
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Aiyanna Bruen PhD
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2006-04-29
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
246
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
4
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
157
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
3
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
2
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
1
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
321
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Ala Schmidt DDS
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2006-01-16
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
349
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
3
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
363
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
2
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
1
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
2
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
212
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Alannah Borer
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2005-04-21
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
619
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
4
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
196
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
1
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
2
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
1
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
121
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;code&gt;rfm_table_order()&lt;/code&gt; will return the following columns as seen in the above table:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;customer_id&lt;/code&gt;: unique customer id&lt;/li&gt;
&lt;li&gt;&lt;code&gt;date_most_recent&lt;/code&gt;: date of most recent visit&lt;/li&gt;
&lt;li&gt;&lt;code&gt;recency_days&lt;/code&gt;: days since the most recent visit&lt;/li&gt;
&lt;li&gt;&lt;code&gt;transaction_count&lt;/code&gt;: number of transactions of the customer&lt;/li&gt;
&lt;li&gt;&lt;code&gt;amount&lt;/code&gt;: total revenue generated by the customer&lt;/li&gt;
&lt;li&gt;&lt;code&gt;recency_score&lt;/code&gt;: recency score of the customer&lt;/li&gt;
&lt;li&gt;&lt;code&gt;frequency_score&lt;/code&gt;: frequency score of the customer&lt;/li&gt;
&lt;li&gt;&lt;code&gt;monetary_score&lt;/code&gt;: monetary score of the customer&lt;/li&gt;
&lt;li&gt;&lt;code&gt;rfm_score&lt;/code&gt;: RFM score of the customer&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;segments&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Segments&lt;/h2&gt;
&lt;p&gt;Let us classify our customers based on the individual recency, frequency and monetary scores.&lt;/p&gt;
&lt;table class=&#34;table&#34; style=&#34;font-size: 12px; margin-left: auto; margin-right: auto;&#34;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Segment
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
Description
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
R
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
F
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
M
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Champions
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Bought recently, buy often and spend the most
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
4 - 5
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
4 - 5
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
4 - 5
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Loyal Customers
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Spend good money. Responsive to promotions
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2 - 5
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
3 - 5
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
3 - 5
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Potential Loyalist
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Recent customers, spent good amount, bought more than once
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
3 - 5
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
1 - 3
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
1 - 3
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
New Customers
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Bought more recently, but not often
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
4 - 5
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&amp;lt;= 1
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&amp;lt;= 1
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Promising
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Recent shoppers, but haven’t spent much
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
3 - 4
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&amp;lt;= 1
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&amp;lt;= 1
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Need Attention
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Above average recency, frequency &amp;amp; monetary values
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2 - 3
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2 - 3
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2 - 3
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
About To Sleep
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Below average recency, frequency &amp;amp; monetary values
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2 - 3
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&amp;lt;= 2
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&amp;lt;= 2
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
At Risk
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Spent big money, purchased often but long time ago
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&amp;lt;= 2
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2 - 5
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
2 - 5
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Can’t Lose Them
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Made big purchases and often, but long time ago
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&amp;lt;= 1
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
4 - 5
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
4 - 5
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Hibernating
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Low spenders, low frequency, purchased long time ago
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
1 - 2
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
1 - 2
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
1 - 2
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Lost
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Lowest recency, frequency &amp;amp; monetary scores
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&amp;lt;= 2
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&amp;lt;= 2
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
&amp;lt;= 2
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;div id=&#34;segmented-customer-data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Segmented Customer Data&lt;/h2&gt;
&lt;p&gt;We can use the segmented data to identify&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;best customers&lt;/li&gt;
&lt;li&gt;loyal customers&lt;/li&gt;
&lt;li&gt;at risk customers&lt;/li&gt;
&lt;li&gt;and lost customers&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Once we have classified a customer into a particular segment, we can take appropriate action to increase his/her lifetime value.&lt;/p&gt;
&lt;div id=&#34;htmlwidget-1&#34; style=&#34;width:100%;height:auto;&#34; class=&#34;datatables html-widget&#34;&gt;&lt;/div&gt;
&lt;script type=&#34;application/json&#34; data-for=&#34;htmlwidget-1&#34;&gt;{&#34;x&#34;:{&#34;filter&#34;:&#34;top&#34;,&#34;filterHTML&#34;:&#34;&lt;tr&gt;\n  &lt;td data-type=\&#34;character\&#34; style=\&#34;vertical-align: top;\&#34;&gt;\n    &lt;div class=\&#34;form-group has-feedback\&#34; style=\&#34;margin-bottom: auto;\&#34;&gt;\n      &lt;input type=\&#34;search\&#34; placeholder=\&#34;All\&#34; class=\&#34;form-control\&#34; style=\&#34;width: 100%;\&#34;/&gt;\n      &lt;span class=\&#34;glyphicon glyphicon-remove-circle form-control-feedback\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n  &lt;\/td&gt;\n  &lt;td data-type=\&#34;character\&#34; style=\&#34;vertical-align: top;\&#34;&gt;\n    &lt;div class=\&#34;form-group has-feedback\&#34; style=\&#34;margin-bottom: auto;\&#34;&gt;\n      &lt;input type=\&#34;search\&#34; placeholder=\&#34;All\&#34; class=\&#34;form-control\&#34; style=\&#34;width: 100%;\&#34;/&gt;\n      &lt;span class=\&#34;glyphicon glyphicon-remove-circle form-control-feedback\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n  &lt;\/td&gt;\n  &lt;td data-type=\&#34;character\&#34; style=\&#34;vertical-align: top;\&#34;&gt;\n    &lt;div class=\&#34;form-group has-feedback\&#34; style=\&#34;margin-bottom: auto;\&#34;&gt;\n      &lt;input type=\&#34;search\&#34; placeholder=\&#34;All\&#34; class=\&#34;form-control\&#34; style=\&#34;width: 100%;\&#34;/&gt;\n      &lt;span class=\&#34;glyphicon glyphicon-remove-circle form-control-feedback\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n  &lt;\/td&gt;\n  &lt;td data-type=\&#34;number\&#34; style=\&#34;vertical-align: top;\&#34;&gt;\n    &lt;div class=\&#34;form-group has-feedback\&#34; style=\&#34;margin-bottom: auto;\&#34;&gt;\n      &lt;input type=\&#34;search\&#34; placeholder=\&#34;All\&#34; class=\&#34;form-control\&#34; style=\&#34;width: 100%;\&#34;/&gt;\n      &lt;span class=\&#34;glyphicon glyphicon-remove-circle form-control-feedback\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n    &lt;div style=\&#34;display: none; position: absolute; width: 200px;\&#34;&gt;\n      &lt;div data-min=\&#34;111\&#34; data-max=\&#34;555\&#34;&gt;&lt;\/div&gt;\n      &lt;span style=\&#34;float: left;\&#34;&gt;&lt;\/span&gt;\n      &lt;span style=\&#34;float: right;\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n  &lt;\/td&gt;\n  &lt;td data-type=\&#34;number\&#34; style=\&#34;vertical-align: top;\&#34;&gt;\n    &lt;div class=\&#34;form-group has-feedback\&#34; style=\&#34;margin-bottom: auto;\&#34;&gt;\n      &lt;input type=\&#34;search\&#34; placeholder=\&#34;All\&#34; class=\&#34;form-control\&#34; style=\&#34;width: 100%;\&#34;/&gt;\n      &lt;span class=\&#34;glyphicon glyphicon-remove-circle form-control-feedback\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n    &lt;div style=\&#34;display: none; position: absolute; width: 200px;\&#34;&gt;\n      &lt;div data-min=\&#34;1\&#34; data-max=\&#34;14\&#34;&gt;&lt;\/div&gt;\n      &lt;span style=\&#34;float: left;\&#34;&gt;&lt;\/span&gt;\n      &lt;span style=\&#34;float: right;\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n  &lt;\/td&gt;\n  &lt;td data-type=\&#34;number\&#34; style=\&#34;vertical-align: top;\&#34;&gt;\n    &lt;div class=\&#34;form-group has-feedback\&#34; style=\&#34;margin-bottom: auto;\&#34;&gt;\n      &lt;input type=\&#34;search\&#34; placeholder=\&#34;All\&#34; class=\&#34;form-control\&#34; style=\&#34;width: 100%;\&#34;/&gt;\n      &lt;span class=\&#34;glyphicon glyphicon-remove-circle form-control-feedback\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n    &lt;div style=\&#34;display: none; position: absolute; width: 200px;\&#34;&gt;\n      &lt;div data-min=\&#34;1\&#34; data-max=\&#34;976\&#34;&gt;&lt;\/div&gt;\n      &lt;span style=\&#34;float: left;\&#34;&gt;&lt;\/span&gt;\n      &lt;span style=\&#34;float: right;\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n  &lt;\/td&gt;\n  &lt;td data-type=\&#34;number\&#34; style=\&#34;vertical-align: top;\&#34;&gt;\n    &lt;div class=\&#34;form-group has-feedback\&#34; style=\&#34;margin-bottom: auto;\&#34;&gt;\n      &lt;input type=\&#34;search\&#34; placeholder=\&#34;All\&#34; class=\&#34;form-control\&#34; style=\&#34;width: 100%;\&#34;/&gt;\n      &lt;span class=\&#34;glyphicon glyphicon-remove-circle form-control-feedback\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n    &lt;div style=\&#34;display: none; position: absolute; width: 200px;\&#34;&gt;\n      &lt;div data-min=\&#34;12\&#34; data-max=\&#34;1488\&#34;&gt;&lt;\/div&gt;\n      &lt;span style=\&#34;float: left;\&#34;&gt;&lt;\/span&gt;\n      &lt;span style=\&#34;float: right;\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n  &lt;\/td&gt;\n  &lt;td data-type=\&#34;integer\&#34; style=\&#34;vertical-align: top;\&#34;&gt;\n    &lt;div class=\&#34;form-group has-feedback\&#34; style=\&#34;margin-bottom: auto;\&#34;&gt;\n      &lt;input type=\&#34;search\&#34; placeholder=\&#34;All\&#34; class=\&#34;form-control\&#34; style=\&#34;width: 100%;\&#34;/&gt;\n      &lt;span class=\&#34;glyphicon glyphicon-remove-circle form-control-feedback\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n    &lt;div style=\&#34;display: none; position: absolute; width: 200px;\&#34;&gt;\n      &lt;div data-min=\&#34;1\&#34; data-max=\&#34;5\&#34;&gt;&lt;\/div&gt;\n      &lt;span style=\&#34;float: left;\&#34;&gt;&lt;\/span&gt;\n      &lt;span style=\&#34;float: right;\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n  &lt;\/td&gt;\n  &lt;td data-type=\&#34;integer\&#34; style=\&#34;vertical-align: top;\&#34;&gt;\n    &lt;div class=\&#34;form-group has-feedback\&#34; style=\&#34;margin-bottom: auto;\&#34;&gt;\n      &lt;input type=\&#34;search\&#34; placeholder=\&#34;All\&#34; class=\&#34;form-control\&#34; style=\&#34;width: 100%;\&#34;/&gt;\n      &lt;span class=\&#34;glyphicon glyphicon-remove-circle form-control-feedback\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n    &lt;div style=\&#34;display: none; position: absolute; width: 200px;\&#34;&gt;\n      &lt;div data-min=\&#34;1\&#34; data-max=\&#34;5\&#34;&gt;&lt;\/div&gt;\n      &lt;span style=\&#34;float: left;\&#34;&gt;&lt;\/span&gt;\n      &lt;span style=\&#34;float: right;\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n  &lt;\/td&gt;\n  &lt;td data-type=\&#34;integer\&#34; style=\&#34;vertical-align: top;\&#34;&gt;\n    &lt;div class=\&#34;form-group has-feedback\&#34; style=\&#34;margin-bottom: auto;\&#34;&gt;\n      &lt;input type=\&#34;search\&#34; placeholder=\&#34;All\&#34; class=\&#34;form-control\&#34; style=\&#34;width: 100%;\&#34;/&gt;\n      &lt;span class=\&#34;glyphicon glyphicon-remove-circle form-control-feedback\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n    &lt;div style=\&#34;display: none; position: absolute; width: 200px;\&#34;&gt;\n      &lt;div data-min=\&#34;1\&#34; data-max=\&#34;5\&#34;&gt;&lt;\/div&gt;\n      &lt;span style=\&#34;float: left;\&#34;&gt;&lt;\/span&gt;\n      &lt;span style=\&#34;float: right;\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n  &lt;\/td&gt;\n&lt;\/tr&gt;&#34;,&#34;data&#34;:[[&#34;1&#34;,&#34;2&#34;,&#34;3&#34;,&#34;4&#34;,&#34;5&#34;,&#34;6&#34;,&#34;7&#34;,&#34;8&#34;,&#34;9&#34;,&#34;10&#34;,&#34;11&#34;,&#34;12&#34;,&#34;13&#34;,&#34;14&#34;,&#34;15&#34;,&#34;16&#34;,&#34;17&#34;,&#34;18&#34;,&#34;19&#34;,&#34;20&#34;,&#34;21&#34;,&#34;22&#34;,&#34;23&#34;,&#34;24&#34;,&#34;25&#34;,&#34;26&#34;,&#34;27&#34;,&#34;28&#34;,&#34;29&#34;,&#34;30&#34;,&#34;31&#34;,&#34;32&#34;,&#34;33&#34;,&#34;34&#34;,&#34;35&#34;,&#34;36&#34;,&#34;37&#34;,&#34;38&#34;,&#34;39&#34;,&#34;40&#34;,&#34;41&#34;,&#34;42&#34;,&#34;43&#34;,&#34;44&#34;,&#34;45&#34;,&#34;46&#34;,&#34;47&#34;,&#34;48&#34;,&#34;49&#34;,&#34;50&#34;,&#34;51&#34;,&#34;52&#34;,&#34;53&#34;,&#34;54&#34;,&#34;55&#34;,&#34;56&#34;,&#34;57&#34;,&#34;58&#34;,&#34;59&#34;,&#34;60&#34;,&#34;61&#34;,&#34;62&#34;,&#34;63&#34;,&#34;64&#34;,&#34;65&#34;,&#34;66&#34;,&#34;67&#34;,&#34;68&#34;,&#34;69&#34;,&#34;70&#34;,&#34;71&#34;,&#34;72&#34;,&#34;73&#34;,&#34;74&#34;,&#34;75&#34;,&#34;76&#34;,&#34;77&#34;,&#34;78&#34;,&#34;79&#34;,&#34;80&#34;,&#34;81&#34;,&#34;82&#34;,&#34;83&#34;,&#34;84&#34;,&#34;85&#34;,&#34;86&#34;,&#34;87&#34;,&#34;88&#34;,&#34;89&#34;,&#34;90&#34;,&#34;91&#34;,&#34;92&#34;,&#34;93&#34;,&#34;94&#34;,&#34;95&#34;,&#34;96&#34;,&#34;97&#34;,&#34;98&#34;,&#34;99&#34;,&#34;100&#34;,&#34;101&#34;,&#34;102&#34;,&#34;103&#34;,&#34;104&#34;,&#34;105&#34;,&#34;106&#34;,&#34;107&#34;,&#34;108&#34;,&#34;109&#34;,&#34;110&#34;,&#34;111&#34;,&#34;112&#34;,&#34;113&#34;,&#34;114&#34;,&#34;115&#34;,&#34;116&#34;,&#34;117&#34;,&#34;118&#34;,&#34;119&#34;,&#34;120&#34;,&#34;121&#34;,&#34;122&#34;,&#34;123&#34;,&#34;124&#34;,&#34;125&#34;,&#34;126&#34;,&#34;127&#34;,&#34;128&#34;,&#34;129&#34;,&#34;130&#34;,&#34;131&#34;,&#34;132&#34;,&#34;133&#34;,&#34;134&#34;,&#34;135&#34;,&#34;136&#34;,&#34;137&#34;,&#34;138&#34;,&#34;139&#34;,&#34;140&#34;,&#34;141&#34;,&#34;142&#34;,&#34;143&#34;,&#34;144&#34;,&#34;145&#34;,&#34;146&#34;,&#34;147&#34;,&#34;148&#34;,&#34;149&#34;,&#34;150&#34;,&#34;151&#34;,&#34;152&#34;,&#34;153&#34;,&#34;154&#34;,&#34;155&#34;,&#34;156&#34;,&#34;157&#34;,&#34;158&#34;,&#34;159&#34;,&#34;160&#34;,&#34;161&#34;,&#34;162&#34;,&#34;163&#34;,&#34;164&#34;,&#34;165&#34;,&#34;166&#34;,&#34;167&#34;,&#34;168&#34;,&#34;169&#34;,&#34;170&#34;,&#34;171&#34;,&#34;172&#34;,&#34;173&#34;,&#34;174&#34;,&#34;175&#34;,&#34;176&#34;,&#34;177&#34;,&#34;178&#34;,&#34;179&#34;,&#34;180&#34;,&#34;181&#34;,&#34;182&#34;,&#34;183&#34;,&#34;184&#34;,&#34;185&#34;,&#34;186&#34;,&#34;187&#34;,&#34;188&#34;,&#34;189&#34;,&#34;190&#34;,&#34;191&#34;,&#34;192&#34;,&#34;193&#34;,&#34;194&#34;,&#34;195&#34;,&#34;196&#34;,&#34;197&#34;,&#34;198&#34;,&#34;199&#34;,&#34;200&#34;,&#34;201&#34;,&#34;202&#34;,&#34;203&#34;,&#34;204&#34;,&#34;205&#34;,&#34;206&#34;,&#34;207&#34;,&#34;208&#34;,&#34;209&#34;,&#34;210&#34;,&#34;211&#34;,&#34;212&#34;,&#34;213&#34;,&#34;214&#34;,&#34;215&#34;,&#34;216&#34;,&#34;217&#34;,&#34;218&#34;,&#34;219&#34;,&#34;220&#34;,&#34;221&#34;,&#34;222&#34;,&#34;223&#34;,&#34;224&#34;,&#34;225&#34;,&#34;226&#34;,&#34;227&#34;,&#34;228&#34;,&#34;229&#34;,&#34;230&#34;,&#34;231&#34;,&#34;232&#34;,&#34;233&#34;,&#34;234&#34;,&#34;235&#34;,&#34;236&#34;,&#34;237&#34;,&#34;238&#34;,&#34;239&#34;,&#34;240&#34;,&#34;241&#34;,&#34;242&#34;,&#34;243&#34;,&#34;244&#34;,&#34;245&#34;,&#34;246&#34;,&#34;247&#34;,&#34;248&#34;,&#34;249&#34;,&#34;250&#34;,&#34;251&#34;,&#34;252&#34;,&#34;253&#34;,&#34;254&#34;,&#34;255&#34;,&#34;256&#34;,&#34;257&#34;,&#34;258&#34;,&#34;259&#34;,&#34;260&#34;,&#34;261&#34;,&#34;262&#34;,&#34;263&#34;,&#34;264&#34;,&#34;265&#34;,&#34;266&#34;,&#34;267&#34;,&#34;268&#34;,&#34;269&#34;,&#34;270&#34;,&#34;271&#34;,&#34;272&#34;,&#34;273&#34;,&#34;274&#34;,&#34;275&#34;,&#34;276&#34;,&#34;277&#34;,&#34;278&#34;,&#34;279&#34;,&#34;280&#34;,&#34;281&#34;,&#34;282&#34;,&#34;283&#34;,&#34;284&#34;,&#34;285&#34;,&#34;286&#34;,&#34;287&#34;,&#34;288&#34;,&#34;289&#34;,&#34;290&#34;,&#34;291&#34;,&#34;292&#34;,&#34;293&#34;,&#34;294&#34;,&#34;295&#34;,&#34;296&#34;,&#34;297&#34;,&#34;298&#34;,&#34;299&#34;,&#34;300&#34;,&#34;301&#34;,&#34;302&#34;,&#34;303&#34;,&#34;304&#34;,&#34;305&#34;,&#34;306&#34;,&#34;307&#34;,&#34;308&#34;,&#34;309&#34;,&#34;310&#34;,&#34;311&#34;,&#34;312&#34;,&#34;313&#34;,&#34;314&#34;,&#34;315&#34;,&#34;316&#34;,&#34;317&#34;,&#34;318&#34;,&#34;319&#34;,&#34;320&#34;,&#34;321&#34;,&#34;322&#34;,&#34;323&#34;,&#34;324&#34;,&#34;325&#34;,&#34;326&#34;,&#34;327&#34;,&#34;328&#34;,&#34;329&#34;,&#34;330&#34;,&#34;331&#34;,&#34;332&#34;,&#34;333&#34;,&#34;334&#34;,&#34;335&#34;,&#34;336&#34;,&#34;337&#34;,&#34;338&#34;,&#34;339&#34;,&#34;340&#34;,&#34;341&#34;,&#34;342&#34;,&#34;343&#34;,&#34;344&#34;,&#34;345&#34;,&#34;346&#34;,&#34;347&#34;,&#34;348&#34;,&#34;349&#34;,&#34;350&#34;,&#34;351&#34;,&#34;352&#34;,&#34;353&#34;,&#34;354&#34;,&#34;355&#34;,&#34;356&#34;,&#34;357&#34;,&#34;358&#34;,&#34;359&#34;,&#34;360&#34;,&#34;361&#34;,&#34;362&#34;,&#34;363&#34;,&#34;364&#34;,&#34;365&#34;,&#34;366&#34;,&#34;367&#34;,&#34;368&#34;,&#34;369&#34;,&#34;370&#34;,&#34;371&#34;,&#34;372&#34;,&#34;373&#34;,&#34;374&#34;,&#34;375&#34;,&#34;376&#34;,&#34;377&#34;,&#34;378&#34;,&#34;379&#34;,&#34;380&#34;,&#34;381&#34;,&#34;382&#34;,&#34;383&#34;,&#34;384&#34;,&#34;385&#34;,&#34;386&#34;,&#34;387&#34;,&#34;388&#34;,&#34;389&#34;,&#34;390&#34;,&#34;391&#34;,&#34;392&#34;,&#34;393&#34;,&#34;394&#34;,&#34;395&#34;,&#34;396&#34;,&#34;397&#34;,&#34;398&#34;,&#34;399&#34;,&#34;400&#34;,&#34;401&#34;,&#34;402&#34;,&#34;403&#34;,&#34;404&#34;,&#34;405&#34;,&#34;406&#34;,&#34;407&#34;,&#34;408&#34;,&#34;409&#34;,&#34;410&#34;,&#34;411&#34;,&#34;412&#34;,&#34;413&#34;,&#34;414&#34;,&#34;415&#34;,&#34;416&#34;,&#34;417&#34;,&#34;418&#34;,&#34;419&#34;,&#34;420&#34;,&#34;421&#34;,&#34;422&#34;,&#34;423&#34;,&#34;424&#34;,&#34;425&#34;,&#34;426&#34;,&#34;427&#34;,&#34;428&#34;,&#34;429&#34;,&#34;430&#34;,&#34;431&#34;,&#34;432&#34;,&#34;433&#34;,&#34;434&#34;,&#34;435&#34;,&#34;436&#34;,&#34;437&#34;,&#34;438&#34;,&#34;439&#34;,&#34;440&#34;,&#34;441&#34;,&#34;442&#34;,&#34;443&#34;,&#34;444&#34;,&#34;445&#34;,&#34;446&#34;,&#34;447&#34;,&#34;448&#34;,&#34;449&#34;,&#34;450&#34;,&#34;451&#34;,&#34;452&#34;,&#34;453&#34;,&#34;454&#34;,&#34;455&#34;,&#34;456&#34;,&#34;457&#34;,&#34;458&#34;,&#34;459&#34;,&#34;460&#34;,&#34;461&#34;,&#34;462&#34;,&#34;463&#34;,&#34;464&#34;,&#34;465&#34;,&#34;466&#34;,&#34;467&#34;,&#34;468&#34;,&#34;469&#34;,&#34;470&#34;,&#34;471&#34;,&#34;472&#34;,&#34;473&#34;,&#34;474&#34;,&#34;475&#34;,&#34;476&#34;,&#34;477&#34;,&#34;478&#34;,&#34;479&#34;,&#34;480&#34;,&#34;481&#34;,&#34;482&#34;,&#34;483&#34;,&#34;484&#34;,&#34;485&#34;,&#34;486&#34;,&#34;487&#34;,&#34;488&#34;,&#34;489&#34;,&#34;490&#34;,&#34;491&#34;,&#34;492&#34;,&#34;493&#34;,&#34;494&#34;,&#34;495&#34;,&#34;496&#34;,&#34;497&#34;,&#34;498&#34;,&#34;499&#34;,&#34;500&#34;,&#34;501&#34;,&#34;502&#34;,&#34;503&#34;,&#34;504&#34;,&#34;505&#34;,&#34;506&#34;,&#34;507&#34;,&#34;508&#34;,&#34;509&#34;,&#34;510&#34;,&#34;511&#34;,&#34;512&#34;,&#34;513&#34;,&#34;514&#34;,&#34;515&#34;,&#34;516&#34;,&#34;517&#34;,&#34;518&#34;,&#34;519&#34;,&#34;520&#34;,&#34;521&#34;,&#34;522&#34;,&#34;523&#34;,&#34;524&#34;,&#34;525&#34;,&#34;526&#34;,&#34;527&#34;,&#34;528&#34;,&#34;529&#34;,&#34;530&#34;,&#34;531&#34;,&#34;532&#34;,&#34;533&#34;,&#34;534&#34;,&#34;535&#34;,&#34;536&#34;,&#34;537&#34;,&#34;538&#34;,&#34;539&#34;,&#34;540&#34;,&#34;541&#34;,&#34;542&#34;,&#34;543&#34;,&#34;544&#34;,&#34;545&#34;,&#34;546&#34;,&#34;547&#34;,&#34;548&#34;,&#34;549&#34;,&#34;550&#34;,&#34;551&#34;,&#34;552&#34;,&#34;553&#34;,&#34;554&#34;,&#34;555&#34;,&#34;556&#34;,&#34;557&#34;,&#34;558&#34;,&#34;559&#34;,&#34;560&#34;,&#34;561&#34;,&#34;562&#34;,&#34;563&#34;,&#34;564&#34;,&#34;565&#34;,&#34;566&#34;,&#34;567&#34;,&#34;568&#34;,&#34;569&#34;,&#34;570&#34;,&#34;571&#34;,&#34;572&#34;,&#34;573&#34;,&#34;574&#34;,&#34;575&#34;,&#34;576&#34;,&#34;577&#34;,&#34;578&#34;,&#34;579&#34;,&#34;580&#34;,&#34;581&#34;,&#34;582&#34;,&#34;583&#34;,&#34;584&#34;,&#34;585&#34;,&#34;586&#34;,&#34;587&#34;,&#34;588&#34;,&#34;589&#34;,&#34;590&#34;,&#34;591&#34;,&#34;592&#34;,&#34;593&#34;,&#34;594&#34;,&#34;595&#34;,&#34;596&#34;,&#34;597&#34;,&#34;598&#34;,&#34;599&#34;,&#34;600&#34;,&#34;601&#34;,&#34;602&#34;,&#34;603&#34;,&#34;604&#34;,&#34;605&#34;,&#34;606&#34;,&#34;607&#34;,&#34;608&#34;,&#34;609&#34;,&#34;610&#34;,&#34;611&#34;,&#34;612&#34;,&#34;613&#34;,&#34;614&#34;,&#34;615&#34;,&#34;616&#34;,&#34;617&#34;,&#34;618&#34;,&#34;619&#34;,&#34;620&#34;,&#34;621&#34;,&#34;622&#34;,&#34;623&#34;,&#34;624&#34;,&#34;625&#34;,&#34;626&#34;,&#34;627&#34;,&#34;628&#34;,&#34;629&#34;,&#34;630&#34;,&#34;631&#34;,&#34;632&#34;,&#34;633&#34;,&#34;634&#34;,&#34;635&#34;,&#34;636&#34;,&#34;637&#34;,&#34;638&#34;,&#34;639&#34;,&#34;640&#34;,&#34;641&#34;,&#34;642&#34;,&#34;643&#34;,&#34;644&#34;,&#34;645&#34;,&#34;646&#34;,&#34;647&#34;,&#34;648&#34;,&#34;649&#34;,&#34;650&#34;,&#34;651&#34;,&#34;652&#34;,&#34;653&#34;,&#34;654&#34;,&#34;655&#34;,&#34;656&#34;,&#34;657&#34;,&#34;658&#34;,&#34;659&#34;,&#34;660&#34;,&#34;661&#34;,&#34;662&#34;,&#34;663&#34;,&#34;664&#34;,&#34;665&#34;,&#34;666&#34;,&#34;667&#34;,&#34;668&#34;,&#34;669&#34;,&#34;670&#34;,&#34;671&#34;,&#34;672&#34;,&#34;673&#34;,&#34;674&#34;,&#34;675&#34;,&#34;676&#34;,&#34;677&#34;,&#34;678&#34;,&#34;679&#34;,&#34;680&#34;,&#34;681&#34;,&#34;682&#34;,&#34;683&#34;,&#34;684&#34;,&#34;685&#34;,&#34;686&#34;,&#34;687&#34;,&#34;688&#34;,&#34;689&#34;,&#34;690&#34;,&#34;691&#34;,&#34;692&#34;,&#34;693&#34;,&#34;694&#34;,&#34;695&#34;,&#34;696&#34;,&#34;697&#34;,&#34;698&#34;,&#34;699&#34;,&#34;700&#34;,&#34;701&#34;,&#34;702&#34;,&#34;703&#34;,&#34;704&#34;,&#34;705&#34;,&#34;706&#34;,&#34;707&#34;,&#34;708&#34;,&#34;709&#34;,&#34;710&#34;,&#34;711&#34;,&#34;712&#34;,&#34;713&#34;,&#34;714&#34;,&#34;715&#34;,&#34;716&#34;,&#34;717&#34;,&#34;718&#34;,&#34;719&#34;,&#34;720&#34;,&#34;721&#34;,&#34;722&#34;,&#34;723&#34;,&#34;724&#34;,&#34;725&#34;,&#34;726&#34;,&#34;727&#34;,&#34;728&#34;,&#34;729&#34;,&#34;730&#34;,&#34;731&#34;,&#34;732&#34;,&#34;733&#34;,&#34;734&#34;,&#34;735&#34;,&#34;736&#34;,&#34;737&#34;,&#34;738&#34;,&#34;739&#34;,&#34;740&#34;,&#34;741&#34;,&#34;742&#34;,&#34;743&#34;,&#34;744&#34;,&#34;745&#34;,&#34;746&#34;,&#34;747&#34;,&#34;748&#34;,&#34;749&#34;,&#34;750&#34;,&#34;751&#34;,&#34;752&#34;,&#34;753&#34;,&#34;754&#34;,&#34;755&#34;,&#34;756&#34;,&#34;757&#34;,&#34;758&#34;,&#34;759&#34;,&#34;760&#34;,&#34;761&#34;,&#34;762&#34;,&#34;763&#34;,&#34;764&#34;,&#34;765&#34;,&#34;766&#34;,&#34;767&#34;,&#34;768&#34;,&#34;769&#34;,&#34;770&#34;,&#34;771&#34;,&#34;772&#34;,&#34;773&#34;,&#34;774&#34;,&#34;775&#34;,&#34;776&#34;,&#34;777&#34;,&#34;778&#34;,&#34;779&#34;,&#34;780&#34;,&#34;781&#34;,&#34;782&#34;,&#34;783&#34;,&#34;784&#34;,&#34;785&#34;,&#34;786&#34;,&#34;787&#34;,&#34;788&#34;,&#34;789&#34;,&#34;790&#34;,&#34;791&#34;,&#34;792&#34;,&#34;793&#34;,&#34;794&#34;,&#34;795&#34;,&#34;796&#34;,&#34;797&#34;,&#34;798&#34;,&#34;799&#34;,&#34;800&#34;,&#34;801&#34;,&#34;802&#34;,&#34;803&#34;,&#34;804&#34;,&#34;805&#34;,&#34;806&#34;,&#34;807&#34;,&#34;808&#34;,&#34;809&#34;,&#34;810&#34;,&#34;811&#34;,&#34;812&#34;,&#34;813&#34;,&#34;814&#34;,&#34;815&#34;,&#34;816&#34;,&#34;817&#34;,&#34;818&#34;,&#34;819&#34;,&#34;820&#34;,&#34;821&#34;,&#34;822&#34;,&#34;823&#34;,&#34;824&#34;,&#34;825&#34;,&#34;826&#34;,&#34;827&#34;,&#34;828&#34;,&#34;829&#34;,&#34;830&#34;,&#34;831&#34;,&#34;832&#34;,&#34;833&#34;,&#34;834&#34;,&#34;835&#34;,&#34;836&#34;,&#34;837&#34;,&#34;838&#34;,&#34;839&#34;,&#34;840&#34;,&#34;841&#34;,&#34;842&#34;,&#34;843&#34;,&#34;844&#34;,&#34;845&#34;,&#34;846&#34;,&#34;847&#34;,&#34;848&#34;,&#34;849&#34;,&#34;850&#34;,&#34;851&#34;,&#34;852&#34;,&#34;853&#34;,&#34;854&#34;,&#34;855&#34;,&#34;856&#34;,&#34;857&#34;,&#34;858&#34;,&#34;859&#34;,&#34;860&#34;,&#34;861&#34;,&#34;862&#34;,&#34;863&#34;,&#34;864&#34;,&#34;865&#34;,&#34;866&#34;,&#34;867&#34;,&#34;868&#34;,&#34;869&#34;,&#34;870&#34;,&#34;871&#34;,&#34;872&#34;,&#34;873&#34;,&#34;874&#34;,&#34;875&#34;,&#34;876&#34;,&#34;877&#34;,&#34;878&#34;,&#34;879&#34;,&#34;880&#34;,&#34;881&#34;,&#34;882&#34;,&#34;883&#34;,&#34;884&#34;,&#34;885&#34;,&#34;886&#34;,&#34;887&#34;,&#34;888&#34;,&#34;889&#34;,&#34;890&#34;,&#34;891&#34;,&#34;892&#34;,&#34;893&#34;,&#34;894&#34;,&#34;895&#34;,&#34;896&#34;,&#34;897&#34;,&#34;898&#34;,&#34;899&#34;,&#34;900&#34;,&#34;901&#34;,&#34;902&#34;,&#34;903&#34;,&#34;904&#34;,&#34;905&#34;,&#34;906&#34;,&#34;907&#34;,&#34;908&#34;,&#34;909&#34;,&#34;910&#34;,&#34;911&#34;,&#34;912&#34;,&#34;913&#34;,&#34;914&#34;,&#34;915&#34;,&#34;916&#34;,&#34;917&#34;,&#34;918&#34;,&#34;919&#34;,&#34;920&#34;,&#34;921&#34;,&#34;922&#34;,&#34;923&#34;,&#34;924&#34;,&#34;925&#34;,&#34;926&#34;,&#34;927&#34;,&#34;928&#34;,&#34;929&#34;,&#34;930&#34;,&#34;931&#34;,&#34;932&#34;,&#34;933&#34;,&#34;934&#34;,&#34;935&#34;,&#34;936&#34;,&#34;937&#34;,&#34;938&#34;,&#34;939&#34;,&#34;940&#34;,&#34;941&#34;,&#34;942&#34;,&#34;943&#34;,&#34;944&#34;,&#34;945&#34;,&#34;946&#34;,&#34;947&#34;,&#34;948&#34;,&#34;949&#34;,&#34;950&#34;,&#34;951&#34;,&#34;952&#34;,&#34;953&#34;,&#34;954&#34;,&#34;955&#34;,&#34;956&#34;,&#34;957&#34;,&#34;958&#34;,&#34;959&#34;,&#34;960&#34;,&#34;961&#34;,&#34;962&#34;,&#34;963&#34;,&#34;964&#34;,&#34;965&#34;,&#34;966&#34;,&#34;967&#34;,&#34;968&#34;,&#34;969&#34;,&#34;970&#34;,&#34;971&#34;,&#34;972&#34;,&#34;973&#34;,&#34;974&#34;,&#34;975&#34;,&#34;976&#34;,&#34;977&#34;,&#34;978&#34;,&#34;979&#34;,&#34;980&#34;,&#34;981&#34;,&#34;982&#34;,&#34;983&#34;,&#34;984&#34;,&#34;985&#34;,&#34;986&#34;,&#34;987&#34;,&#34;988&#34;,&#34;989&#34;,&#34;990&#34;,&#34;991&#34;,&#34;992&#34;,&#34;993&#34;,&#34;994&#34;,&#34;995&#34;],[&#34;Abbey O&#39;Reilly DVM&#34;,&#34;Add Senger&#34;,&#34;Aden Lesch Sr.&#34;,&#34;Admiral Senger&#34;,&#34;Agness O&#39;Keefe&#34;,&#34;Aileen Barton&#34;,&#34;Ailene Hermann&#34;,&#34;Aiyanna Bruen PhD&#34;,&#34;Ala Schmidt DDS&#34;,&#34;Alannah Borer&#34;,&#34;Alcide Rohan&#34;,&#34;Aleena Berge&#34;,&#34;Alessandra Heaney&#34;,&#34;Alethea Blanda&#34;,&#34;Alex Armstrong&#34;,&#34;Alex Bergnaum&#34;,&#34;Alexis Cormier&#34;,&#34;Alf Lueilwitz&#34;,&#34;Alferd Ziemann&#34;,&#34;Alfred Metz&#34;,&#34;Almedia Yundt&#34;,&#34;Alpheus Wilkinson&#34;,&#34;Alphonse Champlin V&#34;,&#34;Alton Wintheiser&#34;,&#34;Alvah Bogisich&#34;,&#34;Alvera Balistreri&#34;,&#34;Alwina Wilkinson DDS&#34;,&#34;Alyssia Hickle&#34;,&#34;Amina Renner&#34;,&#34;Amit Langworth&#34;,&#34;Anabel Jakubowski PhD&#34;,&#34;Anastasia Howe&#34;,&#34;Anderson Quitzon&#34;,&#34;Andra Bosco&#34;,&#34;Andra Goodwin&#34;,&#34;Angeles McLaughlin PhD&#34;,&#34;Anie Hettinger&#34;,&#34;Anjelica Klocko&#34;,&#34;Antonio Bechtelar V&#34;,&#34;Ariane Hansen&#34;,&#34;Ariel Yundt&#34;,&#34;Arlie Brekke IV&#34;,&#34;Arlyn Dickinson&#34;,&#34;Arnett Waters&#34;,&#34;Arno Blick&#34;,&#34;Art Hyatt III&#34;,&#34;Aryan Bahringer&#34;,&#34;Asha Ankunding&#34;,&#34;Ashleigh Eichmann&#34;,&#34;Aubrey Witting&#34;,&#34;Aurthur Kirlin II&#34;,&#34;Auther Haley&#34;,&#34;Avah Schneider&#34;,&#34;Avery Bartoletti&#34;,&#34;Ayesha Carroll&#34;,&#34;Azariah Lubowitz&#34;,&#34;Azul Wehner&#34;,&#34;Barrett Turcotte DVM&#34;,&#34;Bartley Collier&#34;,&#34;Bascom Prosacco&#34;,&#34;Bea Considine&#34;,&#34;Beda Paucek&#34;,&#34;Benjamin Barton&#34;,&#34;Benji Jacobson&#34;,&#34;Bennett Gleason&#34;,&#34;Benson Schulist&#34;,&#34;Berkley Ernser DDS&#34;,&#34;Bernard Bruen&#34;,&#34;Bernetta O&#39;Conner&#34;,&#34;Bernhard Lind&#34;,&#34;Bertina Renner MD&#34;,&#34;Bessie Kub&#34;,&#34;Bethel Wunsch&#34;,&#34;Bilal Hahn&#34;,&#34;Blair Cormier&#34;,&#34;Blair Erdman PhD&#34;,&#34;Bobby Corwin&#34;,&#34;Bonny Breitenberg&#34;,&#34;Boyd Cronin&#34;,&#34;Bradford Bode&#34;,&#34;Braelyn King&#34;,&#34;Braiden Bogan&#34;,&#34;Braulio Haag MD&#34;,&#34;Brayan Terry&#34;,&#34;Braydon Lindgren&#34;,&#34;Brionna Miller&#34;,&#34;Britany O&#39;Hara&#34;,&#34;Britni Daugherty&#34;,&#34;Britton Brekke&#34;,&#34;Bronson Towne&#34;,&#34;Brooks Funk&#34;,&#34;Bryson Reinger&#34;,&#34;Bud Marquardt&#34;,&#34;Buddie Terry MD&#34;,&#34;Buford Pollich&#34;,&#34;Burke Boehm Sr.&#34;,&#34;Burke Connelly&#34;,&#34;Burns Mayer&#34;,&#34;Burr O&#39;Kon&#34;,&#34;Burton Kuvalis&#34;,&#34;Bush Macejkovic&#34;,&#34;Bush Schroeder&#34;,&#34;Butler Schmitt&#34;,&#34;Byrd Abshire&#34;,&#34;Byrd Kuhn MD&#34;,&#34;Cali Weimann&#34;,&#34;Cameron Abbott DDS&#34;,&#34;Candido Krajcik&#34;,&#34;Cari Renner PhD&#34;,&#34;Carlton Mante&#34;,&#34;Carlyn Mann&#34;,&#34;Carmel Emard&#34;,&#34;Carmella Schiller&#34;,&#34;Cary McGlynn&#34;,&#34;Casandra Krajcik&#34;,&#34;Case Weber&#34;,&#34;Casen Blick V&#34;,&#34;Casen Kuhlman&#34;,&#34;Caswell Anderson&#34;,&#34;Catalina Ortiz&#34;,&#34;Catharine Pacocha&#34;,&#34;Cathey Beatty&#34;,&#34;Cato Cartwright&#34;,&#34;Caylee Carroll&#34;,&#34;Celine Wisozk&#34;,&#34;Chadrick Williamson&#34;,&#34;Chantelle Gaylord&#34;,&#34;Charity Rodriguez&#34;,&#34;Charls Rempel DDS&#34;,&#34;Charolette Klein&#34;,&#34;Chase Skiles&#34;,&#34;Chastity Greenfelder PhD&#34;,&#34;Cherrelle Bartell&#34;,&#34;Christal Dooley&#34;,&#34;Christal Lakin DDS&#34;,&#34;Christi Connelly&#34;,&#34;Claire Terry&#34;,&#34;Claire Torp&#34;,&#34;Claudette Cummings DVM&#34;,&#34;Claus Bradtke&#34;,&#34;Clemens Torp&#34;,&#34;Cleveland Fay&#34;,&#34;Clovis Feil I&#34;,&#34;Coley Lind Sr.&#34;,&#34;Collie Greenholt&#34;,&#34;Collie Von MD&#34;,&#34;Con Altenwerth&#34;,&#34;Corda Towne&#34;,&#34;Corene Lind&#34;,&#34;Corey Bechtelar&#34;,&#34;Corrina Little DDS&#34;,&#34;Corrine Champlin&#34;,&#34;Cristen Hammes&#34;,&#34;Cristine Baumbach&#34;,&#34;Cristofer VonRueden&#34;,&#34;Cristy Ferry&#34;,&#34;Curtis Runolfsdottir&#34;,&#34;Daija Legros&#34;,&#34;Daisha Torphy&#34;,&#34;Damarcus Erdman II&#34;,&#34;Darci Schaefer&#34;,&#34;Darrell Heathcote&#34;,&#34;Darrian Bartell I&#34;,&#34;Darrion Stoltenberg&#34;,&#34;Darwyn Berge&#34;,&#34;Daryn Hickle&#34;,&#34;Dashawn Schroeder&#34;,&#34;Davian Ledner&#34;,&#34;Davian Stokes&#34;,&#34;Davie Hintz PhD&#34;,&#34;Davion Hudson&#34;,&#34;Davy Leuschke&#34;,&#34;Deann Dicki&#34;,&#34;Deasia Lockman MD&#34;,&#34;Deena Ziemann&#34;,&#34;Deion Auer&#34;,&#34;Delfina Watsica MD&#34;,&#34;Delia Witting&#34;,&#34;Dell Mitchell&#34;,&#34;Dellar Schroeder&#34;,&#34;Dema Beer&#34;,&#34;Dennie Powlowski&#34;,&#34;Deontae Effertz&#34;,&#34;Deonte Zemlak&#34;,&#34;Dereck Denesik DDS&#34;,&#34;Derek Witting&#34;,&#34;Desi Ortiz&#34;,&#34;Devante Gerhold&#34;,&#34;Devante O&#39;Hara&#34;,&#34;Devaughn Erdman V&#34;,&#34;Devon Osinski DVM&#34;,&#34;Devontae Swaniawski&#34;,&#34;Diandra Brakus DVM&#34;,&#34;Diego Gislason&#34;,&#34;Domingo Block&#34;,&#34;Dominick Jewess IV&#34;,&#34;Dominik Anderson&#34;,&#34;Dominique McKenzie&#34;,&#34;Donaciano Corwin&#34;,&#34;Donell Dach&#34;,&#34;Donie Stroman PhD&#34;,&#34;Donta Veum&#34;,&#34;Dorathy Nader&#34;,&#34;Dorcas Friesen&#34;,&#34;Dorr Lindgren&#34;,&#34;Dorris Jast&#34;,&#34;Doshia Stroman&#34;,&#34;Dow Halvorson&#34;,&#34;Dr. Aden Murphy&#34;,&#34;Dr. Alberto Kunze II&#34;,&#34;Dr. Alva Klocko&#34;,&#34;Dr. Arnoldo Grimes PhD&#34;,&#34;Dr. Arnoldo Marks&#34;,&#34;Dr. Barrie Bins&#34;,&#34;Dr. Bertrand Wolff&#34;,&#34;Dr. Bree Stehr DVM&#34;,&#34;Dr. Buffy Williamson&#34;,&#34;Dr. Camilo Kiehn&#34;,&#34;Dr. Carma Wyman&#34;,&#34;Dr. Charlton Kutch&#34;,&#34;Dr. Chas Cummerata Jr.&#34;,&#34;Dr. Cheyenne Dach DVM&#34;,&#34;Dr. Christal Wolff PhD&#34;,&#34;Dr. Collie Krajcik&#34;,&#34;Dr. Crawford Mayert&#34;,&#34;Dr. Darl Rice&#34;,&#34;Dr. Dell Baumbach III&#34;,&#34;Dr. Dillon Pollich DDS&#34;,&#34;Dr. Donal Auer DDS&#34;,&#34;Dr. Dustyn Rodriguez&#34;,&#34;Dr. Eddie Armstrong DDS&#34;,&#34;Dr. Eliezer Wuckert&#34;,&#34;Dr. Elroy Kirlin Jr.&#34;,&#34;Dr. Elzy Anderson&#34;,&#34;Dr. Erving Pagac Sr.&#34;,&#34;Dr. Ferd Stroman&#34;,&#34;Dr. Fleming Grant IV&#34;,&#34;Dr. Flint Zboncak&#34;,&#34;Dr. Franco Kemmer II&#34;,&#34;Dr. Fredrick Klein&#34;,&#34;Dr. Fronnie Kemmer&#34;,&#34;Dr. Gerard Bauch&#34;,&#34;Dr. Grady Beier DDS&#34;,&#34;Dr. Gussie McLaughlin III&#34;,&#34;Dr. Halley Johnston PhD&#34;,&#34;Dr. Hansel Steuber&#34;,&#34;Dr. Hildegard Murray&#34;,&#34;Dr. Hjalmar Langworth II&#34;,&#34;Dr. Hoke Jacobs&#34;,&#34;Dr. Howard Zulauf V&#34;,&#34;Dr. Humphrey Grant&#34;,&#34;Dr. Isaak Oberbrunner DVM&#34;,&#34;Dr. Ismael Stracke&#34;,&#34;Dr. Jaheem Pfannerstill III&#34;,&#34;Dr. Jaren Schmeler&#34;,&#34;Dr. Jeannie Rutherford&#34;,&#34;Dr. Jeff Bartoletti&#34;,&#34;Dr. Jeffie Johns&#34;,&#34;Dr. Jerod Berge Jr.&#34;,&#34;Dr. Jesse Schowalter&#34;,&#34;Dr. Jett Schaefer&#34;,&#34;Dr. Karissa Kerluke&#34;,&#34;Dr. Keenen Parker&#34;,&#34;Dr. Kelcie Yost MD&#34;,&#34;Dr. Kieth Wiegand&#34;,&#34;Dr. Kloe Parker DVM&#34;,&#34;Dr. Kyle Doyle II&#34;,&#34;Dr. Kyra Littel&#34;,&#34;Dr. Letta Daniel MD&#34;,&#34;Dr. Linn Schuppe&#34;,&#34;Dr. Lovett Legros DDS&#34;,&#34;Dr. Lucious Langosh&#34;,&#34;Dr. Lynn Gleason Jr.&#34;,&#34;Dr. Mallory Dooley MD&#34;,&#34;Dr. Matteo Little&#34;,&#34;Dr. Mazie Predovic MD&#34;,&#34;Dr. Mettie Green DVM&#34;,&#34;Dr. Micayla Kutch&#34;,&#34;Dr. Mike Legros&#34;,&#34;Dr. Myles Stroman&#34;,&#34;Dr. Ned Swaniawski&#34;,&#34;Dr. Nehemiah Kassulke&#34;,&#34;Dr. Niles Altenwerth II&#34;,&#34;Dr. Patti Rempel&#34;,&#34;Dr. Ras Kshlerin&#34;,&#34;Dr. Rayburn Wilkinson I&#34;,&#34;Dr. Rene Kuhlman DDS&#34;,&#34;Dr. Romeo Sauer PhD&#34;,&#34;Dr. Santana Schultz V&#34;,&#34;Dr. Shaniece Herzog PhD&#34;,&#34;Dr. Shea Buckridge PhD&#34;,&#34;Dr. Sherie Mayer&#34;,&#34;Dr. Shirl Cremin PhD&#34;,&#34;Dr. Skyler Windler Sr.&#34;,&#34;Dr. Tyreke DuBuque IV&#34;,&#34;Dr. Valentine Volkman DVM&#34;,&#34;Dr. Vic Bauch&#34;,&#34;Dr. Wilfredo Wisozk V&#34;,&#34;Dr. Willis Bahringer&#34;,&#34;Dr. Woodson Klein&#34;,&#34;Drew Rohan&#34;,&#34;Dudley Franecki&#34;,&#34;Dulce Wintheiser&#34;,&#34;Dwain Skiles Jr.&#34;,&#34;Dwan Wilderman&#34;,&#34;Dyllan Osinski&#34;,&#34;Ean Raynor&#34;,&#34;Earnest Rolfson&#34;,&#34;Ebb Doyle&#34;,&#34;Egbert McLaughlin&#34;,&#34;Elaine Emard&#34;,&#34;Elam Hirthe DVM&#34;,&#34;Elenora Trantow&#34;,&#34;Elgie Cole&#34;,&#34;Elgin Abbott&#34;,&#34;Elias Huels V&#34;,&#34;Elinor Howell&#34;,&#34;Elinore Doyle&#34;,&#34;Elizabet Schiller&#34;,&#34;Elizah Abbott&#34;,&#34;Elizbeth West&#34;,&#34;Eller Marquardt&#34;,&#34;Elmyra Schaefer&#34;,&#34;Elon Haag&#34;,&#34;Elsie Parker&#34;,&#34;Elza Gleichner&#34;,&#34;Emanuel Reichert&#34;,&#34;Emmaline Stark MD&#34;,&#34;Enid Reinger&#34;,&#34;Enos VonRueden&#34;,&#34;Epifanio Kozey&#34;,&#34;Erastus Macejkovic&#34;,&#34;Erla Schulist&#34;,&#34;Errol Bogisich&#34;,&#34;Esequiel Kirlin I&#34;,&#34;Esker Cormier&#34;,&#34;Essence Metz DDS&#34;,&#34;Ethyl Botsford&#34;,&#34;Etta Franecki MD&#34;,&#34;Etta Towne&#34;,&#34;Eugenie Conn PhD&#34;,&#34;Evelyn Schinner&#34;,&#34;Ewart Haag&#34;,&#34;Ewart Luettgen&#34;,&#34;Ewin Torphy&#34;,&#34;Exie Gutmann&#34;,&#34;Exie Shields&#34;,&#34;Ezzard Bernhard&#34;,&#34;Fannie Watsica&#34;,&#34;Fidel Kilback&#34;,&#34;Finnegan Franecki&#34;,&#34;Flem Kozey&#34;,&#34;Flo Gulgowski&#34;,&#34;Florine Jones&#34;,&#34;Floy Krajcik&#34;,&#34;Forest Pouros&#34;,&#34;Fount Flatley&#34;,&#34;Francisquita Heidenreich&#34;,&#34;Franz Mohr&#34;,&#34;Franz Powlowski&#34;,&#34;Friend Stracke&#34;,&#34;Gabriel Schiller&#34;,&#34;Garfield Hammes&#34;,&#34;Garrison Kling&#34;,&#34;Gayle Kuphal&#34;,&#34;Gaylen Kiehn&#34;,&#34;Gee Nitzsche&#34;,&#34;Geoffrey Reichert&#34;,&#34;Georgene Aufderhar PhD&#34;,&#34;Geralyn Rosenbaum&#34;,&#34;Geri Wuckert&#34;,&#34;Germaine Becker&#34;,&#34;Gerold Bernhard Jr.&#34;,&#34;Gianna Stiedemann&#34;,&#34;Gilmer Kertzmann&#34;,&#34;Gilmore Schmitt&#34;,&#34;Ginger Stamm&#34;,&#34;Ginger Wintheiser&#34;,&#34;Girtha Douglas&#34;,&#34;Giuseppe Tremblay&#34;,&#34;Glennis Howe&#34;,&#34;Gonzalo Jones&#34;,&#34;Gracia Wunsch&#34;,&#34;Gregg Franecki&#34;,&#34;Grisel Reichert MD&#34;,&#34;Gunner Wiegand&#34;,&#34;Haden Kautzer&#34;,&#34;Hakeem Leffler&#34;,&#34;Halbert Nolan&#34;,&#34;Hampton Rath&#34;,&#34;Handy Walsh&#34;,&#34;Hansel Kiehn&#34;,&#34;Hansford Moen PhD&#34;,&#34;Hardy Leannon&#34;,&#34;Harlon Rolfson&#34;,&#34;Harrie Swaniawski&#34;,&#34;Hassie Schiller PhD&#34;,&#34;Hattie Roberts&#34;,&#34;Helmer Monahan&#34;,&#34;Helyn Ondricka&#34;,&#34;Herman Kling I&#34;,&#34;Herschel Flatley&#34;,&#34;Hershel Shields&#34;,&#34;Hilma Little&#34;,&#34;Hiroshi Terry&#34;,&#34;Hobson Barton&#34;,&#34;Holland Lynch&#34;,&#34;Hosteen Jacobi&#34;,&#34;Howell Blick&#34;,&#34;Hughey Bartoletti DDS&#34;,&#34;Hurley Schiller I&#34;,&#34;Hyman Kemmer&#34;,&#34;Iesha Mraz&#34;,&#34;Iliana Donnelly&#34;,&#34;Imani Swift&#34;,&#34;Imelda Harber&#34;,&#34;Ingrid O&#39;Kon MD&#34;,&#34;Irwin Ritchie&#34;,&#34;Isabela Mertz MD&#34;,&#34;Isidore Skiles&#34;,&#34;Iverson Herman Sr.&#34;,&#34;Iverson Hilpert&#34;,&#34;Iverson Robel&#34;,&#34;Ivy Kohler&#34;,&#34;Iyanna Schmeler PhD&#34;,&#34;Izetta Stracke&#34;,&#34;Jabbar Dickens&#34;,&#34;Jacqueline Nikolaus&#34;,&#34;Jacquez Jacobs&#34;,&#34;Jadiel Wunsch&#34;,&#34;Jaime Nader&#34;,&#34;Jaliyah Purdy&#34;,&#34;Jammie Runolfsdottir&#34;,&#34;Janeen West&#34;,&#34;Janell Heller DVM&#34;,&#34;Janiyah Cassin&#34;,&#34;Jarred Stiedemann DDS&#34;,&#34;Jayden Hayes&#34;,&#34;Jayme Welch&#34;,&#34;Jayvion Cummings&#34;,&#34;Jazlyn Casper PhD&#34;,&#34;Jazmin Harvey&#34;,&#34;Jeanette Lind&#34;,&#34;Jeanie Berge&#34;,&#34;Jensen Cormier Jr.&#34;,&#34;Jerald Gaylord&#34;,&#34;Jerald Hintz&#34;,&#34;Jeraldine Waelchi&#34;,&#34;Jeremie Wehner V&#34;,&#34;Jerold Sporer&#34;,&#34;Jerrell Wisozk I&#34;,&#34;Jessica Connelly&#34;,&#34;Jessica Koepp MD&#34;,&#34;Jessy Emard&#34;,&#34;Jevon Rutherford&#34;,&#34;Jimmie Herzog&#34;,&#34;Joana Crist&#34;,&#34;Joana Kemmer DDS&#34;,&#34;Joann Yundt&#34;,&#34;Joe McDermott&#34;,&#34;Joelle Deckow&#34;,&#34;Johnathon Schimmel&#34;,&#34;Johney Mayer&#34;,&#34;Josef Lemke&#34;,&#34;Josephus Bradtke DVM&#34;,&#34;Josette Bailey&#34;,&#34;Juana Bogan&#34;,&#34;Judyth Lueilwitz&#34;,&#34;Jules Harber&#34;,&#34;Jules Jacobi&#34;,&#34;Julia Koch&#34;,&#34;Juliana Sipes&#34;,&#34;Juliet Terry&#34;,&#34;Julisa Halvorson&#34;,&#34;Kadence Morissette&#34;,&#34;Kalvin Prosacco&#34;,&#34;Kamren Moen&#34;,&#34;Kamron Halvorson&#34;,&#34;Karan Weber DVM&#34;,&#34;Karen Harvey&#34;,&#34;Karlie Treutel&#34;,&#34;Karon Torphy&#34;,&#34;Karren Funk&#34;,&#34;Karren Schuppe&#34;,&#34;Katlyn Mann&#34;,&#34;Katy King&#34;,&#34;Kelsey Pollich&#34;,&#34;Kem Medhurst II&#34;,&#34;Kendal Wiegand&#34;,&#34;Kendrick Boyle&#34;,&#34;Kenny Wisozk&#34;,&#34;Kenton Dickens&#34;,&#34;Keri Schuppe MD&#34;,&#34;Keri Williamson&#34;,&#34;Kingston Hayes&#34;,&#34;Kingston Waelchi&#34;,&#34;Kittie Dare&#34;,&#34;Kizzy Doyle&#34;,&#34;Kole Crooks&#34;,&#34;Kordell Hartmann&#34;,&#34;Korey Cronin&#34;,&#34;Kraig Hayes DDS&#34;,&#34;Krista Hartmann&#34;,&#34;Kristian Heaney&#34;,&#34;Kristy Kunde MD&#34;,&#34;Kyla Orn&#34;,&#34;Kylie Kertzmann&#34;,&#34;Lacy Connelly MD&#34;,&#34;Laddie Donnelly Sr.&#34;,&#34;Laisha VonRueden&#34;,&#34;Lakeshia Harris&#34;,&#34;Lane Roberts&#34;,&#34;Lani Dicki MD&#34;,&#34;Lashawn Hoppe&#34;,&#34;Lassie Lindgren&#34;,&#34;Latesha Bernhard&#34;,&#34;Latifah Carter&#34;,&#34;Latoya Stanton&#34;,&#34;Latrice Stokes&#34;,&#34;Laurel Morar&#34;,&#34;Laurene Considine&#34;,&#34;Lavern Pfeffer DDS&#34;,&#34;Leala Schuppe MD&#34;,&#34;Lennon Hilll&#34;,&#34;Leone Fritsch&#34;,&#34;Leonel Rippin&#34;,&#34;Lesa Hane&#34;,&#34;Lesta Carter&#34;,&#34;Lesta Davis&#34;,&#34;Letitia Stokes&#34;,&#34;Lexi Altenwerth&#34;,&#34;Leyla Dietrich&#34;,&#34;Lidie Gislason&#34;,&#34;Lilah Blanda PhD&#34;,&#34;Lillianna Larkin&#34;,&#34;Lim Langworth&#34;,&#34;Lindy Pagac&#34;,&#34;Link Carroll MD&#34;,&#34;Link Orn&#34;,&#34;Lionel Marquardt&#34;,&#34;Lisandro Kassulke&#34;,&#34;Lisandro Swift&#34;,&#34;Lisha Hayes&#34;,&#34;Lissa White&#34;,&#34;Livia Pfeffer&#34;,&#34;Lockie Fahey&#34;,&#34;Lollie Conroy&#34;,&#34;Lollie Heaney&#34;,&#34;Londyn Reinger&#34;,&#34;Lorean Stokes DVM&#34;,&#34;Lorelai Parisian&#34;,&#34;Loretta Lueilwitz&#34;,&#34;Loretto Romaguera&#34;,&#34;Lott Larkin&#34;,&#34;Louis Toy I&#34;,&#34;Lovisa Wilkinson&#34;,&#34;Loy Olson Sr.&#34;,&#34;Lucia Flatley&#34;,&#34;Luciano Kling&#34;,&#34;Luda Kihn&#34;,&#34;Luka Langosh&#34;,&#34;Lute Batz DVM&#34;,&#34;Luverne Rodriguez DDS&#34;,&#34;Lydia Willms&#34;,&#34;Lyn Parker&#34;,&#34;Lyndon McClure&#34;,&#34;Lyndsey Heidenreich&#34;,&#34;Mabell Lemke&#34;,&#34;Mac Kertzmann&#34;,&#34;Madison Koelpin&#34;,&#34;Madyson Bergnaum PhD&#34;,&#34;Mae O&#39;Kon&#34;,&#34;Maebell Terry&#34;,&#34;Magdalen Ward&#34;,&#34;Mahlon Pfeffer&#34;,&#34;Makenzie Hintz&#34;,&#34;Malaya White&#34;,&#34;Malcolm Bogan&#34;,&#34;Malcolm Heathcote&#34;,&#34;Malcolm Medhurst&#34;,&#34;Manilla Braun&#34;,&#34;Mansfield Boyle&#34;,&#34;Maralyn Greenfelder&#34;,&#34;Marcello Torphy Jr.&#34;,&#34;Marci Nader&#34;,&#34;Margarette Eichmann DVM&#34;,&#34;Margarita O&#39;Reilly&#34;,&#34;Marguerite Heaney&#34;,&#34;Mariano Lueilwitz&#34;,&#34;Marissa Goyette&#34;,&#34;Marla Sanford&#34;,&#34;Marlene Runolfsson&#34;,&#34;Marrion Emmerich IV&#34;,&#34;Marty Wisozk&#34;,&#34;Marvin Wisozk&#34;,&#34;Masao Deckow&#34;,&#34;Mason Rodriguez&#34;,&#34;Mathilda Farrell&#34;,&#34;Matthew Schmeler&#34;,&#34;Maudie Waelchi&#34;,&#34;Mauricio VonRueden&#34;,&#34;Maxie Steuber&#34;,&#34;Melbourne Johns&#34;,&#34;Melvin Schmidt&#34;,&#34;Mendy Ledner&#34;,&#34;Mervin Pfeffer V&#34;,&#34;Mervyn Vandervort&#34;,&#34;Michell Gerlach&#34;,&#34;Miguelangel Dach&#34;,&#34;Mila Gibson&#34;,&#34;Milissa Batz MD&#34;,&#34;Mimi Goldner&#34;,&#34;Miss Akeelah Walsh PhD&#34;,&#34;Miss Aleen Kunze&#34;,&#34;Miss Anaya Kerluke&#34;,&#34;Miss Chante Stoltenberg PhD&#34;,&#34;Miss Cristi Quitzon PhD&#34;,&#34;Miss Dorotha Kuvalis PhD&#34;,&#34;Miss Ela Treutel&#34;,&#34;Miss Eugenia Barton&#34;,&#34;Miss Evita Howe MD&#34;,&#34;Miss Fronnie Schaefer DDS&#34;,&#34;Miss Goldie Smitham&#34;,&#34;Miss Haleigh Wilkinson&#34;,&#34;Miss Halle Davis DDS&#34;,&#34;Miss Jonnie Veum&#34;,&#34;Miss Jovita Reinger&#34;,&#34;Miss Kacie Miller DVM&#34;,&#34;Miss Katelynn Lebsack DVM&#34;,&#34;Miss Katherine Balistreri DDS&#34;,&#34;Miss Kesha Daniel&#34;,&#34;Miss Lacey Sanford PhD&#34;,&#34;Miss Latosha O&#39;Keefe&#34;,&#34;Miss Lovie Keeling DVM&#34;,&#34;Miss Madison Lehner DVM&#34;,&#34;Miss Mistie Torp MD&#34;,&#34;Miss Nealy Stanton&#34;,&#34;Miss Tillie Crooks DVM&#34;,&#34;Miss Velma Schulist&#34;,&#34;Mittie Jacobs PhD&#34;,&#34;Mitzi Bergstrom&#34;,&#34;Moe Sawayn&#34;,&#34;Mohammad Smith&#34;,&#34;Monique Reichel&#34;,&#34;Mont Mertz&#34;,&#34;Morton O&#39;Connell&#34;,&#34;Mozell Greenfelder DDS&#34;,&#34;Mr. Alessandro Weissnat DDS&#34;,&#34;Mr. Almer Osinski&#34;,&#34;Mr. Armin Klocko IV&#34;,&#34;Mr. Brion Stark Sr.&#34;,&#34;Mr. Cayden Waters&#34;,&#34;Mr. Celestino Bosco&#34;,&#34;Mr. Christ Zieme MD&#34;,&#34;Mr. Cletus Corwin&#34;,&#34;Mr. Colin Prohaska&#34;,&#34;Mr. Dandre Nolan I&#34;,&#34;Mr. Demetric Franecki&#34;,&#34;Mr. Edw Frami&#34;,&#34;Mr. Elian Vandervort Jr.&#34;,&#34;Mr. Erin Zboncak IV&#34;,&#34;Mr. Fletcher Hudson&#34;,&#34;Mr. Fount Towne I&#34;,&#34;Mr. Francisco Kiehn&#34;,&#34;Mr. Fredric Funk III&#34;,&#34;Mr. Harris Pollich&#34;,&#34;Mr. Hosea Schiller&#34;,&#34;Mr. Hosie Howell PhD&#34;,&#34;Mr. Hunter Botsford Jr.&#34;,&#34;Mr. Hurley Brekke&#34;,&#34;Mr. Jeff Denesik&#34;,&#34;Mr. Jeramiah Cronin&#34;,&#34;Mr. Jimmy Mayert PhD&#34;,&#34;Mr. Junior Wintheiser II&#34;,&#34;Mr. Kenji Cormier&#34;,&#34;Mr. Kolten Wyman Jr.&#34;,&#34;Mr. Lary Champlin&#34;,&#34;Mr. Lillard McGlynn V&#34;,&#34;Mr. Lon Witting Jr.&#34;,&#34;Mr. Lupe Kohler&#34;,&#34;Mr. Manuel DuBuque&#34;,&#34;Mr. Marcelo Wunsch MD&#34;,&#34;Mr. Marcus Langosh&#34;,&#34;Mr. Marquise Swaniawski MD&#34;,&#34;Mr. Mekhi Goyette&#34;,&#34;Mr. Michal Murphy&#34;,&#34;Mr. Michale Howe DVM&#34;,&#34;Mr. Mikeal Block&#34;,&#34;Mr. Owens Gaylord&#34;,&#34;Mr. Paulo Stoltenberg&#34;,&#34;Mr. Ray Stanton III&#34;,&#34;Mr. Rohan Wolf&#34;,&#34;Mr. Saverio Weimann II&#34;,&#34;Mr. Semaj Sauer&#34;,&#34;Mr. Tad Johnson&#34;,&#34;Mr. Tegan Farrell MD&#34;,&#34;Mr. Thad Nader Sr.&#34;,&#34;Mr. Torry Bogan I&#34;,&#34;Mr. Tripp Batz PhD&#34;,&#34;Mr. Vito Ernser II&#34;,&#34;Mr. Wendel Hintz&#34;,&#34;Mr. Wilkie Moore MD&#34;,&#34;Mr. Zackery Armstrong&#34;,&#34;Mr. Zakary Gleichner II&#34;,&#34;Mrs. Alysa Cummings&#34;,&#34;Mrs. Anice O&#39;Hara DDS&#34;,&#34;Mrs. Astrid Bayer PhD&#34;,&#34;Mrs. Breann Harris&#34;,&#34;Mrs. Cali Considine&#34;,&#34;Mrs. Carolann Anderson PhD&#34;,&#34;Mrs. Charolette McDermott MD&#34;,&#34;Mrs. Chiquita Jacobs&#34;,&#34;Mrs. Cleone Hagenes DDS&#34;,&#34;Mrs. Danika Schulist&#34;,&#34;Mrs. Delisa Kilback&#34;,&#34;Mrs. Hildur Mante&#34;,&#34;Mrs. Ila Leuschke DVM&#34;,&#34;Mrs. Janel Koepp DVM&#34;,&#34;Mrs. Jaquelin Weber DVM&#34;,&#34;Mrs. Jerilynn Schulist&#34;,&#34;Mrs. Kelcie Schimmel&#34;,&#34;Mrs. Kyrie Funk&#34;,&#34;Mrs. Laila Bayer&#34;,&#34;Mrs. Lois Russel&#34;,&#34;Mrs. Lucetta Auer&#34;,&#34;Mrs. Madelyn Hermiston&#34;,&#34;Mrs. Makenna Bernier PhD&#34;,&#34;Mrs. Malaya Russel&#34;,&#34;Mrs. Marti Johnston&#34;,&#34;Mrs. Maura Schamberger&#34;,&#34;Mrs. Melany Mitchell DDS&#34;,&#34;Mrs. Michal Feil DVM&#34;,&#34;Mrs. Noma Hessel PhD&#34;,&#34;Mrs. Oneta Lebsack&#34;,&#34;Mrs. Trudy Rath&#34;,&#34;Mrs. Vernie Ryan MD&#34;,&#34;Mrs. Vivien Bauch&#34;,&#34;Ms. Amaris Williamson MD&#34;,&#34;Ms. Amira Gutkowski DDS&#34;,&#34;Ms. Arletta Jast PhD&#34;,&#34;Ms. Brea Nienow DDS&#34;,&#34;Ms. Delpha King&#34;,&#34;Ms. Elda Schmeler&#34;,&#34;Ms. Erica Gottlieb&#34;,&#34;Ms. Ermine Krajcik&#34;,&#34;Ms. Forest Hartmann DVM&#34;,&#34;Ms. Giada Weissnat&#34;,&#34;Ms. Gracelyn Dare&#34;,&#34;Ms. Gracie Willms&#34;,&#34;Ms. Grecia Schultz&#34;,&#34;Ms. Gussie Bartoletti&#34;,&#34;Ms. Hayleigh Swaniawski DDS&#34;,&#34;Ms. Hessie Gleichner&#34;,&#34;Ms. Hollie Crooks&#34;,&#34;Ms. Iliana O&#39;Conner&#34;,&#34;Ms. Jacklyn Casper&#34;,&#34;Ms. Katherine Schroeder&#34;,&#34;Ms. Katrina Barton PhD&#34;,&#34;Ms. Kelis Rau MD&#34;,&#34;Ms. Leaner Jacobs PhD&#34;,&#34;Ms. Liliana Haley&#34;,&#34;Ms. Maebell Reinger DVM&#34;,&#34;Ms. Marolyn Walsh&#34;,&#34;Ms. Merrilee Lueilwitz&#34;,&#34;Ms. Nada Barton PhD&#34;,&#34;Ms. Oralia Kilback&#34;,&#34;Ms. Penni Corkery&#34;,&#34;Ms. Peyton Larson DVM&#34;,&#34;Ms. Sarita Heidenreich DVM&#34;,&#34;Ms. Starr Corwin DDS&#34;,&#34;Ms. Val McKenzie PhD&#34;,&#34;Ms. Valorie Kling&#34;,&#34;Ms. Zola Nolan&#34;,&#34;Murl Dicki&#34;,&#34;Murl Wilkinson II&#34;,&#34;Murray Harvey&#34;,&#34;Myer Stokes&#34;,&#34;Mykel Johnson&#34;,&#34;Myrle Krajcik&#34;,&#34;Myrtis Larkin DDS&#34;,&#34;Naima Treutel&#34;,&#34;Nan O&#39;Connell&#34;,&#34;Nathaly Streich&#34;,&#34;Nathanael Wisozk&#34;,&#34;Neppie Armstrong&#34;,&#34;Nery Ankunding PhD&#34;,&#34;Nevin Boehm&#34;,&#34;Nico Dickinson&#34;,&#34;Nigel Leannon II&#34;,&#34;Nikita Becker&#34;,&#34;Nikolai Welch MD&#34;,&#34;Nikolas Shanahan&#34;,&#34;Nobie Hermann&#34;,&#34;Noma Dare MD&#34;,&#34;Nyree Walker&#34;,&#34;Odelia Rippin&#34;,&#34;Odessa Haag&#34;,&#34;Odie Jacobs&#34;,&#34;Odie Lakin&#34;,&#34;Odis Schoen&#34;,&#34;Olaf Witting&#34;,&#34;Olen Steuber DVM&#34;,&#34;Olena Kessler&#34;,&#34;Oley Schroeder I&#34;,&#34;Olof Swift&#34;,&#34;Omie Cummerata&#34;,&#34;Ophelia Ernser&#34;,&#34;Orpha Bernhard&#34;,&#34;Orville Lemke III&#34;,&#34;Ossie Schaden PhD&#34;,&#34;Ottis Wiza&#34;,&#34;Pansy Bergstrom&#34;,&#34;Parker Bailey DVM&#34;,&#34;Pat Nitzsche PhD&#34;,&#34;Patience Ferry&#34;,&#34;Paulo Torphy&#34;,&#34;Payten Morissette&#34;,&#34;Pearl Schmidt&#34;,&#34;Perley Renner&#34;,&#34;Pershing Johnston MD&#34;,&#34;Pershing Torp II&#34;,&#34;Peyton Koelpin&#34;,&#34;Peyton Runolfsson&#34;,&#34;Phylis Gaylord&#34;,&#34;Pierre Stoltenberg&#34;,&#34;Pink Murazik&#34;,&#34;Piper Buckridge&#34;,&#34;Pleasant Ullrich&#34;,&#34;Porsche Mayert DDS&#34;,&#34;Portia Schamberger&#34;,&#34;Posey Metz&#34;,&#34;Pratt Crooks&#34;,&#34;Price Harvey&#34;,&#34;Princess Hermann PhD&#34;,&#34;Prudie Kertzmann&#34;,&#34;Quintin Tillman&#34;,&#34;Rafael Mitchell&#34;,&#34;Raheem Bosco&#34;,&#34;Rakeem Harvey&#34;,&#34;Rayna Hagenes PhD&#34;,&#34;Reanna O&#39;Keefe&#34;,&#34;Rebeca Kling&#34;,&#34;Reggie Leffler&#34;,&#34;Regina Collins&#34;,&#34;Rexford Greenholt&#34;,&#34;Reynaldo Davis&#34;,&#34;Ricci Bins&#34;,&#34;Rice Prohaska&#34;,&#34;Rikki Watsica DVM&#34;,&#34;Riley Heller&#34;,&#34;Rob Wilderman Sr.&#34;,&#34;Robbin Herzog&#34;,&#34;Robert Satterfield&#34;,&#34;Robert Schmeler&#34;,&#34;Rochelle Johnson&#34;,&#34;Roger Green&#34;,&#34;Rolla Hodkiewicz&#34;,&#34;Rollie Yundt DVM&#34;,&#34;Roma Daniel&#34;,&#34;Roma Rath&#34;,&#34;Romaine McCullough&#34;,&#34;Romie Upton&#34;,&#34;Ronan McLaughlin&#34;,&#34;Roni Carter&#34;,&#34;Ronin Beatty Jr.&#34;,&#34;Rosanne Maggio&#34;,&#34;Rosario Boyle&#34;,&#34;Rose Kuphal&#34;,&#34;Rosevelt Murazik DDS&#34;,&#34;Rosina Abbott&#34;,&#34;Ruel Ruecker&#34;,&#34;Russell Boyle&#34;,&#34;Ruthe Macejkovic MD&#34;,&#34;Ryland Predovic&#34;,&#34;Sadie Upton&#34;,&#34;Saint Doyle&#34;,&#34;Samira Medhurst&#34;,&#34;Santana Bradtke&#34;,&#34;Savion Rohan&#34;,&#34;Schuyler Volkman&#34;,&#34;Scottie Beahan PhD&#34;,&#34;Seaborn Bogisich III&#34;,&#34;Shakira Stokes&#34;,&#34;Shane Haley&#34;,&#34;Shania Stamm DDS&#34;,&#34;Shantel Jenkins&#34;,&#34;Shari Rowe PhD&#34;,&#34;Sharyn Barrows&#34;,&#34;Shaun Rempel&#34;,&#34;Shea Feil&#34;,&#34;Shea Gerlach&#34;,&#34;Shellie Brekke III&#34;,&#34;Shelton Hudson&#34;,&#34;Sherlyn Gutmann&#34;,&#34;Shirl Keebler&#34;,&#34;Shirl Kuvalis&#34;,&#34;Shirl Wisozk&#34;,&#34;Shirlie Nikolaus&#34;,&#34;Shoji Wintheiser III&#34;,&#34;Skylar Hoeger&#34;,&#34;Sol Zboncak&#34;,&#34;Somer Turcotte&#34;,&#34;Sonny Dickens&#34;,&#34;Soren Gleason&#34;,&#34;Stafford Willms&#34;,&#34;Starling Welch&#34;,&#34;Stefani Kshlerin&#34;,&#34;Stephaine Graham&#34;,&#34;Stetson Ferry DVM&#34;,&#34;Susannah Bernier&#34;,&#34;Suzann Koss&#34;,&#34;Suzette Hartmann&#34;,&#34;Suzette Pollich&#34;,&#34;Sydell West&#34;,&#34;Sylva Littel&#34;,&#34;Symone McClure&#34;,&#34;Tallie Gleason&#34;,&#34;Tamia Hills&#34;,&#34;Tamia Langworth&#34;,&#34;Tamika Labadie&#34;,&#34;Tamisha Crooks&#34;,&#34;Tarik Marvin Jr.&#34;,&#34;Tate Turcotte&#34;,&#34;Tawanda Balistreri MD&#34;,&#34;Taylor Crist&#34;,&#34;Tegan O&#39;Conner&#34;,&#34;Tera Collins&#34;,&#34;Texas Keebler&#34;,&#34;Theo Buckridge&#34;,&#34;Thor Schultz&#34;,&#34;Tia Zulauf&#34;,&#34;Tierra Hayes&#34;,&#34;Tilden Hermann&#34;,&#34;Tisa Mosciski&#34;,&#34;Tobie Carroll&#34;,&#34;Toccara Lebsack&#34;,&#34;Tomika Koepp&#34;,&#34;Toney Marvin&#34;,&#34;Tori Bailey&#34;,&#34;Torrance Pollich&#34;,&#34;Torry Reynolds&#34;,&#34;Tracy Feest&#34;,&#34;Travis Cartwright&#34;,&#34;Tressie Buckridge DDS&#34;,&#34;Trina Gaylord DDS&#34;,&#34;Triston Mills&#34;,&#34;Trudie Mraz&#34;,&#34;Trudy Stokes&#34;,&#34;True Conroy&#34;,&#34;Tyshawn Witting&#34;,&#34;Uriah West&#34;,&#34;Uriel Kuhn&#34;,&#34;Valencia Keebler DVM&#34;,&#34;Vannie Kunze&#34;,&#34;Velda Goyette&#34;,&#34;Venice Smith&#34;,&#34;Verlene Emmerich&#34;,&#34;Verlin Christiansen Sr.&#34;,&#34;Verna Hudson&#34;,&#34;Vernell Lockman&#34;,&#34;Verona Langosh&#34;,&#34;Vic Volkman&#34;,&#34;Vick Okuneva&#34;,&#34;Vinson Tillman&#34;,&#34;Violette O&#39;Kon&#34;,&#34;Virgel Grimes&#34;,&#34;Vivian McLaughlin MD&#34;,&#34;Vivienne Medhurst&#34;,&#34;Von Cassin&#34;,&#34;Vonda Connelly&#34;,&#34;Waldemar Greenholt&#34;,&#34;Wally Nikolaus&#34;,&#34;Warner Kessler&#34;,&#34;Warren Osinski&#34;,&#34;Watt Cremin&#34;,&#34;Wellington Runolfsdottir&#34;,&#34;Wendi Purdy&#34;,&#34;Werner Hahn&#34;,&#34;William Sawayn&#34;,&#34;Willian Runte&#34;,&#34;Winifred Hills DDS&#34;,&#34;Winifred Kris&#34;,&#34;Wong Bradtke II&#34;,&#34;Woodie Gleichner&#34;,&#34;Yaakov Labadie&#34;,&#34;Yazmin Borer MD&#34;,&#34;Yessenia Rempel&#34;,&#34;Yetta Gorczany MD&#34;,&#34;Yoselin Bauch&#34;,&#34;Zackery Spinka&#34;,&#34;Zander Lebsack&#34;,&#34;Zechariah Gislason&#34;,&#34;Zenas Pacocha&#34;,&#34;Zeno Lakin&#34;,&#34;Zillah Koch PhD&#34;],[&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;Need Attention&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;About To Sleep&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Potential Loyalist&#34;,&#34;Potential Loyalist&#34;,&#34;Promising&#34;,&#34;Potential Loyalist&#34;,&#34;Can&#39;t Lose Them&#34;,&#34;About To Sleep&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;Others&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Need Attention&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Lost&#34;,&#34;Potential Loyalist&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Need Attention&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Others&#34;,&#34;Lost&#34;,&#34;Others&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;About To Sleep&#34;,&#34;Potential Loyalist&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;About To Sleep&#34;,&#34;Lost&#34;,&#34;About To Sleep&#34;,&#34;At Risk&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;About To Sleep&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Can&#39;t Lose Them&#34;,&#34;Lost&#34;,&#34;Potential Loyalist&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;About To Sleep&#34;,&#34;Lost&#34;,&#34;Promising&#34;,&#34;Potential Loyalist&#34;,&#34;Others&#34;,&#34;New Customers&#34;,&#34;Lost&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Need Attention&#34;,&#34;Potential Loyalist&#34;,&#34;Need Attention&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Promising&#34;,&#34;About To Sleep&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;New Customers&#34;,&#34;At Risk&#34;,&#34;At Risk&#34;,&#34;Lost&#34;,&#34;Others&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;Promising&#34;,&#34;At Risk&#34;,&#34;Can&#39;t Lose Them&#34;,&#34;Lost&#34;,&#34;Others&#34;,&#34;Lost&#34;,&#34;Others&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;About To Sleep&#34;,&#34;Others&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;About To Sleep&#34;,&#34;Others&#34;,&#34;About To Sleep&#34;,&#34;At Risk&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;Others&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;Potential Loyalist&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;Lost&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;About To Sleep&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;About To Sleep&#34;,&#34;About To Sleep&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Others&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;New Customers&#34;,&#34;Potential Loyalist&#34;,&#34;Others&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;Others&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;New Customers&#34;,&#34;Can&#39;t Lose Them&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;New Customers&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;About To Sleep&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;New Customers&#34;,&#34;About To Sleep&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Promising&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Promising&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;About To Sleep&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;About To Sleep&#34;,&#34;Potential Loyalist&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Potential Loyalist&#34;,&#34;Potential Loyalist&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;About To Sleep&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Lost&#34;,&#34;About To Sleep&#34;,&#34;Potential Loyalist&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;About To Sleep&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Others&#34;,&#34;Lost&#34;,&#34;About To Sleep&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;Potential Loyalist&#34;,&#34;New Customers&#34;,&#34;Lost&#34;,&#34;Potential Loyalist&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Can&#39;t Lose Them&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;Can&#39;t Lose Them&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;New Customers&#34;,&#34;Loyal Customers&#34;,&#34;About To Sleep&#34;,&#34;At Risk&#34;,&#34;At Risk&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Need Attention&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;About To Sleep&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;Others&#34;,&#34;At Risk&#34;,&#34;Lost&#34;,&#34;Need Attention&#34;,&#34;Others&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;Others&#34;,&#34;At Risk&#34;,&#34;Potential Loyalist&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;Promising&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;Promising&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Potential Loyalist&#34;,&#34;New Customers&#34;,&#34;Lost&#34;,&#34;Promising&#34;,&#34;Lost&#34;,&#34;New Customers&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;About To Sleep&#34;,&#34;Potential Loyalist&#34;,&#34;Potential Loyalist&#34;,&#34;Promising&#34;,&#34;Need Attention&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Promising&#34;,&#34;At Risk&#34;,&#34;At Risk&#34;,&#34;About To Sleep&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;Need Attention&#34;,&#34;At Risk&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;Lost&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Need Attention&#34;,&#34;Loyal Customers&#34;,&#34;Need Attention&#34;,&#34;At Risk&#34;,&#34;At Risk&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Need Attention&#34;,&#34;Loyal Customers&#34;,&#34;Promising&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Need Attention&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;About To Sleep&#34;,&#34;About To Sleep&#34;,&#34;Need Attention&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;Potential Loyalist&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Need Attention&#34;,&#34;Others&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;About To Sleep&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;At Risk&#34;,&#34;At Risk&#34;,&#34;At Risk&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;Potential Loyalist&#34;,&#34;About To Sleep&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;Potential Loyalist&#34;,&#34;About To Sleep&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;About To Sleep&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Can&#39;t Lose Them&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;About To Sleep&#34;,&#34;Lost&#34;,&#34;Need Attention&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Others&#34;,&#34;Lost&#34;,&#34;Potential Loyalist&#34;,&#34;Promising&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;At Risk&#34;,&#34;Others&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Others&#34;,&#34;Loyal Customers&#34;,&#34;Others&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;New Customers&#34;,&#34;At Risk&#34;,&#34;About To Sleep&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Potential Loyalist&#34;,&#34;Potential Loyalist&#34;,&#34;Others&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;Can&#39;t Lose Them&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;New Customers&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Promising&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;About To Sleep&#34;,&#34;Others&#34;,&#34;At Risk&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;About To Sleep&#34;,&#34;Others&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Lost&#34;,&#34;New Customers&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;New Customers&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Others&#34;,&#34;Need Attention&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;Others&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Can&#39;t Lose Them&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;About To Sleep&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;About To Sleep&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;Others&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;Lost&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Need Attention&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;At Risk&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;About To Sleep&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Others&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Potential Loyalist&#34;,&#34;Can&#39;t Lose Them&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;At Risk&#34;,&#34;Promising&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Can&#39;t Lose Them&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Need Attention&#34;,&#34;Need Attention&#34;,&#34;New Customers&#34;,&#34;Need Attention&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;At Risk&#34;,&#34;Lost&#34;,&#34;Promising&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;Need Attention&#34;,&#34;Others&#34;,&#34;At Risk&#34;,&#34;About To Sleep&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Others&#34;,&#34;Lost&#34;,&#34;About To Sleep&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;New Customers&#34;,&#34;At Risk&#34;,&#34;Need Attention&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Need Attention&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Others&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Others&#34;,&#34;Loyal Customers&#34;,&#34;Need Attention&#34;,&#34;At Risk&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;At Risk&#34;,&#34;At Risk&#34;,&#34;New Customers&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;At Risk&#34;,&#34;Potential Loyalist&#34;,&#34;Potential Loyalist&#34;,&#34;Potential Loyalist&#34;,&#34;About To Sleep&#34;,&#34;Promising&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Can&#39;t Lose Them&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Promising&#34;,&#34;Can&#39;t Lose Them&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Can&#39;t Lose Them&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;About To Sleep&#34;,&#34;Need Attention&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;Lost&#34;,&#34;Can&#39;t Lose Them&#34;,&#34;At Risk&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;About To Sleep&#34;,&#34;Lost&#34;,&#34;About To Sleep&#34;,&#34;At Risk&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;About To Sleep&#34;,&#34;Loyal Customers&#34;,&#34;About To Sleep&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;At Risk&#34;,&#34;About To Sleep&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Potential Loyalist&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;Can&#39;t Lose Them&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Need Attention&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Others&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Need Attention&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Others&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;Potential Loyalist&#34;,&#34;About To Sleep&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;At Risk&#34;,&#34;Others&#34;,&#34;About To Sleep&#34;,&#34;At Risk&#34;,&#34;Need Attention&#34;,&#34;Loyal Customers&#34;,&#34;Need Attention&#34;,&#34;Potential Loyalist&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Potential Loyalist&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;At Risk&#34;,&#34;Others&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Others&#34;,&#34;Potential Loyalist&#34;,&#34;Potential Loyalist&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;At Risk&#34;,&#34;Others&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Others&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;Need Attention&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;About To Sleep&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Others&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Others&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Others&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Need Attention&#34;,&#34;About To Sleep&#34;,&#34;At Risk&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Can&#39;t Lose Them&#34;,&#34;Others&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Promising&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;About To Sleep&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;Promising&#34;,&#34;Potential Loyalist&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;About To Sleep&#34;,&#34;Lost&#34;,&#34;Potential Loyalist&#34;,&#34;At Risk&#34;,&#34;Potential Loyalist&#34;,&#34;Lost&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;At Risk&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Lost&#34;,&#34;Need Attention&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;About To Sleep&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Others&#34;,&#34;At Risk&#34;,&#34;Others&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Others&#34;,&#34;At Risk&#34;,&#34;Lost&#34;,&#34;Loyal Customers&#34;,&#34;Need Attention&#34;,&#34;About To Sleep&#34;,&#34;Loyal Customers&#34;,&#34;Promising&#34;,&#34;About To Sleep&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;About To Sleep&#34;,&#34;At Risk&#34;,&#34;Lost&#34;,&#34;At Risk&#34;,&#34;Potential Loyalist&#34;,&#34;Others&#34;,&#34;At Risk&#34;,&#34;At Risk&#34;,&#34;Loyal Customers&#34;,&#34;Loyal Customers&#34;,&#34;At Risk&#34;,&#34;Lost&#34;,&#34;At Risk&#34;],[343,412,323,433,555,555,355,321,212,121,433,523,411,421,144,311,455,344,335,345,423,244,342,233,354,434,345,333,334,211,443,223,112,421,521,112,212,224,112,244,455,233,544,332,523,345,324,211,425,521,455,555,445,322,533,433,111,322,111,311,234,111,334,111,311,345,355,555,522,422,544,255,211,111,335,355,211,144,212,532,433,233,312,122,411,422,542,511,212,521,111,444,132,344,523,112,543,333,422,323,313,344,445,513,334,234,555,554,455,434,411,311,345,334,455,544,223,511,134,245,112,342,432,344,544,532,112,233,411,224,145,111,542,112,213,512,445,312,442,123,345,555,312,213,312,244,212,355,521,111,113,344,233,344,344,111,234,523,532,234,111,422,555,445,211,222,111,322,423,222,311,322,211,211,423,122,545,522,211,543,521,234,444,534,524,135,444,135,511,523,114,122,111,331,134,324,555,234,555,412,511,145,533,134,334,124,511,245,544,345,334,313,444,523,111,244,212,222,544,422,111,433,455,445,121,223,512,132,322,242,543,444,532,443,511,312,111,222,355,343,112,422,234,433,212,222,345,411,435,111,411,331,134,444,513,123,555,354,243,545,112,111,554,244,322,522,355,222,445,311,433,422,211,211,522,532,413,555,311,111,343,111,244,244,535,143,112,312,423,422,443,444,322,543,345,555,555,212,544,424,211,312,121,245,412,511,111,423,432,543,222,144,455,433,111,145,245,544,511,543,311,123,255,111,555,212,333,432,555,111,111,534,512,111,455,522,255,354,255,444,112,211,454,111,513,544,311,242,344,523,142,342,223,122,333,113,455,111,123,211,244,213,234,512,533,123,411,112,443,533,111,223,411,545,135,432,511,122,411,111,511,533,344,322,432,521,411,332,111,444,445,443,345,411,244,132,311,433,212,333,244,244,445,544,343,111,143,122,331,555,245,333,443,333,244,243,255,445,555,323,544,411,455,245,323,544,455,343,211,235,322,311,332,532,111,211,222,243,111,555,133,535,555,124,334,422,412,412,553,443,545,243,533,344,212,333,524,455,111,212,533,223,311,533,224,234,133,134,111,255,431,322,211,455,444,445,212,255,522,321,532,234,212,244,345,344,513,322,445,522,344,155,334,455,312,112,323,455,532,212,211,445,121,113,221,521,411,221,211,555,142,234,542,233,555,355,424,555,324,431,255,224,344,244,222,234,511,255,311,454,224,433,512,342,455,533,222,144,111,111,235,543,522,243,211,112,111,111,555,555,355,111,511,243,545,212,444,222,544,222,223,223,344,455,534,334,255,444,513,313,555,411,522,111,111,111,544,434,523,322,214,244,423,543,543,312,424,522,244,445,554,334,443,232,112,511,212,345,523,112,132,511,412,545,424,333,112,344,522,124,524,223,445,212,111,245,433,545,212,355,144,544,134,355,454,455,311,455,543,322,543,334,345,532,143,542,211,445,211,422,211,111,344,122,412,212,533,444,455,143,355,421,445,544,111,245,111,423,555,332,545,111,544,111,211,535,255,233,112,211,322,544,123,214,412,135,455,111,313,245,455,211,512,155,222,434,255,132,411,112,455,145,334,555,355,332,333,511,333,533,545,111,223,544,555,243,455,234,233,111,411,421,112,233,333,213,243,321,422,445,444,134,524,111,311,423,223,511,233,333,111,233,245,345,244,443,545,332,111,445,544,555,455,255,111,112,542,544,124,442,455,323,242,133,344,533,244,445,534,123,244,245,511,111,544,343,544,244,223,421,422,433,322,411,445,434,145,353,245,423,434,411,145,112,111,123,545,154,534,423,321,332,122,224,111,144,134,112,211,434,311,111,311,244,533,121,344,455,311,544,321,533,143,422,344,111,313,234,243,311,111,111,422,331,111,211,112,245,144,545,355,332,211,111,554,555,113,421,255,124,555,455,233,332,334,112,121,542,544,423,111,222,422,311,344,123,123,113,321,143,333,454,323,422,423,544,234,523,433,244,433,112,255,234,424,344,245,455,555,454,314,413,533,433,355,123,234,442,423,444,345,113,455,555,522,333,122,345,432,321,111,355,342,555,112,444,344,524,111,545,342,343,223,344,445,323,312,235,111,445,544,144,113,523,344,411,112,135,543,512,444,455,111,321,255,343,344,334,411,512,444,121,555,223,312,222,533,255,533,111,111,134,232,255,443,111,332,223,535,311,133,543,524,123,324,435,244,113,232,112,355,333,322,455,411,311,134,444,234,445,434,243,312,232,111,135,421,442,255,243,344,355,223,111,124],[6,3,4,5,9,9,8,4,3,4,5,4,1,4,6,1,8,7,5,7,4,6,7,5,8,5,6,5,5,2,6,4,3,4,4,2,3,4,3,6,10,5,7,5,4,6,4,3,4,4,9,9,7,4,5,5,1,4,2,3,5,2,5,2,1,7,9,8,4,4,6,9,3,2,5,8,3,6,3,5,5,5,3,4,1,4,7,3,3,4,2,6,5,7,4,3,6,5,4,4,3,6,7,3,5,5,8,8,8,5,2,3,6,5,10,6,4,2,5,7,3,6,5,7,7,5,3,5,2,4,6,3,6,3,3,3,6,3,6,4,7,8,3,3,3,6,2,8,4,2,3,6,5,6,6,1,5,4,5,5,2,4,8,6,2,4,2,4,4,4,2,4,3,1,4,4,6,4,2,6,4,5,7,5,4,5,7,5,3,4,3,4,3,5,5,4,10,5,8,3,2,7,5,5,5,4,3,6,7,7,5,3,6,4,1,7,3,4,7,4,2,5,9,7,4,4,3,5,4,7,6,6,5,6,3,3,2,4,12,6,3,4,5,5,3,4,7,2,5,1,2,5,5,6,3,4,8,8,6,6,3,1,8,7,4,4,8,4,7,3,5,4,3,1,4,5,3,10,1,2,6,1,7,7,5,6,3,3,4,4,6,7,4,6,7,8,9,3,6,4,2,2,4,6,3,1,2,4,5,6,4,6,9,5,2,7,6,7,2,6,2,4,12,1,8,3,5,5,9,3,1,5,3,1,12,4,8,8,8,6,2,2,10,2,2,7,3,6,7,4,6,6,4,4,5,3,11,3,4,1,6,3,5,3,5,4,2,3,6,5,1,4,2,7,5,5,3,4,3,3,3,5,6,4,5,4,2,5,2,6,7,6,7,3,7,5,2,5,3,5,6,6,6,7,6,1,6,4,5,10,6,5,6,5,6,6,9,6,13,4,6,2,9,7,4,7,10,7,2,5,4,3,5,5,3,2,4,7,1,9,5,5,10,4,5,4,3,3,8,6,7,7,5,7,2,5,4,8,2,3,5,4,3,5,4,5,5,5,2,9,5,4,2,12,7,7,3,8,4,4,5,5,3,6,7,6,3,4,6,4,6,8,5,9,3,3,4,13,5,2,2,6,4,3,4,4,2,4,3,9,7,5,6,5,8,8,4,10,4,5,9,4,6,6,4,5,3,9,3,8,4,5,3,6,9,5,4,7,1,1,5,6,4,6,2,3,2,1,9,9,9,1,2,6,6,3,6,4,6,4,4,4,6,11,5,5,9,7,3,3,8,3,4,2,3,2,6,5,4,4,3,6,4,6,6,3,4,4,6,7,9,5,7,5,3,3,3,7,4,2,5,2,3,6,4,5,3,7,4,4,4,4,7,2,1,6,5,7,3,9,6,6,5,10,8,8,3,10,7,4,6,5,6,5,6,6,3,7,3,4,3,2,6,4,3,3,5,7,10,6,8,4,7,7,2,7,1,4,10,5,6,2,6,2,3,5,9,5,2,2,4,6,4,3,3,5,14,2,3,7,9,1,3,8,4,5,8,5,3,3,11,6,5,8,10,5,5,2,5,5,6,2,4,7,9,7,8,5,5,3,1,4,3,5,5,3,6,4,4,7,7,5,4,2,3,4,4,3,5,5,1,5,7,7,6,6,7,5,2,7,6,12,8,8,1,3,6,6,4,6,8,4,6,5,6,5,6,7,5,4,7,6,3,1,7,6,6,6,4,4,4,5,4,2,7,5,7,8,6,4,5,2,6,3,1,4,6,8,5,4,4,5,4,4,3,6,5,3,2,5,2,1,2,6,5,4,6,9,3,7,4,5,7,4,6,2,3,5,6,2,2,1,4,5,2,2,3,7,6,7,10,5,3,1,8,9,3,4,10,4,8,8,5,5,5,3,4,6,7,4,1,4,4,3,7,4,4,3,4,6,5,8,4,4,4,7,5,4,5,7,5,2,9,5,4,6,7,8,10,10,3,3,5,5,9,4,5,6,4,6,7,3,8,9,4,5,4,7,5,4,3,10,6,9,3,7,7,4,3,6,6,6,4,6,7,4,3,5,1,7,6,6,3,4,6,2,3,5,6,3,6,8,2,4,9,6,6,5,2,3,7,4,8,4,3,4,5,8,5,3,3,5,5,9,6,3,5,4,5,1,5,6,4,4,4,5,6,3,5,2,9,5,4,10,1,2,5,6,5,7,5,6,3,5,1,5,4,6,8,6,6,9,4,1,4],[205,140,194,132,90,84,281,246,349,619,138,102,168,157,482,239,150,202,245,245,146,405,214,475,191,127,227,209,215,414,164,339,676,156,12,937,444,458,666,455,126,327,39,210,46,274,286,399,162,53,116,57,122,183,35,179,932,186,872,253,312,488,181,632,202,217,269,72,114,152,5,457,331,588,250,181,365,573,298,13,170,479,186,601,176,174,18,62,363,89,497,175,521,294,101,578,41,266,172,259,203,236,122,59,225,473,108,71,180,164,172,182,200,222,144,77,391,27,499,426,601,250,144,240,95,46,526,350,155,474,525,506,84,537,458,114,167,280,140,676,221,88,268,307,261,462,463,183,59,846,592,265,392,265,229,559,431,30,82,446,583,160,48,176,480,352,589,199,143,430,251,295,430,392,137,847,10,17,359,39,23,467,135,95,9,556,154,529,81,99,545,508,557,224,511,186,20,332,12,146,92,515,101,655,208,629,102,317,98,210,267,282,129,4,870,376,298,445,44,135,510,153,116,144,504,433,80,558,284,439,64,130,28,168,62,183,686,327,260,199,531,173,408,132,399,393,213,119,133,569,164,228,491,153,102,511,81,294,422,29,589,700,57,481,210,113,183,334,161,200,151,116,476,399,93,99,179,32,186,485,208,534,380,462,78,561,515,276,131,148,166,172,201,102,210,81,64,477,42,152,432,222,490,481,174,47,499,148,170,63,480,652,172,172,575,569,320,83,62,102,187,488,326,696,13,457,269,129,7,629,493,80,77,684,159,33,379,252,481,134,548,317,168,528,98,103,227,423,181,94,572,182,379,509,272,613,146,734,527,427,456,416,433,28,20,652,176,548,122,80,599,444,126,30,582,125,34,633,165,577,101,100,225,225,150,96,171,264,516,127,116,134,186,136,449,636,187,122,331,277,371,379,179,65,239,516,486,545,245,73,442,203,131,251,443,455,463,159,97,189,106,161,160,356,182,106,160,280,375,343,191,241,276,66,488,360,372,478,760,53,512,34,41,539,236,173,179,146,50,135,113,352,88,281,391,265,67,153,604,390,101,455,272,48,374,449,505,662,673,453,171,190,410,127,144,129,336,403,67,249,61,398,449,381,297,246,48,287,137,8,182,575,206,180,190,533,233,168,92,478,479,171,695,681,350,90,117,466,352,27,549,372,112,469,63,195,146,21,181,172,311,426,193,431,359,307,77,427,239,175,399,118,94,202,148,106,446,494,955,976,312,97,105,417,436,509,578,568,45,82,186,651,84,472,48,471,151,309,101,304,412,333,279,116,68,270,384,164,43,231,85,168,107,533,507,497,86,140,9,275,372,465,162,4,48,220,127,114,400,120,93,230,149,354,553,6,469,242,110,720,509,113,173,73,142,222,723,279,16,486,75,468,160,396,687,316,152,55,397,218,632,51,498,198,132,148,200,169,99,288,79,284,197,103,583,103,441,164,464,119,375,522,201,532,125,409,37,174,123,482,229,120,133,111,558,479,951,149,44,195,26,600,8,620,439,21,410,421,613,444,235,6,512,429,177,495,124,588,295,299,126,446,98,569,416,136,430,526,123,487,144,502,263,31,206,295,282,107,291,13,87,836,341,43,1,360,141,310,349,590,139,158,537,443,263,431,392,285,147,116,142,502,72,632,229,122,410,93,377,266,681,463,298,258,387,159,109,241,576,130,90,43,129,340,595,538,102,112,504,164,172,289,414,493,194,105,407,136,86,647,473,443,90,699,114,182,98,433,305,171,122,155,224,178,135,145,491,276,335,132,150,143,525,636,607,574,86,616,63,140,192,264,597,475,550,488,586,484,442,150,191,520,214,402,88,519,281,153,215,44,244,88,852,162,249,892,296,446,427,296,490,604,174,210,618,449,601,319,496,49,183,182,411,597,88,64,550,124,454,538,35,129,455,234,196,681,535,71,43,171,624,366,135,243,204,663,564,600,229,490,232,145,289,128,146,67,417,69,139,339,176,614,373,436,151,190,430,152,84,160,275,178,75,157,188,724,426,155,180,176,201,591,153,19,90,276,630,210,140,282,508,190,250,103,506,128,186,105,500,33,288,291,335,191,178,207,227,443,576,138,11,585,516,103,261,177,546,484,15,38,149,128,545,229,344,209,249,212,129,54,135,530,45,404,198,332,89,472,40,573,653,542,328,397,151,484,240,389,106,236,539,102,52,490,246,173,416,517,402,515,267,181,290,129,127,265,490,169,321,157,180,452,287,395,582,549,163,120,346,387,204,207,405,524,548],[472,340,405,448,843,763,699,157,363,196,500,393,28,245,634,175,786,596,697,703,436,597,367,392,598,539,712,387,663,253,443,425,287,225,202,316,325,589,336,507,1069,434,600,341,388,803,527,81,681,229,856,878,777,370,390,425,190,319,141,211,527,198,552,94,37,764,696,875,276,375,528,977,190,241,733,845,246,531,318,330,435,470,381,338,188,374,330,226,336,161,96,580,323,635,492,316,465,419,381,393,442,639,689,456,532,533,723,613,787,522,171,143,721,520,968,564,407,186,559,837,346,343,314,636,596,281,293,420,187,602,728,222,277,311,491,295,775,353,313,435,950,790,312,439,342,612,271,1018,218,237,484,510,402,620,615,172,566,432,371,589,198,316,819,766,62,364,244,291,385,363,172,356,205,185,422,328,668,323,231,460,251,581,544,586,633,674,626,713,166,384,579,274,211,198,532,575,1249,615,892,260,97,792,456,648,583,549,123,836,596,669,548,398,567,446,120,607,353,281,620,360,169,406,1007,704,222,392,270,284,370,265,433,529,363,448,244,298,172,277,1065,471,363,282,542,471,266,333,672,114,708,113,138,228,521,641,421,416,771,665,392,714,366,57,532,646,350,289,889,259,688,111,420,265,114,33,311,283,464,834,23,187,457,111,644,625,672,489,355,312,390,308,420,654,326,472,690,1068,850,332,665,515,230,375,203,805,268,155,77,433,307,466,301,546,826,476,233,841,746,531,194,431,183,401,1150,32,839,268,421,282,792,99,43,519,270,81,768,283,722,526,892,581,286,91,595,252,424,651,251,317,648,411,263,365,416,269,484,455,937,72,430,169,571,420,644,294,460,489,165,301,464,393,86,400,149,759,677,353,248,340,143,162,188,450,662,317,260,234,236,332,95,619,758,416,1004,236,603,363,119,436,264,384,578,518,819,513,434,102,499,300,235,1036,687,455,466,486,546,474,922,694,1104,410,584,149,880,719,473,523,1060,434,87,714,276,249,374,374,203,75,291,435,23,1090,403,874,1062,570,556,275,286,359,488,506,764,438,450,653,268,401,552,806,223,317,479,436,101,391,520,663,416,552,77,935,236,314,218,987,613,751,274,829,276,229,318,554,353,549,698,653,473,275,712,347,630,872,528,741,347,292,441,1488,332,260,82,781,155,479,242,251,209,113,196,1003,309,585,356,437,775,724,601,814,574,230,1008,632,512,621,375,515,157,773,152,536,655,485,285,358,1011,424,306,648,61,133,730,479,340,492,139,284,94,28,782,708,788,79,237,437,711,311,560,289,587,371,482,505,582,713,639,575,1050,583,438,388,965,249,258,184,166,252,546,565,431,350,513,640,401,464,494,345,649,265,540,693,637,554,490,347,356,239,270,736,422,277,371,181,260,673,523,463,294,654,316,620,643,404,779,320,104,805,425,958,336,753,579,573,631,900,665,770,243,1027,382,357,447,652,854,348,475,303,248,709,224,292,188,176,600,360,261,258,417,591,862,492,852,232,716,510,81,700,30,387,868,332,895,165,540,133,228,734,840,496,267,175,326,547,382,529,359,668,1074,96,413,716,927,52,363,799,350,548,740,323,172,308,816,820,534,806,1184,378,480,195,446,461,798,244,490,615,876,469,687,599,416,217,82,144,331,495,476,386,396,253,332,888,536,520,516,166,128,446,386,209,409,434,12,390,815,777,547,422,676,289,191,720,580,1233,744,829,106,311,346,548,556,357,885,489,368,400,613,415,566,774,537,458,589,673,180,185,576,480,620,664,462,228,380,421,375,233,936,646,826,453,937,423,613,79,681,343,219,425,694,569,579,462,212,268,353,597,211,585,641,353,132,512,143,39,163,632,453,220,622,955,147,600,242,394,476,306,644,219,466,536,406,108,241,89,335,185,82,225,265,1089,515,762,1060,300,137,55,580,960,421,182,809,587,960,956,413,360,570,358,210,319,581,446,34,381,317,254,652,468,409,467,197,420,405,622,496,365,434,597,512,400,447,652,436,265,805,665,541,558,826,732,1118,658,538,459,438,424,997,388,665,292,427,588,760,384,867,726,377,450,363,688,329,255,88,1018,362,1061,295,590,520,609,237,754,353,427,395,642,778,449,293,694,103,839,627,510,394,393,643,199,324,702,446,274,522,952,96,159,870,433,542,558,121,377,650,253,713,504,264,366,474,855,471,208,195,567,369,823,473,219,359,491,789,153,492,492,569,454,565,675,574,390,350,297,859,419,310,1038,52,39,560,594,570,754,618,459,280,277,91,716,236,378,760,406,574,1196,442,38,516],[3,4,3,4,5,5,3,3,2,1,4,5,4,4,1,3,4,3,3,3,4,2,3,2,3,4,3,3,3,2,4,2,1,4,5,1,2,2,1,2,4,2,5,3,5,3,3,2,4,5,4,5,4,3,5,4,1,3,1,3,2,1,3,1,3,3,3,5,5,4,5,2,2,1,3,3,2,1,2,5,4,2,3,1,4,4,5,5,2,5,1,4,1,3,5,1,5,3,4,3,3,3,4,5,3,2,5,5,4,4,4,3,3,3,4,5,2,5,1,2,1,3,4,3,5,5,1,2,4,2,1,1,5,1,2,5,4,3,4,1,3,5,3,2,3,2,2,3,5,1,1,3,2,3,3,1,2,5,5,2,1,4,5,4,2,2,1,3,4,2,3,3,2,2,4,1,5,5,2,5,5,2,4,5,5,1,4,1,5,5,1,1,1,3,1,3,5,2,5,4,5,1,5,1,3,1,5,2,5,3,3,3,4,5,1,2,2,2,5,4,1,4,4,4,1,2,5,1,3,2,5,4,5,4,5,3,1,2,3,3,1,4,2,4,2,2,3,4,4,1,4,3,1,4,5,1,5,3,2,5,1,1,5,2,3,5,3,2,4,3,4,4,2,2,5,5,4,5,3,1,3,1,2,2,5,1,1,3,4,4,4,4,3,5,3,5,5,2,5,4,2,3,1,2,4,5,1,4,4,5,2,1,4,4,1,1,2,5,5,5,3,1,2,1,5,2,3,4,5,1,1,5,5,1,4,5,2,3,2,4,1,2,4,1,5,5,3,2,3,5,1,3,2,1,3,1,4,1,1,2,2,2,2,5,5,1,4,1,4,5,1,2,4,5,1,4,5,1,4,1,5,5,3,3,4,5,4,3,1,4,4,4,3,4,2,1,3,4,2,3,2,2,4,5,3,1,1,1,3,5,2,3,4,3,2,2,2,4,5,3,5,4,4,2,3,5,4,3,2,2,3,3,3,5,1,2,2,2,1,5,1,5,5,1,3,4,4,4,5,4,5,2,5,3,2,3,5,4,1,2,5,2,3,5,2,2,1,1,1,2,4,3,2,4,4,4,2,2,5,3,5,2,2,2,3,3,5,3,4,5,3,1,3,4,3,1,3,4,5,2,2,4,1,1,2,5,4,2,2,5,1,2,5,2,5,3,4,5,3,4,2,2,3,2,2,2,5,2,3,4,2,4,5,3,4,5,2,1,1,1,2,5,5,2,2,1,1,1,5,5,3,1,5,2,5,2,4,2,5,2,2,2,3,4,5,3,2,4,5,3,5,4,5,1,1,1,5,4,5,3,2,2,4,5,5,3,4,5,2,4,5,3,4,2,1,5,2,3,5,1,1,5,4,5,4,3,1,3,5,1,5,2,4,2,1,2,4,5,2,3,1,5,1,3,4,4,3,4,5,3,5,3,3,5,1,5,2,4,2,4,2,1,3,1,4,2,5,4,4,1,3,4,4,5,1,2,1,4,5,3,5,1,5,1,2,5,2,2,1,2,3,5,1,2,4,1,4,1,3,2,4,2,5,1,2,4,2,1,4,1,4,1,3,5,3,3,3,5,3,5,5,1,2,5,5,2,4,2,2,1,4,4,1,2,3,2,2,3,4,4,4,1,5,1,3,4,2,5,2,3,1,2,2,3,2,4,5,3,1,4,5,5,4,2,1,1,5,5,1,4,4,3,2,1,3,5,2,4,5,1,2,2,5,1,5,3,5,2,2,4,4,4,3,4,4,4,1,3,2,4,4,4,1,1,1,1,5,1,5,4,3,3,1,2,1,1,1,1,2,4,3,1,3,2,5,1,3,4,3,5,3,5,1,4,3,1,3,2,2,3,1,1,4,3,1,2,1,2,1,5,3,3,2,1,5,5,1,4,2,1,5,4,2,3,3,1,1,5,5,4,1,2,4,3,3,1,1,1,3,1,3,4,3,4,4,5,2,5,4,2,4,1,2,2,4,3,2,4,5,4,3,4,5,4,3,1,2,4,4,4,3,1,4,5,5,3,1,3,4,3,1,3,3,5,1,4,3,5,1,5,3,3,2,3,4,3,3,2,1,4,5,1,1,5,3,4,1,1,5,5,4,4,1,3,2,3,3,3,4,5,4,1,5,2,3,2,5,2,5,1,1,1,2,2,4,1,3,2,5,3,1,5,5,1,3,4,2,1,2,1,3,3,3,4,4,3,1,4,2,4,4,2,3,2,1,1,4,4,2,2,3,3,2,1,1],[4,1,2,3,5,5,5,2,1,2,3,2,1,2,4,1,5,4,3,4,2,4,4,3,5,3,4,3,3,1,4,2,1,2,2,1,1,2,1,4,5,3,4,3,2,4,2,1,2,2,5,5,4,2,3,3,1,2,1,1,3,1,3,1,1,4,5,5,2,2,4,5,1,1,3,5,1,4,1,3,3,3,1,2,1,2,4,1,1,2,1,4,3,4,2,1,4,3,2,2,1,4,4,1,3,3,5,5,5,3,1,1,4,3,5,4,2,1,3,4,1,4,3,4,4,3,1,3,1,2,4,1,4,1,1,1,4,1,4,2,4,5,1,1,1,4,1,5,2,1,1,4,3,4,4,1,3,2,3,3,1,2,5,4,1,2,1,2,2,2,1,2,1,1,2,2,4,2,1,4,2,3,4,3,2,3,4,3,1,2,1,2,1,3,3,2,5,3,5,1,1,4,3,3,3,2,1,4,4,4,3,1,4,2,1,4,1,2,4,2,1,3,5,4,2,2,1,3,2,4,4,4,3,4,1,1,1,2,5,4,1,2,3,3,1,2,4,1,3,1,1,3,3,4,1,2,5,5,4,4,1,1,5,4,2,2,5,2,4,1,3,2,1,1,2,3,1,5,1,1,4,1,4,4,3,4,1,1,2,2,4,4,2,4,4,5,5,1,4,2,1,1,2,4,1,1,1,2,3,4,2,4,5,3,1,4,4,4,1,4,1,2,5,1,5,1,3,3,5,1,1,3,1,1,5,2,5,5,5,4,1,1,5,1,1,4,1,4,4,2,4,4,2,2,3,1,5,1,2,1,4,1,3,1,3,2,1,1,4,3,1,2,1,4,3,3,1,2,1,1,1,3,4,2,3,2,1,3,1,4,4,4,4,1,4,3,1,3,1,3,4,4,4,4,4,1,4,2,3,5,4,3,4,3,4,4,5,4,5,2,4,1,5,4,2,4,5,4,1,3,2,1,3,3,1,1,2,4,1,5,3,3,5,2,3,2,1,1,5,4,4,4,3,4,1,3,2,5,1,1,3,2,1,3,2,3,3,3,1,5,3,2,1,5,4,4,1,5,2,2,3,3,1,4,4,4,1,2,4,2,4,5,3,5,1,1,2,5,3,1,1,4,2,1,2,2,1,2,1,5,4,3,4,3,5,5,2,5,2,3,5,2,4,4,2,3,1,5,1,5,2,3,1,4,5,3,2,4,1,1,3,4,2,4,1,1,1,1,5,5,5,1,1,4,4,1,4,2,4,2,2,2,4,5,3,3,5,4,1,1,5,1,2,1,1,1,4,3,2,2,1,4,2,4,4,1,2,2,4,4,5,3,4,3,1,1,1,4,2,1,3,1,1,4,2,3,1,4,2,2,2,2,4,1,1,4,3,4,1,5,4,4,3,5,5,5,1,5,4,2,4,3,4,3,4,4,1,4,1,2,1,1,4,2,1,1,3,4,5,4,5,2,4,4,1,4,1,2,5,3,4,1,4,1,1,3,5,3,1,1,2,4,2,1,1,3,5,1,1,4,5,1,1,5,2,3,5,3,1,1,5,4,3,5,5,3,3,1,3,3,4,1,2,4,5,4,5,3,3,1,1,2,1,3,3,1,4,2,2,4,4,3,2,1,1,2,2,1,3,3,1,3,4,4,4,4,4,3,1,4,4,5,5,5,1,1,4,4,2,4,5,2,4,3,4,3,4,4,3,2,4,4,1,1,4,4,4,4,2,2,2,3,2,1,4,3,4,5,4,2,3,1,4,1,1,2,4,5,3,2,2,3,2,2,1,4,3,1,1,3,1,1,1,4,3,2,4,5,1,4,2,3,4,2,4,1,1,3,4,1,1,1,2,3,1,1,1,4,4,4,5,3,1,1,5,5,1,2,5,2,5,5,3,3,3,1,2,4,4,2,1,2,2,1,4,2,2,1,2,4,3,5,2,2,2,4,3,2,3,4,3,1,5,3,2,4,4,5,5,5,1,1,3,3,5,2,3,4,2,4,4,1,5,5,2,3,2,4,3,2,1,5,4,5,1,4,4,2,1,4,4,4,2,4,4,2,1,3,1,4,4,4,1,2,4,1,1,3,4,1,4,5,1,2,5,4,4,3,1,1,4,2,5,2,1,2,3,5,3,1,1,3,3,5,4,1,3,2,3,1,3,4,2,2,2,3,4,1,3,1,5,3,2,5,1,1,3,4,3,4,3,4,1,3,1,3,2,4,5,4,4,5,2,1,2],[3,2,3,3,5,5,5,1,2,1,3,3,1,1,4,1,5,4,5,5,3,4,2,3,4,4,5,3,4,1,3,3,2,1,1,2,2,4,2,4,5,3,4,2,3,5,4,1,5,1,5,5,5,2,3,3,1,2,1,1,4,1,4,1,1,5,5,5,2,2,4,5,1,1,5,5,1,4,2,2,3,3,2,2,1,2,2,1,2,1,1,4,2,4,3,2,3,3,2,3,3,4,5,3,4,4,5,4,5,4,1,1,5,4,5,4,3,1,4,5,2,2,2,4,4,2,2,3,1,4,5,1,2,2,3,2,5,2,2,3,5,5,2,3,2,4,2,5,1,1,3,4,3,4,4,1,4,3,2,4,1,2,5,5,1,2,1,2,3,2,1,2,1,1,3,2,5,2,1,3,1,4,4,4,4,5,4,5,1,3,4,2,1,1,4,4,5,4,5,2,1,5,3,4,4,4,1,5,4,5,4,3,4,3,1,4,2,2,4,2,1,3,5,5,1,3,2,2,2,2,3,4,2,3,1,2,1,2,5,3,2,2,4,3,2,2,5,1,5,1,1,1,4,4,3,3,5,4,3,5,2,1,4,4,2,2,5,2,5,1,3,2,1,1,2,2,3,5,1,1,3,1,4,4,5,3,2,2,3,2,3,4,2,3,5,5,5,2,4,4,1,2,1,5,2,1,1,3,2,3,2,4,5,3,1,5,5,4,1,3,1,3,5,1,5,2,3,2,5,1,1,4,2,1,5,2,5,4,5,4,2,1,4,1,3,4,1,2,4,3,2,2,3,2,3,3,5,1,3,1,4,3,4,2,3,3,1,2,3,3,1,3,1,5,5,2,1,2,1,1,1,3,4,2,2,1,1,2,1,4,5,3,5,1,4,2,1,3,2,3,4,4,5,4,3,1,3,2,1,5,5,3,3,3,4,3,5,5,5,3,4,1,5,5,3,4,5,3,1,5,2,1,2,2,1,1,2,3,1,5,3,5,5,4,4,2,2,2,3,3,5,3,3,4,2,3,4,5,1,2,3,3,1,3,4,4,3,4,1,5,1,2,1,5,4,5,2,5,2,1,2,4,2,4,5,4,3,2,5,2,4,5,4,5,2,2,3,5,2,2,1,5,1,3,1,1,1,1,1,5,2,4,2,3,5,5,4,5,4,1,5,4,4,4,2,4,1,5,1,4,4,3,2,2,5,3,2,4,1,1,5,3,2,3,1,2,1,1,5,5,5,1,1,3,5,2,4,2,4,2,3,3,4,5,4,4,5,4,3,3,5,1,2,1,1,1,4,4,3,2,4,4,3,3,3,2,4,2,4,5,4,4,3,2,2,1,2,5,3,2,2,1,2,5,4,3,2,4,2,4,4,3,5,2,1,5,3,5,2,5,4,4,4,5,4,5,1,5,3,2,3,4,5,2,3,2,1,5,1,2,1,1,4,2,2,2,3,4,5,3,5,1,5,4,1,5,1,3,5,2,5,1,4,1,1,5,5,3,2,1,2,4,3,4,2,5,5,1,3,5,5,1,2,5,2,4,5,2,1,2,5,5,4,5,5,2,3,1,3,3,5,1,3,4,5,3,5,4,3,1,1,1,2,3,3,3,3,1,2,5,4,4,4,1,1,3,3,1,3,3,1,3,5,5,4,3,5,2,1,5,4,5,5,5,1,2,2,4,4,2,5,3,2,3,4,3,4,5,4,3,4,5,1,1,4,3,4,4,3,1,2,3,2,1,5,4,5,3,5,3,4,1,5,2,1,3,5,4,4,3,1,2,2,4,1,4,4,2,1,4,1,1,1,4,3,1,4,5,1,4,1,3,3,2,4,1,3,4,3,1,1,1,2,1,1,1,2,5,4,5,5,2,1,1,4,5,3,1,5,4,5,5,3,2,4,2,1,2,4,3,1,2,2,1,4,3,3,3,1,3,3,4,3,2,3,4,4,3,3,4,3,2,5,4,4,4,5,5,5,4,4,3,3,3,5,3,4,2,3,4,5,3,5,5,2,3,2,5,2,1,1,5,2,5,2,4,4,4,1,5,2,3,3,4,5,3,2,5,1,5,4,4,3,3,4,1,2,5,3,2,4,5,1,1,5,3,4,4,1,2,4,1,5,3,2,2,3,5,3,1,1,4,2,5,3,1,2,3,5,1,3,3,4,3,4,5,4,3,2,2,5,3,2,5,1,1,4,4,4,5,4,3,2,2,1,5,1,2,5,3,4,5,3,1,4]],&#34;container&#34;:&#34;&lt;table class=\&#34;display\&#34;&gt;\n  &lt;thead&gt;\n    &lt;tr&gt;\n      &lt;th&gt;Customer&lt;\/th&gt;\n      &lt;th&gt;Segment&lt;\/th&gt;\n      &lt;th&gt;RFM&lt;\/th&gt;\n      &lt;th&gt;Orders&lt;\/th&gt;\n      &lt;th&gt;Recency&lt;\/th&gt;\n      &lt;th&gt;Total Spend&lt;\/th&gt;\n    &lt;\/tr&gt;\n  &lt;\/thead&gt;\n&lt;\/table&gt;&#34;,&#34;options&#34;:{&#34;pageLength&#34;:5,&#34;autoWidth&#34;:true,&#34;columnDefs&#34;:[{&#34;className&#34;:&#34;dt-right&#34;,&#34;targets&#34;:[3,4,5,6,7,8,9]}],&#34;order&#34;:[],&#34;orderClasses&#34;:false,&#34;orderCellsTop&#34;:true,&#34;lengthMenu&#34;:[5,10,25,50,100]}},&#34;evals&#34;:[],&#34;jsHooks&#34;:[]}&lt;/script&gt;
&lt;/div&gt;
&lt;div id=&#34;segment-size&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Segment Size&lt;/h2&gt;
&lt;p&gt;Now that we have defined and segmented our customers, let us examine the distribution of customers across the segments. Ideally, we should have very few or no customer in segments such as &lt;code&gt;At Risk&lt;/code&gt; or &lt;code&gt;Needs Attention&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;segments %&amp;gt;%
  count(segment) %&amp;gt;%
  arrange(desc(n)) %&amp;gt;%
  rename(Segment = segment, Count = n)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 10 x 2
##    Segment            Count
##    &amp;lt;chr&amp;gt;              &amp;lt;int&amp;gt;
##  1 Loyal Customers      288
##  2 Lost                 185
##  3 At Risk              180
##  4 Potential Loyalist   147
##  5 About To Sleep        58
##  6 Others                48
##  7 Need Attention        34
##  8 Promising             21
##  9 Can&amp;#39;t Lose Them       17
## 10 New Customers         17&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can also examine the median recency, frequency and monetary value across segments to ensure that the
logic used for customer classification is sound and practical.&lt;/p&gt;
&lt;div id=&#34;median-recency&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Median Recency&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rfm_plot_median_recency(segments)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-12-introducing-rfm_files/figure-html/avg_recency-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;median-frequency&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Median Frequency&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rfm_plot_median_frequency(segments)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-12-introducing-rfm_files/figure-html/avg_frequency-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;median-monetary-value&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Median Monetary Value&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rfm_plot_median_monetary(segments)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-12-introducing-rfm_files/figure-html/avg_monetary-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;heat-map&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Heat Map&lt;/h2&gt;
&lt;p&gt;The heat map shows the average monetary value for different categories of recency and frequency scores. Higher scores of frequency and recency are characterized by higher average monetary value as indicated by the darker areas in the heatmap.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rfm_heatmap(rfm_result)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-12-introducing-rfm_files/figure-html/heatmap-1.png&#34; width=&#34;768&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;bar-chart&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Bar Chart&lt;/h2&gt;
&lt;p&gt;Use &lt;code&gt;rfm_bar_chart()&lt;/code&gt; to generate the distribution of monetary scores for the different combinations of frequency and recency scores.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rfm_bar_chart(rfm_result)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-12-introducing-rfm_files/figure-html/barchart-1.png&#34; width=&#34;768&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;histogram&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Histogram&lt;/h2&gt;
&lt;p&gt;Use &lt;code&gt;rfm_histograms()&lt;/code&gt; to examine the relative distribution of&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;monetary value (total revenue generated by each customer)&lt;/li&gt;
&lt;li&gt;recency days (days since the most recent visit for each customer)&lt;/li&gt;
&lt;li&gt;frequency (transaction count for each customer)&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rfm_histograms(rfm_result)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-12-introducing-rfm_files/figure-html/rfmhist-1.png&#34; width=&#34;768&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;customers-by-orders&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Customers by Orders&lt;/h2&gt;
&lt;p&gt;Visualize the distribution of customers across orders.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rfm_order_dist(rfm_result)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-12-introducing-rfm_files/figure-html/rfmorders-1.png&#34; width=&#34;768&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;scatter-plots&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Scatter Plots&lt;/h2&gt;
&lt;p&gt;The best customers are those who:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;bought most recently&lt;/li&gt;
&lt;li&gt;most often&lt;/li&gt;
&lt;li&gt;and spend the most&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now let us examine the relationship between the above.&lt;/p&gt;
&lt;div id=&#34;recency-vs-monetary-value&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Recency vs Monetary Value&lt;/h4&gt;
&lt;p&gt;Customers who visited more recently generated more revenue compared to those who visited in the distant past. The customers who visited in the recent past are more likely to return compared to those who visited long time ago as most of those would be lost customers. As such, higher revenue would be associated with most recent visits.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rfm_rm_plot(rfm_result)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-12-introducing-rfm_files/figure-html/mr-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;frequency-vs-monetary-value&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Frequency vs Monetary Value&lt;/h4&gt;
&lt;p&gt;As the frequency of visits increases, the revenue generated also increases. Customers who visit more frquently are your champion customers, loyal customers or potential loyalists and they drive higher revenue.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rfm_fm_plot(rfm_result)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-12-introducing-rfm_files/figure-html/fm-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;recency-vs-frequency&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Recency vs Frequency&lt;/h4&gt;
&lt;p&gt;Customers with low frequency visited in the distant past while those with high frequency have visited in the recent past. Again, the customers who visited in the recent past are more likely to return compared to those who visited long time ago. As such, higher frequency would be associated with the most recent visits.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rfm_rf_plot(rfm_result)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-12-introducing-rfm_files/figure-html/fr-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;learning-more&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Learning More&lt;/h3&gt;
&lt;p&gt;The &lt;a href=&#34;https://rfm.rsquaredacademy.com/index.html&#34;&gt;rfm website&lt;/a&gt; includes
comprehensive documentation on using the package, including the following
articles that cover various aspects of using rfm:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href=&#34;https://rfm.rsquaredacademy.com/articles/rfm-customer-level-data.html&#34;&gt;RFM Customer Level Data&lt;/a&gt; - shows you
how to handle customer level data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href=&#34;https://rfm.rsquaredacademy.com/articles/rfm-transaction-level-data.html&#34;&gt;RFM Transaction Level Data&lt;/a&gt; - shows
you how to handle transaction level data.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;feedback&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Feedback&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;rfm&lt;/strong&gt; has been on CRAN for a few months now while we were fixing bugs and
making the API stable. All feedback is welcome. Issues (bugs and feature
requests) can be posted to &lt;a href=&#34;https://github.com/rsquaredacademy/rfm/issues&#34;&gt;github tracker&lt;/a&gt;.
For help with code or other related questions, feel free to reach me &lt;a href=&#34;mailto:hebbali.aravind@gmail.com&#34; class=&#34;email&#34;&gt;hebbali.aravind@gmail.com&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Introducing olsrr</title>
      <link>https://blog.rsquaredacademy.com/introducing-olsrr/</link>
      <pubDate>Fri, 08 Feb 2019 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/introducing-olsrr/</guid>
      <description>&lt;p&gt;I am pleased to announce the &lt;strong&gt;olsrr&lt;/strong&gt; package, a set of tools for improved
output from linear regression models, designed keeping in mind
beginner/intermediate R users. The package includes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;comprehensive regression output&lt;/li&gt;
&lt;li&gt;variable selection procedures&lt;/li&gt;
&lt;li&gt;heteroskedasticiy, collinearity diagnostics and measures of influence&lt;/li&gt;
&lt;li&gt;various plots and underlying data&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you know how to build models using &lt;code&gt;lm()&lt;/code&gt;, you will find &lt;strong&gt;olsrr&lt;/strong&gt; very
useful. Most of the functions use an object of class &lt;code&gt;lm&lt;/code&gt; as input. So you
just need to build a model using &lt;code&gt;lm()&lt;/code&gt; and then pass it onto the functions in
&lt;strong&gt;olsrr&lt;/strong&gt;. Once you have picked up enough knowledge of R, you can move on to
more intuitive approach offered by tidymodels etc. as they offer more
flexibility, which &lt;strong&gt;olsrr&lt;/strong&gt; does not.&lt;/p&gt;
&lt;div id=&#34;installation&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Installation&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Install release version from CRAN
install.packages(&amp;quot;olsrr&amp;quot;)

# Install development version from GitHub
# install.packages(&amp;quot;devtools&amp;quot;)
devtools::install_github(&amp;quot;rsquaredacademy/olsrr&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;shiny-app&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Shiny App&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;olsrr&lt;/strong&gt; includes a shiny app which can be launched using&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ols_launch_app()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or try the live version &lt;a href=&#34;https://www.rsquaredcomputing.com/olsrr/&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Read on to learn more about the features of &lt;strong&gt;olsrr&lt;/strong&gt;, or see the
&lt;a href=&#34;https://olsrr.rsquaredacademy.com/&#34;&gt;olsrr website&lt;/a&gt; for
detailed documentation on using the package.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;regression-output&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Regression Output&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;model &amp;lt;- lm(mpg ~ disp + hp + wt + qsec, data = mtcars)
ols_regress(model)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.914       RMSE                2.622 
## R-Squared               0.835       Coef. Var          13.051 
## Adj. R-Squared          0.811       MSE                 6.875 
## Pred R-Squared          0.771       MAE                 1.858 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                ANOVA                                 
## --------------------------------------------------------------------
##                 Sum of                                              
##                Squares        DF    Mean Square      F         Sig. 
## --------------------------------------------------------------------
## Regression     940.412         4        235.103    34.195    0.0000 
## Residual       185.635        27          6.875                     
## Total         1126.047        31                                    
## --------------------------------------------------------------------
## 
##                                   Parameter Estimates                                    
## ----------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower     upper 
## ----------------------------------------------------------------------------------------
## (Intercept)    27.330         8.639                  3.164    0.004     9.604    45.055 
##        disp     0.003         0.011        0.055     0.248    0.806    -0.019     0.025 
##          hp    -0.019         0.016       -0.212    -1.196    0.242    -0.051     0.013 
##          wt    -4.609         1.266       -0.748    -3.641    0.001    -7.206    -2.012 
##        qsec     0.544         0.466        0.161     1.166    0.254    -0.413     1.501 
## ----------------------------------------------------------------------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the presence of interaction terms in the model, the predictors are scaled
and centered before computing the standardized betas. &lt;code&gt;ols_regress()&lt;/code&gt; will
detect interaction terms automatically but in case you have created a new
variable instead of using the inline function, you can indicate the presence
of interaction terms by setting &lt;code&gt;iterm&lt;/code&gt; to &lt;code&gt;TRUE&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;residual-diagnostics&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Residual Diagnostics&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;olsrr&lt;/strong&gt; offers tools for detecting violation of standard regression assumptions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Residual QQ plot&lt;/li&gt;
&lt;li&gt;Residual normality test&lt;/li&gt;
&lt;li&gt;Residual vs Fitted plot&lt;/li&gt;
&lt;li&gt;Residual histogram&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ols_plot_resid_qq(model)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-08-introducing-olsrr_files/figure-html/residiag-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;See &lt;a href=&#34;https://olsrr.rsquaredacademy.com/articles/residual_diagnostics.html&#34;&gt;Residual Diagnostics&lt;/a&gt;
for more details.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;heteroskedasticity&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Heteroskedasticity&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;olsrr&lt;/strong&gt; provides the following 4 tests for detecting heteroscedasticity:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Bartlett Test&lt;/li&gt;
&lt;li&gt;Breusch Pagan Test&lt;/li&gt;
&lt;li&gt;Score Test&lt;/li&gt;
&lt;li&gt;F Test&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ols_test_breusch_pagan(model)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##  Breusch Pagan Test for Heteroskedasticity
##  -----------------------------------------
##  Ho: the variance is constant            
##  Ha: the variance is not constant        
## 
##              Data               
##  -------------------------------
##  Response : mpg 
##  Variables: fitted values of mpg 
## 
##         Test Summary         
##  ----------------------------
##  DF            =    1 
##  Chi2          =    0.5884673 
##  Prob &amp;gt; Chi2   =    0.4430124&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;See &lt;a href=&#34;https://olsrr.rsquaredacademy.com/articles/heteroskedasticity.html&#34;&gt;Heteroskedasticity&lt;/a&gt;
for more details.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;collinearity-diagnostics&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Collinearity Diagnostics&lt;/h3&gt;
&lt;p&gt;VIF, Tolerance and condition indices to detect collinearity and plots for
assessing mode fit and contributions of variables.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ols_coll_diag(model)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Tolerance and Variance Inflation Factor
## ---------------------------------------
##   Variables Tolerance      VIF
## 1      disp 0.1252279 7.985439
## 2        hp 0.1935450 5.166758
## 3        wt 0.1445726 6.916942
## 4      qsec 0.3191708 3.133119
## 
## 
## Eigenvalue and Condition Index
## ------------------------------
##    Eigenvalue Condition Index   intercept        disp          hp           wt
## 1 4.721487187        1.000000 0.000123237 0.001132468 0.001413094 0.0005253393
## 2 0.216562203        4.669260 0.002617424 0.036811051 0.027751289 0.0002096014
## 3 0.050416837        9.677242 0.001656551 0.120881424 0.392366164 0.0377028008
## 4 0.010104757       21.616057 0.025805998 0.777260487 0.059594623 0.7017528428
## 5 0.001429017       57.480524 0.969796790 0.063914571 0.518874831 0.2598094157
##           qsec
## 1 0.0001277169
## 2 0.0046789491
## 3 0.0001952599
## 4 0.0024577686
## 5 0.9925403056&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;See &lt;a href=&#34;https://olsrr.rsquaredacademy.com/articles/regression_diagnostics.html&#34;&gt;Collinearity Diagnostics&lt;/a&gt; for more details.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;measures-of-influence&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Measures of Influence&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;olsrr&lt;/strong&gt; offers the following tools to detect influential observations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Cook’s D Bar Plot&lt;/li&gt;
&lt;li&gt;Cook’s D Chart&lt;/li&gt;
&lt;li&gt;DFBETAs Panel&lt;/li&gt;
&lt;li&gt;DFFITs Plot&lt;/li&gt;
&lt;li&gt;Studentized Residual Plot&lt;/li&gt;
&lt;li&gt;Standardized Residual Chart&lt;/li&gt;
&lt;li&gt;Studentized Residuals vs Leverage Plot&lt;/li&gt;
&lt;li&gt;Deleted Studentized Residual vs Fitted Values Plot&lt;/li&gt;
&lt;li&gt;Hadi Plot&lt;/li&gt;
&lt;li&gt;Potential Residual Plot&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ols_plot_resid_lev(model)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2019-02-08-introducing-olsrr_files/figure-html/mof-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;See &lt;a href=&#34;https://olsrr.rsquaredacademy.com/articles/influence_measures.html&#34;&gt;Measures of Influence&lt;/a&gt; for more details.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;variable-selection&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Variable Selection&lt;/h3&gt;
&lt;p&gt;Different variable selection procedures such as all possible regression, best
subset regression, stepwise regression, stepwise forward regression and
stepwise backward regression.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;model &amp;lt;- lm(y ~ ., data = stepdata)
ols_step_both_aic(model)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 
##                                   Stepwise Summary                                  
## ----------------------------------------------------------------------------------
## Variable     Method        AIC         RSS        Sum Sq       R-Sq      Adj. R-Sq 
## ----------------------------------------------------------------------------------
## x6          addition    33473.297    6241.497    13986.736    0.69145      0.69143 
## x1          addition    32931.758    6074.156    14154.076    0.69972      0.69969 
## x3          addition    31912.722    5771.842    14456.391    0.71466      0.71462 
## x2          addition    29304.296    5065.587    15162.646    0.74958      0.74953 
## x6          removal     29302.317    5065.592    15162.641    0.74958      0.74954 
## x4          addition    29300.814    5064.705    15163.528    0.74962      0.74957 
## ----------------------------------------------------------------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;See &lt;a href=&#34;https://olsrr.rsquaredacademy.com/articles/variable_selection.html&#34;&gt;Variable Selection&lt;/a&gt; for more details.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;learning-more&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Learning More&lt;/h3&gt;
&lt;p&gt;The &lt;a href=&#34;https://olsrr.rsquaredacademy.com/index.html&#34;&gt;olsrr website&lt;/a&gt; includes
comprehensive documentation on using the package, including the following
articles that cover various aspects of using olsrr:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href=&#34;https://olsrr.rsquaredacademy.com/articles/variable_selection.html&#34;&gt;Variable Selection&lt;/a&gt; - Different variable selection procedures such as all possible regression, best
subset regression, stepwise regression, stepwise forward regression and
stepwise backward regression.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href=&#34;https://olsrr.rsquaredacademy.com/articles/residual_diagnostics.html&#34;&gt;Residual Diagnostics&lt;/a&gt; - Includes plots to examine residuals to validate OLS assumptions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href=&#34;https://olsrr.rsquaredacademy.com/articles/heteroskedasticity.html&#34;&gt;Heteroskedasticity&lt;/a&gt; - Tests for heteroskedasticity include bartlett test, breusch pagan test, score test and f test.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href=&#34;https://olsrr.rsquaredacademy.com/articles/regression_diagnostics.html&#34;&gt;Collinearity Diagnostics&lt;/a&gt; - VIF, Tolerance and condition indices to detect collinearity and plots for assessing mode fit and contributions of variables.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href=&#34;https://olsrr.rsquaredacademy.com/articles/influence_measures.html&#34;&gt;Measures of Influence&lt;/a&gt; - Includes 10 different plots to detect and identify influential observations.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;feedback&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Feedback&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;olsrr&lt;/strong&gt; has been on CRAN for more than an year while we were fixing bugs and
making the API stable. All feedback is welcome. Issues (bugs and feature
requests) can be posted to &lt;a href=&#34;https://github.com/rsquaredacademy/olsrr/issues&#34;&gt;github tracker&lt;/a&gt;.
For help with code or other related questions, feel free to reach me &lt;a href=&#34;mailto:hebbali.aravind@gmail.com&#34; class=&#34;email&#34;&gt;hebbali.aravind@gmail.com&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>SQL for Data Science - Part 2</title>
      <link>https://blog.rsquaredacademy.com/sql-for-data-science-part-2/</link>
      <pubDate>Wed, 02 Jan 2019 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/sql-for-data-science-part-2/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Introduction&lt;/h4&gt;
&lt;p&gt;This is the fourth post in the series &lt;strong&gt;R &amp;amp; Databases&lt;/strong&gt;. You can find the links to the other two posts of this series below:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://blog.rsquaredacademy.com/quick-guide-r-sqlite/&#34;&gt;Quick Guide: R &amp;amp; SQLite&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://blog.rsquaredacademy.com/data-wrangling-with-dbplyr/&#34;&gt;Data Wrangling with dbplyr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://blog.rsquaredacademy.com/sql-for-data-science-part-1/&#34;&gt;SQL for Data Science - Part 1&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this post, we will learn to&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;aggregate data&lt;/li&gt;
&lt;li&gt;order data&lt;/li&gt;
&lt;li&gt;and group data&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;p&gt;We will use the following libraries in this post:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://readr.tidyverse.org/&#34;&gt;DBI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://rstats-db.github.io/RSQLite/&#34;&gt;RSQLite&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://dbplyr.tidyverse.org/&#34;&gt;dbplyr&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt; and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/691dba8e13873c648bfdb91aba65d4d7&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;div id=&#34;set-up&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Set Up&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom &amp;lt;- readr::read_csv(&amp;#39;https://raw.githubusercontent.com/rsquaredacademy/datasets/master/web.csv&amp;#39;)
con &amp;lt;- DBI::dbConnect(RSQLite::SQLite(), &amp;quot;:memory:&amp;quot;)
copy_to(con, ecom)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;aggregate&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Aggregate&lt;/h4&gt;
&lt;p&gt;Let us combine the aggregate statements with WHERE statement to filter data.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;SUM() : returns the total sum of a numeric column&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT SUM(n_visit) FROM ecom&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   SUM(n_visit)
## 1         4972&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT SUM(n_visit) 
                 FROM ecom 
                 WHERE n_visit &amp;gt; 5&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   SUM(n_visit)
## 1         3574&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;AVG() : returns the average value of a numeric column&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT AVG(n_visit) FROM ecom&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   AVG(n_visit)
## 1        4.972&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT AVG(n_visit) 
                 FROM ecom 
                 WHERE country LIKE &amp;#39;P%&amp;#39;&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   AVG(n_visit)
## 1     5.079137&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;MAX() : returns the largest value of the selected column&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT MAX(n_visit) FROM ecom&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   MAX(n_visit)
## 1           10&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT MAX(n_visit) 
                 FROM ecom 
                 WHERE device == &amp;#39;tablet&amp;#39;&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   MAX(n_visit)
## 1           10&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;MIN() : returns the smallest value of the selected column&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT MIN(n_visit) FROM ecom&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   MIN(n_visit)
## 1            0&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT MIN(n_visit) 
                 FROM ecom 
                 WHERE duration BETWEEN 600 AND 900&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   MIN(n_visit)
## 1            0&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;alias&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Alias&lt;/h4&gt;
&lt;p&gt;SQL aliases are used to give a table, or a column in a table, a temporary name. They are often used to make column names more readable. An alias only exists for the duration of the query. Below are a
few examples:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT AVG(n_visit) AS avg_mobile 
                 FROM ecom 
                 WHERE device == &amp;#39;mobile&amp;#39;&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   avg_mobile
## 1   5.479651&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT MAX(n_visit) AS max_visit 
                 FROM ecom&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   max_visit
## 1        10&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT MIN(duration) AS min_duration 
                 FROM ecom&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   min_duration
## 1           10&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;order-by&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Order By&lt;/h4&gt;
&lt;p&gt;The ORDER BY keyword is used to sort the records in ascending or descending order. By default, the records are sorted in ascending order. Use the DESC keyword if you want to sort the records in descending order,&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT * 
                 FROM ecom 
                 ORDER BY country&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    id referrer device bouncers n_visit n_pages duration     country purchase
## 1 232   social laptop        0       8       2       60 Afghanistan        0
## 2 299    yahoo laptop        0      10      18      180 Afghanistan        0
## 3 570   social laptop        1       2       1      274 Afghanistan        0
## 4 677   direct tablet        1      10       1      682 Afghanistan        0
##   order_items order_value
## 1           0           0
## 2           0           0
## 3           0           0
## 4           0           0
##  [ reached &amp;#39;max&amp;#39; / getOption(&amp;quot;max.print&amp;quot;) -- omitted 996 rows ]&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT *  
                 FROM ecom 
                 ORDER BY duration&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    id referrer device bouncers n_visit n_pages duration   country purchase
## 1 236    yahoo tablet        1       5       1       10    Poland        0
## 2 615   social laptop        1       1       1       10   Finland        0
## 3 392    yahoo laptop        0       0       1       12 Indonesia        0
## 4 688   social mobile        1       2       1       12  Botswana        0
##   order_items order_value
## 1           0           0
## 2           0           0
## 3           0           0
## 4           0           0
##  [ reached &amp;#39;max&amp;#39; / getOption(&amp;quot;max.print&amp;quot;) -- omitted 996 rows ]&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT * 
                 FROM ecom 
                 ORDER BY n_visit DESC&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   id referrer device bouncers n_visit n_pages duration        country purchase
## 1  1   google laptop        1      10       1      693 Czech Republic        0
## 2  7    yahoo mobile        1      10       1       75     Bangladesh        0
## 3  8   direct mobile        1      10       1      908      Indonesia        0
## 4 29   google mobile        1      10       1      338         Russia        0
##   order_items order_value
## 1           0           0
## 2           0           0
## 3           0           0
## 4           0           0
##  [ reached &amp;#39;max&amp;#39; / getOption(&amp;quot;max.print&amp;quot;) -- omitted 996 rows ]&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;group-by&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Group By&lt;/h4&gt;
&lt;p&gt;The GROUP BY statement is used with aggregate functions (COUNT, MAX, MIN, SUM, AVG) to group the result by one or more columns.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT device, 
                 count(*) AS visits 
                 FROM ecom 
                 GROUP BY device 
                 ORDER by visits DESC&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   device visits
## 1 mobile    344
## 2 tablet    331
## 3 laptop    325&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT device, MAX(duration) AS max_duration 
                 FROM ecom 
                 GROUP BY device 
                 ORDER by max_duration DESC&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   device max_duration
## 1 tablet          999
## 2 laptop          997
## 3 mobile          994&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;In this post, we learnt to&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;aggregate data&lt;/li&gt;
&lt;li&gt;order data&lt;/li&gt;
&lt;li&gt;and group data&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>SQL for Data Science - Part 1</title>
      <link>https://blog.rsquaredacademy.com/sql-for-data-science-part-1/</link>
      <pubDate>Fri, 21 Dec 2018 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/sql-for-data-science-part-1/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;This is the third post in the series &lt;strong&gt;R &amp;amp; Databases&lt;/strong&gt;. You can find the links to the other two posts of this series below:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://blog.rsquaredacademy.com/quick-guide-r-sqlite/&#34;&gt;Quick Guide: R &amp;amp; SQLite&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://blog.rsquaredacademy.com/data-wrangling-with-dbplyr/&#34;&gt;Data Wrangling with dbplyr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://blog.rsquaredacademy.com/sql-for-data-science-part-2/&#34;&gt;SQL for Data Science - Part 2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this post, we will learn to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;select
&lt;ul&gt;
&lt;li&gt;single column&lt;/li&gt;
&lt;li&gt;multiple columns&lt;/li&gt;
&lt;li&gt;distinct values in a column&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;limit the number of records returned&lt;/li&gt;
&lt;li&gt;handle NULL values&lt;/li&gt;
&lt;li&gt;and filter columns using the following operators
&lt;ul&gt;
&lt;li&gt;WHERE&lt;/li&gt;
&lt;li&gt;AND, or &amp;amp; NOT&lt;/li&gt;
&lt;li&gt;BETWEEN&lt;/li&gt;
&lt;li&gt;IN&lt;/li&gt;
&lt;li&gt;LIKE&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;p&gt;We will use the following libraries in this post:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://readr.tidyverse.org/&#34;&gt;DBI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://rstats-db.github.io/RSQLite/&#34;&gt;RSQLite&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://dbplyr.tidyverse.org/&#34;&gt;dbplyr&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt; and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/f44774d9c6e115c08d5e2e693380a00f&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;set-up&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Set Up&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom &amp;lt;- readr::read_csv(&amp;#39;https://raw.githubusercontent.com/rsquaredacademy/datasets/master/web.csv&amp;#39;)
con &amp;lt;- DBI::dbConnect(RSQLite::SQLite(), &amp;quot;:memory:&amp;quot;)
copy_to(con, ecom)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;select-columns&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Select Columns&lt;/h3&gt;
&lt;p&gt;The SQL SELECT statement is used to fetch the data from a database table.&lt;/p&gt;
&lt;div id=&#34;syntax&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Syntax&lt;/h4&gt;
&lt;p&gt;Below is the basic syntax of the SELECT statement.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;SELECT column1, column2, columnN FROM table_name;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Here, column1, column2… are the fields of a table whose values you want to fetch.
If you want to fetch all the fields, use the following syntax.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;SELECT * FROM table_name;&lt;/code&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;select-single-column&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Select Single Column&lt;/h4&gt;
&lt;p&gt;Let us begin by selecting the &lt;code&gt;device&lt;/code&gt; field from the &lt;code&gt;ecom&lt;/code&gt; table.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT device FROM ecom&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    device
## 1  laptop
## 2  tablet
## 3  laptop
## 4  tablet
## 5  mobile
## 6  laptop
## 7  mobile
## 8  mobile
## 9  mobile
## 10 mobile
## 11 laptop
## 12 tablet
## 13 mobile
## 14 tablet
## 15 mobile
## 16 laptop
## 17 tablet
## 18 tablet
## 19 tablet
## 20 tablet
## 21 laptop
## 22 mobile
## 23 mobile
## 24 laptop
## 25 laptop
## 26 laptop
## 27 tablet
## 28 laptop
## 29 mobile
## 30 mobile
## 31 tablet
## 32 mobile
## 33 laptop
## 34 tablet
## 35 mobile
## 36 mobile
## 37 laptop
## 38 mobile
## 39 mobile
## 40 mobile
## 41 mobile
## 42 mobile
## 43 laptop
## 44 tablet
## 45 laptop
## 46 tablet
## 47 mobile
## 48 laptop
## 49 mobile
## 50 tablet
##  [ reached &amp;#39;max&amp;#39; / getOption(&amp;quot;max.print&amp;quot;) -- omitted 950 rows ]&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;select-multiple-columns&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Select Multiple Columns&lt;/h4&gt;
&lt;p&gt;Select the following fields from the &lt;code&gt;ecom&lt;/code&gt; table:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;referrer&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;device&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;purchase&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT referrer, device, purchase  FROM ecom&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    referrer device purchase
## 1    google laptop        0
## 2     yahoo tablet        0
## 3    direct laptop        0
## 4      bing tablet        1
## 5     yahoo mobile        0
## 6     yahoo laptop        0
## 7     yahoo mobile        0
## 8    direct mobile        0
## 9      bing mobile        0
## 10   google mobile        0
## 11   direct laptop        0
## 12   direct tablet        0
## 13   direct mobile        1
## 14    yahoo tablet        0
## 15    yahoo mobile        0
## 16     bing laptop        0
##  [ reached &amp;#39;max&amp;#39; / getOption(&amp;quot;max.print&amp;quot;) -- omitted 984 rows ]&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;select-all-columns&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Select All Columns&lt;/h4&gt;
&lt;p&gt;Select all the fields from the &lt;code&gt;ecom&lt;/code&gt; table.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT * FROM ecom&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   id referrer device bouncers n_visit n_pages duration        country purchase
## 1  1   google laptop        1      10       1      693 Czech Republic        0
## 2  2    yahoo tablet        1       9       1      459          Yemen        0
## 3  3   direct laptop        1       0       1      996         Brazil        0
## 4  4     bing tablet        0       3      18      468          China        1
##   order_items order_value
## 1           0           0
## 2           0           0
## 3           0           0
## 4           6         434
##  [ reached &amp;#39;max&amp;#39; / getOption(&amp;quot;max.print&amp;quot;) -- omitted 996 rows ]&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;limit&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Limit&lt;/h4&gt;
&lt;p&gt;If you have a large table with thousands of rows, returning all the records
will take time. Use LIMIT to specify the number of records to return.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT * FROM ecom limit 10&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   id referrer device bouncers n_visit n_pages duration        country purchase
## 1  1   google laptop        1      10       1      693 Czech Republic        0
## 2  2    yahoo tablet        1       9       1      459          Yemen        0
## 3  3   direct laptop        1       0       1      996         Brazil        0
## 4  4     bing tablet        0       3      18      468          China        1
##   order_items order_value
## 1           0           0
## 2           0           0
## 3           0           0
## 4           6         434
##  [ reached &amp;#39;max&amp;#39; / getOption(&amp;quot;max.print&amp;quot;) -- omitted 6 rows ]&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;distinct&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Distinct&lt;/h4&gt;
&lt;p&gt;A column in a table may often contain many duplicate values; and we might be interested only in the
distinct/unique values. In such cases, we can use the SELECT DISTINCT statement to return only distinct values.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT distinct referrer FROM ecom&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   referrer
## 1   google
## 2    yahoo
## 3   direct
## 4     bing
## 5   social&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;filter&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Filter&lt;/h3&gt;
&lt;p&gt;Now that we know how to select columns, let us focus on filtering data. In SQL, the WHERE keyword is used to extract only those records that fulfill a specified condition. Data filter based on both text and numeric values in a table. Below are a few comparison operators we can use:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;=&lt;/code&gt; equal&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;&amp;gt;&lt;/code&gt; not equal&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;&lt;/code&gt; less than&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;gt;&lt;/code&gt; greater than&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;=&lt;/code&gt; less than or equal to&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;gt;=&lt;/code&gt; greater than or equal to&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The following SQL statement filters all rows from the &lt;code&gt;ecom&lt;/code&gt; table where the &lt;code&gt;duration&lt;/code&gt; field
is greater than 300.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT * 
                 FROM ecom 
                 WHERE duration &amp;gt; 300&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   id referrer device bouncers n_visit n_pages duration        country purchase
## 1  1   google laptop        1      10       1      693 Czech Republic        0
## 2  2    yahoo tablet        1       9       1      459          Yemen        0
## 3  3   direct laptop        1       0       1      996         Brazil        0
## 4  4     bing tablet        0       3      18      468          China        1
##   order_items order_value
## 1           0           0
## 2           0           0
## 3           0           0
## 4           6         434
##  [ reached &amp;#39;max&amp;#39; / getOption(&amp;quot;max.print&amp;quot;) -- omitted 472 rows ]&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us filter data based on a text value. In the following example, we filter all rows
from the &lt;code&gt;ecom&lt;/code&gt; table where the &lt;code&gt;device&lt;/code&gt; used is &lt;code&gt;mobile&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT * 
                 FROM ecom 
                 WHERE device == &amp;#39;mobile&amp;#39;&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   id referrer device bouncers n_visit n_pages duration     country purchase
## 1  5    yahoo mobile        1       9       1      955      Poland        0
## 2  7    yahoo mobile        1      10       1       75  Bangladesh        0
## 3  8   direct mobile        1      10       1      908   Indonesia        0
## 4  9     bing mobile        0       3      19      209 Netherlands        0
##   order_items order_value
## 1           0           0
## 2           0           0
## 3           0           0
## 4           0           0
##  [ reached &amp;#39;max&amp;#39; / getOption(&amp;quot;max.print&amp;quot;) -- omitted 340 rows ]&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;and-or-not&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;And, Or &amp;amp; Not&lt;/h5&gt;
&lt;p&gt;The WHERE clause can be combined with other operators such as&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;AND - displays a record if all the conditions separated by AND is TRUE&lt;/li&gt;
&lt;li&gt;OR - displays a record if any of the conditions separated by OR is TRUE&lt;/li&gt;
&lt;li&gt;NOT - displays a record if the condition(s) is NOT TRUE&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;to filter data based on more than one condition or to create more complex conditions.&lt;/p&gt;
&lt;p&gt;In the following example, we filter all the rows from the &lt;code&gt;ecom&lt;/code&gt; table where
&lt;code&gt;n_visit&lt;/code&gt; (visit count) is greater than 3 and &lt;code&gt;duration&lt;/code&gt; (time spent on the site)
is greater than 100. We use AND to create multiple conditions.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT * 
                 FROM ecom 
                 WHERE n_visit &amp;gt; 3 AND duration &amp;gt; 100&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   id referrer device bouncers n_visit n_pages duration        country purchase
## 1  1   google laptop        1      10       1      693 Czech Republic        0
## 2  2    yahoo tablet        1       9       1      459          Yemen        0
## 3  5    yahoo mobile        1       9       1      955         Poland        0
## 4  6    yahoo laptop        0       5       5      135   South Africa        0
##   order_items order_value
## 1           0           0
## 2           0           0
## 3           0           0
## 4           0           0
##  [ reached &amp;#39;max&amp;#39; / getOption(&amp;quot;max.print&amp;quot;) -- omitted 509 rows ]&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the next example, we will use both AND &amp;amp; OR. Our goal is to filter all
rows from the &lt;code&gt;ecom&lt;/code&gt; table that follow the below conditions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;n_visit&lt;/code&gt; (visit count) is either equal to 3 or 5&lt;/li&gt;
&lt;li&gt;&lt;code&gt;device&lt;/code&gt; used to visit the website is either &lt;code&gt;mobile&lt;/code&gt; or &lt;code&gt;tablet&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT * 
                 FROM ecom WHERE (n_visit == 5 OR n_visit == 3)  
                 AND (device = &amp;#39;mobile&amp;#39; OR device = &amp;#39;tablet&amp;#39;)&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   id referrer device bouncers n_visit n_pages duration     country purchase
## 1  4     bing tablet        0       3      18      468       China        1
## 2  9     bing mobile        0       3      19      209 Netherlands        0
## 3 14    yahoo tablet        0       5       8       80 Philippines        0
## 4 17     bing tablet        0       5      16      368        Peru        1
##   order_items order_value
## 1           6         434
## 2           0           0
## 3           2         362
## 4           6        1049
##  [ reached &amp;#39;max&amp;#39; / getOption(&amp;quot;max.print&amp;quot;) -- omitted 130 rows ]&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;between&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;BETWEEN&lt;/h5&gt;
&lt;p&gt;The BETWEEN operator selects values within a given range and is inclusive: begin and end values are included. The values can be numbers, text, or dates. In the following example, we filter rows from
the &lt;code&gt;ecom&lt;/code&gt; table where the visit count is between 1 and 3, and the &lt;code&gt;device&lt;/code&gt; used to visit the website is
&lt;code&gt;mobile&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT * 
                 FROM ecom
                 WHERE n_visit BETWEEN 1 AND 3 AND device = &amp;#39;mobile&amp;#39;&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   id referrer device bouncers n_visit n_pages duration     country purchase
## 1  9     bing mobile        0       3      19      209 Netherlands        0
## 2 32   direct mobile        1       2       1      501 El Salvador        0
## 3 36     bing mobile        0       1       1       25     Ireland        0
## 4 38    yahoo mobile        1       3       1      700      Canada        0
##   order_items order_value
## 1           0           0
## 2           0           0
## 3          10        1885
## 4           0           0
##  [ reached &amp;#39;max&amp;#39; / getOption(&amp;quot;max.print&amp;quot;) -- omitted 86 rows ]&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;in&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;IN&lt;/h5&gt;
&lt;p&gt;The IN operator allows us to specify multiple values in a WHERE clause. It is a shorthand
for multiple OR conditions. In the below example, we filter rows from the &lt;code&gt;ecom&lt;/code&gt; table where
the visit count is either 2 or 4 or 6 or 8 or 10. Instead of using multiple OR conditions,
we use the IN operator.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT * 
                 FROM ecom 
                 WHERE n_visit IN (2, 4, 6, 8, 10)&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   id referrer device bouncers n_visit n_pages duration        country purchase
## 1  1   google laptop        1      10       1      693 Czech Republic        0
## 2  7    yahoo mobile        1      10       1       75     Bangladesh        0
## 3  8   direct mobile        1      10       1      908      Indonesia        0
## 4 10   google mobile        1       6       1      208 Czech Republic        0
##   order_items order_value
## 1           0           0
## 2           0           0
## 3           0           0
## 4           0           0
##  [ reached &amp;#39;max&amp;#39; / getOption(&amp;quot;max.print&amp;quot;) -- omitted 443 rows ]&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;is-null&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;IS NULL&lt;/h5&gt;
&lt;p&gt;A field with a NULL value is a field with no value. If a field in a table is optional, it is possible to insert a new record or update a record without adding a value to this field. Then, the field will be saved with a NULL value. In the next example, we filter all rows from the &lt;code&gt;ecom&lt;/code&gt; table where the &lt;code&gt;device&lt;/code&gt; column
has NULL values.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT * 
                 FROM ecom 
                 WHERE device IS NULL&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] id          referrer    device      bouncers    n_visit     n_pages    
##  [7] duration    country     purchase    order_items order_value
## &amp;lt;0 rows&amp;gt; (or 0-length row.names)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;like&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;LIKE&lt;/h5&gt;
&lt;p&gt;The LIKE operator is used to search for a specific pattern in a column. There are two wildcards used in conjunction with the LIKE operator:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;% : represents zero, one, or multiple characters&lt;/li&gt;
&lt;li&gt;_ : represents a single character&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the following example, we filter all rows from the &lt;code&gt;ecom&lt;/code&gt; table where the name of the &lt;code&gt;country&lt;/code&gt; starts with &lt;code&gt;P&lt;/code&gt;. We use &lt;code&gt;%&lt;/code&gt; after &lt;code&gt;P&lt;/code&gt; to indicate that it can be followed by any number or type of characters.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT * 
                 FROM ecom 
                 WHERE country LIKE &amp;#39;P%&amp;#39;&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   id referrer device bouncers n_visit n_pages duration     country purchase
## 1  5    yahoo mobile        1       9       1      955      Poland        0
## 2 14    yahoo tablet        0       5       8       80 Philippines        0
## 3 17     bing tablet        0       5      16      368        Peru        1
## 4 43     bing laptop        1       0       1      456    Portugal        0
##   order_items order_value
## 1           0           0
## 2           2         362
## 3           6        1049
## 4           0           0
##  [ reached &amp;#39;max&amp;#39; / getOption(&amp;quot;max.print&amp;quot;) -- omitted 135 rows ]&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us look at another example where we filter all rows from the &lt;code&gt;ecom&lt;/code&gt; table where the name of the
country should follow the below conditions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;name can start with any character&lt;/li&gt;
&lt;li&gt;the second character must be &lt;code&gt;o&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;it can have any type or number of characters after the second character&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;SELECT * 
                 FROM ecom 
                 WHERE country LIKE &amp;#39;_o%&amp;#39;&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   id referrer device bouncers n_visit n_pages duration      country purchase
## 1  5    yahoo mobile        1       9       1      955       Poland        0
## 2  6    yahoo laptop        0       5       5      135 South Africa        0
## 3 19   social tablet        0       7      10      290     Colombia        1
## 4 30    yahoo mobile        0       8       9      225     Colombia        0
##   order_items order_value
## 1           0           0
## 2           0           0
## 3           9        1304
## 4           0           0
##  [ reached &amp;#39;max&amp;#39; / getOption(&amp;quot;max.print&amp;quot;) -- omitted 117 rows ]&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;In this post we learnt to&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;select
&lt;ul&gt;
&lt;li&gt;single column&lt;/li&gt;
&lt;li&gt;multiple columns&lt;/li&gt;
&lt;li&gt;distinct values in a column&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;limit the number of records returned&lt;/li&gt;
&lt;li&gt;handle NULL values&lt;/li&gt;
&lt;li&gt;and filter columns using the following operators
&lt;ul&gt;
&lt;li&gt;WHERE&lt;/li&gt;
&lt;li&gt;AND, or &amp;amp; NOT&lt;/li&gt;
&lt;li&gt;BETWEEN&lt;/li&gt;
&lt;li&gt;IN&lt;/li&gt;
&lt;li&gt;LIKE&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;up-next..&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Up Next..&lt;/h3&gt;
&lt;p&gt;In the next post, we will learn advanced SQL commands.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Data Wrangling with dbplyr</title>
      <link>https://blog.rsquaredacademy.com/data-wrangling-with-dbplyr/</link>
      <pubDate>Sun, 09 Dec 2018 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/data-wrangling-with-dbplyr/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;This is the second post in the series &lt;strong&gt;R &amp;amp; Databases&lt;/strong&gt;. You can find the links to the first post of this series below:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://blog.rsquaredacademy.com/quick-guide-r-sqlite/&#34;&gt;Quick Guide: R &amp;amp; SQLite&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this post, we will learn to query data from a database using dplyr.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;p&gt;We will use the following libraries in this post:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://readr.tidyverse.org/&#34;&gt;DBI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://rstats-db.github.io/RSQLite/&#34;&gt;RSQLite&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://dbplyr.tidyverse.org/&#34;&gt;dbplyr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://dplyr.tidyverse.org/&#34;&gt;dplyr&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt; and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/f5ee72cee9ab3256230cdedecd3ef25b&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;div id=&#34;connect-to-database&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Connect to Database&lt;/h4&gt;
&lt;p&gt;Let us connect to an in memory SQLite database using &lt;code&gt;dbConnect()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;con &amp;lt;- dbConnect(RSQLite::SQLite(), &amp;quot;:memory:&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We will copy the &lt;code&gt;mtcars&lt;/code&gt; data to the database so that we can use it for running
dplyr statements.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dplyr::copy_to(con, mtcars)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;reference-copied-data-frame&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Reference Copied Data Frame&lt;/h4&gt;
&lt;p&gt;In order to use dplyr functions, we need to reference the table in the database using
&lt;code&gt;tbl()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mtcars2 &amp;lt;- dplyr::tbl(con, &amp;quot;mtcars&amp;quot;)
mtcars2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # Source:   table&amp;lt;mtcars&amp;gt; [?? x 11]
## # Database: sqlite 3.30.1 [:memory:]
##      mpg   cyl  disp    hp  drat    wt  qsec    vs    am  gear  carb
##    &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;
##  1  21       6  160    110  3.9   2.62  16.5     0     1     4     4
##  2  21       6  160    110  3.9   2.88  17.0     0     1     4     4
##  3  22.8     4  108     93  3.85  2.32  18.6     1     1     4     1
##  4  21.4     6  258    110  3.08  3.22  19.4     1     0     3     1
##  5  18.7     8  360    175  3.15  3.44  17.0     0     0     3     2
##  6  18.1     6  225    105  2.76  3.46  20.2     1     0     3     1
##  7  14.3     8  360    245  3.21  3.57  15.8     0     0     3     4
##  8  24.4     4  147.    62  3.69  3.19  20       1     0     4     2
##  9  22.8     4  141.    95  3.92  3.15  22.9     1     0     4     2
## 10  19.2     6  168.   123  3.92  3.44  18.3     1     0     4     4
## # ... with more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;query-data&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Query Data&lt;/h4&gt;
&lt;p&gt;We will look at some simple examples. Let us start by selecting &lt;code&gt;mpg&lt;/code&gt;, &lt;code&gt;cyl&lt;/code&gt; and &lt;code&gt;drat&lt;/code&gt;
columns from &lt;code&gt;mtcars2&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;select(mtcars2, mpg, cyl, drat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # Source:   lazy query [?? x 3]
## # Database: sqlite 3.30.1 [:memory:]
##      mpg   cyl  drat
##    &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;
##  1  21       6  3.9 
##  2  21       6  3.9 
##  3  22.8     4  3.85
##  4  21.4     6  3.08
##  5  18.7     8  3.15
##  6  18.1     6  2.76
##  7  14.3     8  3.21
##  8  24.4     4  3.69
##  9  22.8     4  3.92
## 10  19.2     6  3.92
## # ... with more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can filter data as well. Filter all the rows from &lt;code&gt;mtcars2&lt;/code&gt; where &lt;code&gt;mpg&lt;/code&gt; is
greater than 25.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;filter(mtcars2, mpg &amp;gt; 25)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # Source:   lazy query [?? x 11]
## # Database: sqlite 3.30.1 [:memory:]
##     mpg   cyl  disp    hp  drat    wt  qsec    vs    am  gear  carb
##   &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;
## 1  32.4     4  78.7    66  4.08  2.2   19.5     1     1     4     1
## 2  30.4     4  75.7    52  4.93  1.62  18.5     1     1     4     2
## 3  33.9     4  71.1    65  4.22  1.84  19.9     1     1     4     1
## 4  27.3     4  79      66  4.08  1.94  18.9     1     1     4     1
## 5  26       4 120.     91  4.43  2.14  16.7     0     1     5     2
## 6  30.4     4  95.1   113  3.77  1.51  16.9     1     1     5     2&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Time to do some grouping and summarizing. Let us compute the average mileage for
different types of cylinders.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mtcars2 %&amp;gt;%
  group_by(cyl) %&amp;gt;%
  summarise(mileage = mean(mpg))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: Missing values are always removed in SQL.
## Use `mean(x, na.rm = TRUE)` to silence this warning
## This warning is displayed only once per session.&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # Source:   lazy query [?? x 2]
## # Database: sqlite 3.30.1 [:memory:]
##     cyl mileage
##   &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;
## 1     4    26.7
## 2     6    19.7
## 3     8    15.1&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;show-query&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Show Query&lt;/h4&gt;
&lt;p&gt;If you want to view the SQL query generated in the above step, use &lt;code&gt;show_query()&lt;/code&gt; or &lt;code&gt;explain()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mileages &amp;lt;- 
  mtcars2 %&amp;gt;%
  group_by(cyl) %&amp;gt;%
  summarise(mileage = mean(mpg))

dplyr::show_query(mileages)
## &amp;lt;SQL&amp;gt;
## SELECT `cyl`, AVG(`mpg`) AS `mileage`
## FROM `mtcars`
## GROUP BY `cyl`

dplyr::explain(mileages)
## &amp;lt;SQL&amp;gt;
## SELECT `cyl`, AVG(`mpg`) AS `mileage`
## FROM `mtcars`
## GROUP BY `cyl`
## 
## &amp;lt;PLAN&amp;gt;
##   id parent notused                       detail
## 1  6      0       0            SCAN TABLE mtcars
## 2  8      0       0 USE TEMP B-TREE FOR GROUP BY&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;collect-data&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Collect Data&lt;/h4&gt;
&lt;p&gt;Now, some interesting facts. When working with databases, &lt;strong&gt;dplyr&lt;/strong&gt; never pulls data into R unless you explicitly ask for it. In the previous example, dplyr will not do anything until you ask for the mileages data. It generates the SQL and only pulls down a few rows when you try to print &lt;code&gt;mileages&lt;/code&gt;.
So how do we pull all the data and store it for further analysis? &lt;code&gt;collect()&lt;/code&gt; will pull all
the data and store it in a tibble and you can use it for any further analysis.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dplyr::collect(mileages)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 x 2
##     cyl mileage
##   &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;
## 1     4    26.7
## 2     6    19.7
## 3     8    15.1&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;references&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://dbplyr.tidyverse.org/&#34; class=&#34;uri&#34;&gt;https://dbplyr.tidyverse.org/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;up-next..&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Up Next..&lt;/h3&gt;
&lt;p&gt;In the next &lt;a href=&#34;&#34;&gt;post&lt;/a&gt;, we will learn basic SQL commands.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Quick Guide: R &amp; SQLite</title>
      <link>https://blog.rsquaredacademy.com/quick-guide-r-sqlite/</link>
      <pubDate>Tue, 27 Nov 2018 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/quick-guide-r-sqlite/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;This is the first post in the series &lt;strong&gt;R &amp;amp; Databases&lt;/strong&gt;. You can find the links to the other two posts of this series below:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://rsquaredacademy.github.io/blog/post/data-wrangling-with-dbplyr&#34;&gt;Data Wrangling with dbplyr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://rsquaredacademy.github.io/blog/post/sql-for-data-science-part-1&#34;&gt;SQL for Data Science - Part 1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://rsquaredacademy.github.io/blog/post/sql-for-data-science-part-2&#34;&gt;SQL for Data Science - Part 2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this post, we will learn to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;connect to a SQLite database from R&lt;/li&gt;
&lt;li&gt;display database information&lt;/li&gt;
&lt;li&gt;list tables in the database&lt;/li&gt;
&lt;li&gt;query data
&lt;ul&gt;
&lt;li&gt;read entire table&lt;/li&gt;
&lt;li&gt;read few rows&lt;/li&gt;
&lt;li&gt;read data in batches&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;create table in database&lt;/li&gt;
&lt;li&gt;overwrite table in database&lt;/li&gt;
&lt;li&gt;append data to table in database&lt;/li&gt;
&lt;li&gt;remove table from database&lt;/li&gt;
&lt;li&gt;generate SQL query&lt;/li&gt;
&lt;li&gt;close database connection&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;p&gt;We will use the following libraries in this post:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://rstats-db.github.io/DBI/&#34;&gt;DBI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://rstats-db.github.io/RSQLite/&#34;&gt;RSQLite&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt; and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/7d99eb52a0e44cd1f87c8689cf1a307d&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;div id=&#34;connection&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Connection&lt;/h4&gt;
&lt;p&gt;The first step is to connect to a database. In this post, we will connect to an in memory
SQLite databse using &lt;code&gt;dbConnect()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;con &amp;lt;- dbConnect(RSQLite::SQLite(), &amp;quot;:memory:&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;connection-summary&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Connection Summary&lt;/h4&gt;
&lt;p&gt;We can get the more information about the connection using &lt;code&gt;summary()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;summary(con)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##           Length            Class             Mode 
##                1 SQLiteConnection               S4&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;list-tables&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;List Tables&lt;/h4&gt;
&lt;p&gt;Now that we are connected to a database, let us list all the tables present in it using
&lt;code&gt;dbListTables()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbListTables(con)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;ecom&amp;quot;         &amp;quot;sqlite_stat1&amp;quot; &amp;quot;sqlite_stat4&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;list-fields&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;List Fields&lt;/h4&gt;
&lt;p&gt;Time to explore the &lt;code&gt;ecom&lt;/code&gt; table in the database. Use &lt;code&gt;dbListFields()&lt;/code&gt; to list all
the fields in the table.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbListFields(con, &amp;quot;ecom&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;referrer&amp;quot; &amp;quot;device&amp;quot;   &amp;quot;bouncers&amp;quot; &amp;quot;n_visit&amp;quot;  &amp;quot;n_pages&amp;quot;  &amp;quot;duration&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;querying-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Querying Data&lt;/h3&gt;
&lt;p&gt;The main objectives of connecting to a database are to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;query data from the tables already present&lt;/li&gt;
&lt;li&gt;create new tables&lt;/li&gt;
&lt;li&gt;overwrite existing tables&lt;/li&gt;
&lt;li&gt;delete existing tables&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let us begin with querying data. We can do this in the following ways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;read an entire table at once&lt;/li&gt;
&lt;li&gt;read few rows from a table&lt;/li&gt;
&lt;li&gt;read data in batches&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;entire-table&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Entire Table&lt;/h4&gt;
&lt;p&gt;We can read an entire table from a database using &lt;code&gt;dbReadTable()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbReadTable(con, &amp;#39;ecom&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    referrer device bouncers n_visit n_pages duration
## 1    google laptop        1      10       1      693
## 2     yahoo tablet        1       9       1      459
## 3    direct laptop        1       0       1      996
## 4      bing tablet        0       3      18      468
## 5     yahoo mobile        1       9       1      955
## 6     yahoo laptop        0       5       5      135
## 7     yahoo mobile        1      10       1       75
## 8    direct mobile        1      10       1      908
## 9      bing mobile        0       3      19      209
## 10   google mobile        1       6       1      208
## 11   direct laptop        1       9       1      738
## 12   direct tablet        0       6      12      132
## 13   direct mobile        0       9      14      406
## 14    yahoo tablet        0       5       8       80
## 15    yahoo mobile        0       7       1       19
## 16     bing laptop        1       1       1      995
## 17     bing tablet        0       5      16      368
## 18   google tablet        1       7       1      406
## 19   social tablet        0       7      10      290
## 20   social tablet        0       2       1       28&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In some cases, we may not need the entire table but only a specific number of rows.
Use &lt;code&gt;dbGetQuery()&lt;/code&gt; and supply a SQL statement specifying the number of rows of
data to be read from the table. In the below example, we read ten rows of data from
the &lt;code&gt;ecom&lt;/code&gt; table.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;few-rows&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Few Rows&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;select * from ecom limit 10&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    referrer device bouncers n_visit n_pages duration
## 1    google laptop        1      10       1      693
## 2     yahoo tablet        1       9       1      459
## 3    direct laptop        1       0       1      996
## 4      bing tablet        0       3      18      468
## 5     yahoo mobile        1       9       1      955
## 6     yahoo laptop        0       5       5      135
## 7     yahoo mobile        1      10       1       75
## 8    direct mobile        1      10       1      908
## 9      bing mobile        0       3      19      209
## 10   google mobile        1       6       1      208&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In case of very large table, we can read data in batches using &lt;code&gt;dbSendQuery()&lt;/code&gt; and
&lt;code&gt;dbFetch()&lt;/code&gt;. We can mention the number of rows of data to be read while fetching the
data using the query generated by &lt;code&gt;dbGetQuery()&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;read-data-in-batches&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Read Data in Batches&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;query &amp;lt;- dbSendQuery(con, &amp;#39;select * from ecom&amp;#39;)
result &amp;lt;- dbFetch(query, n = 15)
result&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    referrer device bouncers n_visit n_pages duration
## 1    google laptop        1      10       1      693
## 2     yahoo tablet        1       9       1      459
## 3    direct laptop        1       0       1      996
## 4      bing tablet        0       3      18      468
## 5     yahoo mobile        1       9       1      955
## 6     yahoo laptop        0       5       5      135
## 7     yahoo mobile        1      10       1       75
## 8    direct mobile        1      10       1      908
## 9      bing mobile        0       3      19      209
## 10   google mobile        1       6       1      208
## 11   direct laptop        1       9       1      738
## 12   direct tablet        0       6      12      132
## 13   direct mobile        0       9      14      406
## 14    yahoo tablet        0       5       8       80
## 15    yahoo mobile        0       7       1       19&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;query&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Query&lt;/h3&gt;
&lt;div id=&#34;query-status&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Query Status&lt;/h4&gt;
&lt;p&gt;To know the status of a query, use &lt;code&gt;dbHasCompleted()&lt;/code&gt;. It is very useful in
cases of queries that might take a long time to complete.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbHasCompleted(query)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;query-info&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Query Info&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;dbGetInfo()&lt;/code&gt; will return the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the sql staement&lt;/li&gt;
&lt;li&gt;number of rows fetched&lt;/li&gt;
&lt;li&gt;number of rows modified/affected&lt;/li&gt;
&lt;li&gt;status of the query&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetInfo(query)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## $statement
## [1] &amp;quot;select * from ecom&amp;quot;
## 
## $row.count
## [1] 15
## 
## $rows.affected
## [1] 0
## 
## $has.completed
## [1] FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;latest-query&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Latest Query&lt;/h4&gt;
&lt;p&gt;To get the latest query, use &lt;code&gt;dbGetStatement()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetStatement(query)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;select * from ecom&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;rows-fetched&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Rows Fetched&lt;/h4&gt;
&lt;p&gt;To check the number of rows of data returned by a query, use &lt;code&gt;dbGetRowCount()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetRowCount(query)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 15&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;rows-affected&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Rows Affected&lt;/h4&gt;
&lt;p&gt;To know the number of rows modified or affected in the table, use &lt;code&gt;dbGetRowsAffected()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetRowsAffected(query)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;column-info&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Column Info&lt;/h4&gt;
&lt;p&gt;To know the name of the columns and their data types, use &lt;code&gt;dbColumnInfo()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbColumnInfo(query)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##       name      type
## 1 referrer character
## 2   device character
## 3 bouncers   integer
## 4  n_visit    double
## 5  n_pages    double
## 6 duration    double&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;create-table&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Create Table&lt;/h3&gt;
&lt;p&gt;So far we have explored querying data from an existing table. Now, let us turn our
attention to creating new tables in the database.&lt;/p&gt;
&lt;div id=&#34;introduction-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Introduction&lt;/h4&gt;
&lt;p&gt;To create a new table, use &lt;code&gt;dbWriteTable()&lt;/code&gt;. It takes the following 3 arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;connection name&lt;/li&gt;
&lt;li&gt;name of the new table&lt;/li&gt;
&lt;li&gt;data for the new table&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x &amp;lt;- 1:10
y &amp;lt;- letters[1:10]
trial &amp;lt;- tibble::tibble(x, y)
dbWriteTable(con, &amp;quot;trial&amp;quot;, trial)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: Closing open result set, pending rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us check if the new table has been created.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbListTables(con)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;ecom&amp;quot;         &amp;quot;sqlite_stat1&amp;quot; &amp;quot;sqlite_stat4&amp;quot; &amp;quot;trial&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbExistsTable(con, &amp;quot;trial&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us query data from the new table.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;select * from trial limit 5&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   x y
## 1 1 a
## 2 2 b
## 3 3 c
## 4 4 d
## 5 5 e&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;overwrite-table&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Overwrite Table&lt;/h4&gt;
&lt;p&gt;In some cases, you may want to overwrite the data in an existing table. Use the
&lt;code&gt;overwrite&lt;/code&gt; argument in &lt;code&gt;dbWriteTable()&lt;/code&gt; and set it to &lt;code&gt;TRUE&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x &amp;lt;- sample(100, 10)
y &amp;lt;- letters[11:20]
trial2 &amp;lt;- tibble::tibble(x, y)
dbWriteTable(con, &amp;quot;trial&amp;quot;, trial2, overwrite = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us see if the &lt;strong&gt;trial&lt;/strong&gt; table has been overwritten.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbGetQuery(con, &amp;quot;select * from trial limit 5&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    x y
## 1 48 k
## 2 58 l
## 3 85 m
## 4 99 n
## 5 78 o&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;append-data&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Append Data&lt;/h4&gt;
&lt;p&gt;You can append data to an existing table by setting the &lt;code&gt;append&lt;/code&gt; argument in
&lt;code&gt;dbWriteTable()&lt;/code&gt; to &lt;code&gt;TRUE&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x &amp;lt;- sample(100, 10)
y &amp;lt;- letters[5:14]
trial3 &amp;lt;- tibble::tibble(x, y)
dbWriteTable(con, &amp;quot;trial&amp;quot;, trial3, append = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us quickly check if the new data has been appended to the &lt;strong&gt;trial&lt;/strong&gt; table.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbReadTable(con, &amp;quot;trial&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##     x y
## 1  48 k
## 2  58 l
## 3  85 m
## 4  99 n
## 5  78 o
## 6   9 p
## 7   6 q
## 8  59 r
## 9  11 s
## 10 38 t
## 11 39 e
## 12 69 f
## 13 43 g
## 14 71 h
## 15 99 i
## 16 56 j
## 17 45 k
## 18 81 l
## 19 93 m
## 20 47 n&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can also use &lt;code&gt;sqlAppendTable()&lt;/code&gt; to append data to an existing table.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;sqlAppendTable(con, &amp;quot;ecom&amp;quot;, head(ecom))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: Do not rely on the default value of the row.names argument for
## sqlAppendTable(), it will change in the future.&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## &amp;lt;SQL&amp;gt; INSERT INTO `ecom`
##   (`referrer`, `device`, `bouncers`, `n_visit`, `n_pages`, `duration`)
## VALUES
##   (&amp;#39;google&amp;#39;, &amp;#39;laptop&amp;#39;, TRUE, 10, 1, 693),
##   (&amp;#39;yahoo&amp;#39;, &amp;#39;tablet&amp;#39;, TRUE, 9, 1, 459),
##   (&amp;#39;direct&amp;#39;, &amp;#39;laptop&amp;#39;, TRUE, 0, 1, 996),
##   (&amp;#39;bing&amp;#39;, &amp;#39;tablet&amp;#39;, FALSE, 3, 18, 468),
##   (&amp;#39;yahoo&amp;#39;, &amp;#39;mobile&amp;#39;, TRUE, 9, 1, 955),
##   (&amp;#39;yahoo&amp;#39;, &amp;#39;laptop&amp;#39;, FALSE, 5, 5, 135)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;insert-rows&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Insert Rows&lt;/h3&gt;
&lt;div id=&#34;introduction-2&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Introduction&lt;/h4&gt;
&lt;p&gt;We can insert new rows into existing tables using:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;dbExecute()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;dbSendStatement()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Both the function take 2 arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;connection name&lt;/li&gt;
&lt;li&gt;sql statement&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# use dbExecute
dbExecute(con,
  &amp;quot;INSERT into trial (x, y) VALUES (32, &amp;#39;c&amp;#39;), (45, &amp;#39;k&amp;#39;), (61, &amp;#39;h&amp;#39;)&amp;quot;
)
## [1] 3

# use dbSendStatement
dbSendStatement(con,
  &amp;quot;INSERT into trial (x, y) VALUES (25, &amp;#39;m&amp;#39;), (54, &amp;#39;l&amp;#39;), (16, &amp;#39;y&amp;#39;)&amp;quot;
)
## &amp;lt;SQLiteResult&amp;gt;
##   SQL  INSERT into trial (x, y) VALUES (25, &amp;#39;m&amp;#39;), (54, &amp;#39;l&amp;#39;), (16, &amp;#39;y&amp;#39;)
##   ROWS Fetched: 0 [complete]
##        Changed: 3&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;remove-table&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Remove Table&lt;/h4&gt;
&lt;p&gt;If you want to delete/remove a table from the database, use &lt;code&gt;dbRemoveTable()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbRemoveTable(con, &amp;quot;trial&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: Closing open result set, pending rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;sqlite-data-type&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;SQLite Data Type&lt;/h3&gt;
&lt;p&gt;If you want to know the data type, use &lt;code&gt;dbDataType()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbDataType(RSQLite::SQLite(), &amp;quot;a&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;TEXT&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbDataType(RSQLite::SQLite(), 1:5)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;INTEGER&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbDataType(RSQLite::SQLite(), 1.5)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;REAL&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;close-connection&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Close Connection&lt;/h4&gt;
&lt;p&gt;It is a good practice to close connection to a database when you no longer need to
read/write data from/to it. Use &lt;code&gt;dbDisconnect()&lt;/code&gt; to close the database connection.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dbDisconnect(con)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;references&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://dbi.r-dbi.org/&#34; class=&#34;uri&#34;&gt;https://dbi.r-dbi.org/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Categorical Data Analysis using forcats</title>
      <link>https://blog.rsquaredacademy.com/working-with-categorical-data-using-forcats/</link>
      <pubDate>Thu, 15 Nov 2018 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/working-with-categorical-data-using-forcats/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In this post, we will learn to work with categorical/qualitative data in R
using &lt;a href=&#34;https://forcats.tidyverse.org&#34;&gt;forcats&lt;/a&gt;. Let us begin by installing
and loading forcats and a set of other pacakges we will be using.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Libraries &amp;amp; Code&lt;/h2&gt;
&lt;p&gt;We will use the following packages:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://forcats.tidyverse.org/index.html&#34;&gt;forcats&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://dplyr.tidyverse.org/index.html&#34;&gt;dplyr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://magrittr.tidyverse.org/index.html&#34;&gt;magrittr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://ggplot2.tidyverse.org/index.html&#34;&gt;ggplot2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://tibble.tidyverse.org/index.html&#34;&gt;tibbe&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://purrr.tidyverse.org/index.html&#34;&gt;purrr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;and &lt;a href=&#34;http://readr.tidyverse.org/index.html&#34;&gt;readr&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The codes from &lt;a href=&#34;https://gist.github.com/aravindhebbali/85fac536f563ae3fd8e2605fd56a7086&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(forcats)
library(tibble)
library(magrittr)
library(purrr)
library(dplyr)
library(ggplot2)
library(readr)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;case-study&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Case Study&lt;/h2&gt;
&lt;p&gt;We will use a case study to explore the various features of the forcats
package. You can download the data for the case study from
&lt;a href=&#34;https://raw.githubusercontent.com/rsquaredacademy/datasets/master/web.csv&#34;&gt;here&lt;/a&gt;
or directly import the data using the readr package. We will do the following
in this case study:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;compute the frequency of different referrers&lt;/li&gt;
&lt;li&gt;plot average number of pages browsed for different referrers&lt;/li&gt;
&lt;li&gt;collapse referrers with low sample size into a single group&lt;/li&gt;
&lt;li&gt;club traffic from social media websites into a new category&lt;/li&gt;
&lt;li&gt;group referrers with traffic below a threshold into a single category&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom &amp;lt;- 
  read_csv(&amp;#39;https://raw.githubusercontent.com/rsquaredacademy/datasets/master/web.csv&amp;#39;,
    col_types = cols_only(
      referrer = col_factor(levels = c(&amp;quot;bing&amp;quot;, &amp;quot;direct&amp;quot;, &amp;quot;social&amp;quot;, &amp;quot;yahoo&amp;quot;, &amp;quot;google&amp;quot;)),
      n_pages = col_double(), duration = col_double()
    )
  )

ecom&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1,000 x 3
##    referrer n_pages duration
##    &amp;lt;fct&amp;gt;      &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt;
##  1 google         1      693
##  2 yahoo          1      459
##  3 direct         1      996
##  4 bing          18      468
##  5 yahoo          1      955
##  6 yahoo          5      135
##  7 yahoo          1       75
##  8 direct         1      908
##  9 bing          19      209
## 10 google         1      208
## # ... with 990 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us extract the &lt;code&gt;referrer&lt;/code&gt; column from the above data using &lt;code&gt;use_series&lt;/code&gt;
and save it in a new variable &lt;code&gt;referrers&lt;/code&gt;. Instead of using ecom which is
a tibble, we will use &lt;code&gt;referrers&lt;/code&gt; which is a vector. We do this to avoid
extracting the &lt;code&gt;referrer&lt;/code&gt; column from the above data in later examples.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;referrers &amp;lt;- use_series(ecom, referrer)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;tabulate-referrers&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Tabulate Referrers&lt;/h2&gt;
&lt;p&gt;Let us look at the traffic driven by different referrer types.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_count.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fct_count(referrers)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 5 x 2
##   f          n
##   &amp;lt;fct&amp;gt;  &amp;lt;int&amp;gt;
## 1 bing     194
## 2 direct   191
## 3 social   200
## 4 yahoo    207
## 5 google   208&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you want to sort the output in descending order, use &lt;code&gt;sort&lt;/code&gt; and set it to &lt;code&gt;TRUE&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fct_count(referrers, sort = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 5 x 2
##   f          n
##   &amp;lt;fct&amp;gt;  &amp;lt;int&amp;gt;
## 1 google   208
## 2 yahoo    207
## 3 social   200
## 4 bing     194
## 5 direct   191&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Use &lt;code&gt;fct_unique&lt;/code&gt; to view the categories or levels of the referrer variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fct_unique(referrers)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] bing   direct social yahoo  google
## Levels: bing direct social yahoo google&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;reorder-referrers&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Reorder Referrers&lt;/h2&gt;
&lt;p&gt;We want to examine the average number of pages visited by each referrer type.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;refer_summary &amp;lt;- 
  ecom %&amp;gt;%
  group_by(referrer) %&amp;gt;%
  summarise(
    page = mean(n_pages),
    tos = mean(duration),
    n = n()
  )&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## `summarise()` ungrouping (override with `.groups` argument)&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;refer_summary&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 5 x 4
##   referrer  page   tos     n
## * &amp;lt;fct&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;int&amp;gt;
## 1 bing      6.13  368.   194
## 2 direct    6.38  358.   191
## 3 social    5.42  355.   200
## 4 yahoo     5.99  336.   207
## 5 google    5.73  360.   208&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us plot the average number of pages visited by each referrer type.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;refer_summary %&amp;gt;%
  ggplot() +
  geom_point(aes(page, referrer))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-11-15-working-with-categorical-data-using-forcats_files/figure-html/cat10-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Use &lt;code&gt;fct_reorder&lt;/code&gt; to reorder the referrer types by the average number of pages
visited.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;refer_summary %&amp;gt;%
  ggplot() +
  geom_point(aes(page, fct_reorder(referrer, page)))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-11-15-working-with-categorical-data-using-forcats_files/figure-html/cat11-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;plot-referrer-frequency-descending-order&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Plot Referrer Frequency (Descending Order)&lt;/h2&gt;
&lt;p&gt;Since we want to plot the referrers in descending order of frequency, we will
use &lt;code&gt;fct_infreq()&lt;/code&gt; to reorder by frequency.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_infreq.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;referrers %&amp;gt;%
  fct_infreq() %&amp;gt;%
  fct_unique()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] google yahoo  social bing   direct
## Levels: google yahoo social bing direct&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now that we know how to reorder categories/levels by frequency, let us reorder
the referrers by frequency and plot them.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom %&amp;gt;%
  mutate(
    ref = referrer %&amp;gt;% 
      fct_infreq()
  ) %&amp;gt;%
  ggplot(aes(ref)) +
  geom_bar()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-11-15-working-with-categorical-data-using-forcats_files/figure-html/cat4-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;plot-referrer-frequency-ascending-order&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Plot Referrer Frequency (Ascending Order)&lt;/h2&gt;
&lt;p&gt;Let us look at the categories of the referrer variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fct_unique(referrers)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] bing   direct social yahoo  google
## Levels: bing direct social yahoo google&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Since we want to plot the referrers in ascending order of frequency, we will
use &lt;code&gt;fct_rev()&lt;/code&gt; to reverse the order.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_rev.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;referrers %&amp;gt;%
  fct_rev() %&amp;gt;%
  fct_unique()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] google yahoo  social direct bing  
## Levels: google yahoo social direct bing&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us reorder the referrers by frequency first and then reverse the order
before plotting their frequencies.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom %&amp;gt;%
  mutate(
    ref = referrer %&amp;gt;% 
      fct_infreq() %&amp;gt;% 
      fct_rev()
  ) %&amp;gt;%
  ggplot(aes(ref)) +
  geom_bar()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-11-15-working-with-categorical-data-using-forcats_files/figure-html/cat5-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;case-study-2&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Case Study 2&lt;/h2&gt;
&lt;p&gt;In this case study, we will learn to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;combine categories&lt;/li&gt;
&lt;li&gt;recategorize&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The data set we will use has just one column &lt;code&gt;traffics&lt;/code&gt; i.e. the source
of traffic for a imaginary website.&lt;/p&gt;
&lt;div id=&#34;data-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;traffic &amp;lt;- 
  read_csv(&amp;#39;https://raw.githubusercontent.com/rsquaredacademy/datasets/master/web_traffic.csv&amp;#39;,
    col_types = list(
      col_factor(levels = c(&amp;quot;affiliates&amp;quot;, &amp;quot;bing&amp;quot;, &amp;quot;direct&amp;quot;, &amp;quot;facebook&amp;quot;, 
        &amp;quot;yahoo&amp;quot;, &amp;quot;google&amp;quot;, &amp;quot;instagram&amp;quot;, &amp;quot;twitter&amp;quot;, &amp;quot;unknown&amp;quot;)
      )
    )
  )

traffic&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 48,232 x 1
##    traffics
##    &amp;lt;fct&amp;gt;   
##  1 google  
##  2 google  
##  3 google  
##  4 google  
##  5 google  
##  6 google  
##  7 google  
##  8 google  
##  9 google  
## 10 google  
## # ... with 48,222 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us extract the &lt;code&gt;traffics&lt;/code&gt; column from the above data using &lt;code&gt;use_series&lt;/code&gt;
and save it in a new variable &lt;code&gt;traffics&lt;/code&gt;. Instead of using traffic which is
a tibble, we will use &lt;code&gt;traffics&lt;/code&gt; which is a vector. We do this to avoid
extracting the &lt;code&gt;traffics&lt;/code&gt; column from the above data in all the examples
shown below.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;traffics &amp;lt;- use_series(traffic, traffics)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;tabulate-referrer&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Tabulate Referrer&lt;/h2&gt;
&lt;p&gt;Let us compute the traffic driven by different referrers using &lt;code&gt;fct_count&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fct_count(traffics)   &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 9 x 2
##   f              n
##   &amp;lt;fct&amp;gt;      &amp;lt;int&amp;gt;
## 1 affiliates  7641
## 2 bing        5893
## 3 direct      1350
## 4 facebook    8135
## 5 yahoo       4899
## 6 google      9229
## 7 instagram   3907
## 8 twitter     4521
## 9 unknown     2657&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;collapse-referrer-categories&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Collapse Referrer Categories&lt;/h2&gt;
&lt;p&gt;We want to group some of the referrers into 2 categories:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;social&lt;/li&gt;
&lt;li&gt;search&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To group categories/levels, we will use &lt;code&gt;fct_collapse()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_collapse.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;traffics %&amp;gt;%
  fct_collapse(
    social = c(&amp;quot;facebook&amp;quot;, &amp;quot;twitter&amp;quot;, &amp;quot;instagram&amp;quot;),
    search = c(&amp;quot;google&amp;quot;, &amp;quot;bing&amp;quot;, &amp;quot;yahoo&amp;quot;)
  ) %&amp;gt;% 
  fct_count()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 5 x 2
##   f              n
##   &amp;lt;fct&amp;gt;      &amp;lt;int&amp;gt;
## 1 affiliates  7641
## 2 search     20021
## 3 direct      1350
## 4 social     16563
## 5 unknown     2657&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The above result can be achieved using &lt;code&gt;fct_recode()&lt;/code&gt; as shown below:&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_recode.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fct_recode(traffics, 
  search = &amp;quot;bing&amp;quot;, 
  search = &amp;quot;yahoo&amp;quot;, 
  search = &amp;quot;google&amp;quot;,
  social = &amp;quot;facebook&amp;quot;, 
  social = &amp;quot;twitter&amp;quot;, 
  social = &amp;quot;instagram&amp;quot;) %&amp;gt;%
  levels()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;affiliates&amp;quot; &amp;quot;search&amp;quot;     &amp;quot;direct&amp;quot;     &amp;quot;social&amp;quot;     &amp;quot;unknown&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;lump-infrequent-referrer-types&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Lump Infrequent Referrer Types&lt;/h2&gt;
&lt;p&gt;Let us group together referrer types that drive low traffic to the website.
Use &lt;code&gt;fct_lump()&lt;/code&gt; to lump together categories.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_lump_1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fct_count(traffics)
## # A tibble: 9 x 2
##   f              n
##   &amp;lt;fct&amp;gt;      &amp;lt;int&amp;gt;
## 1 affiliates  7641
## 2 bing        5893
## 3 direct      1350
## 4 facebook    8135
## 5 yahoo       4899
## 6 google      9229
## 7 instagram   3907
## 8 twitter     4521
## 9 unknown     2657

traffics %&amp;gt;% 
  fct_lump() %&amp;gt;% 
  table()
## .
## affiliates       bing   facebook      yahoo     google  instagram    twitter 
##       7641       5893       8135       4899       9229       3907       4521 
##    unknown      Other 
##       2657       1350&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;retain-top-3-referrers&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Retain top 3 referrers&lt;/h2&gt;
&lt;p&gt;We want to retain the top 3 referrers and combine the rest of them into a
single category.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 9 x 2
##   f              n
##   &amp;lt;fct&amp;gt;      &amp;lt;int&amp;gt;
## 1 google      9229
## 2 facebook    8135
## 3 affiliates  7641
## 4 bing        5893
## 5 yahoo       4899
## 6 twitter     4521
## 7 instagram   3907
## 8 unknown     2657
## 9 direct      1350&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Use &lt;code&gt;fct_lump()&lt;/code&gt; and set the argument &lt;code&gt;n&lt;/code&gt; to &lt;code&gt;3&lt;/code&gt; indicating we want to
retain top 3 categories and combine the rest.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;traffics %&amp;gt;% 
  fct_lump(n = 3) %&amp;gt;% 
  table()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## .
## affiliates   facebook     google      Other 
##       7641       8135       9229      23227&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;lump-referrer-types-with-less-than-10-traffic&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Lump Referrer Types with less than 10% traffic&lt;/h2&gt;
&lt;p&gt;Let us combine referrers that drive less than 10% traffic to the website.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_lump_2.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 9 x 3
##   f              n percent
##   &amp;lt;fct&amp;gt;      &amp;lt;int&amp;gt;   &amp;lt;dbl&amp;gt;
## 1 affiliates  7641   15.8 
## 2 bing        5893   12.2 
## 3 direct      1350    2.8 
## 4 facebook    8135   16.9 
## 5 yahoo       4899   10.2 
## 6 google      9229   19.1 
## 7 instagram   3907    8.1 
## 8 twitter     4521    9.37
## 9 unknown     2657    5.51&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Since we are looking at proportion of traffic driven to the website and
not the actual numbers, we use the &lt;code&gt;prop&lt;/code&gt; argument and set it to &lt;code&gt;0.1&lt;/code&gt;,
indicating that we want to retain only those categories which have a
proportion of more than 10% and combine the rest.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;traffics %&amp;gt;%
  fct_lump(prop = 0.1) %&amp;gt;% 
  table()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## .
## affiliates       bing   facebook      yahoo     google      Other 
##       7641       5893       8135       4899       9229      12435&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;retain-3-referrer-types-with-lowest-traffic&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Retain 3 Referrer Types with lowest traffic&lt;/h2&gt;
&lt;p&gt;What if we want to retain 3 referrers which drive the lowest traffic
to the website and combine the rest?&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 9 x 2
##   f              n
##   &amp;lt;fct&amp;gt;      &amp;lt;int&amp;gt;
## 1 direct      1350
## 2 unknown     2657
## 3 instagram   3907
## 4 twitter     4521
## 5 yahoo       4899
## 6 bing        5893
## 7 affiliates  7641
## 8 facebook    8135
## 9 google      9229&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We will still use the &lt;code&gt;n&lt;/code&gt; argument but instead of specifying &lt;code&gt;3&lt;/code&gt;, we now specify &lt;code&gt;-3&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;traffics %&amp;gt;% 
  fct_lump(n = -3) %&amp;gt;% 
  table()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## .
##    direct instagram   unknown     Other 
##      1350      3907      2657     40318&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;retain-3-referrer-types-with-less-than-10-traffic&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Retain 3 Referrer Types with less than 10% traffic&lt;/h2&gt;
&lt;p&gt;Let us see how to retain referrers that drive less than 10 % traffic to
the website and combine the rest into a single group.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 9 x 3
##   f              n percent
##   &amp;lt;fct&amp;gt;      &amp;lt;int&amp;gt;   &amp;lt;dbl&amp;gt;
## 1 affiliates  7641   15.8 
## 2 bing        5893   12.2 
## 3 direct      1350    2.8 
## 4 facebook    8135   16.9 
## 5 yahoo       4899   10.2 
## 6 google      9229   19.1 
## 7 instagram   3907    8.1 
## 8 twitter     4521    9.37
## 9 unknown     2657    5.51&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Instead of setting &lt;code&gt;prop&lt;/code&gt; to &lt;code&gt;0.1&lt;/code&gt;, we will set it to &lt;code&gt;-0.1&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;traffics %&amp;gt;% 
  fct_lump(prop = -0.1) %&amp;gt;% 
  table()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## .
##    direct instagram   twitter   unknown     Other 
##      1350      3907      4521      2657     35797&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;replace-levels&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Replace Levels&lt;/h2&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_others_1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Let us assume we want to retain a couple of important categories and group
the rest into a single category. In the below example, we retain &lt;em&gt;google&lt;/em&gt; and
&lt;em&gt;yahoo&lt;/em&gt; while grouping the rest as others using &lt;code&gt;fct_other()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fct_other(traffics, keep = c(&amp;quot;google&amp;quot;, &amp;quot;yahoo&amp;quot;)) %&amp;gt;%
  levels()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;yahoo&amp;quot;  &amp;quot;google&amp;quot; &amp;quot;Other&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;drop-levels&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Drop Levels&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_others_2.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;What if you want to drop a couple of categories instead of grouping them?
Use the &lt;code&gt;drop&lt;/code&gt; argument in &lt;code&gt;fct_other()&lt;/code&gt; and specify the categories to be
dropped. In the below example, we drop the following referrer categories:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;instagram&lt;/li&gt;
&lt;li&gt;twitter&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fct_other(traffics, drop = c(&amp;quot;instagram&amp;quot;, &amp;quot;twitter&amp;quot;)) %&amp;gt;%
  levels()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;affiliates&amp;quot; &amp;quot;bing&amp;quot;       &amp;quot;direct&amp;quot;     &amp;quot;facebook&amp;quot;   &amp;quot;yahoo&amp;quot;     
## [6] &amp;quot;google&amp;quot;     &amp;quot;unknown&amp;quot;    &amp;quot;Other&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;reorder-levels&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Reorder Levels&lt;/h2&gt;
&lt;p&gt;The categories can be reordered using &lt;code&gt;fct_relevel()&lt;/code&gt;. In the above example,
we reorder the categories to ensure &lt;em&gt;google&lt;/em&gt; appears first. Similarly in
the below example, we reorder the levels to ensure &lt;em&gt;twitter&lt;/em&gt; appears first
irrespective of its frequency or order of appearance in the data.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_relevel_1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fct_relevel(traffics, &amp;quot;twitter&amp;quot;) %&amp;gt;%
  levels()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;twitter&amp;quot;    &amp;quot;affiliates&amp;quot; &amp;quot;bing&amp;quot;       &amp;quot;direct&amp;quot;     &amp;quot;facebook&amp;quot;  
## [6] &amp;quot;yahoo&amp;quot;      &amp;quot;google&amp;quot;     &amp;quot;instagram&amp;quot;  &amp;quot;unknown&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If the category needs to appear at a particular position, use the &lt;code&gt;after&lt;/code&gt;
argument and specify the position after which it should appear. For example,
if &lt;em&gt;google&lt;/em&gt; should be the third category, we would specify &lt;code&gt;after = 2&lt;/code&gt; i.e.
&lt;em&gt;google&lt;/em&gt; should come after the 2nd position (i.e. third position).&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_relevel_2.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fct_relevel(traffics, &amp;quot;google&amp;quot;, after = 2) %&amp;gt;%
  levels()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;affiliates&amp;quot; &amp;quot;bing&amp;quot;       &amp;quot;google&amp;quot;     &amp;quot;direct&amp;quot;     &amp;quot;facebook&amp;quot;  
## [6] &amp;quot;yahoo&amp;quot;      &amp;quot;instagram&amp;quot;  &amp;quot;twitter&amp;quot;    &amp;quot;unknown&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If the category should appear last, supply the value &lt;code&gt;Inf&lt;/code&gt; (infinity) to the
&lt;code&gt;after&lt;/code&gt; argument as shown below.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_relevel_3.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fct_relevel(traffics, &amp;quot;facebook&amp;quot;, after = Inf) %&amp;gt;%
  levels()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;affiliates&amp;quot; &amp;quot;bing&amp;quot;       &amp;quot;direct&amp;quot;     &amp;quot;yahoo&amp;quot;      &amp;quot;google&amp;quot;    
## [6] &amp;quot;instagram&amp;quot;  &amp;quot;twitter&amp;quot;    &amp;quot;unknown&amp;quot;    &amp;quot;facebook&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;case-study-3&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Case Study 3&lt;/h2&gt;
&lt;p&gt;In this case study, we deal with categorical data which is ordered and cyclical.
It contains response to an imaginary survey.&lt;/p&gt;
&lt;div id=&#34;data-2&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;response_data &amp;lt;- 
  read_csv(&amp;#39;https://raw.githubusercontent.com/rsquaredacademy/datasets/master/response.csv&amp;#39;,
    col_types = list(col_factor(levels = c(&amp;quot;like&amp;quot;, &amp;quot;like somewhat&amp;quot;, &amp;quot;neutral&amp;quot;, 
      &amp;quot;dislike somewhat&amp;quot;, &amp;quot;dislike&amp;quot;), ordered = TRUE)
    )
  )&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Since we will be using only one column from the above data set, let us extract it using
&lt;code&gt;use_series()&lt;/code&gt; and save it as &lt;code&gt;responses&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;responses &amp;lt;- use_series(response_data, response)
levels(responses)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;like&amp;quot;             &amp;quot;like somewhat&amp;quot;    &amp;quot;neutral&amp;quot;          &amp;quot;dislike somewhat&amp;quot;
## [5] &amp;quot;dislike&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;shift-levels&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Shift Levels&lt;/h2&gt;
&lt;p&gt;To shift the levels, we use &lt;code&gt;fct_shift()&lt;/code&gt;. Use the &lt;code&gt;n&lt;/code&gt; argument to indicate
the direction of the shift. If &lt;code&gt;n&lt;/code&gt; is positive, the levels are shifted to
the left else to the right. In the below example, we shift the levels to
the left by 2 positions.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_shift_1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fct_shift(responses, 2) %&amp;gt;%
  levels()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;neutral&amp;quot;          &amp;quot;dislike somewhat&amp;quot; &amp;quot;dislike&amp;quot;          &amp;quot;like&amp;quot;            
## [5] &amp;quot;like somewhat&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To shift the levels to the right, supply a negative value to the &lt;code&gt;n&lt;/code&gt; argument
in &lt;code&gt;fct_shift()&lt;/code&gt;. In the below example, we shift the levels to the right by
2 positions.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/fct_shift_2.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fct_shift(responses, -2) %&amp;gt;%
  levels()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;dislike somewhat&amp;quot; &amp;quot;dislike&amp;quot;          &amp;quot;like&amp;quot;             &amp;quot;like somewhat&amp;quot;   
## [5] &amp;quot;neutral&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;references&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://forcats.tidyverse.org/index.html&#34; class=&#34;uri&#34;&gt;https://forcats.tidyverse.org/index.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://r4ds.had.co.nz/factors.html&#34; class=&#34;uri&#34;&gt;http://r4ds.had.co.nz/factors.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Working with Date and Time in R </title>
      <link>https://blog.rsquaredacademy.com/working-with-dates-in-r/</link>
      <pubDate>Sat, 03 Nov 2018 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/working-with-dates-in-r/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In this post, we will learn to work with date/time data in R using &lt;a href=&#34;http://lubridate.tidyverse.org/&#34;&gt;lubridate&lt;/a&gt;, an R package that makes it easy to work with dates and time.
Let us begin by installing and loading the pacakge.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Libraries, Code &amp;amp; Data&lt;/h2&gt;
&lt;p&gt;We will use the following packages:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://lubridate.tidyverse.org/index.html&#34;&gt;lubridate&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://dplyr.tidyverse.org/index.html&#34;&gt;dplyr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://magrittr.tidyverse.org/index.html&#34;&gt;magrittr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://readr.tidyverse.org/index.html&#34;&gt;readr&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The data sets can be downloaded from &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt; and the codes from &lt;a href=&#34;https://gist.github.com/aravindhebbali/7758b86c2bc13ff1e5d88d9d1c204f8c&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(lubridate)
library(dplyr)
library(magrittr)
library(readr)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;quick-intro&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Quick Intro&lt;/h2&gt;
&lt;div id=&#34;origin&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Origin&lt;/h4&gt;
&lt;p&gt;Let us look at the origin for the numbering system used for date and time
calculations in R.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;origin&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;1970-01-01 UTC&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;current-datetime&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Current Date/Time&lt;/h4&gt;
&lt;p&gt;Next, let us check out the current date, time and whether it occurs in the am
or pm. &lt;code&gt;now()&lt;/code&gt; returns the date time as well as the time zone whereas &lt;code&gt;today()&lt;/code&gt;
will return only the current date. &lt;code&gt;am()&lt;/code&gt; and &lt;code&gt;pm()&lt;/code&gt; return &lt;code&gt;TRUE&lt;/code&gt; or &lt;code&gt;FALSE&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;now()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2020-06-10 18:52:25 IST&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;today()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2020-06-10&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;am(now())  &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;pm(now())&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;case-study&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Case Study&lt;/h2&gt;
&lt;div id=&#34;data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;transact &amp;lt;- read_csv(&amp;#39;https://raw.githubusercontent.com/rsquaredacademy/datasets/master/transact.csv&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 2,466 x 3
##    Invoice    Due        Payment   
##    &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;    
##  1 2013-01-02 2013-02-01 2013-01-15
##  2 2013-01-26 2013-02-25 2013-03-03
##  3 2013-07-03 2013-08-02 2013-07-08
##  4 2013-02-10 2013-03-12 2013-03-17
##  5 2012-10-25 2012-11-24 2012-11-28
##  6 2012-01-27 2012-02-26 2012-02-22
##  7 2013-08-13 2013-09-12 2013-09-09
##  8 2012-12-16 2013-01-15 2013-01-12
##  9 2012-05-14 2012-06-13 2012-07-01
## 10 2013-07-01 2013-07-31 2013-07-26
## # ... with 2,456 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;data-dictionary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data Dictionary&lt;/h3&gt;
&lt;p&gt;The data set has 3 columns. All the dates are in the format (yyyy-mm-dd).&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Invoice: invoice date&lt;/li&gt;
&lt;li&gt;Due: due date&lt;/li&gt;
&lt;li&gt;Payment: payment date&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We will use the functions in the lubridate package to answer a few
questions we have about the transact data.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;extract date, month and year from Due&lt;/li&gt;
&lt;li&gt;compute the number of days to settle invoice&lt;/li&gt;
&lt;li&gt;compute days over due&lt;/li&gt;
&lt;li&gt;check if due year is a leap year&lt;/li&gt;
&lt;li&gt;check when due day in february is 29, whether it is a leap year&lt;/li&gt;
&lt;li&gt;how many invoices were settled within due date&lt;/li&gt;
&lt;li&gt;how many invoices are due in each quarter&lt;/li&gt;
&lt;li&gt;what is the average duration between invoice date and payment date&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;extract-date-month-year-from-due-date&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Extract Date, Month &amp;amp; Year from Due Date&lt;/h2&gt;
&lt;p&gt;The first thing we will learn is to extract the date, month and year.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/day_week_month.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;this_day &amp;lt;- as_date(&amp;#39;2017-03-23&amp;#39;)
day(this_day)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 23&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;month(this_day)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 3&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;year(this_day)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 2017&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us now extract the date, month and year from the &lt;code&gt;Due&lt;/code&gt; column.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;transact %&amp;gt;%
  mutate(
    due_day   = day(Due),
    due_month = month(Due),
    due_year  = year(Due)
  )&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 2,466 x 6
##    Invoice    Due        Payment    due_day due_month due_year
##    &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;       &amp;lt;int&amp;gt;     &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt;
##  1 2013-01-02 2013-02-01 2013-01-15       1         2     2013
##  2 2013-01-26 2013-02-25 2013-03-03      25         2     2013
##  3 2013-07-03 2013-08-02 2013-07-08       2         8     2013
##  4 2013-02-10 2013-03-12 2013-03-17      12         3     2013
##  5 2012-10-25 2012-11-24 2012-11-28      24        11     2012
##  6 2012-01-27 2012-02-26 2012-02-22      26         2     2012
##  7 2013-08-13 2013-09-12 2013-09-09      12         9     2013
##  8 2012-12-16 2013-01-15 2013-01-12      15         1     2013
##  9 2012-05-14 2012-06-13 2012-07-01      13         6     2012
## 10 2013-07-01 2013-07-31 2013-07-26      31         7     2013
## # ... with 2,456 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;compute-days-to-settle-invoice&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Compute days to settle invoice&lt;/h2&gt;
&lt;p&gt;Time to do some arithmetic with the dates. Let us calculate the duration of a
course by subtracting the course start date from the course end date.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/course_duration.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;course_start    &amp;lt;- as_date(&amp;#39;2017-04-12&amp;#39;)
course_end      &amp;lt;- as_date(&amp;#39;2017-04-21&amp;#39;)
course_duration &amp;lt;- course_end - course_start
course_duration
## Time difference of 9 days&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us estimate the number of days to settle the invoice by subtracting the
date of invoice from the date of payment.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;transact %&amp;gt;%
  mutate(
    days_to_pay = Payment - Invoice
  )&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 2,466 x 4
##    Invoice    Due        Payment    days_to_pay
##    &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;     &amp;lt;drtn&amp;gt;     
##  1 2013-01-02 2013-02-01 2013-01-15 13 days    
##  2 2013-01-26 2013-02-25 2013-03-03 36 days    
##  3 2013-07-03 2013-08-02 2013-07-08  5 days    
##  4 2013-02-10 2013-03-12 2013-03-17 35 days    
##  5 2012-10-25 2012-11-24 2012-11-28 34 days    
##  6 2012-01-27 2012-02-26 2012-02-22 26 days    
##  7 2013-08-13 2013-09-12 2013-09-09 27 days    
##  8 2012-12-16 2013-01-15 2013-01-12 27 days    
##  9 2012-05-14 2012-06-13 2012-07-01 48 days    
## 10 2013-07-01 2013-07-31 2013-07-26 25 days    
## # ... with 2,456 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;compute-days-over-due&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Compute days over due&lt;/h2&gt;
&lt;p&gt;How many of the invoices were settled post the due date? We can find this by:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;subtracting the due date from the payment date&lt;/li&gt;
&lt;li&gt;counting the number of rows where delay &amp;lt; 0&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;transact %&amp;gt;%
  mutate(
    delay = Due - Payment
  ) %&amp;gt;%
  filter(delay &amp;lt; 0) %&amp;gt;%
  tally()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1 x 1
##       n
##   &amp;lt;int&amp;gt;
## 1   877&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;is-due-year-a-leap-year&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Is due year a leap year?&lt;/h2&gt;
&lt;p&gt;Just for fun, let us check if the due year happens to be a leap year.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;transact %&amp;gt;%
  mutate(
    is_leap = leap_year(Due)
  )&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 2,466 x 4
##    Invoice    Due        Payment    is_leap
##    &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;     &amp;lt;lgl&amp;gt;  
##  1 2013-01-02 2013-02-01 2013-01-15 FALSE  
##  2 2013-01-26 2013-02-25 2013-03-03 FALSE  
##  3 2013-07-03 2013-08-02 2013-07-08 FALSE  
##  4 2013-02-10 2013-03-12 2013-03-17 FALSE  
##  5 2012-10-25 2012-11-24 2012-11-28 TRUE   
##  6 2012-01-27 2012-02-26 2012-02-22 TRUE   
##  7 2013-08-13 2013-09-12 2013-09-09 FALSE  
##  8 2012-12-16 2013-01-15 2013-01-12 FALSE  
##  9 2012-05-14 2012-06-13 2012-07-01 TRUE   
## 10 2013-07-01 2013-07-31 2013-07-26 FALSE  
## # ... with 2,456 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;if-due-day-is-february-29-is-it-a-leap-year&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;If due day is February 29, is it a leap year?&lt;/h2&gt;
&lt;p&gt;Let us do some data sanitization. If the due day happens to be February 29,
let us ensure that the due year is a leap year. Below are the steps to check
if the due year is a leap year:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;we will extract the following from the due date:
&lt;ul&gt;
&lt;li&gt;day&lt;/li&gt;
&lt;li&gt;month&lt;/li&gt;
&lt;li&gt;year&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;we will then create a new column &lt;code&gt;is_leap&lt;/code&gt; which will have be set to &lt;code&gt;TRUE&lt;/code&gt; if
the year is a leap year else it will be set to &lt;code&gt;FALSE&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;filter all the payments due on 29th Feb&lt;/li&gt;
&lt;li&gt;select the following columns:
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Due&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;is_leap&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;transact %&amp;gt;%
  mutate(
    due_day   = day(Due),
    due_month = month(Due),
    due_year  = year(Due),
    is_leap   = leap_year(due_year)
  ) %&amp;gt;%
  filter(due_month == 2 &amp;amp; due_day == 29) %&amp;gt;%
  select(Due, is_leap) &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 4 x 2
##   Due        is_leap
##   &amp;lt;date&amp;gt;     &amp;lt;lgl&amp;gt;  
## 1 2012-02-29 TRUE   
## 2 2012-02-29 TRUE   
## 3 2012-02-29 TRUE   
## 4 2012-02-29 TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;shift-date&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Shift Date&lt;/h2&gt;
&lt;p&gt;Time to shift some dates. We can shift a date by days, weeks or months. Let us
shift the course start date by:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;2 days&lt;/li&gt;
&lt;li&gt;3 weeks&lt;/li&gt;
&lt;li&gt;1 year&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/shift_dates.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;course_start + days(2)
## [1] &amp;quot;2017-04-14&amp;quot;
course_start + weeks(3)
## [1] &amp;quot;2017-05-03&amp;quot;
course_start + years(1)
## [1] &amp;quot;2018-04-12&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;interval&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Interval&lt;/h2&gt;
&lt;p&gt;Let us calculate the duration of the course using &lt;code&gt;interval&lt;/code&gt;. If you observe
carefully, the result is not the duration in days but an object of class
&lt;code&gt;interval&lt;/code&gt;. Now let us learn how we can use intervals.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/course_interval.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;interval(course_start, course_end)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 2017-04-12 UTC--2017-04-21 UTC&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;intervals-overlap&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Intervals Overlap&lt;/h2&gt;
&lt;p&gt;Let us say you are planning a vacation and want to check if the vacation
dates overlap with the course dates. You can do this by:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;creating vacation and course intervals&lt;/li&gt;
&lt;li&gt;use &lt;code&gt;int_overlaps()&lt;/code&gt; to check if two intervals overlap. It returns &lt;code&gt;TRUE&lt;/code&gt;
if the intervals overlap else &lt;code&gt;FALSE&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let us use the vacation start and end dates to create &lt;code&gt;vacation_interval&lt;/code&gt;
and then check if it overlaps with &lt;code&gt;course_interval&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/interval_overlap.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vacation_start    &amp;lt;- as_date(&amp;#39;2017-04-19&amp;#39;)
vacation_end      &amp;lt;- as_date(&amp;#39;2017-04-25&amp;#39;)
course_interval   &amp;lt;- interval(course_start, course_end)
vacation_interval &amp;lt;- interval(vacation_start, vacation_end)
int_overlaps(course_interval, vacation_interval)
## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;how-many-invoices-were-settled-within-due-date&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;How many invoices were settled within due date?&lt;/h2&gt;
&lt;p&gt;Let us use intervals to count the number of invoices that were settled within
the due date. To do this, we will:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;create an interval for the invoice and due date&lt;/li&gt;
&lt;li&gt;create a new column &lt;code&gt;due_next&lt;/code&gt; by incrementing the due date by 1 day&lt;/li&gt;
&lt;li&gt;another interval for &lt;code&gt;due_next&lt;/code&gt; and the payment date&lt;/li&gt;
&lt;li&gt;if the intervals overlap, the payment was made within the due date&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;transact %&amp;gt;%
  mutate(
    inv_due_interval = interval(Invoice, Due),
    due_next         = Due + days(1),
    due_pay_interval = interval(due_next, Payment),
    overlaps         = int_overlaps(inv_due_interval, due_pay_interval)
  ) %&amp;gt;%
  select(Invoice, Due, Payment, overlaps)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 2,466 x 4
##    Invoice    Due        Payment    overlaps
##    &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;     &amp;lt;lgl&amp;gt;   
##  1 2013-01-02 2013-02-01 2013-01-15 TRUE    
##  2 2013-01-26 2013-02-25 2013-03-03 FALSE   
##  3 2013-07-03 2013-08-02 2013-07-08 TRUE    
##  4 2013-02-10 2013-03-12 2013-03-17 FALSE   
##  5 2012-10-25 2012-11-24 2012-11-28 FALSE   
##  6 2012-01-27 2012-02-26 2012-02-22 TRUE    
##  7 2013-08-13 2013-09-12 2013-09-09 TRUE    
##  8 2012-12-16 2013-01-15 2013-01-12 TRUE    
##  9 2012-05-14 2012-06-13 2012-07-01 FALSE   
## 10 2013-07-01 2013-07-31 2013-07-26 TRUE    
## # ... with 2,456 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Below we show another method to count the number of invoices paid within the
due date. Instead of using &lt;code&gt;days&lt;/code&gt; to change the due date, we use &lt;code&gt;int_shift&lt;/code&gt;
to shift it by 1 day.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;transact %&amp;gt;%
  mutate(
    inv_due_interval = interval(Invoice, Due),
    due_pay_interval = interval(Due, Payment),  
    due_pay_next     = int_shift(due_pay_interval, by = days(1)),
    overlaps         = int_overlaps(inv_due_interval, due_pay_next)
  ) %&amp;gt;%
  select(Invoice, Due, Payment, overlaps)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 2,466 x 4
##    Invoice    Due        Payment    overlaps
##    &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;     &amp;lt;lgl&amp;gt;   
##  1 2013-01-02 2013-02-01 2013-01-15 TRUE    
##  2 2013-01-26 2013-02-25 2013-03-03 FALSE   
##  3 2013-07-03 2013-08-02 2013-07-08 TRUE    
##  4 2013-02-10 2013-03-12 2013-03-17 FALSE   
##  5 2012-10-25 2012-11-24 2012-11-28 FALSE   
##  6 2012-01-27 2012-02-26 2012-02-22 TRUE    
##  7 2013-08-13 2013-09-12 2013-09-09 TRUE    
##  8 2012-12-16 2013-01-15 2013-01-12 TRUE    
##  9 2012-05-14 2012-06-13 2012-07-01 FALSE   
## 10 2013-07-01 2013-07-31 2013-07-26 TRUE    
## # ... with 2,456 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You might be thinking why we incremented the due date by a day before creating
the interval between the due day and the payment day. If we do not increment,
both the intervals will share a common date i.e. the due date and they will
always overlap as shown below:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;transact %&amp;gt;%
  mutate(
    inv_due_interval = interval(Invoice, Due),
    due_pay_interval = interval(Due, Payment),
    overlaps         = int_overlaps(inv_due_interval, due_pay_interval)
  ) %&amp;gt;%
  select(Invoice, Due, Payment, overlaps)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 2,466 x 4
##    Invoice    Due        Payment    overlaps
##    &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;     &amp;lt;lgl&amp;gt;   
##  1 2013-01-02 2013-02-01 2013-01-15 TRUE    
##  2 2013-01-26 2013-02-25 2013-03-03 TRUE    
##  3 2013-07-03 2013-08-02 2013-07-08 TRUE    
##  4 2013-02-10 2013-03-12 2013-03-17 TRUE    
##  5 2012-10-25 2012-11-24 2012-11-28 TRUE    
##  6 2012-01-27 2012-02-26 2012-02-22 TRUE    
##  7 2013-08-13 2013-09-12 2013-09-09 TRUE    
##  8 2012-12-16 2013-01-15 2013-01-12 TRUE    
##  9 2012-05-14 2012-06-13 2012-07-01 TRUE    
## 10 2013-07-01 2013-07-31 2013-07-26 TRUE    
## # ... with 2,456 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;shift-interval&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Shift Interval&lt;/h2&gt;
&lt;p&gt;Intervals can be shifted too. In the below example, we shift the course
interval by:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;1 day&lt;/li&gt;
&lt;li&gt;3 weeks&lt;/li&gt;
&lt;li&gt;1 year&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/shift_interval.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;course_interval &amp;lt;- interval(course_start, course_end)
int_shift(course_interval, by = days(1))
## [1] 2017-04-13 UTC--2017-04-22 UTC
int_shift(course_interval, by = weeks(3))
## [1] 2017-05-03 UTC--2017-05-12 UTC
int_shift(course_interval, by = years(1))
## [1] 2018-04-12 UTC--2018-04-21 UTC&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;within&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Within&lt;/h2&gt;
&lt;p&gt;Let us assume that we have to attend a conference in April 2017. Does it occur
during the course duration? We can answer this using &lt;code&gt;%within%&lt;/code&gt; which will
return &lt;code&gt;TRUE&lt;/code&gt; if a date falls within an interval.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/within.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;conference &amp;lt;- as_date(&amp;#39;2017-04-15&amp;#39;)
conference %within% course_interval
## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;how-many-invoices-were-settled-within-due-date-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;How many invoices were settled within due date?&lt;/h4&gt;
&lt;p&gt;Let us use &lt;code&gt;%within%&lt;/code&gt; to count the number of invoices that were settled within
the due date. We will do this by:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;creating an interval for the invoice and due date&lt;/li&gt;
&lt;li&gt;check if the payment date falls within the above interval&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;transact %&amp;gt;%
  mutate(
    inv_due_interval = interval(Invoice, Due),
    overlaps         = Payment %within% inv_due_interval
  ) %&amp;gt;%
  select(Due, Payment, overlaps)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 2,466 x 3
##    Due        Payment    overlaps
##    &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;     &amp;lt;lgl&amp;gt;   
##  1 2013-02-01 2013-01-15 TRUE    
##  2 2013-02-25 2013-03-03 FALSE   
##  3 2013-08-02 2013-07-08 TRUE    
##  4 2013-03-12 2013-03-17 FALSE   
##  5 2012-11-24 2012-11-28 FALSE   
##  6 2012-02-26 2012-02-22 TRUE    
##  7 2013-09-12 2013-09-09 TRUE    
##  8 2013-01-15 2013-01-12 TRUE    
##  9 2012-06-13 2012-07-01 FALSE   
## 10 2013-07-31 2013-07-26 TRUE    
## # ... with 2,456 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;quarter&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Quarter&lt;/h2&gt;
&lt;p&gt;Let us check the quarter and the semester in which the course starts.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/quarter_semester.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;course_start
## [1] &amp;quot;2017-04-12&amp;quot;
quarter(course_start)
## [1] 2
quarter(course_start, with_year = TRUE)
## [1] 2017.2
semester(course_start)  
## [1] 1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us count the invoices due for each quarter.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;transact %&amp;gt;%
  mutate(
    quarter_due = quarter(Due)
  ) %&amp;gt;%
  count(quarter_due)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 4 x 2
##   quarter_due     n
## *       &amp;lt;int&amp;gt; &amp;lt;int&amp;gt;
## 1           1   521
## 2           2   661
## 3           3   618
## 4           4   666&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;transact %&amp;gt;%
  mutate(
    Quarter = quarter(Due, with_year = TRUE)
  )&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 2,466 x 4
##    Invoice    Due        Payment    Quarter
##    &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;     &amp;lt;date&amp;gt;       &amp;lt;dbl&amp;gt;
##  1 2013-01-02 2013-02-01 2013-01-15   2013.
##  2 2013-01-26 2013-02-25 2013-03-03   2013.
##  3 2013-07-03 2013-08-02 2013-07-08   2013.
##  4 2013-02-10 2013-03-12 2013-03-17   2013.
##  5 2012-10-25 2012-11-24 2012-11-28   2012.
##  6 2012-01-27 2012-02-26 2012-02-22   2012.
##  7 2013-08-13 2013-09-12 2013-09-09   2013.
##  8 2012-12-16 2013-01-15 2013-01-12   2013.
##  9 2012-05-14 2012-06-13 2012-07-01   2012.
## 10 2013-07-01 2013-07-31 2013-07-26   2013.
## # ... with 2,456 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;case-study-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Case Study&lt;/h4&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/convert.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Let us also get the course interval in different units.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;course_interval / dseconds()
## [1] 777600
course_interval / dminutes()
## [1] 12960
course_interval / dhours()
## [1] 216
course_interval / dweeks()
## [1] 1.285714
course_interval / dyears()
## [1] 0.02464066&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can use &lt;code&gt;time_length()&lt;/code&gt; to get the course interval in different units.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/time_length.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;time_length(course_interval, unit = &amp;quot;seconds&amp;quot;)
## [1] 777600
time_length(course_interval, unit = &amp;quot;minutes&amp;quot;)
## [1] 12960
time_length(course_interval, unit = &amp;quot;hours&amp;quot;)
## [1] 216&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;as.period()&lt;/code&gt; is another way to get the course interval in different units.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/as_period.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;as.period(course_interval, unit = &amp;quot;seconds&amp;quot;)
## [1] &amp;quot;777600S&amp;quot;
as.period(course_interval, unit = &amp;quot;minutes&amp;quot;)
## [1] &amp;quot;12960M 0S&amp;quot;
as.period(course_interval, unit = &amp;quot;hours&amp;quot;)
## [1] &amp;quot;216H 0M 0S&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;references&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://lubridate.tidyverse.org/&#34; class=&#34;uri&#34;&gt;https://lubridate.tidyverse.org/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://r4ds.had.co.nz/dates-and-times.html&#34; class=&#34;uri&#34;&gt;http://r4ds.had.co.nz/dates-and-times.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Hacking strings with stringr</title>
      <link>https://blog.rsquaredacademy.com/hacking-strings-with-stringr/</link>
      <pubDate>Mon, 22 Oct 2018 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/hacking-strings-with-stringr/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In this post, we will learn to work with string data in R using &lt;a href=&#34;http://stringr.tidyverse.org&#34;&gt;stringr&lt;/a&gt;. As we did in the other posts, we will use a case study to explore the various features of the stringr package. Let us begin by installing and loading stringr and a set of other pacakges we will be using.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Libraries, Code &amp;amp; Data&lt;/h2&gt;
&lt;p&gt;We will use the following libraries:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://lubridate.tidyverse.org/index.html&#34;&gt;stringr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://dplyr.tidyverse.org/index.html&#34;&gt;dplyr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://magrittr.tidyverse.org/index.html&#34;&gt;magrittr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://tibble.tidyverse.org/index.html&#34;&gt;tibble&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://purrr.tidyverse.org/index.html&#34;&gt;purrr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;and &lt;a href=&#34;http://readr.tidyverse.org/index.html&#34;&gt;readr&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The data sets can be downloaded from &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt; and the codes from &lt;a href=&#34;https://gist.github.com/aravindhebbali/5d1799744e55dc76cdf1af6b1cc03c82&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(stringr)
library(tibble)
library(magrittr)
library(purrr)
library(dplyr)
library(readr)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;case-study&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Case Study&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;extract domain name from random email ids&lt;/li&gt;
&lt;li&gt;extract image type from url&lt;/li&gt;
&lt;li&gt;extract image dimension from url&lt;/li&gt;
&lt;li&gt;extract extension from domain name&lt;/li&gt;
&lt;li&gt;extract http protocol from url&lt;/li&gt;
&lt;li&gt;extract file type from url&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mockstring &amp;lt;- read_csv(&amp;#39;https://raw.githubusercontent.com/rsquaredacademy/datasets/master/mock_strings.csv&amp;#39;)
mockstring&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1,000 x 12
##       id image_url domain imageurl email filename phone address url   full_name
##    &amp;lt;dbl&amp;gt; &amp;lt;chr&amp;gt;     &amp;lt;chr&amp;gt;  &amp;lt;chr&amp;gt;    &amp;lt;chr&amp;gt; &amp;lt;chr&amp;gt;    &amp;lt;chr&amp;gt; &amp;lt;chr&amp;gt;   &amp;lt;chr&amp;gt; &amp;lt;chr&amp;gt;    
##  1     1 https://~ addto~ http://~ mnew~ PedeMal~ 66-(~ 8 Anha~ http~ Mufi Ruit
##  2     2 https://~ gmpg.~ http://~ mdan~ Loborti~ 351-~ 697 Ea~ http~ Leese Fu~
##  3     3 https://~ samsu~ http://~ hgir~ CongueD~ 33-(~ 89 Dot~ http~ Blakelee~
##  4     4 https://~ spoti~ http://~ pmcm~ Eleifen~ 86-(~ 98135 ~ http~ Terencio~
##  5     5 https://~ wunde~ http://~ dris~ PurusPh~ 223-~ 7814 P~ http~ Debee Mc~
##  6     6 https://~ alexa~ http://~ cphl~ Element~ 420-~ 4897 L~ http~ Fran Pai~
##  7     7 https://~ googl~ http://~ kdod~ Mattis.~ 1-(7~ 53541 ~ http~ Frasco B~
##  8     8 https://~ ed.gov http://~ vhou~ PurusEu~ 62-(~ 4819 H~ http~ Car Pont~
##  9     9 https://~ jigsy~ http://~ rdik~ JustoEt~ 1-(6~ 68096 ~ http~ Tades Ch~
## 10    10 https://~ jugem~ http://~ tdud~ Ante.ti~ 30-(~ 9595 S~ http~ Wilton K~
## # ... with 990 more rows, and 2 more variables: currency &amp;lt;chr&amp;gt;, passwords &amp;lt;chr&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;data-dictionary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data Dictionary&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;domain: dummy website domain&lt;/li&gt;
&lt;li&gt;imageurl: url of an image&lt;/li&gt;
&lt;li&gt;email: dummy email id&lt;/li&gt;
&lt;li&gt;filename: dummy file name with different extensions&lt;/li&gt;
&lt;li&gt;phone: dummy phone number&lt;/li&gt;
&lt;li&gt;address: dummy address with door and street names&lt;/li&gt;
&lt;li&gt;url: randomyly generated urls&lt;/li&gt;
&lt;li&gt;full_name: dummy first and last names&lt;/li&gt;
&lt;li&gt;currency: different currencies&lt;/li&gt;
&lt;li&gt;passwords: dummy passwords&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;overview&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Overview&lt;/h2&gt;
&lt;p&gt;Before we start with the case study, let us take a quick tour of &lt;strong&gt;stringr&lt;/strong&gt; and introduce
ourselves to some of the functions we will be using later in the case study. One of the
columns in the case study data is &lt;code&gt;email&lt;/code&gt;. It contains random email ids. We want to ensure
that the email ids adher to a particular format .i.e&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;they contain &lt;code&gt;@&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;they contain only one &lt;code&gt;@&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let us first detect if the email ids contain &lt;code&gt;@&lt;/code&gt;. Since the data set has 1000 rows, we will
use a smaller sample in the examples.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mockdata &amp;lt;- slice(mockstring, 1:10)
mockdata&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 10 x 12
##       id image_url domain imageurl email filename phone address url   full_name
##    &amp;lt;dbl&amp;gt; &amp;lt;chr&amp;gt;     &amp;lt;chr&amp;gt;  &amp;lt;chr&amp;gt;    &amp;lt;chr&amp;gt; &amp;lt;chr&amp;gt;    &amp;lt;chr&amp;gt; &amp;lt;chr&amp;gt;   &amp;lt;chr&amp;gt; &amp;lt;chr&amp;gt;    
##  1     1 https://~ addto~ http://~ mnew~ PedeMal~ 66-(~ 8 Anha~ http~ Mufi Ruit
##  2     2 https://~ gmpg.~ http://~ mdan~ Loborti~ 351-~ 697 Ea~ http~ Leese Fu~
##  3     3 https://~ samsu~ http://~ hgir~ CongueD~ 33-(~ 89 Dot~ http~ Blakelee~
##  4     4 https://~ spoti~ http://~ pmcm~ Eleifen~ 86-(~ 98135 ~ http~ Terencio~
##  5     5 https://~ wunde~ http://~ dris~ PurusPh~ 223-~ 7814 P~ http~ Debee Mc~
##  6     6 https://~ alexa~ http://~ cphl~ Element~ 420-~ 4897 L~ http~ Fran Pai~
##  7     7 https://~ googl~ http://~ kdod~ Mattis.~ 1-(7~ 53541 ~ http~ Frasco B~
##  8     8 https://~ ed.gov http://~ vhou~ PurusEu~ 62-(~ 4819 H~ http~ Car Pont~
##  9     9 https://~ jigsy~ http://~ rdik~ JustoEt~ 1-(6~ 68096 ~ http~ Tades Ch~
## 10    10 https://~ jugem~ http://~ tdud~ Ante.ti~ 30-(~ 9595 S~ http~ Wilton K~
## # ... with 2 more variables: currency &amp;lt;chr&amp;gt;, passwords &amp;lt;chr&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/str_count.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Use &lt;code&gt;str_detect()&lt;/code&gt; to detect &lt;code&gt;@&lt;/code&gt; and &lt;code&gt;str_count()&lt;/code&gt; to count the number of times
&lt;code&gt;@&lt;/code&gt; appears in the email ids.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/str_detect.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# detect @
str_detect(mockdata$email, pattern = &amp;quot;@&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# count @
str_count(mockdata$email, pattern = &amp;quot;@&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] 1 1 1 1 1 1 1 1 1 1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can use &lt;code&gt;str_c()&lt;/code&gt; to concatenate strings. Let us add the string &lt;code&gt;email id:&lt;/code&gt; before each
email id in the data set.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/str_c.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str_c(&amp;quot;email id:&amp;quot;, mockdata$email)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;email id:mnewburn0@fastcompany.com&amp;quot;   
##  [2] &amp;quot;email id:mdankersley1@digg.com&amp;quot;       
##  [3] &amp;quot;email id:hgirhard2@altervista.org&amp;quot;    
##  [4] &amp;quot;email id:pmcmenamy3@sciencedirect.com&amp;quot;
##  [5] &amp;quot;email id:drisbrough4@bandcamp.com&amp;quot;    
##  [6] &amp;quot;email id:cphlippi5@surveymonkey.com&amp;quot;  
##  [7] &amp;quot;email id:kdodswell6@un.org&amp;quot;           
##  [8] &amp;quot;email id:vhourihane7@ovh.net&amp;quot;         
##  [9] &amp;quot;email id:rdike8@timesonline.co.uk&amp;quot;    
## [10] &amp;quot;email id:tdudbridge9@clickbank.net&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If we want to split a string into two parts using a particular pattern, we use &lt;code&gt;str_split()&lt;/code&gt;.
Let us split the domain name and extension from the domain column in the data. The domain name
and extension are separated by &lt;code&gt;.&lt;/code&gt; and we will use it to split the domain column. Since &lt;code&gt;.&lt;/code&gt; is
a special character, we will use two slashes to escape the special character.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/str_split.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str_split(mockdata$domain, pattern = &amp;quot;\\.&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [[1]]
## [1] &amp;quot;addtoany&amp;quot; &amp;quot;com&amp;quot;     
## 
## [[2]]
## [1] &amp;quot;gmpg&amp;quot; &amp;quot;org&amp;quot; 
## 
## [[3]]
## [1] &amp;quot;samsung&amp;quot; &amp;quot;com&amp;quot;    
## 
## [[4]]
## [1] &amp;quot;spotify&amp;quot; &amp;quot;com&amp;quot;    
## 
## [[5]]
## [1] &amp;quot;wunderground&amp;quot; &amp;quot;com&amp;quot;         
## 
## [[6]]
## [1] &amp;quot;alexa&amp;quot; &amp;quot;com&amp;quot;  
## 
## [[7]]
## [1] &amp;quot;google&amp;quot; &amp;quot;it&amp;quot;    
## 
## [[8]]
## [1] &amp;quot;ed&amp;quot;  &amp;quot;gov&amp;quot;
## 
## [[9]]
## [1] &amp;quot;jigsy&amp;quot; &amp;quot;com&amp;quot;  
## 
## [[10]]
## [1] &amp;quot;jugem&amp;quot; &amp;quot;jp&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can truncate a string using &lt;code&gt;str_trunc()&lt;/code&gt;. The default truncation happens at the beggining
of the string but we can truncate the central part or the end of the string as well.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str_trunc(mockdata$email, width = 10)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;mnewbur...&amp;quot; &amp;quot;mdanker...&amp;quot; &amp;quot;hgirhar...&amp;quot; &amp;quot;pmcmena...&amp;quot; &amp;quot;drisbro...&amp;quot;
##  [6] &amp;quot;cphlipp...&amp;quot; &amp;quot;kdodswe...&amp;quot; &amp;quot;vhourih...&amp;quot; &amp;quot;rdike8@...&amp;quot; &amp;quot;tdudbri...&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str_trunc(mockdata$email, width = 10, side = &amp;quot;left&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;...any.com&amp;quot; &amp;quot;...igg.com&amp;quot; &amp;quot;...sta.org&amp;quot; &amp;quot;...ect.com&amp;quot; &amp;quot;...amp.com&amp;quot;
##  [6] &amp;quot;...key.com&amp;quot; &amp;quot;...@un.org&amp;quot; &amp;quot;...ovh.net&amp;quot; &amp;quot;...e.co.uk&amp;quot; &amp;quot;...ank.net&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str_trunc(mockdata$email, width = 10, side = &amp;quot;center&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;mnew...com&amp;quot; &amp;quot;mdan...com&amp;quot; &amp;quot;hgir...org&amp;quot; &amp;quot;pmcm...com&amp;quot; &amp;quot;dris...com&amp;quot;
##  [6] &amp;quot;cphl...com&amp;quot; &amp;quot;kdod...org&amp;quot; &amp;quot;vhou...net&amp;quot; &amp;quot;rdik....uk&amp;quot; &amp;quot;tdud...net&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/str_sort_descending.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Strings can be sorted using &lt;code&gt;str_sort()&lt;/code&gt;. Let us quickly sort the emails in both
ascending and descending orders.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/str_sort.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str_sort(mockdata$email)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;cphlippi5@surveymonkey.com&amp;quot;   &amp;quot;drisbrough4@bandcamp.com&amp;quot;    
##  [3] &amp;quot;hgirhard2@altervista.org&amp;quot;     &amp;quot;kdodswell6@un.org&amp;quot;           
##  [5] &amp;quot;mdankersley1@digg.com&amp;quot;        &amp;quot;mnewburn0@fastcompany.com&amp;quot;   
##  [7] &amp;quot;pmcmenamy3@sciencedirect.com&amp;quot; &amp;quot;rdike8@timesonline.co.uk&amp;quot;    
##  [9] &amp;quot;tdudbridge9@clickbank.net&amp;quot;    &amp;quot;vhourihane7@ovh.net&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str_sort(mockdata$email, decreasing = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;vhourihane7@ovh.net&amp;quot;          &amp;quot;tdudbridge9@clickbank.net&amp;quot;   
##  [3] &amp;quot;rdike8@timesonline.co.uk&amp;quot;     &amp;quot;pmcmenamy3@sciencedirect.com&amp;quot;
##  [5] &amp;quot;mnewburn0@fastcompany.com&amp;quot;    &amp;quot;mdankersley1@digg.com&amp;quot;       
##  [7] &amp;quot;kdodswell6@un.org&amp;quot;            &amp;quot;hgirhard2@altervista.org&amp;quot;    
##  [9] &amp;quot;drisbrough4@bandcamp.com&amp;quot;     &amp;quot;cphlippi5@surveymonkey.com&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The case of a string can be changed to upper, lower or title case as shown below.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/str_to_upper.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str_to_upper(mockdata$full_name)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;MUFI RUIT&amp;quot;          &amp;quot;LEESE FURMAGIER&amp;quot;    &amp;quot;BLAKELEE WILSHIRE&amp;quot; 
##  [4] &amp;quot;TERENCIO MCILLRICK&amp;quot; &amp;quot;DEBEE MCERLAINE&amp;quot;    &amp;quot;FRAN PAINTEN&amp;quot;      
##  [7] &amp;quot;FRASCO BOWICH&amp;quot;      &amp;quot;CAR PONTEN&amp;quot;         &amp;quot;TADES CHECCUCCI&amp;quot;   
## [10] &amp;quot;WILTON KEMMEY&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str_to_lower(mockdata$full_name)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;mufi ruit&amp;quot;          &amp;quot;leese furmagier&amp;quot;    &amp;quot;blakelee wilshire&amp;quot; 
##  [4] &amp;quot;terencio mcillrick&amp;quot; &amp;quot;debee mcerlaine&amp;quot;    &amp;quot;fran painten&amp;quot;      
##  [7] &amp;quot;frasco bowich&amp;quot;      &amp;quot;car ponten&amp;quot;         &amp;quot;tades checcucci&amp;quot;   
## [10] &amp;quot;wilton kemmey&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Parts of a string can be replaced using &lt;code&gt;str_replace()&lt;/code&gt;. In the &lt;code&gt;address&lt;/code&gt; column of the data set,
let us replace:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Street with ST&lt;/li&gt;
&lt;li&gt;Road with RD&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/str_replace.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str_replace(mockdata$address, &amp;quot;Street&amp;quot;, &amp;quot;ST&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;8 Anhalt Crossing&amp;quot;          &amp;quot;697 East Avenue&amp;quot;           
##  [3] &amp;quot;89 Dottie Circle&amp;quot;           &amp;quot;98135 Blue Bill Park Drive&amp;quot;
##  [5] &amp;quot;7814 Pennsylvania ST&amp;quot;       &amp;quot;4897 Little Fleur Drive&amp;quot;   
##  [7] &amp;quot;53541 Morrow Center&amp;quot;        &amp;quot;4819 Hermina Parkway&amp;quot;      
##  [9] &amp;quot;68096 Monument Park&amp;quot;        &amp;quot;9595 Spaight Avenue&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str_replace(mockdata$address, &amp;quot;Road&amp;quot;, &amp;quot;RD&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;8 Anhalt Crossing&amp;quot;          &amp;quot;697 East Avenue&amp;quot;           
##  [3] &amp;quot;89 Dottie Circle&amp;quot;           &amp;quot;98135 Blue Bill Park Drive&amp;quot;
##  [5] &amp;quot;7814 Pennsylvania Street&amp;quot;   &amp;quot;4897 Little Fleur Drive&amp;quot;   
##  [7] &amp;quot;53541 Morrow Center&amp;quot;        &amp;quot;4819 Hermina Parkway&amp;quot;      
##  [9] &amp;quot;68096 Monument Park&amp;quot;        &amp;quot;9595 Spaight Avenue&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can extract parts of the string that match a particular pattern using &lt;code&gt;str_extract()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/str_extract.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str_extract(mockdata$email, pattern = &amp;quot;org&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] NA    NA    &amp;quot;org&amp;quot; NA    NA    NA    &amp;quot;org&amp;quot; NA    NA    NA&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Before we extract, we need to know whether the string contains text that match our pattern.
Use &lt;code&gt;str_match()&lt;/code&gt; to see if the pattern is present in the string.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/str_match.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str_match(mockdata$email, pattern = &amp;quot;org&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##       [,1] 
##  [1,] NA   
##  [2,] NA   
##  [3,] &amp;quot;org&amp;quot;
##  [4,] NA   
##  [5,] NA   
##  [6,] NA   
##  [7,] &amp;quot;org&amp;quot;
##  [8,] NA   
##  [9,] NA   
## [10,] NA&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If we are dealing with a character vector and know that the pattern we are looking at
is present in the vector, we might want to know the index of the strings in which it is
present. Use &lt;code&gt;str_which()&lt;/code&gt; to identify the index of the strings that match our pattern.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/str_which.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str_which(mockdata$email, pattern = &amp;quot;org&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 3 7&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Another objective might be to locate the position of the pattern we are looking for in the
string. For example, if we want to know the position of &lt;code&gt;@&lt;/code&gt; in the email ids, we can use
&lt;code&gt;str_locate()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/str_locate.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str_locate(mockdata$email, pattern = &amp;quot;@&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##       start end
##  [1,]    10  10
##  [2,]    13  13
##  [3,]    10  10
##  [4,]    11  11
##  [5,]    12  12
##  [6,]    10  10
##  [7,]    11  11
##  [8,]    12  12
##  [9,]     7   7
## [10,]    12  12&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The length of the string can be computed using &lt;code&gt;str_length()&lt;/code&gt;. Let us ensure that the length
of the strings in the &lt;code&gt;password&lt;/code&gt; column is 16.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/str_length.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str_length(mockdata$passwords)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] 16 16 16 16 16 16 16 16 16 16&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can extract parts of a string by specifying the starting and ending position using
&lt;code&gt;str_sub()&lt;/code&gt;. Let us extract the currency type from the &lt;code&gt;currency&lt;/code&gt; column.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/str_sub.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str_sub(mockdata$currency, start = 1, end = 1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;¥&amp;quot; &amp;quot;$&amp;quot; &amp;quot;\200&amp;quot; &amp;quot;\200&amp;quot; &amp;quot;\200&amp;quot; &amp;quot;¥&amp;quot; &amp;quot;$&amp;quot; &amp;quot;¥&amp;quot; &amp;quot;\200&amp;quot; &amp;quot;\200&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;One final function that we will look at before the case study is &lt;code&gt;word()&lt;/code&gt;. It extracts
word(s) from sentences. We do not have any sentences in the data set, but let us use it
to extract the first and last name from the &lt;code&gt;full_name&lt;/code&gt; column.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/word.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;word(mockdata$full_name, 1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;Mufi&amp;quot;     &amp;quot;Leese&amp;quot;    &amp;quot;Blakelee&amp;quot; &amp;quot;Terencio&amp;quot; &amp;quot;Debee&amp;quot;    &amp;quot;Fran&amp;quot;    
##  [7] &amp;quot;Frasco&amp;quot;   &amp;quot;Car&amp;quot;      &amp;quot;Tades&amp;quot;    &amp;quot;Wilton&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;word(mockdata$full_name, 2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;Ruit&amp;quot;      &amp;quot;Furmagier&amp;quot; &amp;quot;Wilshire&amp;quot;  &amp;quot;McIllrick&amp;quot; &amp;quot;McErlaine&amp;quot; &amp;quot;Painten&amp;quot;  
##  [7] &amp;quot;Bowich&amp;quot;    &amp;quot;Ponten&amp;quot;    &amp;quot;Checcucci&amp;quot; &amp;quot;Kemmey&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Alright, now let us apply what we have learned so far to our case study.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;extract-domain-name-from-email-ids&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Extract domain name from email ids&lt;/h2&gt;
&lt;div id=&#34;steps&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Steps&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;split email using pattern &lt;code&gt;@&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;extract the second element from the resulting list&lt;/li&gt;
&lt;li&gt;split the above using pattern &lt;code&gt;\\.&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;extract the first element from the resulting list&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let us take a look at the emails before we extract the domain names.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;emails &amp;lt;- 
  mockstring %&amp;gt;%
  pull(email) %&amp;gt;%
  head()

emails&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;mnewburn0@fastcompany.com&amp;quot;    &amp;quot;mdankersley1@digg.com&amp;quot;       
## [3] &amp;quot;hgirhard2@altervista.org&amp;quot;     &amp;quot;pmcmenamy3@sciencedirect.com&amp;quot;
## [5] &amp;quot;drisbrough4@bandcamp.com&amp;quot;     &amp;quot;cphlippi5@surveymonkey.com&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;step-1-split-email-using-pattern-.&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step 1: Split email using pattern &lt;code&gt;@&lt;/code&gt;.&lt;/h4&gt;
&lt;p&gt;We will split the email using &lt;code&gt;str_split&lt;/code&gt;. It will split a string
using the pattern supplied. In our case the pattern is &lt;code&gt;@&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt; str_split(emails, pattern = &amp;#39;@&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [[1]]
## [1] &amp;quot;mnewburn0&amp;quot;       &amp;quot;fastcompany.com&amp;quot;
## 
## [[2]]
## [1] &amp;quot;mdankersley1&amp;quot; &amp;quot;digg.com&amp;quot;    
## 
## [[3]]
## [1] &amp;quot;hgirhard2&amp;quot;      &amp;quot;altervista.org&amp;quot;
## 
## [[4]]
## [1] &amp;quot;pmcmenamy3&amp;quot;        &amp;quot;sciencedirect.com&amp;quot;
## 
## [[5]]
## [1] &amp;quot;drisbrough4&amp;quot;  &amp;quot;bandcamp.com&amp;quot;
## 
## [[6]]
## [1] &amp;quot;cphlippi5&amp;quot;        &amp;quot;surveymonkey.com&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;step-2-extract-the-second-element-from-the-resulting-list.&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step 2: Extract the second element from the resulting list.&lt;/h4&gt;
&lt;p&gt;Step 1 returned a list. Each element of the list has two values. The first
one is the username and the second is the domain name. Since we are
extracting the domain name, we want the second value from each element of
the list.&lt;/p&gt;
&lt;p&gt;We will use &lt;code&gt;map_chr()&lt;/code&gt; from purrr to extract the domain names. It will
return the second value from each element in the list. Since the domain
name is a string, &lt;code&gt;map_chr()&lt;/code&gt; will return a character vector.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;emails %&amp;gt;%
  str_split(pattern = &amp;#39;@&amp;#39;) %&amp;gt;%
  map_chr(2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;fastcompany.com&amp;quot;   &amp;quot;digg.com&amp;quot;          &amp;quot;altervista.org&amp;quot;   
## [4] &amp;quot;sciencedirect.com&amp;quot; &amp;quot;bandcamp.com&amp;quot;      &amp;quot;surveymonkey.com&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;step-3-split-the-above-using-pattern-..&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step 3: Split the above using pattern &lt;code&gt;\\.&lt;/code&gt;.&lt;/h4&gt;
&lt;p&gt;We want the domain name and not the extension. Step 2 returned a
character vector and we need to split the domain name and the domain
extension. They are separated by &lt;code&gt;.&lt;/code&gt;. Since &lt;code&gt;.&lt;/code&gt; is a special character,
we will use &lt;code&gt;\\&lt;/code&gt; before &lt;code&gt;.&lt;/code&gt; to escape it. Let us split the domain
name and domain extension using &lt;code&gt;str_split&lt;/code&gt; and &lt;code&gt;\\.&lt;/code&gt; as the pattern.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;emails %&amp;gt;%
  str_split(pattern = &amp;#39;@&amp;#39;) %&amp;gt;%
  map_chr(2) %&amp;gt;%
  str_split(pattern = &amp;#39;\\.&amp;#39;) &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [[1]]
## [1] &amp;quot;fastcompany&amp;quot; &amp;quot;com&amp;quot;        
## 
## [[2]]
## [1] &amp;quot;digg&amp;quot; &amp;quot;com&amp;quot; 
## 
## [[3]]
## [1] &amp;quot;altervista&amp;quot; &amp;quot;org&amp;quot;       
## 
## [[4]]
## [1] &amp;quot;sciencedirect&amp;quot; &amp;quot;com&amp;quot;          
## 
## [[5]]
## [1] &amp;quot;bandcamp&amp;quot; &amp;quot;com&amp;quot;     
## 
## [[6]]
## [1] &amp;quot;surveymonkey&amp;quot; &amp;quot;com&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;step-4-extract-the-first-element-from-the-resulting-list.&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step 4: Extract the first element from the resulting list.&lt;/h4&gt;
&lt;p&gt;Now that we have separated the domain name from its extension, let us extract
the first value from each element in the list returned in step 3. We will again
use &lt;code&gt;map_chr&lt;/code&gt; to achieve this.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;emails %&amp;gt;%
  str_split(pattern = &amp;#39;@&amp;#39;) %&amp;gt;%
  map_chr(2) %&amp;gt;%
  str_split(pattern = &amp;#39;\\.&amp;#39;) %&amp;gt;%
  map_chr(extract(1))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;fastcompany&amp;quot;   &amp;quot;digg&amp;quot;          &amp;quot;altervista&amp;quot;    &amp;quot;sciencedirect&amp;quot;
## [5] &amp;quot;bandcamp&amp;quot;      &amp;quot;surveymonkey&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;extract-domain-extension&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Extract Domain Extension&lt;/h2&gt;
&lt;p&gt;The below code extracts the domain extension instead of the domain name.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;emails %&amp;gt;%
  str_split(pattern = &amp;#39;@&amp;#39;) %&amp;gt;%
  map_chr(2) %&amp;gt;%
  str_split(pattern = &amp;#39;\\.&amp;#39;, simplify = TRUE) %&amp;gt;%
  extract(, 2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;com&amp;quot; &amp;quot;com&amp;quot; &amp;quot;org&amp;quot; &amp;quot;com&amp;quot; &amp;quot;com&amp;quot; &amp;quot;com&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;extract-image-type-from-url&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Extract image type from URL&lt;/h2&gt;
&lt;div id=&#34;steps-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Steps&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;split imageurl using pattern &lt;code&gt;\\.&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;extract the third value from each element of the resulting list&lt;/li&gt;
&lt;li&gt;subset the string using the index position&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let us take a look at the URL of the image.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;img &amp;lt;- 
  mockstring %&amp;gt;%
  pull(imageurl) %&amp;gt;%
  head()

img&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;http://dummyimage.com/130x183.jpg/dddddd/000000&amp;quot;
## [2] &amp;quot;http://dummyimage.com/106x217.bmp/dddddd/000000&amp;quot;
## [3] &amp;quot;http://dummyimage.com/146x127.bmp/cc0000/ffffff&amp;quot;
## [4] &amp;quot;http://dummyimage.com/181x194.png/5fa2dd/ffffff&amp;quot;
## [5] &amp;quot;http://dummyimage.com/220x123.jpg/ff4444/ffffff&amp;quot;
## [6] &amp;quot;http://dummyimage.com/118x176.bmp/dddddd/000000&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;step-1-split-imageurl-using-pattern-.&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step 1: Split imageurl using pattern &lt;code&gt;\\.&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;Let us split imageurl using &lt;code&gt;str_split&lt;/code&gt; and the pattern &lt;code&gt;\\.&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str_split(img, pattern = &amp;#39;\\.&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [[1]]
## [1] &amp;quot;http://dummyimage&amp;quot; &amp;quot;com/130x183&amp;quot;       &amp;quot;jpg/dddddd/000000&amp;quot;
## 
## [[2]]
## [1] &amp;quot;http://dummyimage&amp;quot; &amp;quot;com/106x217&amp;quot;       &amp;quot;bmp/dddddd/000000&amp;quot;
## 
## [[3]]
## [1] &amp;quot;http://dummyimage&amp;quot; &amp;quot;com/146x127&amp;quot;       &amp;quot;bmp/cc0000/ffffff&amp;quot;
## 
## [[4]]
## [1] &amp;quot;http://dummyimage&amp;quot; &amp;quot;com/181x194&amp;quot;       &amp;quot;png/5fa2dd/ffffff&amp;quot;
## 
## [[5]]
## [1] &amp;quot;http://dummyimage&amp;quot; &amp;quot;com/220x123&amp;quot;       &amp;quot;jpg/ff4444/ffffff&amp;quot;
## 
## [[6]]
## [1] &amp;quot;http://dummyimage&amp;quot; &amp;quot;com/118x176&amp;quot;       &amp;quot;bmp/dddddd/000000&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;step-2-extract-the-third-value-from-each-element-of-the-resulting-list&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step 2: Extract the third value from each element of the resulting list&lt;/h4&gt;
&lt;p&gt;Step 1 returned a list the elements of which have 3 values each. If you
observe the list, the image type is in the 3rd value. We will now
extract the third value from each element of the list using &lt;code&gt;map_chr&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;img %&amp;gt;%
  str_split(pattern = &amp;#39;\\.&amp;#39;) %&amp;gt;%
  map_chr(extract(3))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;jpg/dddddd/000000&amp;quot; &amp;quot;bmp/dddddd/000000&amp;quot; &amp;quot;bmp/cc0000/ffffff&amp;quot;
## [4] &amp;quot;png/5fa2dd/ffffff&amp;quot; &amp;quot;jpg/ff4444/ffffff&amp;quot; &amp;quot;bmp/dddddd/000000&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;step-3-subset-the-string-using-the-index-position&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step 3: Subset the string using the index position&lt;/h4&gt;
&lt;p&gt;We can now extract the image type in two ways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;subset the first 3 characters of the string&lt;/li&gt;
&lt;li&gt;split the string using pattern &lt;code&gt;/&lt;/code&gt; and extract the first value from the
elements of the resulting list&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Below is the first method. We know that the image type is 3 characters. So
we use &lt;code&gt;str_sub&lt;/code&gt; to subset the first 3 characters. The index positions
are mentioned using &lt;code&gt;start&lt;/code&gt; and &lt;code&gt;stop&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;img %&amp;gt;%
  str_split(pattern = &amp;#39;\\.&amp;#39;) %&amp;gt;%
  map_chr(extract(3)) %&amp;gt;%
  str_sub(start = 1, end = 3)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;jpg&amp;quot; &amp;quot;bmp&amp;quot; &amp;quot;bmp&amp;quot; &amp;quot;png&amp;quot; &amp;quot;jpg&amp;quot; &amp;quot;bmp&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In case you are not sure about the length of the image type. In such cases,
we will split the string using pattern &lt;code&gt;/&lt;/code&gt; and then use &lt;code&gt;map_chr&lt;/code&gt; to
extract the first value of each element of the resulting list.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;img %&amp;gt;%
  str_split(pattern = &amp;#39;\\.&amp;#39;) %&amp;gt;%
  map_chr(extract(3)) %&amp;gt;%
  str_split(pattern = &amp;#39;/&amp;#39;) %&amp;gt;%
  map_chr(extract(1))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;jpg&amp;quot; &amp;quot;bmp&amp;quot; &amp;quot;bmp&amp;quot; &amp;quot;png&amp;quot; &amp;quot;jpg&amp;quot; &amp;quot;bmp&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;extract-image-dimesion-from-url&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Extract Image Dimesion from URL&lt;/h2&gt;
&lt;div id=&#34;steps-2&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Steps&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;locate numbers between 0 and 9&lt;/li&gt;
&lt;li&gt;extract part of url starting with image dimension&lt;/li&gt;
&lt;li&gt;split the string using the pattern &lt;code&gt;\\.&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;extract the first element&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;step-1-locate-numbers-between-0-and-9.&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step 1: Locate numbers between 0 and 9.&lt;/h4&gt;
&lt;p&gt;Let us inspect the image url. The dimension of the image appears
after the domain extension and there are no numbers in the url
before. We will locate the position or index of the first number
in the url using &lt;code&gt;str_locate()&lt;/code&gt; and using the pattern &lt;code&gt;[0-9]&lt;/code&gt;
which instructs to look for any number between and including 0
and 9.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str_locate(img, pattern = &amp;quot;[0-9]&amp;quot;) &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      start end
## [1,]    23  23
## [2,]    23  23
## [3,]    23  23
## [4,]    23  23
## [5,]    23  23
## [6,]    23  23&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;step-2-extract-url&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step 2: Extract url&lt;/h4&gt;
&lt;p&gt;We know where the dimension is located in the url. Let us extract the
part of the url that contains the image dimension using &lt;code&gt;str_sub()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str_sub(img, start = 23) &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;130x183.jpg/dddddd/000000&amp;quot; &amp;quot;106x217.bmp/dddddd/000000&amp;quot;
## [3] &amp;quot;146x127.bmp/cc0000/ffffff&amp;quot; &amp;quot;181x194.png/5fa2dd/ffffff&amp;quot;
## [5] &amp;quot;220x123.jpg/ff4444/ffffff&amp;quot; &amp;quot;118x176.bmp/dddddd/000000&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;step-3-split-the-string-using-the-pattern-..&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step 3: Split the string using the pattern &lt;code&gt;\\.&lt;/code&gt;.&lt;/h4&gt;
&lt;p&gt;From the previous step, we have the part of the url that
contains the image dimension. To extract the dimension, we
will split it from the rest of the url using &lt;code&gt;str_split()&lt;/code&gt;
and using the pattern &lt;code&gt;\\.&lt;/code&gt; as it separates the dimension
and the image extension.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;img %&amp;gt;%
  str_sub(start = 23) %&amp;gt;%
  str_split(pattern = &amp;#39;\\.&amp;#39;) &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [[1]]
## [1] &amp;quot;130x183&amp;quot;           &amp;quot;jpg/dddddd/000000&amp;quot;
## 
## [[2]]
## [1] &amp;quot;106x217&amp;quot;           &amp;quot;bmp/dddddd/000000&amp;quot;
## 
## [[3]]
## [1] &amp;quot;146x127&amp;quot;           &amp;quot;bmp/cc0000/ffffff&amp;quot;
## 
## [[4]]
## [1] &amp;quot;181x194&amp;quot;           &amp;quot;png/5fa2dd/ffffff&amp;quot;
## 
## [[5]]
## [1] &amp;quot;220x123&amp;quot;           &amp;quot;jpg/ff4444/ffffff&amp;quot;
## 
## [[6]]
## [1] &amp;quot;118x176&amp;quot;           &amp;quot;bmp/dddddd/000000&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;step-4-extract-the-first-element.&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step 4: Extract the first element.&lt;/h4&gt;
&lt;p&gt;The above step resulted in a list which contains the
image dimension and the rest of the url. Each element
of the list is a character vector. We want to extract
the first value in the character vector. Let us use
&lt;code&gt;map_chr()&lt;/code&gt; to extract the first value from each
element of the list.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;img %&amp;gt;%
  str_sub(start = 23) %&amp;gt;%
  str_split(pattern = &amp;#39;\\.&amp;#39;) %&amp;gt;%
  map_chr(extract(1))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;130x183&amp;quot; &amp;quot;106x217&amp;quot; &amp;quot;146x127&amp;quot; &amp;quot;181x194&amp;quot; &amp;quot;220x123&amp;quot; &amp;quot;118x176&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;extract-http-protocol-from-url&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Extract HTTP Protocol from URL&lt;/h2&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;url1 &amp;lt;- 
  mockstring %&amp;gt;%
  pull(url) %&amp;gt;%
  first()

url1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;https://engadget.com/nascetur/ridiculus/mus/vivamus/vestibulum.jsp?eu=est&amp;amp;tincidunt=risus&amp;amp;in=auctor&amp;amp;leo=sed&amp;amp;maecenas=tristique&amp;amp;pulvinar=in&amp;amp;lobortis=tempus&amp;amp;est=sit&amp;amp;phasellus=amet&amp;amp;sit=sem&amp;amp;amet=fusce&amp;amp;erat=consequat&amp;amp;nulla=nulla&amp;amp;tempus=nisl&amp;amp;vivamus=nunc&amp;amp;in=nisl&amp;amp;felis=duis&amp;amp;eu=bibendum&amp;amp;sapien=felis&amp;amp;cursus=sed&amp;amp;vestibulum=interdum&amp;amp;proin=venenatis&amp;amp;eu=turpis&amp;amp;mi=enim&amp;amp;nulla=blandit&amp;amp;ac=mi&amp;amp;enim=in&amp;amp;in=porttitor&amp;amp;tempor=pede&amp;amp;turpis=justo&amp;amp;nec=eu&amp;amp;euismod=massa&amp;amp;scelerisque=donec&amp;amp;quam=dapibus&amp;amp;turpis=duis&amp;amp;adipiscing=at&amp;amp;lorem=velit&amp;amp;vitae=eu&amp;amp;mattis=est&amp;amp;nibh=congue&amp;amp;ligula=elementum&amp;amp;nec=in&amp;amp;sem=hac&amp;amp;duis=habitasse&amp;amp;aliquam=platea&amp;amp;convallis=dictumst&amp;amp;nunc=morbi&amp;amp;proin=vestibulum&amp;amp;at=velit&amp;amp;turpis=id&amp;amp;a=pretium&amp;amp;pede=iaculis&amp;amp;posuere=diam&amp;amp;nonummy=erat&amp;amp;integer=fermentum&amp;amp;non=justo&amp;amp;velit=nec&amp;amp;donec=condimentum&amp;amp;diam=neque&amp;amp;neque=sapien&amp;amp;vestibulum=placerat&amp;amp;eget=ante&amp;amp;vulputate=nulla&amp;amp;ut=justo&amp;amp;ultrices=aliquam&amp;amp;vel=quis&amp;amp;augue=turpis&amp;amp;vestibulum=eget&amp;amp;ante=elit&amp;amp;ipsum=sodales&amp;amp;primis=scelerisque&amp;amp;in=mauris&amp;amp;faucibus=sit&amp;amp;orci=amet&amp;amp;luctus=eros&amp;amp;et=suspendisse&amp;amp;ultrices=accumsan&amp;amp;posuere=tortor&amp;amp;cubilia=quis&amp;amp;curae=turpis&amp;amp;donec=sed&amp;amp;pharetra=ante&amp;amp;magna=vivamus&amp;amp;vestibulum=tortor&amp;amp;aliquet=duis&amp;amp;ultrices=mattis&amp;amp;erat=egestas&amp;amp;tortor=metus&amp;amp;sollicitudin=aenean&amp;amp;mi=fermentum&amp;amp;sit=donec&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;steps-3&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Steps&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;split the url using the pattern &lt;code&gt;://&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;extract the first element&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;step-1-split-the-url-using-the-pattern-.&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step 1: Split the url using the pattern &lt;code&gt;://&lt;/code&gt;.&lt;/h4&gt;
&lt;p&gt;The HTTP protocol is the first part of the url and is
separated from the rest of the url by &lt;code&gt;:&lt;/code&gt;. Let us
split the url using &lt;code&gt;str_split()&lt;/code&gt; and using the
pattern &lt;code&gt;:&lt;/code&gt;. Since &lt;code&gt;:&lt;/code&gt; is a special character, we
will escape it using &lt;code&gt;\\&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str_split(url1, pattern = &amp;#39;://&amp;#39;) &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [[1]]
## [1] &amp;quot;https&amp;quot;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
## [2] &amp;quot;engadget.com/nascetur/ridiculus/mus/vivamus/vestibulum.jsp?eu=est&amp;amp;tincidunt=risus&amp;amp;in=auctor&amp;amp;leo=sed&amp;amp;maecenas=tristique&amp;amp;pulvinar=in&amp;amp;lobortis=tempus&amp;amp;est=sit&amp;amp;phasellus=amet&amp;amp;sit=sem&amp;amp;amet=fusce&amp;amp;erat=consequat&amp;amp;nulla=nulla&amp;amp;tempus=nisl&amp;amp;vivamus=nunc&amp;amp;in=nisl&amp;amp;felis=duis&amp;amp;eu=bibendum&amp;amp;sapien=felis&amp;amp;cursus=sed&amp;amp;vestibulum=interdum&amp;amp;proin=venenatis&amp;amp;eu=turpis&amp;amp;mi=enim&amp;amp;nulla=blandit&amp;amp;ac=mi&amp;amp;enim=in&amp;amp;in=porttitor&amp;amp;tempor=pede&amp;amp;turpis=justo&amp;amp;nec=eu&amp;amp;euismod=massa&amp;amp;scelerisque=donec&amp;amp;quam=dapibus&amp;amp;turpis=duis&amp;amp;adipiscing=at&amp;amp;lorem=velit&amp;amp;vitae=eu&amp;amp;mattis=est&amp;amp;nibh=congue&amp;amp;ligula=elementum&amp;amp;nec=in&amp;amp;sem=hac&amp;amp;duis=habitasse&amp;amp;aliquam=platea&amp;amp;convallis=dictumst&amp;amp;nunc=morbi&amp;amp;proin=vestibulum&amp;amp;at=velit&amp;amp;turpis=id&amp;amp;a=pretium&amp;amp;pede=iaculis&amp;amp;posuere=diam&amp;amp;nonummy=erat&amp;amp;integer=fermentum&amp;amp;non=justo&amp;amp;velit=nec&amp;amp;donec=condimentum&amp;amp;diam=neque&amp;amp;neque=sapien&amp;amp;vestibulum=placerat&amp;amp;eget=ante&amp;amp;vulputate=nulla&amp;amp;ut=justo&amp;amp;ultrices=aliquam&amp;amp;vel=quis&amp;amp;augue=turpis&amp;amp;vestibulum=eget&amp;amp;ante=elit&amp;amp;ipsum=sodales&amp;amp;primis=scelerisque&amp;amp;in=mauris&amp;amp;faucibus=sit&amp;amp;orci=amet&amp;amp;luctus=eros&amp;amp;et=suspendisse&amp;amp;ultrices=accumsan&amp;amp;posuere=tortor&amp;amp;cubilia=quis&amp;amp;curae=turpis&amp;amp;donec=sed&amp;amp;pharetra=ante&amp;amp;magna=vivamus&amp;amp;vestibulum=tortor&amp;amp;aliquet=duis&amp;amp;ultrices=mattis&amp;amp;erat=egestas&amp;amp;tortor=metus&amp;amp;sollicitudin=aenean&amp;amp;mi=fermentum&amp;amp;sit=donec&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;step-2-extract-the-first-element.&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step 2: Extract the first element.&lt;/h4&gt;
&lt;p&gt;The HTTP protocol is the first value in each element
of the list. As we did in the previous example, we
will extact it using &lt;code&gt;map_chr()&lt;/code&gt; and &lt;code&gt;extract()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;url1 %&amp;gt;%
  str_split(pattern = &amp;#39;://&amp;#39;) %&amp;gt;%
  map_chr(extract(1))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;https&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;extract-file-type&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Extract file type&lt;/h2&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;urls &amp;lt;-
  mockstring %&amp;gt;%
  use_series(url) %&amp;gt;%
  extract(1:3)&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;steps-4&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Steps&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;check if there are only 2 dots in the URL&lt;/li&gt;
&lt;li&gt;check if there is only 1 question mark in the URL&lt;/li&gt;
&lt;li&gt;detect the staritng position of file type&lt;/li&gt;
&lt;li&gt;tetect the ending position of file type&lt;/li&gt;
&lt;li&gt;use the locations to specify the index position for extracting file type&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;step-1-check-if-there-are-only-2-dots-in-the-url&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step 1: Check if there are only 2 dots in the URL&lt;/h4&gt;
&lt;p&gt;Let us locate all the dots in the url using &lt;code&gt;str_locate_all()&lt;/code&gt; and see
if any of them contain more than 2 dots.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;urls %&amp;gt;%
  str_locate_all(pattern = &amp;#39;\\.&amp;#39;) %&amp;gt;%
  map_int(nrow) %&amp;gt;%
  is_greater_than(2) %&amp;gt;%
  sum()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;step-2-check-if-there-is-only-1-question-mark-in-the-url&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step 2: Check if there is only 1 question mark in the URL&lt;/h4&gt;
&lt;p&gt;The next step is to check if there is only one &lt;code&gt;?&lt;/code&gt; (question mark)
in the url.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;urls %&amp;gt;%
  str_locate_all(pattern = &amp;quot;[?]&amp;quot;) %&amp;gt;%
  map_int(nrow) %&amp;gt;%
  is_greater_than(1) %&amp;gt;%
  sum()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;step-3-detect-the-staritng-position-of-file-type&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step 3: Detect the staritng position of file type&lt;/h4&gt;
&lt;p&gt;Since the file type is located between the second dot and
the first quesiton mark in the url, let us extract the
location of the second dot and add 1 as the file type
starts after the dot.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;d &amp;lt;- 
  urls %&amp;gt;%
  str_locate_all(pattern = &amp;#39;\\.&amp;#39;) %&amp;gt;%
  map_int(extract(2)) %&amp;gt;%
  add(1)

d  &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 64 47 48&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;step-4-detect-the-ending-position-of-file-type&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step 4: Detect the ending position of file type&lt;/h4&gt;
&lt;p&gt;In step 2, we confirmed that the url has only one question mark.
Let us locate the question mark in the url and subtract 1 (as the
file type ends before the question mark) so that we get the
ending postion of the file type.
.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;q &amp;lt;-  
  urls %&amp;gt;%
  str_locate_all(pattern = &amp;quot;[?]&amp;quot;) %&amp;gt;%
  map_int(extract(1)) %&amp;gt;%
  subtract(1)

q&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 66 50 51&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;step-5-specify-the-index-position-for-extracting-file-type&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Step 5: Specify the index position for extracting file type&lt;/h4&gt;
&lt;p&gt;From steps 3 and 4, we have the location of the second dot and the
first question mark in the url. Let us use them with &lt;code&gt;str_sub()&lt;/code&gt;
to extract the file type.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str_sub(urls, start = d, end = q)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;jsp&amp;quot;  &amp;quot;json&amp;quot; &amp;quot;json&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;references&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://stringr.tidyverse.org/&#34; class=&#34;uri&#34;&gt;https://stringr.tidyverse.org/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://r4ds.had.co.nz/strings.html&#34; class=&#34;uri&#34;&gt;http://r4ds.had.co.nz/strings.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Readable Code with Pipes</title>
      <link>https://blog.rsquaredacademy.com/readable-code-with-pipes/</link>
      <pubDate>Wed, 10 Oct 2018 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/readable-code-with-pipes/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;R code contain a lot of parentheses in case of a sequence of multiple operations. When you are dealing with
complex code, it results in nested function calls which are hard to read and maintain. The &lt;a href=&#34;https://CRAN.R-project.org/package=magrittr&#34;&gt;magrittr&lt;/a&gt; package by &lt;a href=&#34;http://stefanbache.dk/&#34;&gt;Stefan Milton Bache&lt;/a&gt; provides pipes enabling us to write R code that is readable.&lt;/p&gt;
&lt;p&gt;Pipes allow us to clearly express a sequence of multiple operations by:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;structuring operations from left to right&lt;/li&gt;
&lt;li&gt;avoiding
&lt;ul&gt;
&lt;li&gt;nested function calls&lt;/li&gt;
&lt;li&gt;intermediate steps&lt;/li&gt;
&lt;li&gt;overwriting of original data&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;minimizing creation of local variables&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;pipes&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Pipes&lt;/h2&gt;
&lt;p&gt;If you are using &lt;a href=&#34;https://www.tidyverse.org/&#34;&gt;tidyverse&lt;/a&gt;, magrittr will be automatically loaded. We will look at 3 different types of pipes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;%&amp;gt;%&lt;/code&gt; : pipe a value forward into an expression or function call&lt;/li&gt;
&lt;li&gt;&lt;code&gt;%&amp;lt;&amp;gt;%&lt;/code&gt;: result assigned to left hand side object instead of returning it&lt;/li&gt;
&lt;li&gt;&lt;code&gt;%$%&lt;/code&gt; : expose names within left hand side objects to right hand side expressions&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Libraries, Code &amp;amp; Data&lt;/h2&gt;
&lt;p&gt;We will use the following packages in this post:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://magrittr.tidyverse.org/&#34;&gt;magrittr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://readr.tidyverse.org/&#34;&gt;readr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://dplyr.tidyverse.org/&#34;&gt;dplyr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://stringr.tidyverse.org/&#34;&gt;stringr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;and &lt;a href=&#34;http://readr.tidyverse.org/&#34;&gt;purrr&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can find the data sets &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt; and the codes
&lt;a href=&#34;https://gist.github.com/aravindhebbali/26d85ab4a4dadd2fe7c1f58d854cc950&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(magrittr)
library(readr)
library(dplyr)
library(stringr)
library(purrr)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data&lt;/h2&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom &amp;lt;- 
  read_csv(&amp;#39;https://raw.githubusercontent.com/rsquaredacademy/datasets/master/web.csv&amp;#39;,
    col_types = cols_only(
      referrer = col_factor(levels = c(&amp;quot;bing&amp;quot;, &amp;quot;direct&amp;quot;, &amp;quot;social&amp;quot;, &amp;quot;yahoo&amp;quot;, &amp;quot;google&amp;quot;)),
      n_pages = col_double(), duration = col_double(), purchase = col_logical()
    )
  )

ecom&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1,000 x 4
##    referrer n_pages duration purchase
##    &amp;lt;fct&amp;gt;      &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;lgl&amp;gt;   
##  1 google         1      693 FALSE   
##  2 yahoo          1      459 FALSE   
##  3 direct         1      996 FALSE   
##  4 bing          18      468 TRUE    
##  5 yahoo          1      955 FALSE   
##  6 yahoo          5      135 FALSE   
##  7 yahoo          1       75 FALSE   
##  8 direct         1      908 FALSE   
##  9 bing          19      209 FALSE   
## 10 google         1      208 FALSE   
## # ... with 990 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We will create a smaller data set from the above data to be used in some examples:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom_mini &amp;lt;- sample_n(ecom, size = 10)
ecom_mini&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 10 x 4
##    referrer n_pages duration purchase
##    &amp;lt;fct&amp;gt;      &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;lgl&amp;gt;   
##  1 direct         1      136 FALSE   
##  2 direct         1      314 FALSE   
##  3 direct        18      324 TRUE    
##  4 social        10      290 TRUE    
##  5 yahoo          7      140 FALSE   
##  6 direct         1      658 FALSE   
##  7 bing          17      493 FALSE   
##  8 bing           1      406 FALSE   
##  9 social        15      405 FALSE   
## 10 google        15      210 FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;data-dictionary&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Data Dictionary&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;referrer: referrer website/search engine&lt;/li&gt;
&lt;li&gt;n_pages: number of pages visited&lt;/li&gt;
&lt;li&gt;duration: time spent on the website (in seconds)&lt;/li&gt;
&lt;li&gt;purchase: whether visitor purchased&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;first-example&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;First Example&lt;/h2&gt;
&lt;p&gt;Let us start with a simple example. You must be aware of &lt;code&gt;head()&lt;/code&gt;. If not,
do not worry. It returns the first few observations/rows of data. We can
specify the number of observations it should return as well. Let us use
it to view the first 10 rows of our data set.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;head(ecom, 10)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 10 x 4
##    referrer n_pages duration purchase
##    &amp;lt;fct&amp;gt;      &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;lgl&amp;gt;   
##  1 google         1      693 FALSE   
##  2 yahoo          1      459 FALSE   
##  3 direct         1      996 FALSE   
##  4 bing          18      468 TRUE    
##  5 yahoo          1      955 FALSE   
##  6 yahoo          5      135 FALSE   
##  7 yahoo          1       75 FALSE   
##  8 direct         1      908 FALSE   
##  9 bing          19      209 FALSE   
## 10 google         1      208 FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;using-pipe&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Using Pipe&lt;/h4&gt;
&lt;p&gt;Now let us do the same but with &lt;code&gt;%&amp;gt;%&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom %&amp;gt;% head(10)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 10 x 4
##    referrer n_pages duration purchase
##    &amp;lt;fct&amp;gt;      &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;lgl&amp;gt;   
##  1 google         1      693 FALSE   
##  2 yahoo          1      459 FALSE   
##  3 direct         1      996 FALSE   
##  4 bing          18      468 TRUE    
##  5 yahoo          1      955 FALSE   
##  6 yahoo          5      135 FALSE   
##  7 yahoo          1       75 FALSE   
##  8 direct         1      908 FALSE   
##  9 bing          19      209 FALSE   
## 10 google         1      208 FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;square-root&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Square Root&lt;/h2&gt;
&lt;p&gt;Time to try a slightly more challenging example. We want the square root of
&lt;code&gt;n_pages&lt;/code&gt; column from the data set.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;y &amp;lt;- sqrt(ecom_mini$n_pages)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us break down the above computation into small steps:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;select/expose the &lt;code&gt;n_pages&lt;/code&gt; column from &lt;code&gt;ecom&lt;/code&gt; data&lt;/li&gt;
&lt;li&gt;compute the square root&lt;/li&gt;
&lt;li&gt;assign the first few observations to &lt;code&gt;y&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/pipes_square_root.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Let us reproduce &lt;code&gt;y&lt;/code&gt; using pipes.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# select n_pages variable and assign it to y
y &amp;lt;-
    ecom_mini %$%
    n_pages

# compute square root of y and assign it to y 
y %&amp;lt;&amp;gt;% sqrt&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Another way to compute the square root of y is shown below.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;y &amp;lt;-
  ecom_mini %$% 
  n_pages %&amp;gt;% 
  sqrt()&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;visualization&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Visualization&lt;/h2&gt;
&lt;p&gt;Let us look at a data visualization example. We will create a bar plot to
visualize the frequency of different referrer types that drove purchasers
to the website. Let us look at the steps involved in creating the bar plot:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;extract rows where purchase is TRUE&lt;/li&gt;
&lt;li&gt;select/expose &lt;code&gt;referrer&lt;/code&gt; column&lt;/li&gt;
&lt;li&gt;tabulate referrer data using &lt;code&gt;table()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;use the tabulated data to create bar plot using &lt;code&gt;barplot()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(table(subset(ecom, purchase)$referrer))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-10-10-readable-code-with-pipes_files/figure-html/mag21-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;using-pipe-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Using pipe&lt;/h4&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/pipes_data_visualization.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom %&amp;gt;%
  subset(purchase) %&amp;gt;%
  extract(&amp;#39;referrer&amp;#39;) %&amp;gt;%
  table() %&amp;gt;%
  barplot()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-10-10-readable-code-with-pipes_files/figure-html/mag7-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;correlation&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Correlation&lt;/h2&gt;
&lt;p&gt;Correlation is a statistical measure that indicates the extent to which two or more variables
fluctuate together. In R, correlation is computed using &lt;code&gt;cor()&lt;/code&gt;. Let us look at the
correlation between the number of pages browsed and time spent on the site for
visitors who purchased some product. Below are the steps for computing correlation:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;extract rows where purchase is TRUE&lt;/li&gt;
&lt;li&gt;select/expose &lt;code&gt;n_pages&lt;/code&gt; and &lt;code&gt;duration&lt;/code&gt; columns&lt;/li&gt;
&lt;li&gt;use &lt;code&gt;cor()&lt;/code&gt; to compute the correlation&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/pipes_correlation.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# without pipe
ecom1 &amp;lt;- subset(ecom, purchase)
cor(ecom1$n_pages, ecom1$duration)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.4290905&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# with pipe
ecom %&amp;gt;%
  subset(purchase) %$% 
  cor(n_pages, duration)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.4290905&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# with pipe
ecom %&amp;gt;%
  filter(purchase) %$% 
  cor(n_pages, duration)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.4290905&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;regression&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Regression&lt;/h2&gt;
&lt;p&gt;Let us look at a regression example. We regress time spent on the site on
number of pages visited. Below are the steps involved in running the regression:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;use &lt;code&gt;duration&lt;/code&gt; and &lt;code&gt;n_pages&lt;/code&gt; columns from ecom data&lt;/li&gt;
&lt;li&gt;pass the above data to &lt;code&gt;lm()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;pass the output from &lt;code&gt;lm()&lt;/code&gt; to &lt;code&gt;summary()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;summary(lm(duration ~ n_pages, data = ecom))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Call:
## lm(formula = duration ~ n_pages, data = ecom)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -386.45 -213.03  -38.93  179.31  602.55 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(&amp;gt;|t|)    
## (Intercept)  404.803     11.323  35.750  &amp;lt; 2e-16 ***
## n_pages       -8.355      1.296  -6.449 1.76e-10 ***
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1
## 
## Residual standard error: 263.3 on 998 degrees of freedom
## Multiple R-squared:   0.04,  Adjusted R-squared:  0.03904 
## F-statistic: 41.58 on 1 and 998 DF,  p-value: 1.756e-10&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;using-pipe-2&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Using pipe&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom %$%
  lm(duration ~ n_pages) %&amp;gt;%
  summary()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Call:
## lm(formula = duration ~ n_pages)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -386.45 -213.03  -38.93  179.31  602.55 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(&amp;gt;|t|)    
## (Intercept)  404.803     11.323  35.750  &amp;lt; 2e-16 ***
## n_pages       -8.355      1.296  -6.449 1.76e-10 ***
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1
## 
## Residual standard error: 263.3 on 998 degrees of freedom
## Multiple R-squared:   0.04,  Adjusted R-squared:  0.03904 
## F-statistic: 41.58 on 1 and 998 DF,  p-value: 1.756e-10&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;string-manipulation&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;String Manipulation&lt;/h2&gt;
&lt;p&gt;We want to extract the first name (jovial) from the below email id and
convert it to upper case. Below are the steps to achieve this:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;split the email id using the pattern &lt;code&gt;@&lt;/code&gt; using &lt;code&gt;str_split()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;extract the first element from the resulting list using &lt;code&gt;extract2()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;extract the first element from the character vector using &lt;code&gt;extract()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;extract the first six characters using &lt;code&gt;str_sub()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;convert to upper case using &lt;code&gt;str_to_upper()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/pipes_string.png&#34; width=&#34;70%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;email &amp;lt;- &amp;#39;jovialcann@anymail.com&amp;#39;

# without pipe
str_to_upper(str_sub(str_split(email, &amp;#39;@&amp;#39;)[[1]][1], start = 1, end = 6))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;JOVIAL&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# with pipe
email %&amp;gt;%
  str_split(pattern = &amp;#39;@&amp;#39;) %&amp;gt;%
  extract2(1) %&amp;gt;%
  extract(1) %&amp;gt;%
  str_sub(start = 1, end = 6) %&amp;gt;%
  str_to_upper()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;JOVIAL&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Another method that uses &lt;code&gt;map_chr()&lt;/code&gt; from the &lt;a href=&#34;https://readr.tidyverse.org/&#34;&gt;purrr&lt;/a&gt; package.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;email %&amp;gt;%
  str_split(pattern = &amp;#39;@&amp;#39;) %&amp;gt;%
  map_chr(1) %&amp;gt;%
  str_sub(start = 1, end = 6) %&amp;gt;%
  str_to_upper()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;JOVIAL&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;data-extraction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data Extraction&lt;/h2&gt;
&lt;p&gt;Let us turn our attention towards data extraction. magrittr provides
alternatives to &lt;code&gt;$&lt;/code&gt;, &lt;code&gt;[&lt;/code&gt; and &lt;code&gt;[[&lt;/code&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;extract()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;extract2()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;use_series()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;extract-column-by-name&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Extract Column By Name&lt;/h4&gt;
&lt;p&gt;To extract a specific column using the column name, we mention the name
of the column in single/double quotes within &lt;code&gt;[&lt;/code&gt; or &lt;code&gt;[[&lt;/code&gt;. In case of &lt;code&gt;$&lt;/code&gt;,
we do not use quotes.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# base 
ecom_mini[&amp;#39;n_pages&amp;#39;]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 10 x 1
##    n_pages
##      &amp;lt;dbl&amp;gt;
##  1       1
##  2       1
##  3      18
##  4      10
##  5       7
##  6       1
##  7      17
##  8       1
##  9      15
## 10      15&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# magrittr
extract(ecom_mini, &amp;#39;n_pages&amp;#39;) &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 10 x 1
##    n_pages
##      &amp;lt;dbl&amp;gt;
##  1       1
##  2       1
##  3      18
##  4      10
##  5       7
##  6       1
##  7      17
##  8       1
##  9      15
## 10      15&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;extract-column-by-position&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Extract Column By Position&lt;/h4&gt;
&lt;p&gt;We can extract columns using their index position. Keep in mind that index
position starts from &lt;strong&gt;1&lt;/strong&gt; in R. In the below example, we show how to
extract &lt;code&gt;n_pages&lt;/code&gt; column but instead of using the column name, we use the
column position.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# base 
ecom_mini[2]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 10 x 1
##    n_pages
##      &amp;lt;dbl&amp;gt;
##  1       1
##  2       1
##  3      18
##  4      10
##  5       7
##  6       1
##  7      17
##  8       1
##  9      15
## 10      15&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# magrittr
extract(ecom_mini, 2) &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 10 x 1
##    n_pages
##      &amp;lt;dbl&amp;gt;
##  1       1
##  2       1
##  3      18
##  4      10
##  5       7
##  6       1
##  7      17
##  8       1
##  9      15
## 10      15&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;extract-column-as-vector&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Extract Column (as vector)&lt;/h4&gt;
&lt;p&gt;One important differentiator between &lt;code&gt;[&lt;/code&gt; and &lt;code&gt;[[&lt;/code&gt; is that &lt;code&gt;[[&lt;/code&gt; will
return a atomic vector and not a &lt;code&gt;data.frame&lt;/code&gt;. &lt;code&gt;$&lt;/code&gt; will also return
a atomic vector. In magrittr, we can use &lt;code&gt;use_series()&lt;/code&gt; in place of
&lt;code&gt;$&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# base 
ecom_mini$n_pages&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  1  1 18 10  7  1 17  1 15 15&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# magrittr
use_series(ecom_mini, &amp;#39;n_pages&amp;#39;) &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  1  1 18 10  7  1 17  1 15 15&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;extract-list-element-by-name&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Extract List Element By Name&lt;/h4&gt;
&lt;p&gt;Let us convert &lt;code&gt;ecom_mini&lt;/code&gt; into a list using as.list() as shown below:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom_list &amp;lt;- as.list(ecom_mini)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To extract elements of a list, we can use &lt;code&gt;extract2()&lt;/code&gt;. It is an
alternative for &lt;code&gt;[[&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# base 
ecom_list[[&amp;#39;n_pages&amp;#39;]]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  1  1 18 10  7  1 17  1 15 15&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# magrittr
extract2(ecom_list, &amp;#39;n_pages&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  1  1 18 10  7  1 17  1 15 15&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;extract-list-element-by-position&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Extract List Element By Position&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# base 
ecom_list[[1]]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] direct direct direct social yahoo  direct bing   bing   social google
## Levels: bing direct social yahoo google&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# magrittr
extract2(ecom_list, 1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] direct direct direct social yahoo  direct bing   bing   social google
## Levels: bing direct social yahoo google&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;extract-list-element&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Extract List Element&lt;/h4&gt;
&lt;p&gt;We can extract the elements of a list using &lt;code&gt;use_series()&lt;/code&gt; as well.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# base 
ecom_list$n_pages&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  1  1 18 10  7  1 17  1 15 15&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# magrittr
use_series(ecom_list, n_pages)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  1  1 18 10  7  1 17  1 15 15&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;arithmetic-operations&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Arithmetic Operations&lt;/h2&gt;
&lt;p&gt;magrittr offer alternatives for arithemtic operations as well. We will look at
a few examples below.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;add()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;subtract()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;multiply_by()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;multiply_by_matrix()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;divide_by()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;divide_by_int()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;mod()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;raise_to_power()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;addition&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Addition&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;1:10 + 1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  2  3  4  5  6  7  8  9 10 11&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;add(1:10, 1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  2  3  4  5  6  7  8  9 10 11&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;`+`(1:10, 1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  2  3  4  5  6  7  8  9 10 11&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;multiplication&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Multiplication&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;1:10 * 3&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  3  6  9 12 15 18 21 24 27 30&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;multiply_by(1:10, 3)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  3  6  9 12 15 18 21 24 27 30&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;`*`(1:10, 3)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  3  6  9 12 15 18 21 24 27 30&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;division&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Division&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;1:10 / 2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;divide_by(1:10, 2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;`/`(1:10, 2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;power&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Power&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;1:10 ^ 2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   [1]   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18
##  [19]  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36
##  [37]  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54
##  [55]  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72
##  [73]  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90
##  [91]  91  92  93  94  95  96  97  98  99 100&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;raise_to_power(1:10, 2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]   1   4   9  16  25  36  49  64  81 100&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;`^`(1:10, 2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]   1   4   9  16  25  36  49  64  81 100&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;logical-operators&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Logical Operators&lt;/h2&gt;
&lt;p&gt;There are alternatives for logical operators as well. We will look at
a few examples below.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;and()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;or()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;equals()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;not()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;is_greater_than()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;is_weakly_greater_than()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;is_less_than()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;is_weakly_less_than()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;greater-than&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Greater Than&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;1:10 &amp;gt; 5&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;is_greater_than(1:10, 5)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;`&amp;gt;`(1:10, 5)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;weakly-greater-than&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Weakly Greater Than&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;1:10 &amp;gt;= 5&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] FALSE FALSE FALSE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;is_weakly_greater_than(1:10, 5)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] FALSE FALSE FALSE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;`&amp;gt;=`(1:10, 5)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] FALSE FALSE FALSE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;references&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://magrittr.tidyverse.org/&#34; class=&#34;uri&#34;&gt;https://magrittr.tidyverse.org/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://r4ds.had.co.nz/pipes.html&#34; class=&#34;uri&#34;&gt;http://r4ds.had.co.nz/pipes.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Introduction to tibbles</title>
      <link>https://blog.rsquaredacademy.com/introduction-to-tibbles/</link>
      <pubDate>Fri, 28 Sep 2018 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/introduction-to-tibbles/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;A &lt;strong&gt;tibble&lt;/strong&gt;, or &lt;code&gt;tbl_df&lt;/code&gt;, is a modern reimagining of the data.frame, keeping what time has proven to be effective, and throwing out what is not. Tibbles are data.frames that are lazy and surly: they do less (i.e. they don’t change variable names or types, and don’t do partial matching) and complain more (e.g. when a variable does not exist). This forces you to confront problems earlier, typically leading to cleaner, more expressive code. Tibbles also have an enhanced &lt;code&gt;print method()&lt;/code&gt; which makes them easier to use with large datasets containing complex objects.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Source: &lt;a href=&#34;https://tibble.tidyverse.org/&#34; class=&#34;uri&#34;&gt;https://tibble.tidyverse.org/&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;In this post, we will explore tibbles. To be more precise, we will learn:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;how tibbles are different from data frames?&lt;/li&gt;
&lt;li&gt;how to create tibbles?&lt;/li&gt;
&lt;li&gt;how to manipulate tibbles?&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Libraries, Code &amp;amp; Data&lt;/h2&gt;
&lt;p&gt;We will use the following packages:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://tibble.tidyverse.org/&#34;&gt;tibble&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://dplyr.tidyverse.org/&#34;&gt;dplyr&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The code can be found &lt;a href=&#34;https://gist.github.com/aravindhebbali/9a3814b9b4bb5c271d030b15ce4ecdf1&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(tibble)
library(dplyr)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;creating-tibbles&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Creating tibbles&lt;/h2&gt;
&lt;p&gt;tibble can be created using any of the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;tibble()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;as_tibble()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;tribble()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let us start with &lt;code&gt;tibble()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tibble(x = letters,
       y = 1:26,
       z = sample(100, 26))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 26 x 3
##    x         y     z
##    &amp;lt;chr&amp;gt; &amp;lt;int&amp;gt; &amp;lt;int&amp;gt;
##  1 a         1    71
##  2 b         2    56
##  3 c         3    59
##  4 d         4    14
##  5 e         5    58
##  6 f         6    60
##  7 g         7    16
##  8 h         8     9
##  9 i         9    66
## 10 j        10    48
## # ... with 16 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We mentioned the column names followed by the data. If you do not specify the
column names, &lt;code&gt;tibble()&lt;/code&gt; will supply them. Ensure that the length of each column
is same.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;tibble-features&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;tibble features&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;never changes input’s types&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;tibble()&lt;/code&gt; will never alter the input’s type. For example, if you supply a
character vector it will not be converted to factor unlike data.frame where
you need to set &lt;code&gt;stringsAsFactors&lt;/code&gt; to &lt;code&gt;FALSE&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tibble(x = letters,
       y = 1:26,
       z = sample(100, 26))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 26 x 3
##    x         y     z
##    &amp;lt;chr&amp;gt; &amp;lt;int&amp;gt; &amp;lt;int&amp;gt;
##  1 a         1    62
##  2 b         2    13
##  3 c         3    75
##  4 d         4    17
##  5 e         5    82
##  6 f         6    83
##  7 g         7     9
##  8 h         8    76
##  9 i         9    19
## 10 j        10    97
## # ... with 16 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;never adjusts variable names&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;tibble()&lt;/code&gt; will never modify the column names. In the below example, you can
observe that while &lt;code&gt;data.frame&lt;/code&gt; adds a &lt;code&gt;.&lt;/code&gt;, &lt;code&gt;tibble()&lt;/code&gt; retains the column names
as is.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;names(data.frame(`order value` = 10))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;order.value&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;names(tibble(`order value` = 10))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;order value&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;never prints all rows&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;tibble()&lt;/code&gt; will never print all the rows and clutter your console. It will only
print the first 10 rows and only as many columns that fit the width of the
console.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x &amp;lt;- 1:100
y &amp;lt;- letters[1]
z &amp;lt;- sample(c(TRUE, FALSE), 100, replace = TRUE)
tibble(x, y, z)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 100 x 3
##        x y     z    
##    &amp;lt;int&amp;gt; &amp;lt;chr&amp;gt; &amp;lt;lgl&amp;gt;
##  1     1 a     TRUE 
##  2     2 a     FALSE
##  3     3 a     TRUE 
##  4     4 a     TRUE 
##  5     5 a     FALSE
##  6     6 a     TRUE 
##  7     7 a     TRUE 
##  8     8 a     FALSE
##  9     9 a     TRUE 
## 10    10 a     FALSE
## # ... with 90 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;never recycles vector of length greater than 1&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Recycling vectors of length greater than 1 often leads to errors and as such
&lt;code&gt;tibble()&lt;/code&gt; will only recycle vectors of length 1.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x &amp;lt;- 1:100
y &amp;lt;- letters
z &amp;lt;- sample(c(TRUE, FALSE), 100, replace = TRUE)
tibble(x, y, z)
Error in overscope_eval_next(overscope, expr) : object &amp;#39;y&amp;#39; not found&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;membership-testing&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Membership Testing&lt;/h2&gt;
&lt;p&gt;We can test if an object is a tibble using &lt;code&gt;is_tibble()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;is_tibble(mtcars)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;is_tibble(as_tibble(mtcars))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;tribble&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Tribble&lt;/h2&gt;
&lt;p&gt;Another way to create tibbles is using &lt;code&gt;tribble()&lt;/code&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;it is short for transposed tibbles&lt;/li&gt;
&lt;li&gt;it is customized for data entry in code&lt;/li&gt;
&lt;li&gt;column names start with &lt;code&gt;~&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;and values are separated by commas&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tribble(
  ~x, ~y, ~z,
  #--|--|----
  1, TRUE, &amp;#39;a&amp;#39;,
  2, FALSE, &amp;#39;b&amp;#39;
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 2 x 3
##       x y     z    
##   &amp;lt;dbl&amp;gt; &amp;lt;lgl&amp;gt; &amp;lt;chr&amp;gt;
## 1     1 TRUE  a    
## 2     2 FALSE b&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;column-names&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Column Names&lt;/h2&gt;
&lt;p&gt;Names of the columns in tibbles need not be valid R variable names. They can
contain unusual characters like a space or a smiley but must be enclosed in
ticks.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tibble(
  ` ` = &amp;#39;space&amp;#39;,
  `2` = &amp;#39;integer&amp;#39;,
  `:)` = &amp;#39;smiley&amp;#39;
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1 x 3
##   ` `   `2`     `:)`  
##   &amp;lt;chr&amp;gt; &amp;lt;chr&amp;gt;   &amp;lt;chr&amp;gt; 
## 1 space integer smiley&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;add-rows&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Add Rows&lt;/h2&gt;
&lt;p&gt;Let us add data related to &lt;strong&gt;Safari&lt;/strong&gt; browser to the web traffic data using
&lt;code&gt;add_row()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;browsers &amp;lt;- enframe(c(chrome = 40, firefox = 20, edge = 30))
browsers&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 x 2
##   name    value
##   &amp;lt;chr&amp;gt;   &amp;lt;dbl&amp;gt;
## 1 chrome     40
## 2 firefox    20
## 3 edge       30&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;add_row(browsers, name = &amp;#39;safari&amp;#39;, value = 10)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 4 x 2
##   name    value
##   &amp;lt;chr&amp;gt;   &amp;lt;dbl&amp;gt;
## 1 chrome     40
## 2 firefox    20
## 3 edge       30
## 4 safari     10&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If we want to add the data at a particular row, we can specify the row number
using the &lt;code&gt;.before&lt;/code&gt; argument. Let us add the data related to &lt;strong&gt;Safari&lt;/strong&gt; browser
in the second row instead of the last row.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;add_row(browsers, name = &amp;#39;safari&amp;#39;, value = 10, .before = 2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 4 x 2
##   name    value
##   &amp;lt;chr&amp;gt;   &amp;lt;dbl&amp;gt;
## 1 chrome     40
## 2 safari     10
## 3 firefox    20
## 4 edge       30&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;add-columns&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Add Columns&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;add_column()&lt;/code&gt; adds a new column to tibbles.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;browsers &amp;lt;- enframe(c(chrome = 40, firefox = 20, edge = 30, safari = 10))
add_column(browsers, visits = c(4000, 2000, 3000, 1000))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 4 x 3
##   name    value visits
##   &amp;lt;chr&amp;gt;   &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;
## 1 chrome     40   4000
## 2 firefox    20   2000
## 3 edge       30   3000
## 4 safari     10   1000&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;rownames&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Rownames&lt;/h2&gt;
&lt;p&gt;The &lt;a href=&#34;tibble.tidyverse.org&#34;&gt;tibble&lt;/a&gt; package provides a set of functions to deal
with rownames. Remember, &lt;code&gt;tibble&lt;/code&gt; does not have &lt;code&gt;rownames&lt;/code&gt; unlike &lt;code&gt;data.frame&lt;/code&gt;.
To check whether a data set has rownames, use &lt;code&gt;has_rownames()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;has_rownames(mtcars)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;remove-rownames&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Remove Rownames&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;remove_rownames(mtcars)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##     mpg cyl  disp  hp drat    wt  qsec vs am gear carb
## 1  21.0   6 160.0 110 3.90 2.620 16.46  0  1    4    4
## 2  21.0   6 160.0 110 3.90 2.875 17.02  0  1    4    4
## 3  22.8   4 108.0  93 3.85 2.320 18.61  1  1    4    1
## 4  21.4   6 258.0 110 3.08 3.215 19.44  1  0    3    1
## 5  18.7   8 360.0 175 3.15 3.440 17.02  0  0    3    2
## 6  18.1   6 225.0 105 2.76 3.460 20.22  1  0    3    1
## 7  14.3   8 360.0 245 3.21 3.570 15.84  0  0    3    4
## 8  24.4   4 146.7  62 3.69 3.190 20.00  1  0    4    2
## 9  22.8   4 140.8  95 3.92 3.150 22.90  1  0    4    2
## 10 19.2   6 167.6 123 3.92 3.440 18.30  1  0    4    4
## 11 17.8   6 167.6 123 3.92 3.440 18.90  1  0    4    4
## 12 16.4   8 275.8 180 3.07 4.070 17.40  0  0    3    3
## 13 17.3   8 275.8 180 3.07 3.730 17.60  0  0    3    3
## 14 15.2   8 275.8 180 3.07 3.780 18.00  0  0    3    3
## 15 10.4   8 472.0 205 2.93 5.250 17.98  0  0    3    4
## 16 10.4   8 460.0 215 3.00 5.424 17.82  0  0    3    4
## 17 14.7   8 440.0 230 3.23 5.345 17.42  0  0    3    4
## 18 32.4   4  78.7  66 4.08 2.200 19.47  1  1    4    1
## 19 30.4   4  75.7  52 4.93 1.615 18.52  1  1    4    2
## 20 33.9   4  71.1  65 4.22 1.835 19.90  1  1    4    1
## 21 21.5   4 120.1  97 3.70 2.465 20.01  1  0    3    1
## 22 15.5   8 318.0 150 2.76 3.520 16.87  0  0    3    2
## 23 15.2   8 304.0 150 3.15 3.435 17.30  0  0    3    2
## 24 13.3   8 350.0 245 3.73 3.840 15.41  0  0    3    4
## 25 19.2   8 400.0 175 3.08 3.845 17.05  0  0    3    2
## 26 27.3   4  79.0  66 4.08 1.935 18.90  1  1    4    1
## 27 26.0   4 120.3  91 4.43 2.140 16.70  0  1    5    2
## 28 30.4   4  95.1 113 3.77 1.513 16.90  1  1    5    2
## 29 15.8   8 351.0 264 4.22 3.170 14.50  0  1    5    4
## 30 19.7   6 145.0 175 3.62 2.770 15.50  0  1    5    6
## 31 15.0   8 301.0 335 3.54 3.570 14.60  0  1    5    8
## 32 21.4   4 121.0 109 4.11 2.780 18.60  1  1    4    2&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;rownames-to-column&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Rownames to Column&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;head(rownames_to_column(mtcars))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##             rowname  mpg cyl disp  hp drat    wt  qsec vs am gear carb
## 1         Mazda RX4 21.0   6  160 110 3.90 2.620 16.46  0  1    4    4
## 2     Mazda RX4 Wag 21.0   6  160 110 3.90 2.875 17.02  0  1    4    4
## 3        Datsun 710 22.8   4  108  93 3.85 2.320 18.61  1  1    4    1
## 4    Hornet 4 Drive 21.4   6  258 110 3.08 3.215 19.44  1  0    3    1
## 5 Hornet Sportabout 18.7   8  360 175 3.15 3.440 17.02  0  0    3    2
## 6           Valiant 18.1   6  225 105 2.76 3.460 20.22  1  0    3    1&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;column-to-rownames&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Column to Rownames&lt;/h4&gt;
&lt;p&gt;To convert the first column in the data set to rownames, use &lt;code&gt;column_to_rownames()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mtcars_tbl &amp;lt;- rownames_to_column(mtcars)
column_to_rownames(mtcars_tbl)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                      mpg cyl  disp  hp drat    wt  qsec vs am gear carb
## Mazda RX4           21.0   6 160.0 110 3.90 2.620 16.46  0  1    4    4
## Mazda RX4 Wag       21.0   6 160.0 110 3.90 2.875 17.02  0  1    4    4
## Datsun 710          22.8   4 108.0  93 3.85 2.320 18.61  1  1    4    1
## Hornet 4 Drive      21.4   6 258.0 110 3.08 3.215 19.44  1  0    3    1
## Hornet Sportabout   18.7   8 360.0 175 3.15 3.440 17.02  0  0    3    2
## Valiant             18.1   6 225.0 105 2.76 3.460 20.22  1  0    3    1
## Duster 360          14.3   8 360.0 245 3.21 3.570 15.84  0  0    3    4
## Merc 240D           24.4   4 146.7  62 3.69 3.190 20.00  1  0    4    2
## Merc 230            22.8   4 140.8  95 3.92 3.150 22.90  1  0    4    2
## Merc 280            19.2   6 167.6 123 3.92 3.440 18.30  1  0    4    4
## Merc 280C           17.8   6 167.6 123 3.92 3.440 18.90  1  0    4    4
## Merc 450SE          16.4   8 275.8 180 3.07 4.070 17.40  0  0    3    3
## Merc 450SL          17.3   8 275.8 180 3.07 3.730 17.60  0  0    3    3
## Merc 450SLC         15.2   8 275.8 180 3.07 3.780 18.00  0  0    3    3
## Cadillac Fleetwood  10.4   8 472.0 205 2.93 5.250 17.98  0  0    3    4
## Lincoln Continental 10.4   8 460.0 215 3.00 5.424 17.82  0  0    3    4
## Chrysler Imperial   14.7   8 440.0 230 3.23 5.345 17.42  0  0    3    4
## Fiat 128            32.4   4  78.7  66 4.08 2.200 19.47  1  1    4    1
## Honda Civic         30.4   4  75.7  52 4.93 1.615 18.52  1  1    4    2
## Toyota Corolla      33.9   4  71.1  65 4.22 1.835 19.90  1  1    4    1
## Toyota Corona       21.5   4 120.1  97 3.70 2.465 20.01  1  0    3    1
## Dodge Challenger    15.5   8 318.0 150 2.76 3.520 16.87  0  0    3    2
## AMC Javelin         15.2   8 304.0 150 3.15 3.435 17.30  0  0    3    2
## Camaro Z28          13.3   8 350.0 245 3.73 3.840 15.41  0  0    3    4
## Pontiac Firebird    19.2   8 400.0 175 3.08 3.845 17.05  0  0    3    2
## Fiat X1-9           27.3   4  79.0  66 4.08 1.935 18.90  1  1    4    1
## Porsche 914-2       26.0   4 120.3  91 4.43 2.140 16.70  0  1    5    2
## Lotus Europa        30.4   4  95.1 113 3.77 1.513 16.90  1  1    5    2
## Ford Pantera L      15.8   8 351.0 264 4.22 3.170 14.50  0  1    5    4
## Ferrari Dino        19.7   6 145.0 175 3.62 2.770 15.50  0  1    5    6
## Maserati Bora       15.0   8 301.0 335 3.54 3.570 14.60  0  1    5    8
## Volvo 142E          21.4   4 121.0 109 4.11 2.780 18.60  1  1    4    2&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;glimpse&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Glimpse&lt;/h2&gt;
&lt;p&gt;Use &lt;code&gt;glimpse()&lt;/code&gt; to get an overview of the data.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;glimpse(mtcars)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Rows: 32
## Columns: 11
## $ mpg  &amp;lt;dbl&amp;gt; 21.0, 21.0, 22.8, 21.4, 18.7, 18.1, 14.3, 24.4, 22.8, 19.2, 17...
## $ cyl  &amp;lt;dbl&amp;gt; 6, 6, 4, 6, 8, 6, 8, 4, 4, 6, 6, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4,...
## $ disp &amp;lt;dbl&amp;gt; 160.0, 160.0, 108.0, 258.0, 360.0, 225.0, 360.0, 146.7, 140.8,...
## $ hp   &amp;lt;dbl&amp;gt; 110, 110, 93, 110, 175, 105, 245, 62, 95, 123, 123, 180, 180, ...
## $ drat &amp;lt;dbl&amp;gt; 3.90, 3.90, 3.85, 3.08, 3.15, 2.76, 3.21, 3.69, 3.92, 3.92, 3....
## $ wt   &amp;lt;dbl&amp;gt; 2.620, 2.875, 2.320, 3.215, 3.440, 3.460, 3.570, 3.190, 3.150,...
## $ qsec &amp;lt;dbl&amp;gt; 16.46, 17.02, 18.61, 19.44, 17.02, 20.22, 15.84, 20.00, 22.90,...
## $ vs   &amp;lt;dbl&amp;gt; 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,...
## $ am   &amp;lt;dbl&amp;gt; 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0,...
## $ gear &amp;lt;dbl&amp;gt; 4, 4, 4, 3, 3, 3, 3, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 4, 4, 4, 3,...
## $ carb &amp;lt;dbl&amp;gt; 4, 4, 1, 1, 2, 1, 4, 2, 2, 4, 4, 3, 3, 3, 4, 4, 4, 1, 2, 1, 1,...&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;check-column&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Check Column&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;has_name()&lt;/code&gt; can be used to check if a tibble has a specific column.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;has_name(mtcars, &amp;#39;cyl&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;has_name(mtcars, &amp;#39;gears&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Summary&lt;/h2&gt;
&lt;div id=&#34;creating-tibbles-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Creating tibbles&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;use &lt;code&gt;tibble()&lt;/code&gt; to create tibbles&lt;/li&gt;
&lt;li&gt;use &lt;code&gt;as_tibble()&lt;/code&gt; to coerce other objects to tibble&lt;/li&gt;
&lt;li&gt;use &lt;code&gt;enframe()&lt;/code&gt; to coerce vector to tibble&lt;/li&gt;
&lt;li&gt;use &lt;code&gt;tribble()&lt;/code&gt; to create tibble using data entry&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;modifying-tibbles&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Modifying tibbles&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;use &lt;code&gt;add_row()&lt;/code&gt; to add a new row&lt;/li&gt;
&lt;li&gt;use &lt;code&gt;add_column()&lt;/code&gt; to add a new column&lt;/li&gt;
&lt;li&gt;use &lt;code&gt;remove_rownames()&lt;/code&gt; to remove rownames from data&lt;/li&gt;
&lt;li&gt;use &lt;code&gt;rownames_to_colum()&lt;/code&gt; to coerce rowname to first column&lt;/li&gt;
&lt;li&gt;use &lt;code&gt;column_to_rownames()&lt;/code&gt; to coerce first column to rownames&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;testing-tibbles&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Testing tibbles&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;use &lt;code&gt;is_tibble()&lt;/code&gt; to test if an object is a tibble&lt;/li&gt;
&lt;li&gt;use &lt;code&gt;has_rownames()&lt;/code&gt; to check whether a data set has rownames&lt;/li&gt;
&lt;li&gt;use &lt;code&gt;has_name()&lt;/code&gt; to check if tibble has a specific column&lt;/li&gt;
&lt;li&gt;use &lt;code&gt;glimpse()&lt;/code&gt; to get an overview of data&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;references&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://tibble.tidyverse.org/&#34; class=&#34;uri&#34;&gt;https://tibble.tidyverse.org/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://r4ds.had.co.nz/tibbles.html&#34; class=&#34;uri&#34;&gt;http://r4ds.had.co.nz/tibbles.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Data Wrangling with dplyr - Part 3</title>
      <link>https://blog.rsquaredacademy.com/data-wrangling-with-dplyr-part-3/</link>
      <pubDate>Sun, 16 Sep 2018 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/data-wrangling-with-dplyr-part-3/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In the previous &lt;a href=&#34;https://blog.aravindhebbali.com/2017/12/25/data-wrangling-with-dplyr-part-2/&#34;&gt;post&lt;/a&gt;,
we learnt to combine tables using dplyr. In this post, we will explore a set of
helper functions in order to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;extract unique rows&lt;/li&gt;
&lt;li&gt;rename columns&lt;/li&gt;
&lt;li&gt;sample data&lt;/li&gt;
&lt;li&gt;extract columns&lt;/li&gt;
&lt;li&gt;slice rows&lt;/li&gt;
&lt;li&gt;arrange rows&lt;/li&gt;
&lt;li&gt;compare tables&lt;/li&gt;
&lt;li&gt;extract/mutate data using predicate functions&lt;/li&gt;
&lt;li&gt;count observations for different levels of a variable&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Libraries, Code &amp;amp; Data&lt;/h2&gt;
&lt;p&gt;We will use the following packages:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://dplyr.tidyverse.org/index.html&#34;&gt;dplyr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://readr.tidyverse.org/index.html&#34;&gt;readr&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The data sets can be downloaded from &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt;
and the codes from &lt;a href=&#34;https://gist.github.com/aravindhebbali/55c4f40476028c09949b73af97bb1619&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(dplyr)
library(readr)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;case-study&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Case Study&lt;/h2&gt;
&lt;p&gt;Let us look at a case study (e-commerce data) and see how we can use dplyr
helper functions to answer questions we have about and to modify/transform the
underlying data set.&lt;/p&gt;
&lt;div id=&#34;data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom &amp;lt;- 
  read_csv(&amp;#39;https://raw.githubusercontent.com/rsquaredacademy/datasets/master/web.csv&amp;#39;,
    col_types = cols_only(device = col_factor(levels = c(&amp;quot;laptop&amp;quot;, &amp;quot;tablet&amp;quot;, &amp;quot;mobile&amp;quot;)),
      referrer = col_factor(levels = c(&amp;quot;bing&amp;quot;, &amp;quot;direct&amp;quot;, &amp;quot;social&amp;quot;, &amp;quot;yahoo&amp;quot;, &amp;quot;google&amp;quot;)),
      purchase = col_logical(), bouncers = col_logical(), duration = col_double(),
      n_visit = col_double(), n_pages = col_double()
    )
  )

ecom&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1,000 x 7
##    referrer device bouncers n_visit n_pages duration purchase
##    &amp;lt;fct&amp;gt;    &amp;lt;fct&amp;gt;  &amp;lt;lgl&amp;gt;      &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;lgl&amp;gt;   
##  1 google   laptop TRUE          10       1      693 FALSE   
##  2 yahoo    tablet TRUE           9       1      459 FALSE   
##  3 direct   laptop TRUE           0       1      996 FALSE   
##  4 bing     tablet FALSE          3      18      468 TRUE    
##  5 yahoo    mobile TRUE           9       1      955 FALSE   
##  6 yahoo    laptop FALSE          5       5      135 FALSE   
##  7 yahoo    mobile TRUE          10       1       75 FALSE   
##  8 direct   mobile TRUE          10       1      908 FALSE   
##  9 bing     mobile FALSE          3      19      209 FALSE   
## 10 google   mobile TRUE           6       1      208 FALSE   
## # ... with 990 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;data-dictionary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data Dictionary&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;referrer: referrer website/search engine&lt;/li&gt;
&lt;li&gt;device: device used to visit the website&lt;/li&gt;
&lt;li&gt;bouncers: whether a visit bounced (exited from landing page)&lt;/li&gt;
&lt;li&gt;duration: time spent on the website (in seconds)&lt;/li&gt;
&lt;li&gt;purchase: whether visitor purchased&lt;/li&gt;
&lt;li&gt;n_visit: number of visits&lt;/li&gt;
&lt;li&gt;n_pages: number of pages visited/browsed&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;data-sanitization&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data Sanitization&lt;/h2&gt;
&lt;p&gt;Let us ensure that the data is sanitized by checking the sources of traffic
and devices used to visit the site. We will use &lt;code&gt;distinct&lt;/code&gt; to examine the
values in the &lt;code&gt;referrer&lt;/code&gt; column&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/distinct_1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;distinct(ecom, referrer)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 5 x 1
##   referrer
##   &amp;lt;fct&amp;gt;   
## 1 google  
## 2 yahoo   
## 3 direct  
## 4 bing    
## 5 social&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and the &lt;code&gt;device&lt;/code&gt; column as well.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;distinct(ecom, device)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 x 1
##   device
##   &amp;lt;fct&amp;gt; 
## 1 laptop
## 2 tablet
## 3 mobile&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;rename-columns&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Rename Columns&lt;/h2&gt;
&lt;p&gt;Columns can be renamed using &lt;code&gt;rename()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/rename_1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rename(ecom, time_on_site = duration)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1,000 x 7
##    referrer device bouncers n_visit n_pages time_on_site purchase
##    &amp;lt;fct&amp;gt;    &amp;lt;fct&amp;gt;  &amp;lt;lgl&amp;gt;      &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;        &amp;lt;dbl&amp;gt; &amp;lt;lgl&amp;gt;   
##  1 google   laptop TRUE          10       1          693 FALSE   
##  2 yahoo    tablet TRUE           9       1          459 FALSE   
##  3 direct   laptop TRUE           0       1          996 FALSE   
##  4 bing     tablet FALSE          3      18          468 TRUE    
##  5 yahoo    mobile TRUE           9       1          955 FALSE   
##  6 yahoo    laptop FALSE          5       5          135 FALSE   
##  7 yahoo    mobile TRUE          10       1           75 FALSE   
##  8 direct   mobile TRUE          10       1          908 FALSE   
##  9 bing     mobile FALSE          3      19          209 FALSE   
## 10 google   mobile TRUE           6       1          208 FALSE   
## # ... with 990 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;data-tabulation&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data Tabulation&lt;/h2&gt;
&lt;p&gt;Let us now look at the proportion or share of visits driven by different sources
of traffic.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/tally_count.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom %&amp;gt;%
  group_by(referrer) %&amp;gt;%
  tally()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 5 x 2
##   referrer     n
## * &amp;lt;fct&amp;gt;    &amp;lt;int&amp;gt;
## 1 bing       194
## 2 direct     191
## 3 social     200
## 4 yahoo      207
## 5 google     208&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We would also like to know the number of bouncers driven by the different
sources of traffic.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom %&amp;gt;%
  group_by(referrer, bouncers) %&amp;gt;%
  tally()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 10 x 3
## # Groups:   referrer [5]
##    referrer bouncers     n
##    &amp;lt;fct&amp;gt;    &amp;lt;lgl&amp;gt;    &amp;lt;int&amp;gt;
##  1 bing     FALSE      104
##  2 bing     TRUE        90
##  3 direct   FALSE       98
##  4 direct   TRUE        93
##  5 social   FALSE       93
##  6 social   TRUE       107
##  7 yahoo    FALSE      110
##  8 yahoo    TRUE        97
##  9 google   FALSE      101
## 10 google   TRUE       107&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us look at how many conversions happen across different devices.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom %&amp;gt;%
  group_by(device, purchase) %&amp;gt;%
  tally() %&amp;gt;%
  filter(purchase)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 x 3
## # Groups:   device [3]
##   device purchase     n
##   &amp;lt;fct&amp;gt;  &amp;lt;lgl&amp;gt;    &amp;lt;int&amp;gt;
## 1 laptop TRUE        31
## 2 tablet TRUE        36
## 3 mobile TRUE        36&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Another way to extract the above information is by using &lt;code&gt;count&lt;/code&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom %&amp;gt;%
  count(referrer, purchase) %&amp;gt;%
  filter(purchase)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 5 x 3
##   referrer purchase     n
##   &amp;lt;fct&amp;gt;    &amp;lt;lgl&amp;gt;    &amp;lt;int&amp;gt;
## 1 bing     TRUE        17
## 2 direct   TRUE        25
## 3 social   TRUE        20
## 4 yahoo    TRUE        22
## 5 google   TRUE        19&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;sampling-data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Sampling Data&lt;/h2&gt;
&lt;p&gt;dplyr offers sampling functions which allow us to specify either the
number or percentage of observations. &lt;code&gt;sample_n()&lt;/code&gt; allows sampling a specific
number of observations.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/sample_frac_n.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;sample_n(ecom, 700)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 700 x 7
##    referrer device bouncers n_visit n_pages duration purchase
##    &amp;lt;fct&amp;gt;    &amp;lt;fct&amp;gt;  &amp;lt;lgl&amp;gt;      &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;lgl&amp;gt;   
##  1 yahoo    laptop FALSE          2       9      162 FALSE   
##  2 yahoo    tablet FALSE          2      14      364 TRUE    
##  3 social   laptop TRUE           1       1      111 FALSE   
##  4 direct   laptop TRUE           4       1      896 FALSE   
##  5 yahoo    mobile FALSE          5       8       80 FALSE   
##  6 social   laptop TRUE           0       1      720 FALSE   
##  7 bing     mobile TRUE           5       1      190 FALSE   
##  8 direct   mobile TRUE           2       1      501 FALSE   
##  9 yahoo    tablet TRUE           1       1      605 FALSE   
## 10 bing     laptop TRUE           1       1      169 FALSE   
## # ... with 690 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can combine the sampling functions with other dplyr functions as shown below
where we sample observation after grouping them according to the source of
traffic.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom %&amp;gt;%
  group_by(referrer) %&amp;gt;%
  sample_n(100)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 500 x 7
## # Groups:   referrer [5]
##    referrer device bouncers n_visit n_pages duration purchase
##    &amp;lt;fct&amp;gt;    &amp;lt;fct&amp;gt;  &amp;lt;lgl&amp;gt;      &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;lgl&amp;gt;   
##  1 bing     mobile FALSE          3       8      120 FALSE   
##  2 bing     laptop FALSE          9      13      299 FALSE   
##  3 bing     tablet FALSE          2      17      510 FALSE   
##  4 bing     laptop TRUE           9       1      709 FALSE   
##  5 bing     tablet TRUE           0       1      845 FALSE   
##  6 bing     tablet TRUE           1       1      721 FALSE   
##  7 bing     tablet TRUE           0       1      425 FALSE   
##  8 bing     mobile FALSE          0       7      196 FALSE   
##  9 bing     tablet TRUE           4       1      493 FALSE   
## 10 bing     mobile TRUE           6       1      604 FALSE   
## # ... with 490 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;sample_frac()&lt;/code&gt; allows a specific percentage of observations.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;sample_frac(ecom, size = 0.7)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 700 x 7
##    referrer device bouncers n_visit n_pages duration purchase
##    &amp;lt;fct&amp;gt;    &amp;lt;fct&amp;gt;  &amp;lt;lgl&amp;gt;      &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;lgl&amp;gt;   
##  1 google   mobile TRUE           0       1      132 FALSE   
##  2 yahoo    tablet TRUE           7       1      889 FALSE   
##  3 bing     mobile FALSE          7       1       22 FALSE   
##  4 google   laptop TRUE           5       1      376 FALSE   
##  5 social   tablet FALSE         10      11      330 TRUE    
##  6 social   mobile FALSE          7       8      216 FALSE   
##  7 bing     mobile FALSE          1      12      168 FALSE   
##  8 bing     tablet TRUE           7       1      489 FALSE   
##  9 social   laptop TRUE           0       1      581 FALSE   
## 10 direct   laptop FALSE          6       6       96 FALSE   
## # ... with 690 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;data-extraction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data Extraction&lt;/h2&gt;
&lt;p&gt;In the first &lt;a href=&#34;https://blog.aravindhebbali.com/2017/12/25/data-wrangling-with-dplyr-part-1/&#34;&gt;post&lt;/a&gt;,
we had observed that dplyr verbs always returned a tibble. What if you want to
extract a specific column or a bunch of rows but not as a tibble?&lt;/p&gt;
&lt;p&gt;Use &lt;code&gt;pull&lt;/code&gt; to extract columns either by name or position. It will return a
vector. In the below example, we extract the &lt;code&gt;device&lt;/code&gt; column as a vector. I am
using &lt;code&gt;head&lt;/code&gt; in addition to limit the output printed.&lt;/p&gt;
&lt;div id=&#34;sample-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Sample Data&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom_mini &amp;lt;- sample_n(ecom, size = 10)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/pull_1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;pull(ecom_mini, device)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] laptop mobile mobile laptop tablet laptop mobile laptop tablet tablet
## Levels: laptop tablet mobile&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us extract the first column from &lt;code&gt;ecom&lt;/code&gt; using column position instead of
name.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;pull(ecom_mini, 1) &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] bing   google yahoo  direct bing   direct bing   bing   bing   bing  
## Levels: bing direct social yahoo google&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can use &lt;code&gt;-&lt;/code&gt; before the column position to indicate the position in reverse.
The below example extracts data from the last column.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;pull(ecom_mini, -1) &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us now look at extracting rows using &lt;code&gt;slice()&lt;/code&gt;. In the below example, we
extract data starting from the 5th row and upto the 15th row.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/slice_1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;slice(ecom, 5:15)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 11 x 7
##    referrer device bouncers n_visit n_pages duration purchase
##    &amp;lt;fct&amp;gt;    &amp;lt;fct&amp;gt;  &amp;lt;lgl&amp;gt;      &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;lgl&amp;gt;   
##  1 yahoo    mobile TRUE           9       1      955 FALSE   
##  2 yahoo    laptop FALSE          5       5      135 FALSE   
##  3 yahoo    mobile TRUE          10       1       75 FALSE   
##  4 direct   mobile TRUE          10       1      908 FALSE   
##  5 bing     mobile FALSE          3      19      209 FALSE   
##  6 google   mobile TRUE           6       1      208 FALSE   
##  7 direct   laptop TRUE           9       1      738 FALSE   
##  8 direct   tablet FALSE          6      12      132 FALSE   
##  9 direct   mobile FALSE          9      14      406 TRUE    
## 10 yahoo    tablet FALSE          5       8       80 FALSE   
## 11 yahoo    mobile FALSE          7       1       19 FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Use &lt;code&gt;n()&lt;/code&gt; inside &lt;code&gt;slice()&lt;/code&gt; to extract the last row.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;slice(ecom, n())&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1 x 7
##   referrer device bouncers n_visit n_pages duration purchase
##   &amp;lt;fct&amp;gt;    &amp;lt;fct&amp;gt;  &amp;lt;lgl&amp;gt;      &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;lgl&amp;gt;   
## 1 google   mobile TRUE           9       1      269 FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;between&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Between&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;between()&lt;/code&gt; allows us to test if the values in a column lie between two specific
values. In the below example, we check how many visits browsed pages between 5
and 15.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom_sample &amp;lt;- sample_n(ecom, 30)
  
ecom_sample %&amp;gt;%
  pull(n_pages) %&amp;gt;%
  between(5, 15) &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] FALSE FALSE FALSE  TRUE  TRUE FALSE FALSE FALSE FALSE  TRUE  TRUE FALSE
## [13]  TRUE  TRUE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE
## [25] FALSE FALSE FALSE FALSE FALSE FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;case-when&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Case When&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;case_when()&lt;/code&gt; is an alternative to &lt;code&gt;if else&lt;/code&gt;. It allows us to lay down the
conditions clearly and makes the code more readable. In the below example, we
create a new column &lt;code&gt;repeat_visit&lt;/code&gt; from &lt;code&gt;n_visit&lt;/code&gt; (the number of previous visits).&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom %&amp;gt;%
  mutate(
    repeat_visit = case_when(
      n_visit &amp;gt; 0 ~ TRUE,
      TRUE ~ FALSE
    )
  ) %&amp;gt;%
  select(n_visit, repeat_visit) &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1,000 x 2
##    n_visit repeat_visit
##      &amp;lt;dbl&amp;gt; &amp;lt;lgl&amp;gt;       
##  1      10 TRUE        
##  2       9 TRUE        
##  3       0 FALSE       
##  4       3 TRUE        
##  5       9 TRUE        
##  6       5 TRUE        
##  7      10 TRUE        
##  8      10 TRUE        
##  9       3 TRUE        
## 10       6 TRUE        
## # ... with 990 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;references&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://dplyr.tidyverse.org/&#34; class=&#34;uri&#34;&gt;https://dplyr.tidyverse.org/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://r4ds.had.co.nz/transform.html&#34; class=&#34;uri&#34;&gt;http://r4ds.had.co.nz/transform.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Data Wrangling with dplyr - Part 2</title>
      <link>https://blog.rsquaredacademy.com/data-wrangling-with-dplyr-part-2/</link>
      <pubDate>Tue, 04 Sep 2018 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/data-wrangling-with-dplyr-part-2/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In the previous post we learnt about dplyr verbs and used them to compute
average order value for an online retail company data. In this post, we will
learn to combine tables using different &lt;code&gt;*_join&lt;/code&gt; functions provided in dplyr.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Libraries, Code &amp;amp; Data&lt;/h2&gt;
&lt;p&gt;We will use the following packages:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://dplyr.tidyverse.org/index.html&#34;&gt;dplyr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://readr.tidyverse.org/index.html&#34;&gt;readr&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The data sets can be downloaded from &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt;
and the codes from &lt;a href=&#34;https://gist.github.com/aravindhebbali/3e31f13a4194a8f1003034aa7d70d5ee&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(dplyr)
library(readr)
options(tibble.width = Inf)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;case-study&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Case Study&lt;/h2&gt;
&lt;p&gt;For our case study, we will use two data sets. The first one, &lt;code&gt;order&lt;/code&gt;, contains
details of orders placed by different customers. The second data set, &lt;code&gt;customer&lt;/code&gt;
contains details of each customer. The below table displays the details stored
in each data set.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/join_data.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Let us import both the data sets using &lt;code&gt;read_csv&lt;/code&gt;.&lt;/p&gt;
&lt;div id=&#34;data-orders&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data: Orders&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;order &amp;lt;- read_delim(&amp;#39;https://raw.githubusercontent.com/rsquaredacademy/datasets/master/order.csv&amp;#39;, delim = &amp;#39;;&amp;#39;)
order&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 300 x 3
##       id order_date amount
##    &amp;lt;dbl&amp;gt; &amp;lt;chr&amp;gt;       &amp;lt;dbl&amp;gt;
##  1   368 7/2/2016     365.
##  2   286 11/2/2016   2064.
##  3    28 2/22/2017    432.
##  4   309 3/5/2017     480.
##  5     2 12/28/2016   235.
##  6    31 12/30/2016  2745.
##  7   179 12/21/2016  2358.
##  8   484 11/24/2016  1031.
##  9   115 9/9/2016    1218.
## 10   340 5/6/2017    1184.
## # ... with 290 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;data-customers&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data: Customers&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;customer &amp;lt;- read_delim(&amp;#39;https://raw.githubusercontent.com/rsquaredacademy/datasets/master/customer.csv&amp;#39;, delim = &amp;#39;;&amp;#39;)
customer&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 91 x 3
##       id first_name city      
##    &amp;lt;dbl&amp;gt; &amp;lt;chr&amp;gt;      &amp;lt;chr&amp;gt;     
##  1     1 Elbertine  California
##  2     2 Marcella   Colorado  
##  3     3 Daria      Florida   
##  4     4 Sherilyn   Distric...
##  5     5 Ketty      Texas     
##  6     6 Jethro     California
##  7     7 Jeremiah   California
##  8     8 Constancia Texas     
##  9     9 Muire      Idaho     
## 10    10 Abigail    Texas     
## # ... with 81 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We will explore the following in the case study:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;details of customers who have placed orders and their order details&lt;/li&gt;
&lt;li&gt;details of customers and their orders irrespective of whether a customer has
placed orders or not&lt;/li&gt;
&lt;li&gt;customer details for each order&lt;/li&gt;
&lt;li&gt;details of customers who have placed orders&lt;/li&gt;
&lt;li&gt;details of customers who have not placed orders&lt;/li&gt;
&lt;li&gt;details of all customers and all orders&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;example-data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Example Data&lt;/h2&gt;
&lt;p&gt;We will use another data set to illustrate how the different joins work. You can
view the example data sets below.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/join.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;inner-join&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Inner Join&lt;/h2&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Inner join return all rows from &lt;code&gt;Age&lt;/code&gt; where there are matching values in
&lt;code&gt;Height&lt;/code&gt;, and all columns from &lt;code&gt;Age&lt;/code&gt; and &lt;code&gt;Height&lt;/code&gt;. If there are multiple matches
between &lt;code&gt;Age&lt;/code&gt; and &lt;code&gt;Height&lt;/code&gt;, all combination of the matches are returned.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/draw_inner.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;case-study-details-of-customers-who-have-placed-orders-and-their-order-details&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Case Study: Details of customers who have placed orders and their order details&lt;/h4&gt;
&lt;p&gt;To get data for all those customers who have placed orders in the past let us
join the &lt;code&gt;order&lt;/code&gt; data with the &lt;code&gt;customer&lt;/code&gt; data using &lt;code&gt;inner_join&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;inner_join(customer, order, by = &amp;quot;id&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 55 x 5
##       id first_name city       order_date amount
##    &amp;lt;dbl&amp;gt; &amp;lt;chr&amp;gt;      &amp;lt;chr&amp;gt;      &amp;lt;chr&amp;gt;       &amp;lt;dbl&amp;gt;
##  1     2 Marcella   Colorado   12/28/2016   235.
##  2     2 Marcella   Colorado   8/31/2016   1150.
##  3     5 Ketty      Texas      1/17/2017    346.
##  4     6 Jethro     California 1/27/2017   2317.
##  5     7 Jeremiah   California 6/21/2016    136.
##  6     7 Jeremiah   California 2/13/2017   1407.
##  7     7 Jeremiah   California 7/8/2016    1914.
##  8     8 Constancia Texas      11/5/2016   2461.
##  9     8 Constancia Texas      5/19/2017   2714.
## 10     9 Muire      Idaho      12/28/2016   187.
## # ... with 45 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;left-join&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Left Join&lt;/h2&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Left join return all rows from &lt;code&gt;Age&lt;/code&gt;, and all columns from &lt;code&gt;Age&lt;/code&gt; and &lt;code&gt;Height&lt;/code&gt;.
Rows in &lt;code&gt;Age&lt;/code&gt; with no match in &lt;code&gt;Height&lt;/code&gt; will have NA values in the new columns.
If there are multiple matches between &lt;code&gt;Age&lt;/code&gt; and &lt;code&gt;Height&lt;/code&gt;, all combinations of
the matches are returned.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/draw_left.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;case-study-details-of-customers-and-their-orders-irrespective-of-whether-a-customer-has&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Case Study: Details of customers and their orders irrespective of whether a customer has&lt;/h4&gt;
&lt;p&gt;placed orders or not.&lt;/p&gt;
&lt;p&gt;To get data for all those customers and their orders irrespective of whether a
customer has placed orders or not let us join the &lt;code&gt;order&lt;/code&gt; data with the
&lt;code&gt;customer&lt;/code&gt; data using &lt;code&gt;left_join&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;left_join(customer, order, by = &amp;quot;id&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 104 x 5
##       id first_name city       order_date amount
##    &amp;lt;dbl&amp;gt; &amp;lt;chr&amp;gt;      &amp;lt;chr&amp;gt;      &amp;lt;chr&amp;gt;       &amp;lt;dbl&amp;gt;
##  1     1 Elbertine  California &amp;lt;NA&amp;gt;          NA 
##  2     2 Marcella   Colorado   12/28/2016   235.
##  3     2 Marcella   Colorado   8/31/2016   1150.
##  4     3 Daria      Florida    &amp;lt;NA&amp;gt;          NA 
##  5     4 Sherilyn   Distric... &amp;lt;NA&amp;gt;          NA 
##  6     5 Ketty      Texas      1/17/2017    346.
##  7     6 Jethro     California 1/27/2017   2317.
##  8     7 Jeremiah   California 6/21/2016    136.
##  9     7 Jeremiah   California 2/13/2017   1407.
## 10     7 Jeremiah   California 7/8/2016    1914.
## # ... with 94 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;right-join&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Right Join&lt;/h2&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Right join return all rows from &lt;code&gt;Height&lt;/code&gt;, and all columns from &lt;code&gt;Age&lt;/code&gt; and
&lt;code&gt;Height&lt;/code&gt;. Rows in &lt;code&gt;Height&lt;/code&gt; with no match in &lt;code&gt;Age&lt;/code&gt; will have NA values in the
new columns. If there are multiple matches between &lt;code&gt;Age&lt;/code&gt; and &lt;code&gt;Height&lt;/code&gt;, all
combinations of the matches are returned.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/draw_right.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;case-study-customer-details-for-each-order&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Case Study: Customer details for each order&lt;/h4&gt;
&lt;p&gt;To get customer data for all orders, let us join the &lt;code&gt;order&lt;/code&gt; data with the
&lt;code&gt;customer&lt;/code&gt; data using &lt;code&gt;right_join&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;right_join(customer, order, by = &amp;quot;id&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 300 x 5
##       id first_name city       order_date amount
##    &amp;lt;dbl&amp;gt; &amp;lt;chr&amp;gt;      &amp;lt;chr&amp;gt;      &amp;lt;chr&amp;gt;       &amp;lt;dbl&amp;gt;
##  1     2 Marcella   Colorado   12/28/2016   235.
##  2     2 Marcella   Colorado   8/31/2016   1150.
##  3     5 Ketty      Texas      1/17/2017    346.
##  4     6 Jethro     California 1/27/2017   2317.
##  5     7 Jeremiah   California 6/21/2016    136.
##  6     7 Jeremiah   California 2/13/2017   1407.
##  7     7 Jeremiah   California 7/8/2016    1914.
##  8     8 Constancia Texas      11/5/2016   2461.
##  9     8 Constancia Texas      5/19/2017   2714.
## 10     9 Muire      Idaho      12/28/2016   187.
## # ... with 290 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;semi-join&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Semi Join&lt;/h2&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Semi join return all rows from &lt;code&gt;Age&lt;/code&gt; where there are matching values in &lt;code&gt;Height&lt;/code&gt;,
keeping just columns from &lt;code&gt;Age&lt;/code&gt;. A semi join differs from an inner join because
an inner join will return one row of &lt;code&gt;Age&lt;/code&gt; for each matching row of &lt;code&gt;Height&lt;/code&gt;,
where a semi join will never duplicate rows of &lt;code&gt;Age&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/draw_semi.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;case-study-details-of-customers-who-have-placed-orders&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Case Study: Details of customers who have placed orders&lt;/h4&gt;
&lt;p&gt;To get customer data for all orders where customer data exists, let us join the &lt;code&gt;order&lt;/code&gt; data with the
&lt;code&gt;customer&lt;/code&gt; data using &lt;code&gt;semi_join&lt;/code&gt;. You can observe that data is returned only for those
cases where customer data is present.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;semi_join(customer, order, by = &amp;quot;id&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 42 x 3
##       id first_name city      
##    &amp;lt;dbl&amp;gt; &amp;lt;chr&amp;gt;      &amp;lt;chr&amp;gt;     
##  1     2 Marcella   Colorado  
##  2     5 Ketty      Texas     
##  3     6 Jethro     California
##  4     7 Jeremiah   California
##  5     8 Constancia Texas     
##  6     9 Muire      Idaho     
##  7    15 Valentijn  California
##  8    16 Monique    Missouri  
##  9    20 Colette    Texas     
## 10    28 Avrit      Texas     
## # ... with 32 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;anti-join&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Anti Join&lt;/h2&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Anti join return all rows from &lt;code&gt;Age&lt;/code&gt; where there are not matching values in
&lt;code&gt;Height&lt;/code&gt;, keeping just columns from &lt;code&gt;Age&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/draw_anti.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;case-study-details-of-customers-who-have-not-placed-orders&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Case Study: Details of customers who have not placed orders&lt;/h4&gt;
&lt;p&gt;To get details of customers who have not placed orders, let us join the &lt;code&gt;order&lt;/code&gt;
data with the &lt;code&gt;customer&lt;/code&gt; data using &lt;code&gt;anti_join&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;anti_join(customer, order, by = &amp;quot;id&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 49 x 3
##       id first_name city      
##    &amp;lt;dbl&amp;gt; &amp;lt;chr&amp;gt;      &amp;lt;chr&amp;gt;     
##  1     1 Elbertine  California
##  2     3 Daria      Florida   
##  3     4 Sherilyn   Distric...
##  4    10 Abigail    Texas     
##  5    11 Wynne      Georgia   
##  6    12 Pietra     Minnesota 
##  7    13 Bram       Iowa      
##  8    14 Rees       New York  
##  9    17 Orazio     Louisiana 
## 10    18 Mason      Texas     
## # ... with 39 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;full-join&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Full Join&lt;/h2&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Full join return all rows and all columns from both &lt;code&gt;Age&lt;/code&gt; and &lt;code&gt;Height&lt;/code&gt;. Where
there are not matching values, returns NA for the one missing.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/draw_full.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;div id=&#34;case-study-details-of-all-customers-and-all-orders&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Case Study: Details of all customers and all orders&lt;/h4&gt;
&lt;p&gt;To get details of all customers and all orders, let us join the &lt;code&gt;order&lt;/code&gt;
data with the &lt;code&gt;customer&lt;/code&gt; data using &lt;code&gt;full_join&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;full_join(customer, order, by = &amp;quot;id&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 349 x 5
##       id first_name city       order_date amount
##    &amp;lt;dbl&amp;gt; &amp;lt;chr&amp;gt;      &amp;lt;chr&amp;gt;      &amp;lt;chr&amp;gt;       &amp;lt;dbl&amp;gt;
##  1     1 Elbertine  California &amp;lt;NA&amp;gt;          NA 
##  2     2 Marcella   Colorado   12/28/2016   235.
##  3     2 Marcella   Colorado   8/31/2016   1150.
##  4     3 Daria      Florida    &amp;lt;NA&amp;gt;          NA 
##  5     4 Sherilyn   Distric... &amp;lt;NA&amp;gt;          NA 
##  6     5 Ketty      Texas      1/17/2017    346.
##  7     6 Jethro     California 1/27/2017   2317.
##  8     7 Jeremiah   California 6/21/2016    136.
##  9     7 Jeremiah   California 2/13/2017   1407.
## 10     7 Jeremiah   California 7/8/2016    1914.
## # ... with 339 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;references&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://dplyr.tidyverse.org/&#34; class=&#34;uri&#34;&gt;https://dplyr.tidyverse.org/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://r4ds.had.co.nz/relational-data.html&#34; class=&#34;uri&#34;&gt;http://r4ds.had.co.nz/relational-data.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Data Wrangling with dplyr - Part 1</title>
      <link>https://blog.rsquaredacademy.com/data-wrangling-with-dplyr-part-1/</link>
      <pubDate>Thu, 23 Aug 2018 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/data-wrangling-with-dplyr-part-1/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;According to a &lt;a href=&#34;http://visit.crowdflower.com/rs/416-ZBE-142/images/CrowdFlower_DataScienceReport_2016.pdf&#34;&gt;survey&lt;/a&gt; by &lt;a href=&#34;https://www.crowdflower.com/&#34;&gt;CrowdFlower&lt;/a&gt;, data scientists spend most of their
time cleaning and manipulating data rather than mining or modeling them for
insights. As such, it becomes important to have tools that make data
manipulation faster and easier. In today’s post, we introduce you to
&lt;a href=&#34;http://dplyr.tidyverse.org/&#34;&gt;dplyr&lt;/a&gt;, a grammar of data manipulation.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/crowd_flower.png&#34; width=&#34;70%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Libraries, Code &amp;amp; Data&lt;/h2&gt;
&lt;p&gt;We will use the following libraries:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://dplyr.tidyverse.org/index.html&#34;&gt;dplyr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;and &lt;a href=&#34;http://readr.tidyverse.org/index.html&#34;&gt;readr&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The data sets can be downloaded from &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt;
and the codes from &lt;a href=&#34;https://gist.github.com/aravindhebbali/7758b86c2bc13ff1e5d88d9d1c204f8c&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(dplyr)
library(readr)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;dplyr-verbs&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;dplyr Verbs&lt;/h2&gt;
&lt;p&gt;dplyr provides a set of verbs that help us solve the most common data
manipulation challenges while working with tabular data (dataframes, tibbles):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;select&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;filter&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;arrange&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;mutate&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;summarise&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data&lt;/h2&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom &amp;lt;- 
  read_csv(&amp;#39;https://raw.githubusercontent.com/rsquaredacademy/datasets/master/web.csv&amp;#39;,
    col_types = cols_only(device = col_factor(levels = c(&amp;quot;laptop&amp;quot;, &amp;quot;tablet&amp;quot;, &amp;quot;mobile&amp;quot;)),
      referrer = col_factor(levels = c(&amp;quot;bing&amp;quot;, &amp;quot;direct&amp;quot;, &amp;quot;social&amp;quot;, &amp;quot;yahoo&amp;quot;, &amp;quot;google&amp;quot;)),
      purchase = col_logical(), n_pages = col_double(), n_visit = col_double(), 
      duration = col_double(), order_value = col_double(), order_items = col_double()
    )
  )

ecom&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1,000 x 8
##    referrer device n_visit n_pages duration purchase order_items order_value
##    &amp;lt;fct&amp;gt;    &amp;lt;fct&amp;gt;    &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;lgl&amp;gt;          &amp;lt;dbl&amp;gt;       &amp;lt;dbl&amp;gt;
##  1 google   laptop      10       1      693 FALSE              0           0
##  2 yahoo    tablet       9       1      459 FALSE              0           0
##  3 direct   laptop       0       1      996 FALSE              0           0
##  4 bing     tablet       3      18      468 TRUE               6         434
##  5 yahoo    mobile       9       1      955 FALSE              0           0
##  6 yahoo    laptop       5       5      135 FALSE              0           0
##  7 yahoo    mobile      10       1       75 FALSE              0           0
##  8 direct   mobile      10       1      908 FALSE              0           0
##  9 bing     mobile       3      19      209 FALSE              0           0
## 10 google   mobile       6       1      208 FALSE              0           0
## # ... with 990 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;data-dictionary&#34; class=&#34;section level6&#34;&gt;
&lt;h6&gt;Data Dictionary&lt;/h6&gt;
&lt;p&gt;Below is the description of the data set:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;referrer: referrer website/search engine&lt;/li&gt;
&lt;li&gt;device: device used to visit the website&lt;/li&gt;
&lt;li&gt;n_pages: number of pages visited&lt;/li&gt;
&lt;li&gt;duration: time spent on the website (in seconds)&lt;/li&gt;
&lt;li&gt;purchase: whether visitor purchased&lt;/li&gt;
&lt;li&gt;order_value: order value of visitor (in dollars)&lt;/li&gt;
&lt;li&gt;n_visit: number of visits&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;case-study&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Case Study&lt;/h2&gt;
&lt;p&gt;We will use dplyr to answer the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;what is the average order value by device types?&lt;/li&gt;
&lt;li&gt;what is the average number of pages visited by purchasers and non-purchasers?&lt;/li&gt;
&lt;li&gt;what is the average time on site for purchasers vs non-purchasers?&lt;/li&gt;
&lt;li&gt;what is the average number of pages visited by purchasers and non-purchasers
using mobile?&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;average-order-value&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Average Order Value&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/image.jpg&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;aov-by-devices&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;AOV by Devices&lt;/h2&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom %&amp;gt;%
  filter(purchase) %&amp;gt;%
  select(device, order_value) %&amp;gt;%
  group_by(device) %&amp;gt;%
  summarise_all(funs(revenue = sum, orders = n())) %&amp;gt;%
  mutate(
    aov = revenue / orders
  ) %&amp;gt;%
  select(device, aov) %&amp;gt;%
  arrange(aov)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: `funs()` is deprecated as of dplyr 0.8.0.
## Please use a list of either functions or lambdas: 
## 
##   # Simple named list: 
##   list(mean = mean, median = median)
## 
##   # Auto named with `tibble::lst()`: 
##   tibble::lst(mean, median)
## 
##   # Using lambdas
##   list(~ mean(., trim = .2), ~ median(., na.rm = TRUE))
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 x 2
##   device   aov
##   &amp;lt;fct&amp;gt;  &amp;lt;dbl&amp;gt;
## 1 tablet 1426.
## 2 mobile 1431.
## 3 laptop 1824.&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;syntax&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Syntax&lt;/h2&gt;
&lt;p&gt;Before we start exploring the dplyr verbs, let us look at their syntax:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the first argument is always a &lt;code&gt;data.frame&lt;/code&gt; or &lt;code&gt;tibble&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;the subsequent arguments provide the information required for the verbs to
take action&lt;/li&gt;
&lt;li&gt;the name of columns in the data need not be surrounded by quotes&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;filter-rows&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Filter Rows&lt;/h2&gt;
&lt;p&gt;In order to compute the AOV, we must first separate the purchasers from
non-purchasers. We will do this by filtering the data related to purchasers
using the &lt;code&gt;filter()&lt;/code&gt; function. It allows us to filter rows that meet a specific
criteria/condition. The first argument is the name of the data frame and the
rest of the arguments are expressions for filtering the data. Let us look at a
few examples:&lt;/p&gt;
&lt;p&gt;The first example we will look at filters all visits from device &lt;strong&gt;mobile&lt;/strong&gt;. As
we had learnt in the previous section, the first argument is our data set &lt;code&gt;ecom&lt;/code&gt;
and the next argument is the condition for filtering rows.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/filter_1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;filter(ecom, device == &amp;quot;mobile&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 344 x 8
##    referrer device n_visit n_pages duration purchase order_items order_value
##    &amp;lt;fct&amp;gt;    &amp;lt;fct&amp;gt;    &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;lgl&amp;gt;          &amp;lt;dbl&amp;gt;       &amp;lt;dbl&amp;gt;
##  1 yahoo    mobile       9       1      955 FALSE              0           0
##  2 yahoo    mobile      10       1       75 FALSE              0           0
##  3 direct   mobile      10       1      908 FALSE              0           0
##  4 bing     mobile       3      19      209 FALSE              0           0
##  5 google   mobile       6       1      208 FALSE              0           0
##  6 direct   mobile       9      14      406 TRUE               3         651
##  7 yahoo    mobile       7       1       19 FALSE              7        2423
##  8 google   mobile       5       1      147 FALSE              0           0
##  9 bing     mobile       0       7      196 FALSE              4         237
## 10 google   mobile      10       1      338 FALSE              0           0
## # ... with 334 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can specify multiple filtering conditions as well. In the below example, we
specify two filter conditions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;visit from device &lt;strong&gt;mobile&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;resulted in a purchase or conversion&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/filter_2.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;filter(ecom, device == &amp;quot;mobile&amp;quot;, purchase)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 36 x 8
##    referrer device n_visit n_pages duration purchase order_items order_value
##    &amp;lt;fct&amp;gt;    &amp;lt;fct&amp;gt;    &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;lgl&amp;gt;          &amp;lt;dbl&amp;gt;       &amp;lt;dbl&amp;gt;
##  1 direct   mobile       9      14      406 TRUE               3         651
##  2 bing     mobile       4      20      440 TRUE               3         184
##  3 bing     mobile       3      18      288 TRUE               6         764
##  4 social   mobile      10      11      242 TRUE               4         287
##  5 yahoo    mobile       6      14      322 TRUE               3        1443
##  6 google   mobile       1      18      252 TRUE               3        2449
##  7 social   mobile       7      16      352 TRUE              10        2824
##  8 direct   mobile       4      18      324 TRUE               3        1670
##  9 social   mobile       1      20      520 TRUE               5        1021
## 10 yahoo    mobile       0      13      351 TRUE              10         288
## # ... with 26 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here is another example where we specify multiple conditions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;visit from device &lt;strong&gt;tablet&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;made a purchase&lt;/li&gt;
&lt;li&gt;browsed less than 15 pages&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;filter(ecom, device == &amp;quot;tablet&amp;quot;, purchase, n_pages &amp;lt; 15)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 12 x 8
##    referrer device n_visit n_pages duration purchase order_items order_value
##    &amp;lt;fct&amp;gt;    &amp;lt;fct&amp;gt;    &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;lgl&amp;gt;          &amp;lt;dbl&amp;gt;       &amp;lt;dbl&amp;gt;
##  1 social   tablet       7      10      290 TRUE               9        1304
##  2 yahoo    tablet       2      14      364 TRUE               6        1667
##  3 google   tablet       7      12      324 TRUE               2        1358
##  4 direct   tablet       3      12      324 TRUE              10        1257
##  5 yahoo    tablet       0      13      390 TRUE               5        1748
##  6 social   tablet       2      12      300 TRUE               2        2754
##  7 direct   tablet       6      13      338 TRUE               5         683
##  8 yahoo    tablet       2      10      280 TRUE               4         293
##  9 social   tablet      10      10      290 TRUE               9          37
## 10 direct   tablet       3      10      260 TRUE               7         980
## 11 google   tablet       9      14      308 TRUE               7        2436
## 12 social   tablet      10      11      330 TRUE               1        2171&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;case-study-1&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Case Study&lt;/h5&gt;
&lt;p&gt;Let us apply what we have learnt to the case study. We want to filter all
visits that resulted in a purchase.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;filter(ecom, purchase)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 103 x 8
##    referrer device n_visit n_pages duration purchase order_items order_value
##    &amp;lt;fct&amp;gt;    &amp;lt;fct&amp;gt;    &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;lgl&amp;gt;          &amp;lt;dbl&amp;gt;       &amp;lt;dbl&amp;gt;
##  1 bing     tablet       3      18      468 TRUE               6         434
##  2 direct   mobile       9      14      406 TRUE               3         651
##  3 bing     tablet       5      16      368 TRUE               6        1049
##  4 social   tablet       7      10      290 TRUE               9        1304
##  5 direct   tablet       2      19      342 TRUE               5         622
##  6 social   tablet       9      20      420 TRUE               7        1613
##  7 bing     mobile       4      20      440 TRUE               3         184
##  8 yahoo    tablet       2      16      480 TRUE               9         286
##  9 bing     mobile       3      18      288 TRUE               6         764
## 10 yahoo    tablet       2      14      364 TRUE               6        1667
## # ... with 93 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;select-columns&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Select Columns&lt;/h2&gt;
&lt;p&gt;After filtering the data, we need to select relevent variables to compute the
AOV. Remember, we do not need all the columns in the data to compute a required
metric (in our case, AOV). The &lt;code&gt;select()&lt;/code&gt; function allows us to select a subset
of columns. The first argument is the name of the data frame and the subsequent
arguments specify the columns by name or position.&lt;/p&gt;
&lt;p&gt;To select the &lt;code&gt;device&lt;/code&gt; and &lt;code&gt;duration&lt;/code&gt; columns, we specify the data set i.e. 
&lt;code&gt;ecom&lt;/code&gt; followed by the name of the columns.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/select_1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;select(ecom, device, duration)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1,000 x 2
##    device duration
##    &amp;lt;fct&amp;gt;     &amp;lt;dbl&amp;gt;
##  1 laptop      693
##  2 tablet      459
##  3 laptop      996
##  4 tablet      468
##  5 mobile      955
##  6 laptop      135
##  7 mobile       75
##  8 mobile      908
##  9 mobile      209
## 10 mobile      208
## # ... with 990 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can select a set of columns using &lt;code&gt;:&lt;/code&gt;. In the below example, we select all
the columns starting from &lt;code&gt;referrer&lt;/code&gt; up to &lt;code&gt;order_items&lt;/code&gt;. Remember that we can use &lt;code&gt;:&lt;/code&gt; only when
the columns are adjacent to each other in the data set.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/select_2.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;select(ecom, referrer:order_items)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1,000 x 7
##    referrer device n_visit n_pages duration purchase order_items
##    &amp;lt;fct&amp;gt;    &amp;lt;fct&amp;gt;    &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;lgl&amp;gt;          &amp;lt;dbl&amp;gt;
##  1 google   laptop      10       1      693 FALSE              0
##  2 yahoo    tablet       9       1      459 FALSE              0
##  3 direct   laptop       0       1      996 FALSE              0
##  4 bing     tablet       3      18      468 TRUE               6
##  5 yahoo    mobile       9       1      955 FALSE              0
##  6 yahoo    laptop       5       5      135 FALSE              0
##  7 yahoo    mobile      10       1       75 FALSE              0
##  8 direct   mobile      10       1      908 FALSE              0
##  9 bing     mobile       3      19      209 FALSE              0
## 10 google   mobile       6       1      208 FALSE              0
## # ... with 990 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What if you want to select all columns except a few? Typing the name of many
columns can be cumbersome and may also result in spelling errors. We may use &lt;code&gt;:&lt;/code&gt;
only if the columns are adjacent to each other but that may not always be
the case. dplyr allows us to specify columns that need not be
selected using &lt;code&gt;-&lt;/code&gt;. In the below example, we select all columns except &lt;code&gt;n_pages&lt;/code&gt; and
&lt;code&gt;duration&lt;/code&gt;. Notice the &lt;code&gt;-&lt;/code&gt; before both of them.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/select_3.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;select(ecom, -n_pages, -duration)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1,000 x 6
##    referrer device n_visit purchase order_items order_value
##    &amp;lt;fct&amp;gt;    &amp;lt;fct&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;lgl&amp;gt;          &amp;lt;dbl&amp;gt;       &amp;lt;dbl&amp;gt;
##  1 google   laptop      10 FALSE              0           0
##  2 yahoo    tablet       9 FALSE              0           0
##  3 direct   laptop       0 FALSE              0           0
##  4 bing     tablet       3 TRUE               6         434
##  5 yahoo    mobile       9 FALSE              0           0
##  6 yahoo    laptop       5 FALSE              0           0
##  7 yahoo    mobile      10 FALSE              0           0
##  8 direct   mobile      10 FALSE              0           0
##  9 bing     mobile       3 FALSE              0           0
## 10 google   mobile       6 FALSE              0           0
## # ... with 990 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;case-study-2&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Case Study&lt;/h5&gt;
&lt;p&gt;For our case study, we need to select the column &lt;code&gt;order_value&lt;/code&gt;
to calculate the AOV. We also need to select the &lt;code&gt;device&lt;/code&gt; column as we are
computing the AOV for each device type.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;select(ecom, device, order_value)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1,000 x 2
##    device order_value
##    &amp;lt;fct&amp;gt;        &amp;lt;dbl&amp;gt;
##  1 laptop           0
##  2 tablet           0
##  3 laptop           0
##  4 tablet         434
##  5 mobile           0
##  6 laptop           0
##  7 mobile           0
##  8 mobile           0
##  9 mobile           0
## 10 mobile           0
## # ... with 990 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But we want the above data only for purchasers. Let us combine &lt;code&gt;filter()&lt;/code&gt; and
&lt;code&gt;select()&lt;/code&gt; functions to extract &lt;code&gt;order_value&lt;/code&gt; and &lt;code&gt;order_items&lt;/code&gt; only for those
visis that resulted in a purchase.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# filter all visits that resulted in a purchase
ecom1 &amp;lt;- filter(ecom, purchase)

# select the relevant columns
ecom2 &amp;lt;- select(ecom1, device, order_value)

# view data
ecom2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 103 x 2
##    device order_value
##    &amp;lt;fct&amp;gt;        &amp;lt;dbl&amp;gt;
##  1 tablet         434
##  2 mobile         651
##  3 tablet        1049
##  4 tablet        1304
##  5 tablet         622
##  6 tablet        1613
##  7 mobile         184
##  8 tablet         286
##  9 mobile         764
## 10 tablet        1667
## # ... with 93 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;grouping-data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Grouping Data&lt;/h2&gt;
&lt;p&gt;We need to compute the total order value and total order items for each device
in order to compute their AOV. To achieve this, we need to group the selected
&lt;code&gt;order_value&lt;/code&gt; and &lt;code&gt;order_items&lt;/code&gt; by device type. &lt;code&gt;group_by()&lt;/code&gt; allows us to group
or split data based on particular (discrete) variable. The first argument is the
name of the data set and the second argument is the name of the column based on
which the data will be split.&lt;/p&gt;
&lt;p&gt;To split the data by referrer type, we use &lt;code&gt;group_by&lt;/code&gt; and specify the data set
i.e. &lt;code&gt;ecom&lt;/code&gt; and the column based on which to split the data i.e. &lt;code&gt;referrer&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;group_by(ecom, referrer)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1,000 x 8
## # Groups:   referrer [5]
##    referrer device n_visit n_pages duration purchase order_items order_value
##    &amp;lt;fct&amp;gt;    &amp;lt;fct&amp;gt;    &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;lgl&amp;gt;          &amp;lt;dbl&amp;gt;       &amp;lt;dbl&amp;gt;
##  1 google   laptop      10       1      693 FALSE              0           0
##  2 yahoo    tablet       9       1      459 FALSE              0           0
##  3 direct   laptop       0       1      996 FALSE              0           0
##  4 bing     tablet       3      18      468 TRUE               6         434
##  5 yahoo    mobile       9       1      955 FALSE              0           0
##  6 yahoo    laptop       5       5      135 FALSE              0           0
##  7 yahoo    mobile      10       1       75 FALSE              0           0
##  8 direct   mobile      10       1      908 FALSE              0           0
##  9 bing     mobile       3      19      209 FALSE              0           0
## 10 google   mobile       6       1      208 FALSE              0           0
## # ... with 990 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;case-study-3&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Case Study&lt;/h5&gt;
&lt;p&gt;In the second line in the previous output, you can observe &lt;code&gt;Groups: referrer [5]&lt;/code&gt;
. The data is split into 5 groups as the referrer variable has 5 distinct values.
For our case study, we need to group the data by &lt;code&gt;device&lt;/code&gt; type.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# split ecom2 by device type
ecom3 &amp;lt;- group_by(ecom2, device)
ecom3&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 103 x 2
## # Groups:   device [3]
##    device order_value
##    &amp;lt;fct&amp;gt;        &amp;lt;dbl&amp;gt;
##  1 tablet         434
##  2 mobile         651
##  3 tablet        1049
##  4 tablet        1304
##  5 tablet         622
##  6 tablet        1613
##  7 mobile         184
##  8 tablet         286
##  9 mobile         764
## 10 tablet        1667
## # ... with 93 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;summarise-data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Summarise Data&lt;/h2&gt;
&lt;p&gt;The next step is to compute the total order value and total order items for each
device. i.e. we need to reduce the order value and order items data to a single
summary. We can achieve this using &lt;code&gt;summarise()&lt;/code&gt;. As usual, the first argument
is the name of a data set and the subsequent arguments are functions that can
summarise data. For example, we can use &lt;code&gt;min&lt;/code&gt;, &lt;code&gt;max&lt;/code&gt;, &lt;code&gt;sum&lt;/code&gt;, &lt;code&gt;mean&lt;/code&gt; etc.&lt;/p&gt;
&lt;p&gt;Let us compute the average number of pages browsed by referrer type:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;split data by &lt;code&gt;referrer&lt;/code&gt; type&lt;/li&gt;
&lt;li&gt;compute the average number of pages using &lt;code&gt;mean&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/groupby_summarise.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# split data by referrer type
step_1 &amp;lt;- group_by(ecom, referrer)

# compute average number of pages
step_2 &amp;lt;- summarise(step_1, mean(n_pages))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## `summarise()` ungrouping (override with `.groups` argument)&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;step_2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 5 x 2
##   referrer `mean(n_pages)`
## * &amp;lt;fct&amp;gt;              &amp;lt;dbl&amp;gt;
## 1 bing                6.13
## 2 direct              6.38
## 3 social              5.42
## 4 yahoo               5.99
## 5 google              5.73&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now let us compute both the &lt;code&gt;mean&lt;/code&gt; and the &lt;code&gt;median&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# split data by referrer type
step_1 &amp;lt;- group_by(ecom, referrer)

# compute average number of pages
step_2 &amp;lt;- summarise(step_1, mean(n_pages), median(n_pages))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## `summarise()` ungrouping (override with `.groups` argument)&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;step_2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 5 x 3
##   referrer `mean(n_pages)` `median(n_pages)`
## * &amp;lt;fct&amp;gt;              &amp;lt;dbl&amp;gt;             &amp;lt;dbl&amp;gt;
## 1 bing                6.13                 1
## 2 direct              6.38                 1
## 3 social              5.42                 1
## 4 yahoo               5.99                 2
## 5 google              5.73                 1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Another way to achieve the above result is to use the
&lt;code&gt;summarise_all()&lt;/code&gt; function. How does that work? It generates the specified
summary for all the columns in the data set except for the column based on
which the data has been grouped or split. So we need to ensure that the data
does not have any irrelevant columns.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;split data by &lt;code&gt;referrer&lt;/code&gt; type&lt;/li&gt;
&lt;li&gt;select &lt;code&gt;order_value&lt;/code&gt; and &lt;code&gt;order_items&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;compute the average number of pages by applying the &lt;code&gt;mean&lt;/code&gt; function to all
the columns&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# select relevant columns
step_1 &amp;lt;- select(ecom, referrer, order_value)

# split data by referrer type
step_2 &amp;lt;- group_by(step_1, referrer)

# compute average number of pages
step_3 &amp;lt;- summarise_all(step_2, funs(mean))
step_3&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 5 x 2
##   referrer order_value
## * &amp;lt;fct&amp;gt;          &amp;lt;dbl&amp;gt;
## 1 bing            316.
## 2 direct          441.
## 3 social          380.
## 4 yahoo           470.
## 5 google          328.&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us compute &lt;code&gt;mean&lt;/code&gt; and &lt;code&gt;median&lt;/code&gt; number of pages for each referre type using
&lt;code&gt;summarise_all&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# select relevant columns
step_1 &amp;lt;- select(ecom, referrer, order_value)

# split data by referrer type
step_2 &amp;lt;- group_by(step_1, referrer)

# compute mean and median number of pages
step_3 &amp;lt;- summarise_all(step_2, funs(mean, median))
step_3&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 5 x 3
##   referrer  mean median
## * &amp;lt;fct&amp;gt;    &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;
## 1 bing      316.      0
## 2 direct    441.      0
## 3 social    380.      0
## 4 yahoo     470.      0
## 5 google    328.      0&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;case-study-4&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Case Study&lt;/h5&gt;
&lt;p&gt;So far, we have split the data based on the &lt;code&gt;device&lt;/code&gt; type and we have selected 2
columns, &lt;code&gt;order_value&lt;/code&gt; and &lt;code&gt;order_items&lt;/code&gt;. We need the sum of order value and
order items. What function can we use to obtain them? The &lt;code&gt;sum()&lt;/code&gt; function will
generate the sum of the values and hence we will use it inside the &lt;code&gt;summarise()&lt;/code&gt;
function. Remember, we need to provide a name to the summary being generated.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom4 &amp;lt;- summarise(ecom3, revenue = sum(order_value),
          orders = n())&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## `summarise()` ungrouping (override with `.groups` argument)&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom4&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 x 3
##   device revenue orders
## * &amp;lt;fct&amp;gt;    &amp;lt;dbl&amp;gt;  &amp;lt;int&amp;gt;
## 1 laptop   56531     31
## 2 tablet   51321     36
## 3 mobile   51504     36&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There you go, we have the total order value and total order items for each
device type. If we use &lt;code&gt;summarise_all()&lt;/code&gt;, it will generate the summary for the
selected columns based on the function specified. To specify the functions, we
need to use another argument &lt;code&gt;funs&lt;/code&gt; and it can take any number of valid
functions.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom4 &amp;lt;- summarise_all(ecom3, funs(revenue = sum, orders = n()))
ecom4&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 x 3
##   device revenue orders
## * &amp;lt;fct&amp;gt;    &amp;lt;dbl&amp;gt;  &amp;lt;int&amp;gt;
## 1 laptop   56531     31
## 2 tablet   51321     36
## 3 mobile   51504     36&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;create-columns&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Create Columns&lt;/h2&gt;
&lt;p&gt;To create a new column, we will use &lt;code&gt;mutate()&lt;/code&gt;. The first argument is the name
of the data set and the subsequent arguments are expressions for creating new
columns based out of existing columns.&lt;/p&gt;
&lt;p&gt;Let us add a new column &lt;code&gt;avg_page_time&lt;/code&gt; i.e. time on site divided by number of
pages visited.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# select duration and n_pages from ecom
mutate_1 &amp;lt;- select(ecom, n_pages, duration)
mutate(mutate_1, avg_page_time = duration / n_pages)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1,000 x 3
##    n_pages duration avg_page_time
##      &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt;         &amp;lt;dbl&amp;gt;
##  1       1      693           693
##  2       1      459           459
##  3       1      996           996
##  4      18      468            26
##  5       1      955           955
##  6       5      135            27
##  7       1       75            75
##  8       1      908           908
##  9      19      209            11
## 10       1      208           208
## # ... with 990 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can create new columns based on other columns created using &lt;code&gt;mutate&lt;/code&gt;. Let us
create another column &lt;code&gt;sqrt_avg_page_time&lt;/code&gt; i.e. square root of the average time
on page using &lt;code&gt;avg_page_time&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mutate(mutate_1,
       avg_page_time = duration / n_pages,
       sqrt_avg_page_time = sqrt(avg_page_time))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1,000 x 4
##    n_pages duration avg_page_time sqrt_avg_page_time
##      &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt;         &amp;lt;dbl&amp;gt;              &amp;lt;dbl&amp;gt;
##  1       1      693           693              26.3 
##  2       1      459           459              21.4 
##  3       1      996           996              31.6 
##  4      18      468            26               5.10
##  5       1      955           955              30.9 
##  6       5      135            27               5.20
##  7       1       75            75               8.66
##  8       1      908           908              30.1 
##  9      19      209            11               3.32
## 10       1      208           208              14.4 
## # ... with 990 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;case-study-5&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Case Study&lt;/h5&gt;
&lt;p&gt;Back to our case study, from the last step we have the total order value and
total order items for each device category and can compute the AOV. We will
create a new column to store AOV.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom5 &amp;lt;- mutate(ecom4, aov = revenue / orders)
ecom5&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 x 4
##   device revenue orders   aov
## * &amp;lt;fct&amp;gt;    &amp;lt;dbl&amp;gt;  &amp;lt;int&amp;gt; &amp;lt;dbl&amp;gt;
## 1 laptop   56531     31 1824.
## 2 tablet   51321     36 1426.
## 3 mobile   51504     36 1431.&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;select-columns-1&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Select Columns&lt;/h2&gt;
&lt;p&gt;The last step is to select the relevant columns. We will select the device type
and the corresponding aov while getting rid of other columns. Use &lt;code&gt;select()&lt;/code&gt;
to extract the relevant columns.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom6 &amp;lt;- select(ecom5, device, aov)
ecom6&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 x 2
##   device   aov
##   &amp;lt;fct&amp;gt;  &amp;lt;dbl&amp;gt;
## 1 laptop 1824.
## 2 tablet 1426.
## 3 mobile 1431.&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;arrange-data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Arrange Data&lt;/h2&gt;
&lt;p&gt;Arranging data in ascending or descending order is one of the most common tasks
in data manipulation. We can use &lt;code&gt;arrange&lt;/code&gt; to arrange data by different columns.
Let us say we want to arrange data by the number of pages browsed.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/arrange_1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;arrange(ecom, n_pages)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1,000 x 8
##    referrer device n_visit n_pages duration purchase order_items order_value
##    &amp;lt;fct&amp;gt;    &amp;lt;fct&amp;gt;    &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;lgl&amp;gt;          &amp;lt;dbl&amp;gt;       &amp;lt;dbl&amp;gt;
##  1 google   laptop      10       1      693 FALSE              0           0
##  2 yahoo    tablet       9       1      459 FALSE              0           0
##  3 direct   laptop       0       1      996 FALSE              0           0
##  4 yahoo    mobile       9       1      955 FALSE              0           0
##  5 yahoo    mobile      10       1       75 FALSE              0           0
##  6 direct   mobile      10       1      908 FALSE              0           0
##  7 google   mobile       6       1      208 FALSE              0           0
##  8 direct   laptop       9       1      738 FALSE              0           0
##  9 yahoo    mobile       7       1       19 FALSE              7        2423
## 10 bing     laptop       1       1      995 FALSE              0           0
## # ... with 990 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If we want to arrange the data in descending order, we can use &lt;code&gt;desc()&lt;/code&gt;. Let us
arrange the data in descending order.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;arrange(ecom , desc(n_pages))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1,000 x 8
##    referrer device n_visit n_pages duration purchase order_items order_value
##    &amp;lt;fct&amp;gt;    &amp;lt;fct&amp;gt;    &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;lgl&amp;gt;          &amp;lt;dbl&amp;gt;       &amp;lt;dbl&amp;gt;
##  1 social   tablet       9      20      420 TRUE               7        1613
##  2 bing     mobile       4      20      440 TRUE               3         184
##  3 yahoo    tablet       0      20      200 FALSE              0           0
##  4 direct   tablet       6      20      580 TRUE               5        1155
##  5 social   mobile       1      20      520 TRUE               5        1021
##  6 google   mobile       8      20      300 TRUE               7        2091
##  7 social   laptop       4      20      200 FALSE              0           0
##  8 yahoo    mobile       3      20      480 FALSE              0           0
##  9 social   laptop      10      20      280 TRUE               1        2011
## 10 yahoo    mobile       2      20      240 FALSE              0           0
## # ... with 990 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Data can be arranged by multiple variables as well. Let us arrange data first by
number of visits and then by number of pages in a descending order.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;arrange(ecom, n_visit, desc(n_pages))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1,000 x 8
##    referrer device n_visit n_pages duration purchase order_items order_value
##    &amp;lt;fct&amp;gt;    &amp;lt;fct&amp;gt;    &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;lgl&amp;gt;          &amp;lt;dbl&amp;gt;       &amp;lt;dbl&amp;gt;
##  1 yahoo    tablet       0      20      200 FALSE              0           0
##  2 google   laptop       0      19      418 TRUE               2         996
##  3 bing     laptop       0      18      180 FALSE              0           0
##  4 yahoo    laptop       0      18      522 TRUE               8        1523
##  5 direct   tablet       0      18      252 FALSE              0           0
##  6 social   laptop       0      17      204 FALSE              0           0
##  7 bing     laptop       0      17      272 TRUE               9        1384
##  8 bing     mobile       0      16      272 FALSE              0           0
##  9 yahoo    mobile       0      15      255 FALSE              0           0
## 10 direct   laptop       0      15      255 FALSE              0           0
## # ... with 990 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;case-study-6&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Case Study&lt;/h5&gt;
&lt;p&gt;If you observe &lt;code&gt;ecom6&lt;/code&gt;, the &lt;code&gt;aov&lt;/code&gt; column is arranged in descending order.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;arrange(ecom6, aov)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 x 2
##   device   aov
##   &amp;lt;fct&amp;gt;  &amp;lt;dbl&amp;gt;
## 1 tablet 1426.
## 2 mobile 1431.
## 3 laptop 1824.&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;aov-by-devices-1&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;AOV by Devices&lt;/h2&gt;
&lt;p&gt;Let us combine all the code from the above steps:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom1 &amp;lt;- filter(ecom, purchase)
ecom2 &amp;lt;- select(ecom1, device, order_value)
ecom3 &amp;lt;- group_by(ecom2, device)
ecom4 &amp;lt;- summarise_all(ecom3, funs(revenue = sum, orders = n()))
ecom5 &amp;lt;- mutate(ecom4, aov = revenue / orders)
ecom6 &amp;lt;- select(ecom5, device, aov)
ecom7 &amp;lt;- arrange(ecom6, aov)
ecom7&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 x 2
##   device   aov
##   &amp;lt;fct&amp;gt;  &amp;lt;dbl&amp;gt;
## 1 tablet 1426.
## 2 mobile 1431.
## 3 laptop 1824.&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you observe, at each step we create a new variable(data frame) and then use
it as an input in the next step i.e. the output from one step becomes the input
for the next. Can we achieve the final outcome i.e. &lt;code&gt;ecom7&lt;/code&gt; without creating the
intermediate data (ecom1 - ecom6)? Yes, we can. We will use the &lt;code&gt;%&amp;gt;%&lt;/code&gt; operator
to chain the steps and get rid of the intermediate data.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom %&amp;gt;%
  filter(purchase) %&amp;gt;%
  select(device, order_value) %&amp;gt;%
  group_by(device) %&amp;gt;%
  summarise_all(funs(revenue = sum, orders = n())) %&amp;gt;%
  mutate(
    aov = revenue / orders
  ) %&amp;gt;%
  select(device, aov) %&amp;gt;%
  arrange(aov)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 x 2
##   device   aov
##   &amp;lt;fct&amp;gt;  &amp;lt;dbl&amp;gt;
## 1 tablet 1426.
## 2 mobile 1431.
## 3 laptop 1824.&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;your-turn&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Your Turn&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;what is the average number of pages visited by purchasers and non-purchasers?&lt;/li&gt;
&lt;li&gt;what is the average time on site for purchasers vs non-purchasers?&lt;/li&gt;
&lt;li&gt;what is the average number of pages visited by purchasers and non-purchasers using mobile?&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;references&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://dplyr.tidyverse.org/&#34; class=&#34;uri&#34;&gt;https://dplyr.tidyverse.org/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://r4ds.had.co.nz/transform.html&#34; class=&#34;uri&#34;&gt;http://r4ds.had.co.nz/transform.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Import Data into R - Part 2</title>
      <link>https://blog.rsquaredacademy.com/import-data-into-r-part-2/</link>
      <pubDate>Sat, 11 Aug 2018 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/import-data-into-r-part-2/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;This is the second post in the series &lt;strong&gt;Importing Data into R&lt;/strong&gt;. In the
previous post, we explored reading data from flat/delimited files. In this
post, we will:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;list sheets in an excel file&lt;/li&gt;
&lt;li&gt;read data from an excel sheet&lt;/li&gt;
&lt;li&gt;read specific cells from an excel sheet&lt;/li&gt;
&lt;li&gt;read specific rows&lt;/li&gt;
&lt;li&gt;read specific columns&lt;/li&gt;
&lt;li&gt;read data from
- SAS
- SPSS
- STATA&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-data-code&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Libraries, Data &amp;amp; Code&lt;/h2&gt;
&lt;p&gt;We will use the &lt;a href=&#34;http://readr.tidyverse.org/index.html&#34;&gt;readxl&lt;/a&gt; package. It has
no external dependencies as compared to other packages available for reading
data from Excel. The data sets can be downloaded from
&lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt; and the codes from
&lt;a href=&#34;https://gist.github.com/aravindhebbali/65dc2af57b8eda098f2b878095c5aaa4&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(readxl)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;list-sheets&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;List Sheets&lt;/h2&gt;
&lt;p&gt;An excel file may contain several sheets. Let us see how many sheets are
present in &lt;code&gt;sample.xls&lt;/code&gt; file and their respective names using &lt;code&gt;excel_sheets()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;excel_sheets(&amp;#39;sample.xls&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;ecom&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;read-sheet&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Read Sheet&lt;/h2&gt;
&lt;p&gt;Now that we know the number of sheets and their names, let us read data from
the &lt;code&gt;ecom&lt;/code&gt; sheet of the &lt;code&gt;sample.xls&lt;/code&gt; file using &lt;code&gt;read_excel()&lt;/code&gt;. We will specify
the file name, and the sheet name or sheet number.&lt;/p&gt;
&lt;div id=&#34;case-1-specify-the-sheet-number&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Case 1: Specify the sheet number&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;read_excel(&amp;#39;sample.xls&amp;#39;, sheet = 1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 7 x 5
##   channel        users new_users sessions bounce_rate
##   &amp;lt;chr&amp;gt;          &amp;lt;dbl&amp;gt;     &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;chr&amp;gt;      
## 1 Organic Search 43296     40238    50810 48.72%     
## 2 Direct         12916     12311    16419 49.27%     
## 3 Referral       10983      7636    18105 22.26%     
## 4 Social         10346     10029    11101 61.92%     
## 5 Display         5564      4790     7220 83.30%     
## 6 Paid Search     2687      2205     3438 38.02%     
## 7 Affiliates      1773      1585     2167 55.75%&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;case-2-specify-the-sheet-name&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Case 2: Specify the sheet name&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;read_excel(&amp;#39;sample.xls&amp;#39;, sheet = &amp;#39;ecom&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 7 x 5
##   channel        users new_users sessions bounce_rate
##   &amp;lt;chr&amp;gt;          &amp;lt;dbl&amp;gt;     &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;chr&amp;gt;      
## 1 Organic Search 43296     40238    50810 48.72%     
## 2 Direct         12916     12311    16419 49.27%     
## 3 Referral       10983      7636    18105 22.26%     
## 4 Social         10346     10029    11101 61.92%     
## 5 Display         5564      4790     7220 83.30%     
## 6 Paid Search     2687      2205     3438 38.02%     
## 7 Affiliates      1773      1585     2167 55.75%&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Notice when you use the sheet name, the name should be enclosed in
single/double quotes.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;read-specific-cells&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Read Specific Cells&lt;/h2&gt;
&lt;p&gt;You may not always want to read all the columns or rows from the excel sheet.
In such cases, you can specify the cells from which the data must be read
which can be achieved using the &lt;code&gt;range&lt;/code&gt; argument. So how do we specify the
cells from which to read data? There are different ways of specifying the
cell range and we will look at them one by one:&lt;/p&gt;
&lt;div id=&#34;method-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Method 1&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/readxl_range.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;The first method uses the cell names along with &lt;code&gt;:&lt;/code&gt; to specify the cell range.
For example, to read data from first 4 rows of columns &lt;strong&gt;B&lt;/strong&gt; and &lt;strong&gt;C&lt;/strong&gt;, we will
specify the range as &lt;code&gt;&#34;B1:C4&#34;&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;read_excel(&amp;#39;sample.xls&amp;#39;, sheet = 1, range = &amp;quot;B1:C4&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 x 2
##   users new_users
##   &amp;lt;dbl&amp;gt;     &amp;lt;dbl&amp;gt;
## 1 43296     40238
## 2 12916     12311
## 3 10983      7636&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To read data from first 5 rows of columns &lt;strong&gt;A&lt;/strong&gt;, &lt;strong&gt;B&lt;/strong&gt; and &lt;strong&gt;C&lt;/strong&gt;, we will specify the range as &lt;code&gt;&#34;A1:C5&#34;&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;read_excel(&amp;#39;sample.xls&amp;#39;, sheet = 1, range = &amp;quot;A1:C5&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 4 x 3
##   channel        users new_users
##   &amp;lt;chr&amp;gt;          &amp;lt;dbl&amp;gt;     &amp;lt;dbl&amp;gt;
## 1 Organic Search 43296     40238
## 2 Direct         12916     12311
## 3 Referral       10983      7636
## 4 Social         10346     10029&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;method-2&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Method 2&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/readxl_anchored_lucid.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;In the second method, we start from a particular cell and specify the number
of rows and columns to be covered keeping the initial cell as anchorage.
In the below example, we want to read 3 rows and 2 columns starting from the
cell &lt;code&gt;A4&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;read_excel(&amp;#39;sample.xls&amp;#39;, sheet = 1, col_names = FALSE,
  range = anchored(&amp;quot;A4&amp;quot;, dim = c(3, 2)))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 x 2
##   ...1      ...2
##   &amp;lt;chr&amp;gt;    &amp;lt;dbl&amp;gt;
## 1 Referral 10983
## 2 Social   10346
## 3 Display   5564&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;method-3&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Method 3&lt;/h3&gt;
&lt;p&gt;In this method, we use the &lt;code&gt;cell_limit()&lt;/code&gt; and specify the location of two ends
of a rectangle covering the cells we want to read. For example, to read data
from the first 6 rows and 4 columns, we will specify the range as following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;start from the first row of the first column&lt;/li&gt;
&lt;li&gt;cover all cells upto the 6th row of the 4th column&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/readxl_cell_limits_lucid.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;read_excel(&amp;#39;sample.xls&amp;#39;, sheet = 1,
  range = cell_limits(c(1, 1), c(6, 4)))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 5 x 4
##   channel        users new_users sessions
##   &amp;lt;chr&amp;gt;          &amp;lt;dbl&amp;gt;     &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt;
## 1 Organic Search 43296     40238    50810
## 2 Direct         12916     12311    16419
## 3 Referral       10983      7636    18105
## 4 Social         10346     10029    11101
## 5 Display         5564      4790     7220&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can use &lt;code&gt;NA&lt;/code&gt; to indicate the first and last row/column. For example, to
read data from all the rows from the second column onwards:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;read_excel(&amp;#39;sample.xls&amp;#39;, sheet = 1,
  range = cell_limits(c(1, 2), c(NA, NA)))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 7 x 4
##   users new_users sessions bounce_rate
##   &amp;lt;dbl&amp;gt;     &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;chr&amp;gt;      
## 1 43296     40238    50810 48.72%     
## 2 12916     12311    16419 49.27%     
## 3 10983      7636    18105 22.26%     
## 4 10346     10029    11101 61.92%     
## 5  5564      4790     7220 83.30%     
## 6  2687      2205     3438 38.02%     
## 7  1773      1585     2167 55.75%&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us quickly look at how we will specify range of cells using the above 3
methods when we want to read data from the first 4 rows of columns &lt;code&gt;B&lt;/code&gt; and &lt;code&gt;C&lt;/code&gt;:&lt;/p&gt;
&lt;div id=&#34;method-1-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Method 1&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;read_excel(&amp;#39;sample.xls&amp;#39;, sheet = 1,
  range = &amp;quot;B1:C4&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 x 2
##   users new_users
##   &amp;lt;dbl&amp;gt;     &amp;lt;dbl&amp;gt;
## 1 43296     40238
## 2 12916     12311
## 3 10983      7636&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;method-2-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Method 2&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;read_excel(&amp;#39;sample.xls&amp;#39;, sheet = 1,
  range = anchored(&amp;quot;B1&amp;quot;, dim = c(4, 2)))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 x 2
##   users new_users
##   &amp;lt;dbl&amp;gt;     &amp;lt;dbl&amp;gt;
## 1 43296     40238
## 2 12916     12311
## 3 10983      7636&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;method-3-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Method 3&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;read_excel(&amp;#39;sample.xls&amp;#39;, sheet = 1,
  range = cell_limits(c(1, 2), c(4, 3)))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 x 2
##   users new_users
##   &amp;lt;dbl&amp;gt;     &amp;lt;dbl&amp;gt;
## 1 43296     40238
## 2 12916     12311
## 3 10983      7636&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;read-specific-rows&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Read Specific Rows&lt;/h2&gt;
&lt;p&gt;When you want to read a subset of rows from the data, use &lt;code&gt;cell_rows()&lt;/code&gt; and
specify the row numbers or the range. In the below example, we want to read
the first 4 rows of data from the file.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;read_excel(&amp;#39;sample.xls&amp;#39;, sheet = 1, range = cell_rows(1:4))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 3 x 5
##   channel        users new_users sessions bounce_rate
##   &amp;lt;chr&amp;gt;          &amp;lt;dbl&amp;gt;     &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;chr&amp;gt;      
## 1 Organic Search 43296     40238    50810 48.72%     
## 2 Direct         12916     12311    16419 49.27%     
## 3 Referral       10983      7636    18105 22.26%&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;read-single-column&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Read Single Column&lt;/h2&gt;
&lt;p&gt;If you want to read a single column from the data, use &lt;code&gt;cell_cols()&lt;/code&gt; and
specify the column number. In the below example, we read the second column
from the &lt;code&gt;sample.xls&lt;/code&gt; file.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;read_excel(&amp;#39;sample.xls&amp;#39;, sheet = 1, range = cell_cols(2))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 7 x 1
##   users
##   &amp;lt;dbl&amp;gt;
## 1 43296
## 2 12916
## 3 10983
## 4 10346
## 5  5564
## 6  2687
## 7  1773&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;read-multiple-columns&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Read Multiple Columns&lt;/h2&gt;
&lt;p&gt;In case of multiple columns, we need to specify the column numbers or the
column range. In the below example, we want to read the 2nd, 4th and 6th column from
the &lt;code&gt;sample.xls&lt;/code&gt; file.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;read_excel(&amp;#39;sample.xls&amp;#39;, sheet = 1, range = cell_cols(c(2, 4, 6)))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 7 x 5
##   users new_users sessions bounce_rate ...5 
##   &amp;lt;dbl&amp;gt;     &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;chr&amp;gt;       &amp;lt;lgl&amp;gt;
## 1 43296     40238    50810 48.72%      NA   
## 2 12916     12311    16419 49.27%      NA   
## 3 10983      7636    18105 22.26%      NA   
## 4 10346     10029    11101 61.92%      NA   
## 5  5564      4790     7220 83.30%      NA   
## 6  2687      2205     3438 38.02%      NA   
## 7  1773      1585     2167 55.75%      NA&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the next example, we want to read data from the 2nd column upto and
including the 6th column.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;read_excel(&amp;#39;sample.xls&amp;#39;, sheet = 1, range = cell_cols(c(2:6)))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 7 x 5
##   users new_users sessions bounce_rate ...5 
##   &amp;lt;dbl&amp;gt;     &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;chr&amp;gt;       &amp;lt;lgl&amp;gt;
## 1 43296     40238    50810 48.72%      NA   
## 2 12916     12311    16419 49.27%      NA   
## 3 10983      7636    18105 22.26%      NA   
## 4 10346     10029    11101 61.92%      NA   
## 5  5564      4790     7220 83.30%      NA   
## 6  2687      2205     3438 38.02%      NA   
## 7  1773      1585     2167 55.75%      NA&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/range_summary.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;statistical-softwares&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Statistical Softwares&lt;/h2&gt;
&lt;p&gt;We will use the &lt;a href=&#34;https://haven.tidyverse.org&#34;&gt;haven&lt;/a&gt; package to read data from files of other statistical softwares such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;SAS&lt;/li&gt;
&lt;li&gt;SPSS&lt;/li&gt;
&lt;li&gt;STATA&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;library&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Library&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(haven)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;stata&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;STATA&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;read_stata(&amp;#39;airline.dta&amp;#39;)  &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 32 x 6
##     year     y     w     r     l     k
##    &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;
##  1  1948  1.21 0.243 0.145  1.41 0.612
##  2  1949  1.35 0.260 0.218  1.38 0.559
##  3  1950  1.57 0.278 0.316  1.39 0.573
##  4  1951  1.95 0.297 0.394  1.55 0.564
##  5  1952  2.27 0.310 0.356  1.80 0.574
##  6  1953  2.73 0.322 0.359  1.93 0.711
##  7  1954  3.03 0.335 0.403  1.96 0.776
##  8  1955  3.56 0.350 0.396  2.12 0.827
##  9  1956  3.98 0.361 0.382  2.43 0.800
## 10  1957  4.42 0.379 0.305  2.71 0.921
## # ... with 22 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;spss&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;SPSS&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;read_spss(&amp;#39;employee.sav&amp;#39;)  &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 474 x 9
##       id gender       educ    jobcat  salary salbegin jobtime   prevexp minority
##    &amp;lt;dbl&amp;gt; &amp;lt;chr+lb&amp;gt; &amp;lt;dbl+lb&amp;gt; &amp;lt;dbl+lbl&amp;gt; &amp;lt;dbl+l&amp;gt; &amp;lt;dbl+lb&amp;gt; &amp;lt;dbl+l&amp;gt; &amp;lt;dbl+lbl&amp;gt; &amp;lt;dbl+lb&amp;gt;
##  1     1 m [Male]  15 [15] 3 [Manag~   57000    27000      98 144         0 [No]
##  2     2 m [Male]  16 [16] 1 [Cleri~   40200    18750      98  36         0 [No]
##  3     3 f [Fema~  12 [12] 1 [Cleri~   21450    12000      98 381         0 [No]
##  4     4 f [Fema~   8 [8]  1 [Cleri~   21900    13200      98 190         0 [No]
##  5     5 m [Male]  15 [15] 1 [Cleri~   45000    21000      98 138         0 [No]
##  6     6 m [Male]  15 [15] 1 [Cleri~   32100    13500      98  67         0 [No]
##  7     7 m [Male]  15 [15] 1 [Cleri~   36000    18750      98 114         0 [No]
##  8     8 f [Fema~  12 [12] 1 [Cleri~   21900     9750      98   0 [mis~   0 [No]
##  9     9 f [Fema~  15 [15] 1 [Cleri~   27900    12750      98 115         0 [No]
## 10    10 f [Fema~  12 [12] 1 [Cleri~   24000    13500      98 244         0 [No]
## # ... with 464 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;sas&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;SAS&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;read_sas(&amp;#39;airline.sas7bdat&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 32 x 6
##     YEAR     Y     W     R     L     K
##    &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;
##  1  1948  1.21 0.243 0.145  1.41 0.612
##  2  1949  1.35 0.260 0.218  1.38 0.559
##  3  1950  1.57 0.278 0.316  1.39 0.573
##  4  1951  1.95 0.297 0.394  1.55 0.564
##  5  1952  2.27 0.310 0.356  1.80 0.574
##  6  1953  2.73 0.322 0.359  1.93 0.711
##  7  1954  3.03 0.335 0.403  1.96 0.776
##  8  1955  3.56 0.350 0.396  2.12 0.827
##  9  1956  3.98 0.361 0.382  2.43 0.800
## 10  1957  4.42 0.379 0.305  2.71 0.921
## # ... with 22 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;summary-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/readxl_summary_lucid.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;references&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://readxl.tidyverse.org/&#34; class=&#34;uri&#34;&gt;https://readxl.tidyverse.org/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://haven.tidyverse.org/&#34; class=&#34;uri&#34;&gt;https://haven.tidyverse.org/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://r4ds.had.co.nz/data-import.html&#34; class=&#34;uri&#34;&gt;http://r4ds.had.co.nz/data-import.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Import Data into R - Part 1</title>
      <link>https://blog.rsquaredacademy.com/import-data-into-r-part-1/</link>
      <pubDate>Mon, 30 Jul 2018 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/import-data-into-r-part-1/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In this post, we will learn to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;read data from flat or delimited files&lt;/li&gt;
&lt;li&gt;handle column names/header&lt;/li&gt;
&lt;li&gt;skip text/info present before data&lt;/li&gt;
&lt;li&gt;specify column/variable types&lt;/li&gt;
&lt;li&gt;read specific columns/variables&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-data-code&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Libraries, Data &amp;amp; Code&lt;/h2&gt;
&lt;p&gt;We will use the &lt;a href=&#34;http://readr.tidyverse.org/index.html&#34;&gt;readr&lt;/a&gt; package. The
data sets can be downloaded from &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt;
and the codes from &lt;a href=&#34;https://gist.github.com/aravindhebbali/ade2338fd725438f57345e6bd0bccfac&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(readr)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;types-of-delimiters&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Types of Delimiters&lt;/h2&gt;
&lt;p&gt;Before we start reading data from files, let us take a quick look at the
different types of delimiters we have to deal with while reading or importing
data. In general, it is a good practice to take a quick look at as you will
clearly know the delimiter used in the file.&lt;/p&gt;
&lt;div id=&#34;comma-separated-values&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Comma Separated Values&lt;/h4&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/mtcars_comma.png&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;semi-colon-separated-values&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Semi Colon Separated Values&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/mtcars_semicolon.png&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;space-separated-values&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Space Separated Values&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/mtcars_space.png&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;tab-separated-values&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Tab Separated Values&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/mtcars_tab.png&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;read-data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Read Data&lt;/h2&gt;
&lt;p&gt;Let us begin by reading data from a &lt;code&gt;csv&lt;/code&gt; file using &lt;code&gt;read_csv()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;read_csv(&amp;#39;hsb2.csv&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Parsed with column specification:
## cols(
##   id = col_double(),
##   female = col_double(),
##   race = col_double(),
##   ses = col_double(),
##   schtyp = col_double(),
##   prog = col_double(),
##   read = col_double(),
##   write = col_double(),
##   math = col_double(),
##   science = col_double(),
##   socst = col_double()
## )&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 200 x 11
##       id female  race   ses schtyp  prog  read write  math science socst
##    &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;
##  1    70      0     4     1      1     1    57    52    41      47    57
##  2   121      1     4     2      1     3    68    59    53      63    61
##  3    86      0     4     3      1     1    44    33    54      58    31
##  4   141      0     4     3      1     3    63    44    47      53    56
##  5   172      0     4     2      1     2    47    52    57      53    61
##  6   113      0     4     2      1     2    44    52    51      63    61
##  7    50      0     3     2      1     1    50    59    42      53    61
##  8    11      0     1     2      1     2    34    46    45      39    36
##  9    84      0     4     2      1     1    63    57    54      58    51
## 10    48      0     3     2      1     2    57    55    52      50    51
## # ... with 190 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Great! If you see the above output, you have successfully read data into R. If
you see an error message (which most of us see when we are trying to read data
for the first time), follow the below instructions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;check the separator in the file and ensure it is a &lt;code&gt;comma&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;check the file name&lt;/li&gt;
&lt;li&gt;check the file path i.e. location of the file&lt;/li&gt;
&lt;li&gt;ensure that the file name or path is enclosed in single or double quotes&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When you read data using &lt;code&gt;readr&lt;/code&gt;, it will display the data type detected for
each column/variable in the data set. If you want to check the data types
before reading the data, use &lt;code&gt;spec_csv()&lt;/code&gt;. We will learn to specify the column
types in the next section.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;spec_csv(&amp;#39;hsb2.csv&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## cols(
##   id = col_double(),
##   female = col_double(),
##   race = col_double(),
##   ses = col_double(),
##   schtyp = col_double(),
##   prog = col_double(),
##   read = col_double(),
##   write = col_double(),
##   math = col_double(),
##   science = col_double(),
##   socst = col_double()
## )&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;column-names&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Column Names&lt;/h2&gt;
&lt;p&gt;In some cases, files do not include column names or headers. If we do not
indicate the absence of column names, &lt;code&gt;readr&lt;/code&gt; will treat the first row from
the data as the column name. Like we said before, it is a good practice to take
a quick look at the data to check for the presence/absence of column names.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/mtcars_comma.png&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/mtcars_column_false.png&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;We will first read the data set without indicating the presence or absence of
column names.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;read_csv(&amp;#39;hsb3.csv&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: Duplicated column names deduplicated: &amp;#39;1&amp;#39; =&amp;gt; &amp;#39;1_1&amp;#39; [5], &amp;#39;1&amp;#39; =&amp;gt;
## &amp;#39;1_2&amp;#39; [6], &amp;#39;57&amp;#39; =&amp;gt; &amp;#39;57_1&amp;#39; [11]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 199 x 11
##     `70`   `0`   `4`   `1` `1_1` `1_2`  `57`  `52`  `41`  `47` `57_1`
##    &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;
##  1   121     1     4     2     1     3    68    59    53    63     61
##  2    86     0     4     3     1     1    44    33    54    58     31
##  3   141     0     4     3     1     3    63    44    47    53     56
##  4   172     0     4     2     1     2    47    52    57    53     61
##  5   113     0     4     2     1     2    44    52    51    63     61
##  6    50     0     3     2     1     1    50    59    42    53     61
##  7    11     0     1     2     1     2    34    46    45    39     36
##  8    84     0     4     2     1     1    63    57    54    58     51
##  9    48     0     3     2     1     2    57    55    52    50     51
## 10    75     0     4     2     1     3    60    46    51    53     61
## # ... with 189 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, in the absence of column names, &lt;code&gt;readr&lt;/code&gt; has converted the
first row of the data into the column names. As a result, the data is
not read properly and there are lots of missing values and warnings.
If the column names are absent (i.e. the column names are provided in a
separate file), use the &lt;code&gt;col_names&lt;/code&gt; argument and set it to &lt;code&gt;FALSE&lt;/code&gt;. Now &lt;code&gt;readr&lt;/code&gt;
will not convert the first row of data into column name and instead it
will generate new column names.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;read_csv(&amp;#39;hsb3.csv&amp;#39;, col_names = FALSE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 200 x 11
##       X1    X2    X3    X4    X5    X6    X7    X8    X9   X10   X11
##    &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;
##  1    70     0     4     1     1     1    57    52    41    47    57
##  2   121     1     4     2     1     3    68    59    53    63    61
##  3    86     0     4     3     1     1    44    33    54    58    31
##  4   141     0     4     3     1     3    63    44    47    53    56
##  5   172     0     4     2     1     2    47    52    57    53    61
##  6   113     0     4     2     1     2    44    52    51    63    61
##  7    50     0     3     2     1     1    50    59    42    53    61
##  8    11     0     1     2     1     2    34    46    45    39    36
##  9    84     0     4     2     1     1    63    57    54    58    51
## 10    48     0     3     2     1     2    57    55    52    50    51
## # ... with 190 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We may not always want to use the column names generated by &lt;code&gt;readr&lt;/code&gt; and
instead specify new column names. In such cases, we can use &lt;code&gt;col_names&lt;/code&gt; to
supply column names as shown in the below example. Let us reread &lt;code&gt;hsb3&lt;/code&gt;
and specify column names.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;cnames &amp;lt;- c(&amp;quot;id&amp;quot;, &amp;quot;gender&amp;quot;, &amp;quot;race&amp;quot;, &amp;quot;socio_economic_status&amp;quot;, &amp;quot;school_type&amp;quot;, &amp;quot;program&amp;quot;, &amp;quot;read&amp;quot;, &amp;quot;write&amp;quot;, &amp;quot;math&amp;quot;, &amp;quot;science&amp;quot;, &amp;quot;socst&amp;quot;)
read_csv(&amp;#39;hsb3.csv&amp;#39;, col_names = cnames)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 200 x 11
##       id gender  race socio_economic_~ school_type program  read write  math
##    &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;            &amp;lt;dbl&amp;gt;       &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;
##  1    70      0     4                1           1       1    57    52    41
##  2   121      1     4                2           1       3    68    59    53
##  3    86      0     4                3           1       1    44    33    54
##  4   141      0     4                3           1       3    63    44    47
##  5   172      0     4                2           1       2    47    52    57
##  6   113      0     4                2           1       2    44    52    51
##  7    50      0     3                2           1       1    50    59    42
##  8    11      0     1                2           1       2    34    46    45
##  9    84      0     4                2           1       1    63    57    54
## 10    48      0     3                2           1       2    57    55    52
## # ... with 190 more rows, and 2 more variables: science &amp;lt;dbl&amp;gt;, socst &amp;lt;dbl&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;skip-lines&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Skip Lines&lt;/h3&gt;
&lt;p&gt;In certain files, you will find information related to the data such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the data source&lt;/li&gt;
&lt;li&gt;column names&lt;/li&gt;
&lt;li&gt;column description&lt;/li&gt;
&lt;li&gt;copyright etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The data will appear after/below such text/information. While reading data from
such files, we need to skip all the rows where the text is present. If we do
not skip them, &lt;code&gt;readr&lt;/code&gt; will consider them as part of the data.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/mtcars_skip.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Let us read the data without skipping any lines/rows and observe the result.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;read_csv(&amp;#39;hsb4.csv&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: 201 parsing failures.
## row col  expected     actual       file
##   3  -- 1 columns 11 columns &amp;#39;hsb4.csv&amp;#39;
##   4  -- 1 columns 11 columns &amp;#39;hsb4.csv&amp;#39;
##   5  -- 1 columns 11 columns &amp;#39;hsb4.csv&amp;#39;
##   6  -- 1 columns 11 columns &amp;#39;hsb4.csv&amp;#39;
##   7  -- 1 columns 11 columns &amp;#39;hsb4.csv&amp;#39;
## ... ... ......... .......... ..........
## See problems(...) for more details.&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 203 x 1
##    `# A dataset containing demographic information and standardized`
##    &amp;lt;chr&amp;gt;                                                            
##  1 # test scores of high school students.                           
##  2 # http://www.ats.ucla.edu/stat/spss/whatstat/whatstat.htm        
##  3 id                                                               
##  4 70                                                               
##  5 121                                                              
##  6 86                                                               
##  7 141                                                              
##  8 172                                                              
##  9 113                                                              
## 10 50                                                               
## # ... with 193 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Use &lt;code&gt;skip&lt;/code&gt; argument to indicate the number of lines/rows to be skipped while
reading data from a file. For example, if the file has contents other than data
in the first few lines, we need to skip them before reading the data. In the
below example, we will skip the first 3 lines as they contain information about
the data set which we do not need.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;read_csv(&amp;#39;hsb4.csv&amp;#39;, skip = 3)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 200 x 11
##       id female  race   ses schtyp  prog  read write  math science socst
##    &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;
##  1    70      0     4     1      1     1    57    52    41      47    57
##  2   121      1     4     2      1     3    68    59    53      63    61
##  3    86      0     4     3      1     1    44    33    54      58    31
##  4   141      0     4     3      1     3    63    44    47      53    56
##  5   172      0     4     2      1     2    47    52    57      53    61
##  6   113      0     4     2      1     2    44    52    51      63    61
##  7    50      0     3     2      1     1    50    59    42      53    61
##  8    11      0     1     2      1     2    34    46    45      39    36
##  9    84      0     4     2      1     1    63    57    54      58    51
## 10    48      0     3     2      1     2    57    55    52      50    51
## # ... with 190 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;maximum-lines&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Maximum Lines&lt;/h3&gt;
&lt;p&gt;Suppose the data file contains several thousands of rows of data and we do not
want to read all of it. What can we do in such cases? &lt;code&gt;readr&lt;/code&gt; allows us to
specify the maximum number of rows to be read using the &lt;code&gt;n_max&lt;/code&gt; argument.
Suppose we want to read only 100 rows of data from a file, we can set &lt;code&gt;n_max&lt;/code&gt;
equal to 100. In the next example, we will read the first 120 rows from the
&lt;code&gt;hsb2&lt;/code&gt; file. If you observe the last row in the output, it says &lt;code&gt;# ... with  110 more rows&lt;/code&gt;, indicating that only 120 rows of data has been read from the
file.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;read_csv(&amp;#39;hsb2.csv&amp;#39;, n_max = 120)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 120 x 11
##       id female  race   ses schtyp  prog  read write  math science socst
##    &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;
##  1    70      0     4     1      1     1    57    52    41      47    57
##  2   121      1     4     2      1     3    68    59    53      63    61
##  3    86      0     4     3      1     1    44    33    54      58    31
##  4   141      0     4     3      1     3    63    44    47      53    56
##  5   172      0     4     2      1     2    47    52    57      53    61
##  6   113      0     4     2      1     2    44    52    51      63    61
##  7    50      0     3     2      1     1    50    59    42      53    61
##  8    11      0     1     2      1     2    34    46    45      39    36
##  9    84      0     4     2      1     1    63    57    54      58    51
## 10    48      0     3     2      1     2    57    55    52      50    51
## # ... with 110 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;column-types&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Column Types&lt;/h3&gt;
&lt;p&gt;If you have observed carefully, when you read data using &lt;code&gt;readr&lt;/code&gt;, it displays
the column names and column types followed by the first 10 rows of data.
&lt;code&gt;readr&lt;/code&gt; determines the data type for each column based on the first 1000 rows
of data. The data can be of the following types:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;integer&lt;/li&gt;
&lt;li&gt;double (decimal point)&lt;/li&gt;
&lt;li&gt;logical (TRUE/FALSE)&lt;/li&gt;
&lt;li&gt;character (text/string)&lt;/li&gt;
&lt;li&gt;factor (categorical/qualitative)&lt;/li&gt;
&lt;li&gt;date/time&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/column_types_list_canva.png&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Before you read data from a file, use &lt;code&gt;spec_csv()&lt;/code&gt; to see the data types as
determined by &lt;code&gt;readr&lt;/code&gt;. If it determines the data types correctly, you can go
ahead and read the data else we will have to specify the data types and we
will have to do that for all the columns we want to read and not just for
those columns whose data type was wrongly determined by &lt;code&gt;readr&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;To specify the data types, we will use the &lt;code&gt;col_types&lt;/code&gt; argument and supply it
a list of data types. The data types can be specified using:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;col_integer()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;col_double()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;col_factor()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;col_logical()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;col_character()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;col_date()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;col_time()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;col_datetime()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;While specifying the data types we also need to specify the categories of the
categorical/qualitative variable. To do that, we use the &lt;code&gt;levels&lt;/code&gt; argument
within &lt;code&gt;col_factor()&lt;/code&gt;. Let us read data from the &lt;code&gt;hsb2.csv&lt;/code&gt; file to understand
data type specification.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;read_csv(&amp;#39;hsb2.csv&amp;#39;, col_types = list(
  col_integer(), col_factor(levels = c(0, 1)), 
  col_factor(levels = c(1, 2, 3, 4)), col_factor(levels = c(1, 2, 3)), 
  col_factor(levels = c(1, 2)), col_factor(levels = c(1, 2, 3)),
  col_integer(), col_integer(), col_integer(), col_integer(),
  col_integer())            
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 200 x 11
##       id female race  ses   schtyp prog   read write  math science socst
##    &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt;  &amp;lt;fct&amp;gt; &amp;lt;fct&amp;gt; &amp;lt;fct&amp;gt;  &amp;lt;fct&amp;gt; &amp;lt;int&amp;gt; &amp;lt;int&amp;gt; &amp;lt;int&amp;gt;   &amp;lt;int&amp;gt; &amp;lt;int&amp;gt;
##  1    70 0      4     1     1      1        57    52    41      47    57
##  2   121 1      4     2     1      3        68    59    53      63    61
##  3    86 0      4     3     1      1        44    33    54      58    31
##  4   141 0      4     3     1      3        63    44    47      53    56
##  5   172 0      4     2     1      2        47    52    57      53    61
##  6   113 0      4     2     1      2        44    52    51      63    61
##  7    50 0      3     2     1      1        50    59    42      53    61
##  8    11 0      1     2     1      2        34    46    45      39    36
##  9    84 0      4     2     1      1        63    57    54      58    51
## 10    48 0      3     2     1      2        57    55    52      50    51
## # ... with 190 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If we do not specify the data type for all columns, &lt;code&gt;readr&lt;/code&gt; will return an
error which leads to the following questions:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;What if I want to skip a few columns?&lt;/li&gt;
&lt;li&gt;What if I want to read certain columns only?&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div id=&#34;specific-columns&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Specific Columns&lt;/h3&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/column_objective_function_map.png&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;For the first scenario, we can use &lt;code&gt;col_skip()&lt;/code&gt; i.e. instead of specifying the
data type, we indicate to &lt;code&gt;readr&lt;/code&gt; to skip that particular column while reading
the data.&lt;/p&gt;
&lt;p&gt;In case of the second scenario, we will use &lt;code&gt;cols_only()&lt;/code&gt; to specify the
columns to be read i.e. instead of using &lt;code&gt;list()&lt;/code&gt; to supply the data types, we
will use &lt;code&gt;cols_only()&lt;/code&gt; and provide the following details:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;column name&lt;/li&gt;
&lt;li&gt;column type using &lt;code&gt;col_types&lt;/code&gt; argument&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;read_csv(&amp;#39;hsb2.csv&amp;#39;, col_types = cols_only(id = col_integer(),
  prog = col_factor(levels = c(1, 2, 3)), read = col_integer())
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 200 x 3
##       id prog   read
##    &amp;lt;int&amp;gt; &amp;lt;fct&amp;gt; &amp;lt;int&amp;gt;
##  1    70 1        57
##  2   121 3        68
##  3    86 1        44
##  4   141 3        63
##  5   172 2        47
##  6   113 2        44
##  7    50 1        50
##  8    11 2        34
##  9    84 1        63
## 10    48 2        57
## # ... with 190 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you have a data set with 10 columns and plan to skip only a couple of
columns, use &lt;code&gt;col_skip()&lt;/code&gt; instead if you plan to read only a couple of
columns, use &lt;code&gt;cols_only()&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Summary&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/img/import_funca.png&#34; width=&#34;80%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;summary-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;In this post, we explored:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;reading data from flat/delimited files&lt;/li&gt;
&lt;li&gt;indicating the presence/absence of column names&lt;/li&gt;
&lt;li&gt;skipping rows in the presence of text/information&lt;/li&gt;
&lt;li&gt;specifying maximum rows to be read&lt;/li&gt;
&lt;li&gt;specifying column data types&lt;/li&gt;
&lt;li&gt;skipping columns&lt;/li&gt;
&lt;li&gt;reading specific columns only&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the next post, we will explore reading data from excel spreadsheets and other statistical softwares.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;references&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://readr.tidyverse.org/&#34; class=&#34;uri&#34;&gt;https://readr.tidyverse.org/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://r4ds.had.co.nz/data-import.html&#34; class=&#34;uri&#34;&gt;http://r4ds.had.co.nz/data-import.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>ggplot2: Themes</title>
      <link>https://blog.rsquaredacademy.com/themes/</link>
      <pubDate>Mon, 07 May 2018 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/themes/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;This is the last post in the series &lt;strong&gt;Elegant Data Visualization with ggplot2&lt;/strong&gt;.
In the previous post, we learnt to combine multiple plots. In this post, we
will learn to modify the appearance of all non data components of the plot such
as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;axis&lt;/li&gt;
&lt;li&gt;legend&lt;/li&gt;
&lt;li&gt;panel&lt;/li&gt;
&lt;li&gt;plot area&lt;/li&gt;
&lt;li&gt;background&lt;/li&gt;
&lt;li&gt;margin&lt;/li&gt;
&lt;li&gt;facets&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;We will use the following libraries in this post:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://readr.tidyverse.org/&#34;&gt;readr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://ggplot2.tidyverse.org/&#34;&gt;ggplot2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt; and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/a6722c54610578ddcadaeeaf1df7cbf3&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;basic-plot&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Basic Plot&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;We will continue with the scatter plot examining the relationship between
displacement and miles per gallon from the the mtcars data set.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p &amp;lt;- ggplot(mtcars) +
  geom_point(aes(disp, mpg))
p&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-05-07-ggplot2-themes_files/figure-html/theme1-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;axis&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Axis&lt;/h3&gt;
&lt;div id=&#34;text&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Text&lt;/h4&gt;
&lt;hr&gt;
&lt;p&gt;The &lt;code&gt;axis.title.x&lt;/code&gt; argument can be used to modify the appearance of the &lt;code&gt;X&lt;/code&gt;
axis. In the below example, we modify the color and size of the title using
the &lt;code&gt;element_text()&lt;/code&gt; function. Remember, whenever you are trying to modify the
appearance of a theme element which is a text, you must use &lt;code&gt;element_text()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;You can use &lt;code&gt;axis.title.y&lt;/code&gt; to modify the &lt;code&gt;Y&lt;/code&gt; axis title and to modify the
title of both the axis together, use &lt;code&gt;axis.title&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p + theme(axis.title.x = element_text(color = &amp;quot;red&amp;quot;, size = 10, face = &amp;quot;italic&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-05-07-ggplot2-themes_files/figure-html/theme2-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;ticks&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Ticks&lt;/h4&gt;
&lt;hr&gt;
&lt;p&gt;To modify the appearance of the axis ticks, use the &lt;code&gt;axis.ticks&lt;/code&gt; argument. You can
change the color, size, linetype and length of the ticks using the &lt;code&gt;element_line()&lt;/code&gt;
function as shown below.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p + theme(axis.ticks = element_line(color = &amp;#39;blue&amp;#39;, size = 1.25, linetype = 2), 
          axis.ticks.length = unit(1, &amp;quot;cm&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-05-07-ggplot2-themes_files/figure-html/theme5-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;line&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Line&lt;/h4&gt;
&lt;hr&gt;
&lt;p&gt;The &lt;code&gt;axis.line&lt;/code&gt; argument should be used to modify the appearance of the
axis lines. You can change the color, size and linetype of the line using
the &lt;code&gt;element_line()&lt;/code&gt; function.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p + theme(axis.line = element_line(color = &amp;#39;red&amp;#39;, size = 1.5, linetype = 3))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-05-07-ggplot2-themes_files/figure-html/theme6-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;legend&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Legend&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;Now, let us look at modifying the non-data components of a legend.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p &amp;lt;- ggplot(mtcars) +
  geom_point(aes(disp, mpg, color = factor(cyl), shape = factor(gear)))
p&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-05-07-ggplot2-themes_files/figure-html/theme7-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;div id=&#34;background&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Background&lt;/h4&gt;
&lt;hr&gt;
&lt;p&gt;The background of the legend can be modified using the &lt;code&gt;legend.background&lt;/code&gt;
argument. You can change the background color, the border color and line type
using &lt;code&gt;element_rect()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p + theme(legend.background = element_rect(fill = &amp;#39;gray&amp;#39;, linetype = 3,  
          color = &amp;quot;black&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-05-07-ggplot2-themes_files/figure-html/theme30-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;text-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Text&lt;/h4&gt;
&lt;hr&gt;
&lt;p&gt;The appearance of the text can be modified using the &lt;code&gt;legend.text&lt;/code&gt; argument.
You can change the color, size and font using the &lt;code&gt;element_text()&lt;/code&gt; function.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p + theme(legend.text = element_text(color = &amp;#39;green&amp;#39;, face = &amp;#39;italic&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-05-07-ggplot2-themes_files/figure-html/theme34-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;title&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Title&lt;/h4&gt;
&lt;hr&gt;
&lt;p&gt;The appearance fo the title of the legend can be modified using the
&lt;code&gt;legend.title&lt;/code&gt; argument. You can change the color, size, font and alignment
using &lt;code&gt;element_text()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p + theme(legend.title = element_text(color = &amp;#39;blue&amp;#39;, face = &amp;#39;bold&amp;#39;),
          legend.title.align = 0.1)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-05-07-ggplot2-themes_files/figure-html/theme35-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;position&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Position&lt;/h4&gt;
&lt;hr&gt;
&lt;p&gt;The position and direction of the legend can be changed using:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;legend.position&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;and &lt;code&gt;legend.direction&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;p + theme(legend.position = &amp;quot;top&amp;quot;, legend.direction = &amp;quot;horizontal&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-05-07-ggplot2-themes_files/figure-html/theme36-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;themes&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Themes&lt;/h3&gt;
&lt;div id=&#34;classic-dark-on-light&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Classic Dark on Light&lt;/h4&gt;
&lt;hr&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) +
  theme_bw()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-05-07-ggplot2-themes_files/figure-html/theme17-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;default-gray&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Default Gray&lt;/h4&gt;
&lt;hr&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) +
  theme_gray()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-05-07-ggplot2-themes_files/figure-html/theme18-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;light&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Light&lt;/h4&gt;
&lt;hr&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) +
  theme_light()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-05-07-ggplot2-themes_files/figure-html/theme19-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;minimal&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Minimal&lt;/h4&gt;
&lt;hr&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) +
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-05-07-ggplot2-themes_files/figure-html/theme20-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;dark&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Dark&lt;/h4&gt;
&lt;hr&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) +
  theme_dark()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-05-07-ggplot2-themes_files/figure-html/theme21-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;classic&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Classic&lt;/h4&gt;
&lt;hr&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) +
  theme_classic()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-05-07-ggplot2-themes_files/figure-html/theme22-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;void-empty&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Void (Empty)&lt;/h4&gt;
&lt;hr&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) +
  theme_void()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-05-07-ggplot2-themes_files/figure-html/theme23-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;In this post, we learnt to modify the appearance of all non data components
of a plot and about the different themes available in ggplot2. This brings us
to the end of the series &lt;strong&gt;Elegant Data Visualization with ggplot2&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>ggplot2: Faceting</title>
      <link>https://blog.rsquaredacademy.com/faceting/</link>
      <pubDate>Wed, 25 Apr 2018 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/faceting/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;This is the 19th post in the series &lt;strong&gt;Elegant Data Visualization with ggplot2&lt;/strong&gt;.
In the previous post, we learnt to modify the title, label and bar of a legend.
In this post, we will learn about faceting i.e. combining plots.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;We will use the following libraries in this post:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://readr.tidyverse.org/&#34;&gt;readr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://ggplot2.tidyverse.org/&#34;&gt;ggplot2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt; and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/733381d6b5773e1007a097aeca0f8f4d&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;faceting---intro&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Faceting - Intro&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;Let us continue with the scatter plot examining the relationship between
displacement and miles per gallon but let us make one additional change.
We now want 3 sub plots for each type of cylinder. How can we do this? We can
split or group the data by cylinder type and plot the subset of data which
means dealing with 3 different data sets, plotting 3 plots and arranging them
for comparison. ggplot2 offers the following 2 functions which allow us to plot
subset of data with a simple formula based interface:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;facet_grid()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;facet_wrap()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Faceting allows us to create multiple sub plots. It partitions a plot into a
matrix of panels with each panel showing a different subset of data.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;vertical&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Vertical&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;&lt;code&gt;facet_grid()&lt;/code&gt; allows us to split up the data by one or two discrete variables
and create sub plots. The sub plots can be arranged horizontally or vertically
using a formula of the form &lt;code&gt;vertical ~ horizontal&lt;/code&gt;. In the below example, 3
sub plots are created, one each for the levels of the &lt;code&gt;cyl&lt;/code&gt; variable and
the sub plots are arranged vertically&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(disp, mpg)) + 
  geom_point() +
  facet_grid(cyl ~ .)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-25-ggplot2-facets-combine-multiple-plots_files/figure-html/facet2-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;horizontal&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Horizontal&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;Below we reproduce the previous example but arrange the sub plots horizontally.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(disp, mpg)) + 
  geom_point() +
  facet_grid(. ~ cyl)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-25-ggplot2-facets-combine-multiple-plots_files/figure-html/facet1-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;vertical-horizontal&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Vertical &amp;amp; Horizontal&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;In certain cases, we might want different discrete variables to represent the
horizontal and vertical direction. In the below example, we examine the
relationship between displacement and miles per gallon for different combinations
of &lt;code&gt;cyl&lt;/code&gt; and &lt;code&gt;gear&lt;/code&gt; variables.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(disp, mpg)) + 
  geom_point() +
  facet_grid(cyl ~ gear)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-25-ggplot2-facets-combine-multiple-plots_files/figure-html/facet3-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Below, we switch the variables representing the vertical and horizontal
directions.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(disp, mpg)) + 
  geom_point() +
  facet_grid(gear ~ cyl)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-25-ggplot2-facets-combine-multiple-plots_files/figure-html/facet4-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;scales&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Scales&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;If you carefully observe the second example, the range of &lt;code&gt;X&lt;/code&gt; axis is same for
all the 3 sub plots i.e. it is a fixed range. You can allow each of the sub
plots to have different range using the &lt;code&gt;scales&lt;/code&gt; argument and supplying it the
value &lt;code&gt;&#39;free&#39;&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(disp, mpg, color = factor(cyl))) +
  geom_point() + 
  facet_grid(. ~ cyl, scales = &amp;quot;free&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-25-ggplot2-facets-combine-multiple-plots_files/figure-html/facet5-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Now, each of the sub plot has a different range.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;switch-labels&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Switch Labels&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;In the third example, the labels are displayed at the bottom for &lt;code&gt;X&lt;/code&gt; axis and
at the right for the &lt;code&gt;Y&lt;/code&gt; axis. It can be changed using the &lt;code&gt;switch&lt;/code&gt; argument
and supplying the value &lt;code&gt;&#39;both&#39;&lt;/code&gt;. The labels will now be displayed at the top
for the &lt;code&gt;X&lt;/code&gt; axis and at left for the &lt;code&gt;Y&lt;/code&gt; axis. If you just want to change the
labels for a particular axis, use the values &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt; for the &lt;code&gt;X&lt;/code&gt; and &lt;code&gt;Y&lt;/code&gt;
axis respectively.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(disp, mpg)) + 
  geom_point() + 
  facet_grid(cyl ~ gear, switch = &amp;quot;both&amp;quot;) &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-25-ggplot2-facets-combine-multiple-plots_files/figure-html/facet6-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;wrap&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Wrap&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;&lt;code&gt;facet_wrap()&lt;/code&gt; allows us to arrange sub plots in a certain number of rows and
columns. In the below example, we will use &lt;code&gt;facet_wrap()&lt;/code&gt; to arrange the sub
plots in a single row.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(disp, mpg)) +
  geom_point() +
  facet_wrap(~cyl)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-25-ggplot2-facets-combine-multiple-plots_files/figure-html/facet7-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;specify-rows&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Specify Rows&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;To arrange the sub plots in a specific number of rows, use the &lt;code&gt;nrow&lt;/code&gt; argument.
In the below example, we arrange the sub plots in 2 rows.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(disp, mpg)) +
  geom_point() +
  facet_wrap(~cyl, nrow = 2)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-25-ggplot2-facets-combine-multiple-plots_files/figure-html/facet8-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;specify-columns&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Specify Columns&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;Here, we arrange the sub plots in 3 columns instead of rows using the &lt;code&gt;ncol&lt;/code&gt;
argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(disp, mpg)) +
  geom_point() +
  facet_wrap(~cyl, ncol = 3)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-25-ggplot2-facets-combine-multiple-plots_files/figure-html/facet9-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;scales-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Scales&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;You can allow each of the sub plots to have different range using the &lt;code&gt;scales&lt;/code&gt;
argument and supplying it the value &lt;code&gt;&#39;free&#39;&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(disp, mpg)) +
  geom_point() +
  facet_wrap(~cyl, scales = &amp;quot;free&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-25-ggplot2-facets-combine-multiple-plots_files/figure-html/facet12-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;rows-columns&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Rows &amp;amp; Columns&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;If 2 discrete variables are used to create the sub plots, we can either use
the formula interface to specify the variables as shown below&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(disp, mpg)) +
  geom_point() +
  facet_wrap(~cyl + gear, nrow = 2)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-25-ggplot2-facets-combine-multiple-plots_files/figure-html/facet10-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;or use a character vector of variable names.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(disp, mpg)) +
  geom_point() +
  facet_wrap(c(&amp;quot;cyl&amp;quot;, &amp;quot;gear&amp;quot;), ncol = 2)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-25-ggplot2-facets-combine-multiple-plots_files/figure-html/facet11-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;In this post, we learnt to create sub plots using:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;facet_grid()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;facet_wrap()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;up-next..&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Up Next..&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;In the next post, we will learn to modify the theme of a plot.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>ggplot2: Legend - Part 6</title>
      <link>https://blog.rsquaredacademy.com/legend-part-6/</link>
      <pubDate>Fri, 13 Apr 2018 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/legend-part-6/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;This is the 18th post in the series &lt;strong&gt;Elegant Data Visualization with ggplot2&lt;/strong&gt;.
In the previous post, we learnt how to modify the legend of plot when &lt;code&gt;alpha&lt;/code&gt;
is mapped to a categorical variable. In this post, we will learn to modify legend&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;title&lt;/li&gt;
&lt;li&gt;label&lt;/li&gt;
&lt;li&gt;and bar&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So far, we have learnt to modify the components of a legend using &lt;code&gt;scale_*&lt;/code&gt;
family of functions. Now, we will use the &lt;code&gt;guide&lt;/code&gt; argument and supply it
values using the &lt;code&gt;guide_legend()&lt;/code&gt; function.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;We will use the following libraries in this post:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://readr.tidyverse.org/&#34;&gt;readr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://ggplot2.tidyverse.org/&#34;&gt;ggplot2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt; and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/a77a836e7e06c61c28ba7db3a69e1510&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;title&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Title&lt;/h3&gt;
&lt;div id=&#34;title-alignment&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Title Alignment&lt;/h4&gt;
&lt;hr&gt;
&lt;p&gt;The horizontal alignment of the title can be managed using the &lt;code&gt;title.hjust&lt;/code&gt;
argument. It can take any value between &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;0 (left)&lt;/li&gt;
&lt;li&gt;1 (right)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the below example, we align the title to the center by assigning the value
&lt;code&gt;0.5&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) + geom_point(aes(disp, mpg, color = factor(cyl))) +
  scale_color_manual(values = c(&amp;quot;red&amp;quot;, &amp;quot;blue&amp;quot;, &amp;quot;green&amp;quot;),
    guide = guide_legend(title = &amp;quot;Cylinders&amp;quot;, title.hjust = 0.5))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-13-legend-part-6_files/figure-html/leg2-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;title-alignment-vertical&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Title Alignment (Vertical)&lt;/h4&gt;
&lt;hr&gt;
&lt;p&gt;To manage the vertical alignment of the title, use &lt;code&gt;title.vjust&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) + geom_point(aes(disp, mpg, color = hp)) +
  scale_color_continuous(guide = guide_colorbar(
    title = &amp;quot;Horsepower&amp;quot;, title.position = &amp;quot;top&amp;quot;, title.vjust = 1))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-13-legend-part-6_files/figure-html/leg22-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;title-position&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Title Position&lt;/h4&gt;
&lt;hr&gt;
&lt;p&gt;The position of the title can be managed using &lt;code&gt;title.posiiton&lt;/code&gt; argument. It
can be positioned at:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;top&lt;/li&gt;
&lt;li&gt;bottom&lt;/li&gt;
&lt;li&gt;left&lt;/li&gt;
&lt;li&gt;right&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) + geom_point(aes(disp, mpg, color = factor(cyl))) +
  scale_color_manual(values = c(&amp;quot;red&amp;quot;, &amp;quot;blue&amp;quot;, &amp;quot;green&amp;quot;),
    guide = guide_legend(title = &amp;quot;Cylinders&amp;quot;, title.hjust = 0.5, 
      title.position = &amp;quot;top&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-13-legend-part-6_files/figure-html/leg3-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;label&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Label&lt;/h2&gt;
&lt;div id=&#34;label-position&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Label Position&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;The position of the label can be managed using the &lt;code&gt;label.position&lt;/code&gt; argument.
It can be positioned at:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;top&lt;/li&gt;
&lt;li&gt;bottom&lt;/li&gt;
&lt;li&gt;left&lt;/li&gt;
&lt;li&gt;right&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the below example, we position the label at right.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) + geom_point(aes(disp, mpg, color = factor(cyl))) +
  scale_color_manual(values = c(&amp;quot;red&amp;quot;, &amp;quot;blue&amp;quot;, &amp;quot;green&amp;quot;),
    guide = guide_legend(label.position = &amp;quot;right&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-13-legend-part-6_files/figure-html/leg4-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;label-alignment&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Label Alignment&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;The horizontal alignment of the label can be managed using the &lt;code&gt;label.hjust&lt;/code&gt;
argument. It can take any value between &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;0 (left)&lt;/li&gt;
&lt;li&gt;1 (right)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the below example, we align the label to the center by assigning the value
&lt;code&gt;0.5&lt;/code&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;alignment
&lt;ul&gt;
&lt;li&gt;0 (left)&lt;/li&gt;
&lt;li&gt;1 (right)&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) + geom_point(aes(disp, mpg, color = factor(cyl))) +
  scale_color_manual(values = c(&amp;quot;red&amp;quot;, &amp;quot;blue&amp;quot;, &amp;quot;green&amp;quot;),
    guide = guide_legend(label.hjust = 0.5))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-13-legend-part-6_files/figure-html/leg5-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;div id=&#34;labels-alignment-vertical&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Labels Alignment (Vertical)&lt;/h4&gt;
&lt;hr&gt;
&lt;p&gt;The vertical alignment of the label can be managed using the &lt;code&gt;label.vjust&lt;/code&gt;
argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, color = hp)) +
  scale_color_continuous(guide = guide_colorbar(
    label.vjust = 0.8))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-13-legend-part-6_files/figure-html/leg23-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;direction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Direction&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;The direction of the label can be either horizontal or veritcal and it can be
set using the &lt;code&gt;direction&lt;/code&gt; argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) + geom_point(aes(disp, mpg, color = factor(cyl))) +
  scale_color_manual(values = c(&amp;quot;red&amp;quot;, &amp;quot;blue&amp;quot;, &amp;quot;green&amp;quot;),
    guide = guide_legend(direction = &amp;quot;horizontal&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-13-legend-part-6_files/figure-html/leg6-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;rows&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Rows&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;The label can be spread across multiple rows using the &lt;code&gt;nrow&lt;/code&gt; argument. In the
below example, the label is spread across 2 rows.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) + geom_point(aes(disp, mpg, color = factor(cyl))) +
  scale_color_manual(values = c(&amp;quot;red&amp;quot;, &amp;quot;blue&amp;quot;, &amp;quot;green&amp;quot;),
    guide = guide_legend(nrow = 2))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-13-legend-part-6_files/figure-html/leg7-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;reverse&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Reverse&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;The order of the labels can be reversed using the &lt;code&gt;reverse&lt;/code&gt; argument. We need
to supply logical values i.e. either &lt;code&gt;TRUE&lt;/code&gt; or &lt;code&gt;FALSE&lt;/code&gt;. If &lt;code&gt;TRUE&lt;/code&gt;, the order
will be reversed.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) + geom_point(aes(disp, mpg, color = factor(cyl))) +
  scale_color_manual(values = c(&amp;quot;red&amp;quot;, &amp;quot;blue&amp;quot;, &amp;quot;green&amp;quot;),
    guide = guide_legend(reverse = TRUE))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-13-legend-part-6_files/figure-html/leg8-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;putting-it-all-together&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Putting it all together…&lt;/h3&gt;
&lt;hr&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) + geom_point(aes(disp, mpg, color = factor(cyl))) +
  scale_color_manual(values = c(&amp;quot;red&amp;quot;, &amp;quot;blue&amp;quot;, &amp;quot;green&amp;quot;),
    guide = guide_legend(title = &amp;quot;Cylinders&amp;quot;, title.hjust = 0.5, 
      title.position = &amp;quot;top&amp;quot;, label.position = &amp;quot;right&amp;quot;, 
      direction = &amp;quot;horizontal&amp;quot;, label.hjust = 0.5, nrow = 2, reverse = TRUE)
  )&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-13-legend-part-6_files/figure-html/leg20-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;legend-bar&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Legend Bar&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;So far we have looked at modifying components of the legend when it acts as a
guide for &lt;code&gt;color&lt;/code&gt;, &lt;code&gt;fill&lt;/code&gt; or &lt;code&gt;shape&lt;/code&gt; i.e. when the aesthetics have been mapped
to a categorical variable. In this section, you will learn about
&lt;code&gt;guide_colorbar()&lt;/code&gt; which will allow us to modify the legend when the aesthetics
are mapped to a continuous variable.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;plot&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Plot&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;Let us start with a scatter plot examining the relationship between displacement
and miles per gallon from the mtcars data set. We will map the color of the points
to the &lt;code&gt;hp&lt;/code&gt; variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, color = hp))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-13-legend-part-6_files/figure-html/leg36-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;width&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Width&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;The width of the bar can be modified using the &lt;code&gt;barwidth&lt;/code&gt; argument. It is used
inside the &lt;code&gt;guide_colorbar()&lt;/code&gt; function which itself is supplied to the &lt;code&gt;guide&lt;/code&gt;
argument of &lt;code&gt;scale_color_continuous()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, color = hp)) +
  scale_color_continuous(guide = guide_colorbar(
    barwidth = 10))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-13-legend-part-6_files/figure-html/leg24-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;height&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Height&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;Similarly, the height of the bar can be modified using the &lt;code&gt;barheight&lt;/code&gt; argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, color = hp)) +
  scale_color_continuous(guide = guide_colorbar(
    barheight = 3))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-13-legend-part-6_files/figure-html/leg25-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;bins&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Bins&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;The &lt;code&gt;nbin&lt;/code&gt; argument allows us to specify the number of bins in the bar.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, color = hp)) +
  scale_color_continuous(guide = guide_colorbar(
    nbin = 4))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-13-legend-part-6_files/figure-html/leg26-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;ticks&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Ticks&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;The ticks of the bar can be removed using the &lt;code&gt;ticks&lt;/code&gt; argument and setting it
to &lt;code&gt;FALSE&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, color = hp)) +
  scale_color_continuous(guide = guide_colorbar(
    ticks = FALSE))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-13-legend-part-6_files/figure-html/leg28-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;upperlower-limits&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Upper/Lower Limits&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;The upper and lower limits of the bars can be drawn or undrawn using the
&lt;code&gt;draw.ulim&lt;/code&gt; and &lt;code&gt;draw.llim&lt;/code&gt; arguments. They both accept logical values.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, color = hp)) +
  scale_color_continuous(guide = guide_colorbar(
    draw.ulim = TRUE, draw.llim = FALSE))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-13-legend-part-6_files/figure-html/leg29-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;guides-color-shape-size&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Guides: Color, Shape &amp;amp; Size&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;The &lt;code&gt;guides()&lt;/code&gt; function can be used to create multiple legends to act as a
guide for &lt;code&gt;color&lt;/code&gt;, &lt;code&gt;shape&lt;/code&gt;, &lt;code&gt;size&lt;/code&gt; etc. as shown below. First, we map color,
shape and size to different variables. Next, in the &lt;code&gt;guides()&lt;/code&gt; function, we
supply values to each of the above aesthetics to indicate the type of legend.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, color = hp, 
    size = qsec, shape = factor(gear))) + 
  guides(color = &amp;quot;colorbar&amp;quot;, shape = &amp;quot;legend&amp;quot;, size = &amp;quot;legend&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-13-legend-part-6_files/figure-html/leg34-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;guides-title&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Guides: Title&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;To modify the components of the different legends, we must use the
&lt;code&gt;guide_*&lt;/code&gt; family of functions. In the below example, we use &lt;code&gt;guide_colorbar()&lt;/code&gt;
for the legend acting as guide for color mapped to a continuous variable and
&lt;code&gt;guide_legend()&lt;/code&gt; for the legends acting as guide for shape/size mapped to
categorical variables.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, color = hp, size = wt, shape = factor(gear))) + 
  guides(color = guide_colorbar(title = &amp;quot;Horsepower&amp;quot;),
    shape = guide_legend(title = &amp;quot;Weight&amp;quot;), size = guide_legend(title = &amp;quot;Gear&amp;quot;)
  )&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-13-legend-part-6_files/figure-html/leg35-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;In this post, we will learn to modify legend&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;title&lt;/li&gt;
&lt;li&gt;label&lt;/li&gt;
&lt;li&gt;and bar&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;up-next..&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Up Next..&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;In the next post, we will learn faceting.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>ggplot2: Legend - Part 5</title>
      <link>https://blog.rsquaredacademy.com/legend-part-5/</link>
      <pubDate>Sun, 01 Apr 2018 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/legend-part-5/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;This is the 17th post in the series &lt;strong&gt;Elegant Data Visualization with ggplot2&lt;/strong&gt;.
In the previous post, we learnt how to modify the legend of plot when &lt;code&gt;size&lt;/code&gt; is
mapped to continuous variable. In this post, we will learn to modify the
following using &lt;code&gt;scale_alpha_continuous()&lt;/code&gt; when &lt;code&gt;alpha&lt;/code&gt; or transparency is
mapped to variables:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;title&lt;/li&gt;
&lt;li&gt;breaks&lt;/li&gt;
&lt;li&gt;limits&lt;/li&gt;
&lt;li&gt;range&lt;/li&gt;
&lt;li&gt;labels&lt;/li&gt;
&lt;li&gt;values&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;We will use the following libraries in this post:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://readr.tidyverse.org/&#34;&gt;readr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://ggplot2.tidyverse.org/&#34;&gt;ggplot2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt; and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/ae9f6afd3c4818b3778ea008da7d2e92&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;plot&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Plot&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;Let us start with a scatter plot examining the relationship between displacement
and miles per gallon from the mtcars data set. We will map the transparency of
the points to the &lt;code&gt;hp&lt;/code&gt; variable. Remember, &lt;code&gt;alpha&lt;/code&gt; must always be mapped to a
continuous variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, alpha = hp), color = &amp;#39;blue&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-01-legend-part-5_files/figure-html/leg2-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As you can see, the legend acts as a guide for the &lt;code&gt;alpha&lt;/code&gt; aesthetic. Now, let
us learn to modify the different aspects of the legend.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;title&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Title&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;The title of the legend (&lt;code&gt;hp&lt;/code&gt;) is not very intuitive. If the user does
not know the underlying data, they will not be able to make any sense out of it.
Let us change it to &lt;code&gt;Horsepower&lt;/code&gt; using the &lt;code&gt;name&lt;/code&gt; argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, alpha = hp), color = &amp;#39;blue&amp;#39;) +
  scale_alpha_continuous(&amp;quot;Horsepower&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-01-legend-part-5_files/figure-html/leg3-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;breaks&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Breaks&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;When the range of the variable mapped to size is large, you may not
want the labels in the legend to represent all of them. In such cases, we can
use the breaks argument and specify the labels to be used. In the below case,
we use the &lt;code&gt;breaks&lt;/code&gt; argument to ensure that the labels in legend represent
certain midpoints (125, 200, 275) of the mapped variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, alpha = hp), color = &amp;#39;blue&amp;#39;) +
  scale_alpha_continuous(breaks = c(125, 200, 275))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-01-legend-part-5_files/figure-html/leg4-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;limits&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Limits&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;Let us assume that we want to modify the data to be displayed i.e. instead of
examining the relationship between mileage and displacement for all cars, we
desire to look at only cars whose horsepower is between &lt;code&gt;100&lt;/code&gt; and &lt;code&gt;350&lt;/code&gt;.
One way to approach this would be to filter the data using &lt;code&gt;filter&lt;/code&gt; from dplyr
and then visualize it. Instead, we will use the &lt;code&gt;limits&lt;/code&gt; argument and filter
the data for visualization.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, alpha = hp), color = &amp;#39;blue&amp;#39;) +
  scale_alpha_continuous(limits = c(100, 350))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-01-legend-part-5_files/figure-html/leg5-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;range&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Range&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;The range of the transparency of points can be modified using the &lt;code&gt;range&lt;/code&gt;
argument. We need to specify a lower and upper range using a numeric vector.
In the below example, we use &lt;code&gt;range&lt;/code&gt; and supply the lower and upper limits as
&lt;code&gt;0.4&lt;/code&gt; and &lt;code&gt;0.8&lt;/code&gt;. The transparency of the points will now lie between &lt;code&gt;0.4&lt;/code&gt; and
&lt;code&gt;0.8&lt;/code&gt; only.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, alpha = hp), color = &amp;#39;blue&amp;#39;) +
  scale_alpha_continuous(range = c(0.4, 0.8))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-01-legend-part-5_files/figure-html/leg6-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;labels&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Labels&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;The labels in the legend can be modified using the &lt;code&gt;labels&lt;/code&gt; argument. Let us
change the labels to “1 Hundred”, “2 Hundred” and “3 Hundred” in the next example.
Ensure that the labels are intuitive and easy to interpret for the end user of
the plot.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, alpha = hp), color = &amp;#39;blue&amp;#39;) +
  scale_alpha_continuous(breaks = c(100, 200, 300),
    labels = c(&amp;quot;1 Hundred&amp;quot;, &amp;quot;2 Hundred&amp;quot;, 
      &amp;quot;3 Hundred&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-01-legend-part-5_files/figure-html/leg7-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;putting-it-all-together&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Putting it all together&lt;/h3&gt;
&lt;hr&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, alpha = hp), color = &amp;#39;blue&amp;#39;) +
  scale_alpha_continuous(&amp;quot;Horsepower&amp;quot;, breaks = c(100, 200, 300),
    limits = c(100, 350), range = c(0.4, 0.8),
    labels = c(&amp;quot;1 Hundred&amp;quot;, &amp;quot;2 Hundred&amp;quot;, &amp;quot;3 Hundred&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-04-01-legend-part-5_files/figure-html/leg8-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;In this post, we learnt to modify the following aspects of legends:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;title&lt;/li&gt;
&lt;li&gt;breaks&lt;/li&gt;
&lt;li&gt;range&lt;/li&gt;
&lt;li&gt;limits&lt;/li&gt;
&lt;li&gt;labels&lt;/li&gt;
&lt;li&gt;values&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;up-next..&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Up Next..&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;In the next post, we will learn how to modify the title, label and bar of the legend.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>ggplot2: Legend - Part 4</title>
      <link>https://blog.rsquaredacademy.com/legend-part-4/</link>
      <pubDate>Tue, 20 Mar 2018 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/legend-part-4/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;This is the 16th post in the series &lt;strong&gt;Elegant Data Visualization with ggplot2&lt;/strong&gt;.
In the previous post, we learnt how to modify the legend of plot when &lt;code&gt;shape&lt;/code&gt;
is mapped to categorical variables. In this post, we will learn to modify the
following using &lt;code&gt;scale_size_continuous&lt;/code&gt; when &lt;code&gt;size&lt;/code&gt; aesthetic is mapped to
variables:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;title&lt;/li&gt;
&lt;li&gt;breaks&lt;/li&gt;
&lt;li&gt;limits&lt;/li&gt;
&lt;li&gt;range&lt;/li&gt;
&lt;li&gt;labels&lt;/li&gt;
&lt;li&gt;values&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;We will use the following libraries in this post:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://readr.tidyverse.org/&#34;&gt;readr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://ggplot2.tidyverse.org/&#34;&gt;ggplot2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt; and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/9c1e4475fe554377bb3b20acf0b71231&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;plot&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Plot&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;Let us start with a scatter plot examining the relationship between displacement
and miles per gallon from the mtcars data set. We will map the size of the points
to the &lt;code&gt;hp&lt;/code&gt; variable. Remember, &lt;code&gt;size&lt;/code&gt; must always be mapped to a continuous
variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, size = hp))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-03-20-legend-part-4_files/figure-html/leg36-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As you can see, the legend acts as a guide for the &lt;code&gt;size&lt;/code&gt; aesthetic. Now, let
us learn to modify the different aspects of the legend.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;title&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Title&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;The title of the legend (&lt;code&gt;hp&lt;/code&gt;) is not very intuitive. If the user does
not know the underlying data, they will not be able to make any sense out of it.
Let us change it to &lt;code&gt;Horsepower&lt;/code&gt; using the &lt;code&gt;name&lt;/code&gt; argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, size = hp)) +
  scale_size_continuous(name = &amp;quot;Horsepower&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-03-20-legend-part-4_files/figure-html/leg37-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;range&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Range&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;The range of the size of points can be modified using the &lt;code&gt;range&lt;/code&gt; argument. We
need to specify a lower and upper range using a numeric vector. In the below
example, we use &lt;code&gt;range&lt;/code&gt; and supply the lower and upper limits as &lt;code&gt;3&lt;/code&gt; and &lt;code&gt;6&lt;/code&gt;.
The size of the points will now lie between &lt;code&gt;3&lt;/code&gt; and &lt;code&gt;6&lt;/code&gt; only.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, size = hp)) +
  scale_size_continuous(range = c(3, 6))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-03-20-legend-part-4_files/figure-html/leg38-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;limits&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Limits&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;Let us assume that we want to modify the data to be displayed i.e. instead of
examining the relationship between mileage and displacement for all cars, we
desire to look at only cars whose horsepower is between &lt;code&gt;100&lt;/code&gt; and &lt;code&gt;350&lt;/code&gt;.
One way to approach this would be to filter the data using &lt;code&gt;filter&lt;/code&gt; from dplyr
and then visualize it. Instead, we will use the &lt;code&gt;limits&lt;/code&gt; argument and filter
the data for visualization.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, size = hp)) +
  scale_size_continuous(limits = c(100, 350))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: Removed 9 rows containing missing values (geom_point).&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-03-20-legend-part-4_files/figure-html/leg39-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;breaks&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Breaks&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;When the range of the variable mapped to size is large, you may not
want the labels in the legend to represent all of them. In such cases, we can
use the breaks argument and specify the labels to be used. In the below case,
we use the &lt;code&gt;breaks&lt;/code&gt; argument to ensure that the labels in legend represent
certain midpoints (125, 200, 275) of the mapped variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, size = hp)) +
  scale_size_continuous(breaks = c(125, 200, 275))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-03-20-legend-part-4_files/figure-html/leg40-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;labels&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Labels&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;The labels in the legend can be modified using the &lt;code&gt;labels&lt;/code&gt; argument. Let us
change the labels to “1 Hundred”, “2 Hundred” and “3 Hundred” in the next example.
Ensure that the labels are intuitive and easy to interpret for the end user of
the plot.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, size = hp)) +
  scale_size_continuous(breaks = c(100, 200, 300),
    labels = c(&amp;quot;1 Hundred&amp;quot;, &amp;quot;2 Hundred&amp;quot;, &amp;quot;3 Hundred&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-03-20-legend-part-4_files/figure-html/leg41-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;putting-it-all-together&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Putting it all together&lt;/h3&gt;
&lt;hr&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, size = hp)) +
  scale_size_continuous(name = &amp;quot;Horsepower&amp;quot;, range = c(3, 6), 
    limits = c(0, 400), breaks = c(100, 200, 300),
    labels = c(&amp;quot;1 Hundred&amp;quot;, &amp;quot;2 Hundred&amp;quot;, &amp;quot;3 Hundred&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-03-20-legend-part-4_files/figure-html/leg42-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;In this post, we learnt to modify the following aspects of legends:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;title&lt;/li&gt;
&lt;li&gt;breaks&lt;/li&gt;
&lt;li&gt;range&lt;/li&gt;
&lt;li&gt;limits&lt;/li&gt;
&lt;li&gt;labels&lt;/li&gt;
&lt;li&gt;values&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;up-next..&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Up Next..&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;In the next post, we will learn to modify the legend when &lt;code&gt;alpha&lt;/code&gt; is mapped to variables.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>ggplot2: Legend - Part 3</title>
      <link>https://blog.rsquaredacademy.com/legend-part-3/</link>
      <pubDate>Thu, 08 Mar 2018 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/legend-part-3/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;This is the 15th post in the series &lt;strong&gt;Elegant Data Visualization with ggplot2&lt;/strong&gt;.
In the previous post, we learnt how to modify the legend of plots when
aesthetics are mapped to variables..In this post, we will learn to modify the
following using &lt;code&gt;scale_shape_manual&lt;/code&gt; when &lt;code&gt;shape&lt;/code&gt; is mapped to categorical
variables:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;title&lt;/li&gt;
&lt;li&gt;breaks&lt;/li&gt;
&lt;li&gt;limits&lt;/li&gt;
&lt;li&gt;labels&lt;/li&gt;
&lt;li&gt;values&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;We will use the following libraries in this post:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://readr.tidyverse.org/&#34;&gt;readr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://ggplot2.tidyverse.org/&#34;&gt;ggplot2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt; and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/446c78bd5cb4a6cb546bd440bc357140&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;plot&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Plot&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;Let us start with a scatter plot examining the relationship between displacement
and miles per gallon from the mtcars data set. We will map the shape of the points
to the &lt;code&gt;cyl&lt;/code&gt; variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, shape = factor(cyl)))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-03-08-legend-part-3_files/figure-html/leg29-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As you can see, the legend acts as a guide for the &lt;code&gt;shape&lt;/code&gt; aesthetic. Now, let
us learn to modify the different aspects of the legend.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;title&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Title&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;The title of the legend (&lt;code&gt;factor(cyl)&lt;/code&gt;) is not very intuitive. If the user does
not know the underlying data, they will not be able to make any sense out of it.
Let us change it to &lt;code&gt;Cylinders&lt;/code&gt; using the &lt;code&gt;name&lt;/code&gt; argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, shape = factor(cyl))) +
  scale_shape_manual(name = &amp;quot;Cylinders&amp;quot;, values = c(4, 12, 24))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-03-08-legend-part-3_files/figure-html/leg30-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;If you have mapped shape/size to a discrete variable which has less than six
categories, you can use &lt;code&gt;scale_shape()&lt;/code&gt;.&lt;/p&gt;
&lt;hr&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, shape = factor(cyl))) +
  scale_shape(name = &amp;#39;Cylinders&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-03-08-legend-part-3_files/figure-html/leg51-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;values&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Values&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;To change the default shapes in the legend, use the &lt;code&gt;values&lt;/code&gt; argument and
supply a numeric vector of shapes. The number of shapes specified
must be equal to the number of levels in the categorical variable mapped.
In the below example, &lt;code&gt;cyl&lt;/code&gt; has 3 levels (4, 6, 8) and hence we have specified
3 different shapes.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, shape = factor(cyl))) +
  scale_shape_manual(values = c(4, 12, 24))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-03-08-legend-part-3_files/figure-html/leg31-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;labels&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Labels&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;The labels in the legend can be modified using the &lt;code&gt;labels&lt;/code&gt; argument. Let us
change the labels to &lt;code&gt;Four&lt;/code&gt;, &lt;code&gt;Six&lt;/code&gt; and &lt;code&gt;Eight&lt;/code&gt; in the next example. Ensure that
the labels are intuitive and easy to interpret for the end user of the plot.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, shape = factor(cyl))) +
  scale_shape_manual(values = c(4, 12, 24), labels = c(&amp;#39;Four&amp;#39;, &amp;#39;Six&amp;#39;, &amp;#39;Eight&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-03-08-legend-part-3_files/figure-html/leg32-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;limits&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Limits&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;Let us assume that we want to modify the data to be displayed i.e. instead of
examining the relationship between mileage and displacement for all cars, we
desire to look at only cars with at least 6 cylinders. One way to approach this
would be to filter the data using &lt;code&gt;filter&lt;/code&gt; from dplyr and then visualize it.
Instead, we will use the &lt;code&gt;limits&lt;/code&gt; argument and filter the data for visualization.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, shape = factor(cyl))) +
  scale_shape_manual(values = c(4, 24), limits = c(6, 8))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: Removed 11 rows containing missing values (geom_point).&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-03-08-legend-part-3_files/figure-html/leg33-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As you can see above, &lt;code&gt;ggplot2&lt;/code&gt; returns a warning message indicating data related
to 4 cylinders has been dropped. If you observe the legend, it now represents
only 4 and 6 cylinders.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;breaks&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Breaks&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;When there are large number of levels in the mapped variable, you may not
want the labels in the legend to represent all of them. In such cases, we can
use the breaks argument and specify the labels to be used. In the below case,
we use the &lt;code&gt;breaks&lt;/code&gt; argument to ensure that the labels in legend represent
two levels (4, 8) of the mapped variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, shape = factor(cyl))) +
  scale_shape_manual(values = c(4, 12, 24), breaks = c(4, 8))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-03-08-legend-part-3_files/figure-html/leg34-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;putting-it-all-together&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Putting it all together&lt;/h3&gt;
&lt;hr&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, shape = factor(cyl))) +
  scale_shape_manual(name = &amp;quot;Cylinders&amp;quot;, labels = c(&amp;#39;Six&amp;#39;, &amp;#39;Eight&amp;#39;),  
     values = c(4, 24), limits = c(6, 8), breaks = c(6, 8))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: Removed 11 rows containing missing values (geom_point).&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-03-08-legend-part-3_files/figure-html/leg35-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;In this post, we learnt to modify the following aspects of legends:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;title&lt;/li&gt;
&lt;li&gt;breaks&lt;/li&gt;
&lt;li&gt;limits&lt;/li&gt;
&lt;li&gt;labels&lt;/li&gt;
&lt;li&gt;values&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;up-next..&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Up Next..&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;In the next post, we will learn how to modify the legend when &lt;code&gt;size&lt;/code&gt; is mapped to variables.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>ggplot2: Legend - Part 2</title>
      <link>https://blog.rsquaredacademy.com/legend-part-2/</link>
      <pubDate>Sat, 24 Feb 2018 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/legend-part-2/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;This is the 14th post in the series &lt;strong&gt;Elegant Data Visualization with ggplot2&lt;/strong&gt;.
In the previous post, we learnt how to modify the legend of plots when
aesthetics are mapped to variables. In this post, we will continue to explore
different ways to modify/customize the legend of plots.&lt;/p&gt;
&lt;p&gt;Specifically, we will learn to modify the following using &lt;code&gt;scale_fill_manual()&lt;/code&gt;
when &lt;code&gt;fill&lt;/code&gt; is mapped to categorical variables:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;title&lt;/li&gt;
&lt;li&gt;breaks&lt;/li&gt;
&lt;li&gt;limits&lt;/li&gt;
&lt;li&gt;labels&lt;/li&gt;
&lt;li&gt;values&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;We will use the following libraries in this post:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://readr.tidyverse.org/&#34;&gt;readr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://ggplot2.tidyverse.org/&#34;&gt;ggplot2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt; and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/ef2b665173cf7cfe17093f3dcb052035&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;plot&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Plot&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;Let us start with a scatter plot examining the relationship between
displacement and miles per gallon from the mtcars data set. We will map &lt;code&gt;fill&lt;/code&gt;
to the &lt;code&gt;cyl&lt;/code&gt; variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, fill = factor(cyl)), shape = 22)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-02-24-guides-legends-part-2_files/figure-html/leg22-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As you can see, the legend acts as a guide for the &lt;code&gt;color&lt;/code&gt; aesthetic. Now, let
us learn to modify the different aspects of the legend.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;title&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Title&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;The title of the legend (&lt;code&gt;factor(cyl)&lt;/code&gt;) is not very intuitive. If the user
does not know the underlying data, they will not be able to make any sense out
of it. Let us change it to &lt;code&gt;Cylinders&lt;/code&gt; using the &lt;code&gt;name&lt;/code&gt; argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, fill = factor(cyl)), shape = 22) +
  scale_fill_manual(name = &amp;quot;Cylinders&amp;quot;, 
    values = c(&amp;quot;red&amp;quot;, &amp;quot;blue&amp;quot;, &amp;quot;green&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-02-24-guides-legends-part-2_files/figure-html/leg23-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;values&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Values&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;To change the default colors in the legend, use the &lt;code&gt;values&lt;/code&gt; argument and
supply a character vector of color names. The number of colors specified
must be equal to the number of levels in the categorical variable mapped.
In the below example, &lt;code&gt;cyl&lt;/code&gt; has 3 levels (4, 6, 8) and hence we have specified
3 colors.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, fill = factor(cyl)), shape = 22) +
  scale_fill_manual(values = c(&amp;quot;red&amp;quot;, &amp;quot;blue&amp;quot;, &amp;quot;green&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-02-24-guides-legends-part-2_files/figure-html/leg24-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;labels&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Labels&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;The labels in the legend can be modified using the &lt;code&gt;labels&lt;/code&gt; argument. Let us
change the labels to &lt;code&gt;Four&lt;/code&gt;, &lt;code&gt;Six&lt;/code&gt; and &lt;code&gt;Eight&lt;/code&gt; in the next example. Ensure that
the labels are intuitive and easy to interpret for the end user of the plot.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, fill = factor(cyl)), shape = 22) +
  scale_fill_manual(values = c(&amp;quot;red&amp;quot;, &amp;quot;blue&amp;quot;, &amp;quot;green&amp;quot;),
    labels = c(&amp;#39;Four&amp;#39;, &amp;#39;Six&amp;#39;, &amp;#39;Eight&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-02-24-guides-legends-part-2_files/figure-html/leg25-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;limits&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Limits&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;Let us assume that we want to modify the data to be displayed i.e. instead of
examining the relationship between mileage and displacement for all cars, we
desire to look at only cars with at least 6 cylinders. One way to approach this
would be to filter the data using &lt;code&gt;filter&lt;/code&gt; from dplyr and then visualize it.
Instead, we will use the &lt;code&gt;limits&lt;/code&gt; argument and filter the data for visualization.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, fill = factor(cyl)), shape = 22) +
  scale_fill_manual(values = c(&amp;quot;red&amp;quot;, &amp;quot;blue&amp;quot;, &amp;quot;green&amp;quot;),
    limits = c(6, 8))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-02-24-guides-legends-part-2_files/figure-html/leg26-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As you can see above, &lt;code&gt;ggplot2&lt;/code&gt; returns a warning message indicating data related
to 4 cylinders has been dropped. If you observe the legend, it now represents
only 4 and 6 cylinders.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;breaks&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Breaks&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;When there are large number of levels in the mapped variable, you may not
want the labels in the legend to represent all of them. In such cases, we can
use the breaks argument and specify the labels to be used. In the below case,
we use the &lt;code&gt;breaks&lt;/code&gt; argument to ensure that the labels in legend represent
two levels (4, 8) of the mapped variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, fill = factor(cyl)), shape = 22) +
  scale_fill_manual(values = c(&amp;quot;red&amp;quot;, &amp;quot;blue&amp;quot;, &amp;quot;green&amp;quot;),
    breaks = c(4, 8))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-02-24-guides-legends-part-2_files/figure-html/leg27-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;putting-it-all-together&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Putting it all together…&lt;/h3&gt;
&lt;hr&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, fill = factor(cyl)), shape = 22) +
  scale_fill_manual(name = &amp;quot;Cylinders&amp;quot;, values = c(&amp;quot;red&amp;quot;, &amp;quot;blue&amp;quot;, &amp;quot;green&amp;quot;),
    labels = c(&amp;#39;Four&amp;#39;, &amp;#39;Six&amp;#39;, &amp;#39;Eight&amp;#39;), limits = c(4, 6, 8), breaks = c(4, 6, 8))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-02-24-guides-legends-part-2_files/figure-html/leg28-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;In this post, we learnt to modify the following aspects of legends:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;title&lt;/li&gt;
&lt;li&gt;breaks&lt;/li&gt;
&lt;li&gt;limits&lt;/li&gt;
&lt;li&gt;labels&lt;/li&gt;
&lt;li&gt;values&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;up-next..&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Up Next..&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;In the next post, we will learn to modify the legend when &lt;code&gt;shape&lt;/code&gt; is mapped to categorical variables.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>ggplot2: Legend - Part 1</title>
      <link>https://blog.rsquaredacademy.com/legend-part-1/</link>
      <pubDate>Mon, 12 Feb 2018 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/legend-part-1/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;This is the 13th post in the series &lt;strong&gt;Elegant Data Visualization with
ggplot2&lt;/strong&gt;. In the previos post, we learnt how to modify the axis of plots. In
this post, we will focus on modifying the appearance of legend of plots when
the aesthetics are mapped to variables. Specifically, we will learn to modify
the following when &lt;code&gt;color&lt;/code&gt; is mapped to categorical variables:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;title&lt;/li&gt;
&lt;li&gt;breaks&lt;/li&gt;
&lt;li&gt;limits&lt;/li&gt;
&lt;li&gt;labels&lt;/li&gt;
&lt;li&gt;values&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;p&gt;We will use the following libraries in this post:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://readr.tidyverse.org/&#34;&gt;readr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://ggplot2.tidyverse.org/&#34;&gt;ggplot2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt;
and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/f099b954fa8f5a84cd8e5a2a031f91db&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;basic-plot&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Basic Plot&lt;/h3&gt;
&lt;p&gt;Let us start with a scatter plot examining the relationship between displacement
and miles per gallon from the mtcars data set. We will map the color of the points
to the &lt;code&gt;cyl&lt;/code&gt; variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, color = factor(cyl)))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-02-12-ggplot2-guides-legends_files/figure-html/leg15-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As you can see, the legend acts as a guide for the &lt;code&gt;color&lt;/code&gt; aesthetic. Now, let
us learn to modify the different aspects of the legend.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;values&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Values&lt;/h3&gt;
&lt;p&gt;To change the default colors in the legend, use the &lt;code&gt;values&lt;/code&gt; argument and
supply a character vector of color names. The number of colors specified
must be equal to the number of levels in the categorical variable mapped.
In the below example, &lt;code&gt;cyl&lt;/code&gt; has 3 levels (4, 6, 8) and hence we have specified
3 colors.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, color = factor(cyl))) +
  scale_color_manual(values = c(&amp;quot;red&amp;quot;, &amp;quot;blue&amp;quot;, &amp;quot;green&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-02-12-ggplot2-guides-legends_files/figure-html/leg17-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;title&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Title&lt;/h3&gt;
&lt;p&gt;In the previous example, the title of the legend (&lt;code&gt;factor(cyl)&lt;/code&gt;) is not very
intuitive. If the user does not know the underlying data, they will not be able
to make any sense out of it. Let us change it to &lt;code&gt;Cylinders&lt;/code&gt; using the &lt;code&gt;name&lt;/code&gt;
argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, color = factor(cyl))) +
  scale_color_manual(name = &amp;quot;Cylinders&amp;quot;, 
    values = c(&amp;quot;red&amp;quot;, &amp;quot;blue&amp;quot;, &amp;quot;green&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-02-12-ggplot2-guides-legends_files/figure-html/leg16-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Now, the user will know that the different colors represent number of cylinders in
the car.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;limits&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Limits&lt;/h3&gt;
&lt;p&gt;Let us assume that we want to modify the data to be displayed i.e. instead of
examining the relationship between mileage and displacement for all cars, we
desire to look at only cars with at least 6 cylinders. One way to approach this
would be to filter the data using &lt;code&gt;filter&lt;/code&gt; from dplyr and then visualize it.
Instead, we will use the &lt;code&gt;limits&lt;/code&gt; argument and filter the data for visualization.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, color = factor(cyl))) +
  scale_color_manual(values = c(&amp;quot;red&amp;quot;, &amp;quot;blue&amp;quot;, &amp;quot;green&amp;quot;), limits = c(6, 8))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: Removed 11 rows containing missing values (geom_point).&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-02-12-ggplot2-guides-legends_files/figure-html/leg18-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As you can see above, &lt;code&gt;ggplot2&lt;/code&gt; returns a warning message indicating data related
to 4 cylinders has been dropped. If you observe the legend, it now represents
only 4 and 6 cylinders.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;labels&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Labels&lt;/h3&gt;
&lt;p&gt;The labels in the legend can be modified using the &lt;code&gt;labels&lt;/code&gt; argument. Let us
change the labels to &lt;code&gt;Four&lt;/code&gt;, &lt;code&gt;Six&lt;/code&gt; and &lt;code&gt;Eight&lt;/code&gt; in the next example. Ensure that
the labels are intuitive and easy to interpret for the end user of the plot.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, color = factor(cyl))) +
  scale_color_manual(values = c(&amp;quot;red&amp;quot;, &amp;quot;blue&amp;quot;, &amp;quot;green&amp;quot;),
    labels = c(&amp;#39;Four&amp;#39;, &amp;#39;Six&amp;#39;, &amp;#39;Eight&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-02-12-ggplot2-guides-legends_files/figure-html/leg19-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;breaks&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Breaks&lt;/h3&gt;
&lt;p&gt;When there are large number of levels in the mapped variable, you may not
want the labels in the legend to represent all of them. In such cases, we can
use the breaks argument and specify the labels to be used. In the below case,
we use the &lt;code&gt;breaks&lt;/code&gt; argument to ensure that the labels in legend represent
two levels (4, 8) of the mapped variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, color = factor(cyl))) +
  scale_color_manual(values = c(&amp;quot;red&amp;quot;, &amp;quot;blue&amp;quot;, &amp;quot;green&amp;quot;),
    breaks = c(4, 8))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-02-12-ggplot2-guides-legends_files/figure-html/leg20-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;putting-it-all-together&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Putting it all together…&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, color = factor(cyl))) +
  scale_color_manual(name = &amp;quot;Cylinders&amp;quot;, values = c(&amp;quot;red&amp;quot;, &amp;quot;blue&amp;quot;, &amp;quot;green&amp;quot;),
    labels = c(&amp;#39;Four&amp;#39;, &amp;#39;Six&amp;#39;, &amp;#39;Eight&amp;#39;), limits = c(4, 6, 8), breaks = c(4, 6, 8))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-02-12-ggplot2-guides-legends_files/figure-html/leg21-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;In this post, we learnt to modify the following aspects of legends:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;title&lt;/li&gt;
&lt;li&gt;breaks&lt;/li&gt;
&lt;li&gt;limits&lt;/li&gt;
&lt;li&gt;labels&lt;/li&gt;
&lt;li&gt;values&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;up-next..&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Up Next..&lt;/h3&gt;
&lt;p&gt;In the next post, we will learn how to modify legend when &lt;code&gt;fill&lt;/code&gt; is mapped to variables.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>ggplot2: Guides - Axes</title>
      <link>https://blog.rsquaredacademy.com/guides-axes/</link>
      <pubDate>Wed, 31 Jan 2018 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/guides-axes/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;This is the twelfth post in the series &lt;strong&gt;Elegant Data Visualization with
ggplot2&lt;/strong&gt;. In the previous post, we learnt to build histograms. Now that we
have learnt to build different plots, let us look at different ways to modify
the axis. Along the way, we will also explore the &lt;code&gt;scale_*()&lt;/code&gt; family of functions.&lt;/p&gt;
&lt;p&gt;Modify X and Y axis&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;title&lt;/li&gt;
&lt;li&gt;labels&lt;/li&gt;
&lt;li&gt;limits&lt;/li&gt;
&lt;li&gt;breaks&lt;/li&gt;
&lt;li&gt;position&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this module, we will learn how to modify the X and Y axis using the
following functions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Continuous Axis
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;scale_x_continuous()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;scale_y_continuous()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Discrete Axis
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;scale_x_discrete()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;scale_y_discrete()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;p&gt;We will use the following libraries in this post:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://readr.tidyverse.org/&#34;&gt;readr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://ggplot2.tidyverse.org/&#34;&gt;ggplot2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt;
and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/096bc745c18a9ba47b99260978189920&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;continuous-axis&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Continuous Axis&lt;/h3&gt;
&lt;p&gt;If the X and Y axis represent continuous data, we can use
&lt;code&gt;scale_x_continuous()&lt;/code&gt; and &lt;code&gt;scale_y_continuous()&lt;/code&gt; to modify the axis. They take
the following arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;name&lt;/li&gt;
&lt;li&gt;limits&lt;/li&gt;
&lt;li&gt;breaks&lt;/li&gt;
&lt;li&gt;labels&lt;/li&gt;
&lt;li&gt;position&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Let us continue with the scatter plot we have used in previous posts.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-31-ggplot2-guides-axes_files/figure-html/guide2-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;name&lt;/code&gt; argument is used to modify the X axis label. In the below example,
we change the X axis label to &lt;code&gt;&#39;Displacement&#39;&lt;/code&gt;. In previous posts, we
have used &lt;code&gt;xlab()&lt;/code&gt; to work with the X axis label.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) +
  scale_x_continuous(name = &amp;quot;Displacement&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-31-ggplot2-guides-axes_files/figure-html/guide3-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;To modify the range, use the &lt;code&gt;limits&lt;/code&gt; argument. It takes a vector of length
2 i.e. 2 values, the lower and upper limit of the range. It is an alternative
for &lt;code&gt;xlim()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) +
  scale_x_continuous(limits = c(0, 600))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-31-ggplot2-guides-axes_files/figure-html/guide4-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;In the above plot, the ticks on the X axis appear at &lt;code&gt;0&lt;/code&gt;, &lt;code&gt;200&lt;/code&gt;, &lt;code&gt;400&lt;/code&gt; and
&lt;code&gt;600&lt;/code&gt;. Let us say we want the ticks to appear more closer i.e. the difference
between the tick should be reduced by &lt;code&gt;50&lt;/code&gt;. The &lt;code&gt;breaks&lt;/code&gt; argument will allow
us to specify where the ticks appear. It takes a numeric vector equal to the
length of the number of ticks.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) +
  scale_x_continuous(breaks = c(150, 300, 450))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-31-ggplot2-guides-axes_files/figure-html/guide5-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;We can change the tick labels using the &lt;code&gt;labels&lt;/code&gt; argument. In the below
example, we use words instead of numbers. When adding labels, we need to
ensure that the length of the &lt;code&gt;breaks&lt;/code&gt; and &lt;code&gt;labels&lt;/code&gt; are same.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) +
  scale_x_continuous(breaks = c(150, 300, 450),
    labels = c(&amp;#39;One Hundred Fifty&amp;#39;, &amp;#39;Three Hundred&amp;#39;, &amp;#39;Four Hundred Fifity&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-31-ggplot2-guides-axes_files/figure-html/guide6-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;The position of the axes can be changed using the &lt;code&gt;position&lt;/code&gt; argument. In the
below example, we can move the axes to the top of the plot by supplying the
value &lt;code&gt;&#39;top&#39;&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) +
  scale_x_continuous(position = &amp;#39;top&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-31-ggplot2-guides-axes_files/figure-html/guide7-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;putting-it-all-together..&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Putting it all together..&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) + geom_point(aes(disp, mpg)) +
  scale_x_continuous(name = &amp;quot;Displacement&amp;quot;, limits = c(0, 600),
                     breaks = c(0, 150, 300, 450, 600), position = &amp;#39;top&amp;#39;,
                     labels = c(&amp;#39;0&amp;#39;, &amp;#39;150&amp;#39;, &amp;#39;300&amp;#39;, &amp;#39;450&amp;#39;, &amp;#39;600&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-31-ggplot2-guides-axes_files/figure-html/guide8-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;y-axis---continuous&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Y Axis - Continuous&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) + geom_point(aes(disp, mpg)) +
  scale_y_continuous(name = &amp;quot;Miles Per Gallon&amp;quot;, limits = c(0, 45),
                     breaks = c(0, 15, 30, 45), position = &amp;#39;right&amp;#39;,
                     labels = c(&amp;#39;0&amp;#39;, &amp;#39;15&amp;#39;, &amp;#39;30&amp;#39;, &amp;#39;45&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-31-ggplot2-guides-axes_files/figure-html/guide9-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;discrete-axis&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Discrete Axis&lt;/h3&gt;
&lt;p&gt;If the X and Y axis represent discrete or categorical data, &lt;code&gt;scale_x_discrete()&lt;/code&gt;
and &lt;code&gt;scale_y_discrete()&lt;/code&gt; can be used to modify them. They take the following arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;name&lt;/li&gt;
&lt;li&gt;labels&lt;/li&gt;
&lt;li&gt;breaks&lt;/li&gt;
&lt;li&gt;position&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The above options serve the same purpose as in the case of continuous scales.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;div id=&#34;axis-label&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Axis Label&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_bar(aes(factor(cyl))) +
  scale_x_discrete(name = &amp;quot;Number of Cylinders&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-31-ggplot2-guides-axes_files/figure-html/guide11-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;axis-tick-labels&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Axis Tick Labels&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_bar(aes(factor(cyl))) +
  scale_x_discrete(labels = c(&amp;quot;4&amp;quot; = &amp;quot;Four&amp;quot;, &amp;quot;6&amp;quot; = &amp;quot;Six&amp;quot;, &amp;quot;8&amp;quot; = &amp;quot;Eight&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-31-ggplot2-guides-axes_files/figure-html/guide12-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;axis-breaks&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Axis Breaks&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_bar(aes(factor(cyl))) +
  scale_x_discrete(breaks = c(&amp;quot;4&amp;quot;, &amp;quot;6&amp;quot;, &amp;quot;8&amp;quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-31-ggplot2-guides-axes_files/figure-html/guide13-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;axis-position&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Axis Position&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_bar(aes(factor(cyl))) +
  scale_x_discrete(position = &amp;#39;bottom&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-31-ggplot2-guides-axes_files/figure-html/guide14-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;putting-it-all-together&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Putting it all together…&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) + geom_bar(aes(factor(cyl))) +
  scale_x_discrete(name = &amp;quot;Number of Cylinders&amp;quot;,
    labels = c(&amp;quot;4&amp;quot; = &amp;quot;Four&amp;quot;, &amp;quot;6&amp;quot; = &amp;quot;Six&amp;quot;, &amp;quot;8&amp;quot; = &amp;quot;Eight&amp;quot;),
    breaks = c(&amp;quot;4&amp;quot;, &amp;quot;6&amp;quot;, &amp;quot;8&amp;quot;), position = &amp;quot;bottom&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-31-ggplot2-guides-axes_files/figure-html/guide15-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;In this post, we learnt to modify&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;title&lt;/li&gt;
&lt;li&gt;labels&lt;/li&gt;
&lt;li&gt;limits&lt;/li&gt;
&lt;li&gt;breaks&lt;/li&gt;
&lt;li&gt;position&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;up-next..&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Up Next..&lt;/h3&gt;
&lt;p&gt;In the next post, we will learn to modify the legend when &lt;code&gt;color&lt;/code&gt; is mapped to a variable.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>ggplot2: Histogram</title>
      <link>https://blog.rsquaredacademy.com/ggplot2-histogram/</link>
      <pubDate>Fri, 19 Jan 2018 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/ggplot2-histogram/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;This is the eleventh post in the series &lt;strong&gt;Elegant Data Visualization with
ggplot2&lt;/strong&gt;. In the previous post, we learnt to build box plots. In this post,
we will learn to&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;build histogram&lt;/li&gt;
&lt;li&gt;specify bins&lt;/li&gt;
&lt;li&gt;modify
&lt;ul&gt;
&lt;li&gt;color&lt;/li&gt;
&lt;li&gt;fill&lt;/li&gt;
&lt;li&gt;alpha&lt;/li&gt;
&lt;li&gt;bin width&lt;/li&gt;
&lt;li&gt;line type&lt;/li&gt;
&lt;li&gt;line size&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;map aesthetics to variables&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A histogram is a plot that can be used to examine the shape and spread of continuous data. It looks very similar to a bar graph and can be used to detect outliers and skewness in data. The histogram graphically shows the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;center (location) of the data&lt;/li&gt;
&lt;li&gt;spread (dispersion) of the data&lt;/li&gt;
&lt;li&gt;skewness&lt;/li&gt;
&lt;li&gt;outliers&lt;/li&gt;
&lt;li&gt;presence of multiple modes&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To construct a histogram, the data is split into intervals called bins. The intervals may or may not be equal sized. For each bin, the number of data points that fall into it are counted (frequency). The Y axis of the histogram represents the frequency and the X axis represents the variable.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;p&gt;We will use the following libraries in this post:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://readr.tidyverse.org/&#34;&gt;readr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://ggplot2.tidyverse.org/&#34;&gt;ggplot2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt;
and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/674bc30cc1539d735bdc4e6210982d1d&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom &amp;lt;- readr::read_csv(&amp;#39;https://raw.githubusercontent.com/rsquaredacademy/datasets/master/web.csv&amp;#39;)
ecom&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1,000 x 11
##       id referrer device bouncers n_visit n_pages duration country purchase
##    &amp;lt;dbl&amp;gt; &amp;lt;chr&amp;gt;    &amp;lt;chr&amp;gt;  &amp;lt;lgl&amp;gt;      &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;chr&amp;gt;   &amp;lt;lgl&amp;gt;   
##  1     1 google   laptop TRUE          10       1      693 Czech ~ FALSE   
##  2     2 yahoo    tablet TRUE           9       1      459 Yemen   FALSE   
##  3     3 direct   laptop TRUE           0       1      996 Brazil  FALSE   
##  4     4 bing     tablet FALSE          3      18      468 China   TRUE    
##  5     5 yahoo    mobile TRUE           9       1      955 Poland  FALSE   
##  6     6 yahoo    laptop FALSE          5       5      135 South ~ FALSE   
##  7     7 yahoo    mobile TRUE          10       1       75 Bangla~ FALSE   
##  8     8 direct   mobile TRUE          10       1      908 Indone~ FALSE   
##  9     9 bing     mobile FALSE          3      19      209 Nether~ FALSE   
## 10    10 google   mobile TRUE           6       1      208 Czech ~ FALSE   
## # ... with 990 more rows, and 2 more variables: order_items &amp;lt;dbl&amp;gt;,
## #   order_value &amp;lt;dbl&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data-dictionary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data Dictionary&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;id: row id&lt;/li&gt;
&lt;li&gt;referrer: referrer website/search engine&lt;/li&gt;
&lt;li&gt;os: operating system&lt;/li&gt;
&lt;li&gt;browser: browser&lt;/li&gt;
&lt;li&gt;device: device used to visit the website&lt;/li&gt;
&lt;li&gt;n_pages: number of pages visited&lt;/li&gt;
&lt;li&gt;duration: time spent on the website (in seconds)&lt;/li&gt;
&lt;li&gt;repeat: frequency of visits&lt;/li&gt;
&lt;li&gt;country: country of origin&lt;/li&gt;
&lt;li&gt;purchase: whether visitor purchased&lt;/li&gt;
&lt;li&gt;order_value: order value of visitor (in dollars)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;div id=&#34;histogram&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Histogram&lt;/h4&gt;
&lt;p&gt;To create a histogram, we will use &lt;code&gt;geom_histogram()&lt;/code&gt; and specify the variable
name within &lt;code&gt;aes()&lt;/code&gt;. In the below example, we create histogram of the variable
&lt;code&gt;n_visit&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom) +
  geom_histogram(aes(n_visit))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-19-ggplot2-histogram_files/figure-html/hist2-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;specify-bins&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Specify Bins&lt;/h4&gt;
&lt;p&gt;The default number of bins in ggplot2 is &lt;code&gt;30&lt;/code&gt;. You can modify the number of
bins using the &lt;code&gt;bins&lt;/code&gt; argument. In the below example, we create a histogram
with 7 bins.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom) +
  geom_histogram(aes(n_visit), bins = 7)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-19-ggplot2-histogram_files/figure-html/hist4-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;aesthetics&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Aesthetics&lt;/h4&gt;
&lt;p&gt;Now that we know how to create a histogram, let us learn to modify its
appearance. We will begin with the background color. Use the &lt;code&gt;fill&lt;/code&gt; argument
to modify the background color of the histogram. In the below case, we change
the color of the histogram to ‘blue’.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom) +
  geom_histogram(aes(n_visit), bins = 7, fill = &amp;#39;blue&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-19-ggplot2-histogram_files/figure-html/hist3-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;As we have learnt before, the transparency of the background color can be
modified using the &lt;code&gt;alpha&lt;/code&gt; argument. It can take any value between &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom) +
  geom_histogram(aes(n_visit), bins = 7, fill = &amp;#39;blue&amp;#39;, alpha = 0.3)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-19-ggplot2-histogram_files/figure-html/hist11-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;The color of the histogram border can be modified using the &lt;code&gt;color&lt;/code&gt; argument.
The color can be specified either using its name or the associated hex code.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom) +
  geom_histogram(aes(n_visit), bins = 7, fill = &amp;#39;white&amp;#39;, color = &amp;#39;blue&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-19-ggplot2-histogram_files/figure-html/hist8-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;
&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;putting-it-all-together&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Putting it all together…&lt;/h4&gt;
&lt;p&gt;Let us modify the bins, the background and border color of the histogram in
the below example.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom) +
  geom_histogram(aes(n_visit), bins = 7, fill = &amp;#39;blue&amp;#39;, color = &amp;#39;white&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-19-ggplot2-histogram_files/figure-html/hist9-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;bin-width&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Bin Width&lt;/h4&gt;
&lt;p&gt;Another way to control the number of bins in a histogram is by using the
&lt;code&gt;binwidth&lt;/code&gt; argument. In this case, we specify the width of the bins instead
of the number of bins. As you can see, in the below example, we do not use
the &lt;code&gt;bins&lt;/code&gt; argument when using the &lt;code&gt;binwidth&lt;/code&gt; argument. You can use either of
them but not both.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom) +
  geom_histogram(aes(n_visit), binwidth = 2, fill = &amp;#39;blue&amp;#39;, color = &amp;#39;black&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-19-ggplot2-histogram_files/figure-html/hist5-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;line-type&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Line Type&lt;/h4&gt;
&lt;p&gt;The line type of the histogram border can be modified using the &lt;code&gt;linetype&lt;/code&gt;
argument. It can take any integer value between &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;6&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom) +
  geom_histogram(aes(n_visit), bins = 5, fill = &amp;#39;white&amp;#39;, 
    color = &amp;#39;blue&amp;#39;, linetype = 3)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-19-ggplot2-histogram_files/figure-html/hist6-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;line-size&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Line Size&lt;/h4&gt;
&lt;p&gt;Use the &lt;code&gt;size&lt;/code&gt; argument to modify the width of the border of the histogram bins.
It can take any value greater than &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom) +
  geom_histogram(aes(n_visit), bins = 5, fill = &amp;#39;white&amp;#39;, 
    color = &amp;#39;blue&amp;#39;, size = 1.25)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-19-ggplot2-histogram_files/figure-html/hist10-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;map-variables&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Map Variables&lt;/h4&gt;
&lt;p&gt;You can map the aesthetics to variables as well. In the below example, we map
&lt;code&gt;fill&lt;/code&gt; to the device variable. You can try mapping color, linetype and size to
variables as well.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom) +
  geom_histogram(aes(n_visit, fill = device), bins = 7)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-19-ggplot2-histogram_files/figure-html/hist7-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;In this post, we learnt to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;build histogram&lt;/li&gt;
&lt;li&gt;specify bins&lt;/li&gt;
&lt;li&gt;modify
&lt;ul&gt;
&lt;li&gt;color&lt;/li&gt;
&lt;li&gt;fill&lt;/li&gt;
&lt;li&gt;alpha&lt;/li&gt;
&lt;li&gt;bin width&lt;/li&gt;
&lt;li&gt;line type&lt;/li&gt;
&lt;li&gt;line size&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;map aesthetics to variables&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;up-next..&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Up Next..&lt;/h3&gt;
&lt;p&gt;In the next post, we will learn to modify the axes of a plot.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>ggplot2: Box Plots</title>
      <link>https://blog.rsquaredacademy.com/ggplot2-box-plots/</link>
      <pubDate>Sun, 07 Jan 2018 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/ggplot2-box-plots/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;This is the 9th post in the series &lt;strong&gt;Elegant Data Visualization with
ggplot2&lt;/strong&gt;. In the previous post, we learnt how to build bar charts. In this
post, we will learn to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;build box plots&lt;/li&gt;
&lt;li&gt;modify box
&lt;ul&gt;
&lt;li&gt;color&lt;/li&gt;
&lt;li&gt;fill&lt;/li&gt;
&lt;li&gt;alpha&lt;/li&gt;
&lt;li&gt;line size&lt;/li&gt;
&lt;li&gt;line type&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;modify outlier
&lt;ul&gt;
&lt;li&gt;color&lt;/li&gt;
&lt;li&gt;shape&lt;/li&gt;
&lt;li&gt;size&lt;/li&gt;
&lt;li&gt;alpha&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The box plot is a standardized way of displaying the distribution of data. It
is useful for detecting outliers and for comparing distributions and shows the
shape, central tendancy and variability of the data.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;structure&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Structure&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;the body of the boxplot consists of a “box” (hence, the name), which goes from the first quartile (Q1) to the third quartile (Q3)&lt;/li&gt;
&lt;li&gt;within the box, a vertical line is drawn at the Q2, the median of the data set&lt;/li&gt;
&lt;li&gt;two horizontal lines, called whiskers, extend from the front and back of the box&lt;/li&gt;
&lt;li&gt;the front whisker goes from Q1 to the smallest non-outlier in the data set, and the back whisker goes from Q3 to the largest non-outlier&lt;/li&gt;
&lt;li&gt;if the data set includes one or more outliers, they are plotted separately as points on the chart&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;p&gt;We will use the following libraries in this post:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://readr.tidyverse.org/&#34;&gt;readr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://ggplot2.tidyverse.org/&#34;&gt;ggplot2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt; and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/246091b512a6c006e68374e2d24caf7c&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data&lt;/h2&gt;
&lt;p&gt;We are going to use two different data sets in this post. Both the data sets have the same data but are in
different formats.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;daily_returns &amp;lt;- readr::read_csv(&amp;#39;https://raw.githubusercontent.com/rsquaredacademy/datasets/master/tickers.csv&amp;#39;)
daily_returns&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 250 x 5
##       AAPL   AMZN      FB    GOOG    MSFT
##      &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;
##  1  1.38    24.2   2.12    22.4    1.12  
##  2  2.83     3.25 -0.860    5.99   0.767 
##  3 -0.0394   9.91  1.45     6.75   0.973 
##  4  0.108    3.76 -0.770  -10.7   -0.285 
##  5  1.64    19.8   4.75     8.66   0.501 
##  6  0.0689   5.33 -0.300   -0.930  0.256 
##  7 -0.561   -5.21 -0.630   -7.28  -0.708 
##  8  0.551    0.25 -0.460    0.690  0.128 
##  9 -0.217  -13.6   0.0300   6.56   0.0786
## 10 -0.108   -4.25  0.460    2.60   0.472 
## # ... with 240 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;univariate-box-plot&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Univariate Box Plot&lt;/h2&gt;
&lt;p&gt;If you are not comparing the distribution of continuous data, you can create
box plot for a single variable. Unlike &lt;code&gt;plot()&lt;/code&gt;, where we could just use
1 input, in ggplot2, we must specify a value for the X axis and it must be
categorical data. Since we are not comparing distributions, we will use &lt;code&gt;1&lt;/code&gt;
as the value for the X axis and wrap it inside &lt;code&gt;factor()&lt;/code&gt; to treat it as a
categorical variable. In the below example, we examine the distribution of
stock returns of Apple.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(daily_returns) +
  geom_boxplot(aes(x = factor(1), y = AAPL))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-07-ggplot2-box-plots_files/figure-html/box2-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data-1&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data&lt;/h2&gt;
&lt;p&gt;For the rest of the post, we will use the below data set. Instead of 5 columns,
we have two columns. One for the stock names and another for returns.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tidy_returns &amp;lt;- 
  read_csv(&amp;#39;https://raw.githubusercontent.com/rsquaredacademy/datasets/master/tidy_tickers.csv&amp;#39;,
  col_types = list(col_factor(levels = c(&amp;#39;AAPL&amp;#39;, &amp;#39;AMZN&amp;#39;, &amp;#39;FB&amp;#39;, &amp;#39;GOOG&amp;#39;, &amp;#39;MSFT&amp;#39;)), col_double()))
tidy_returns&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1,254 x 2
##    stock returns
##    &amp;lt;fct&amp;gt;   &amp;lt;dbl&amp;gt;
##  1 AAPL   1.38  
##  2 AAPL   2.83  
##  3 AAPL  -0.0394
##  4 AAPL   0.108 
##  5 AAPL   1.64  
##  6 AAPL   0.0689
##  7 AAPL  -0.561 
##  8 AAPL   0.551 
##  9 AAPL  -0.217 
## 10 AAPL  -0.108 
## # ... with 1,244 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;box-plot&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Box Plot&lt;/h2&gt;
&lt;p&gt;With the above data, let us create a box plot where we compate the distribution
of stock returns of different companies. We map X axis to the column with stock
names and Y axis to the column with stock returns. Note that, the column names
are wrapped inside &lt;code&gt;aes()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(tidy_returns) +
  geom_boxplot(aes(x = stock, y = returns))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-07-ggplot2-box-plots_files/figure-html/box3-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;To create a horizontal bar plot, we can use &lt;code&gt;coord_flip()&lt;/code&gt; which will flip the
coordinate axes.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;horizontal-box-plot&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Horizontal Box Plot&lt;/h2&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(tidy_returns) +
  geom_boxplot(aes(x = stock, y = returns)) +
  coord_flip()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-07-ggplot2-box-plots_files/figure-html/box4-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;notch&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Notch&lt;/h2&gt;
&lt;p&gt;Notches are used to compare medians. You can use the &lt;code&gt;notch&lt;/code&gt; argument and set
it to &lt;code&gt;TRUE&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(tidy_returns) +
  geom_boxplot(aes(x = stock, y = returns),
    notch = TRUE) &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-07-ggplot2-box-plots_files/figure-html/box5-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;jitter&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Jitter&lt;/h2&gt;
&lt;p&gt;Just for comparison, let us plot the returns as points on top of the box plot
using &lt;code&gt;geom_jitter()&lt;/code&gt;. We modify the color of the points using the &lt;code&gt;color&lt;/code&gt;
argument and the spread using the &lt;code&gt;width&lt;/code&gt; argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(tidy_returns, aes(x = stock, y = returns)) +
  geom_boxplot() +
  geom_jitter(width = 0.2, color = &amp;#39;blue&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-07-ggplot2-box-plots_files/figure-html/box6-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;outliers&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Outliers&lt;/h2&gt;
&lt;p&gt;To highlight extreme observations, we can modify the appearance of outliers
using the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;color&lt;/li&gt;
&lt;li&gt;shape&lt;/li&gt;
&lt;li&gt;size&lt;/li&gt;
&lt;li&gt;alpha&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;To modify the color of the outliers, use the &lt;code&gt;outlier.color&lt;/code&gt; argument. The
color can be specified either using its name or the associated hex code.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(tidy_returns) +
  geom_boxplot(aes(x = stock, y = returns), outlier.color = &amp;#39;red&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-07-ggplot2-box-plots_files/figure-html/box7-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;The shape of the outlier can be modified using the &lt;code&gt;outlier.shape&lt;/code&gt; argument.
It can take values between &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;25&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(tidy_returns) +
  geom_boxplot(aes(x = stock, y = returns), outlier.shape = 23) &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-07-ggplot2-box-plots_files/figure-html/box9-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;The size of the outlier can be modified using the &lt;code&gt;outlier.size&lt;/code&gt; argument. It
can take any value greater than &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(tidy_returns) +
  geom_boxplot(aes(x = stock, y = returns), outlier.size = 3) &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-07-ggplot2-box-plots_files/figure-html/box10-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;You can play around with the transparency of the outlier using the
&lt;code&gt;outlier.alpha&lt;/code&gt; argument. It can take values between &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(tidy_returns) +
  geom_boxplot(aes(x = stock, y = returns), outlier.color = &amp;#39;blue&amp;#39;, outlier.alpha = 0.3) &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-07-ggplot2-box-plots_files/figure-html/box11-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;box-aesthetics&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Box Aesthetics&lt;/h2&gt;
&lt;p&gt;The appearance of the box can be controlled using the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;color&lt;/li&gt;
&lt;li&gt;fill&lt;/li&gt;
&lt;li&gt;alpha&lt;/li&gt;
&lt;li&gt;line type&lt;/li&gt;
&lt;li&gt;line width&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;specify-values&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Specify Values&lt;/h2&gt;
&lt;p&gt;The background color of the box can be modified using the &lt;code&gt;fill&lt;/code&gt; argument. The
color can be specified either using its name or the associated hex code.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(tidy_returns) +
  geom_boxplot(aes(x = stock, y = returns), fill = c(&amp;#39;blue&amp;#39;, &amp;#39;red&amp;#39;, &amp;#39;green&amp;#39;, &amp;#39;yellow&amp;#39;, &amp;#39;brown&amp;#39;)) &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-07-ggplot2-box-plots_files/figure-html/box12-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;To modify the transparency of the background color, use the &lt;code&gt;alpha&lt;/code&gt; argument. It
can take any value between &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(tidy_returns) +
  geom_boxplot(aes(x = stock, y = returns), fill = &amp;#39;blue&amp;#39;, alpha = 0.3) &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-07-ggplot2-box-plots_files/figure-html/box14-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;The color of the border can be modified using the &lt;code&gt;color&lt;/code&gt; argument. The
color can be specified either using its name or the associated hex code.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(tidy_returns) +
  geom_boxplot(aes(x = stock, y = returns), color = c(&amp;#39;blue&amp;#39;, &amp;#39;red&amp;#39;, &amp;#39;green&amp;#39;, &amp;#39;yellow&amp;#39;, &amp;#39;brown&amp;#39;)) &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-07-ggplot2-box-plots_files/figure-html/box15-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;The width of the border can be changed using the &lt;code&gt;size&lt;/code&gt; argument. It can take
any value greater than &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(tidy_returns) +
  geom_boxplot(aes(x = stock, y = returns), size = 1.5) &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-07-ggplot2-box-plots_files/figure-html/box17-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;To change the line type of the border, use the &lt;code&gt;linetype&lt;/code&gt; argument. It can take
any value between &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;6&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(tidy_returns) +
  geom_boxplot(aes(x = stock, y = returns), linetype = 2) &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-07-ggplot2-box-plots_files/figure-html/box18-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;map-variables&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Map Variables&lt;/h2&gt;
&lt;p&gt;Instead of specifying values, we can map &lt;code&gt;fill&lt;/code&gt; and &lt;code&gt;color&lt;/code&gt; to variables as
well. In the below example, we map &lt;code&gt;fill&lt;/code&gt; to the variable stock. It assigns
different colors to the different stocks.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(tidy_returns) +
  geom_boxplot(aes(x = stock, y = returns, fill = stock)) &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-07-ggplot2-box-plots_files/figure-html/box13-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Let us map &lt;code&gt;color&lt;/code&gt; to the variable stock. It will assign different colors
to the box borders.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(tidy_returns) +
  geom_boxplot(aes(x = stock, y = returns, color = stock)) &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2018-01-07-ggplot2-box-plots_files/figure-html/box16-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;In this post, we learnt to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;build box plots&lt;/li&gt;
&lt;li&gt;modify outlier color, shape, size etc.&lt;/li&gt;
&lt;li&gt;modify box color&lt;/li&gt;
&lt;li&gt;modify box line color, size and line type&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;up-next..&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Up Next..&lt;/h3&gt;
&lt;p&gt;In the next post, we will learn to build histograms.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>ggplot2: Bar Plots</title>
      <link>https://blog.rsquaredacademy.com/ggplot2-bar-plots/</link>
      <pubDate>Tue, 26 Dec 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/ggplot2-bar-plots/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;This is the ninth post in the series &lt;strong&gt;Elegant Data Visualization with
ggplot2&lt;/strong&gt;. In the previous post, we learnt to build line charts. In this post,
we will learn to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;build
&lt;ul&gt;
&lt;li&gt;simple bar plot&lt;/li&gt;
&lt;li&gt;stacked bar plot&lt;/li&gt;
&lt;li&gt;grouped bar plot&lt;/li&gt;
&lt;li&gt;proportional bar plot&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;map aesthetics to variables&lt;/li&gt;
&lt;li&gt;specify values for
&lt;ul&gt;
&lt;li&gt;bar color&lt;/li&gt;
&lt;li&gt;bar line color&lt;/li&gt;
&lt;li&gt;bar line type&lt;/li&gt;
&lt;li&gt;bar line size&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;p&gt;We will use the following libraries in this post:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://readr.tidyverse.org/&#34;&gt;readr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://ggplot2.tidyverse.org/&#34;&gt;ggplot2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt;
and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/096329693fa1f9313771d4e259cce1ec&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom &amp;lt;- read_csv(&amp;#39;https://raw.githubusercontent.com/rsquaredacademy/datasets/master/ecom.csv&amp;#39;,
  col_types = list(col_factor(levels = c(&amp;#39;Desktop&amp;#39;, &amp;#39;Mobile&amp;#39;, &amp;#39;Tablet&amp;#39;)), 
  col_factor(levels = c(TRUE, FALSE)), col_factor(levels = c(TRUE, FALSE)), 
  col_factor(levels = c(&amp;#39;Affiliates&amp;#39;, &amp;#39;Direct&amp;#39;, &amp;#39;Display&amp;#39;, &amp;#39;Organic&amp;#39;, &amp;#39;Paid&amp;#39;, &amp;#39;Referral&amp;#39;, &amp;#39;Social&amp;#39;))))
ecom&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 5,000 x 4
##    device  bouncers purchase referrer  
##    &amp;lt;fct&amp;gt;   &amp;lt;fct&amp;gt;    &amp;lt;fct&amp;gt;    &amp;lt;fct&amp;gt;     
##  1 Desktop FALSE    FALSE    Affiliates
##  2 Mobile  FALSE    FALSE    Affiliates
##  3 Desktop TRUE     FALSE    Organic   
##  4 Desktop FALSE    FALSE    Organic   
##  5 Mobile  TRUE     FALSE    Direct    
##  6 Desktop TRUE     FALSE    Direct    
##  7 Desktop FALSE    FALSE    Referral  
##  8 Tablet  TRUE     FALSE    Organic   
##  9 Mobile  TRUE     FALSE    Social    
## 10 Desktop TRUE     FALSE    Organic   
## # ... with 4,990 more rows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data-dictionary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data Dictionary&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;device: device used to visit the website&lt;/li&gt;
&lt;li&gt;bouncers: whether visit was a bouncer (exit website from landing page)&lt;/li&gt;
&lt;li&gt;purchase: whether visitor purchased&lt;/li&gt;
&lt;li&gt;referrer: referrer website/search engine&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;aesthetics&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Aesthetics&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;fill&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;color&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;linetype&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;size&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;position&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;div id=&#34;simple-bar-plot&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Simple Bar Plot&lt;/h4&gt;
&lt;p&gt;We can create a bar plot using &lt;code&gt;geom_bar()&lt;/code&gt;. It takes a single input, a
categorical variable. In the below example, we plot the number of visits for
each device type.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom) +
  geom_bar(aes(device))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-26-ggplot2-bar-plots_files/figure-html/bar2-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;bar-color&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Bar Color&lt;/h4&gt;
&lt;p&gt;The color of the bars can be modified using the &lt;code&gt;fill&lt;/code&gt; argument. In the below
example, we assign different colors to the 3 bars in the plot. If you use the
&lt;code&gt;color&lt;/code&gt; argument, it will modify the color of the bar line and not the
background color of the bars. We will look at that later in the post.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom) +
  geom_bar(aes(device), fill = c(&amp;#39;red&amp;#39;, &amp;#39;blue&amp;#39;, &amp;#39;green&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-26-ggplot2-bar-plots_files/figure-html/bar3-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;stacked-bar-plot&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Stacked Bar Plot&lt;/h4&gt;
&lt;p&gt;If you want to look at distribution of one categorical variable across the
levels of another categorical variable, you can create a stacked bar plot. In
ggplot2, a stacked bar plot is created by mapping the &lt;code&gt;fill&lt;/code&gt; argument to the
second categorical variable. In the below example, we have mapped &lt;code&gt;fill&lt;/code&gt; to
&lt;code&gt;referrer&lt;/code&gt; variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom) +
  geom_bar(aes(device, fill = referrer))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-26-ggplot2-bar-plots_files/figure-html/bar7-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;grouped-bar-plot&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Grouped Bar Plot&lt;/h4&gt;
&lt;p&gt;Grouped bar plots are a variation of stacked bar plots. Instead of being
stacked on top of one another, the bars are placed next to one another and
grouped by levels. In the below example, we create a grouped bar plot and you
can observe that the bars are placed next to one another instead of being
stacked as was shown in the previous example. To create a grouped bar plot,
use the &lt;code&gt;position&lt;/code&gt; argument and set it to &lt;code&gt;&#39;dodge&#39;&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom) +
  geom_bar(aes(device, fill = referrer), position = &amp;#39;dodge&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-26-ggplot2-bar-plots_files/figure-html/bar8-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;proportional-bar-plot&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Proportional Bar Plot&lt;/h4&gt;
&lt;p&gt;In a proportional bar plot, the height of all the bars is proportional or same.
To create a proportional bar plot, use the &lt;code&gt;position&lt;/code&gt; argument and set it to
&lt;code&gt;&#39;fill&#39;&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom) +
  geom_bar(aes(device, fill = referrer), position = &amp;#39;fill&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-26-ggplot2-bar-plots_files/figure-html/bar10-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;horizontal-bar-plot&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Horizontal Bar Plot&lt;/h4&gt;
&lt;p&gt;A horizontal bar plot can be created by flipping the coordinate axes of a
regular plot. To flip the axes, use &lt;code&gt;coord_flip()&lt;/code&gt; as shown below.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom) +
  geom_bar(aes(device, fill = referrer)) +
  coord_flip()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-26-ggplot2-bar-plots_files/figure-html/bar9-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;bar-line&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Bar Line&lt;/h4&gt;
&lt;p&gt;The color of the bar line can be modified using the &lt;code&gt;color&lt;/code&gt; argument. The color
can be specified either using its name or hex code.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom) +
  geom_bar(aes(device), fill = &amp;#39;white&amp;#39;, color = c(&amp;#39;red&amp;#39;, &amp;#39;blue&amp;#39;, &amp;#39;green&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-26-ggplot2-bar-plots_files/figure-html/bar4-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;To modify the line type of the bar line, use the &lt;code&gt;linetype&lt;/code&gt; argument. It can
take values between &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;6&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom) +
  geom_bar(aes(device), fill = &amp;#39;white&amp;#39;,  color = &amp;#39;black&amp;#39;, linetype = 2)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-26-ggplot2-bar-plots_files/figure-html/bar5-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;The width of the bar line can be modified using the &lt;code&gt;size&lt;/code&gt; argument. It can
take any value greater than &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom) +
  geom_bar(aes(device), fill = &amp;#39;white&amp;#39;, color = &amp;#39;black&amp;#39;, size = 2)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-26-ggplot2-bar-plots_files/figure-html/bar6-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;In this post, we learnt to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;build
&lt;ul&gt;
&lt;li&gt;simple bar plot&lt;/li&gt;
&lt;li&gt;stacked bar plot&lt;/li&gt;
&lt;li&gt;grouped bar plot&lt;/li&gt;
&lt;li&gt;proportional bar plot&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;map aesthetics to variables&lt;/li&gt;
&lt;li&gt;specify values for
&lt;ul&gt;
&lt;li&gt;bar color&lt;/li&gt;
&lt;li&gt;bar line color&lt;/li&gt;
&lt;li&gt;bar line type&lt;/li&gt;
&lt;li&gt;bar line size&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;up-next..&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Up Next..&lt;/h3&gt;
&lt;p&gt;In the next post, we will learn to build box plots.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>ggplot2: Line Graphs</title>
      <link>https://blog.rsquaredacademy.com/ggplot2-line-graphs/</link>
      <pubDate>Thu, 14 Dec 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/ggplot2-line-graphs/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;This is the 8th post in the series &lt;strong&gt;Elegant Data Visualization with
ggplot2&lt;/strong&gt;. In the previous post, we learnt to build scatter plots. In this
post, we will learn to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;build
&lt;ul&gt;
&lt;li&gt;simple line chart&lt;/li&gt;
&lt;li&gt;grouped line chart&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;map aesthetics to variables&lt;/li&gt;
&lt;li&gt;modify line
&lt;ul&gt;
&lt;li&gt;color&lt;/li&gt;
&lt;li&gt;type&lt;/li&gt;
&lt;li&gt;size&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;p&gt;We will use the following libraries in this post:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://readr.tidyverse.org/&#34;&gt;readr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://ggplot2.tidyverse.org/&#34;&gt;ggplot2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt;
and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/84b3204eee81d6e804f10a73900809b5&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;div id=&#34;case-study&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Case Study&lt;/h4&gt;
&lt;p&gt;We will use a data set related to GDP growth rate. You can download it from
&lt;a href=&#34;https://github.com/rsquaredacademy/datasets/blob/master/gdp.csv&#34;&gt;here&lt;/a&gt;. It
contains GDP (Gross Domestic Product) growth data for the BRICS (Brazil,
Russia, India, China, South Africa) for the years 2000 to 2005.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Data&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;gdp &amp;lt;- readr::read_csv(&amp;#39;https://raw.githubusercontent.com/rsquaredacademy/datasets/master/gdp.csv&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: Missing column names filled in: &amp;#39;X1&amp;#39; [1]&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;gdp&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 6 x 6
##      X1     X year       growth india china
##   &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;date&amp;gt;      &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;
## 1     1     1 2000-01-01      6     5     8
## 2     2     2 2001-01-01      9     9     5
## 3     3     3 2002-01-01      8     8     6
## 4     4     4 2003-01-01      9     8     8
## 5     5     5 2004-01-01      9     5     9
## 6     6     6 2005-01-01      8     7     8&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;line-chart&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Line Chart&lt;/h4&gt;
&lt;p&gt;To create a line chart, use &lt;code&gt;geom_line()&lt;/code&gt;. In the below example, we examine the
GDP growth rate trend of India for the years 2000 to 2005.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(gdp, aes(year, india)) +
  geom_line()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-14-ggplot2-line-graphs_files/figure-html/line100-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;line-color&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Line Color&lt;/h4&gt;
&lt;p&gt;To modify the color of the line, use the &lt;code&gt;color&lt;/code&gt; argument and supply it a valid
color name. In the below example, we modify the color of the line to &lt;code&gt;&#39;blue&#39;&lt;/code&gt;.
Remember that the &lt;code&gt;color&lt;/code&gt; argument should be outside &lt;code&gt;aes()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(gdp, aes(year, india)) +
  geom_line(color = &amp;#39;blue&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-14-ggplot2-line-graphs_files/figure-html/line1-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;line-type&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Line Type&lt;/h4&gt;
&lt;p&gt;The line type can be modified using the &lt;code&gt;linetype&lt;/code&gt; argument. It can take 7 different
values. You can specify the line type either using numbers or words as shown below:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;0 : blank&lt;/li&gt;
&lt;li&gt;1 : solid&lt;/li&gt;
&lt;li&gt;2 : dashed&lt;/li&gt;
&lt;li&gt;3 : dotted&lt;/li&gt;
&lt;li&gt;4 : dotdash&lt;/li&gt;
&lt;li&gt;5 : longdash&lt;/li&gt;
&lt;li&gt;6 : twodash&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Let us modify the line type to dashed style by supplying the value &lt;code&gt;2&lt;/code&gt; to the
&lt;code&gt;linetype&lt;/code&gt; argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(gdp, aes(year, india)) +
  geom_line(linetype = 2)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-14-ggplot2-line-graphs_files/figure-html/line2-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;The above example can be recreated by supplying the value &lt;code&gt;&#39;dashed&#39;&lt;/code&gt; instead
of &lt;code&gt;2&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(gdp, aes(year, india)) +
  geom_line(linetype = &amp;#39;dashed&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-14-ggplot2-line-graphs_files/figure-html/line3-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;line-size&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Line Size&lt;/h4&gt;
&lt;p&gt;The width of the line can be modified using the &lt;code&gt;size&lt;/code&gt; argument. It can take
any value above 0 as input.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(gdp, aes(year, india)) +
  geom_line(size = 2)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-14-ggplot2-line-graphs_files/figure-html/line4-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;modify-data&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Modify Data&lt;/h4&gt;
&lt;p&gt;Now let us map the aesthetics to the variables. The data used in the above
example cannot be used as we need a variable with country names. We will use
&lt;code&gt;gather()&lt;/code&gt; function from the &lt;code&gt;tidyr&lt;/code&gt; package to reshape the data.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;gdp2 &amp;lt;- gdp %&amp;gt;% 
  select(year, growth, india, china) %&amp;gt;% 
  gather(key = country, value = gdp, -year)

gdp2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 18 x 3
##    year       country   gdp
##    &amp;lt;date&amp;gt;     &amp;lt;chr&amp;gt;   &amp;lt;dbl&amp;gt;
##  1 2000-01-01 growth      6
##  2 2001-01-01 growth      9
##  3 2002-01-01 growth      8
##  4 2003-01-01 growth      9
##  5 2004-01-01 growth      9
##  6 2005-01-01 growth      8
##  7 2000-01-01 india       5
##  8 2001-01-01 india       9
##  9 2002-01-01 india       8
## 10 2003-01-01 india       8
## 11 2004-01-01 india       5
## 12 2005-01-01 india       7
## 13 2000-01-01 china       8
## 14 2001-01-01 china       5
## 15 2002-01-01 china       6
## 16 2003-01-01 china       8
## 17 2004-01-01 china       9
## 18 2005-01-01 china       8&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;grouped-line-chart&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Grouped Line Chart&lt;/h4&gt;
&lt;p&gt;In the original data, to plot GDP trend of multiple countries we will have to
use &lt;code&gt;geom_line()&lt;/code&gt; multiple times. But in the reshaped data, we have the
country names as one of the variables and this can be used along with the
&lt;code&gt;group&lt;/code&gt; argument to plot data of multiple countries with a single line of code
as shown below. By mapping country to the &lt;code&gt;group&lt;/code&gt; argument, we have plotted
data of all countries.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(gdp2, aes(year, gdp, group = country)) +
  geom_line()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-14-ggplot2-line-graphs_files/figure-html/line6-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;In the above plot, we cannot distinguish between the lines and there is no way
to identify which line represents which country. To make it easier to identify
the trend of different countries, let us map the &lt;code&gt;color&lt;/code&gt; argument to the
variable country as shown below. Now, each country will be represented by line
of different color.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(gdp2, aes(year, gdp, group = country)) +
  geom_line(aes(color = country))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-14-ggplot2-line-graphs_files/figure-html/line7-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;We can map &lt;code&gt;linetype&lt;/code&gt; argument to country as well. In this case, each country
will be represented by a different line type.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(gdp2, aes(year, gdp, group = country)) +
  geom_line(aes(linetype = country))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-14-ggplot2-line-graphs_files/figure-html/line8-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;We can map the width of the line to the variable country as well. But in this
case, the plot does not look either elegant or intuitive.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(gdp2, aes(year, gdp, group = country)) +
  geom_line(aes(size = country))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: Using size for a discrete variable is not advised.&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-14-ggplot2-line-graphs_files/figure-html/line9-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Remember that in all the above cases, we mapped the arguments to a variable
inside &lt;code&gt;aes()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;In this post, we learnt to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;build
&lt;ul&gt;
&lt;li&gt;simple line chart&lt;/li&gt;
&lt;li&gt;grouped line chart&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;map aesthetics to variables&lt;/li&gt;
&lt;li&gt;modify line
&lt;ul&gt;
&lt;li&gt;color&lt;/li&gt;
&lt;li&gt;type&lt;/li&gt;
&lt;li&gt;size&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;up-next..&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Up Next..&lt;/h3&gt;
&lt;p&gt;In the next post, we will learn to build bar plots.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>ggplot2: Scatter Plots</title>
      <link>https://blog.rsquaredacademy.com/ggplot2-scatter-plots/</link>
      <pubDate>Sat, 02 Dec 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/ggplot2-scatter-plots/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;This is the fifth post in the series &lt;strong&gt;Elegant Data Visualization with
ggplot2&lt;/strong&gt;. In the previous post, we learnt about text annotations. In this
post, we will:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;build scatter plots&lt;/li&gt;
&lt;li&gt;modify point
&lt;ul&gt;
&lt;li&gt;color&lt;/li&gt;
&lt;li&gt;fill&lt;/li&gt;
&lt;li&gt;alpha&lt;/li&gt;
&lt;li&gt;shape&lt;/li&gt;
&lt;li&gt;size&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;fit regression line&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;p&gt;We will use the following libraries in this post:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://readr.tidyverse.org/&#34;&gt;readr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://ggplot2.tidyverse.org/&#34;&gt;ggplot2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt;
and code can be downloaded from &lt;a href=&#34;&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;div id=&#34;basic-plot&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Basic Plot&lt;/h4&gt;
&lt;p&gt;As we did in the previous post, let us begin by creating a scatter plot using&lt;br /&gt;
&lt;code&gt;geom_point()&lt;/code&gt; to examine the relationship between displacement and miles per
gallon using the mtcars data.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-02-ggplot2-scatter-plots_files/figure-html/scat2-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;jitter&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Jitter&lt;/h4&gt;
&lt;p&gt;If you want to avoid over plotting, use the &lt;code&gt;position&lt;/code&gt; argument and supply it
the value &lt;code&gt;&#39;jitter&#39;&lt;/code&gt;. It adds random noise to a plot and makes it easier to
read.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg), position = &amp;#39;jitter&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-02-ggplot2-scatter-plots_files/figure-html/scat22-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Another way to avoid over plotting is to use &lt;code&gt;geom_jitter()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_jitter(aes(disp, mpg))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-02-ggplot2-scatter-plots_files/figure-html/scat3-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;aesthetics&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Aesthetics&lt;/h4&gt;
&lt;p&gt;Now let us modify the appearance of the points. There are two ways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;specify values&lt;/li&gt;
&lt;li&gt;map them to variables using &lt;code&gt;aes()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;specify-values&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Specify Values&lt;/h4&gt;
&lt;div id=&#34;color&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Color&lt;/h5&gt;
&lt;p&gt;To modify the color of the points, you can use the &lt;code&gt;color&lt;/code&gt; argument and
supply it a valid color name. In the below example, we change the color of the
points to &lt;code&gt;&#39;blue&#39;&lt;/code&gt;. Keep in mind that the &lt;code&gt;color&lt;/code&gt; argument should be outside
&lt;code&gt;aes()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg), color = &amp;#39;blue&amp;#39;, position = &amp;#39;jitter&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-02-ggplot2-scatter-plots_files/figure-html/scat6-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;alpha&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Alpha&lt;/h5&gt;
&lt;p&gt;The transparency of the color can be modified using the &lt;code&gt;alpha&lt;/code&gt; argument. It
takes values between &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg), color = &amp;#39;blue&amp;#39;, alpha = 0.4, position = &amp;#39;jitter&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-02-ggplot2-scatter-plots_files/figure-html/scat7-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;shape&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Shape&lt;/h5&gt;
&lt;p&gt;The shape of the points can be modified using the &lt;code&gt;shape&lt;/code&gt; argument. It
takes values between &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;25&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg), shape = 3, position = &amp;#39;jitter&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-02-ggplot2-scatter-plots_files/figure-html/scat9-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;size&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Size&lt;/h5&gt;
&lt;p&gt;The size of the points can be modified using the &lt;code&gt;size&lt;/code&gt; argument. It can take
any value greater than &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg), size = 3, position = &amp;#39;jitter&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-02-ggplot2-scatter-plots_files/figure-html/scat11-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;map-variables&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Map Variables&lt;/h4&gt;
&lt;p&gt;So far, we have specified values for color, shape, size etc. Now, let us map
them to variables using &lt;code&gt;aes()&lt;/code&gt;.&lt;/p&gt;
&lt;div id=&#34;color-1&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Color&lt;/h5&gt;
&lt;p&gt;You can modify the color of the points by mapping them to a variable using
&lt;code&gt;aes()&lt;/code&gt;. It allows you to examine the relationship between two continuous
variables at different levels of a categorical variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, color = factor(cyl)), 
             position = &amp;#39;jitter&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-02-ggplot2-scatter-plots_files/figure-html/scat4-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;The color can be mapped to a conitnuous variable as well and in this case you
will be able to examine the relationship betweem two continuous variable for
a range of value of a third variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, color = hp), 
             position = &amp;#39;jitter&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-02-ggplot2-scatter-plots_files/figure-html/scat5-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;shape-1&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Shape&lt;/h5&gt;
&lt;p&gt;Shape can be mapped to categorical variables. In the below example, we use
&lt;code&gt;factor()&lt;/code&gt; to convert &lt;code&gt;cyl&lt;/code&gt; to categorical data before mapping shape to it.
ggplot2 will throw an error if you map shape to a continuous variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, shape = factor(cyl)), position = &amp;#39;jitter&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-02-ggplot2-scatter-plots_files/figure-html/scat8-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;size-1&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Size&lt;/h5&gt;
&lt;p&gt;Size must be always mapped to continuous variables. In the below example, we
have mapped size to &lt;code&gt;hp&lt;/code&gt; variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, size = hp), color = &amp;#39;blue&amp;#39;, position = &amp;#39;jitter&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-02-ggplot2-scatter-plots_files/figure-html/scat10-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;If you map size to categorical data as shown in the below example, ggplot2
will throw a warning.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg, size = factor(cyl)), color = &amp;#39;blue&amp;#39;, position = &amp;#39;jitter&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: Using size for a discrete variable is not advised.&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-02-ggplot2-scatter-plots_files/figure-html/scat10a-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;regression-line&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Regression Line&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;geom_smooth()&lt;/code&gt; allows us to fit a regression line to the plot. By default it
will use least squares method to fit the line but you can also use the loess
method. In the below example, we fit a regression line using the least squares
technique by supplying the value &lt;code&gt;&#39;lm&#39;&lt;/code&gt; to the &lt;code&gt;method&lt;/code&gt; argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(disp, mpg)) +
  geom_point(position = &amp;#39;jitter&amp;#39;) +
  geom_smooth(method = &amp;#39;lm&amp;#39;, se = FALSE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## `geom_smooth()` using formula &amp;#39;y ~ x&amp;#39;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-02-ggplot2-scatter-plots_files/figure-html/aes12-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;intercept-slope&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Intercept &amp;amp; Slope&lt;/h4&gt;
&lt;p&gt;If you know the intercept and the slope of the line, you can use &lt;code&gt;geom_abline()&lt;/code&gt;.
Let us regress &lt;code&gt;mpg&lt;/code&gt; over &lt;code&gt;disp&lt;/code&gt; and then use the result to add the line.&lt;/p&gt;
&lt;div id=&#34;regression&#34; class=&#34;section level6&#34;&gt;
&lt;h6&gt;Regression&lt;/h6&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;lm(mpg ~ disp, data = mtcars)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Call:
## lm(formula = mpg ~ disp, data = mtcars)
## 
## Coefficients:
## (Intercept)         disp  
##    29.59985     -0.04122&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;add-line&#34; class=&#34;section level6&#34;&gt;
&lt;h6&gt;Add Line&lt;/h6&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(disp, mpg)) +
  geom_point(position = &amp;#39;jitter&amp;#39;) +
  geom_abline(slope = -0.04122, intercept = 29.59985)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-02-ggplot2-scatter-plots_files/figure-html/aes17-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;se&lt;/code&gt; argument will add a confidence interval around the regression line,
if set to &lt;code&gt;TRUE&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;conf.-interval&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Conf. Interval&lt;/h5&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(disp, mpg)) +
  geom_point(position = &amp;#39;jitter&amp;#39;) +
  geom_smooth(method = &amp;#39;lm&amp;#39;, se = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## `geom_smooth()` using formula &amp;#39;y ~ x&amp;#39;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-02-ggplot2-scatter-plots_files/figure-html/aes13-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;loess-method&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Loess Method&lt;/h5&gt;
&lt;p&gt;In the below example, we use the loess method instead of the default least
squares method to fit the regression line.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(disp, mpg)) +
  geom_point(position = &amp;#39;jitter&amp;#39;) +
  geom_smooth(method = &amp;#39;loess&amp;#39;, se = FALSE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## `geom_smooth()` using formula &amp;#39;y ~ x&amp;#39;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-12-02-ggplot2-scatter-plots_files/figure-html/aes14-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;In this post, we learnt to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;build scatter plots&lt;/li&gt;
&lt;li&gt;map aesthetics to variables&lt;/li&gt;
&lt;li&gt;fit regression line&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;up-next..&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Up Next..&lt;/h3&gt;
&lt;p&gt;In the next post, we will learn to build line charts.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>ggplot2: Text Annotations</title>
      <link>https://blog.rsquaredacademy.com/ggplot2-text-annotations/</link>
      <pubDate>Mon, 20 Nov 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/ggplot2-text-annotations/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;This is the sixth post in the series &lt;strong&gt;Elegant Data Visualization with
ggplot2&lt;/strong&gt;. In the previous post, we learnt to modify the axis and plot labels.
In this post, we will learn to add text to the plots.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;add custom text&lt;/li&gt;
&lt;li&gt;modify color&lt;/li&gt;
&lt;li&gt;modify size&lt;/li&gt;
&lt;li&gt;modify fontface&lt;/li&gt;
&lt;li&gt;modify angle&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;p&gt;We will use the following libraries in this post:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://readr.tidyverse.org/&#34;&gt;readr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://ggplot2.tidyverse.org/&#34;&gt;ggplot2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt; and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/567094325b5e134b5b4459677206f363&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;div id=&#34;annotate&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Annotate&lt;/h4&gt;
&lt;p&gt;We will use the &lt;code&gt;annotate()&lt;/code&gt; function to add custom text to the plots. You can
use the &lt;code&gt;annotate()&lt;/code&gt; function to add rectangles/segments/pointrange as well but
our focus will be on adding text. Let us start with a simple scatter plot.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;annotate()&lt;/code&gt; takes the following arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;geom&lt;/code&gt; : specify text&lt;/li&gt;
&lt;li&gt;&lt;code&gt;x&lt;/code&gt; : x axis location&lt;/li&gt;
&lt;li&gt;&lt;code&gt;y&lt;/code&gt; : y axis location&lt;/li&gt;
&lt;li&gt;&lt;code&gt;label&lt;/code&gt; : custom text&lt;/li&gt;
&lt;li&gt;&lt;code&gt;color&lt;/code&gt; : color of text&lt;/li&gt;
&lt;li&gt;&lt;code&gt;size&lt;/code&gt; : size of text&lt;/li&gt;
&lt;li&gt;&lt;code&gt;fontface&lt;/code&gt; : fontface of text&lt;/li&gt;
&lt;li&gt;&lt;code&gt;angle&lt;/code&gt; : angle of text&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;add-text&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Add Text&lt;/h4&gt;
&lt;p&gt;Let us begin by adding text to a scatter plot. We will use the mtcars data set
and continue to examine the relationship between displacement and miles per
gallon. To add the text, we have to indicate that we are using &lt;code&gt;annotate()&lt;/code&gt;
for adding text, and we do this by ensuring that the first input is the word
&lt;code&gt;&#39;text&#39;&lt;/code&gt;. Now, ggplot2 knows that it should add a text to the plot but it still
needs other information such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;where should the text appear on the plot i.e. location of the text&lt;/li&gt;
&lt;li&gt;and the text itself&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We will provide the location by specifying points on the X and Y axis which are
also the second and third inputs to &lt;code&gt;annotate()&lt;/code&gt; and the final input is the text
itself, which in our example is &lt;code&gt;&#39;Sample Text&#39;&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) +
  annotate(&amp;#39;text&amp;#39;, x = 200, y = 30, label = &amp;#39;Sample Text&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-11-20-ggplot2-text-annotations_files/figure-html/ann2-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;color&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Color&lt;/h4&gt;
&lt;p&gt;Now that we know how to add text, let us look at modifying the appearance of
the text. To change the color, use the &lt;code&gt;color&lt;/code&gt; argument. In the below example,
we modify the color to &lt;code&gt;&#39;red&#39;&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) +
  annotate(&amp;#39;text&amp;#39;, x = 200, y = 30, label = &amp;#39;Sample Text&amp;#39;, color = &amp;#39;red&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-11-20-ggplot2-text-annotations_files/figure-html/ann4-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;size&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Size&lt;/h4&gt;
&lt;p&gt;The &lt;code&gt;size&lt;/code&gt; argument can be used to modify the size of the text.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) +
  annotate(&amp;#39;text&amp;#39;, x = 200, y = 30, label = &amp;#39;Sample Text&amp;#39;, size = 6)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-11-20-ggplot2-text-annotations_files/figure-html/ann5-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;font&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Font&lt;/h4&gt;
&lt;p&gt;To choose a font of your liking, use the &lt;code&gt;font&lt;/code&gt; argument and supply it a valid
value.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) +
  annotate(&amp;#39;text&amp;#39;, x = 200, y = 30, label = &amp;#39;Sample Text&amp;#39;, fontface = &amp;#39;bold&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-11-20-ggplot2-text-annotations_files/figure-html/ann6-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;angle&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Angle&lt;/h4&gt;
&lt;p&gt;The angle of the text can also be modified using the &lt;code&gt;angle&lt;/code&gt; argument. In the
below example, we modify the angle of the text to &lt;code&gt;25&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) +
  annotate(&amp;#39;text&amp;#39;, x = 200, y = 30, label = &amp;#39;Sample Text&amp;#39;, angle = 25)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-11-20-ggplot2-text-annotations_files/figure-html/ann7-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;putting-it-all-together..&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Putting it all together..&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) +
  annotate(&amp;#39;text&amp;#39;, x = 200, y = 30, label = &amp;#39;Sample Text&amp;#39;,
           color = &amp;#39;red&amp;#39;, size = 6, fontface = &amp;#39;bold&amp;#39;, angle = 25)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-11-20-ggplot2-text-annotations_files/figure-html/ann3-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Summary&lt;/h4&gt;
&lt;p&gt;In this post, we learnt to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;add custom text&lt;/li&gt;
&lt;li&gt;modify color&lt;/li&gt;
&lt;li&gt;modify size&lt;/li&gt;
&lt;li&gt;modify fontface&lt;/li&gt;
&lt;li&gt;modify angle&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;up-next..&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Up Next..&lt;/h4&gt;
&lt;p&gt;In the next post, we will learn to build scatter plots.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>ggplot2 - Axis and Plot Labels</title>
      <link>https://blog.rsquaredacademy.com/axis-plot-labels/</link>
      <pubDate>Wed, 08 Nov 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/axis-plot-labels/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;This is the fifth post in the series &lt;strong&gt;Elegant Data Visualization with
ggplot2&lt;/strong&gt;. In the previous post, we learnt about aesthetics. In this post, we
will learn to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;add title and subtitle to the plot&lt;/li&gt;
&lt;li&gt;modify axis labels&lt;/li&gt;
&lt;li&gt;modify axis range&lt;/li&gt;
&lt;li&gt;remove axis&lt;/li&gt;
&lt;li&gt;format axis&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;div id=&#34;basic-plot&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Basic Plot&lt;/h4&gt;
&lt;p&gt;Let us start with a simple scatter plot. We will continue to use the mtcars
data set and examine the relationship between displacement and miles per gallon
using &lt;code&gt;geom_point()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-11-08-ggplot2-axis-plot-labels_files/figure-html/axis2-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;title-subtitle&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Title &amp;amp; Subtitle&lt;/h4&gt;
&lt;p&gt;There are two ways to add title to a plot:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;ggtitle()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;labs()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;ggtitle&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;ggtitle()&lt;/h4&gt;
&lt;p&gt;Let us explore the &lt;code&gt;ggtitle()&lt;/code&gt; function first. It takes two arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;label: title of the plot&lt;/li&gt;
&lt;li&gt;subtitle: subtitle of the plot&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;title-subtitle-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Title &amp;amp; Subtitle&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) +
  ggtitle(label = &amp;#39;Displacement vs Mileage&amp;#39;, subtitle = &amp;#39;disp vs mpg&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-11-08-ggplot2-axis-plot-labels_files/figure-html/axis3-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;axis-labels&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Axis Labels&lt;/h4&gt;
&lt;p&gt;You can add labels to the axis using:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;xlab()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ylab()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;labs()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;axis-labels-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Axis Labels&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) +
  xlab(&amp;#39;Displacement&amp;#39;) + ylab(&amp;#39;Miles Per Gallon&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-11-08-ggplot2-axis-plot-labels_files/figure-html/axis4-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;labs&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Labs&lt;/h4&gt;
&lt;p&gt;The &lt;code&gt;labs()&lt;/code&gt; function can be used to add the following to a plot:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;title&lt;/li&gt;
&lt;li&gt;subtitle&lt;/li&gt;
&lt;li&gt;X axis label&lt;/li&gt;
&lt;li&gt;Y axis label&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;labs-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Labs&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) +
  labs(title = &amp;#39;Displacement vs Mileage&amp;#39;, subtitle = &amp;#39;disp vs mpg&amp;#39;, 
    x = &amp;#39;Displacement&amp;#39;, y = &amp;#39;Miles Per Gallon&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-11-08-ggplot2-axis-plot-labels_files/figure-html/axis5-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;axis-range&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Axis Range&lt;/h4&gt;
&lt;p&gt;In certain scenarios, you may want to modify the range of the axis. In ggplot2,
we can achieve this using:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;xlim()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ylim()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;expand_limits()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;axis-range-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Axis Range&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;xlim()&lt;/code&gt; and &lt;code&gt;ylim()&lt;/code&gt; take a numeric vector of length 2 as input&lt;/li&gt;
&lt;li&gt;&lt;code&gt;expand_limits()&lt;/code&gt; takes two numeric vectors (each of length 2), one for each axis&lt;/li&gt;
&lt;li&gt;in all of the above functions, the first element represents the lower limit and the second element represents the upper limit&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;x-axis&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;X Axis&lt;/h4&gt;
&lt;p&gt;In the below example, we limit the range of the X axis between &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;600&lt;/code&gt; using &lt;code&gt;xlim&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) +
  xlim(c(0, 600))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-11-08-ggplot2-axis-plot-labels_files/figure-html/axis6-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;y-axis&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Y Axis&lt;/h4&gt;
&lt;p&gt;Let us limit the range of the Y axis between &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;40&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) +
  ylim(c(0, 40))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-11-08-ggplot2-axis-plot-labels_files/figure-html/axis7-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;expand-limits&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Expand Limits&lt;/h4&gt;
&lt;p&gt;Let us use &lt;code&gt;expand_limits()&lt;/code&gt; to limit the range of both the X and Y axis. The
first input is the range for the X axis and the second input for the Y axis. In
both the cases, we use a numeric vector of length 2 to specify the lower and
upper limit.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) +
  expand_limits(x = c(0, 600), y = c(0, 40))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-11-08-ggplot2-axis-plot-labels_files/figure-html/axis8-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;remove-axis-labels&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Remove Axis Labels&lt;/h4&gt;
&lt;p&gt;If you want to remove the axis labels all together, use the &lt;code&gt;theme()&lt;/code&gt; function.
It allows us to modify every aspect of the theme of the plot. Within &lt;code&gt;theme()&lt;/code&gt;,
set the following to &lt;code&gt;element_blank()&lt;/code&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;axis.title.x&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;axis.title.y&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;remove-axis-labels-using-theme&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Remove Axis Labels using theme()&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;element_blank()&lt;/code&gt; will remove the title of the X and Y axis.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) +
  theme(axis.title.x = element_blank(), axis.title.y = element_blank())&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-11-08-ggplot2-axis-plot-labels_files/figure-html/axis9-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;format-title-axis-labels&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Format Title &amp;amp; Axis Labels&lt;/h4&gt;
&lt;p&gt;To format the title or the axis labels, we have to modify the theme of the plot
using the &lt;code&gt;theme()&lt;/code&gt; function. We can modify:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;color&lt;/li&gt;
&lt;li&gt;font family&lt;/li&gt;
&lt;li&gt;font face&lt;/li&gt;
&lt;li&gt;font size&lt;/li&gt;
&lt;li&gt;horizontal alignment&lt;/li&gt;
&lt;li&gt;and angle&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In addition to &lt;code&gt;theme()&lt;/code&gt;, we will also use &lt;code&gt;element_text()&lt;/code&gt;. It should be used
whenever you want to modify the appearance of any text element of your plot.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;color&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Color&lt;/h4&gt;
&lt;p&gt;In the below example, we use the &lt;code&gt;color&lt;/code&gt; argument within &lt;code&gt;element_text()&lt;/code&gt; to
modify the color of the title of the plot to &lt;code&gt;&#39;blue&#39;&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) + ggtitle(&amp;#39;Diaplacement vs Mileage&amp;#39;) +
  theme(plot.title = element_text(color = &amp;#39;blue&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-11-08-ggplot2-axis-plot-labels_files/figure-html/axis10-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;font-family&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Font Family&lt;/h4&gt;
&lt;p&gt;Let us change the font family of the plot title to &lt;code&gt;&#39;Arial&#39;&lt;/code&gt; by using the
&lt;code&gt;family&lt;/code&gt; argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) + ggtitle(&amp;#39;Diaplacement vs Mileage&amp;#39;) +
  theme(plot.title = element_text(family = &amp;#39;Arial&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-11-08-ggplot2-axis-plot-labels_files/figure-html/axis11-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;font-face&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Font Face&lt;/h4&gt;
&lt;p&gt;The font face can be any of the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;plain&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;bold&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;italic&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;bold.italic&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;font-face-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Font Face&lt;/h4&gt;
&lt;p&gt;The &lt;code&gt;face&lt;/code&gt; argument can be used to modify the font face of the title of the
plot.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) + ggtitle(&amp;#39;Diaplacement vs Mileage&amp;#39;) +
  theme(plot.title = element_text(face = &amp;#39;bold&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-11-08-ggplot2-axis-plot-labels_files/figure-html/axis12-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;font-size&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Font Size&lt;/h4&gt;
&lt;p&gt;The size of the title of the plot can be modified using the &lt;code&gt;size&lt;/code&gt; argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) + ggtitle(&amp;#39;Diaplacement vs Mileage&amp;#39;) +
  theme(plot.title = element_text(size = 8))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-11-08-ggplot2-axis-plot-labels_files/figure-html/axis13-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;horizontal-alignment&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Horizontal Alignment&lt;/h4&gt;
&lt;p&gt;To modify the horizontal alignment of the title, use the &lt;code&gt;hjust&lt;/code&gt; argument. It
can take values between &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;1&lt;/code&gt;. If the value is closer to &lt;code&gt;0&lt;/code&gt;, the text
will be left-aligned and viceversa.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) + ggtitle(&amp;#39;Diaplacement vs Mileage&amp;#39;) +
  theme(plot.title = element_text(hjust = 0.3))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-11-08-ggplot2-axis-plot-labels_files/figure-html/axis14-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;putting-it-all-together&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Putting it all together…&lt;/h3&gt;
&lt;div id=&#34;title&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Title&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) + ggtitle(&amp;#39;Diaplacement vs Mileage&amp;#39;) +
  theme(plot.title = element_text(color = &amp;#39;blue&amp;#39;, family = &amp;#39;Arial&amp;#39;,
    face = &amp;#39;bold&amp;#39;, size = 12, hjust = 0.5))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-11-08-ggplot2-axis-plot-labels_files/figure-html/axis15-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;x-axis-label&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;X axis label&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) + xlab(&amp;#39;Diaplacement&amp;#39;) +
  theme(axis.title.x = element_text(color = &amp;#39;blue&amp;#39;, family = &amp;#39;Arial&amp;#39;,
    face = &amp;#39;bold&amp;#39;, size = 8, hjust = 0.5, angle = 15))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-11-08-ggplot2-axis-plot-labels_files/figure-html/axis16-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;y-axis-label&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Y axis label&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars) +
  geom_point(aes(disp, mpg)) + ylab(&amp;#39;Miles Per Gallon&amp;#39;) +
  theme(axis.title.y = element_text(color = &amp;#39;blue&amp;#39;, family = &amp;#39;Arial&amp;#39;,
    face = &amp;#39;italic&amp;#39;, size = 8, vjust = 0.3, angle = 90))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-11-08-ggplot2-axis-plot-labels_files/figure-html/axis17-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;In this post, we learnt to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;add title and subtitle to the plot&lt;/li&gt;
&lt;li&gt;modify axis labels&lt;/li&gt;
&lt;li&gt;modify axis range&lt;/li&gt;
&lt;li&gt;remove axis&lt;/li&gt;
&lt;li&gt;format axis&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;up-next..&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Up Next..&lt;/h3&gt;
&lt;p&gt;In the next post, we will learn to add text annotations to plots.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>ggplot2 - Introduction to Aesthetics</title>
      <link>https://blog.rsquaredacademy.com/ggplot2-introduction-to-aesthetics/</link>
      <pubDate>Fri, 27 Oct 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/ggplot2-introduction-to-aesthetics/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;This is the fourth post in the series &lt;strong&gt;Elegant Data Visualization with
ggplot2&lt;/strong&gt;. In the previous post, we learnt about geoms and how we can use them
to build different plots. In this post, we will focus on the aesthetics i.e. 
color, shape, size, alpha, line type, line width etc. We can map these to
variables or specify values for them. If we want to map the above to variables,
we have to specify them within the &lt;code&gt;aes()&lt;/code&gt; function. We will look at both
methods in the following sections.&lt;/p&gt;
&lt;p&gt;Explore aesthetics such as&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;color&lt;/li&gt;
&lt;li&gt;shape&lt;/li&gt;
&lt;li&gt;size&lt;/li&gt;
&lt;li&gt;fill&lt;/li&gt;
&lt;li&gt;alpha&lt;/li&gt;
&lt;li&gt;width&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;p&gt;We will use the following libraries in this post:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://readr.tidyverse.org/&#34;&gt;readr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://ggplot2.tidyverse.org/&#34;&gt;ggplot2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://dplyr.tidyverse.org/&#34;&gt;dplyr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://tidyr.tidyverse.org/&#34;&gt;tidyr&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt;
and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/a596a4604b2ebda163313caa272f05cd&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data&lt;/h3&gt;
&lt;div id=&#34;introduction-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Introduction&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom &amp;lt;- readr::read_csv(&amp;#39;https://raw.githubusercontent.com/rsquaredacademy/datasets/master/web.csv&amp;#39;)
ecom&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1,000 x 11
##       id referrer device bouncers n_visit n_pages duration country purchase
##    &amp;lt;dbl&amp;gt; &amp;lt;chr&amp;gt;    &amp;lt;chr&amp;gt;  &amp;lt;lgl&amp;gt;      &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;chr&amp;gt;   &amp;lt;lgl&amp;gt;   
##  1     1 google   laptop TRUE          10       1      693 Czech ~ FALSE   
##  2     2 yahoo    tablet TRUE           9       1      459 Yemen   FALSE   
##  3     3 direct   laptop TRUE           0       1      996 Brazil  FALSE   
##  4     4 bing     tablet FALSE          3      18      468 China   TRUE    
##  5     5 yahoo    mobile TRUE           9       1      955 Poland  FALSE   
##  6     6 yahoo    laptop FALSE          5       5      135 South ~ FALSE   
##  7     7 yahoo    mobile TRUE          10       1       75 Bangla~ FALSE   
##  8     8 direct   mobile TRUE          10       1      908 Indone~ FALSE   
##  9     9 bing     mobile FALSE          3      19      209 Nether~ FALSE   
## 10    10 google   mobile TRUE           6       1      208 Czech ~ FALSE   
## # ... with 990 more rows, and 2 more variables: order_items &amp;lt;dbl&amp;gt;,
## #   order_value &amp;lt;dbl&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data-dictionary&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Data Dictionary&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;id: row id&lt;/li&gt;
&lt;li&gt;referrer: referrer website/search engine&lt;/li&gt;
&lt;li&gt;os: operating system&lt;/li&gt;
&lt;li&gt;browser: browser&lt;/li&gt;
&lt;li&gt;device: device used to visit the website&lt;/li&gt;
&lt;li&gt;n_pages: number of pages visited&lt;/li&gt;
&lt;li&gt;duration: time spent on the website (in seconds)&lt;/li&gt;
&lt;li&gt;repeat: frequency of visits&lt;/li&gt;
&lt;li&gt;country: country of origin&lt;/li&gt;
&lt;li&gt;purchase: whether visitor purchased&lt;/li&gt;
&lt;li&gt;order_value: order value of visitor (in dollars)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;color&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Color&lt;/h4&gt;
&lt;p&gt;In ggplot2, when we mention &lt;code&gt;color&lt;/code&gt; or &lt;code&gt;colour&lt;/code&gt;, it usually refers to the color
of the geoms. The &lt;code&gt;fill&lt;/code&gt; argument is used to specify the color of the shapes in
certain cases. In this first section, we will see how we can specify the color
for the different geoms we learnt in the previous post.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;point&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Point&lt;/h4&gt;
&lt;p&gt;For points, the &lt;code&gt;color&lt;/code&gt; argument specifies the color of the point for certain
shapes and border for others. The &lt;code&gt;fill&lt;/code&gt; argument is used to specify the
background for some shapes and will not work with other shapes. Let us look at
an example:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(x = disp, y = mpg, color = factor(cyl))) +
  geom_point()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-27-ggplot2-introduction-to-aesthetics_files/figure-html/aes2-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;We can map the variable to color in the &lt;code&gt;geom_point()&lt;/code&gt; function as well since
it inherits the data from the &lt;code&gt;ggplot()&lt;/code&gt; function.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(x = disp, y = mpg)) +
  geom_point(aes(color = factor(cyl)))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-27-ggplot2-introduction-to-aesthetics_files/figure-html/aes3-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;If you do not want to map a variable to color, you can specify it separately
using the &lt;code&gt;color&lt;/code&gt; argument but in this case it should be outside the &lt;code&gt;aes()&lt;/code&gt;
function.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(x = disp, y = mpg)) +
  geom_point(color = &amp;#39;blue&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-27-ggplot2-introduction-to-aesthetics_files/figure-html/aes4-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Now we will change the shape of the points to understand the difference between
&lt;code&gt;color&lt;/code&gt; and &lt;code&gt;fill&lt;/code&gt; arguments. It can be again mapped to variables or values.
Let us map shape to variables.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(x = disp, y = mpg, shape = factor(cyl))) +
  geom_point()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-27-ggplot2-introduction-to-aesthetics_files/figure-html/aes5-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Let us map shape to &lt;code&gt;cyl&lt;/code&gt; in the &lt;code&gt;geom_point()&lt;/code&gt; function. Remember, when you
are mapping an aesthetic to a variable, it must be inside &lt;code&gt;aes()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(x = disp, y = mpg)) +
  geom_point(aes(shape = factor(cyl)))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-27-ggplot2-introduction-to-aesthetics_files/figure-html/aes6-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Instead of mapping shape to a variable, let us specify a value for shape. In
this case, &lt;code&gt;shape&lt;/code&gt; is not wrapped inside &lt;code&gt;aes()&lt;/code&gt; as we are not mapping it to
a variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(x = disp, y = mpg)) +
  geom_point(shape = 5)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-27-ggplot2-introduction-to-aesthetics_files/figure-html/aes7-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Let us specify a color for the point using &lt;code&gt;color&lt;/code&gt; argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(x = disp, y = mpg)) +
  geom_point(shape = 5, color = &amp;#39;blue&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-27-ggplot2-introduction-to-aesthetics_files/figure-html/aes8-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Background color cannot be added for all shapes. In the below example, we try
to modify the background color using the &lt;code&gt;fill&lt;/code&gt; argument but it does not work.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(x = disp, y = mpg)) +
  geom_point(shape = 5, fill = &amp;#39;blue&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-27-ggplot2-introduction-to-aesthetics_files/figure-html/aes9-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Since the shape number is now greater than 21, &lt;code&gt;fill&lt;/code&gt; argument will add background color
in the below case.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(x = disp, y = mpg)) +
  geom_point(shape = 22, fill = &amp;#39;blue&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-27-ggplot2-introduction-to-aesthetics_files/figure-html/aes10-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;In shapes greater than number 21, &lt;code&gt;color&lt;/code&gt; argument will modify the border of the shape.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(x = disp, y = mpg)) +
  geom_point(shape = 22, color = &amp;#39;blue&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-27-ggplot2-introduction-to-aesthetics_files/figure-html/aes11-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Let us map size of points to a variable. It is advised to map size only to
continuous variables and not categorical variables.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(x = disp, y = mpg, size = disp)) +
  geom_point()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-27-ggplot2-introduction-to-aesthetics_files/figure-html/aes12-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;If you map size to categorical variables, ggplot2 will throw a warning.&lt;/p&gt;
&lt;p&gt;Specify value for size.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(x = disp, y = mpg)) +
  geom_point(size = 4)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-27-ggplot2-introduction-to-aesthetics_files/figure-html/aes13-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;To modify the opacity of the color, use the &lt;code&gt;alpha&lt;/code&gt; argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(x = disp, y = mpg)) +
  geom_point(aes(alpha = factor(cyl)), color = &amp;#39;blue&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: Using alpha for a discrete variable is not advised.&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-27-ggplot2-introduction-to-aesthetics_files/figure-html/aes14-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;So far we have focussed on &lt;code&gt;geom_point()&lt;/code&gt; to learn how to map aesthetics to
variables. To explore line type and line width, we will use &lt;code&gt;geom_line()&lt;/code&gt;. In
the previous post, we used &lt;code&gt;geom_line()&lt;/code&gt; to build line charts. Now we will
modify the appearance of the line. In the section below, we will specify values
for color, line type and width. In the next section, we will map the same to
variables in the data. We will use a new data set. You can download it from
&lt;a href=&#34;https://github.com/rsquaredacademy/datasets/blob/master/gdp.csv&#34;&gt;here&lt;/a&gt;. It
contains GDP (Gross Domestic Product) growth data for the BRICS (Brazil,
Russia, India, China, South Africa) for the years 2000 to 2005.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;data-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;gdp &amp;lt;- readr::read_csv(&amp;#39;https://raw.githubusercontent.com/rsquaredacademy/datasets/master/gdp.csv&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: Missing column names filled in: &amp;#39;X1&amp;#39; [1]&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A line chart can be created using &lt;code&gt;geom_line()&lt;/code&gt;. In the below example, we
examine the GDP trend of India and modify the color of the line to &lt;code&gt;&#39;blue&#39;&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(gdp, aes(year, india)) +
  geom_line(color = &amp;#39;blue&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-27-ggplot2-introduction-to-aesthetics_files/figure-html/aes15-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;To modify the line type, use the &lt;code&gt;linetype&lt;/code&gt; argument. It can take values
between 1 and 5.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(gdp, aes(year, india)) +
  geom_line(linetype = 2)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-27-ggplot2-introduction-to-aesthetics_files/figure-html/aes16-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The line type can also be mentioned in the following way:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(gdp, aes(year, india)) +
  geom_line(linetype = &amp;#39;dashed&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-27-ggplot2-introduction-to-aesthetics_files/figure-html/aes17-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;The width of the line can be modified using the &lt;code&gt;size&lt;/code&gt; argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(gdp, aes(year, india)) +
  geom_line(size = 2)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-27-ggplot2-introduction-to-aesthetics_files/figure-html/aes18-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Now let us map the aesthetics to the variables. The data used in the above
example cannot be used as we need a variable with country names. We will use
&lt;code&gt;gather()&lt;/code&gt; function from the &lt;code&gt;tidyr&lt;/code&gt; package to reshape the data.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;gdp2 &amp;lt;- 
  gdp %&amp;gt;% 
  select(year, growth, india, china) %&amp;gt;% 
  gather(key = country, value = gdp, -year)

gdp2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 18 x 3
##    year       country   gdp
##    &amp;lt;date&amp;gt;     &amp;lt;chr&amp;gt;   &amp;lt;dbl&amp;gt;
##  1 2000-01-01 growth      6
##  2 2001-01-01 growth      9
##  3 2002-01-01 growth      8
##  4 2003-01-01 growth      9
##  5 2004-01-01 growth      9
##  6 2005-01-01 growth      8
##  7 2000-01-01 india       5
##  8 2001-01-01 india       9
##  9 2002-01-01 india       8
## 10 2003-01-01 india       8
## 11 2004-01-01 india       5
## 12 2005-01-01 india       7
## 13 2000-01-01 china       8
## 14 2001-01-01 china       5
## 15 2002-01-01 china       6
## 16 2003-01-01 china       8
## 17 2004-01-01 china       9
## 18 2005-01-01 china       8&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;To map the aesthetics to a variable, we must use the &lt;code&gt;group&lt;/code&gt; argument. In the
below example, we map the aesthetics to &lt;code&gt;country&lt;/code&gt;. But we cannot distinguish
between the lines as their color, width and line type are the same. We have
easily plotted the GDP trend of all countries using the &lt;code&gt;group&lt;/code&gt; argument. Now,
let us ensure that we can distinguish and identidy them using different
aesthetics.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(gdp2, aes(year, gdp, group = country)) +
  geom_line()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-27-ggplot2-introduction-to-aesthetics_files/figure-html/aes20-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Let us begin by ensuring that the lines have different color using the
&lt;code&gt;color&lt;/code&gt; argument within &lt;code&gt;aes()&lt;/code&gt; and assigning it the variable &lt;code&gt;country&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(gdp2, aes(year, gdp, group = country)) +
  geom_line(aes(color = country))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-27-ggplot2-introduction-to-aesthetics_files/figure-html/aes21-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Instead of color, now we modify the line type using the &lt;code&gt;linetype&lt;/code&gt; argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(gdp2, aes(year, gdp, group = country)) +
  geom_line(aes(linetype = country))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-27-ggplot2-introduction-to-aesthetics_files/figure-html/aes22-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;In the below instance, we assign different width to the lines using the &lt;code&gt;size&lt;/code&gt;
argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(gdp2, aes(year, gdp, group = country)) +
  geom_line(aes(size = country))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: Using size for a discrete variable is not advised.&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-27-ggplot2-introduction-to-aesthetics_files/figure-html/aes23-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Before we wrap up, let us quickly see how we can map aesthetics to variables
for different plots.&lt;/p&gt;
&lt;div id=&#34;bar-plots&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Bar Plots&lt;/h4&gt;
&lt;p&gt;Here we create a stacked bar plot by mapping &lt;code&gt;fill&lt;/code&gt; to &lt;code&gt;purchase&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom, aes(device, fill = purchase)) +
  geom_bar()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-27-ggplot2-introduction-to-aesthetics_files/figure-html/aes24-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;histograms&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Histograms&lt;/h4&gt;
&lt;p&gt;Instead of a bar chart, we create a histogram and again map &lt;code&gt;fill&lt;/code&gt; to
&lt;code&gt;purchase&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom) +
  geom_histogram(aes(duration, fill = purchase), bins = 10)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-27-ggplot2-introduction-to-aesthetics_files/figure-html/aes25-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;box-plots&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Box Plots&lt;/h4&gt;
&lt;p&gt;We repeat the same exercise below, but replace the bar plot with a box plot.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom) +
  geom_boxplot(aes(device, duration, fill = purchase))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-27-ggplot2-introduction-to-aesthetics_files/figure-html/aes26-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In all the above cases, you can observe that when we are mapping aesthetics
such as color, fill, shape, size or linetype to variables, they are all wrapped
inside &lt;code&gt;aes()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;In this post, we learnt about aesthetics i.e. how to modify the properties of
geoms such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;color&lt;/li&gt;
&lt;li&gt;shape&lt;/li&gt;
&lt;li&gt;size&lt;/li&gt;
&lt;li&gt;fill&lt;/li&gt;
&lt;li&gt;alpha&lt;/li&gt;
&lt;li&gt;width&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;up-next..&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Up Next..&lt;/h3&gt;
&lt;p&gt;In the next post, we will learn to modify the axis and labels of a plot.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>ggplot2 - Introduction to geoms</title>
      <link>https://blog.rsquaredacademy.com/ggplot2-introduction-to-geoms/</link>
      <pubDate>Sun, 15 Oct 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/ggplot2-introduction-to-geoms/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;This is the third post in the series &lt;strong&gt;Elegant Data Visualization with
ggplot2&lt;/strong&gt;. In the previous post, we learnt how to create plots using the
&lt;code&gt;qplot()&lt;/code&gt; function. In this post, we will create some of the most routinely
used plots to explore data using the &lt;code&gt;geom_*&lt;/code&gt; functions.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;p&gt;We will use the following libraries in this post:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://readr.tidyverse.org/&#34;&gt;readr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://ggplot2.tidyverse.org/&#34;&gt;ggplot2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://tibble.tidyverse.org/&#34;&gt;tibble&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://dplyr.tidyverse.org/&#34;&gt;dplyr&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt; and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/2d0d5d5b60d0ef0f4d1b227c8fb0335d&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ecom &amp;lt;- readr::read_csv(&amp;#39;https://raw.githubusercontent.com/rsquaredacademy/datasets/master/web.csv&amp;#39;)
ecom&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 1,000 x 11
##       id referrer device bouncers n_visit n_pages duration country purchase
##    &amp;lt;dbl&amp;gt; &amp;lt;chr&amp;gt;    &amp;lt;chr&amp;gt;  &amp;lt;lgl&amp;gt;      &amp;lt;dbl&amp;gt;   &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt; &amp;lt;chr&amp;gt;   &amp;lt;lgl&amp;gt;   
##  1     1 google   laptop TRUE          10       1      693 Czech ~ FALSE   
##  2     2 yahoo    tablet TRUE           9       1      459 Yemen   FALSE   
##  3     3 direct   laptop TRUE           0       1      996 Brazil  FALSE   
##  4     4 bing     tablet FALSE          3      18      468 China   TRUE    
##  5     5 yahoo    mobile TRUE           9       1      955 Poland  FALSE   
##  6     6 yahoo    laptop FALSE          5       5      135 South ~ FALSE   
##  7     7 yahoo    mobile TRUE          10       1       75 Bangla~ FALSE   
##  8     8 direct   mobile TRUE          10       1      908 Indone~ FALSE   
##  9     9 bing     mobile FALSE          3      19      209 Nether~ FALSE   
## 10    10 google   mobile TRUE           6       1      208 Czech ~ FALSE   
## # ... with 990 more rows, and 2 more variables: order_items &amp;lt;dbl&amp;gt;,
## #   order_value &amp;lt;dbl&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;div id=&#34;data-dictionary&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Data Dictionary&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;id: row id&lt;/li&gt;
&lt;li&gt;referrer: referrer website/search engine&lt;/li&gt;
&lt;li&gt;os: operating system&lt;/li&gt;
&lt;li&gt;browser: browser&lt;/li&gt;
&lt;li&gt;device: device used to visit the website&lt;/li&gt;
&lt;li&gt;n_pages: number of pages visited&lt;/li&gt;
&lt;li&gt;duration: time spent on the website (in seconds)&lt;/li&gt;
&lt;li&gt;repeat: frequency of visits&lt;/li&gt;
&lt;li&gt;country: country of origin&lt;/li&gt;
&lt;li&gt;purchase: whether visitor purchased&lt;/li&gt;
&lt;li&gt;order_value: order value of visitor (in dollars)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;scatter-plot&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Scatter Plot&lt;/h3&gt;
&lt;p&gt;A scatter plot displays the relationship between two continuous variables. In
ggplot2, we can build a scatter plot using &lt;code&gt;geom_point()&lt;/code&gt;. Scatterplots can
show you visually&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the strength of the relationship between the variables&lt;/li&gt;
&lt;li&gt;the direction of the relationship between the variables&lt;/li&gt;
&lt;li&gt;and whether outliers exist&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;div id=&#34;point&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Point&lt;/h4&gt;
&lt;p&gt;The variables representing the X and Y axis can be specified either in &lt;code&gt;ggplot()&lt;/code&gt;
or in &lt;code&gt;geom_point()&lt;/code&gt;. We will learn to modify the appearance of the points in a
different post.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom, aes(x = n_pages, y = duration)) + 
  geom_point()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-15-ggplot2-introduction-to-geoms_files/figure-html/geoms2-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;regression-line&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Regression Line&lt;/h4&gt;
&lt;p&gt;A regression line can be fit using either:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;geom_abline()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;geom_smooth()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;regression-line-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Regression Line&lt;/h4&gt;
&lt;p&gt;If you are using &lt;code&gt;geom_abline()&lt;/code&gt;, you need to specify the intercept and slope
as shown in the below example:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(x = wt, y = mpg)) +
  geom_point() + 
  geom_abline(intercept = 37.285, slope = -5.344)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-15-ggplot2-introduction-to-geoms_files/figure-html/geoms5-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;regression-line-2&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Regression Line&lt;/h4&gt;
&lt;p&gt;If you are using &lt;code&gt;geom_smooth()&lt;/code&gt;, you need to specify the method of fitting the
line, which can be &lt;code&gt;lm&lt;/code&gt; or &lt;code&gt;loess&lt;/code&gt;. You also need to indicate whether the
confidence interval must be displayed using the &lt;code&gt;se&lt;/code&gt; argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(x = wt, y = mpg)) +
  geom_smooth(method = &amp;#39;lm&amp;#39;, se = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## `geom_smooth()` using formula &amp;#39;y ~ x&amp;#39;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-15-ggplot2-introduction-to-geoms_files/figure-html/geoms6-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;loess-method&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Loess Method&lt;/h4&gt;
&lt;p&gt;Here we use the &lt;code&gt;&#39;loess&#39;&lt;/code&gt; method to fit the regression line.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(x = wt, y = mpg)) +
  geom_smooth(method = &amp;#39;loess&amp;#39;, se = FALSE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## `geom_smooth()` using formula &amp;#39;y ~ x&amp;#39;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-15-ggplot2-introduction-to-geoms_files/figure-html/geoms7-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;horizontalvertical-lines&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Horizontal/Vertical Lines&lt;/h4&gt;
&lt;p&gt;Add horizontal or vertical lines using&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;geom_hline()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;geom_vline()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;horizontal-line&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Horizontal Line&lt;/h4&gt;
&lt;p&gt;To add a horizontal line, the Y axis intercept must be supplied using the
&lt;code&gt;yintercept&lt;/code&gt; argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(x = wt, y = mpg)) +
  geom_point() +
  geom_hline(yintercept = 30) &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-15-ggplot2-introduction-to-geoms_files/figure-html/geoms4-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;vertical-line&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Vertical Line&lt;/h4&gt;
&lt;p&gt;For the vertical line, the X axis intercept must be supplied using the
&lt;code&gt;xintercept&lt;/code&gt; argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(x = wt, y = mpg)) +
  geom_point() +
  geom_vline(xintercept = 5) &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-15-ggplot2-introduction-to-geoms_files/figure-html/geoms3-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;bar-plot&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Bar Plot&lt;/h4&gt;
&lt;p&gt;Bar plots present grouped data with rectangular bars. The bars may represent
the frequency of the groups or values. Bar plots can be:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;horizontal&lt;/li&gt;
&lt;li&gt;vertical&lt;/li&gt;
&lt;li&gt;grouped&lt;/li&gt;
&lt;li&gt;stacked&lt;/li&gt;
&lt;li&gt;proportional&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;frequency&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Frequency&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom, aes(x = factor(device))) +
  geom_bar()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-15-ggplot2-introduction-to-geoms_files/figure-html/geoms8-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;weight&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Weight&lt;/h4&gt;
&lt;p&gt;If the bars should represent a continuous variable, use the &lt;code&gt;weight&lt;/code&gt; argument
within &lt;code&gt;aes()&lt;/code&gt;. In the below example, the bars do not represent the count of
devices, instead, they represent the total order value for each device type.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom, aes(x = factor(device))) +
  geom_bar(aes(weight = order_value))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-15-ggplot2-introduction-to-geoms_files/figure-html/geoms9-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;stacked-bar-plot&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Stacked Bar Plot&lt;/h4&gt;
&lt;p&gt;To create a stacked bar plot, the &lt;code&gt;fill&lt;/code&gt; argument must be mapped to a
categorical variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom, aes(x = factor(device))) +
  geom_bar(aes(fill = purchase))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-15-ggplot2-introduction-to-geoms_files/figure-html/geoms10-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;horizontal-bar-plot&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Horizontal Bar Plot&lt;/h4&gt;
&lt;p&gt;A horizontal bar plot can be created by flipping the coordinate axes using the
&lt;code&gt;coord_flip()&lt;/code&gt; function.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom, aes(x = factor(device))) +
  geom_bar(aes(fill = purchase)) +
  coord_flip()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-15-ggplot2-introduction-to-geoms_files/figure-html/geoms11-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;columns&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Columns&lt;/h4&gt;
&lt;p&gt;If the data has already been summarized, you can use &lt;code&gt;geom_col()&lt;/code&gt; instead of
&lt;code&gt;geom_bar()&lt;/code&gt;. In the below example, we have the total visits for each device
type. The data has already been summarized and as such we cannot use &lt;code&gt;geom_bar()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;device &amp;lt;- c(&amp;#39;laptop&amp;#39;, &amp;#39;mobile&amp;#39;, &amp;#39;tablet&amp;#39;)
visits &amp;lt;- c(30000, 12000, 5000)
traffic &amp;lt;- tibble::tibble(device, visits)
ggplot(traffic, aes(x = device, y = visits)) +
  geom_col(fill = &amp;#39;blue&amp;#39;) &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-15-ggplot2-introduction-to-geoms_files/figure-html/geoms12-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;boxplot&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Boxplot&lt;/h4&gt;
&lt;p&gt;The box plot is a standardized way of displaying the distribution of data
based on the five number summary: minimum, first quartile, median, third
quartile, and maximum. Box plots are useful for detecting outliers and for
comparing distributions. It shows the shape, central tendancy and variability
of the data. Use &lt;code&gt;geom_boxplot()&lt;/code&gt; to create a box plot.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom, aes(x = factor(device), y = n_pages)) +
  geom_boxplot()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-15-ggplot2-introduction-to-geoms_files/figure-html/geoms13-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;histogram&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Histogram&lt;/h4&gt;
&lt;p&gt;A histogram is a plot that can be used to examine the shape and spread of
continuous data. It looks very similar to a bar graph and can be used to detect
outliers and skewness in data. Use &lt;code&gt;geom_histogram()&lt;/code&gt; to create a histogram.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom, aes(x = duration)) +
  geom_histogram()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-15-ggplot2-introduction-to-geoms_files/figure-html/geoms15-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;You can control the number of bins using the &lt;code&gt;bins&lt;/code&gt; argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(ecom, aes(x = duration)) +
  geom_histogram(bins = 5)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-15-ggplot2-introduction-to-geoms_files/figure-html/geoms16-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;line&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Line&lt;/h4&gt;
&lt;p&gt;Line charts are used to examine trends over time. We will use a different data
set for exploring line plots.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Data&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;gdp &amp;lt;- readr::read_csv(&amp;#39;https://raw.githubusercontent.com/rsquaredacademy/datasets/master/gdp.csv&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: Missing column names filled in: &amp;#39;X1&amp;#39; [1]&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;gdp&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 6 x 6
##      X1     X year       growth india china
##   &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;date&amp;gt;      &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;
## 1     1     1 2000-01-01      6     5     8
## 2     2     2 2001-01-01      9     9     5
## 3     3     3 2002-01-01      8     8     6
## 4     4     4 2003-01-01      9     8     8
## 5     5     5 2004-01-01      9     5     9
## 6     6     6 2005-01-01      8     7     8&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Use &lt;code&gt;geom_line()&lt;/code&gt; to create a line chart. In the below plot, we chart the GDP
of India, the fastest growing economy in emerging markets, across years.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(gdp, aes(year, india)) +
  geom_line()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-15-ggplot2-introduction-to-geoms_files/figure-html/geomline1-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;The color and line type can be modified using the &lt;code&gt;color&lt;/code&gt; and &lt;code&gt;linetype&lt;/code&gt;
arguments. We will explore the different line types in an upcoming post.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(gdp, aes(year, india)) +
  geom_line(color = &amp;#39;blue&amp;#39;, linetype = &amp;#39;dashed&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-15-ggplot2-introduction-to-geoms_files/figure-html/geomline2-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;label&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Label&lt;/h4&gt;
&lt;p&gt;You can label the points using &lt;code&gt;geom_label()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(disp, mpg, label = rownames(mtcars))) +
  geom_label()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-15-ggplot2-introduction-to-geoms_files/figure-html/geoms20-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;text&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Text&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;geom_text()&lt;/code&gt; offers another way to add text to the plots. We will learn to
modify the appearance and location of the text in another post.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(mtcars, aes(disp, mpg, label = rownames(mtcars))) +
  geom_text(check_overlap = TRUE, size = 2)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-15-ggplot2-introduction-to-geoms_files/figure-html/geoms19-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;In this post, we learnt about different &lt;code&gt;geoms&lt;/code&gt; such as&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;geom_point()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;geom_line()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;geom_histogram()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;geom_bar()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;geom_boxplot()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;geom_abline()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;geom_text()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;up-next..&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Up Next..&lt;/h3&gt;
&lt;p&gt;In the next post, we will learn about aesthetics.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>ggplot2: Quick Tour</title>
      <link>https://blog.rsquaredacademy.com/ggplot2-quick-tour/</link>
      <pubDate>Tue, 03 Oct 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/ggplot2-quick-tour/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;This is the second post in the series &lt;strong&gt;Elegant Data Visualization with
ggplot2&lt;/strong&gt;. In the previous post, we understood the concept of grammar of
graphics and even built a bar plot step by step while exploring the different
components of a plot/chart. In this post, we will learn to quickly build a set
of plots that are routinely used to explore data using &lt;code&gt;qplot()&lt;/code&gt;. It can be
used to quickly create plots but also has certain limitations. Nevertheless, if
you want to quickly explore data using a single function, &lt;code&gt;qplot()&lt;/code&gt; is your friend.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;p&gt;We will use the following libraries in this post:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://readr.tidyverse.org/&#34;&gt;readr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://ggplot2.tidyverse.org/&#34;&gt;ggplot2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt;
and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/3b25fa07c60d44d561819d2c6ab77978&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;div id=&#34;scatter-plot&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Scatter Plot&lt;/h4&gt;
&lt;p&gt;Scatter plots are used to examine the relationship between two continuous
variables. The relationship can be examined across the levels of a categorical
variable as well. Let us begin by creating scatter plots. The first two inputs
are the variables/columns representing the X and Y axis. The next input is the
name of the data set.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;qplot(disp, mpg, data = mtcars)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-03-ggplot2-quick-tour_files/figure-html/gg2-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;If you want the relationship between the two variables to be represented by
both points and line, use the &lt;code&gt;geom&lt;/code&gt; argument and supply it the values using a
character vector.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;qplot(disp, mpg, data = mtcars, geom = c(&amp;#39;point&amp;#39;, &amp;#39;line&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-03-ggplot2-quick-tour_files/figure-html/gg3-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The color of the points can be mapped to a categorical variable, in our case
&lt;code&gt;cyl&lt;/code&gt;, using the color argument. Ensure that the variable is categorical using
&lt;code&gt;factor()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;qplot(disp, mpg, data = mtcars, color = factor(cyl))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-03-ggplot2-quick-tour_files/figure-html/gg4-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The shape and size of the points can also be mapped to variables using the
&lt;code&gt;shape&lt;/code&gt; and &lt;code&gt;size&lt;/code&gt; argument as shown in the below examples.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;qplot(disp, mpg, data = mtcars, shape = factor(cyl))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-03-ggplot2-quick-tour_files/figure-html/gg5-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Ensure that size is mapped to a continuous variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;qplot(disp, mpg, data = mtcars, size = qsec)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-03-ggplot2-quick-tour_files/figure-html/gg6-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;bar-plot&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Bar Plot&lt;/h4&gt;
&lt;p&gt;A bar plot represents data in rectangular bars. The length of the bars are
proportional to the values they represent. Bar plots can be either horizontal
or vertical. The X axis of the plot represents the levels or the categories and
the Y axis represents the frequency/count of the variable.&lt;/p&gt;
&lt;p&gt;To create a bar plot, the first input must be a categorical variable. You can
convert a variable to type &lt;code&gt;factor&lt;/code&gt; (R equivalent of categorical) using the
&lt;code&gt;factor()&lt;/code&gt; function. The next input is the name of the data set and the final
input is the &lt;code&gt;geom&lt;/code&gt; which is supplied the value &lt;code&gt;&#39;bar&#39;&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;qplot(factor(cyl), data = mtcars, geom = c(&amp;#39;bar&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-03-ggplot2-quick-tour_files/figure-html/gg7-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;
You can create a stacked bar plot using the &lt;code&gt;fill&lt;/code&gt; argument and mapping it to
another categorical variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;qplot(factor(cyl), data = mtcars, geom = c(&amp;#39;bar&amp;#39;), fill = factor(am))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-03-ggplot2-quick-tour_files/figure-html/gg8-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;box-plot&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Box Plot&lt;/h4&gt;
&lt;p&gt;The box plot is a standardized way of displaying the distribution of data
based on the five number summary: minimum, first quartile, median, third
quartile, and maximum. Box plots are useful for detecting outliers and for
comparing distributions. It shows the shape, central tendancy and variability
of the data.&lt;/p&gt;
&lt;p&gt;Box plots can be created by supplying the value &lt;code&gt;&#39;boxplot&#39;&lt;/code&gt; to the &lt;code&gt;geom&lt;/code&gt;
argument. The firstinput must be a categorical variable and the second must be
a continuous variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;qplot(factor(cyl), mpg, data = mtcars, geom = c(&amp;#39;boxplot&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-03-ggplot2-quick-tour_files/figure-html/gg9-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Unlike &lt;code&gt;plot()&lt;/code&gt;, we cannot create box plots using a single variable. If you are
not comparing the distribution of a variable across the levels of a categorical
variable, you must supply the value &lt;code&gt;1&lt;/code&gt; as the first input as show below.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;qplot(factor(1), mpg, data = mtcars, geom = c(&amp;#39;boxplot&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-03-ggplot2-quick-tour_files/figure-html/gg10-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;line-chart&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Line Chart&lt;/h4&gt;
&lt;p&gt;Line charts are used to examing trends across time. To create a line chart,
supply the value &lt;code&gt;&#39;line&#39;&lt;/code&gt; to the &lt;code&gt;geom&lt;/code&gt; argument. The first two inputs should
be names of the columns/variables representing the X and Y axis, and the third
input must be the name of the data set.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;qplot(x = date, y = unemploy, data = economics, geom = c(&amp;#39;line&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-03-ggplot2-quick-tour_files/figure-html/gg12-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The appearance of the line can be modified using the &lt;code&gt;color&lt;/code&gt; argument as shown below.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;qplot(x = date, y = unemploy, data = economics, geom = c(&amp;#39;line&amp;#39;),
      color = &amp;#39;red&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-03-ggplot2-quick-tour_files/figure-html/gg13-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;histogram&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Histogram&lt;/h4&gt;
&lt;p&gt;A histogram is a plot that can be used to examine the shape and spread of
continuous data. It looks very similar to a bar graph and can be used to detect
outliers and skewness in data. A histogram is created using the &lt;code&gt;bins&lt;/code&gt; argument
as shown below. The first input is the name of the continuous variable and the
second is the name of the data set.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;qplot(mpg, data = mtcars, bins = 5)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-10-03-ggplot2-quick-tour_files/figure-html/gg14-1.png&#34; width=&#34;576&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;In this post, we learnt to quickly create plots using the &lt;code&gt;qplot()&lt;/code&gt; function. While useful, it has limitations and can be used only to quickly visualize data.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;up-next..&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Up Next..&lt;/h3&gt;
&lt;p&gt;In the next post, we will create the same set of plots but using &lt;strong&gt;geoms&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Data Visualization with R - Combining Plots</title>
      <link>https://blog.rsquaredacademy.com/data-visualization-with-r-combining-plots/</link>
      <pubDate>Sat, 09 Sep 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/data-visualization-with-r-combining-plots/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;This is the tenth post in the series &lt;strong&gt;Data Visualization With R&lt;/strong&gt;. In the previous post, we learnt how to add text annotations to plots. In this post, we will learn how to combine multiple plots. Often, it is useful to have multiple plots in the same frame as it allows us to get a comprehensive view of a particular variable or compare among different variables. The Graphics package offers two methods to combine multiple plots. &lt;code&gt;par()&lt;/code&gt; can be used to set graphical parameters regarding plot layout using the mfcol and mfrow arguments. &lt;code&gt;layout()&lt;/code&gt; serves the same purpose but offers more flexibility by allowing us to modify the height and width of rows and columns.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;par()&lt;/code&gt; allows us to customize the graphical parameters(title, axis, font, color, size) for a particular session. For combining multiple plots, we can use the graphical parameters mfrow and mfcol. These two parameters create a matrix of plots filled by rows and columns respectively. Let us combine plots using both the above parameters.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;left&#34;&gt;Option&lt;/th&gt;
&lt;th align=&#34;left&#34;&gt;Description&lt;/th&gt;
&lt;th align=&#34;left&#34;&gt;Arguments&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;left&#34;&gt;mfrow&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;Fill by rows&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;Number of rows and columns&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;left&#34;&gt;mfcol&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;Fill by columns&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;Number of rows and columns&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;mfrow combines plots filled by rows i.e it takes two arguments, the number of rows and number of columns and then starts filling the plots by row. Below is the syntax for mfrow.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# mfrow syntax
mfrow(number of rows, number of columns)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us begin by combining 4 plots in 2 rows and 2 columns:&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt; and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/8fc6a6d21c5ab8a0a68f11df51074a9d&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;case-study-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Case Study 1&lt;/h3&gt;
&lt;p&gt;Let us begin by combining 4 plots in 2 rows and 2 columns. The plots will be filled by rows as we are using the mfrow function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# store the current parameter settings in init
init &amp;lt;- par(no.readonly=TRUE)
 
# specify that 4 graphs to be combined and filled by rows
par(mfrow = c(2, 2))
 
# specify the graphs to be combined
plot(mtcars$mpg)
plot(mtcars$disp, mtcars$mpg)
hist(mtcars$mpg)
boxplot(mtcars$mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-09-09-data-visualization-with-r-combining-plots_files/figure-html/facet1-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt; 
# restore the setting stored in init
par(init)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;case-study-2&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Case Study 2&lt;/h3&gt;
&lt;p&gt;Combine 2 plots in 1 row and 2 columns.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# store the current parameter settings in init
init &amp;lt;- par(no.readonly=TRUE)
 
# specify that 2 graphs to be combined and filled by rows
par(mfrow = c(1, 2))
 
# specify the graphs to be combined
hist(mtcars$mpg)
boxplot(mtcars$mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-09-09-data-visualization-with-r-combining-plots_files/figure-html/facet2-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt; 
# restore the setting stored in init
par(init)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;case-study-3&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Case Study 3&lt;/h3&gt;
&lt;p&gt;Combine 2 plots in 2 rows and 1 column.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# store the current parameter settings in init
init &amp;lt;- par(no.readonly=TRUE)
 
# specify that 2 graphs to be combined and filled by rows
par(mfrow = c(2, 1))
 
# specify the graphs to be combined
hist(mtcars$mpg)
boxplot(mtcars$mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-09-09-data-visualization-with-r-combining-plots_files/figure-html/facet3-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt; 
# restore the setting stored in init
par(init)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;case-study-4&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Case Study 4&lt;/h3&gt;
&lt;p&gt;Combine 3 plots in 1 row and 3 columns.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# store the current parameter settings in init
init &amp;lt;- par(no.readonly=TRUE)
 
# specify that 3 graphs to be combined and filled by rows
par(mfrow = c(1, 3))
 
# specify the graphs to be combined
plot(mtcars$disp, mtcars$mpg)
hist(mtcars$mpg)
boxplot(mtcars$mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-09-09-data-visualization-with-r-combining-plots_files/figure-html/facet4-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt; 
# restore the setting stored in init
par(init)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;case-study-5&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Case Study 5&lt;/h3&gt;
&lt;p&gt;Combine 3 plots in 3 rows and 1 column.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# store the current parameter settings in init
init &amp;lt;- par(no.readonly=TRUE)
 
# specify that 3 graphs to be combined and filled by rows
par(mfrow = c(3, 1))
 
# specify the graphs to be combined
plot(mtcars$disp, mtcars$mpg)
hist(mtcars$mpg)
boxplot(mtcars$mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-09-09-data-visualization-with-r-combining-plots_files/figure-html/facet5-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt; 
# restore the setting stored in init
par(init)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;mfcol&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;mfcol&lt;/h3&gt;
&lt;p&gt;mfcol combines plots filled by columns i.e it takes two arguments, the number of rows and number of columns and then starts filling the plots by columns. Below is the syntax for mfrow:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# mfcol syntax
mfcol(number of rows, number of columns)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us begin by combining 4 plots in 2 rows and 2 columns:&lt;/p&gt;
&lt;div id=&#34;case-study-6&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Case Study 6&lt;/h4&gt;
&lt;p&gt;Combine 3 plots in 3 rows and 1 column.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# store the current parameter settings in init
init &amp;lt;- par(no.readonly=TRUE)
 
# specify that 4 graphs to be combined and filled by columns 
par(mfcol = c(2, 2))
 
# specify the graphs to be combined
plot(mtcars$mpg)
plot(mtcars$disp, mtcars$mpg)
hist(mtcars$mpg)
boxplot(mtcars$mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-09-09-data-visualization-with-r-combining-plots_files/figure-html/facet6-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt; 
# restore the setting stored in init
par(init)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;special-cases&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Special Cases&lt;/h3&gt;
&lt;p&gt;What happens if we specify lesser or more number of graphs? In the next two examples, we will specify lesser or more number of graphs than we ask the par() function to combine. Let us see what happens in such instances:&lt;/p&gt;
&lt;p&gt;Case 1: Lesser number of graphs specified
We will specify that 4 plots need to be combined in 2 rows and 2 columns but provide only 3 graphs.&lt;/p&gt;
&lt;p&gt;Case 2: Extra graph specified
We will specify that 4 plots need to be combined in 2 rows and 2 columns but specify 6 graphs instead of 4.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;case-study-7&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Case Study 7&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# store the current parameter settings in init
init &amp;lt;- par(no.readonly=TRUE)
 
# specify that 4 graphs to be combined and filled by rows
par(mfrow = c(2, 2))
 
# specify the graphs to be combined
plot(mtcars$disp, mtcars$mpg)
hist(mtcars$mpg)
boxplot(mtcars$mpg)
 
# restore the setting stored in init
par(init)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-09-09-data-visualization-with-r-combining-plots_files/figure-html/facet7-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;case-study-8&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Case Study 8&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# store the current parameter settings in init
init &amp;lt;- par(no.readonly=TRUE)
 
# specify that 4 graphs to be combined and filled by rows
par(mfrow = c(2, 2))
 
# specify the graphs to be combined
plot(mtcars$mpg)
plot(mtcars$disp, mtcars$mpg)
hist(mtcars$mpg)
boxplot(mtcars$mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-09-09-data-visualization-with-r-combining-plots_files/figure-html/facet8-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(mtcars$disp, mtcars$mpg)
boxplot(mtcars$mpg)

# restore the setting stored in init
par(init)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-09-09-data-visualization-with-r-combining-plots_files/figure-html/facet8-2.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;layout&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Layout&lt;/h3&gt;
&lt;p&gt;At the core of the layout() function is a matrix. We communicate the structure in which the plots must be combined using a matrix. As such, the layout function is more flexible compared to the par() function.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;left&#34;&gt;Option&lt;/th&gt;
&lt;th align=&#34;left&#34;&gt;Description&lt;/th&gt;
&lt;th align=&#34;left&#34;&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;left&#34;&gt;matrix&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;matrix specifying location of plants&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;matrix&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;left&#34;&gt;widths&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;width of columns&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;vector&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;left&#34;&gt;heights&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;height of rows&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;vector&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Let us begin by combining 4 plots in a 2 row/2 column structure. We do this by creating a layout using the matrix function.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;case-study-1-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Case Study 1&lt;/h3&gt;
&lt;p&gt;Combine 4 plots in 2 rows/2 columns filled by rows.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# specify the layout
# 4 plots to be combined in 2 row/ 2 columns and arranged by row
layout(matrix(c(1, 2, 3, 4), nrow = 2, byrow = TRUE))
 
# specify the 4 plots
plot(mtcars$disp, mtcars$mpg)
hist(mtcars$mpg)
boxplot(mtcars$mpg)
plot(mtcars$mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-09-09-data-visualization-with-r-combining-plots_files/figure-html/facet9-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;case-study-2-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Case Study 2&lt;/h3&gt;
&lt;p&gt;Combine 4 plots in 2 rows/2 columns filled by columns&lt;/p&gt;
&lt;p&gt;To fill the plots by column, we specify byrow = FALSE in the matrix.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# specify the layout
# 4 plots to be combined in 2 row/ 2 columns and filled by columns
layout(matrix(c(1, 2, 3, 4), nrow = 2, byrow = FALSE))
 
# specify the 4 plots
plot(mtcars$disp, mtcars$mpg)
hist(mtcars$mpg)
boxplot(mtcars$mpg)
plot(mtcars$mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-09-09-data-visualization-with-r-combining-plots_files/figure-html/facet10-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;case-study-3-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Case Study 3&lt;/h3&gt;
&lt;p&gt;Combine 3 plots in 2 rows/2 columns filled by rows&lt;/p&gt;
&lt;p&gt;The magic of the layout() function begins here. We want to combine 3 plots and the first plot should occupy both the columns in row 1 and the next 2 plots should be in row 2. If you look at the matrix below, 1 is specified twice and since the matrix is filled by row, it will occupy both the columns in the first row. Similarly the first plot will occupy the entire first row. It will be crystal clear when you see the plot.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# specify the matrix
matrix(c(1, 1, 2, 3), nrow = 2, byrow = TRUE)
##      [,1] [,2]
## [1,]    1    1
## [2,]    2    3

# 3 plots to be combined in 2 row/ 2 columns and arranged by row
layout(matrix(c(1, 1, 2, 3), nrow = 2, byrow = TRUE))
 
# specify the 3 plots
plot(mtcars$disp, mtcars$mpg)
hist(mtcars$mpg)
boxplot(mtcars$mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-09-09-data-visualization-with-r-combining-plots_files/figure-html/facet11-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;case-study-4-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Case Study 4&lt;/h3&gt;
&lt;p&gt;Combine 3 plots in 2 rows/2 columns filled by rows&lt;/p&gt;
&lt;p&gt;The plots must be filled by rows and the third plot must occupy both the columns of the second row while the other two plots will be placed in the first row. The matrix would look like this:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# specify the matrix
matrix(c(1, 2, 3, 3), nrow = 2, byrow = TRUE)
##      [,1] [,2]
## [1,]    1    2
## [2,]    3    3

# 3 plots to be combined in 2 row/ 2 columns and arranged by row
layout(matrix(c(1, 2, 3, 3), nrow = 2, byrow = TRUE))
 
# specify the 3 plots
hist(mtcars$mpg)
boxplot(mtcars$mpg)
plot(mtcars$disp, mtcars$mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-09-09-data-visualization-with-r-combining-plots_files/figure-html/facet12-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;case-study-5-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Case Study 5&lt;/h3&gt;
&lt;p&gt;Combine 3 plots in 2 rows/2 columns filled by columns&lt;/p&gt;
&lt;p&gt;The plots must be filled by columns and the first plot must occupy both the rows of the first column while the other two plots will be placed in the second column in two rows. The matrix would look like this:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# specify the matrix
matrix(c(1, 1, 2, 3), nrow = 2, byrow = FALSE)
##      [,1] [,2]
## [1,]    1    2
## [2,]    1    3

# 3 plots to be combined in 2 row/ 2 columns and arranged by columns
layout(matrix(c(1, 1, 2, 3), nrow = 2, byrow = FALSE))
 
# specify the 3 plots
hist(mtcars$mpg)
plot(mtcars$disp, mtcars$mpg)
boxplot(mtcars$mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-09-09-data-visualization-with-r-combining-plots_files/figure-html/facet13-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;case-study-6-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Case Study 6&lt;/h3&gt;
&lt;p&gt;Combine 3 plots in 2 rows/2 columns filled by columns&lt;/p&gt;
&lt;p&gt;The plots must be filled by columns and the first plot must occupy both the rows of the second column while the other two plots will be placed in the first column in two rows. The matrix would look like this:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# specify the matrix
matrix(c(1, 2, 3, 3), nrow = 2, byrow = FALSE)
##      [,1] [,2]
## [1,]    1    3
## [2,]    2    3

# 3 plots to be combined in 2 row/ 2 columns and arranged by columns
layout(matrix(c(1, 2, 3, 3), nrow = 2, byrow = FALSE))
 
# specify the 3 plots
boxplot(mtcars$mpg)
plot(mtcars$disp, mtcars$mpg)
hist(mtcars$mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-09-09-data-visualization-with-r-combining-plots_files/figure-html/facet14-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;widths&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Widths&lt;/h3&gt;
&lt;p&gt;In all the layouts created so far, we have kept the size of the rows and columns equal. What if you want to modify the width and height of the columns and rows? The widths and heights arguments in the layout() function address the above mentioned issue. Let us check them out one by one: The widths argument is used for specifying the width of the columns. Based on the number of columns in the layout, you can specify the width of each column. Let us look at some examples.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;case-study-7-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Case Study 7&lt;/h3&gt;
&lt;p&gt;Width of the 2nd column is twice the width of the 1st column&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# specify the matrix
matrix(c(1, 2, 3, 4), nrow = 2, byrow = TRUE)
##      [,1] [,2]
## [1,]    1    2
## [2,]    3    4

# 4 plots to be combined in 2 row/ 2 columns and arranged by columns
layout(matrix(c(1, 2, 3, 4), nrow = 2, byrow = TRUE), widths = c(1, 3))
 
# specify the plots
plot(mtcars$disp, mtcars$mpg)
hist(mtcars$mpg)
boxplot(mtcars$mpg)
plot(mtcars$mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-09-09-data-visualization-with-r-combining-plots_files/figure-html/facet15-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;case-study-8-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Case Study 8&lt;/h3&gt;
&lt;p&gt;Width of the 2nd column is twice that of the first and last column&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# specify the matrix
matrix(c(1, 2, 3, 4, 5, 6), nrow = 2, byrow = TRUE)
##      [,1] [,2] [,3]
## [1,]    1    2    3
## [2,]    4    5    6

# 6 plots to be combined in 2 row/ 3 columns and filled by rows
layout(matrix(c(1, 2, 3, 4, 5, 6), nrow = 2, byrow = TRUE), widths = c(1, 2, 1))
 
# specify the plots
plot(mtcars$disp, mtcars$mpg)
hist(mtcars$mpg)
boxplot(mtcars$mpg)
plot(mtcars$mpg)
hist(mtcars$mpg)
boxplot(mtcars$mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-09-09-data-visualization-with-r-combining-plots_files/figure-html/facet16-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;heights&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Heights&lt;/h3&gt;
&lt;p&gt;The heights arguments is used to modify the height of the rows and based on the number of rows specified in the layout, we can specify the height of each row.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;case-study-9&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Case Study 9&lt;/h3&gt;
&lt;p&gt;Height of the 2nd row is twice that of the first row&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# 4 plots to be combined in 2 row/ 2 columns and filled by rows
layout(matrix(c(1, 2, 3, 4), nrow = 2, byrow = TRUE), heights= c(1, 2))
 
# specify the 4 plots
plot(mtcars$disp, mtcars$mpg)
hist(mtcars$mpg)
boxplot(mtcars$mpg)
plot(mtcars$mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-09-09-data-visualization-with-r-combining-plots_files/figure-html/facet17-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;putting-it-all-together&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Putting it all together…&lt;/h3&gt;
&lt;p&gt;Before we end this section, let us combine plots using both the widths and heights option&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# specify the matrix
matrix(c(1, 2, 3, 4, 5, 6), nrow = 3, byrow = TRUE)
##      [,1] [,2]
## [1,]    1    2
## [2,]    3    4
## [3,]    5    6

# 6 plots to be combined in 3 row/ 2 columns and arranged by rows
layout(matrix(c(1, 2, 3, 4, 5, 6), nrow = 3, byrow = TRUE), heights= c(1, 2, 1),
widths = c(2, 1))
 
# specify the 6 plots
plot(mtcars$disp, mtcars$mpg)
hist(mtcars$mpg)
boxplot(mtcars$mpg)
plot(mtcars$mpg)
hist(mtcars$mpg)
boxplot(mtcars$mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-09-09-data-visualization-with-r-combining-plots_files/figure-html/facet18-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Data Visualization with R - Text Annotations</title>
      <link>https://blog.rsquaredacademy.com/data-visualization-with-r-text-annotations/</link>
      <pubDate>Mon, 28 Aug 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/data-visualization-with-r-text-annotations/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;This is the ninth post in the series &lt;strong&gt;Data Visualization With R&lt;/strong&gt;. In the previous post, we learnt how to add legend to a plot. In this post, we will learn to add text annotations. There are occassions when you want to display additional information in a plot. This is usually achieved by adding text either inside the plot or on the margins. For example, you might want to label a line/bar or add formulas to better communicate what is shown in the plot. The idea is to use the available space within/outside the plot to provide additional information that can be useful to the end users. We will learn to add text inside as well as on the margins of the plot. This is accomplished using the following two functions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;text()&lt;/code&gt; : add text inside the plot&lt;/li&gt;
&lt;li&gt;&lt;code&gt;mtext()&lt;/code&gt; : add text on the margins of the plot&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt; and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/7a445b32ca3a6e1f75e7d4bbf66cb702&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;syntax&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Syntax&lt;/h3&gt;
&lt;p&gt;Let us take a quick look at the syntax of both the functions:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;text(x, y = NULL, labels = seq_along(x$x), adj = NULL,
     pos = NULL, offset = 0.5, vfont = NULL,
     cex = 1, col = NULL, font = NULL, ...)

mtext(text, side = 3, line = 0, outer = FALSE, at = NA,
      adj = NA, padj = NA, cex = NA, col = NA, font = NA, ...)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;text-inside-the-plot&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Text Inside the Plot&lt;/h3&gt;
&lt;p&gt;To add text inside a plot, the following arguments must be supplied to the &lt;code&gt;text()&lt;/code&gt; function:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;labels&lt;/code&gt; : the text to be displayed&lt;/li&gt;
&lt;li&gt;&lt;code&gt;x&lt;/code&gt; : x axis coordinate&lt;/li&gt;
&lt;li&gt;&lt;code&gt;y&lt;/code&gt; : y axis coordinate&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Below is a simple example:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(mtcars$disp, mtcars$mpg)
text(x = 340, y = 30, labels = &amp;#39;Sample Text&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-28-data-visualization-with-r-text-annotations_files/figure-html/text1-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The text appears at the coordinates (340, 30). Ensure that the text is enclosed in single/double quotes and the coordinates provided are within the range of the &lt;strong&gt;X&lt;/strong&gt; and &lt;strong&gt;Y&lt;/strong&gt; axis variables.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;color&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Color&lt;/h3&gt;
&lt;p&gt;The color of the text can be modified using the &lt;code&gt;col&lt;/code&gt; argument in the &lt;code&gt;text()&lt;/code&gt; function.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(mtcars$disp, mtcars$mpg)
text(x = 340, y = 30, labels = &amp;#39;Sample Text&amp;#39;, col = &amp;#39;red&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-28-data-visualization-with-r-text-annotations_files/figure-html/text2-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The below plot depicts the appearance of the text for different values of the &lt;code&gt;col&lt;/code&gt; argument:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-28-data-visualization-with-r-text-annotations_files/figure-html/text3-1.png&#34; width=&#34;1440&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;font&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Font&lt;/h3&gt;
&lt;p&gt;The font of the text can be modified using the &lt;code&gt;font&lt;/code&gt; argument in the &lt;code&gt;text()&lt;/code&gt; function.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(mtcars$disp, mtcars$mpg)
text(x = 340, y = 30, labels = &amp;#39;Sample Text&amp;#39;, col = &amp;#39;red&amp;#39;, font = 2)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-28-data-visualization-with-r-text-annotations_files/figure-html/text4-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The below plot depicts the appearance of the text for different values of the &lt;code&gt;font&lt;/code&gt; argument:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-28-data-visualization-with-r-text-annotations_files/figure-html/text5-1.png&#34; width=&#34;960&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;font-family&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Font Family&lt;/h3&gt;
&lt;p&gt;The font family of the text can be modified using the &lt;code&gt;family&lt;/code&gt; argument in the &lt;code&gt;text()&lt;/code&gt; function.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(mtcars$disp, mtcars$mpg)
text(x = 340, y = 30, labels = &amp;#39;Sample Text&amp;#39;, col = &amp;#39;red&amp;#39;, family = &amp;#39;mono&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-28-data-visualization-with-r-text-annotations_files/figure-html/text6-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The below plot depicts the appearance of the text for different values of the &lt;code&gt;family&lt;/code&gt; argument:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;## Warning in text.default(x = 340, y = 30, labels = &amp;quot;Sample Text&amp;quot;, col = &amp;quot;red&amp;quot;, :
## font family not found in Windows font database&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-28-data-visualization-with-r-text-annotations_files/figure-html/text7-1.png&#34; width=&#34;1440&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;font-size&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Font Size&lt;/h3&gt;
&lt;p&gt;The font size of the text can be modified using the &lt;code&gt;cex&lt;/code&gt; argument in the &lt;code&gt;text()&lt;/code&gt; function.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(mtcars$disp, mtcars$mpg)
text(x = 340, y = 30, labels = &amp;#39;Sample Text&amp;#39;, col = &amp;#39;red&amp;#39;, cex = 2)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-28-data-visualization-with-r-text-annotations_files/figure-html/text8-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The below plot depicts the appearance of the text for different values of the &lt;code&gt;cex&lt;/code&gt; argument:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-28-data-visualization-with-r-text-annotations_files/figure-html/text9-1.png&#34; width=&#34;1440&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;text-on-the-margins&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Text on the Margins&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;mtext()&lt;/code&gt; function allows the user to place the text on the margins of the plot. It allows the user to modify the location of the text in multiple ways and we will explore them one by one. To beign with, let us add text to the plot using the &lt;code&gt;mtext()&lt;/code&gt; function. The minimum input you need to provide is the text itself. Below is a simple example:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(mtcars$disp, mtcars$mpg)
mtext(&amp;#39;Sample Text&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-28-data-visualization-with-r-text-annotations_files/figure-html/mtext1-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As you can see, the text is placed on the margin of the plot and not inside the plot. Next, we will specify the margin on which to place the text.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;specify-margin&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Specify Margin&lt;/h3&gt;
&lt;p&gt;Use the &lt;code&gt;side&lt;/code&gt; argument to specify the margin on which you want to place the text. If takes values 1 to 4, each representing one side of the plot.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(mtcars$disp, mtcars$mpg)
mtext(&amp;#39;Sample Text&amp;#39;, side = 1)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-28-data-visualization-with-r-text-annotations_files/figure-html/mtext2-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The below plot displays the appearance of the text when differnt options for &lt;code&gt;side&lt;/code&gt; argument are supplied:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-28-data-visualization-with-r-text-annotations_files/figure-html/mtext3-1.png&#34; width=&#34;960&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;line&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Line&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;line&lt;/code&gt; argument places the text at a specified distance from the margin. The default value is &lt;code&gt;0&lt;/code&gt;. As the value increases, the text is placed farther from the margin and outside the plot. As the value decreases, the text is placed inside the plot and farther from the margin. Below is a example where the text is placed outside the plot as the value is greater than 1.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(mtcars$disp, mtcars$mpg)
mtext(&amp;#39;Sample Text&amp;#39;, line = 1)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-28-data-visualization-with-r-text-annotations_files/figure-html/mtext4-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;When the value is less than &lt;code&gt;0&lt;/code&gt;, the line argument places the text inside the plot.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(mtcars$disp, mtcars$mpg)
mtext(&amp;#39;Sample Text&amp;#39;, line = -1)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-28-data-visualization-with-r-text-annotations_files/figure-html/mtext5-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The below plot displays the appearance of the text when different values are supplied to the &lt;code&gt;line&lt;/code&gt; argument:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-28-data-visualization-with-r-text-annotations_files/figure-html/mtext6-1.png&#34; width=&#34;1440&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;alignment&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Alignment&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;adj&lt;/code&gt; argument is used for horizontal alignment of the text. It takes values between 0 and 1. If set to &lt;code&gt;0&lt;/code&gt;, the text will be left aligned and at &lt;code&gt;1&lt;/code&gt;, it will be right aligned. Below is a example where the text is left aligned as &lt;code&gt;adj&lt;/code&gt; is set to &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(mtcars$disp, mtcars$mpg)
mtext(&amp;#39;Sample Text&amp;#39;, adj = 0)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-28-data-visualization-with-r-text-annotations_files/figure-html/mtext7-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;When the value is set to &lt;code&gt;1&lt;/code&gt;, the text is right aligned.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(mtcars$disp, mtcars$mpg)
mtext(&amp;#39;Sample Text&amp;#39;, adj = 1)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-28-data-visualization-with-r-text-annotations_files/figure-html/mtext8-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The below plot displays the appearance of the text when different values are supplied to the &lt;code&gt;adj&lt;/code&gt; argument:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-28-data-visualization-with-r-text-annotations_files/figure-html/mtext9-1.png&#34; width=&#34;1440&#34; style=&#34;display: block; margin: auto;&#34; /&gt;
### Summary&lt;/p&gt;
&lt;p&gt;In this post, we learnt how to add text annotations to a plot. Specifically, we learnt to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;add text inside the plot&lt;/li&gt;
&lt;li&gt;add text on the margins of the plot&lt;/li&gt;
&lt;li&gt;modify tehe color, font and size of the text&lt;/li&gt;
&lt;li&gt;modify the position of the text&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;up-next..&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Up Next..&lt;/h3&gt;
&lt;p&gt;In the next post, we will learn how to combine multiple plots into a single frame.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Data Visualization with R - Legends</title>
      <link>https://blog.rsquaredacademy.com/data-visualization-with-r-legends/</link>
      <pubDate>Wed, 16 Aug 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/data-visualization-with-r-legends/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;This is the eighth post in the series &lt;strong&gt;Data Visualisation With R&lt;/strong&gt;. In the previous post, we learnt to build histograms. In this post, we will learn how to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;position the legend within the plot&lt;/li&gt;
&lt;li&gt;modify the layout using &lt;code&gt;ncol&lt;/code&gt; and &lt;code&gt;horiz&lt;/code&gt; arguments&lt;/li&gt;
&lt;li&gt;add title using the &lt;code&gt;title&lt;/code&gt; set of arguments&lt;/li&gt;
&lt;li&gt;modify the appearance and position of the legend box&lt;/li&gt;
&lt;li&gt;modify the appearance of the text in the legend box&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Legends are used to convey information about the data being represented by a plot. To understand the importance of legends, let us look at the two plots below. In the first plot, would you be able to understand what the lines represent in the absence of a legend? May be yes but only if the author provides information in a textual form outside the plot. While such information will be useful, it will also be very inconvenient. Now look at the second plot, from the legend at the top right we can easily interpret what the lines represent. Would you agree that a legend is integral to plot representing multiple data? If yes, let us go ahead and learn how to add a legend to different plots.&lt;/p&gt;
&lt;p&gt;Since we have looked at a line graph in the above example, we will learn how to add a legend to a line graph. After that, we will generalise the steps to different plots.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt; and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/0036a9cc1ca779965f45c38af260dcdc&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data&lt;/h3&gt;
&lt;p&gt;Let us build a line graph that represents annual economic growth (GDP) data of the BRICS nations for the years 2010-14.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;year &amp;lt;- seq(2010, 2014, 1)
india &amp;lt;- c(10.3, 6.6, 5.6, 6.6, 7.2)
china &amp;lt;- c(10.6, 9.5, 7.8, 7.7, 7.3)
russia &amp;lt;- c(4.5, 4.3, 3.5, 1.3, 0.7)
brazil &amp;lt;- c(7.5, 3.9, 1.9, 3.0, 0.1)
s_africa &amp;lt;- c(3.2, 3.2, 2.2, 2.2, 1.5)
gdp &amp;lt;- data.frame(year, india, china, russia, brazil, s_africa, stringsAsFactors = FALSE)
gdp&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   year india china russia brazil s_africa
## 1 2010  10.3  10.6    4.5    7.5      3.2
## 2 2011   6.6   9.5    4.3    3.9      3.2
## 3 2012   5.6   7.8    3.5    1.9      2.2
## 4 2013   6.6   7.7    1.3    3.0      2.2
## 5 2014   7.2   7.3    0.7    0.1      1.5&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;line-graph&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Line Graph&lt;/h3&gt;
&lt;p&gt;Below is the line graph that represents the above GDP data set:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-16-data-visualization-with-r-legends_files/figure-html/line1-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Without a legend, it will be very difficult to map the lines to the BRICS nations. We will add a legend to the above plot using the &lt;code&gt;legend()&lt;/code&gt; function and do so one step at a time.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;legend-location&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Legend Location&lt;/h3&gt;
&lt;p&gt;In order to add a legend to the plot, the first thing we must specify is the location of the legend in the plot. There are 2 ways to do this:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;use x and y axis coordinates&lt;/li&gt;
&lt;li&gt;use keywords&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The list of keywords include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;top&lt;/li&gt;
&lt;li&gt;bottom&lt;/li&gt;
&lt;li&gt;left&lt;/li&gt;
&lt;li&gt;right&lt;/li&gt;
&lt;li&gt;center&lt;/li&gt;
&lt;li&gt;bottomright&lt;/li&gt;
&lt;li&gt;bottomleft&lt;/li&gt;
&lt;li&gt;topright&lt;/li&gt;
&lt;li&gt;topleft&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;But there is a glitch. If we do not specify what goes into the legend, the &lt;code&gt;legend()&lt;/code&gt; function will return an error. Before we experiment with the location of the legend inside the plot, we need to learn about another argument used to specify the content of the legend. The argument is also named &lt;code&gt;legend&lt;/code&gt;. It takes a vector as input. In the next example, we will plot the GDP data for India and China and add a basic legend.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;{plot(gdp$year, gdp$india, type = &amp;#39;l&amp;#39;,
      ylim = c(-5, 15), xlab = &amp;#39;Year&amp;#39;,
      ylab = &amp;#39;Growth Rate&amp;#39;, col = &amp;#39;blue&amp;#39;,
      main = &amp;#39;BRICS: Growth Rate&amp;#39;)
lines(gdp$year, gdp$china, col = &amp;#39;red&amp;#39;)
legend(x = 2013, y = 14, legend = c(&amp;#39;india&amp;#39;, &amp;#39;china&amp;#39;))}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-16-data-visualization-with-r-legends_files/figure-html/leg1-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;You can see that a legend has been added bases on the X and Y axis coordinates we specified in the &lt;code&gt;legend()&lt;/code&gt; function. But the legend is incomplete and a user still cannot map the lines to the countries using the legend. We will learn how to add lines inside the legend shortly but before that let us use keywords to position the legend inside the plot.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-16-data-visualization-with-r-legends_files/figure-html/leg2-1.png&#34; width=&#34;1440&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;You can either use the keywords or the axis coordinates to position the legend inside the plot. Use the coordinates method if you want greater control over the position of the legend. Next step is to add lines inside the legend so that a user can map the lines in the plots to the countries.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;lines&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Lines&lt;/h3&gt;
&lt;p&gt;Adding a line in the legend is very simple. Use the &lt;code&gt;lty&lt;/code&gt; argument to specify the line type and the &lt;code&gt;col&lt;/code&gt; argument to add color to the line.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;{plot(gdp$year, gdp$india, type = &amp;#39;l&amp;#39;,
      ylim = c(-5, 15), xlab = &amp;#39;Year&amp;#39;,
      ylab = &amp;#39;Growth Rate&amp;#39;, col = &amp;#39;blue&amp;#39;,
      main = &amp;#39;BRICS: Growth Rate&amp;#39;)
lines(gdp$year, gdp$china, col = &amp;#39;red&amp;#39;)
legend(x = 2012, y = 14, legend = c(&amp;#39;india&amp;#39;, &amp;#39;china&amp;#39;),
       lty = 1, col = c(&amp;#39;blue&amp;#39;, &amp;#39;red&amp;#39;))}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-16-data-visualization-with-r-legends_files/figure-html/leg3-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Now we can map the lines to the respective countries using the legend. But our legend looks very simple right. Let us explore the options available to modify and enhance the appearance of the legend.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;points&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Points&lt;/h3&gt;
&lt;p&gt;If the plot has both lines and points, we can use the &lt;code&gt;pch&lt;/code&gt; argument in the &lt;code&gt;legend()&lt;/code&gt; function to specify the shape of the point.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;{plot(gdp$year, gdp$india, type = &amp;#39;l&amp;#39;,
      ylim = c(-5, 15), xlab = &amp;#39;Year&amp;#39;,
      ylab = &amp;#39;Growth Rate&amp;#39;, col = &amp;#39;blue&amp;#39;,
      main = &amp;#39;BRICS: Growth Rate&amp;#39;)
points(gdp$year, gdp$india, pch = 2, col = &amp;#39;blue&amp;#39;)
lines(gdp$year, gdp$china, col = &amp;#39;red&amp;#39;)
points(gdp$year, gdp$china, pch = 2, col = &amp;#39;red&amp;#39;)
legend(x = 2012, y = 14, legend = c(&amp;#39;india&amp;#39;, &amp;#39;china&amp;#39;),
       lty = 1, pch = 2, col = c(&amp;#39;blue&amp;#39;, &amp;#39;red&amp;#39;))}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-16-data-visualization-with-r-legends_files/figure-html/leg4-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;text-placement&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Text Placement&lt;/h3&gt;
&lt;p&gt;The contents of the legend can be positioned horizontally using the &lt;code&gt;horiz&lt;/code&gt; argument. It takes logical values as inputs and the default is &lt;code&gt;FALSE&lt;/code&gt;. Set it to &lt;code&gt;TRUE&lt;/code&gt; to position the contents horizontally:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;{plot(gdp$year, gdp$india, type = &amp;#39;l&amp;#39;,
      ylim = c(-5, 15), xlab = &amp;#39;Year&amp;#39;,
      ylab = &amp;#39;Growth Rate&amp;#39;, col = &amp;#39;blue&amp;#39;,
      main = &amp;#39;BRICS: Growth Rate&amp;#39;)
lines(gdp$year, gdp$china, col = &amp;#39;red&amp;#39;)
legend(x = 2011, y = 14, legend = c(&amp;#39;india&amp;#39;, &amp;#39;china&amp;#39;),
       lty = 1, col = c(&amp;#39;blue&amp;#39;, &amp;#39;red&amp;#39;),
       horiz = TRUE)}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-16-data-visualization-with-r-legends_files/figure-html/leg5-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Another way to position the content inside the legend is to use columns. In the below example, we use the &lt;code&gt;ncol&lt;/code&gt; argument to split the contents of the legend into two columns instead of the default one.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-16-data-visualization-with-r-legends_files/figure-html/leg6-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The below plots show the difference in appearance:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-16-data-visualization-with-r-legends_files/figure-html/leg7-1.png&#34; width=&#34;1440&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;title&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Title&lt;/h3&gt;
&lt;p&gt;Let us add a title to the legend using the &lt;code&gt;title&lt;/code&gt; argument:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;{plot(gdp$year, gdp$india, type = &amp;#39;l&amp;#39;,
      ylim = c(-5, 15), xlab = &amp;#39;Year&amp;#39;,
      ylab = &amp;#39;Growth Rate&amp;#39;, col = &amp;#39;blue&amp;#39;,
      main = &amp;#39;BRICS: Growth Rate&amp;#39;)
lines(gdp$year, gdp$china, col = &amp;#39;red&amp;#39;)
legend(x = 2012, y = 14, legend = c(&amp;#39;india&amp;#39;, &amp;#39;china&amp;#39;),
       lty = 1, col = c(&amp;#39;blue&amp;#39;, &amp;#39;red&amp;#39;),
       title = &amp;#39;Nations&amp;#39;)}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-16-data-visualization-with-r-legends_files/figure-html/leg8-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;title-color&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Title Color&lt;/h4&gt;
&lt;p&gt;The color of the title can be modified using the &lt;code&gt;title.col&lt;/code&gt; argument:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;{plot(gdp$year, gdp$india, type = &amp;#39;l&amp;#39;,
      ylim = c(-5, 15), xlab = &amp;#39;Year&amp;#39;,
      ylab = &amp;#39;Growth Rate&amp;#39;, col = &amp;#39;blue&amp;#39;,
      main = &amp;#39;BRICS: Growth Rate&amp;#39;)
lines(gdp$year, gdp$china, col = &amp;#39;red&amp;#39;)
legend(x = 2012, y = 14, legend = c(&amp;#39;india&amp;#39;, &amp;#39;china&amp;#39;),
       lty = 1, col = c(&amp;#39;blue&amp;#39;, &amp;#39;red&amp;#39;),
       title = &amp;#39;Nations&amp;#39;, title.col = &amp;#39;red&amp;#39;)}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-16-data-visualization-with-r-legends_files/figure-html/leg9-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;title-position&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Title Position&lt;/h4&gt;
&lt;p&gt;The title can be positioned within the legend box using the &lt;code&gt;title.adj&lt;/code&gt; argument. It will take values between 0 and 1. The default is 0.5 and the title is positioned in the middle of the box. As the value moves away from 0.5, the position of the title moves to the left or right respectively.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;{plot(gdp$year, gdp$india, type = &amp;#39;l&amp;#39;,
      ylim = c(-5, 15), xlab = &amp;#39;Year&amp;#39;,
      ylab = &amp;#39;Growth Rate&amp;#39;, col = &amp;#39;blue&amp;#39;,
      main = &amp;#39;BRICS: Growth Rate&amp;#39;)
lines(gdp$year, gdp$china, col = &amp;#39;red&amp;#39;)
legend(x = 2012, y = 0, legend = c(&amp;#39;india&amp;#39;, &amp;#39;china&amp;#39;),
       lty = 1, col = c(&amp;#39;blue&amp;#39;, &amp;#39;red&amp;#39;), horiz = TRUE,
       title = &amp;#39;Nations&amp;#39;, title.adj = 0.1)}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-16-data-visualization-with-r-legends_files/figure-html/leg10-1.png&#34; width=&#34;672&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The below plots show the relative position of the title within the legend box for different values between 0 and 1.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-16-data-visualization-with-r-legends_files/figure-html/leg11-1.png&#34; width=&#34;1440&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;box-appearance&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Box Appearance&lt;/h3&gt;
&lt;p&gt;There are a lot of options to modify the appearance of the legend box. The below table displays the arguments and their descriptions. Let us look at them one by one:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;left&#34;&gt;option&lt;/th&gt;
&lt;th align=&#34;left&#34;&gt;argument&lt;/th&gt;
&lt;th align=&#34;left&#34;&gt;values&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;left&#34;&gt;Box Type&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;bty&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;o, n&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;left&#34;&gt;Background Color&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;bg&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;blue, #0000ff&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;left&#34;&gt;Border Line Type&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;box.lty&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;1:5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;left&#34;&gt;Border Line Width&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;box.lwd&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;0.5, 1, 1.5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;left&#34;&gt;Border Line Color&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;box.col&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;blue, #0000ff&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;left&#34;&gt;Horizontal Justification&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;xjust&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;0:1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;left&#34;&gt;Vertical Justification&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;yjust&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;0:1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;left&#34;&gt;Text Color&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;text.col&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;blue, #0000ff&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;left&#34;&gt;Text Font&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;text.font&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;1:5&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;div id=&#34;box-type&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Box Type&lt;/h4&gt;
&lt;p&gt;The &lt;code&gt;bty&lt;/code&gt; argument takes two values, &lt;code&gt;o&lt;/code&gt; and &lt;code&gt;n&lt;/code&gt;. If set to &lt;code&gt;n&lt;/code&gt;, there will be no box around the legend.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-16-data-visualization-with-r-legends_files/figure-html/leg12-1.png&#34; width=&#34;960&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;background-color&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Background Color&lt;/h3&gt;
&lt;p&gt;A background color can be added to the legend box using the &lt;code&gt;bg&lt;/code&gt; argument. Below is an example:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;{c}&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## function (...)  .Primitive(&amp;quot;c&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;border&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Border&lt;/h3&gt;
&lt;p&gt;The following arguments can be used to modify the border of the legend box:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;box.lty&lt;/code&gt;: line type&lt;/li&gt;
&lt;li&gt;&lt;code&gt;box.lwd&lt;/code&gt;: line width&lt;/li&gt;
&lt;li&gt;&lt;code&gt;box.col&lt;/code&gt;: color&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;{plot(gdp$year, gdp$india, type = &amp;#39;l&amp;#39;,
      ylim = c(-5, 15), xlab = &amp;#39;Year&amp;#39;,
      ylab = &amp;#39;Growth Rate&amp;#39;, col = &amp;#39;blue&amp;#39;,
      main = &amp;#39;BRICS: Growth Rate&amp;#39;)
lines(gdp$year, gdp$china, col = &amp;#39;red&amp;#39;)
legend(x = 2012, y = 0, legend = c(&amp;#39;india&amp;#39;, &amp;#39;china&amp;#39;),
       lty = 1, col = c(&amp;#39;blue&amp;#39;, &amp;#39;red&amp;#39;), title = &amp;#39;Nations&amp;#39;,
       box.lty = 3, box.lwd = 1.5, box.col = &amp;#39;green&amp;#39;)}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-16-data-visualization-with-r-legends_files/figure-html/leg14-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;justification&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Justification&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;xjust&lt;/code&gt; and &lt;code&gt;yjust&lt;/code&gt; arguments can be used to position the legend relative to the &lt;strong&gt;X&lt;/strong&gt; and &lt;strong&gt;Y&lt;/strong&gt; axis respectively. Listed below is the value and the respective justification:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;0&lt;/code&gt;: left justified&lt;/li&gt;
&lt;li&gt;&lt;code&gt;0.5&lt;/code&gt;: centered&lt;/li&gt;
&lt;li&gt;&lt;code&gt;1&lt;/code&gt;: right justified&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let us look at a few examples to understand how it works.&lt;/p&gt;
&lt;div id=&#34;horizontal-justification&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Horizontal Justification&lt;/h4&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-16-data-visualization-with-r-legends_files/figure-html/leg15-1.png&#34; width=&#34;1440&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;vertical-justification&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Vertical Justification&lt;/h4&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-16-data-visualization-with-r-legends_files/figure-html/leg16-1.png&#34; width=&#34;1440&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;text-appearance&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Text Appearance&lt;/h3&gt;
&lt;p&gt;The last topic we will explore is the appearance of the text inside the legend box. We will modify the color and font of text using the &lt;code&gt;text.col&lt;/code&gt; and &lt;code&gt;text.font&lt;/code&gt; arguments.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;{plot(gdp$year, gdp$india, type = &amp;#39;l&amp;#39;,
      ylim = c(-5, 15), xlab = &amp;#39;Year&amp;#39;,
      ylab = &amp;#39;Growth Rate&amp;#39;, col = &amp;#39;blue&amp;#39;,
      main = &amp;#39;BRICS: Growth Rate&amp;#39;)
lines(gdp$year, gdp$china, col = &amp;#39;red&amp;#39;)
legend(x = 2012, y = 0, legend = c(&amp;#39;india&amp;#39;, &amp;#39;china&amp;#39;),
       lty = 1, col = c(&amp;#39;blue&amp;#39;, &amp;#39;red&amp;#39;), title = &amp;#39;Nations&amp;#39;,
       text.col = &amp;#39;green&amp;#39;, text.font = 3)}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-16-data-visualization-with-r-legends_files/figure-html/leg17-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;In this post, we learnt to add legend to a plot using the &lt;code&gt;legend()&lt;/code&gt; function. Specifically, we learnt to&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;position the legend within the plot&lt;/li&gt;
&lt;li&gt;modify the layout using &lt;code&gt;ncol&lt;/code&gt; and &lt;code&gt;horiz&lt;/code&gt; arguments&lt;/li&gt;
&lt;li&gt;add title using the &lt;code&gt;title.&lt;/code&gt; set of arguments&lt;/li&gt;
&lt;li&gt;modify the appearance and position of the legend box&lt;/li&gt;
&lt;li&gt;modify the appearance of the text in the legend box&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Data Visualization with R - Histogram</title>
      <link>https://blog.rsquaredacademy.com/data-visualization-with-r-histogram/</link>
      <pubDate>Fri, 04 Aug 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/data-visualization-with-r-histogram/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;This is the seventh post in the series &lt;strong&gt;Data Visualization With R&lt;/strong&gt;. In the previous post, we learnt about box and whisker plots. In this post, we will learn to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;create a bare bones histogram&lt;/li&gt;
&lt;li&gt;specify the number of bins/intervals&lt;/li&gt;
&lt;li&gt;represent frequency density on the Y axis&lt;/li&gt;
&lt;li&gt;add colors to the bars and the border&lt;/li&gt;
&lt;li&gt;add labels to the bars&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A histogram is a plot that can be used to examine the shape and spread of continuous data. It looks very similar to a bar graph and can be used to detect outliers and skewness in data. The histogram graphically shows the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;center (location) of the data&lt;/li&gt;
&lt;li&gt;spread (dispersion) of the data&lt;/li&gt;
&lt;li&gt;skewness&lt;/li&gt;
&lt;li&gt;outliers&lt;/li&gt;
&lt;li&gt;presence of multiple modes&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To construct a histogram, the data is split into intervals called bins. The intervals may or may not be equal sized. For each bin, the number of data points that fall into it are counted (frequency). The Y axis of the histogram represents the frequency and the X axis represents the variable.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt; and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/7dbcd02b37e80c5262133d0464b7e8c9&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;distributions&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Distributions&lt;/h3&gt;
&lt;p&gt;Before we learn how to create histograms, let us see how normal and skewed distributions look when represented by a histogram.&lt;/p&gt;
&lt;div id=&#34;normal-distribution&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Normal Distribution&lt;/h5&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-04-data-visualization-with-r-histogram_files/figure-html/hist1-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;skewed-distributions&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Skewed Distributions&lt;/h5&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-04-data-visualization-with-r-histogram_files/figure-html/hist2-1.png&#34; width=&#34;960&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;basics&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Basics&lt;/h3&gt;
&lt;p&gt;Histograms are created using the &lt;code&gt;hist()&lt;/code&gt; function in R. The minimum input required to create a bare bones histogram is a continuous variable. Below is an example:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-04-data-visualization-with-r-histogram_files/figure-html/hist3-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;hist()&lt;/code&gt; functions returns details of the histogram which can be accessed by assigning the histogram to a variable. Let us assign the above histogram to a variable &lt;code&gt;h&lt;/code&gt; and use the &lt;code&gt;$&lt;/code&gt; symbol to access the details stored in the variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# store the results of hist function
h &amp;lt;- hist(mtcars$mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-04-data-visualization-with-r-histogram_files/figure-html/hist4-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;
# display number of breaks
h$breaks
## [1] 10 15 20 25 30 35

# frequency of the intervals
h$counts
## [1]  6 12  8  2  4

# frequency density
h$density
## [1] 0.0375 0.0750 0.0500 0.0125 0.0250

# mid points of the intervals
h$mids
## [1] 12.5 17.5 22.5 27.5 32.5

# varible name
h$xname
## [1] &amp;quot;mtcars$mpg&amp;quot;

# whether intervals are of equal size
h$equidist
## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;bins&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Bins&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;hist()&lt;/code&gt; function creates equidistant intervals by default. We can specify the number of bins using the &lt;code&gt;breaks&lt;/code&gt; argument.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-04-data-visualization-with-r-histogram_files/figure-html/hist5-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The below plot displays histograms with different number of bins:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-04-data-visualization-with-r-histogram_files/figure-html/hist6-1.png&#34; width=&#34;960&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;intervals&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Intervals&lt;/h3&gt;
&lt;p&gt;If we want to create histograms with specific intervals, the &lt;code&gt;breaks&lt;/code&gt; argument can be supplied with the intervals.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-04-data-visualization-with-r-histogram_files/figure-html/hist7-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;If you observe the Y axis, it does not represent frequency any more. Instead, it represents the frequency density. What is frequency density?&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;frequency-density&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Frequency Density&lt;/h3&gt;
&lt;p&gt;Frequency Density = Relative Frequency / Class Width&lt;/p&gt;
&lt;p&gt;Relative Frequency = Frequency / Total Observations&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;h &amp;lt;- hist(mtcars$mpg, breaks = c(10, 18, 24, 30, 35))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-04-data-visualization-with-r-histogram_files/figure-html/hist8-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;frequency &amp;lt;- h$counts
class_width &amp;lt;- c(8, 6, 6, 5)
rel_freq &amp;lt;- frequency / length(mtcars$mpg)
freq_density &amp;lt;- rel_freq / class_width
d &amp;lt;- data.frame(frequency = frequency, class_width = class_width, relative_frequency = rel_freq, frequency_density = freq_density)
d&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   frequency class_width relative_frequency frequency_density
## 1        13           8            0.40625        0.05078125
## 2        12           6            0.37500        0.06250000
## 3         3           6            0.09375        0.01562500
## 4         4           5            0.12500        0.02500000&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When multiplied by the class width, the product will always sum upto 1.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;sum(d$frequency_density * d$class_width)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We will learn more about frequency density in a bit. Before we end this section, we need to learn about one more way to specify the intervals of the histogram, algorithms. The &lt;code&gt;hist()&lt;/code&gt; function allows us to specify the following algorithms:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Sturges (default)&lt;/li&gt;
&lt;li&gt;Scott&lt;/li&gt;
&lt;li&gt;Freedman-Diaconis (FD)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the below plot, we examine how th algorithms work:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-04-data-visualization-with-r-histogram_files/figure-html/hist10-1.png&#34; width=&#34;1440&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;frequency-distribution-ii&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Frequency Distribution II&lt;/h3&gt;
&lt;p&gt;Let us come back to frequency density. If you want the Y axis of the histogram to represent frequency density instead of counts, set the &lt;code&gt;freq&lt;/code&gt; argument to &lt;code&gt;FALSE&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-04-data-visualization-with-r-histogram_files/figure-html/hist11-1.png&#34; width=&#34;960&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The same result can be achieved by using the &lt;code&gt;probability&lt;/code&gt; argument as well. It takes only logical values as inputs and the default is &lt;code&gt;FALSE&lt;/code&gt;. If set to &lt;code&gt;TRUE&lt;/code&gt;, the Y axis will represent the frequency density instead of counts.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;hist(mtcars$mpg, probability = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-04-data-visualization-with-r-histogram_files/figure-html/hist12-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;color&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Color&lt;/h3&gt;
&lt;p&gt;To add colors to the bars of the histogram, use the &lt;code&gt;col&lt;/code&gt; argument. If the number of colors specified is less than the number of bars, the colors are recycled. Below are a few examples:&lt;/p&gt;
&lt;div id=&#34;single-color&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Single Color&lt;/h4&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-04-data-visualization-with-r-histogram_files/figure-html/hist13-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;different-colors&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Different Colors&lt;/h4&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-04-data-visualization-with-r-histogram_files/figure-html/hist14-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;recycled-colors&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Recycled Colors&lt;/h4&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-04-data-visualization-with-r-histogram_files/figure-html/hist15-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;border-color&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Border Color&lt;/h3&gt;
&lt;p&gt;Colors can be specified for the borders of the histogrambars using the &lt;code&gt;border&lt;/code&gt; argument.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-04-data-visualization-with-r-histogram_files/figure-html/hist20-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;different-colors-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Different Colors&lt;/h4&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-04-data-visualization-with-r-histogram_files/figure-html/hist16-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;labels&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Labels&lt;/h3&gt;
&lt;p&gt;In certain cases, we might want to add the frequency counts on the histogram bars. It is easier for the user to know the frequencies of each bin when they are present on top of the bars. Let us add the frequency counts on top of the bars using the &lt;code&gt;labels&lt;/code&gt; argument. We can either set it to &lt;code&gt;TRUE&lt;/code&gt; or a character vector containing the label values. Let us look at both the methods.&lt;/p&gt;
&lt;div id=&#34;method-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Method 1&lt;/h4&gt;
&lt;p&gt;Set &lt;code&gt;labels&lt;/code&gt; to &lt;code&gt;TRUE&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-04-data-visualization-with-r-histogram_files/figure-html/hist17-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;method-2&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Method 2&lt;/h4&gt;
&lt;p&gt;Specify the label values in a character vector.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-04-data-visualization-with-r-histogram_files/figure-html/hist18-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;putting-it-all-together..&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Putting it all together..&lt;/h3&gt;
&lt;p&gt;Before we end this post, let us add a title and axis labels to the histogram.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;hist(mtcars$mpg, labels = TRUE, prob = TRUE,
     ylim = c(0, 0.1), xlab = &amp;#39;Miles Per Gallon&amp;#39;,
     main = &amp;#39;Distribution of Miles Per Gallon&amp;#39;,
     col = rainbow(5))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-08-04-data-visualization-with-r-histogram_files/figure-html/hist19-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;In this post, we learnt how to construct and use histograms to examine the underlying distribution of a continuous variable. Specifically, we learnt how to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;create a bare bones histogram&lt;/li&gt;
&lt;li&gt;specify the number of bins/intervals&lt;/li&gt;
&lt;li&gt;represent frequency density on the Y axis&lt;/li&gt;
&lt;li&gt;add colors to the bars and the border&lt;/li&gt;
&lt;li&gt;add labels to the bars&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Data Visualization with R - Box Plots</title>
      <link>https://blog.rsquaredacademy.com/data-visualization-with-r-box-plots/</link>
      <pubDate>Sun, 23 Jul 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/data-visualization-with-r-box-plots/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;This is the sixth post in the series &lt;strong&gt;Data Visualization With R&lt;/strong&gt;. In the previous post, we learnt how to build bar plots. In this post, we will learn to&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;create univariate/multivariate box plots&lt;/li&gt;
&lt;li&gt;interpret box plots&lt;/li&gt;
&lt;li&gt;create horizontal box plots&lt;/li&gt;
&lt;li&gt;detect outliers&lt;/li&gt;
&lt;li&gt;modify box color&lt;/li&gt;
&lt;li&gt;use formula to compare distributions of different variables&lt;/li&gt;
&lt;li&gt;use notches to compare medians&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt; and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/d5e49b7903a54bd02d77ae2057f05d4a&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;box-plot&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Box Plot&lt;/h3&gt;
&lt;p&gt;The box plot is a standardized way of displaying the distribution of data based on the five number summary: minimum, first quartile, median, third quartile, and maximum. Box plots are useful for detecting outliers and for comparing distributions. It shows the shape, central tendancy and variability of the data.&lt;/p&gt;
&lt;div id=&#34;structure&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Structure&lt;/h4&gt;
&lt;p&gt;A boxplot splits the data set into quartiles. The body of the boxplot consists of a “box” (hence, the name), which goes from the first quartile (Q1) to the third quartile (Q3). Within the box, a vertical line is drawn at the Q2, the median of the data set. Two horizontal lines, called whiskers, extend from the front and back of the box. The front whisker goes from Q1 to the smallest non-outlier in the data set, and the back whisker goes from Q3 to the largest non-outlier. If the data set includes one or more outliers, they are plotted separately as points on the chart.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;univariate-box-plot&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Univariate Box Plot&lt;/h3&gt;
&lt;div id=&#34;basic-plot&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Basic Plot&lt;/h4&gt;
&lt;p&gt;Let us begin by creating a basic box plot. We will use the &lt;code&gt;boxplot()&lt;/code&gt; function and specify the data.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;boxplot(mtcars$mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-23-data-visualization-with-r-box-plots_files/figure-html/box1-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;horizontal-box-plot&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Horizontal Box Plot&lt;/h3&gt;
&lt;p&gt;Use the &lt;code&gt;horizontal&lt;/code&gt; argument in the &lt;code&gt;boxplot()&lt;/code&gt; function to create a horizontal box plot.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;boxplot(mtcars$mpg, horizontal = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-23-data-visualization-with-r-box-plots_files/figure-html/box2-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;color&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Color&lt;/h3&gt;
&lt;p&gt;Let us add some color to the boxplot. Use the &lt;code&gt;col&lt;/code&gt; argument to specify a color for the plot.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;boxplot(mtcars$mpg, col = &amp;#39;blue&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-23-data-visualization-with-r-box-plots_files/figure-html/box3-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;border-color&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Border Color&lt;/h3&gt;
&lt;p&gt;We can specify a separate color for the border of the box in the boxplot. To modify the border color, use the &lt;code&gt;border&lt;/code&gt; argument.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;boxplot(mtcars$mpg, border = &amp;#39;red&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-23-data-visualization-with-r-box-plots_files/figure-html/box4-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;range&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Range&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;range&lt;/code&gt; argument determines how far the plot whiskers extend out from the box. If range is positive, the whiskers extend to the most extreme data point which is no more than range times the interquartile range from the box. A value of zero causes the whiskers to extend to the data extremes.&lt;/p&gt;
&lt;p&gt;Let us set the value of &lt;code&gt;range&lt;/code&gt; to 0 and observe the plot.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;boxplot(mtcars$mpg, range = 0)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-23-data-visualization-with-r-box-plots_files/figure-html/box5-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In the below plot, we set the value of &lt;code&gt;range&lt;/code&gt; to 1.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;boxplot(mtcars$mpg, range = 1)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-23-data-visualization-with-r-box-plots_files/figure-html/box6-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Let us observe how the plot appears as we change the value of &lt;code&gt;range&lt;/code&gt; from 0 to 1.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-23-data-visualization-with-r-box-plots_files/figure-html/box7-1.png&#34; width=&#34;960&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;outline&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Outline&lt;/h3&gt;
&lt;p&gt;The outliers in the plot are not drawn if the &lt;code&gt;outline&lt;/code&gt; argument is set to &lt;code&gt;FALSE&lt;/code&gt;. The default value is &lt;code&gt;TRUE&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;boxplot(mtcars$mpg, range = 1, outline = FALSE)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-23-data-visualization-with-r-box-plots_files/figure-html/box8-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The below plot displays how the plot changes with the values set for &lt;code&gt;outline&lt;/code&gt;:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-23-data-visualization-with-r-box-plots_files/figure-html/box9-1.png&#34; width=&#34;960&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;varwidth&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Varwidth&lt;/h3&gt;
&lt;p&gt;If the &lt;code&gt;varwidth&lt;/code&gt; argument is set to &lt;code&gt;TRUE&lt;/code&gt;, the boxes are drawn with widths proportional to the square-roots of the number of observations in the groups.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-23-data-visualization-with-r-box-plots_files/figure-html/box10-1.png&#34; width=&#34;960&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;bivariatemultivariate-box-plot&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Bivariate/Multivariate Box Plot&lt;/h3&gt;
&lt;p&gt;As we said in the introduction, box plots can be used to compare distributions of several variables. Let us use the &lt;code&gt;mtcars&lt;/code&gt; data set and compare the distribution of Miles Per Gallon (&lt;code&gt;mpg&lt;/code&gt;) for automobiles with different number of cylinders (&lt;code&gt;cyl&lt;/code&gt;). We will do this by specifying a formula as shown in the below example.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;boxplot(mtcars$mpg ~ mtcars$cyl)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-23-data-visualization-with-r-box-plots_files/figure-html/box11-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;We use the formula when we are comparing the distribution of a continuous variable across different levels of a categorical variable. If we want to compare the distributions without using a categorical variable, we need to specify the variable separately in the &lt;code&gt;boxplot()&lt;/code&gt; function. Below is an illustration of this method. We will split the &lt;code&gt;mpg&lt;/code&gt; data using the &lt;code&gt;split()&lt;/code&gt; function and plot them separately. The &lt;code&gt;split()&lt;/code&gt; function splits a continuous variable based on the levels of a categorical variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mpg_split &amp;lt;- split(mtcars$mpg, mtcars$cyl)

mpg_split
## $`4`
##  [1] 22.8 24.4 22.8 32.4 30.4 33.9 21.5 27.3 26.0 30.4 21.4
## 
## $`6`
## [1] 21.0 21.0 21.4 18.1 19.2 17.8 19.7
## 
## $`8`
##  [1] 18.7 14.3 16.4 17.3 15.2 10.4 10.4 14.7 15.5 15.2 13.3 19.2 15.8 15.0

mpg_4 &amp;lt;- mpg_split$`4`
mpg_6 &amp;lt;- mpg_split$`6`
mpg_8 &amp;lt;- mpg_split$`8`

boxplot(mpg_4, mpg_6, mpg_8)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-23-data-visualization-with-r-box-plots_files/figure-html/box12-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The same plot can be created in two ways. If you are comparing the distribution of a continuous variable for the different levels of a categorical variable, use the formula. If you are comparing distribution of independent variables, specify all the variablels in the &lt;code&gt;boxplot()&lt;/code&gt; function.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;color-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Color&lt;/h3&gt;
&lt;p&gt;Let us add some color to the plot. We can specify as many colors as the boxes or we can specify the same color for all of them. Below are two examples where we specify the same color in the first one and different colors in the second one.&lt;/p&gt;
&lt;div id=&#34;single-color&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Single Color&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;boxplot(mtcars$mpg ~ mtcars$cyl, col = &amp;#39;blue&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-23-data-visualization-with-r-box-plots_files/figure-html/box14-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;different-colors&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Different Colors&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;boxplot(mtcars$mpg ~ mtcars$cyl, 
        col = c(&amp;#39;red&amp;#39;, &amp;#39;blue&amp;#39;, &amp;#39;yellow&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-23-data-visualization-with-r-box-plots_files/figure-html/box15-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;compare-medians&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Compare Medians&lt;/h3&gt;
&lt;p&gt;If we want to test whether the medians of the different groups differ, we can use the &lt;code&gt;notch&lt;/code&gt; argument and set it to &lt;code&gt;TRUE&lt;/code&gt;. A notch is drawn in each side of the boxes and if the notches of the plots do not overlap, it is strong evidence that the medians differ.&lt;/p&gt;
&lt;p&gt;We will use a different data set for this example. Download the &lt;code&gt;hsb2&lt;/code&gt; data from UCLA website and compare the distribution of reading score (&lt;code&gt;read&lt;/code&gt;) for males and females (&lt;code&gt;female&lt;/code&gt;).&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;hsb &amp;lt;- read.table(&amp;#39;https://stats.idre.ucla.edu/wp-content/uploads/2016/02/hsb2-2.csv&amp;#39;, header=T, sep=&amp;quot;,&amp;quot;)
boxplot(hsb$read ~ hsb$female, notch = TRUE, 
        col = c(&amp;#39;red&amp;#39;, &amp;#39;blue&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-23-data-visualization-with-r-box-plots_files/figure-html/box16-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Since the notches overlap, there is no strong evidence that the medians differ.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;putting-it-all-together&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Putting it all together&lt;/h3&gt;
&lt;p&gt;We will end this post by adding a title and axis labels to the box plot.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;boxplot(mtcars$mpg ~ mtcars$cyl, range = 1, outline = TRUE, 
        horizontal = TRUE, col = c(&amp;#39;red&amp;#39;, &amp;#39;blue&amp;#39;, &amp;#39;yellow&amp;#39;),
        main = &amp;#39;Miles Per Gallon by Cylinders&amp;#39;, 
        ylab = &amp;#39;Number of Cylinders&amp;#39;, xlab = &amp;#39;Miles Per Gallon&amp;#39;,
        names = c(&amp;#39;Four&amp;#39;, &amp;#39;Six&amp;#39;, &amp;#39;Eight&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-23-data-visualization-with-r-box-plots_files/figure-html/box17-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;In this post, we learnt how to create box plots. Specifically, we learnt to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;create univariate/multivariate box plots&lt;/li&gt;
&lt;li&gt;interpret box plots&lt;/li&gt;
&lt;li&gt;create horizontal box plots&lt;/li&gt;
&lt;li&gt;detect outliers&lt;/li&gt;
&lt;li&gt;modify box color&lt;/li&gt;
&lt;li&gt;use formula to compare distributions of different variables&lt;/li&gt;
&lt;li&gt;use notches to compare medians&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Data Visualization With R - Bar Plots</title>
      <link>https://blog.rsquaredacademy.com/data-visualization-with-r-bar-plots/</link>
      <pubDate>Tue, 11 Jul 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/data-visualization-with-r-bar-plots/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;This is the fifth post in the series &lt;strong&gt;Data Visualization With R&lt;/strong&gt;. In the previous post, we learnt how to build line graphs. In this post, we will visualize categorical data using univariate and bivariate bar plots.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;create
&lt;ul&gt;
&lt;li&gt;simple bar plot&lt;/li&gt;
&lt;li&gt;stacked bar plot&lt;/li&gt;
&lt;li&gt;grouped bar plot&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;modify bar
&lt;ul&gt;
&lt;li&gt;direction&lt;/li&gt;
&lt;li&gt;color&lt;/li&gt;
&lt;li&gt;line color&lt;/li&gt;
&lt;li&gt;width&lt;/li&gt;
&lt;li&gt;labels&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;modify axis range&lt;/li&gt;
&lt;li&gt;remove axes from the plot&lt;/li&gt;
&lt;li&gt;specify the line type of the X axes&lt;/li&gt;
&lt;li&gt;offset the Y axes&lt;/li&gt;
&lt;li&gt;modify legend&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt; and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/57f3c568170ae29ed9cde9f54713269c&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;bar-plot&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Bar Plot&lt;/h3&gt;
&lt;p&gt;A bar plot represents data in rectangular bars. The length of the bars are proportional to the values they represent. Bar plots can be either horizontal or vertical. The X axis of the plot represents the levels or the categories and the Y axis represents the frequency/count of the variable.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;univariate-bar-plot&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Univariate Bar Plot&lt;/h3&gt;
&lt;p&gt;A univariate bar plot represents a single categorical variable. The categories in the variable are represented on the X axis and their frequencies on the Y axis. In the below example, the &lt;code&gt;cyl&lt;/code&gt; variable from the &lt;code&gt;mtcars&lt;/code&gt; data set is visualized using a bar plot. The categories or levels are &lt;code&gt;4&lt;/code&gt;, &lt;code&gt;6&lt;/code&gt; and &lt;code&gt;8&lt;/code&gt; which represent the number of cylinders in the automobile and are represented on the X axis. The frequency for each type of cylinder is represented by the Y axis.&lt;/p&gt;
&lt;p&gt;In R, bar plots can be created using either the &lt;code&gt;plot()&lt;/code&gt; or &lt;code&gt;barplot()&lt;/code&gt; function. The input to both the functions are different. In case of the &lt;code&gt;plot()&lt;/code&gt; function, we can specify the variable but it must be converted to a factor variable. In case of the &lt;code&gt;barplot()&lt;/code&gt; function, the input must be the count or frequency of the variable. The &lt;code&gt;table()&lt;/code&gt; function can be used to generate the counts/frequency for a variable. Let us use both the functions to create the bar plot:&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;using-plot-function&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Using plot function&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(as.factor(mtcars$cyl))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-11-data-visualization-with-r-bar-plots_files/figure-html/bar1-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;using-barplot-function&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Using barplot function&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(table(mtcars$cyl))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-11-data-visualization-with-r-bar-plots_files/figure-html/bar2-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;If you observe carefully, the same plot is generated by both the functions. We will use the &lt;code&gt;barplot()&lt;/code&gt; function for the rest of the post. Before we explore the bar plots further, let us store the data in a new variable instead of using the &lt;code&gt;table()&lt;/code&gt; function in every example:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;cyl_freq &amp;lt;- table(mtcars$cyl)
cyl_freq&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##  4  6  8 
## 11  7 14&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;horizontal-or-vertical&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Horizontal or Vertical&lt;/h3&gt;
&lt;p&gt;Bar plots can be horizontal or veritcal (which is the default). Use the &lt;code&gt;horiz&lt;/code&gt; argument in the &lt;code&gt;barplot()&lt;/code&gt; function to build a horizontal bar plot. As you can see, the axis have been flipped. The Y axis represents the categories and the X axis represents their counts/frequencies.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(cyl_freq, horiz = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-11-data-visualization-with-r-bar-plots_files/figure-html/bar3-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;bar-width&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Bar Width&lt;/h3&gt;
&lt;p&gt;In the bar plot, the width of the bars and the space between them are same. A specific category of the variable can be highlighted by increasing/decreasing the width of the bar representing it. In our example, we will increase the width of the bar that represents automobiles with 8 cylinders. The &lt;code&gt;width&lt;/code&gt; argument is used to specify the width of the bars.
The width must be specified for all the bars in the plot. It must be a vector the length of which must be equal to the number of categories of the variable.&lt;/p&gt;
&lt;div id=&#34;equal-width&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Equal Width&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(cyl_freq, width = 2)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-11-data-visualization-with-r-bar-plots_files/figure-html/bar4-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;different-widths&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Different Widths&lt;/h4&gt;
&lt;p&gt;In the below example, the width of the third bar is twice the width of the other two bars&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(cyl_freq, width = c(1, 1, 2))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-11-data-visualization-with-r-bar-plots_files/figure-html/bar5-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In the below example, the width of the second bar is half the width of the other first bar and the third bar is twice the width of the first bar.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(cyl_freq, width = c(1, 0.5, 2))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-11-data-visualization-with-r-bar-plots_files/figure-html/bar6-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The space between the bars can be specified in a similar manner but using the &lt;code&gt;space&lt;/code&gt; argument in the &lt;code&gt;barplot()&lt;/code&gt; function: In the below example, the space between the third bar and the second bar is twice the space between first and second bar.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(cyl_freq, space = c(1, 1, 2))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-11-data-visualization-with-r-bar-plots_files/figure-html/bar7-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;labels&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Labels&lt;/h3&gt;
&lt;p&gt;It is important to add appropriate labels to the bars in order to communicate properly. In our example, the bars represent automobiles with different number of cylinders. The labels likewise indicate the number of cylinders represented by the bars. In order to demonstrate how to add labels, we will change the labels from numbers to their corresponding words. The &lt;code&gt;names.arg&lt;/code&gt; argument is used to add labels to the bars in a plot. Below is our example:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(cyl_freq, names.arg = c(&amp;#39;Four&amp;#39;, &amp;#39;Six&amp;#39;, &amp;#39;Eight&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-11-data-visualization-with-r-bar-plots_files/figure-html/bar8-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;It is important to specify labels for all the bars in the plot else R will return an error.&lt;/strong&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;color&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Color&lt;/h3&gt;
&lt;p&gt;Let us add some color to the plots. In a bar plot, we can specify different colors for the bars and their borders. Use the &lt;code&gt;col&lt;/code&gt; argument to add color to the bars.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;same-color-for-all-bars&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Same color for all bars&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(cyl_freq, col = &amp;#39;blue&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-11-data-visualization-with-r-bar-plots_files/figure-html/bar9-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;differnt-color-for-the-bars&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Differnt color for the bars&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(cyl_freq, col = c(&amp;#39;blue&amp;#39;, &amp;#39;red&amp;#39;, &amp;#39;green&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-11-data-visualization-with-r-bar-plots_files/figure-html/bar10-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;What happens if we do not specify color for all the bars? The colors you specify are recycled.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;recycling-colors&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Recycling colors&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(cyl_freq, col = c(&amp;#39;blue&amp;#39;, &amp;#39;red&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-11-data-visualization-with-r-bar-plots_files/figure-html/bar11-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;border&lt;/code&gt; argument specifies the color of the border of the bars. The rules that apply to &lt;code&gt;col&lt;/code&gt; argument apply here also. Below are the examples:&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;same-color-for-all-bars-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Same color for all bars&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(cyl_freq, border = &amp;#39;blue&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-11-data-visualization-with-r-bar-plots_files/figure-html/bar12-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;differnt-color-for-the-bars-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Differnt color for the bars&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(cyl_freq, border = c(&amp;#39;blue&amp;#39;, &amp;#39;red&amp;#39;, &amp;#39;green&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-11-data-visualization-with-r-bar-plots_files/figure-html/bar13-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;What happens if we do not specify color for all the bars? The colors you specify are recycled.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;recycling-colors-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Recycling colors&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(cyl_freq, border = c(&amp;#39;blue&amp;#39;, &amp;#39;red&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-11-data-visualization-with-r-bar-plots_files/figure-html/bar14-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;axes&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Axes&lt;/h3&gt;
&lt;p&gt;In this section, we will learn to&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;remove axes from the plot&lt;/li&gt;
&lt;li&gt;specify the line type of the X axes&lt;/li&gt;
&lt;li&gt;offset the Y axes&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;remove-axes&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Remove axes&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;axes&lt;/code&gt; argument can be used to retain/remove the axes from the plot. It takes logical values as input and the default is &lt;code&gt;TRUE&lt;/code&gt;. Set it to &lt;code&gt;FALSE&lt;/code&gt; to remove the axes from the plot:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(cyl_freq, axes = FALSE)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-11-data-visualization-with-r-bar-plots_files/figure-html/bar15-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;If we decide to retain the axes, the line type of the X axes can be specified using the &lt;code&gt;axis.lty&lt;/code&gt; argument. It does not modify the line type of the Y axes and it will not work if the &lt;code&gt;axes&lt;/code&gt; argument is set to &lt;code&gt;FALSE&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(cyl_freq, axis.lty = 3)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-11-data-visualization-with-r-bar-plots_files/figure-html/bar16-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Though we cannot modify the line type of the Y axes, we can offset it using the &lt;code&gt;offset&lt;/code&gt; argument. In the below example, we will offset the Y axes and you can observe that the minimum value of the Y axes is now 5 instead of 0.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(cyl_freq, offset = 5)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-11-data-visualization-with-r-bar-plots_files/figure-html/bar17-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;You can similarly modify the range of the Y axes using the &lt;code&gt;ylim&lt;/code&gt; argument. Although in case of bar plots, modifying the range of the plot may not be very useful.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(cyl_freq, ylim = c(0, 30))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-11-data-visualization-with-r-bar-plots_files/figure-html/bar18-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;putting-it-all-together&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Putting it all together…&lt;/h3&gt;
&lt;p&gt;Let us quickly revise what we have learnt so far in this post and build a bar plot for visualizing the &lt;code&gt;cyl&lt;/code&gt; variable in the &lt;code&gt;mtcars&lt;/code&gt; data set:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(cyl_freq, col = c(&amp;#39;blue&amp;#39;, &amp;#39;red&amp;#39;, &amp;#39;green&amp;#39;),
        horiz = TRUE, width = c(1, 1, 2),
        names.arg = c(&amp;#39;Four&amp;#39;, &amp;#39;Six&amp;#39;, &amp;#39;Eight&amp;#39;),
        axis.lty = 2, offset = 2)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-11-data-visualization-with-r-bar-plots_files/figure-html/bar19-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;title-axis-labels&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Title &amp;amp; Axis Labels&lt;/h3&gt;
&lt;p&gt;Well the plot looks good but for someone who does not know the underlying data, it will diffficult to understand what is being communicated. Let us add a title and labels for the axes.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(cyl_freq, col = c(&amp;#39;blue&amp;#39;, &amp;#39;red&amp;#39;, &amp;#39;green&amp;#39;),
        horiz = TRUE, width = c(1, 1, 2),
        names.arg = c(&amp;#39;Four&amp;#39;, &amp;#39;Six&amp;#39;, &amp;#39;Eight&amp;#39;),
        axis.lty = 2, offset = 2)
title(main = &amp;#39;Distribution of Cylinders&amp;#39;,
      xlab = &amp;#39;Frequency&amp;#39;, ylab = &amp;#39;Number of Cylinders&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-11-data-visualization-with-r-bar-plots_files/figure-html/bar20-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;bivariate-bar-plots&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Bivariate Bar Plots&lt;/h3&gt;
&lt;p&gt;A bivariate bar plot represents the cross table or two way table of categorical variables. They are of two types:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Stacked Bar Plots&lt;/li&gt;
&lt;li&gt;Grouped Bar Plots&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Before we look at bivariate bar plots, let us create a two way table of &lt;code&gt;cyl&lt;/code&gt; (number of cylinders) and &lt;code&gt;gear&lt;/code&gt; (number of gears) using the &lt;code&gt;table()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;table(mtcars$gear)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##  3  4  5 
## 15 12  5&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;cyl_gear &amp;lt;- table(mtcars$cyl, mtcars$gear)
cyl_gear&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    
##      3  4  5
##   4  1  8  2
##   6  2  4  1
##   8 12  0  2&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The number of gears is represented by the columns in the table and the numbe rof cylinders is represented by the rows.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;stacked-bar-plot&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Stacked Bar Plot&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(cyl_gear)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-11-data-visualization-with-r-bar-plots_files/figure-html/bar21-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The bars in the plot represent the distribution of &lt;code&gt;cyl&lt;/code&gt; for each level of category of the &lt;code&gt;gear&lt;/code&gt; variable. The first bar represents the distribution of cylinders for automobiles with 3 gears. From the two way table we saw earlier, the columns are the bars. The rows are represented by different sections of the bar. Let us add some colors to the plot as the default colors of the plot are not very intuitive. It will also allow us to clearly examine the distribution of &lt;code&gt;cyl&lt;/code&gt; for the different levels of &lt;code&gt;gear&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(cyl_gear, col = c(&amp;#39;blue&amp;#39;, &amp;#39;red&amp;#39;, &amp;#39;green&amp;#39;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-11-data-visualization-with-r-bar-plots_files/figure-html/bar22-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;If you carefully observe the table and the plot:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the blue sections of the bars represent the number of automobiles with 3 gears and 4 cylinders&lt;/li&gt;
&lt;li&gt;the red sections represent the number of automobiles with 4 gears and 6 cylinders&lt;/li&gt;
&lt;li&gt;the green sections represent the number of automobiles with 5 gears and 8 cylinders&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We need to convey the above information in some way and will do that using the &lt;code&gt;legend.text&lt;/code&gt; argument. It takes logical values as inputs and the default values is &lt;code&gt;FALSE&lt;/code&gt;. It adds a legend to the plot when it is set to &lt;code&gt;TRUE&lt;/code&gt;. In the next example, we add a legend as well as other relevant information such as title and axis labels.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(cyl_gear, col = c(&amp;#39;blue&amp;#39;, &amp;#39;red&amp;#39;, &amp;#39;green&amp;#39;),
        main = &amp;#39;Gears vs Cylinders&amp;#39;, legend.text = TRUE,
        xlab = &amp;#39;Number of Gears&amp;#39;, ylab = &amp;#39;Frequency&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-11-data-visualization-with-r-bar-plots_files/figure-html/bar23-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;grouped-bar-plot&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Grouped Bar Plot&lt;/h3&gt;
&lt;p&gt;A grouped bar plot represents the same data as the stacked bar plot but instead of being stacked, the bars are now grouped and placed besides each other.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(cyl_gear, col = c(&amp;#39;blue&amp;#39;, &amp;#39;red&amp;#39;, &amp;#39;green&amp;#39;),
        beside = TRUE, legend.text = TRUE,
        main = &amp;#39;Gears vs Cylinders&amp;#39;,
        xlab = &amp;#39;Number of Gears&amp;#39;, ylab = &amp;#39;Frequency&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-07-11-data-visualization-with-r-bar-plots_files/figure-html/bar24-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;beside&lt;/code&gt; argument in &lt;code&gt;barplot()&lt;/code&gt; function is set to &lt;code&gt;TRUE&lt;/code&gt; to build grouped bar plots. It takes logical values as inputs and the default values is FALSE. As you can observe from the plot, the bars are placed besides each other instead of being stacked.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;In this post, we learnt how to build&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;univariate bar plots&lt;/li&gt;
&lt;li&gt;bivariate bar plots&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;and explored various arguments within the &lt;code&gt;barplot()&lt;/code&gt; function such as&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;horiz&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;col&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;border&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;space&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;width&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;names.arg&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;offset&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;legend.text&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;to modify and enhance the appearance of the plot.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Data Visualization With R - Line Graphs</title>
      <link>https://blog.rsquaredacademy.com/data-visualization-with-r-line-graphs/</link>
      <pubDate>Thu, 29 Jun 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/data-visualization-with-r-line-graphs/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;This is the fourth post in the series &lt;strong&gt;Data Visualization With R&lt;/strong&gt;. In the previous post, we learnt how to build scatter plots. In this post, we will build line graphs. To be more specific we will learn to&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;create line plots&lt;/li&gt;
&lt;li&gt;add color to lines&lt;/li&gt;
&lt;li&gt;modify line type/style&lt;/li&gt;
&lt;li&gt;modify line width&lt;/li&gt;
&lt;li&gt;add points to the lines&lt;/li&gt;
&lt;li&gt;modify axis range&lt;/li&gt;
&lt;li&gt;add additional lines to the plot&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt; and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/ea80f20e798e25b3adfc9ff1e87ed311&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;line-graph&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Line Graph&lt;/h3&gt;
&lt;p&gt;To build a line graph, we will learn a new argument in the &lt;code&gt;plot()&lt;/code&gt; function called &lt;code&gt;type&lt;/code&gt;. It allows us to specify the symbol that must be used to represent the data. Let us begin by building a simple line graph. We will use the &lt;code&gt;AirPassengers&lt;/code&gt; data set in this post. Before we begin to build the plot, let us take a quick look at the data in order to understand what we are plotting.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;head(AirPassengers)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 112 118 132 129 121 135&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In order to build a line plot, we will set the &lt;code&gt;type&lt;/code&gt; argument in the &lt;code&gt;plot()&lt;/code&gt; function to &lt;strong&gt;l&lt;/strong&gt; (line). There are other values which &lt;code&gt;type&lt;/code&gt; takes but we will explore them later.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;data &amp;lt;- head(AirPassengers)
plot(data, type = &amp;#39;l&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-29-data-visualization-with-r-line-graphs_files/figure-html/line1-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;If you do not like plain lines, you can represent the data using lines interspersed with points by setting the &lt;code&gt;type&lt;/code&gt; argument to &lt;strong&gt;b&lt;/strong&gt; (both lines and points).&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(data, type = &amp;#39;b&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-29-data-visualization-with-r-line-graphs_files/figure-html/line2-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Another option is to have the points and lines overplotted. It can be achieved by setting the &lt;code&gt;type&lt;/code&gt; argument to &lt;strong&gt;o&lt;/strong&gt; (overplotted).&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(data, type = &amp;#39;o&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-29-data-visualization-with-r-line-graphs_files/figure-html/line3-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;You can also create lines without points but with breaks instead by setting the &lt;code&gt;type&lt;/code&gt; argument to &lt;strong&gt;c&lt;/strong&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(data, type = &amp;#39;c&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-29-data-visualization-with-r-line-graphs_files/figure-html/line4-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;color&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Color&lt;/h3&gt;
&lt;p&gt;So now we know how to build a simple line graph. Let us now make this plot more elegant by modifying its appearance. Let us begin by adding some color to the line using the &lt;code&gt;col&lt;/code&gt; argument in the &lt;code&gt;plot()&lt;/code&gt; function.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(data, type = &amp;#39;l&amp;#39;, col = &amp;#39;blue&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-29-data-visualization-with-r-line-graphs_files/figure-html/line5-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;If you have points along with the line, they will have the same color as well.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(data, type = &amp;#39;b&amp;#39;, col = &amp;#39;blue&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-29-data-visualization-with-r-line-graphs_files/figure-html/line6-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;line-type&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Line Type&lt;/h3&gt;
&lt;p&gt;The line type can be modified using the &lt;code&gt;lty&lt;/code&gt; argument. It takes values from 1 to 6 and the default value is 1. Below is an example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;1:solid&lt;/li&gt;
&lt;li&gt;2:dashed&lt;/li&gt;
&lt;li&gt;3:dotted&lt;/li&gt;
&lt;li&gt;4:dotdash&lt;/li&gt;
&lt;li&gt;5:longdash&lt;/li&gt;
&lt;li&gt;6:twodash&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(data, type = &amp;#39;l&amp;#39;, lty = 3)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-29-data-visualization-with-r-line-graphs_files/figure-html/line9-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Let us look at all the line types in the below example:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-29-data-visualization-with-r-line-graphs_files/figure-html/lin7-1.png&#34; width=&#34;960&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Instead of specifying the numbers 1:6, you can use their description as well.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-29-data-visualization-with-r-line-graphs_files/figure-html/lin8-1.png&#34; width=&#34;960&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;line-width&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Line Width&lt;/h3&gt;
&lt;p&gt;The width of the lines can be modified using the &lt;code&gt;lwd&lt;/code&gt; argument in the &lt;code&gt;plot()&lt;/code&gt; function. The default value for width is 1.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(data, type = &amp;#39;l&amp;#39;, lwd = 2.5)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-29-data-visualization-with-r-line-graphs_files/figure-html/line10-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;In the below example, we look at the width of the lines relative to the default value.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-29-data-visualization-with-r-line-graphs_files/figure-html/lin11-1.png&#34; width=&#34;960&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;enhance-points&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Enhance Points&lt;/h3&gt;
&lt;p&gt;We can enhance the points in the line plot in the same way as we enhanced the points in the scatter plot in this previous &lt;a href=&#34;https://rsquaredacademy.github.io/post/data-visualization-with-r-scatter-plots/&#34;&gt;post&lt;/a&gt;. Let us look at an example:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(data, type = &amp;#39;b&amp;#39;, pch = 23, col = &amp;#39;red&amp;#39;, cex = 1.5)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-29-data-visualization-with-r-line-graphs_files/figure-html/line12-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;We have used the &lt;code&gt;pch&lt;/code&gt;, &lt;code&gt;col&lt;/code&gt; and &lt;code&gt;cex&lt;/code&gt; arguments to modify the shape, color and size of the points. One drawback of the above method is that the color of the line and the points will be the same. What if we want them to have different colors? The solution is as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;build the line graph using the &lt;code&gt;plot()&lt;/code&gt; function&lt;/li&gt;
&lt;li&gt;add the points to the above plot using the &lt;code&gt;points()&lt;/code&gt; function&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the next example, let us first build the line plot, add points using the &lt;code&gt;points()&lt;/code&gt; function and then specify separate colors to the line and the points.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(data, type = &amp;#39;l&amp;#39;, col = &amp;#39;red&amp;#39;)
points(data, pch = 23, col = &amp;#39;blue&amp;#39;, bg = &amp;#39;green&amp;#39;, cex = 1.5)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-29-data-visualization-with-r-line-graphs_files/figure-html/line13-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;additional-lines&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Additional Lines&lt;/h3&gt;
&lt;p&gt;If you want to compare variables, you would want to add additional lines to the line graph. In R, this can be achieved using the &lt;code&gt;lines()&lt;/code&gt; function. First we create the line plot using the base variable and then we can add as many lines as we want using the &lt;code&gt;lines()&lt;/code&gt; function.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Before you add additional lines, it is important to ensure that the range of both the axis are modified to accommodate the data of the additional lines. If we do not modify the axis range, some of the lines will be outside the plot.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Let us now create a line plot and add an additional line using the &lt;code&gt;lines()&lt;/code&gt; function.We will use some dummy data for this example:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;data1 &amp;lt;- c(7.2, 7.6, 6.8, 6.5, 7)
data2 &amp;lt;- c(6.8, 7.2, 7.8, 7, 6.2)
plot(data1, type = &amp;quot;b&amp;quot;, col = &amp;quot;blue&amp;quot;)
lines(data2, type = &amp;quot;b&amp;quot;, col = &amp;quot;red&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-29-data-visualization-with-r-line-graphs_files/figure-html/line14-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As you can see the second line is outside the plot. Let us recreate the plot but this time we will modify the range of the axis to accommodate the second line (data2).&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(data1, type = &amp;quot;b&amp;quot;, col = &amp;quot;blue&amp;quot;, ylim = c(5, 9))
lines(data2, type = &amp;quot;b&amp;quot;, col = &amp;quot;red&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-29-data-visualization-with-r-line-graphs_files/figure-html/line15-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;putting-it-all-together&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Putting it all together…&lt;/h3&gt;
&lt;p&gt;Finally let us enhance the plot by adding a title and modifying the axis labels which we learnt in this first &lt;a href=&#34;https://rsquaredacademy.github.io/post/data-visualization-with-r-title-and-axis-labels/&#34;&gt;post&lt;/a&gt; of the series.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(data1, type = &amp;quot;b&amp;quot;, col = &amp;quot;blue&amp;quot;, 
     ylim = c(5, 9), main = &amp;#39;Line Graph&amp;#39;,
     xlab = &amp;#39;Index&amp;#39;, ylab = &amp;#39;Data&amp;#39;)
lines(data2, type = &amp;quot;b&amp;quot;, col = &amp;quot;red&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-29-data-visualization-with-r-line-graphs_files/figure-html/line16-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;In this post, we learnt how to&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;create line plots&lt;/li&gt;
&lt;li&gt;modify appearance of the line&lt;/li&gt;
&lt;li&gt;add points to the line plot&lt;/li&gt;
&lt;li&gt;add additional lines&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Data Visualization With R - Scatter Plots</title>
      <link>https://blog.rsquaredacademy.com/data-visualization-with-r-scatter-plots/</link>
      <pubDate>Sat, 17 Jun 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/data-visualization-with-r-scatter-plots/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;This is the third post in the series &lt;strong&gt;Data Visualization With R&lt;/strong&gt;. In the previous post, we learned how to add title, subtitle and axis labels. We also learned how to modify the range of the axis. In this post, we will learn how to create scatter plots.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;adding color to the points&lt;/li&gt;
&lt;li&gt;modify shape of the points&lt;/li&gt;
&lt;li&gt;modify size of the points&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt; and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/f5cd1315826bd44466a15444456ea61d&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;basic-plot&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Basic Plot&lt;/h3&gt;
&lt;p&gt;Let us recreate the plot that we had created in the first post by using the &lt;code&gt;mtcars&lt;/code&gt; data set. We will use the &lt;code&gt;disp&lt;/code&gt; (displacement) and &lt;code&gt;mpg&lt;/code&gt; (miles per gallon) variables. &lt;code&gt;disp&lt;/code&gt; will be on the X axis and &lt;code&gt;mpg&lt;/code&gt; will be on the Y axis.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(mtcars$disp, mtcars$mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-17-data-visualization-with-r-scatter-plots_files/figure-html/scatter1-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;We have created a very basic plot and any one looking at it for the first time will get confused with the axis labels &lt;code&gt;mtcars$disp&lt;/code&gt; and &lt;code&gt;mtcars$mpg&lt;/code&gt;. Let us put into practice what we learnt in the second post, and add a title to the plot, and make the axis labels more meaningful.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(mtcars$disp, mtcars$mpg,
     main = &amp;#39;Displacement vs Miles Per Gallon&amp;#39;,
     xlab = &amp;#39;Displacement&amp;#39;, ylab = &amp;#39;Miles Per Gallon&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-17-data-visualization-with-r-scatter-plots_files/figure-html/scatter2-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Now the plot clearly communicates that it represents the relationship between the displacement and mileage of cars. Now the color of the points in the plot is black by default. Some of us may agree that black is beautiful but not all of us will like it. As a first step in enhancing the way our plot looks, let us change the shape of the points.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;shape&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Shape&lt;/h3&gt;
&lt;p&gt;The shape of the point can be specified using the &lt;code&gt;pch&lt;/code&gt; argument. It will take values between &lt;strong&gt;0&lt;/strong&gt; and &lt;strong&gt;25&lt;/strong&gt;. Below is an example:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# point shape
plot(mtcars$disp, mtcars$mpg, pch = 6)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-17-data-visualization-with-r-scatter-plots_files/figure-html/scatter-shape-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Let us check out a few of the other shapes:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-17-data-visualization-with-r-scatter-plots_files/figure-html/scatter-pch-1.png&#34; width=&#34;960&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;We can specify the shape based on a third (categorical variable as well). In the below plot, the shape is based on the levels of the categorical variable &lt;code&gt;cyl&lt;/code&gt; (number of cylinders) from the &lt;code&gt;mtcars&lt;/code&gt; data set:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# shape  based on number of levels of a third variable
plot(mtcars$disp, mtcars$mpg, pch = nlevels(factor(mtcars$cyl)))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-17-data-visualization-with-r-scatter-plots_files/figure-html/scatter-pch2-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# shape based on a third categorical variable
plot(mtcars$disp, mtcars$mpg, pch = unclass(mtcars$cyl))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-17-data-visualization-with-r-scatter-plots_files/figure-html/scatter-pch3-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;size&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Size&lt;/h3&gt;
&lt;p&gt;The size of the points in the scatter plot can be specified using the &lt;code&gt;cex&lt;/code&gt; argument in the &lt;code&gt;plot()&lt;/code&gt; function. The default value for &lt;code&gt;cex&lt;/code&gt; is 1.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# point size
plot(mtcars$disp, mtcars$mpg, cex = 1.5)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-17-data-visualization-with-r-scatter-plots_files/figure-html/scatter-size-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The below plots show the size of the points for values relative to 1.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-17-data-visualization-with-r-scatter-plots_files/figure-html/scatter-cex-1.png&#34; width=&#34;960&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;color&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Color&lt;/h3&gt;
&lt;p&gt;We can specify a border color for the points using the &lt;code&gt;col&lt;/code&gt; argument and a background color using the &lt;code&gt;bg&lt;/code&gt; argument. The background color can be specified only for points whose &lt;code&gt;pch&lt;/code&gt; argument takes values between &lt;strong&gt;21&lt;/strong&gt; and &lt;strong&gt;25&lt;/strong&gt;. Let us look at some examples to understand this distinction between border and background color.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# shape between 0 and 21
plot(mtcars$disp, mtcars$mpg, pch = 5, col = &amp;#39;blue&amp;#39;, bg = &amp;#39;red&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-17-data-visualization-with-r-scatter-plots_files/figure-html/col1-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;You can observe that although we have specified a background color using the &lt;code&gt;bg&lt;/code&gt; argument, we do not see the red background color as the value specified for the &lt;code&gt;pch&lt;/code&gt; (shape) argument is not between 21 and 25. In the next example, we will use a value between 21 and 25 so that the &lt;code&gt;pch&lt;/code&gt; argument is effective.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# shape between 22 and 25
plot(mtcars$disp, mtcars$mpg, pch = 24, col = &amp;#39;red&amp;#39;, bg = &amp;#39;blue&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-17-data-visualization-with-r-scatter-plots_files/figure-html/col2-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The color of the points can be specified using (levels) of a categorical variable as well. In the next example, we will use the &lt;code&gt;cyl&lt;/code&gt; variable to specify the color of the points.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# color based on a third variable
plot(mtcars$disp, mtcars$mpg, pch = 5, col = factor(mtcars$cyl))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-17-data-visualization-with-r-scatter-plots_files/figure-html/col3-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Since &lt;code&gt;cyl&lt;/code&gt; is a categorical variable with 3 levels, we can see that the points now have 3 different colors. The above method is useful when you want to segregate the points in a scatter plot based on a third variable.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;In this post, we learned how to&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;create scatter plots&lt;/li&gt;
&lt;li&gt;add color to the points&lt;/li&gt;
&lt;li&gt;modify shape of the points&lt;/li&gt;
&lt;li&gt;modify size of the points&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Data Visualization With R - Title and Axis Labels</title>
      <link>https://blog.rsquaredacademy.com/data-visualization-with-r-title-and-axis-labels/</link>
      <pubDate>Mon, 05 Jun 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/data-visualization-with-r-title-and-axis-labels/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;This is the second post of the series &lt;strong&gt;Data Visualization With R&lt;/strong&gt;. In the previous post, we explored the &lt;code&gt;plot()&lt;/code&gt; function and observed the different types of plots it generated. In this post, we will learn how to add:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Title&lt;/li&gt;
&lt;li&gt;Subtitle&lt;/li&gt;
&lt;li&gt;Axis Labels&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;to a plot and how to modify:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Axis range&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the previous &lt;a href=&#34;https://rsquaredacademy.github.io/post/data-visualization-with-r-introduction/&#34;&gt;post&lt;/a&gt;, we created plots which did not have any title or labels. Such plots are of no use to any one as they do not indicate what the X and Y axis represent or the primary information being communicated by the plot. The &lt;code&gt;title&lt;/code&gt; and &lt;code&gt;labels&lt;/code&gt; play an important part in making the plot holistic. There are two ways to add them to a plot:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;use the relevant arguments within the &lt;code&gt;plot()&lt;/code&gt; function&lt;/li&gt;
&lt;li&gt;use the &lt;code&gt;title()&lt;/code&gt; function&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We will explore both the above methods one by one, and you can choose the method most convenient to you. Let us begin with the &lt;code&gt;plot()&lt;/code&gt; function:&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt; and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/7c0968878e8cf989b669ae80ac32d15a&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;syntax&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Syntax&lt;/h3&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;left&#34;&gt;Feature&lt;/th&gt;
&lt;th align=&#34;left&#34;&gt;Argument&lt;/th&gt;
&lt;th align=&#34;left&#34;&gt;Value&lt;/th&gt;
&lt;th align=&#34;left&#34;&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;left&#34;&gt;Title&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;main&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;string&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;“Scatter Plot”&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;left&#34;&gt;Subtitle&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;sub&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;string&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;“Displacement vs Miles Per Gallon”&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;left&#34;&gt;X Axis Label&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;xlab&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;string&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;“Displacement”&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;left&#34;&gt;Y Axis Label&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;ylab&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;string&lt;/td&gt;
&lt;td align=&#34;left&#34;&gt;“Miles Per Gallon”&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;div id=&#34;title&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Title&lt;/h3&gt;
&lt;p&gt;You can add a title to the plot using the &lt;code&gt;main&lt;/code&gt; argument in the &lt;code&gt;plot()&lt;/code&gt; function. Ensure that the title is enclosed in single/double quotes as it is a string. Let us create a scatter plot of &lt;code&gt;disp&lt;/code&gt; and &lt;code&gt;mpg&lt;/code&gt; from &lt;code&gt;mtcars&lt;/code&gt; data set, and add a title to it.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(mtcars$disp, mtcars$mpg, 
     main = &amp;#39;Displacement vs Miles Per Gallon&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-05-data-visualization-with-r-title-and-axis-labels_files/figure-html/title-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;subtitle&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Subtitle&lt;/h3&gt;
&lt;p&gt;You can add a subtitle to the plot using the &lt;code&gt;sub&lt;/code&gt; argument in the &lt;code&gt;plot()&lt;/code&gt; function. The subtitle will appear below the X axis label. Ensure that the subtitle is enclosed in single/double quotes as it is a string. Let us add a subtitle to the plot we created in the previous example:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(mtcars$disp, mtcars$mpg, 
     main = &amp;#39;Displacement vs Miles Per Gallon&amp;#39;,
     sub = &amp;#39;Mileage is inversely related to Displacement&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-05-data-visualization-with-r-title-and-axis-labels_files/figure-html/subtitle-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;axis-labels&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Axis Labels&lt;/h3&gt;
&lt;p&gt;In the plots created in the previous examples, the axis labels appear as &lt;code&gt;mtcars$mpg&lt;/code&gt; and &lt;code&gt;mtcars$disp&lt;/code&gt;. It is not the best way to name the axis and it will make more sense to use names that describe the data. Let us modify the axis labels using the &lt;code&gt;xlab&lt;/code&gt; and &lt;code&gt;ylab&lt;/code&gt; arguments in the &lt;code&gt;plot()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(mtcars$disp, mtcars$mpg, 
     main = &amp;#39;Displacement vs Miles Per Gallon&amp;#39;,
     sub = &amp;#39;Mileage is inversely related to Displacement&amp;#39;,
     xlab = &amp;#39;Displacement&amp;#39;, ylab = &amp;#39;Miles Per Gallon&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-05-data-visualization-with-r-title-and-axis-labels_files/figure-html/axis-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;title-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;title()&lt;/h3&gt;
&lt;p&gt;We can add title, subtitle and axis labels using the &lt;code&gt;title()&lt;/code&gt; function as well. Let us recreate the plots from the previous examples but this time we will use the &lt;code&gt;title()&lt;/code&gt; instead of the &lt;code&gt;plot()&lt;/code&gt; function. We will continue to use the &lt;code&gt;plot()&lt;/code&gt; function to create the plot.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# create scatter plot
plot(mtcars$disp, mtcars$mpg) 

# add title, subtitle and axis labels
title(main = &amp;#39;Displacement vs Miles Per Gallon&amp;#39;,
      sub = &amp;#39;Mileage is inversely related to Displacement&amp;#39;,
      xlab = &amp;#39;Displacement&amp;#39;, ylab = &amp;#39;Miles Per Gallon&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-05-data-visualization-with-r-title-and-axis-labels_files/figure-html/title1-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Do you notice that the axis labels are overwritten? This happens because the &lt;code&gt;plot()&lt;/code&gt; function adds the default labels and we add a new set of labels without modifying the existing ones. The solution is to instruct the &lt;code&gt;plot()&lt;/code&gt; function not to add any labels to the X and Y axis. This can be achieved using the &lt;code&gt;ann&lt;/code&gt; (annotate) argument in the &lt;code&gt;plot()&lt;/code&gt; function and set it to &lt;code&gt;FALSE&lt;/code&gt;. Let us try it:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# create scatter plot
plot(mtcars$disp, mtcars$mpg, ann = FALSE) 

# add title, subtitle and axis labels
title(main = &amp;#39;Displacement vs Miles Per Gallon&amp;#39;,
      sub = &amp;#39;Mileage is inversely related to Displacement&amp;#39;,
      xlab = &amp;#39;Displacement&amp;#39;, ylab = &amp;#39;Miles Per Gallon&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-05-data-visualization-with-r-title-and-axis-labels_files/figure-html/title2-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The axis labels are legible and not overwritten. You can use either the &lt;code&gt;plot()&lt;/code&gt; function or the &lt;code&gt;title()&lt;/code&gt; function to add title, subtitle and axis labels but ensure that in case you use the &lt;code&gt;title()&lt;/code&gt; function, set &lt;code&gt;ann&lt;/code&gt; argument to &lt;code&gt;FALSE&lt;/code&gt; in the &lt;code&gt;plot()&lt;/code&gt; function.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;axis-range&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Axis Range&lt;/h3&gt;
&lt;p&gt;In certain cases, you would want to modify the range of the axis of the plots. By default, the &lt;code&gt;plot()&lt;/code&gt; function will take into account the &lt;code&gt;min&lt;/code&gt; and &lt;code&gt;max&lt;/code&gt; values of the variable(s) and set the range for the axis. We can modify the range by using the &lt;code&gt;xlim&lt;/code&gt; and &lt;code&gt;ylim&lt;/code&gt; arguments in the &lt;code&gt;plot()&lt;/code&gt; function. Both the &lt;code&gt;xlim&lt;/code&gt; and &lt;code&gt;ylim&lt;/code&gt; arguments take 2 values as inputes. The first value is the minimum value for the axis and the second value is the maximum value for the axis. The &lt;code&gt;plot()&lt;/code&gt; function will return an error if we do not specify two values for both &lt;code&gt;xlim&lt;/code&gt; and &lt;code&gt;ylim&lt;/code&gt; arguments. Let us recreate the plot from the previous examples but change the range of both the X and Y axis:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(mtcars$disp, mtcars$mpg, 
     xlim = c(0, 600), ylim = c(0, 50))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-06-05-data-visualization-with-r-title-and-axis-labels_files/figure-html/axisrange-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Keep in mind that the axis ranges cannot be modified using the &lt;code&gt;title()&lt;/code&gt; function.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;In this post, we learned how to add title, subtitle and axis labels to a plot using the &lt;code&gt;plot()&lt;/code&gt; and &lt;code&gt;title()&lt;/code&gt; function. We also learned how to modify the range of the X and Y axis using the &lt;code&gt;xlim&lt;/code&gt; and &lt;code&gt;ylim&lt;/code&gt; arguments within the &lt;code&gt;plot()&lt;/code&gt; function.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Data Visualization With R - Introduction</title>
      <link>https://blog.rsquaredacademy.com/data-visualization-with-r-introduction/</link>
      <pubDate>Wed, 24 May 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/data-visualization-with-r-introduction/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;This is the first post of the series &lt;strong&gt;Data Visualization With R&lt;/strong&gt;. The objective of the series is to provide a gentle introduction to working with base graphics in R. We will come up with a similar series using &lt;a href=&#34;https://ggplot2.tidyverse.org/index.html&#34;&gt;ggplot2&lt;/a&gt; shortly.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;what is data visualization&lt;/li&gt;
&lt;li&gt;why visualize data&lt;/li&gt;
&lt;li&gt;understand R graphics system
&lt;ul&gt;
&lt;li&gt;graphics&lt;/li&gt;
&lt;li&gt;ggplot2&lt;/li&gt;
&lt;li&gt;lattice&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;build some simple plots&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;libraries-code-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Libraries, Code &amp;amp; Data&lt;/h3&gt;
&lt;p&gt;All the data sets used in this post can be found &lt;a href=&#34;https://github.com/rsquaredacademy/datasets&#34;&gt;here&lt;/a&gt; and code can be downloaded from &lt;a href=&#34;https://gist.github.com/rsquaredacademy/3690e9217c72644a9e9bada0df709426&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;what-is-data-visualization&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;What is data visualization?&lt;/h3&gt;
&lt;p&gt;In simple words, data visualization is the representation of data in graphical format.&lt;/p&gt;
&lt;div class=&#34;figure&#34;&gt;
&lt;img src=&#34;data-viz.png&#34; alt=&#34;&#34; /&gt;
&lt;p class=&#34;caption&#34;&gt;data-viz&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;why-visualize-data&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Why visualize data?&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Explore: Visualization helps in exploring and explaining patterns and trends&lt;/li&gt;
&lt;li&gt;Detect: Patterns or anomalies in data can be detected by looking at graphs&lt;/li&gt;
&lt;li&gt;Make sense: Possible to make sense of large amount of data efficiently and in time&lt;/li&gt;
&lt;li&gt;Communicate: Easy to communicate and share the insights from data&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;r-graphics-system&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;R Graphics System&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;graphics&lt;/li&gt;
&lt;li&gt;ggplot2&lt;/li&gt;
&lt;li&gt;lattice&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;graphics&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Graphics&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;It is part of base R and is the fundamental package for visualizing data.&lt;/li&gt;
&lt;li&gt;It has a lot of good features and we can create all the basic plots using it.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;ggplot2&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;ggplot2&lt;/h4&gt;
&lt;p&gt;&lt;a href=&#34;https://ggplot2.tidyverse.org/index.html&#34;&gt;ggplot2&lt;/a&gt;, created by &lt;a href=&#34;https://hadley.nz/&#34;&gt;Hadley Wickham&lt;/a&gt;, is based on the Grammar of Graphics written by Leland Wilkinson. It has a structured approach to data visualization and builds upon the features available in the Graphics and Lattice packages.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;lattice&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Lattice&lt;/h4&gt;
&lt;p&gt;The &lt;a href=&#34;https://CRAN.R-project.org/package=lattice&#34;&gt;lattice&lt;/a&gt; package is inspired by Trellis Graphics and created by &lt;a href=&#34;https://www.isid.ac.in/~deepayan/&#34;&gt;Deepayan Sarkar&lt;/a&gt;. It is a very powerful data visualization system with an emphasis on multivariate data.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;getting-help&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Getting Help&lt;/h3&gt;
&lt;p&gt;Use the &lt;code&gt;help()&lt;/code&gt; to learn more about &lt;code&gt;plot()&lt;/code&gt; function and &lt;code&gt;mtcars&lt;/code&gt; data set.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;help(plot)
help(mtcars)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;mtcars&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;mtcars&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;head(mtcars)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##                    mpg cyl disp  hp drat    wt  qsec vs am gear carb
## Mazda RX4         21.0   6  160 110 3.90 2.620 16.46  0  1    4    4
## Mazda RX4 Wag     21.0   6  160 110 3.90 2.875 17.02  0  1    4    4
## Datsun 710        22.8   4  108  93 3.85 2.320 18.61  1  1    4    1
## Hornet 4 Drive    21.4   6  258 110 3.08 3.215 19.44  1  0    3    1
## Hornet Sportabout 18.7   8  360 175 3.15 3.440 17.02  0  0    3    2
## Valiant           18.1   6  225 105 2.76 3.460 20.22  1  0    3    1&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;variable-info&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;variable info&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;str(mtcars)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## &amp;#39;data.frame&amp;#39;:    32 obs. of  11 variables:
##  $ mpg : num  21 21 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 ...
##  $ cyl : num  6 6 4 6 8 6 8 4 4 6 ...
##  $ disp: num  160 160 108 258 360 ...
##  $ hp  : num  110 110 93 110 175 105 245 62 95 123 ...
##  $ drat: num  3.9 3.9 3.85 3.08 3.15 2.76 3.21 3.69 3.92 3.92 ...
##  $ wt  : num  2.62 2.88 2.32 3.21 3.44 ...
##  $ qsec: num  16.5 17 18.6 19.4 17 ...
##  $ vs  : num  0 0 1 1 0 1 0 1 1 1 ...
##  $ am  : num  1 1 1 0 0 0 0 0 0 0 ...
##  $ gear: num  4 4 4 3 3 3 3 4 4 4 ...
##  $ carb: num  4 4 1 1 2 1 4 2 2 4 ...&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;plot&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;plot()&lt;/h3&gt;
&lt;p&gt;Now that we have some idea about the data set, let us explore the &lt;code&gt;plot()&lt;/code&gt; function. We will use the following different data inputs and observe the kind of plots that are generated:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Case 1: 1 continuous variable&lt;/li&gt;
&lt;li&gt;Case 2: 1 categorical variable&lt;/li&gt;
&lt;li&gt;Case 3: 2 continuous variables&lt;/li&gt;
&lt;li&gt;Case 4: 2 categorical variables&lt;/li&gt;
&lt;li&gt;Case 5: 1 continuous and 1 categorical variable&lt;/li&gt;
&lt;li&gt;Case 6: 1 categorical and 1 continuous variable&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;one-continuous-variable&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;One continuous variable&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(mtcars$mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-05-24-data-visualization-with-r-introduction_files/figure-html/plot1-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;one-categorical-variable&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;One categorical variable&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(as.factor(mtcars$cyl))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-05-24-data-visualization-with-r-introduction_files/figure-html/plot2-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;two-continuous-variables&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Two continuous variables&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(mtcars$disp, mtcars$mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-05-24-data-visualization-with-r-introduction_files/figure-html/plot3-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;two-categorical-variables&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Two categorical variables&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(as.factor(mtcars$am), as.factor(mtcars$cyl))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-05-24-data-visualization-with-r-introduction_files/figure-html/plot4-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;continuouscategorical-variable&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Continuous/Categorical variable&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(mtcars$mpg, mtcars$cyl)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-05-24-data-visualization-with-r-introduction_files/figure-html/plot5-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;categoricalcontinuous-variable&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Categorical/Continuous variable&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot(as.factor(mtcars$cyl), mtcars$mpg)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://blog.rsquaredacademy.com/post/2017-05-24-data-visualization-with-r-introduction_files/figure-html/plot6-1.png&#34; width=&#34;480&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;In this first post, we have explored the &lt;code&gt;plot()&lt;/code&gt; function to understand the different types of plots it can create based on the input types. Before we begin to build different plots such as bar plots, box plots, scatter plots or line plots, we will quickly learn how to add title and labels to a plot.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Dataframes</title>
      <link>https://blog.rsquaredacademy.com/dataframes/</link>
      <pubDate>Fri, 12 May 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/dataframes/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In the previous post, we learnt about lists. In this post, we will learn about &lt;code&gt;dataframe&lt;/code&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;create dataframe&lt;/li&gt;
&lt;li&gt;select columns&lt;/li&gt;
&lt;li&gt;select rows&lt;/li&gt;
&lt;li&gt;utitlity functions&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;create-dataframes&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Create dataframes&lt;/h2&gt;
&lt;p&gt;Use &lt;code&gt;data.frame&lt;/code&gt; to create dataframes. Below is the function syntax:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;args(data.frame)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, 
##     fix.empty.names = TRUE, stringsAsFactors = default.stringsAsFactors()) 
## NULL&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Data frames are basically lists with elements of equal lenght and as such, they are heterogeneous. Let us create a dataframe:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;name &amp;lt;- c(&amp;#39;John&amp;#39;, &amp;#39;Jack&amp;#39;, &amp;#39;Jill&amp;#39;)
age &amp;lt;- c(29, 25, 27)
graduate &amp;lt;- c(TRUE, TRUE, FALSE)
students &amp;lt;- data.frame(name, age, graduate)
students&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   name age graduate
## 1 John  29     TRUE
## 2 Jack  25     TRUE
## 3 Jill  27    FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;basic-information&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Basic Information&lt;/h2&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;class(students)
## [1] &amp;quot;data.frame&amp;quot;
names(students)
## [1] &amp;quot;name&amp;quot;     &amp;quot;age&amp;quot;      &amp;quot;graduate&amp;quot;
colnames(students)
## [1] &amp;quot;name&amp;quot;     &amp;quot;age&amp;quot;      &amp;quot;graduate&amp;quot;
str(students)
## &amp;#39;data.frame&amp;#39;:    3 obs. of  3 variables:
##  $ name    : chr  &amp;quot;John&amp;quot; &amp;quot;Jack&amp;quot; &amp;quot;Jill&amp;quot;
##  $ age     : num  29 25 27
##  $ graduate: logi  TRUE TRUE FALSE
dim(students)
## [1] 3 3
nrow(students)
## [1] 3
ncol(students)
## [1] 3&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;select-columns&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Select Columns&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;[]&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;[[]]&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;$&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# using [
students[1]
##   name
## 1 John
## 2 Jack
## 3 Jill

# using [[
students[[1]]
## [1] &amp;quot;John&amp;quot; &amp;quot;Jack&amp;quot; &amp;quot;Jill&amp;quot;

# using $
students$name
## [1] &amp;quot;John&amp;quot; &amp;quot;Jack&amp;quot; &amp;quot;Jill&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;multiple-columns&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Multiple Columns&lt;/h3&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;students[, 1:3]
##   name age graduate
## 1 John  29     TRUE
## 2 Jack  25     TRUE
## 3 Jill  27    FALSE

students[, c(1, 3)]
##   name graduate
## 1 John     TRUE
## 2 Jack     TRUE
## 3 Jill    FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;select-rows&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Select Rows&lt;/h2&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# single row
students[1, ]
##   name age graduate
## 1 John  29     TRUE

# multiple row
students[c(1, 3), ]
##   name age graduate
## 1 John  29     TRUE
## 3 Jill  27    FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you have observed carefully, the column &lt;code&gt;names&lt;/code&gt; has been coerced to type factor. This happens because of a default argument in
&lt;code&gt;data.frame&lt;/code&gt; which is &lt;code&gt;stringsAsFactors&lt;/code&gt; which is set to &lt;code&gt;TRUE&lt;/code&gt;. If you do not want to treat it as &lt;code&gt;factors&lt;/code&gt;, set the argument to &lt;code&gt;FALSE&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;students &amp;lt;- data.frame(name, age, graduate, stringsAsFactors = FALSE)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We will learn about wrangling dataframes in a different post.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Factors</title>
      <link>https://blog.rsquaredacademy.com/introduction-to-factors/</link>
      <pubDate>Sun, 30 Apr 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/introduction-to-factors/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In the previous post, we learnt about dataframes. In this post, we will learn about factors.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;create factors&lt;/li&gt;
&lt;li&gt;order levels&lt;/li&gt;
&lt;li&gt;specify labels&lt;/li&gt;
&lt;li&gt;check levels&lt;/li&gt;
&lt;li&gt;number of levels&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Categorical or qualitative data in R is treated as data type &lt;code&gt;factor&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;create-factors&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Create Factors&lt;/h2&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;args(factor)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## function (x = character(), levels, labels = levels, exclude = NA, 
##     ordered = is.ordered(x), nmax = NA) 
## NULL&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;devices &amp;lt;- factor(c(&amp;#39;Mobile&amp;#39;, &amp;#39;Tablet&amp;#39;, &amp;#39;Desktop&amp;#39;))
devices&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] Mobile  Tablet  Desktop
## Levels: Desktop Mobile Tablet&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# number of levels
nlevels(devices)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 3&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# levels
levels(devices)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Desktop&amp;quot; &amp;quot;Mobile&amp;quot;  &amp;quot;Tablet&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We will learn more about factors in a later post.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Lists</title>
      <link>https://blog.rsquaredacademy.com/introduction-to-lists/</link>
      <pubDate>Tue, 18 Apr 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/introduction-to-lists/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In the previous post, we learnt about matrices. In this post, we will learn about lists. Lists are very useful as they are heterogeneous i.e. they can contain different data types. If you remember, vectors and matrices are homogeneous i.e. they can contain only one type of data. If you include different data types, they will all be coerced to the same type. With lists, it is different. We learnt how to create lists briefly in the previous post while naming the rows and columns of a matrix. In this post, we will delve deeper into lists.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;how to create lists&lt;/li&gt;
&lt;li&gt;access list elements&lt;/li&gt;
&lt;li&gt;name list elements&lt;/li&gt;
&lt;li&gt;coerce other R objects to list&lt;/li&gt;
&lt;li&gt;coerce list to other R objects&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;creating-lists&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Creating Lists&lt;/h2&gt;
&lt;p&gt;To create a list, we use the &lt;code&gt;list()&lt;/code&gt; function. Let us create a simple list to demonstrate how they can contain different data types.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# numeric vector
vect1 &amp;lt;- 1:10

# character vector 
vect2 &amp;lt;- c(&amp;#39;Jack&amp;#39;, &amp;#39;John&amp;#39;, &amp;#39;Jill&amp;#39;)

# logical vector
vect3 &amp;lt;- c(TRUE, FALSE)

# matrix
mat &amp;lt;- matrix(data = 1:9, nrow = 3)

# list
l &amp;lt;- list(vect1, vect2, vect3, mat)
l&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [[1]]
##  [1]  1  2  3  4  5  6  7  8  9 10
## 
## [[2]]
## [1] &amp;quot;Jack&amp;quot; &amp;quot;John&amp;quot; &amp;quot;Jill&amp;quot;
## 
## [[3]]
## [1]  TRUE FALSE
## 
## [[4]]
##      [,1] [,2] [,3]
## [1,]    1    4    7
## [2,]    2    5    8
## [3,]    3    6    9&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you observe the output, all the elements of the list retain their data types. Now let us learn how to access the elements of the list.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;access-list-elements&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Access List Elements&lt;/h2&gt;
&lt;p&gt;You can access the elements of a list using the following operators:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;[[&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;[&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;$&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let us try them one by one.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# using [[
l[[1]]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  1  2  3  4  5  6  7  8  9 10&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# using [
l[1]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [[1]]
##  [1]  1  2  3  4  5  6  7  8  9 10&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;[[&lt;/code&gt; returns a vector while &lt;code&gt;[&lt;/code&gt; returns a list. The &lt;code&gt;$&lt;/code&gt; operator can be used only when we have named elements in the list. Let us add names to the elements. Use the &lt;code&gt;names()&lt;/code&gt; function to add names to the list.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# named elements
names(l) &amp;lt;- c(&amp;#39;vect1&amp;#39;, &amp;#39;vect2&amp;#39;, &amp;#39;vect3&amp;#39;, &amp;#39;mat&amp;#39;)
l&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## $vect1
##  [1]  1  2  3  4  5  6  7  8  9 10
## 
## $vect2
## [1] &amp;quot;Jack&amp;quot; &amp;quot;John&amp;quot; &amp;quot;Jill&amp;quot;
## 
## $vect3
## [1]  TRUE FALSE
## 
## $mat
##      [,1] [,2] [,3]
## [1,]    1    4    7
## [2,]    2    5    8
## [3,]    3    6    9&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# use $
l$vect1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  1  2  3  4  5  6  7  8  9 10&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# use [[
l[[&amp;#39;vect1&amp;#39;]]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  1  2  3  4  5  6  7  8  9 10&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# use [
l[&amp;#39;vect1&amp;#39;]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## $vect1
##  [1]  1  2  3  4  5  6  7  8  9 10&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;coerce-other-objects&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Coerce other objects&lt;/h2&gt;
&lt;p&gt;You can coerce other objects to list using &lt;code&gt;as.list()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# vector
vect1 &amp;lt;- 1:10
as.list(vect1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [[1]]
## [1] 1
## 
## [[2]]
## [1] 2
## 
## [[3]]
## [1] 3
## 
## [[4]]
## [1] 4
## 
## [[5]]
## [1] 5
## 
## [[6]]
## [1] 6
## 
## [[7]]
## [1] 7
## 
## [[8]]
## [1] 8
## 
## [[9]]
## [1] 9
## 
## [[10]]
## [1] 10&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# matrix
mat &amp;lt;- matrix(data = 1:9, nrow = 3)
as.list(mat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [[1]]
## [1] 1
## 
## [[2]]
## [1] 2
## 
## [[3]]
## [1] 3
## 
## [[4]]
## [1] 4
## 
## [[5]]
## [1] 5
## 
## [[6]]
## [1] 6
## 
## [[7]]
## [1] 7
## 
## [[8]]
## [1] 8
## 
## [[9]]
## [1] 9&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;coerce-list-to-other-objects&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Coerce list to other objects&lt;/h2&gt;
&lt;p&gt;Use &lt;code&gt;unlist()&lt;/code&gt; to coerce a list to vector.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# unlist
unlist(l)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  vect11  vect12  vect13  vect14  vect15  vect16  vect17  vect18  vect19 vect110 
##     &amp;quot;1&amp;quot;     &amp;quot;2&amp;quot;     &amp;quot;3&amp;quot;     &amp;quot;4&amp;quot;     &amp;quot;5&amp;quot;     &amp;quot;6&amp;quot;     &amp;quot;7&amp;quot;     &amp;quot;8&amp;quot;     &amp;quot;9&amp;quot;    &amp;quot;10&amp;quot; 
##  vect21  vect22  vect23  vect31  vect32    mat1    mat2    mat3    mat4    mat5 
##  &amp;quot;Jack&amp;quot;  &amp;quot;John&amp;quot;  &amp;quot;Jill&amp;quot;  &amp;quot;TRUE&amp;quot; &amp;quot;FALSE&amp;quot;     &amp;quot;1&amp;quot;     &amp;quot;2&amp;quot;     &amp;quot;3&amp;quot;     &amp;quot;4&amp;quot;     &amp;quot;5&amp;quot; 
##    mat6    mat7    mat8    mat9 
##     &amp;quot;6&amp;quot;     &amp;quot;7&amp;quot;     &amp;quot;8&amp;quot;     &amp;quot;9&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# remove names
unlist(l, use.names = FALSE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;1&amp;quot;     &amp;quot;2&amp;quot;     &amp;quot;3&amp;quot;     &amp;quot;4&amp;quot;     &amp;quot;5&amp;quot;     &amp;quot;6&amp;quot;     &amp;quot;7&amp;quot;     &amp;quot;8&amp;quot;     &amp;quot;9&amp;quot;    
## [10] &amp;quot;10&amp;quot;    &amp;quot;Jack&amp;quot;  &amp;quot;John&amp;quot;  &amp;quot;Jill&amp;quot;  &amp;quot;TRUE&amp;quot;  &amp;quot;FALSE&amp;quot; &amp;quot;1&amp;quot;     &amp;quot;2&amp;quot;     &amp;quot;3&amp;quot;    
## [19] &amp;quot;4&amp;quot;     &amp;quot;5&amp;quot;     &amp;quot;6&amp;quot;     &amp;quot;7&amp;quot;     &amp;quot;8&amp;quot;     &amp;quot;9&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Matrices - Part 2</title>
      <link>https://blog.rsquaredacademy.com/matrix-part-2/</link>
      <pubDate>Wed, 12 Apr 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/matrix-part-2/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In the previous post, we learnt to create matrices. In this post, we will learn to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;combining matrices&lt;/li&gt;
&lt;li&gt;index/subset matrices&lt;/li&gt;
&lt;li&gt;dissolve matrices&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;append-data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Append Data&lt;/h2&gt;
&lt;p&gt;In this section, we will learn how to append data to a matrix. There are two functions that can be used for this purpose:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;rbind()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;cbind()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;cbind&lt;/code&gt; will append a new column to the matrix while &lt;code&gt;rbind&lt;/code&gt; will append a new row.&lt;/p&gt;
&lt;div id=&#34;append-rowcolumn&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Append Row/Column&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# 3 x 3 matrix
mat &amp;lt;- matrix(data = 1:9, nrow = 3)
mat&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      [,1] [,2] [,3]
## [1,]    1    4    7
## [2,]    2    5    8
## [3,]    3    6    9&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# numeric vector
v &amp;lt;- c(10, 11, 12)
v&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 10 11 12&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# append row
rbind(mat, v)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   [,1] [,2] [,3]
##      1    4    7
##      2    5    8
##      3    6    9
## v   10   11   12&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# append column
cbind(mat, v)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##             v
## [1,] 1 4 7 10
## [2,] 2 5 8 11
## [3,] 3 6 9 12&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;combine-matrices&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Combine Matrices&lt;/h2&gt;
&lt;p&gt;When you use &lt;code&gt;rbind&lt;/code&gt; to combine two matrices, the number of columns must match and in case of &lt;code&gt;cbind&lt;/code&gt;, the number of rows must match.&lt;/p&gt;
&lt;div id=&#34;append-rowcolumn-1&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Append Row/Column&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# 3 x 3 matrix
mat1 &amp;lt;- matrix(data = 1:9, nrow = 3)
mat2 &amp;lt;- matrix(data = sample(9), nrow = 3)

# append rows
rbind(mat1, mat2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      [,1] [,2] [,3]
## [1,]    1    4    7
## [2,]    2    5    8
## [3,]    3    6    9
## [4,]    2    4    7
## [5,]    5    3    8
## [6,]    9    6    1&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# append columns
cbind(mat1, mat2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      [,1] [,2] [,3] [,4] [,5] [,6]
## [1,]    1    4    7    2    4    7
## [2,]    2    5    8    5    3    8
## [3,]    3    6    9    9    6    1&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;subset-matrices&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Subset Matrices&lt;/h2&gt;
&lt;p&gt;In this section, we will learn to subset matrices. The &lt;code&gt;[]&lt;/code&gt; operator can be used to subset matrices just like vectors but since matrices are two dimensional, we need to specify both the row number and the column number. Below are a few examples:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# 3 x 4 matrix
mat &amp;lt;- matrix(data = 1:12, nrow =3)
mat&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      [,1] [,2] [,3] [,4]
## [1,]    1    4    7   10
## [2,]    2    5    8   11
## [3,]    3    6    9   12&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# extract element from first row, first column
mat[1, 1]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# extract all rows of first column
mat[, 1]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1 2 3&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# extract all columns of first row
mat[1,]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  1  4  7 10&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# extract 2nd and 3rd row of first column
mat[c(2, 3), 1]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 2 3&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# extract 2nd and 3rd column of first row
mat[1, c(2, 3)]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 4 7&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# extract 2nd and 3rd row of first and third column
mat[c(2, 3), c(1, 3)]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      [,1] [,2]
## [1,]    2    8
## [2,]    3    9&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;using-row-column-names&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Using Row &amp;amp; Column Names&lt;/h4&gt;
&lt;p&gt;In an earlier section, we learnt how to name the rows and columns of a matrix. Let us see how these names can be used to subset matrices.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# row names
row_names &amp;lt;- c(&amp;#39;row_1&amp;#39;, &amp;#39;row_2&amp;#39;, &amp;#39;row_3&amp;#39;)

# column names
col_names &amp;lt;- c(&amp;#39;col_1&amp;#39;, &amp;#39;col_2&amp;#39;, &amp;#39;col_3&amp;#39;)

# matrix with row and column names
mat &amp;lt;- matrix(data = 1:9, nrow = 3, dimnames = list(row_names, col_names))

# extract elements from first row/columns
mat[&amp;#39;row_1&amp;#39;, &amp;#39;col_1&amp;#39;]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# extract all rows of first column
mat[, &amp;#39;col_1&amp;#39;]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## row_1 row_2 row_3 
##     1     2     3&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# extract all columns of first row
mat[&amp;#39;row_1&amp;#39;,]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## col_1 col_2 col_3 
##     1     4     7&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;using-logical-expressions&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Using Logical Expressions&lt;/h4&gt;
&lt;p&gt;We can use logical expressions to subset matrices.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# 3 x 4 matrix
mat &amp;lt;- matrix(data = 1:12, nrow =3)
mat&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      [,1] [,2] [,3] [,4]
## [1,]    1    4    7   10
## [2,]    2    5    8   11
## [3,]    3    6    9   12&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# elements greater than 4
mat &amp;gt; 4&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##       [,1]  [,2] [,3] [,4]
## [1,] FALSE FALSE TRUE TRUE
## [2,] FALSE  TRUE TRUE TRUE
## [3,] FALSE  TRUE TRUE TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# extract elements greater than 4
mat[mat &amp;gt; 4]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  5  6  7  8  9 10 11 12&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;dissolve-matrices&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Dissolve Matrices&lt;/h2&gt;
&lt;p&gt;Till now we have learnt how to coerce a vector into matrix. Now let us learn how to coerce a matrix into a vector using:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;c()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;as.vector()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# 3 x 3 matrix
mat &amp;lt;- matrix(data = 1:9, nrow =3)
mat&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      [,1] [,2] [,3]
## [1,]    1    4    7
## [2,]    2    5    8
## [3,]    3    6    9&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# using c()
c(mat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1 2 3 4 5 6 7 8 9&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# using as.vector()
as.vector(mat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1 2 3 4 5 6 7 8 9&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Matrices - Part 1</title>
      <link>https://blog.rsquaredacademy.com/matrix-part-1/</link>
      <pubDate>Thu, 06 Apr 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/matrix-part-1/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In the previous post, we learnt to index/subset vectors. In this post, we will learn to create matrices. A matrix is a regular array of data elements, arranged in rows and columns. Matrices in R are homogeneous i.e. they can hold a single type of data. Matrix elements are indexed by specifying the row and column index and the elements of a matrix can filled either by row or column. In the first section, we look at various ways of creating matrices in R.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;creating-matrix&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Creating Matrix&lt;/h2&gt;
&lt;p&gt;The easiest way to create a matrix in R is to use the &lt;code&gt;matrix()&lt;/code&gt; function. Let us look at its syntax:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;args(matrix)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## function (data = NA, nrow = 1, ncol = 1, byrow = FALSE, dimnames = NULL) 
## NULL&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now that we have understood the syntax of the &lt;code&gt;matrix()&lt;/code&gt; function, let us create a simple numeric matrix.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# matrix of 3 rows filled by columns
mat &amp;lt;- matrix(data = 1:9, nrow = 3, byrow = FALSE)
mat&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      [,1] [,2] [,3]
## [1,]    1    4    7
## [2,]    2    5    8
## [3,]    3    6    9&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the above example, we created a matrix of 3 rows where the data elements are filled by columns. We need to specify either the
number of &lt;code&gt;rows&lt;/code&gt; or &lt;code&gt;columns&lt;/code&gt; and R will automatically compute the other. The number of data elements should be equal to the product of the rows and columns, else R will return a warning.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;matrix(data = 1:9, nrow = 2, byrow = FALSE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning in matrix(data = 1:9, nrow = 2, byrow = FALSE): data length [9] is not a
## sub-multiple or multiple of the number of rows [2]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      [,1] [,2] [,3] [,4] [,5]
## [1,]    1    3    5    7    9
## [2,]    2    4    6    8    1&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;matrix(data = 1:10, nrow = 3, byrow = FALSE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning in matrix(data = 1:10, nrow = 3, byrow = FALSE): data length [10] is not
## a sub-multiple or multiple of the number of rows [3]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      [,1] [,2] [,3] [,4]
## [1,]    1    4    7   10
## [2,]    2    5    8    1
## [3,]    3    6    9    2&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can follow some general rules to avoid the mistakes made in the previous examples:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;if the number of elements is odd, both the number of rows and columns must be odd and their product should equal
the number of data elements&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;if the number of elements is even, either the number of rows or columns must be even. In some cases, both the rows and
columns must be even&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let us continue to explore the syntax of the &lt;code&gt;matrix()&lt;/code&gt; function.&lt;/p&gt;
&lt;div id=&#34;fill-data-by-row&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Fill Data by Row&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;matrix(data = 1:9, nrow = 3, byrow = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      [,1] [,2] [,3]
## [1,]    1    2    3
## [2,]    4    5    6
## [3,]    7    8    9&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;fill-data-by-column&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Fill Data by Column&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;matrix(data = 1:9, nrow = 3, byrow = FALSE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      [,1] [,2] [,3]
## [1,]    1    4    7
## [2,]    2    5    8
## [3,]    3    6    9&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;specify-rows&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Specify Rows&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;matrix(data = 1:10, nrow = 2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      [,1] [,2] [,3] [,4] [,5]
## [1,]    1    3    5    7    9
## [2,]    2    4    6    8   10&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;specify-columns&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Specify Columns&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;matrix(data = 1:10, ncol = 5)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      [,1] [,2] [,3] [,4] [,5]
## [1,]    1    3    5    7    9
## [2,]    2    4    6    8   10&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;row-column-names&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Row &amp;amp; Column Names&lt;/h2&gt;
&lt;p&gt;You can specify names for the rows and columns of a matrix. To do so, we need to use &lt;code&gt;list&lt;/code&gt;. Lists can contain other data structures such as vectors, matrices and even other lists. They are heterogeneous i.e. they can contain different data types. We will learn more about lists in a future post, for the time being let us learn how to create a basic list using the &lt;code&gt;list()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# character vector
first_name &amp;lt;-   c(&amp;quot;John&amp;quot;, &amp;quot;Jill&amp;quot;, &amp;quot;Jack&amp;quot;)

# numeric vector
age &amp;lt;- c(20, 24, 32)

# list 
details &amp;lt;- list(first_name, age)
details&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [[1]]
## [1] &amp;quot;John&amp;quot; &amp;quot;Jill&amp;quot; &amp;quot;Jack&amp;quot;
## 
## [[2]]
## [1] 20 24 32&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now that we know how to create a list, let us go ahead and create a matrix and name its rows and columns.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# row names
row_names &amp;lt;- c(&amp;#39;row_1&amp;#39;, &amp;#39;row_2&amp;#39;, &amp;#39;row_3&amp;#39;)

# column names
col_names &amp;lt;- c(&amp;#39;col_1&amp;#39;, &amp;#39;col_2&amp;#39;, &amp;#39;col_3&amp;#39;)

# matrix with row and column names
matrix(data = 1:9, nrow = 3, dimnames = list(row_names, col_names))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##       col_1 col_2 col_3
## row_1     1     4     7
## row_2     2     5     8
## row_3     3     6     9&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;matrix-dimension&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Matrix Dimension&lt;/h2&gt;
&lt;p&gt;Another useful function is &lt;code&gt;dim()&lt;/code&gt;. It can be used to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;check the dimension (rows and columns) of a matrix&lt;/li&gt;
&lt;li&gt;modify the dimension of a matrix&lt;/li&gt;
&lt;li&gt;coerce a vector to a matrix&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;check-dimension-of-a-matrix&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Check dimension of a matrix&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mat &amp;lt;- matrix(data = 1:9, nrow = 3, byrow = TRUE)
dim(mat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 3 3&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;modify-dimension-of-a-matrix&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Modify dimension of a matrix&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# sample matrix
mat &amp;lt;- matrix(data = 1:12, nrow = 3, byrow = TRUE)
dim(mat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 3 4&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# change the dimension to 4 x 3
dim(mat) &amp;lt;- c(4, 3)
dim(mat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 4 3&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;coerce-vector-to-matrix&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Coerce vector to matrix&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# numeric vector
vect1 &amp;lt;- 1:12
vect1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  1  2  3  4  5  6  7  8  9 10 11 12&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# coerce vect1 to a 4 x 3 matrix
dim(vect1) &amp;lt;- c(4, 3)
vect1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      [,1] [,2] [,3]
## [1,]    1    5    9
## [2,]    2    6   10
## [3,]    3    7   11
## [4,]    4    8   12&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Another way to coerce an R data structure to &lt;code&gt;matrix&lt;/code&gt; is to use the &lt;code&gt;as.matrix()&lt;/code&gt; function. Since the only other data structure we have learnt so far is the vector, we will coerce a vector into a matric using &lt;code&gt;as.matrix()&lt;/code&gt;. We will deal with the other data structures as and when we learn them.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# numeric vector
vect1 &amp;lt;- 1:12
vect1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  1  2  3  4  5  6  7  8  9 10 11 12&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# coerce vect1 to a matrix
as.matrix(vect1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##       [,1]
##  [1,]    1
##  [2,]    2
##  [3,]    3
##  [4,]    4
##  [5,]    5
##  [6,]    6
##  [7,]    7
##  [8,]    8
##  [9,]    9
## [10,]   10
## [11,]   11
## [12,]   12&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Regardless of the data type of the vector, all of them will be coerced to a matrix of dimension &lt;code&gt;n x 1&lt;/code&gt; i.e. they will all have only one column.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Vectors - Part 3</title>
      <link>https://blog.rsquaredacademy.com/vectors-part-3/</link>
      <pubDate>Mon, 03 Apr 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/vectors-part-3/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In the previous post, we learnt to perform simple operations on vector and handle missing values. In this post, we will learn to index/subset vectors.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;index-vectors&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Index Vectors&lt;/h2&gt;
&lt;p&gt;One of the most important steps in data analysis is selecting a subset of data from a bigger data set. Indexing helps in retrieving values individually or a set of values that meet a specific criteria. In this post, we look at various ways of indexing/subsetting vectors.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;index-operator&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Index Operator&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;[]&lt;/code&gt; is the index operator in R. We can use various expressions within &lt;code&gt;[]&lt;/code&gt; to subset data. In R, &lt;strong&gt;index positions begin at 1 and not 0&lt;/strong&gt;. To begin with, let us look at values in different index positions:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# random sample of 10 values
vect1 &amp;lt;- sample(10)
vect1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  5  7  2  8  9  6 10  4  1  3&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# return third element
vect1[3]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 2&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# return seventh element
vect1[7]    &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 10&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;out-of-range-index&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Out of range index&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# random sample of 10 values
vect1 &amp;lt;- sample(10)
vect1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  8  2  5  1 10  9  3  4  7  6&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# return value at index 0
vect1[0]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## integer(0)&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# length of the vector
length(vect1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 10&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# out of range index
vect1[11]   &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] NA&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the first case, we specified the index as 0 and in the second case we used the index 11, which is greater than the length of the vector. R returns an empty vector in the first case and &lt;code&gt;NA&lt;/code&gt; in the second case.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;negative-index&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Negative Index&lt;/h4&gt;
&lt;p&gt;Using a negative index will delete the value in the said index position. Unlike other languages, it will not index elements from the
end of the vector counting backwards. Let us look at an example to understand how negative index works in R:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# random sample of 10 values
vect1 &amp;lt;- sample(10)
vect1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  6  9  3  2 10  8  4  7  1  5&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# drop third element
vect1[-3]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  6  9  2 10  8  4  7  1  5&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# drop seventh element
vect1[-7]   &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  6  9  3  2 10  8  7  1  5&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;subset-multiple-elements&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Subset Multiple Elements&lt;/h2&gt;
&lt;p&gt;If we do not specify anything within &lt;code&gt;[]&lt;/code&gt;, all the elements in the vector will be returned. We can specify the index elements using any expression that generates a sequence of integers. Let us look at a few examples:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# random sample of 10 values
vect1 &amp;lt;- sample(10)
vect1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  2  8  1  9  7 10  5  4  3  6&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# return all elements
vect1[]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  2  8  1  9  7 10  5  4  3  6&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# return first 5 values
vect1[1:5]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 2 8 1 9 7&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# return all values from the 5th position
end &amp;lt;- length(vect1)
vect1[5:end]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  7 10  5  4  3  6&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you are using the colon to generate the index positions, you will have to specify both the starting and ending position, else, R will return an error.&lt;/p&gt;
&lt;p&gt;What if we want elements that are not in a sequence as we saw in the last example? In such cases, we have to create a vector using &lt;code&gt;c()&lt;/code&gt; and use it to extract elements from the original vector. Below is an example:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# random sample of 10 values
vect1 &amp;lt;- sample(10)
vect1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  7  4 10  3  9  8  5  1  2  6&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# extract 2nd, 5th and 7th element
select &amp;lt;- c(2, 5, 7)
vect1[select]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 4 9 5&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# extract elements in position 1 to 4, 6 and 9
select &amp;lt;- c(1:4, 6, 9)
vect1[select]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  7  4 10  3  8  2&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;subset-named-vectors&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Subset Named Vectors&lt;/h2&gt;
&lt;p&gt;Vectors can be subset using the name of the elements. &lt;strong&gt;When using name of elements for subsetting, ensure that the names are enclosed in single or double quotations&lt;/strong&gt;, else R will return an error. Let us look at a few examples:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vect1 &amp;lt;- c(score1 = 8, score2 = 6, score3 = 9)
vect1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## score1 score2 score3 
##      8      6      9&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# extract score2
vect1[&amp;#39;score2&amp;#39;]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## score2 
##      6&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# extract score1 and score3
vect1[c(&amp;#39;score1&amp;#39;, &amp;#39;score3&amp;#39;)]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## score1 score3 
##      8      9&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;subset-using-logical-values&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Subset using logical values&lt;/h2&gt;
&lt;p&gt;Logical values can be used to subset vectors. They are not very flexible but can be used for simple indexing. In all of the below examples, the logical vectors are recycled to match the length of the vector from which we subset data:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# random sample of 10 values
vect1 &amp;lt;- sample(10)
vect1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  8  1  4  5 10  9  3  6  2  7&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# returns all values
vect1[TRUE]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  8  1  4  5 10  9  3  6  2  7&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# empty vector
vect1[FALSE]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## integer(0)&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# values in odd positions
vect1[c(TRUE, FALSE)]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  8  4 10  3  2&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# values in even positions
vect1[c(FALSE, TRUE)]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1 5 9 6 7&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;subset-using-logical-expressions&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Subset using logical expressions&lt;/h2&gt;
&lt;p&gt;Logical expressions can be used to extract elements that meet specific criteria. This method is most flexible and useful as we can combine multiple conditions using relational and logical operators. Before we use logical expressions, let us spend some time understanding comparison and logical operators as we will be using them extensively hereafter.&lt;/p&gt;
&lt;div id=&#34;comparison-operators&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Comparison Operators&lt;/h4&gt;
&lt;p&gt;When you create an expression using a comparison operator, the output is always a logical value i.e. &lt;code&gt;TRUE&lt;/code&gt; or &lt;code&gt;FALSE&lt;/code&gt;. Let us see how we can use comparison operators to subset data:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# random sample of 10 values
vect1 &amp;lt;- sample(10)
vect1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  3  1  9 10  5  8  2  6  4  7&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# return elements greater than 5
vect1 &amp;gt; 5&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] FALSE FALSE  TRUE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vect1[vect1 &amp;gt; 5]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  9 10  8  6  7&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# return elements greater than or equal to 5
vect1 &amp;gt;= 5&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] FALSE FALSE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE FALSE  TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vect1[vect1 &amp;gt;= 5]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  9 10  5  8  6  7&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# return elements lesser than 5
vect1 &amp;lt; 5&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  TRUE  TRUE FALSE FALSE FALSE FALSE  TRUE FALSE  TRUE FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vect1[vect1 &amp;lt; 5]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 3 1 2 4&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# return elements lesser than or equal to 5
vect1 &amp;lt;= 5&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  TRUE  TRUE FALSE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vect1[vect1 &amp;lt;= 5]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 3 1 5 2 4&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# return elements equal to 5
vect1 == 5&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vect1[vect1 == 5]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 5&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# return elements not equal to 5
vect1 != 5&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vect1[vect1 != 5]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  3  1  9 10  8  2  6  4  7&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;logical-operators&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Logical Operators&lt;/h2&gt;
&lt;p&gt;Let us combine comparison and logical operators to create expressions and use them to subset vectors:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# random sample of 10 values
vect1 &amp;lt;- sample(10)
vect1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  3  2  9  7  5 10  4  8  6  1&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# return all elements less than 8 or divisible by 3
vect1[(vect1 &amp;lt; 8 | (vect1 %% 3 == 0))]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 3 2 9 7 5 4 6 1&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# return all elements less than 7 or divisible by 2
vect1[(vect1 &amp;lt; 7 | (vect1 %% 2 == 0))]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  3  2  5 10  4  8  6  1&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Vectors - Part 2</title>
      <link>https://blog.rsquaredacademy.com/vectors-part-2/</link>
      <pubDate>Wed, 29 Mar 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/vectors-part-2/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In the previous post, we learnt to create vectors of different data types. In this post, we will learn to&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;coerce different data types&lt;/li&gt;
&lt;li&gt;perform simple operations on vectors&lt;/li&gt;
&lt;li&gt;handle missing data&lt;/li&gt;
&lt;li&gt;index/subset vectors&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;naming-vector-elements&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Naming Vector Elements&lt;/h2&gt;
&lt;p&gt;It is possible to name the different elements of a vector. The advantage of naming vector elements is that we can later on use these names to access the elements. Use &lt;code&gt;names()&lt;/code&gt; to specify the names of a vector. You can specify the names while creating the vector or add them later.&lt;/p&gt;
&lt;div id=&#34;method-1-create-vector-and-add-names-later&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Method 1: Create vector and add names later&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# create vector and add names later
vect1 &amp;lt;- c(1, 2, 3)

# name the elements of the vector
names(vect1) &amp;lt;- c(&amp;quot;One&amp;quot;, &amp;quot;Two&amp;quot;, &amp;quot;Three&amp;quot;)

# call vect1
vect1
##   One   Two Three 
##     1     2     3&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;method-2-specify-names-while-creating-vector&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Method 2: Specify names while creating vector&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# specify names while creating vector
vect2 &amp;lt;- c(John = 1, Jack = 2, Jill = 3, Jovial = 4)

# call vect2
vect2
##   John   Jack   Jill Jovial 
##      1      2      3      4&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;vector-coercion&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Vector Coercion&lt;/h2&gt;
&lt;p&gt;Vectors are homogeneous i.e. all the elements of the vector must be of the same type. If we try to create a vector by combining different data types, the elements will be coerced to the most flexible type. The below table shows the order in which coercion occurs.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;character&lt;/code&gt; data type is the most flexible while &lt;code&gt;logical&lt;/code&gt; data type is the least flexible. If you try to combine any other data type with &lt;code&gt;character&lt;/code&gt;, all the elements will be coerced to type &lt;code&gt;character&lt;/code&gt;. In the absence of &lt;code&gt;character&lt;/code&gt; data, all elements will be coerced to &lt;code&gt;numeric&lt;/code&gt;. Finally, if the data does not include &lt;code&gt;character&lt;/code&gt; or &lt;code&gt;numeric&lt;/code&gt; types, all the elements will be coerced to &lt;code&gt;integer&lt;/code&gt; type.&lt;/p&gt;
&lt;div id=&#34;case-1-different-data-types&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Case 1: Different Data Types&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# vector of different data types
vect1 &amp;lt;- c(1, 1L, &amp;#39;one&amp;#39;, TRUE)

# call vect1
vect1
## [1] &amp;quot;1&amp;quot;    &amp;quot;1&amp;quot;    &amp;quot;one&amp;quot;  &amp;quot;TRUE&amp;quot;

# check data type
class(vect1)
## [1] &amp;quot;character&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;case-2-numeric-integer-and-logical&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Case 2: Numeric, Integer and Logical&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# vector of different data types
vect1 &amp;lt;- c(1, 1L, TRUE)

# call vect1
vect1
## [1] 1 1 1

# check data type
class(vect1)
## [1] &amp;quot;numeric&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;case-integer-and-logical&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Case : Integer and Logical&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# vector of different data types
vect1 &amp;lt;- c(1L, TRUE)

# call vect1
vect1
## [1] 1 1

# check data type
class(vect1)
## [1] &amp;quot;integer&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To summarize, below is the order in which coercion takes place:&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;vector-operations&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Vector Operations&lt;/h2&gt;
&lt;p&gt;In this section, we look at simple operations that can be performed on vectors in R. Remember that the nature of the operations depends upon the type of data. Below are a few examples:&lt;/p&gt;
&lt;div id=&#34;case-1-vectors-of-same-length&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Case 1: Vectors of same length&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# create two vectors
vect1 &amp;lt;- c(1, 3, 8, 4)
vect2 &amp;lt;- c(2, 7, 1, 9)

# addition
vect1 + vect2
## [1]  3 10  9 13

# subtraction
vect1 - vect2
## [1] -1 -4  7 -5

# multiplication
vect1 * vect2
## [1]  2 21  8 36

# division
vect1 / vect2
## [1] 0.5000000 0.4285714 8.0000000 0.4444444&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;case-2-vectors-of-different-length&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Case 2: Vectors of different length&lt;/h4&gt;
&lt;p&gt;In the previous case, the length i.e. the number of elements in the vectors were same. What happens if the length of the vectors are unequal? In such cases, the shorter vector is recycled to match the length of the longer vector. The below example should clear this concept:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# create two vectors
vect1 &amp;lt;- c(2, 7)
vect2 &amp;lt;- c(1, 8, 5, 2)

# addition
vect1 + vect2
## [1]  3 15  7  9

# subtraction
vect1 - vect2
## [1]  1 -1 -3  5

# multiplication
vect1 * vect2
## [1]  2 56 10 14

# division
vect1 / vect2
## [1] 2.000 0.875 0.400 3.500&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;missing-data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Missing Data&lt;/h2&gt;
&lt;p&gt;Missing data is a reality. No matter how careful you are in collecting data for your analysis, chances are always high that you end up with some missing data. In R missing values are represented by &lt;code&gt;NA&lt;/code&gt;. In this section, we will focus on the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;test for missing data&lt;/li&gt;
&lt;li&gt;remove missing data&lt;/li&gt;
&lt;li&gt;exclude missing data from analysis&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;detect-missing-data&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Detect missing data&lt;/h4&gt;
&lt;p&gt;We first create a vector with missing values. After that, we will use &lt;code&gt;is.na()&lt;/code&gt; to test whether the data contains missing values. &lt;code&gt;is.na()&lt;/code&gt; returns a logical vector equal to the length of the vector being tested. Another function that can be used for detecting missing values is &lt;code&gt;complete.cases()&lt;/code&gt;. Below is an example:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# vector with missing values
vect1 &amp;lt;- c(1, 3, NA, 5, 2)

# use is.na
is.na(vect1)
## [1] FALSE FALSE  TRUE FALSE FALSE

# use complete.cases
complete.cases(vect1)
## [1]  TRUE  TRUE FALSE  TRUE  TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;omit-missing-data&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Omit missing data&lt;/h4&gt;
&lt;p&gt;In the presensce of missing data, all computations in R will return &lt;code&gt;NA&lt;/code&gt;. To avoid this, we might want to remove the missing data before doing any computation. &lt;code&gt;na.omit()&lt;/code&gt; will remove all missing values from the data. Let us look at an example:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# vector with missing values
vect1 &amp;lt;- c(1, 3, NA, 5, 2)

# call vect1
vect1
## [1]  1  3 NA  5  2

# omit missing values
na.omit(vect1)
## [1] 1 3 5 2
## attr(,&amp;quot;na.action&amp;quot;)
## [1] 3
## attr(,&amp;quot;class&amp;quot;)
## [1] &amp;quot;omit&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;exclude-missing-data&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Exclude missing data&lt;/h4&gt;
&lt;p&gt;To exclude missing values from computations, use &lt;code&gt;na.rm&lt;/code&gt; and set it to &lt;code&gt;TRUE&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# vector with missing values
vect1 &amp;lt;- c(1, 3, NA, 5, 2)

# compute mean
mean(vect1)
## [1] NA

# compute mean by excluding missing value
mean(vect1, na.rm = TRUE)
## [1] 2.75&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Vectors - Part 1</title>
      <link>https://blog.rsquaredacademy.com/vectors-part-1/</link>
      <pubDate>Sat, 25 Mar 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/vectors-part-1/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In the previous post, we learnt about the basic data types in R. IN this post, we will:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;understand the concept of vectors&lt;/li&gt;
&lt;li&gt;learn to create vectors of different data types&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;vectors&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Vectors&lt;/h2&gt;
&lt;p&gt;Vector is the most basic data structure in R. It is a sequence of elements of the same data type. If the elements are of different data types, they will be coerced to a common type that can accommodate all the elements. Vectors are generally created using &lt;code&gt;c()&lt;/code&gt; (concatenate function), although depending on the data type of vector being created, other methods can be used.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;numeric-vector&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Numeric Vector&lt;/h2&gt;
&lt;p&gt;We will create a numeric vector using &lt;code&gt;c()&lt;/code&gt; but you can use any function that creates a sequence of numbers. After that we will use &lt;code&gt;is.vector()&lt;/code&gt; to check if it is a vector and &lt;code&gt;class&lt;/code&gt; to check the data type.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# create a numeric vector
num_vect &amp;lt;- c(1, 2, 3)

# display the vector
num_vect&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1 2 3&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# check if it is a vector
is.vector(num_vect)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# check data type
class(num_vect)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;numeric&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let us look at other ways to create a sequence of numbers. We leave it as an exercise to the reader to understand the functions using &lt;code&gt;help&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# using colon
vect1 &amp;lt;- 1:10
vect1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  1  2  3  4  5  6  7  8  9 10&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# using rep
vect2 &amp;lt;- rep(1, 5)
vect2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1 1 1 1 1&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# using seq
vect3 &amp;lt;- seq(10)
vect3&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  1  2  3  4  5  6  7  8  9 10&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;integer-vector&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Integer Vector&lt;/h2&gt;
&lt;p&gt;Creating an integer vector is similar to numeric vector except that we need to instruct R to treat the data as &lt;code&gt;integer&lt;/code&gt; and not &lt;code&gt;numeric&lt;/code&gt; or &lt;code&gt;double&lt;/code&gt;. We will use the same methods we used for creating numeric vectors. To specify that the data is of type &lt;code&gt;integer&lt;/code&gt;, we suffix the number with &lt;code&gt;L&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# integer vector
int_vect &amp;lt;- c(1L, 2L, 3L)
int_vect&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1 2 3&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# check data type
class(int_vect)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;integer&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# using colon
vect1 &amp;lt;- 1L:10L
vect1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  1  2  3  4  5  6  7  8  9 10&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# using rep
vect2 &amp;lt;- rep(1L, 5)
vect2&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1 1 1 1 1&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# using seq
vect3 &amp;lt;- seq(10L)
vect3&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  1  2  3  4  5  6  7  8  9 10&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;character-vector&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Character Vector&lt;/h2&gt;
&lt;p&gt;A character vector may contain a single character, a word or a group of words. The elements must be enclosed in single or double quotations.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# character vector
greetings &amp;lt;- c(&amp;quot;hello&amp;quot;, &amp;quot;good morning&amp;quot;)
greetings&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;hello&amp;quot;        &amp;quot;good morning&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# check data type
class(greetings)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;character&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;logical-vector&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Logical Vector&lt;/h2&gt;
&lt;p&gt;A vector of logical values will either contain &lt;code&gt;TRUE&lt;/code&gt; or &lt;code&gt;FALSE&lt;/code&gt; or both.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# logical vector
vect_logic &amp;lt;- c(TRUE, FALSE, TRUE, TRUE, FALSE)
vect_logic&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  TRUE FALSE  TRUE  TRUE FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# check data type
class(vect_logic)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;logical&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In fact, you can create an &lt;code&gt;integer&lt;/code&gt; vector and coerce it to type &lt;code&gt;logical&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# integer vector
int_vect &amp;lt;- rep(0L:1L, 3)
int_vect&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0 1 0 1 0 1&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# coerce to logical vector
log_vect &amp;lt;- as.logical(int_vect)
log_vect&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE  TRUE FALSE  TRUE FALSE  TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# check data type
class(log_vect)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;logical&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Beginners Guide to R Package Ecosystem</title>
      <link>https://blog.rsquaredacademy.com/beginners-guide-to-r-package-ecosystem/</link>
      <pubDate>Mon, 13 Mar 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/beginners-guide-to-r-package-ecosystem/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In the previous post, we learnt about getting help in R. In this post, we will learn about R packages. Packages are fundamental to R. There are approximately 15000 packages available on &lt;a href=&#34;https://cran.r-project.org/&#34;&gt;CRAN&lt;/a&gt; or the Comprehensive R Archive Network.&lt;/p&gt;
&lt;p&gt;Packages are available for different &lt;a href=&#34;https://cran.r-project.org/web/views/&#34;&gt;topics&lt;/a&gt;. You should always look for a package before writing code from scratch. In case you have written your own codes for a new analysis or topic, do share it with the R community by converting the code into a package. You can learn more about building R packages from &lt;a href=&#34;https://r-pkgs.had.co.nz/&#34;&gt;R Packages&lt;/a&gt;, a book written by &lt;a href=&#34;https://hadley.nz/&#34;&gt;Hadley Wickham&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In this post, we will learn to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;install R packages from
&lt;ul&gt;
&lt;li&gt;CRAN&lt;/li&gt;
&lt;li&gt;GitHub&lt;/li&gt;
&lt;li&gt;BitBucket&lt;/li&gt;
&lt;li&gt;Bioconductor&lt;/li&gt;
&lt;li&gt;rForge&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;install different versions of a package&lt;/li&gt;
&lt;li&gt;load, update &amp;amp; remove installed packages&lt;/li&gt;
&lt;li&gt;access package documentation&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;install-packages&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Install Packages&lt;/h2&gt;
&lt;div id=&#34;cran&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;CRAN&lt;/h4&gt;
&lt;p&gt;Packages from CRAN can be installed using &lt;code&gt;install.packages()&lt;/code&gt;. The name of the package must be enclosed in single or double quotes.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;install.packages(&amp;#39;ggplot2&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;github&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;GitHub&lt;/h4&gt;
&lt;p&gt;Some R packages are made available on &lt;a href=&#34;https://github.com/&#34;&gt;GitHub&lt;/a&gt; before releasing them on CRAN. Such packages can be installed using &lt;code&gt;install_github()&lt;/code&gt; from &lt;a href=&#34;https://cran.r-project.org/web/packages/devtools/index.html&#34;&gt;devtools&lt;/a&gt; or &lt;a href=&#34;https://cran.r-project.org/web/packages/remotes/index.html&#34;&gt;remotes&lt;/a&gt; package. You need tp specify the name of the repository and the package. For example, to download &lt;a href=&#34;https://ggplot2.tidyverse.org/&#34;&gt;ggplot2&lt;/a&gt; or &lt;a href=&#34;https://dplyr.tidyverse.org/&#34;&gt;dplyr&lt;/a&gt;, below is the code:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;devtools::install_github(&amp;quot;tidyverse/ggplot2&amp;quot;)
remotes::install_github(&amp;quot;tidyverse/dplyr&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;bitbucket&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;BitBucket&lt;/h4&gt;
&lt;p&gt;&lt;a href=&#34;https://bitbucket.org/&#34;&gt;Bitbucket&lt;/a&gt; is similar to GitHub. You can install packages from Bitbucket using &lt;code&gt;install_bitbucket()&lt;/code&gt; from devtools or remotes pacakge.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;devtools::install_bitbucket(&amp;quot;dannavarro/lsr-package&amp;quot;)
remotes::install_bitbucket(&amp;quot;dannavarro/lsr-package&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;bioconductor&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Bioconductor&lt;/h4&gt;
&lt;p&gt;&lt;a href=&#34;https://www.bioconductor.org/&#34;&gt;Bioconductor&lt;/a&gt; provides tools for analysis and comprehension of high throughput genomic data. Packages hosted on Bioconductor can be installed in multiple ways:&lt;/p&gt;
&lt;div id=&#34;devtools&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;devtools&lt;/h5&gt;
&lt;p&gt;Use &lt;code&gt;install_bioc()&lt;/code&gt; from devtools.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;install_bioc(&amp;quot;SummarizedExperiment&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;bioclite&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;biocLite&lt;/h5&gt;
&lt;p&gt;Use &lt;code&gt;biocLite()&lt;/code&gt; function.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;source(&amp;#39;http://bioconductor.org/biocLite.R&amp;#39;)
biocLite(&amp;#39;GenomicFeatures&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;rforge&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;rForge&lt;/h4&gt;
&lt;p&gt;Many R packages are hosted at &lt;a href=&#34;https://r-forge.r-project.org/&#34;&gt;R-Forge&lt;/a&gt;, a platform for development of R packages.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;install.packages(&amp;#39;quantstrat&amp;#39;, repos = &amp;#39;https://r-forge.r-project.org/&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;install-different-versions&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Install Different Versions&lt;/h2&gt;
&lt;p&gt;Now that we have learnt how to install packages, let us look at installing different versions of the same package.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;remotes::install_version(&amp;#39;dplyr&amp;#39;, version = 0.5.0)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you want to install the latest release from GitHub, append &lt;code&gt;@*release&lt;/code&gt; to the repository name. For example, to install the latest release of dplyr:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;remotes::install_github(&amp;#39;tidyverse/dplyr@*release&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;installed-packages&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Installed Packages&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;installed.packages()&lt;/code&gt;: view currently installed packages&lt;/li&gt;
&lt;li&gt;&lt;code&gt;library(&#39;package_name&#39;)&lt;/code&gt;: load packages&lt;/li&gt;
&lt;li&gt;&lt;code&gt;autoload(&#39;function_name&#39;, &#39;package_name&#39;)&lt;/code&gt;: load functions and data from packages only when called in the script&lt;/li&gt;
&lt;li&gt;&lt;code&gt;available.package()&lt;/code&gt;: packages available for installation&lt;/li&gt;
&lt;li&gt;&lt;code&gt;old.packages()&lt;/code&gt;: packages which have new versions available&lt;/li&gt;
&lt;li&gt;&lt;code&gt;new.packages()&lt;/code&gt;: packages already not installed&lt;/li&gt;
&lt;li&gt;&lt;code&gt;update.packages()&lt;/code&gt;: update packages which have new versions&lt;/li&gt;
&lt;li&gt;&lt;code&gt;remove.packages(&#39;package_name&#39;)&lt;/code&gt;: remove installed packages&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;library-paths&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Library Paths&lt;/h2&gt;
&lt;p&gt;Library is a directory that contains all installed packages. Usually there will be more than one R library in your systme. You can find the location of the libraries using &lt;code&gt;.libPaths()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;.libPaths()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;C:/Users/HP/Documents/R/win-library&amp;quot; &amp;quot;C:/Program Files/R/R-4.0.0/library&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can use &lt;code&gt;lib.loc&lt;/code&gt; when you want to install, load, update and remove packages from a particular library.&lt;/p&gt;
&lt;div id=&#34;install&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Install&lt;/h5&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;install.packages(&amp;#39;stringr&amp;#39;, lib.loc = &amp;quot;C:/Program Files/R/R-3.4.1/library&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;load&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Load&lt;/h5&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(lubridate, lib.loc = &amp;quot;C:/Program Files/R/R-3.4.1/library&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;update-packages&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Update Packages&lt;/h5&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;update.packages(lib.loc = &amp;quot;C:/Program Files/R/R-3.4.1/library&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;remove-packages&#34; class=&#34;section level5&#34;&gt;
&lt;h5&gt;Remove Packages&lt;/h5&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;remove.packages(lib.loc = &amp;quot;C:/Program Files/R/R-3.4.1/library&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Getting Help In R</title>
      <link>https://blog.rsquaredacademy.com/getting-help-in-r/</link>
      <pubDate>Wed, 01 Mar 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/getting-help-in-r/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In the previous post, we learnt about data types in R. In this post, we will learn about the different methods of getting help in R. Often we get stuck while doing some analysis as either we do not know the correct function to use or its syntax. It is important for anyone who is new to R to know the right place to look for help. There are two ways to look for help in R:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;built in help system&lt;/li&gt;
&lt;li&gt;online&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the first section, we will look at various ways to access the built in help system of R. In the second section, we will look at various online resources that can supplement the built in help system. Let us get started!&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;online-resources&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Online Resources&lt;/h2&gt;
&lt;div id=&#34;r-bloggers&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;R Bloggers&lt;/h3&gt;
&lt;p&gt;&lt;a href=&#34;https://www.r-bloggers.com/&#34;&gt;R Bloggers&lt;/a&gt; aggregates blogs written in english from across the globe. This is the first place you want to visit if you want help with R, data analysis, visualization and machine learning. There are blogs on a wide range of topics and the latest content is delivered to your inbox if you subscribe. If you are a blogger yourself, share it with th R community by adding your blog to R Bloggers.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;stack-overflow&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Stack Overflow&lt;/h3&gt;
&lt;p&gt;&lt;a href=&#34;https://stackoverflow.com/questions/tagged/r&#34;&gt;Stack Overflow&lt;/a&gt; is a great place to visit if you are having trouble with R code or packages. Chances are high that someone has already encountered the same or similar problem and you can use the answers given by R experts. In case you have encountered a new problem or issue, you can ask for help by providing a reproducible example of your analysis along with the R code. Use the &lt;a href=&#34;http://reprex.tidyverse.org/&#34;&gt;reprex&lt;/a&gt; package to create reproducible examples.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;twitter&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Twitter&lt;/h3&gt;
&lt;p&gt;The R community is very active on Twitter and there are lot of R experts who are willing to help those who are new to R. Use the hashtag &lt;a href=&#34;https://twitter.com/search?q=%23rstats&#34;&gt;#rstats&lt;/a&gt; if you are asking for help or guidance on Twitter.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;rstudio-community&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;RStudio Community&lt;/h3&gt;
&lt;p&gt;&lt;a href=&#34;https://community.rstudio.com/&#34;&gt;RStudio Community&lt;/a&gt; is similar to Stack Overflow. You can ask questions
related to RStudio, Shiny and tidyverse.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;rstudio&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;RStudio&lt;/h3&gt;
&lt;p&gt;&lt;a href=&#34;https://resources.rstudio.com/&#34;&gt;RStudio&lt;/a&gt; has very good resources including cheatsheets, webinars and blogs.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;reddit&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Reddit&lt;/h3&gt;
&lt;p&gt;&lt;a href=&#34;https://www.reddit.com/r/rstats/&#34;&gt;Reddit&lt;/a&gt; is another place where you can look for help. The discussions are moderated by R experts. There are subreddits for &lt;a href=&#34;https://www.reddit.com/r/rstats/&#34;&gt;Rstats&lt;/a&gt;, &lt;a href=&#34;https://www.reddit.com/r/Rlanguage/&#34;&gt;Rlanguage&lt;/a&gt;, &lt;a href=&#34;https://www.reddit.com/r/rshiny/&#34;&gt;Rstudio&lt;/a&gt; and &lt;a href=&#34;https://www.reddit.com/r/RStudio/&#34;&gt;Rshiny&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;r-weekly&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;R Weekly&lt;/h3&gt;
&lt;p&gt;Visit &lt;a href=&#34;https://rweekly.org/&#34;&gt;RWeekly&lt;/a&gt; to get regular updates about the R community. You can find information about new packages, blogs, conferences, workshops, tutorials and R jobs.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;r-user-groups&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;R User Groups&lt;/h3&gt;
&lt;p&gt;There are several R User Groups active across the globe. You can find the list &lt;a href=&#34;https://jumpingrivers.github.io/meetingsR/r-user-groups.html&#34;&gt;here&lt;/a&gt;. Join the local user group to meet, discuss and learn from other R enthusiasts and experts.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data-helpers&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Data Helpers&lt;/h3&gt;
&lt;p&gt;&lt;a href=&#34;http://www.datahelpers.org/&#34;&gt;Data Helpers&lt;/a&gt; is a list of data analysts, scientists and engineers willing to offer guidance put together by &lt;a href=&#34;https://twitter.com/AngeBassa/&#34;&gt;Angela Bassa&lt;/a&gt;. Visit the website to learn more about how you can approach for help and guidance.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;internal&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Internal&lt;/h2&gt;
&lt;p&gt;In this section, we will look at the following functions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;help.start()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;help()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;?&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;??&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;help.search()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;demo()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;example()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;library()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;vignette()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;browseVignettes()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;help.start&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;help.start&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;help.start()&lt;/code&gt; function opens the documetation page in your browser. Here you can find manuals, reference and other materials.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;help.start()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## starting httpd help server ... done&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## If nothing happens, you should open
## &amp;#39;http://127.0.0.1:24753/doc/html/index.html&amp;#39; yourself&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;help&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;help&lt;/h3&gt;
&lt;p&gt;Use &lt;code&gt;help()&lt;/code&gt; to access the documentation of functions and data sets. &lt;code&gt;?&lt;/code&gt; is a shortcut for &lt;code&gt;help()&lt;/code&gt; and returns the same information.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;help(plot)
?plot&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;help.search&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;help.search&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;help.search()&lt;/code&gt; will search all sources of documentation and return those that match the search string. &lt;code&gt;??&lt;/code&gt; is a shortcut for &lt;code&gt;help.search()&lt;/code&gt; and returns the same information.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;help.search(&amp;#39;regression&amp;#39;)
??regression&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;demo&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;demo&lt;/h3&gt;
&lt;p&gt;demo displays an interactive demonstration of certain topics provided in a R package. Typing &lt;code&gt;demo()&lt;/code&gt; in the console will list the demos available in all the R packages installed.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;demo()
demo(scoping)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## 
##  demo(scoping)
##  ---- ~~~~~~~
## 
## &amp;gt; ## Here is a little example which shows a fundamental difference between
## &amp;gt; ## R and S.  It is a little example from Abelson and Sussman which models
## &amp;gt; ## the way in which bank accounts work.    It shows how R functions can
## &amp;gt; ## encapsulate state information.
## &amp;gt; ##
## &amp;gt; ## When invoked, &amp;quot;open.account&amp;quot; defines and returns three functions
## &amp;gt; ## in a list.  Because the variable &amp;quot;total&amp;quot; exists in the environment
## &amp;gt; ## where these functions are defined they have access to its value.
## &amp;gt; ## This is even true when &amp;quot;open.account&amp;quot; has returned.  The only way
## &amp;gt; ## to access the value of &amp;quot;total&amp;quot; is through the accessor functions
## &amp;gt; ## withdraw, deposit and balance.  Separate accounts maintain their
## &amp;gt; ## own balances.
## &amp;gt; ##
## &amp;gt; ## This is a very nifty way of creating &amp;quot;closures&amp;quot; and a little thought
## &amp;gt; ## will show you that there are many ways of using this in statistics.
## &amp;gt; 
## &amp;gt; #  Copyright (C) 1997-8 The R Core Team
## &amp;gt; 
## &amp;gt; open.account &amp;lt;- function(total) {
## + 
## +     list(
## +     deposit = function(amount) {
## +         if(amount &amp;lt;= 0)
## +         stop(&amp;quot;Deposits must be positive!\n&amp;quot;)
## +         total &amp;lt;&amp;lt;- total + amount
## +         cat(amount,&amp;quot;deposited. Your balance is&amp;quot;, total, &amp;quot;\n\n&amp;quot;)
## +     },
## +     withdraw = function(amount) {
## +         if(amount &amp;gt; total)
## +         stop(&amp;quot;You don&amp;#39;t have that much money!\n&amp;quot;)
## +         total &amp;lt;&amp;lt;- total - amount
## +         cat(amount,&amp;quot;withdrawn.  Your balance is&amp;quot;, total, &amp;quot;\n\n&amp;quot;)
## +     },
## +     balance = function() {
## +         cat(&amp;quot;Your balance is&amp;quot;, total, &amp;quot;\n\n&amp;quot;)
## +     }
## +     )
## + }
## 
## &amp;gt; ross &amp;lt;- open.account(100)
## 
## &amp;gt; robert &amp;lt;- open.account(200)
## 
## &amp;gt; ross$withdraw(30)
## 30 withdrawn.  Your balance is 70 
## 
## 
## &amp;gt; ross$balance()
## Your balance is 70 
## 
## 
## &amp;gt; robert$balance()
## Your balance is 200 
## 
## 
## &amp;gt; ross$deposit(50)
## 50 deposited. Your balance is 120 
## 
## 
## &amp;gt; ross$balance()
## Your balance is 120 
## 
## 
## &amp;gt; try(ross$withdraw(500)) # no way..&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;example&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;example&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;example()&lt;/code&gt; displays examples of the specified topic if available.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;example(&amp;#39;mean&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## mean&amp;gt; x &amp;lt;- c(0:10, 50)
## 
## mean&amp;gt; xm &amp;lt;- mean(x)
## 
## mean&amp;gt; c(xm, mean(x, trim = 0.10))
## [1] 8.75 5.50&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;package-documentation&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Package Documentation&lt;/h2&gt;
&lt;div id=&#34;library&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;library&lt;/h3&gt;
&lt;p&gt;Access the documentation of a package using &lt;code&gt;help()&lt;/code&gt; inside &lt;code&gt;library()&lt;/code&gt;. The package need not be installed for accessing the documentation.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(help = &amp;#39;ggplot2&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;vignette&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;vignette&lt;/h3&gt;
&lt;p&gt;A vignette is a long form guide to a R package. You can access the vignettes available using &lt;code&gt;vignette()&lt;/code&gt;. It will display alist of vignettes available in installed packages.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vignette()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To access a specific vignette from a package, specify the name of the vignette and the package.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;vignette(&amp;#39;dplyr&amp;#39;, package = &amp;#39;dplyr&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;browsevignettes&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;browseVignettes&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;browseVignettes()&lt;/code&gt; is another way to access the vignettes in installed packages. It will list the vignettes in each package along with links to the web page and R code.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;browseVignettes()&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;rsitesearch&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;RsiteSearch&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;RsiteSearch()&lt;/code&gt; will search for a specified topics in help pages, vignettes and task views using the search engine at this &lt;a href=&#34;http://search.r-project.org/&#34;&gt;link&lt;/a&gt; and return the result in a browser.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;RSiteSearch(&amp;#39;glm&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## A search query has been submitted to http://search.r-project.org
## The results page should open in your browser shortly&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Data Types in R</title>
      <link>https://blog.rsquaredacademy.com/data-types-in-r/</link>
      <pubDate>Fri, 17 Feb 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/data-types-in-r/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In the previous post, we learnt how to create variables in R. In this post, we will learn about the following data types:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;numeric/double&lt;/li&gt;
&lt;li&gt;integer&lt;/li&gt;
&lt;li&gt;character&lt;/li&gt;
&lt;li&gt;logical&lt;/li&gt;
&lt;li&gt;date/time&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;numeric&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Numeric&lt;/h2&gt;
&lt;p&gt;In R, numbers are represented by the data type &lt;code&gt;numeric&lt;/code&gt;. We will first create a variable and assign it a value. Next we will learn a few methods of checking the type of the variable.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# create two variables
number1 &amp;lt;- 3.5
number2 &amp;lt;- 3

# check data type
class(number1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;numeric&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;class(number2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;numeric&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# check if data type is numeric
is.numeric(number1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;is.numeric(number2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you carefully observe, &lt;code&gt;integers&lt;/code&gt; are also treated as &lt;code&gt;numeric/double&lt;/code&gt;. We will learn to create integers in a while. In the meanwhile, we have introduced two new funtions in the above example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;class()&lt;/code&gt;: returns the &lt;code&gt;class&lt;/code&gt; or &lt;code&gt;type&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;is.numeric()&lt;/code&gt;: tests whether the variable is of type &lt;code&gt;numeric&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;integer&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Integer&lt;/h2&gt;
&lt;p&gt;Unless specified otherwise, integers are treated as &lt;code&gt;numeric&lt;/code&gt; or &lt;code&gt;double&lt;/code&gt;. In this section, we will learn to create variables of the type &lt;code&gt;integer&lt;/code&gt; and to convert other data types to &lt;code&gt;integer&lt;/code&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;create a variable &lt;code&gt;number1&lt;/code&gt; and assign it the value &lt;code&gt;3&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;check the data type of &lt;code&gt;number1&lt;/code&gt; using &lt;code&gt;class&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;create a second variable &lt;code&gt;number2&lt;/code&gt; using &lt;code&gt;as.integer&lt;/code&gt; and assign it the value &lt;code&gt;3&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;check the data type of &lt;code&gt;number2&lt;/code&gt; using &lt;code&gt;class&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;finally use &lt;code&gt;is.integer&lt;/code&gt; to check the data type of both &lt;code&gt;number1&lt;/code&gt; and &lt;code&gt;number2&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# create a variable and assign it an integer value
number1 &amp;lt;- 3

# create another variable using as.integer
number2 &amp;lt;- as.integer(3)

# check the data type
class(number1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;numeric&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;class(number2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;integer&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# use is.integer to check data type
is.integer(number1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;is.integer(number2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;character&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Character&lt;/h2&gt;
&lt;p&gt;Letters, words and group of words are represented by the data type &lt;code&gt;character&lt;/code&gt;. All data of type &lt;code&gt;character&lt;/code&gt; must be enclosed in single or double quotation marks. In fact any value enclosed in quotes will be treated as &lt;code&gt;character&lt;/code&gt;. Let us create two variables to store the first and last name of a some random guy.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# first name
first_name &amp;lt;- &amp;quot;jovial&amp;quot;

# last name
last_name &amp;lt;- &amp;#39;mann&amp;#39;

# check data type
class(first_name)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;character&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;class(last_name)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;character&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# use is.charactert to check data type
is.character(first_name)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;is.character(last_name)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can coerce any data type to &lt;code&gt;character&lt;/code&gt; using &lt;code&gt;as.character()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# create variable of different data types
age &amp;lt;- as.integer(30) # integer
score &amp;lt;- 9.8          # numeric/double
opt_course &amp;lt;- TRUE    # logical
today &amp;lt;- Sys.time()   # date time

as.character(age) &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;30&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;as.character(score)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;9.8&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;as.character(opt_course)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;TRUE&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;as.character(today)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;2020-06-10 18:20:48&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;logical&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Logical&lt;/h2&gt;
&lt;p&gt;Logical data types take only 2 values. Either &lt;code&gt;TRUE&lt;/code&gt; or &lt;code&gt;FALSE&lt;/code&gt;. Sich data types are created when we compare two objects in R using
comparison or logical operators.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;create two variables &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;assign them the values &lt;code&gt;TRUE&lt;/code&gt; and &lt;code&gt;FALSE&lt;/code&gt; respectively&lt;/li&gt;
&lt;li&gt;use &lt;code&gt;is.logical&lt;/code&gt; to check data type&lt;/li&gt;
&lt;li&gt;use &lt;code&gt;as.logical&lt;/code&gt; to coerce other data types to &lt;code&gt;logical&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# create variables x and y
x &amp;lt;- TRUE
y &amp;lt;- FALSE

# check data type
class(x)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;logical&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;is.logical(y)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The outcome of comparison operators is always &lt;code&gt;logical&lt;/code&gt;. In the below example, we compare two numbers to see the outcome.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# create two numeric variables
x &amp;lt;- 3
y &amp;lt;- 4

# compare x and y
x &amp;gt; y&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x &amp;lt; y&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# store the result
z &amp;lt;- x &amp;gt; y
class(z)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;logical&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;TRUE&lt;/code&gt; is represented by all numbers except &lt;code&gt;0&lt;/code&gt;. &lt;code&gt;FALSE&lt;/code&gt; is represented only by &lt;code&gt;0&lt;/code&gt; and no other numbers.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# TRUE and FALSE are represented by 1 and 0
as.logical(1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;as.logical(0)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# using numbers
as.numeric(TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;as.numeric(FALSE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# using different numbers
as.logical(-2, -1.5, -1, 0, 1, 2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Use &lt;code&gt;as.logical()&lt;/code&gt; to coerce other data types to &lt;code&gt;logical&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# create variable of different data types
age &amp;lt;- as.integer(30) # integer
score &amp;lt;- 9.8          # numeric/double
opt_course &amp;lt;- TRUE    # logical
today &amp;lt;- Sys.time()   # date time

as.logical(age) &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;as.logical(score)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;as.logical(opt_course)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;as.logical(today)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;summary&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Summary&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;numeric, integer, character, logical and date are the basic data types in R&lt;/li&gt;
&lt;li&gt;&lt;code&gt;class()&lt;/code&gt; or &lt;code&gt;typeof()&lt;/code&gt; return the data type&lt;/li&gt;
&lt;li&gt;&lt;code&gt;is.data_type&lt;/code&gt; checks whether the data is of the specified data type
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;is.numeric()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;is.integer()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;is.character()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;is.logical()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;is.date()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;as.data_type&lt;/code&gt; will coerce objects to the specified data type
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;as.numeric()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;as.integer()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;as.character()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;as.logical()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;as.date()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Variables in R</title>
      <link>https://blog.rsquaredacademy.com/variables-in-r/</link>
      <pubDate>Sun, 05 Feb 2017 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/variables-in-r/</guid>
      <description>&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In the previous post, we learnt to install RStudio. In this post, we will learn about variables and data types. You can skip this post, if you have prior experience in any other programming language.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;what-is-a-variable&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;What is a variable?&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;variables are the fundamental elements of any programming language&lt;/li&gt;
&lt;li&gt;they are used to represent values that are likely to change&lt;/li&gt;
&lt;li&gt;they reference memory locations that store information/data&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let us use a simple case study to understand variables. Suppose you are computing the area of a circle whose radius is 3. In R, you can do this straight away as shown below:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;3.14 * 3 * 3&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 28.26&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But you cannot reuse the radius or the area computed in any other analysis or computation. Let us see how variables can change the above scenario and help us in reusing values and computations.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;creating-variables&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Creating Variables&lt;/h2&gt;
&lt;p&gt;A variable consists of 3 components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;variable name&lt;/li&gt;
&lt;li&gt;assignment operator&lt;/li&gt;
&lt;li&gt;variable value&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We can store the value of the radius by creating a variable and assigning it the value. In this case, we create a variable
called &lt;code&gt;radius&lt;/code&gt; and assign it the value &lt;code&gt;3&lt;/code&gt; using the assignment operator &lt;code&gt;&amp;lt;-&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;radius &amp;lt;- 3
radius&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now that we have learnt to create variables, let us see how we can use them for other computations. For our case study,
we will use the &lt;code&gt;radius&lt;/code&gt; variable to compute the area of a circle.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;using-variables&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Using Variables&lt;/h2&gt;
&lt;p&gt;We will create two variables, &lt;code&gt;radius&lt;/code&gt; and &lt;code&gt;pi&lt;/code&gt;, and use them to compute the area of a circle and store it in another variable &lt;code&gt;area&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# assign value 3 to variable radius
radius &amp;lt;- 3

# assign value 3.14 to variable pi
pi &amp;lt;- 3.14

# compute area of circle
area &amp;lt;- pi * radius * radius

# call radius
radius&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 3&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# call area 
area&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 28.26&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;components-of-a-variable&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Components of a Variable&lt;/h2&gt;
&lt;center&gt;
&lt;img src = &#34;/post/components.png&#34; width = &#34;800&#34; height = &#34;600&#34;&gt;
&lt;/center&gt;
&lt;/div&gt;
&lt;div id=&#34;naming-conventions&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Naming Conventions&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Name must begin with a letter. Do not use numbers, dollar sign (&lt;code&gt;$&lt;/code&gt;) or underscore (&lt;code&gt;_&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;The name can contain numbers or underscore. Do not use dash (&lt;code&gt;-&lt;/code&gt;) or period (&lt;code&gt;.&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Do not use the names of keywords and avoid using the names of built in functions.&lt;/li&gt;
&lt;li&gt;Variables are case sensitive; &lt;code&gt;average&lt;/code&gt; and &lt;code&gt;Average&lt;/code&gt; would be different variables.&lt;/li&gt;
&lt;li&gt;Use names that are descriptive. Generally, variable names should be nouns.&lt;/li&gt;
&lt;li&gt;If the name is made of more than one word, use underscore to separate the words.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;recap..&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Recap..&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Variables are the building blocks of a programming language&lt;/li&gt;
&lt;li&gt;Variables reference memory locations that store information/data&lt;/li&gt;
&lt;li&gt;An assignment operator &lt;code&gt;&amp;lt;-&lt;/code&gt; assigns values to a variable&lt;/li&gt;
&lt;li&gt;A variable has the following components:
&lt;ul&gt;
&lt;li&gt;name&lt;/li&gt;
&lt;li&gt;memory address&lt;/li&gt;
&lt;li&gt;value&lt;/li&gt;
&lt;li&gt;data type&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Certain rules must be followed while naming variables&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title></title>
      <link>https://blog.rsquaredacademy.com/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/</guid>
      <description>

&lt;h1 id=&#34;news&#34;&gt;news&lt;/h1&gt;
</description>
    </item>
    
    <item>
      <title></title>
      <link>https://blog.rsquaredacademy.com/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/</guid>
      <description>

&lt;h1 id=&#34;readme&#34;&gt;readme&lt;/h1&gt;
</description>
    </item>
    
    <item>
      <title></title>
      <link>https://blog.rsquaredacademy.com/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/</guid>
      <description></description>
    </item>
    
    <item>
      <title></title>
      <link>https://blog.rsquaredacademy.com/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/</guid>
      <description></description>
    </item>
    
    <item>
      <title></title>
      <link>https://blog.rsquaredacademy.com/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/</guid>
      <description></description>
    </item>
    
    <item>
      <title></title>
      <link>https://blog.rsquaredacademy.com/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/</guid>
      <description></description>
    </item>
    
    <item>
      <title></title>
      <link>https://blog.rsquaredacademy.com/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/</guid>
      <description></description>
    </item>
    
    <item>
      <title></title>
      <link>https://blog.rsquaredacademy.com/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/</guid>
      <description></description>
    </item>
    
    <item>
      <title></title>
      <link>https://blog.rsquaredacademy.com/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/</guid>
      <description></description>
    </item>
    
    <item>
      <title></title>
      <link>https://blog.rsquaredacademy.com/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/</guid>
      <description></description>
    </item>
    
    <item>
      <title></title>
      <link>https://blog.rsquaredacademy.com/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/</guid>
      <description></description>
    </item>
    
    <item>
      <title></title>
      <link>https://blog.rsquaredacademy.com/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/</guid>
      <description></description>
    </item>
    
    <item>
      <title>Untitled</title>
      <link>https://blog.rsquaredacademy.com/untitled/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>https://blog.rsquaredacademy.com/untitled/</guid>
      <description>&lt;pre class=&#34;sh&#34;&gt;&lt;code&gt;ls&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## analysis.R
## bash.R
## bash.Rmd
## bash.sh
## imports_blorr.txt
## imports_olsrr.txt
## lorem-ipsum.txt
## main_project.zip
## myfiles
## mypackage
## myproject
## myproject1
## myproject2
## myproject3
## myproject4
## package_names.txt
## pkg_names.txt
## r
## release_names.tar
## release_names.tar.gz
## release_names.txt
## release_names_18.txt
## release_names_19.txt
## sept_15.csv.gz
## urls.txt
## zip_example.zip&lt;/code&gt;&lt;/pre&gt;
</description>
    </item>
    
  </channel>
</rss>