# Basic data structures

The basic data structures used to organize data within the R environment include vectors, lists, data frames, tables, and matrices. Here, we provide details for each of these data structures and demonstrate how to create them. This chapter does not include information about how to read data from a file, and the focus is on the data structures themselves. More information about reading from a file can be found in Chapter 3, *Saving Data and Printing Results*.

## Vectors

The default data structure in R is the vector. For example, if you define a variable as a single number, R will treat it as a vector of length one:

```
> a <- 5
> a[1]
```**[1] 5**

Vectors represent a convenient and straightforward way to store a long list of numbers. Please see Chapter 1, *Data Types*, to see more examples of creating vectors. One useful and common way to define a vector is to use the `c`

command. The `c`

command concatenates a set of arguments to form a single vector:

> v <- c(1,3,5,7,-10) ...