A Stem and Leaf Diagram, also called as Stem and Leaf plot, is a special table where each numeric value is split into a * stem* (First digit(s) ) and a

*(last Digit). For example, 57 will split into 5 as*

**leaf***and 7 as*

**stem***. In this article we will show you, How to make a Stem and Leaf plot in R Programming language with example.*

**leaf**## Syntax of a Stem and Leaf Plot in R

The basic syntax to draw the Stem and Leaf chart in R Programming is as shown below

stem(x, scale = 1, width = 80, atom = 1e-08)

Following are the list of arguments supported by the Stem and Leaf chart in R programming language:

**x:**Please specify the data on which you want to draw the Stem and Leaf Plot. Here, you have to use the numeric vector, or a list containing numeric vector.**scale:**Please specify the scale you want to use for your plot.**width:**It is optional but you can use this to specify the desired width of a plot. By default it is 80**atom:**It is a tolerance

Before we get into the example, let us see the diagrammatic representation of Stem and Leaf plot. From the below screenshot you can see that, first we declared a variables 10, 15, 22, 25, 28, 23, 29, 31, 36, 45, 48. From those values, First digit is assigned to stem and last Digit is leaf.

## Create a Stem and Leaf Plot in R Programming

In this example we will show you, How to make a Stem and Leaf plot using the * ChickWeight * data set, which is provided by the R Studio. If your requirement is to import data from external files then, I suggest you to refer R Read CSV article to understand the importing of csv file.

**R CODE**

# Make a Stem and Leaf Plot in R Programming ChickWeight # Drawing Stem and Leaf Plot stem(ChickWeight$weight)

**OUTPUT**

**ANALYSIS**

* ChickWeight* data set will return the output as a List. So, we are using the

**$**to extract the data from List.

stem(ChickWeight$weight)

From the above screenshot you can see that, * ChickWeight* data set has numbers like: 25, 29, 29, ……., 341, 361, 363

### Use Scale for Stem and Leaf Plot in R

In this example we will show you, How to use the * scale* argument inside the

*function.*

**stem****R CODE**

# Make a Stem and Leaf Plot in R Programming ChickWeight # Drawing Stem and Leaf Plot stem(ChickWeight$weight, scale = 2)

**OUTPUT**

### Change width of a Stem and Leaf Plot

In this example we will show you, How to change the width of a Stem and Leaf chart in R Programming.

**R CODE**

# Make a Stem and Leaf Plot in R Programming ChickWeight # Drawing Stem and Leaf Plot stem(ChickWeight$weight) stem(ChickWeight$weight, width = 100)

**OUTPUT**

Thank You for Visiting Our Blog