r4ds/data-structures.Rmd

64 lines
917 B
Plaintext

---
layout: default
title: Data structures
---
# Data structures
Might be quite brief.
Atomic vectors and lists + data frames.
Most important data types:
* logical
* integer & double
* character
* date
* date time
* factor
<http://adv-r.had.co.nz/OO-essentials.html>
Every vector has three key properties:
1. Type: e.g. integer, double, list. Retrieve with `typeof()`.
2. Length. Retrieve with `length()`
3. Attributes. A named of list of additional metadata. With the `class`
attribute used to build more complex data structure (like factors and
dates) up from simpler components. Get with `attributes()`.
## Atomic vectors
### Doubles
```{r}
sqrt(2) ^ 2 - 2
0/0
1/0
-1/0
mean(numeric())
```
## Non-atomic vectors
`class()`
### Factors
(Since won't get a chapter of their own)
### Dates
### Date times
## Lists
## Data frames
## Subsetting
Not sure where else this should be covered.