{"id":799,"date":"2026-09-08T11:58:10","date_gmt":"2026-09-08T16:58:10","guid":{"rendered":"https:\/\/sts.doit.wisc.edu\/training-materials\/?post_type=manual&#038;p=799"},"modified":"2026-09-08T12:07:31","modified_gmt":"2026-09-08T17:07:31","slug":"r2-data-transformation-mastery-from-dplyr-to-ggplot-in-r","status":"publish","type":"manual","link":"https:\/\/sts.doit.wisc.edu\/training-materials\/manual\/r2-data-transformation-mastery-from-dplyr-to-ggplot-in-r\/","title":{"rendered":"R2: Data Transformation Mastery: From dplyr to ggplot in R"},"content":{"rendered":"\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img decoding=\"async\" src=\"https:\/\/sts.doit.wisc.edu\/training-materials\/wp-content\/uploads\/2025\/09\/sts-icon-notext.png\" alt=\"The STS logo of a cybernetically enhanced brain. Serious sci-fi.\" style=\"width:395px;height:auto\"\/><\/figure>\n\n\n\n<section class=\"wp-block-sts-block-sts-custom-sections\">\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">When using R and RStudio you&#8217;ll find yourself using imported packages very frequently. There are so many <strong>shortcuts and easy tricks<\/strong> that have been developed and put into packages for our use, it&#8217;d be a waste not to utilize them. The most notable package is called <strong>tidyverse<\/strong>. Tidyverse is a sort of compilation of all of the most useful packages for &#8220;tidying&#8221; data. While there are many useful packages contained in the tidyverse, today we will be dipping our feet into two packages exclusively: <strong>dplyr<\/strong> and <strong>ggplot<\/strong>. These are also two of the most frequently used packages within statistics courses here at UW Madison, so they&#8217;re great to be somewhat familiar with.<\/p>\n<\/section>\n\n\n\n<section class=\"wp-block-sts-block-sts-custom-sections\">\n<h2 class=\"wp-block-heading\">Installing R Packages<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Installing &#8216;tidyverse&#8217;<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To get started we&#8217;re going to run a couple of lines of code to install the tidyverse packages and load them into your RStudio.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First write <strong>install.packages(&#8220;tidyverse&#8221;)<\/strong> and hit <code class=\"\" data-line=\"\">Enter<\/code>\/<code class=\"\" data-line=\"\">Return<\/code>. You&#8217;ll have to run the first line and wait a second until it&#8217;s finished installing before you run the next line to access tidyverse.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then write <strong>library(tidyverse)<\/strong> and hit <code class=\"\" data-line=\"\">Enter<\/code>\/<code class=\"\" data-line=\"\">Return<\/code><\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-1\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;install.packages(&quot;tidyverse&quot;)\nlibrary(tidyverse)&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Installing &#8216;nycflights13&#8217;<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Before we can go through the basic functions of dplyr within the tidyverse package, we will need to load in a dataframe for us to test our functions on. For this workshop, we will download the dataframe &#8220;nycflights13&#8221;.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First write <strong>install.packages(&#8220;nycflights13&#8221;)<\/strong> and press <code class=\"\" data-line=\"\">Enter<\/code>\/<code class=\"\" data-line=\"\">Return<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then write <strong>library(nycflights13)<\/strong> and press <code class=\"\" data-line=\"\">Enter<\/code>\/<code class=\"\" data-line=\"\">Return<\/code><\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-2\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;install.packages(&quot;nycflights13&quot;)\nlibrary(nycflights13)&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">After running this code we should have access to the <strong>flights<\/strong> dataframe. Go ahead and just assign <strong>flights<\/strong> to a variable so we can open the dataframe and see what kind of data we have. The following code will assign the flights dataframe in the package we just installed into a dataframe we can use.<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-3\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;flights = flights&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Now we should be able to click on our dataframe in our environment to take a look at it. We have day, month, and year variables, variables denoting air travel time, departure delay time, arrival delay time, etc. It&#8217;s a very large dataframe. Obviously there is tons of information we can siphon from this, however just looking through this large dataframe as it stands is time consuming and inefficient. Thus we use our dplyr functions to help us get to what we want out of our dataframe.<\/p>\n<\/section>\n\n\n\n<section class=\"wp-block-sts-block-sts-custom-sections\">\n<h2 class=\"wp-block-heading\">DPLYR<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Once we&#8217;ve installed our packages, we can access any and all functions that exist within them. So without further ado, let&#8217;s start by exploring some of the features of dplyr!<\/p>\n\n\n\n<div class=\"wp-block-group sts-callout-goodtoknow has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 class=\"wp-block-heading\">Dplyr<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Dplyr gives us tools necessary to manipulate any dataframe in almost any way imaginable with very little hassle.<\/p>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\">filter()<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The first function we&#8217;ll be exploring is the <strong>filter()<\/strong> function.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When should we use <strong>filter()<\/strong>?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Take a look at the <strong>nycflights13<\/strong> dataframe we&#8217;ve loaded in. With so much data there is a huge variety of observations we can analyze, however if we want to more accurately analyze certain specific observations, sifting through the entire dataframe will only be a nuisance. This is why we filter our data.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>filter()<\/strong> gives you a subset of your dataframe specific to certain valued observations.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The notation is:<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-4\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;filter(dataframe, observation == value, ... )&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Our first input is just the dataframe we want to filter, you&#8217;ll notice the first input remains the same for all of our DPLYR functions. The following inputs are what we want our new dataframe to filter.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This may not make a lot of sense right now, so let&#8217;s work through some examples to see how <strong>filter()<\/strong> works.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Run the following code example:<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-5\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;filtered.flights = filter(flights, month == 1, day == 1)&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">This line of code will filter our original flights data frame into a smaller dataset only containing observations occurring on January 1st and assign it to a new variable, filtered.flights.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">View the flights data frame and compare to our new filtered.flights dataframe we&#8217;ve just created. You should be able to see clearly how the <strong>filter()<\/strong> function altered our dataframe.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Some more important details:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Make sure to use <strong>==<\/strong> instead of <strong>=<\/strong>, as using just <strong>=<\/strong> will give you an error. Also note you can use <strong>|<\/strong> (or) and <strong>&amp;<\/strong> (and) when using <strong>filter()<\/strong>, here&#8217;s an example:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Run the following code example:<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-6\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;filtered.flights2 = filter(flights, month == 1 | month == 2)&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">We&#8217;re using our &#8220;or&#8221; operator in this example. How would you describe this new dataframe we&#8217;ve filtered?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you said that this line of code will return a dataframe specifically concerning observations occurring in January or February, you&#8217;d be correct!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When filtering we can also use any comparison operators, such as <strong>&lt;<\/strong>, <strong>&gt;<\/strong>, <strong>&lt;=<\/strong>, and <strong>&gt;=<\/strong> to give us more flexibility with exactly what we want to filter!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Run this code example to use our comparison operators:<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-7\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;filtered.flights3 = filter(flights, month &lt;= 3, day == 1)&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">This function will give us our flights dataframe exclusively looking at the first day of each of the first 3 months. We are taking all months less than or equal to 3, then we specify we want to look at the first day.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">arrange()<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong>arrange()<\/strong> function works very similarly to the <strong>filter()<\/strong> function.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Rather than create a new dataframe that serves as a subset, arrange() simply rearranges rows within our dataframe into a specified order.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The notation is:<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-8\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;arrange(dataframe, observation, ...)&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">As we did with <strong>filter()<\/strong> we will lead with our dataframe, and our next input is the observation, or the column, that we wish to arrange.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, the following code will arrange the departure delay column in ascending order:<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-9\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;arranged.flights = arrange(flights, dep_delay)&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Feel free to compare our new arranged.flights dataframe to the nycflights dataframe and observe the difference.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img decoding=\"async\" src=\"\/home\/yashwanth\/Downloads\/STS\/images\/r2-000.png\" alt=\"RStudio dataframe view of arranged.flights \u2014 the nycflights13 flights dataset sorted by dep_delay in ascending order, showing the 22 flights with the earliest departures relative to schedule. The dep_delay column is highlighted, with values ranging from \u221243 to \u221222 minutes. Columns include year, month, day, dep_time, sched_dep_time, dep_delay, arr_time, sched_arr_time, arr_delay, carrier, flight, and tailnum.\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">While our DPLYR functions are very useful, we can combine them with other functions to make them even more versatile!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">One very useful function to use alongside <strong>arrange()<\/strong> is the <strong>desc()<\/strong> function.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>desc()<\/strong> will simply rearrange an observation into descending order. So while normally putting an observation into the <strong>arrange()<\/strong> function will rearrange into an ascending order, if you wrap the observation in the <strong>desc()<\/strong> function it will output in descending order instead.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, let&#8217;s run the following code:<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-10\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;arranged.flights3 = arrange(flights, desc(dep_delay))&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">This is the same code we used earlier, however we put <strong>desc()<\/strong> around our dep_delay observation, therefore this will rearrange our data frame in the same way, just in reverse order, starting with the largest departure delay in our dataframe.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img decoding=\"async\" src=\"\/home\/yashwanth\/Downloads\/STS\/images\/r2-001.png\" alt=\"RStudio dataframe view of arranged.flights3 \u2014 the flights dataset sorted by dep_delay in descending order, showing the 22 flights with the longest departure delays. The dep_delay column is highlighted, with the top delay being 1,301 minutes (over 21 hours). Columns include year, month, day, dep_time, sched_dep_time, dep_delay, arr_time, sched_arr_time, arr_delay, carrier, flight, and tailnum.\" style=\"width:600px;height:auto\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">select()<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Our <strong>select()<\/strong> function allows us to look at a very specific subset of variables within a data frame. Some data frames can have thousands of variables, so the ability to pick only a select few we&#8217;re interested in is very valuable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The notation is:<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-11\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;select(dataframe, variable_of_interest, ...)&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Once again, our first input is the dataframe we wish to select from. We follow this with whichever variable\/column we want to select from our dataframe.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s start by running the following code.<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-12\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;selected.flights = select(flights, dep_time, sched_dep_time)&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Here we are choosing to only select the departing time, and the scheduled departure time. If we needed to do specific analysis on the difference between these two variables it would be very useful for us to isolate them and look at this new subset. Take a look at our new dataframe selected.flights and see how our code altered the original dataframe.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img decoding=\"async\" src=\"\/home\/yashwanth\/Downloads\/STS\/images\/r2-002.png\" alt=\"RStudio dataframe view of selected.flights \u2014 a two-column subset of the flights dataset containing only dep_time and sched_dep_time. The first 20 rows are shown, with departure times starting at 517 and scheduled departure times starting at 515.\" style=\"width:600px;height:auto\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">A very neat function you can use in conjunction with this function is wrapping <strong>-()<\/strong> around a variable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This will select the entire dataframe EXCEPT for the variable(s) you included in the <strong>-()<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To try it out in a line of code, run this:<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-13\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;selected.flights2 = select(flights, -(year))&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">This will give us our normal flights dataframe, however the year variable will no longer be there. Although it may not be that useful in this circumstance, it&#8217;s just another way to manipulate your data that is useful to keep in mind.<\/p>\n<\/section>\n\n\n\n<section class=\"wp-block-sts-block-sts-custom-sections\">\n<h2 class=\"wp-block-heading has-text-align-center\">DPLYR Cont&#8217;d<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">mutate()<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>mutate()<\/strong> is an extremely useful function that allows us to add new variables that are functions of existing variables. This is extremely useful when a specific variable you want to research isn&#8217;t already in your dataframe.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The notation is:<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-14\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;mutate(data, new_variable = function_of_old_variables, ...)&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">This function will be easiest explained with an example, run the following code.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First I&#8217;m going to use <strong>select()<\/strong> to make an easier dataframe for us to visualize.<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-15\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;selected.flights.m = select(flights, year, month, day, distance, air_time)&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">This dataframe contains only the year, month, day, distance, and air_time variables. Now I&#8217;m going to use our <strong>mutate()<\/strong> function to create a new variable, hours.<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-16\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;mutated.flights = mutate(selected.flights.m, hours = air_time \/ 60)&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">When we look at our newly mutated dataframe, we now have a new variable, which is just our air_time put into the unit of hours by dividing the entire column by 60.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img decoding=\"async\" src=\"\/home\/yashwanth\/Downloads\/STS\/images\/r2-003.png\" alt=\"RStudio dataframe view of mutated.flights \u2014 a six-column dataframe showing year, month, day, distance, air_time, and a newly created hours column (air_time divided by 60). The hours column is circled in red. All 21 rows shown are from January 1st, 2013, with hours values ranging from 0.73 to 6.02.\" style=\"width:600px;height:auto\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">With this new variable we can make another new variable, speed_mph. Let&#8217;s mutate again, run the following code:<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-17\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;mutated.flights2 = mutate(mutated.flights, speed_mph = distance \/ hours)&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">This new line of code takes our distance column of observations and our newly created hours column of observations and divides them to give us a new variable, the speed of each observation, which can be incredibly useful. We can use this new variable in any further analysis or plotting we might want to put this dataframe through.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img decoding=\"async\" src=\"\/home\/yashwanth\/Downloads\/STS\/images\/r2-004.png\" alt=\"RStudio dataframe view of mutated.flights2 \u2014 a seven-column dataframe adding speed_mph (distance divided by hours) to mutated.flights. The speed_mph column is circled in red. All 21 rows are from January 1st, 2013, with speed values ranging from approximately 255 to 517 mph.\" style=\"width:600px;height:auto\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">transmute()<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Our next function, <strong>transmute()<\/strong> is essentially a combination of <strong>select()<\/strong> and <strong>mutate()<\/strong>. You use this function the same way you would use <strong>mutate()<\/strong>, to create new variables, however, rather than adding the new variables to the previous dataframe, this creates a new dataframe only containing your newly defined variables.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>transmute()<\/strong> actually allows us to do what we did in our last example in fewer steps.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s start by running this code:<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-18\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;transmuted.flights = transmute(flights, year, month, day, distance,\nair_time, hours = air_time \/ 60)&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">This code quite literally combines the first two lines of code we ran in our <strong>mutate()<\/strong> examples. We begin by inputting all of our variables we&#8217;ll be &#8220;selecting&#8221; for our new dataframe, and at the end we add a new variable \u2014 a mutated variable \u2014 the same one we created in our last example. Compare this transmuted.flights dataframe to our mutated.flights dataframe, and spot the similarities.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">summarise()<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong>summarise()<\/strong> function is probably the most complex of the basic DPLYR commands. It collapses an entire dataframe into a single row.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This single row summarization is based on one specific function of interest.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As we are trying to summarise, we need to provide a function to summarise our data with. For this example we will be summarising using the mean, which is the most common use with the summarise() function.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s start with an example to show what I mean by summarising the mean:<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-19\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;summarised.flights = summarise(flights, mean(arr_delay, na.rm = TRUE))&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Now what this code is doing is taking our column of arrival delays, and collapsing the entire column into one mean value. This will literally result in a new column containing only one value \u2014 our mean. When manipulating dataframes, this isn&#8217;t useful at all. If we wanted to find the mean of a column we could just use the <strong>mean()<\/strong> function by itself. Thankfully, once again we have some other functions we can use in conjunction with our main <strong>summarise()<\/strong> function, that will greatly expand its utility.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This magical function that allows <strong>summarise()<\/strong> to shine is the <strong>group_by()<\/strong> function.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong>group_by<\/strong> function redefines a table so that all operations done are in respect to the &#8220;groups&#8221; created.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It&#8217;s easiest explained by an example, run the following code:<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-20\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;grouped.flights = group_by(flights, year, month, day)&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">This function will create our new dataframe which is grouped based on the date (year, month, day). Now we will run the same summarise function we used earlier, however on our grouped dataframe:<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-21\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;summarised.flights2 = summarise(grouped.flights, mean(arr_delay,\nna.rm = TRUE))&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Because our dataframe is now grouped, instead of <strong>summarise()<\/strong> collapsing our arrival delay into a single row, it collapses it into the groups we&#8217;ve specified. Our new dataframe will show us the mean arrival delay for each respective date (year, month, day).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s take a look at our new summarised.flights2 dataframe to fully understand what our function did.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img decoding=\"async\" src=\"\/home\/yashwanth\/Downloads\/STS\/images\/r2-005.png\" alt=\"RStudio dataframe view of summarised.flights2 \u2014 a four-column dataframe showing year, month, day, and the mean arrival delay per date. The first 20 rows cover January 1\u201320, 2013. Mean arrival delay values range from approximately \u221213.0 minutes (January 12th) to +34.2 minutes (January 16th).\" style=\"width:600px;height:auto\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Now let&#8217;s do one more quick example using the <strong>summarise()<\/strong> function:<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-22\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;summarised.flights3 = summarise(grouped.flights, mean(dep_delay,\nna.rm = TRUE))&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">This will operate in the same way our last line of code did, however this will give us the average departure delay for each date (year, month, day).<\/p>\n<\/section>\n\n\n\n<section class=\"wp-block-sts-block-sts-custom-sections\">\n<h2 class=\"wp-block-heading\">Using Pipelines: %&gt;%<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">When using dplyr we may end up needing to use several functions to get our dataframe exactly where we want it. When several functions are needed, to stay organized, it&#8217;s helpful to run all of our code in one nice and neat chunk. We do this using pipelines, which can be expressed as <strong>%&gt;%<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Essentially pipelines are a way to shorten your code, and make it flow and run in one single chunk.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The best way to explain it is with examples:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The first place we would usually use our pipeline is with our initial dataframe.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Run and examine this code:<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-23\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;filtered.piped.flights = flights %&gt;%\n        filter(month == 1, day == 1)&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">This code will do the exact same thing as the first function we used as our example for the <strong>filter()<\/strong> function, however notice how it is written.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We define our dataframe first. By starting with our dataframe and a pipeline, we are telling R that whatever function is called next, we are calling it onto this dataframe we are putting through the pipeline. Notice how, unlike all previous examples, within the function <strong>filter()<\/strong> we are not stating flights as an argument, we are only giving it month and day. The flights dataframe comes through the pipeline.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now let&#8217;s try pipelines on an example using 2 lines of code, our <strong>summarize()<\/strong> and <strong>group_by()<\/strong> functions.<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-24\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;summarised.piped.flights = flights %&gt;%\n    group_by(year, month, day) %&gt;%\n    summarise(mean(arr_delay, na.rm = TRUE))&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">This code will do the same thing as the example we looked at previously, however note what the pipelines are doing. Similarly to our last example, we are putting the flights dataframe into the pipeline, that dataframe is put through the <strong>group_by()<\/strong> function, and then the new dataframe created by the <strong>group_by()<\/strong> function is sent through the pipeline again, and it is put through the last function, the <strong>summarise()<\/strong> function. So previously, what was two lines of code to be run separately is now one fluid chunk that will run all at once.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And for one final example, I will show the last independent practice problem we did, and how to write it using pipelines.<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-25\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;df.a.b = flights %&gt;%\n    transmute(year, month, day, dep_delay, arr_delay, tailnum,\n    total_delay = dep_delay + arr_delay) %&gt;%\n    group_by(tailnum) %&gt;%\n    summarise(mean(total_delay, na.rm = TRUE))&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">This will run all parts of the problem as if it were just one nice fluid line of code. The major things to take away for pipelines are: initially start with your dataframe, don&#8217;t forget to add a pipeline after every line you&#8217;re stringing together, and you do not need to add the dataframe as an argument in any of the functions you&#8217;re putting the pipeline through.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Also pro-tip: ctrl-shift-m, or on Mac cmd-shift-m is a hotkey that will place a pipeline for you if you don&#8217;t want to type it out.<\/strong><\/p>\n<\/section>\n\n\n\n<section class=\"wp-block-sts-block-sts-custom-sections\">\n<h2 class=\"wp-block-heading\">GGPLOT Basics<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">While we are looking at ggplot(), let&#8217;s introduce a new, smaller dataframe to work with. Enter the code:<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-26\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;data(mpg)&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">This dataframe contains various observations collected by the US Environmental Protection Agency on 38 models of car.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Starting off very simply with just:<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-27\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;ggplot()&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">ggplot on its own doesn&#8217;t show us anything. It simply lays the groundwork of our graph.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If we run this code:<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-28\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;ggplot() + aes(x= mpg$displ, y= mpg$hwy)&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">For every aspect of our graph we add, we denote it with the <strong>+<\/strong>. Here we are telling our groundwork that we want our X axis to look at engine displacement, and our Y axis to look at highway miles per gallon. You&#8217;ll notice our graph now has values on the axes, however there is still nothing being graphed.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img decoding=\"async\" src=\"\/home\/yashwanth\/Downloads\/STS\/images\/r2-006.png\" alt=\"An empty ggplot canvas with mpg$displ on the X axis (range 2\u20137) and mpg$hwy on the Y axis (range approximately 15\u201345). The gray grid background and axis labels are visible, but no data has been plotted yet.\" style=\"width:600px;height:auto\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">There are many different ways to create interesting visualizations with ggplot, and countless nuanced graphics to create, however for the purpose of this lesson we&#8217;ll just be looking at the two most basic. If you want to learn more, Google is your best friend!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now we will introduce <strong>geom_point()<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is used to create scatter plots, or more simply just display our data as points on our ggplot.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s take our code we used earlier to create a base graph, but add a <strong>geom_point()<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-29\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;ggplot() + aes(x= mpg$displ, y= mpg$hwy) + geom_point()&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Run this example and you will see the same framework we created with the original ggplot(), however now that we have added geom_point() we have a scatter plot distribution.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img decoding=\"async\" src=\"\/home\/yashwanth\/Downloads\/STS\/images\/r2-007.png\" alt=\"A ggplot scatter plot of mpg$displ vs mpg$hwy produced by geom_point(). Black data points show a clear downward trend \u2014 vehicles with larger engine displacement tend to have lower highway fuel efficiency. A cluster of high-mpg outliers is visible at low displacement values around 1.8\u20132.0. X axis: mpg$displ (2\u20137), Y axis: mpg$hwy (15\u201345).\" style=\"width:600px;height:auto\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Now let&#8217;s try the same code, but instead of <strong>geom_point()<\/strong>, we&#8217;ll use <strong>geom_smooth()<\/strong>.<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-30\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;ggplot() + aes(x= mpg$displ, y= mpg$hwy) + geom_smooth()&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">You will notice geom_smooth gives us a nice &#8220;smooth&#8221; visualization demonstrating the trend seen in the data. You&#8217;ll notice there&#8217;s even a nice shadow surrounding the line which represents the variance of the data.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img decoding=\"async\" src=\"\/home\/yashwanth\/Downloads\/STS\/images\/r2-008.png\" alt=\"A ggplot smooth curve plot of mpg$displ vs mpg$hwy produced by geom_smooth(). A blue LOESS curve descends steeply from displacement 2 to around 4.5, then levels off and rises slightly at higher values. A gray confidence band (representing variance) surrounds the curve throughout. X axis: mpg$displ (2\u20137), Y axis: mpg$hwy (20\u201335).\" style=\"width:600px;height:auto\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Finally for a last example, let&#8217;s see what happens if we use both of these:<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"wp-block-code has-base-color has-text-color has-background has-link-color has-small-font-size wp-elements-31\" style=\"background-color:#3c3c3c;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\"><code class=\"\" data-line=\"\">&lt;strong&gt;&lt;em&gt;ggplot() + aes(x= mpg$displ, y= mpg$hwy) + geom_point() +\ngeom_smooth()&lt;\/em&gt;&lt;\/strong&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Since we called for both geom_point(), and geom_smooth(), we get both displayed on our graph. Sometimes overlaying multiple facets on a graph like this can get overcrowded, however, in this instance it seems to give us a really good idea of these two observations&#8217; relationship.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img decoding=\"async\" src=\"\/home\/yashwanth\/Downloads\/STS\/images\/r2-009.png\" alt=\"A ggplot combining geom_point() and geom_smooth(). Black scatter plot data points are overlaid with a blue LOESS smooth curve and gray confidence band, reinforcing the negative relationship between engine displacement and highway fuel efficiency. The combination shows both the individual data distribution and the overall trend in a single view. X axis: mpg$displ (2\u20137), Y axis: mpg$hwy (15\u201345).\" style=\"width:600px;height:auto\"\/><\/figure>\n<\/section>\n","protected":false},"author":19,"featured_media":0,"template":"","meta":{"_acf_changed":false,"_uw_seo_meta_title":"","_uw_seo_meta_description":"","_uw_seo_twitter_card_type":"summary_large_image","_uw_seo_meta_image":"","_uw_seo_meta_image_url":"","_uw_seo_meta_image_sizes":[],"_uw_seo_custom_meta_tags":[],"footnotes":""},"categories":[3],"class_list":["post-799","manual","type-manual","status-publish","hentry","category-coding-and-data"],"acf":[],"_links":{"self":[{"href":"https:\/\/sts.doit.wisc.edu\/training-materials\/wp-json\/wp\/v2\/manual\/799","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sts.doit.wisc.edu\/training-materials\/wp-json\/wp\/v2\/manual"}],"about":[{"href":"https:\/\/sts.doit.wisc.edu\/training-materials\/wp-json\/wp\/v2\/types\/manual"}],"author":[{"embeddable":true,"href":"https:\/\/sts.doit.wisc.edu\/training-materials\/wp-json\/wp\/v2\/users\/19"}],"version-history":[{"count":3,"href":"https:\/\/sts.doit.wisc.edu\/training-materials\/wp-json\/wp\/v2\/manual\/799\/revisions"}],"predecessor-version":[{"id":1280,"href":"https:\/\/sts.doit.wisc.edu\/training-materials\/wp-json\/wp\/v2\/manual\/799\/revisions\/1280"}],"wp:attachment":[{"href":"https:\/\/sts.doit.wisc.edu\/training-materials\/wp-json\/wp\/v2\/media?parent=799"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sts.doit.wisc.edu\/training-materials\/wp-json\/wp\/v2\/categories?post=799"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}