Yegin Genc

- One of the great strengths of R is the graphics capabilities.
- Not only is it very easy to generate great looking graphs, but it is very simply to extend the standard graphics abilities to include
**conditional graphics**. - These are very useful both when
**exploring data**and when doing statistical analysis.

**Base package**provides the simplest graphs: easy to remember, provides low level of analysis.

`plot()`

,`hist()`

…**Lattice**is more options to create higher level of analysis.- syntax is similar to base functions
- visual aspects (color, font etc) are harder to its alternatives (i.e. ggplot)

**Ggplot**is also good for higher level of analysis.- very detailed and well-thought-out visual functions
- syntax is harder to learn (but not too hard to remember once learned.)

`plot`

: generic x-y plotting`barplot`

: bar plots`boxplot`

: box-and-whisker plot`hist`

: histograms`pie`

: pie charts`dotchart`

: cleveland dot plots`image`

,`heatmap`

,`contour`

,`persp`

: functions to generate image-like plots`qqnorm`

,`qqline`

,`qqplot`

: distribution comparison plots`pairs`

,`coplot`

: display of multivariant data

Jury is still out on which is better

```
#install.packages('lattice') #if not installed already
require(lattice)
histogram(~mpg$hwy|mpg$year)
```

```
ggplot(mpg) +
geom_histogram(aes(x=hwy , fill=as.factor(year) )) +
facet_grid(~ year)
```

```
#histograms
histogram(~hwy, mpg)
```

```
#histograms
histogram(~hwy|year, mpg)
```

```
#histograms
histogram(~hwy|as.factor(year)+as.factor(cyl), mpg)
```

```
densityplot(~hwy|class, mpg)
```