# Data Frame

# Table of Contents

# Overview

A kind of `list`

but:

- The components must be vectors (numeric, character, or logical), factors, numeric matrices, lists, or other data frames.
- Matrices, lists, and data frames provide as many variables to the new data frame as they have columns, elements, or variables, respectively.
- Numeric vectors, logicals and factors are included as is, and by default18 character vectors are coerced to be factors, whose levels are the unique values appearing in the vector.
- Vector structures appearing as variables of the data frame must all have the same length, and matrix structures must all have the same row size.

```
[1] "data.frame"
[1] "list"
```

# Reference

`subset(x, subset, select, drop = FALSE, …)`

reference

- For ordinary vectors
- the result is simply
`x[subset & !is.na(subset)]`

- For data frames
`subset`

argument works on the rows.`subset`

will be evaluated in the data frame, so columns can be referred to (by name) as variables in the expression.

`select`

- expression, indicating columns to select from a data frame.
`drop`

- passed on to
`[`

indexing operator. (like`x[r, vars, drop = drop]`

)

```
subset(airquality, Temp > 80, select = c(Ozone, Temp))
subset(airquality, Day == 1, select = -Temp)
subset(airquality, select = Ozone:Wind)
```