forked from hadley/r4ds
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata-structures.Rmd
More file actions
63 lines (40 loc) · 917 Bytes
/
data-structures.Rmd
File metadata and controls
63 lines (40 loc) · 917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
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.