List is a type of an object in R programming. Lists can contain heterogeneous elements like strings, numeric, matrices, or even lists. A list is a generic vector containing other objects. Two-dimensional list can be created in R programming by creating more lists in a list or simply, we can say nested lists. The ** list()** function in R programming is used to create a list. In this article, we’ll learn to create plot graph using Two Dimensional List in R programming.

#### Creating a Two Dimensional list

A Two Dimensional list can be created with the use of `list()`

function.

Syntax:list(x)

Parameter:

x:represents objects to be inserted in list

**Example:**

`# Defining objects ` `x <` `-` `c(` `1` `, ` `2` `, ` `3` `, ` `4` `) ` ` ` `y <` `-` `LETTERS[` `1` `:` `4` `] ` ` ` `# Adding lists into a list ` `ls <` `-` `list` `( ` ` ` `list` `(x), ` ` ` `list` `(y) ` `) ` ` ` `# Print list ` `print` `(ls) ` |

*chevron_right*

*filter_none*

**Output:**

[[1]] [[1]][[1]] [1] 1 2 3 4 [[2]] [[2]][[1]] [1] "A" "B" "C" "D"

#### Creating Plot Graph using Two Dimensional List

To create plot graphs, lists have to be passed as vectors to the

function as coordinate values. The **plot()**

function converts the list into an atomic type of vector.**unlist()**

**Example:**

`# Creating nested lists with random values ` `ls <` `-` `list` `( ` ` ` `list` `(rnorm(` `20` `, mean ` `=` `10` `, sd ` `=` `2` `)), ` ` ` `list` `(rnorm(` `20` `, mean ` `=` `100` `, sd ` `=` `10` `))) ` ` ` `# Output to be present as PNG file ` `png(` `file` `=` `"2DListGraph.png"` `) ` ` ` `# Plotting list ` `plot(unlist(ls[[` `1` `]]), unlist(ls[[` `2` `]])) ` ` ` `# Saving the file ` `dev.off() ` |

*chevron_right*

*filter_none*

**Output:**

## Recommended Posts:

- Two Dimensional List in R Programming
- Create One Dimensional Scatterplots in R Programming - stripchart() Function
- Plotting of Data using Generic plots in R Programming - plot() Function
- How to create two dimensional array in JavaScript?
- How to take user input for two dimensional (2D) array in PHP ?
- Graph Plotting in R Programming
- Multi-dimensional lists in Python
- How to Create and Print Multi Dimensional Slice in Golang?
- R - Line Graphs
- R - Charts and Graphs
- Introduction to Graphs
- Different plotting using pandas and matplotlib
- Convert an Object to List in R Programming - as.list() Function
- Check if the Object is a List in R Programming - is.list() Function
- Add Color Between Two Points of Kernel Density Plot in R Programming - Using with() Function
- Apply a Function over a List of elements in R Programming - lapply() Function
- Get a List of all the Attached Packages in R Programming - search() Function
- Get the List of Arguments of a Function in R Programming - args() Function
- Recursively apply a Function to a List in R Programming - rapply() function
- Named List in R Programming

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.