<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/how-to-create-visualizations-with-iplots-package-in-r/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.r-exercises.com/2017/07/02/how-to-create-visualizations-with-iplots-package-in-r/?utm_source=rss&utm_medium=rss&utm_campaign=how-to-create-visualizations-with-iplots-package-in-r"> R-exercises</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><a rel="nofollow" href="https://i1.wp.com/www.r-exercises.com/wp-content/uploads/2017/06/Rplotex6_1.jpeg" target="_blank"><img sizes="(max-width: 150px) 100vw, 150px" src="https://i1.wp.com/www.r-exercises.com/wp-content/uploads/2017/06/Rplotex6_1-150x150.jpeg?resize=150%2C150" alt="" class="wp-image-6552" data-recalc-dims="1"></a><strong>INTRODUCTION</strong></p>
<p>iPlots is a package which provides interactive statistical graphics, written in Java. You can find many interesting plots such as histograms, barcharts, scatterplots, boxplots, fluctuation diagrams, parallel coordinates plots and spineplots. The amazing part is that all of these plots support querying, linked highlighting, color brushing, and interactive changing of parameters. </p>
<p>Furthermore, iPlots includes an API for managing plots and adding user-defined objects, such as lines or polygons to a plot.</p>
<p><strong>PACKAGES &amp; DATA</strong></p>
<p>In order to use the iPlots package we have to install and call it. Moreover we need a dataset to work with. Tha dataset we chose in our case is “Cars93” which contains data from 93 Cars on Sale in the USA in 1993 and we can find it in the MASS package which of course must be installed and called too. To install and call those packages and attach the “Cars93” dataset use:</p>
<p><code>install.packages(&quot;iplots&quot;)<br>
install.packages(&quot;MASS&quot;)<br>
library(iplots)<br>
library(MASS)<br>
data(&quot;Cars93&quot;)<br>
attach(Cars93)</code></p>
<p>You can use <code>head(Cars93)</code> in order to see the variables of your dataset.</p>
<p><strong>PLOTS</strong></p>
<p><strong><em>Mosaic Plot</em> </strong></p>
<p>Some of the most important features that mosaic plots in iPlots provide are standard selection, highlighting, color brushing, reordering of variables and addition or exclusion of variables. An example of a mosaic plot with iPlots follows:</p>
<p><code>library(iplots)<br>
library(MASS)<br>
data(&quot;Cars93&quot;)<br>
attach(Cars93)<br>
imosaic(data.frame(AirBags,Cylinders,Origin))</code></p>
<p>iPlots through Model View also allows same Binsize, Fluctuation Diagram and Multiple Barchart. In order to rearrange the variables use the four arrow keys </p>
<p>Note that you can gain further information about your plot using -mouse-over and ctlr.</p>
<p><strong><em>Barcharts</em></strong> </p>
<p>Barcharts in iPlots also feature Spineplots (use ctrl-s or the “View” menu to switch between the two representations). See the example below.</p>
<p><code>library(MASS)<br>
data(Cars93)<br>
attach(Cars93)<br>
ibar(Cylinders)</code></p>
<p>To get a spineplot via the command line use:</p>
<p><code>ibar(Cylinders, isSpine=T)</code></p>
<p>You can reorder Bars with two ways. Firstly by using the options in the “View” menu and secondly by -dragging a bar to the position you wish.<br>
Of course you can order the categories through R in a barchart. Look at the example below:</p>
<p><code>levels(AirBags)<br>
[1] &quot;Driver &amp; Passenger&quot; &quot;Driver only&quot;    &quot;None&quot;         
<p>AirBags2 &lt;-ordered(AirBags,<br>
c(&quot;None&quot;, &quot;Driver only&quot;, &quot;Driver &amp; Passenger&quot;))</p>
<p>levels(AirBags2)<br>
[1] &quot;None&quot; &quot;Driver only&quot; &quot;Driver &amp; Passenger&quot;</p>
<p>ibar(AirBags)<br>
ibar(AirBags2)</p>
<p><strong><em>Parallel Plots</em></strong></p>
<p><em>I. Parallel Coordinate Plot</em></p>
<p>A parallel coordinate plot connects all cases by lines. Look at the example below which creates a Parallel Coordinate Plot for the continuous variables “Cylinders” and “Passengers” of the “Cars93” dataset.</p>
<p><code>ipcp(Cars93[c(Cylinders, Passengers)])</code></p>
<p><strong><em>Parallel Boxplot</em></strong></p>
<p>Parallel boxplots are used to compare distributions of variables. Look how to create a parallel boxplot for all “MPG” variables of the”Cars93″ dataset</p>
<p><code>ibox(Cars93[c(7,8)])</code></p>
<p>All options can be found in the “View” menu of the plot. Note, that the scale is only displayed when all variables share the same scale!</p>
<p><em>III. Boxplot y by x</em></p>
<p>Boxplots y by x show boxplots by group. If ibox() is called with a continuous variable and a factor, a boxplot y by x is created. Look at the example to see how to split “Horsepower” by “Passengers”.<br>
ibox(Horsepower, Passengers)</p>
<p>Note that a boxplot y by x always uses the same scale for all boxplots for a proper comparison.</p>
<p></p>
<div>
<h3>Related exercise sets:</h3>
<ol>
<li><a rel="nofollow" href="http://www.r-exercises.com/2016/09/26/replicating-plots-boxplot-exercises/" title="Replicating Plots – Boxplot Exercises" target="_blank">Replicating Plots – Boxplot Exercises </a></li>
<li><a rel="nofollow" href="http://www.r-exercises.com/2017/04/23/experimental-design-exercises/" title="Experimental Design Exercises" target="_blank">Experimental Design Exercises </a></li>
<li><a rel="nofollow" href="http://www.r-exercises.com/2016/05/20/accessing-dataframe-objects-exercises/" title="Accessing Dataframe Objects Exercises" target="_blank">Accessing Dataframe Objects Exercises </a></li>
<li><a rel="nofollow" href="http://www.r-exercises.com/start-here-to-learn-r/" target="_blank">Explore all our (>1000) R exercises</a></li>
<li><a rel="nofollow" href="http://www.r-exercises.com/r-courses/" target="_blank">Find an R course using our R Course Finder</a> directory</li>
</ol>
</div>

				
		
<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://www.r-exercises.com/2017/07/02/how-to-create-visualizations-with-iplots-package-in-r/?utm_source=rss&utm_medium=rss&utm_campaign=how-to-create-visualizations-with-iplots-package-in-r"> R-exercises</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/Vl2PXW4kU3M" height="1"></a></div></code>