r4ds/data-structures.Rmd

59 lines
869 B
Plaintext
Raw Normal View History

2015-12-12 02:34:20 +08:00
# Data structures
2015-12-06 22:02:29 +08:00
2015-12-12 02:34:20 +08:00
Might be quite brief.
2015-12-06 22:02:29 +08:00
Atomic vectors and lists + data frames.
2015-12-06 22:02:29 +08:00
Most important data types:
2015-12-06 22:02:29 +08:00
* 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
2015-12-06 22:02:29 +08:00
(Since won't get a chapter of their own)
### Dates
### Date times
## Lists
## Data frames
2015-12-06 22:02:29 +08:00
## Subsetting
Not sure where else this should be covered.