Intro to R Webpage



1. Base Function vs ggplot2

We look at simple plotting with base functions (without using any packages). R has very good visualization package called ggplot2. Tutorial for that is on another page.

2. Plotting

## [1] 32  3
## [1] "Cost"   "MWatts" "Date"
##     Cost MWatts  Date
## 1 345.39    514 67.92
## 2 460.05    687 68.58
## 3 452.99   1065 67.33
## 4 443.22   1065 67.33
## 5 652.32   1065 68.00
## 6 642.23   1065 68.00

Note that MWatts is on x-axis.

4. Overlaying Two Plots

##   wine
## 1  464
## 2  675
## 3  703
## 4  887
## 5 1139
## 6 1077
## [1] 142   1


Single plots

Note that X was defined as Orig$Lynx above.


Overlay two plots

Note that lines() uses type=“l” as default. You can change it by usint type= command if you need to.

Note that lines() use uses the plot that is already drawn by plot(). So which one to plot first does matter. You can specify the range of the plot in plot().