#### π₯ Introduction to R (1)

#### π₯ Data Structure (2)

#### π₯ Statistical value (mean, median, mode etc) (3)

#### π₯ Tabular Presentation of Data (4)

#### π₯ Ploting graph with R

#### π₯ constructing frequency distribution with R (6)

The following is an introduction for plotting simple graphs with the R Programming Language. Each example builds on the previous one.

In statistic while trying to do analysis on data the most important way of displaying information is the use of graphs. so let's see different kind of graph we can plot with codes.

### Types of Graph

- Line Charts
- Bar Charts
- [Histograms]
- Pie Charts
- Dotcharts
- Misc

### Line Charts

First we'll produce a very simple graph using the values in the weight vector:

### Example:

copy the following codes

```
# Define the cars vector with 8 values
weight <- c(1, 6, 11, 14, 19, 22, 26, 33)
# Graph the weight vector with all defaults
plot(weight)
```

Result

that is just a simple way to draw a line graph. all your value will be dotted. but that is not nice enough we need to add some attribute that made up perfect graph.

### Title and Colors

Let's add a title, a line to connect the points, and some color with the following codes

Example 1.2

```
weight <- c(1, 6, 11, 14, 19, 22, 26, 33)
# Graph weight using red points overlay by a line and use o as the dot
plot(weight, type="o", col="red",font.main=11)
# Create a title with a green, bold font
title(main="Autos", col.main="red", font.main=4)
```

### Explanation

the `plot()`

function is used to plot the graph. it can take some parameters like vector ,type and color.

**Vectors**: is the data will want to use to plot the graph.

**type**: is the kind of mark and line we want to use to specify dot on the graph. it is dot by default and can be change to whatever we want e.g "h","p","s",'S','l' and 'c'

**color**: this is use to give our own preference color.

can we plot two line graph in one graph?? Yeah! we can and we shall take a look at that later. read the next article.

## Top comments (1)

R in fact has three plotting systems: base, lattice, ggplot2. See devopedia.org/r-plotting-systems for more info. I often use ggplot2.