**R-exercises**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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.

Furthermore, iPlots includes an API for managing plots and adding user-defined objects, such as lines or polygons to a plot.

**PACKAGES & DATA**

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:

`install.packages("iplots")`

install.packages("MASS")

library(iplots)

library(MASS)

data("Cars93")

attach(Cars93)

You can use `head(Cars93)`

in order to see the variables of your dataset.

**PLOTS**

*Mosaic Plot*

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:

`library(iplots)`

library(MASS)

data("Cars93")

attach(Cars93)

imosaic(data.frame(AirBags,Cylinders,Origin))

iPlots through Model View also allows same Binsize, Fluctuation Diagram and Multiple Barchart. In order to rearrange the variables use the four arrow keys

Note that you can gain further information about your plot using -mouse-over and ctlr.

*Barcharts*

Barcharts in iPlots also feature Spineplots (use ctrl-s or the “View” menu to switch between the two representations). See the example below.

`library(MASS)`

data(Cars93)

attach(Cars93)

ibar(Cylinders)

To get a spineplot via the command line use:

`ibar(Cylinders, isSpine=T)`

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.

Of course you can order the categories through R in a barchart. Look at the example below:

`levels(AirBags)`

[1] "Driver & Passenger" "Driver only" "None"

```
```AirBags2 <- ordered(AirBags,

c("None", "Driver only", "Driver & Passenger"))

levels(AirBags2)

[1] "None" "Driver only" "Driver & Passenger"

`ibar(AirBags)`

ibar(AirBags2)

*Parallel Plots*

*I. Parallel Coordinate Plot*

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.

`ipcp(Cars93[c(Cylinders, Passengers)])`

*Parallel Boxplot*

Parallel boxplots are used to compare distributions of variables. Look how to create a parallel boxplot for all “MPG” variables of the”Cars93″ dataset

`ibox(Cars93[c(7,8)])`

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!

*III. Boxplot y by x*

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”.

ibox(Horsepower, Passengers)

Note that a boxplot y by x always uses the same scale for all boxplots for a proper comparison.

**leave a comment**for the author, please follow the link and comment on their blog:

**R-exercises**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.