-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrsession.txt
257 lines (242 loc) · 7.99 KB
/
rsession.txt
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
R version 3.6.2 (2019-12-12) -- "Dark and Stormy Night"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
R version 3.6.2 (2019-12-12) -- Dark and Stormy Night
Type 'citation()', 'contributors()', or 'license()' for more information
Libraries:
* /home/nick/.config/R/library
* /usr/lib/R/library
> typeof(5)
[1] "double"
> class(5)
[1] "numeric"
> lists(4, "hi")
Error in lists(4, "hi") : could not find function "lists"
> list(4, "hi")
[[1]]
[1] 4
[[2]]
[1] "hi"
> matrix(1:6, 2, 3)
[,1] [,2] [,3]
[1,] 1 3 5
[2,] 2 4 6
> dogs = readRDS("data/dogs/dogs_full.rds")
> class(dogs)
[1] "tbl_df" "tbl" "data.frame"
> attr(dogs, "class")
[1] "tbl_df" "tbl" "data.frame"
> attributes(dogs)
$names
[1] "breed" "group" "datadog"
[4] "popularity_all" "popularity" "lifetime_cost"
[7] "intelligence_rank" "longevity" "ailments"
[10] "price" "food_cost" "grooming"
[13] "kids" "megarank_kids" "megarank"
[16] "size" "weight" "height"
$row.names
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
[18] 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
[35] 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
[52] 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
[69] 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
[86] 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
[103] 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
[120] 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
[137] 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
[154] 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
[171] 171 172
$class
[1] "tbl_df" "tbl" "data.frame"
> attr(dogs, "names")
[1] "breed" "group" "datadog"
[4] "popularity_all" "popularity" "lifetime_cost"
[7] "intelligence_rank" "longevity" "ailments"
[10] "price" "food_cost" "grooming"
[13] "kids" "megarank_kids" "megarank"
[16] "size" "weight" "height"
> names(dogs)
[1] "breed" "group" "datadog"
[4] "popularity_all" "popularity" "lifetime_cost"
[7] "intelligence_rank" "longevity" "ailments"
[10] "price" "food_cost" "grooming"
[13] "kids" "megarank_kids" "megarank"
[16] "size" "weight" "height"
> x = matrix(1:4, 2, 2)
> attributes(x)
$dim
[1] 2 2
> dim(x)
[1] 2 2
> length(x)
[1] 4
> x = 5
> class(x) = "data.frame"
> x
> attr(x, "class") = "data.frame"
> structure(5, class = "data.frame")
> x = structure(5, class = "dat.frame")
> x
[1] 5
attr(,"class")
[1] "dat.frame"
> attributes(5)
NULL
> class(5)
[1] "numeric"
> attr(5, "class")
NULL
> class(NA)
[1] "logical"
> typeof(NA)
[1] "logical"
> 5 + NA
[1] NA
> attr(5, "class")
NULL
> dim(3)
NULL
> 0 / 0
[1] NaN
> 5 / 0
[1] Inf
> -5 / 0
[1] -Inf
> c(1, 2, 3) + c(2, 2, 2)
[1] 3 4 5
> c(1, 2, 3) == c(2, 2, 2)
[1] FALSE TRUE FALSE
> c(1, 2, 3) < c(2, 2, 2)
[1] TRUE FALSE FALSE
> c(NA, 3) < c(2, 3)
[1] NA FALSE
> NA == 5
[1] NA
> NA == NA
[1] NA
> is.na(NA)
[1] TRUE
> is.na(c(NA, 1))
[1] TRUE FALSE
> all.equal(5, 5)
[1] TRUE
> all.equal(5, 6)
[1] "Mean relative difference: 0.2"
> ?all.equal
> isTRUE(all.equal(5, 6))
[1] FALSE
> isTRUE(all.equal(5, 5))
[1] TRUE
> c(1, 2, 3) == c(1, 2, 3)
[1] TRUE TRUE TRUE
> identical(c(1, 2, 3), c(1, 2, 3))
[1] TRUE
> identical(c(1, 7, 3), c(1, 2, 3))
[1] FALSE
> !c(TRUE, FALSE)
[1] FALSE TRUE
> c(TRUE, TRUE) & c(TRUE, FALSE)
[1] TRUE FALSE
> TRUE && FALSE
[1] FALSE
> FALSE && FALSE
[1] FALSE
> c(FALSE, TRUE) && c(TRUE, TRUE)
[1] FALSE
> any(c(TRUE, FALSE, FALSE))
[1] TRUE
> any(c(FALSE, FALSE, FALSE))
[1] FALSE
> all(c(TRUE, TRUE))
[1] TRUE
> all(c(FALSE, TRUE))
[1] FALSE
> sum(c(TRUE, FALSE, TRUE))
[1] 2
> table(c(TRUE, FALSE, FALSE))
FALSE TRUE
2 1
> dogs = readRDS("data/dogs/dogs_full.rds")
> dogs$group
[1] herding terrier sporting terrier sporting
[6] sporting sporting toy herding herding
[11] working non-sporting toy hound terrier
[16] toy terrier hound sporting terrier
[21] terrier non-sporting non-sporting sporting sporting
[26] non-sporting sporting toy toy toy
[31] herding toy sporting hound toy
[36] sporting working hound sporting non-sporting
[41] sporting sporting toy herding terrier
[46] sporting non-sporting working toy herding
[51] toy non-sporting hound hound toy
[56] terrier herding herding sporting terrier
[61] hound working hound terrier working
[66] terrier hound working herding toy
[71] herding working hound non-sporting hound
[76] working terrier working working non-sporting
[81] hound hound working working working
[86] working non-sporting terrier hound non-sporting
[91] hound terrier sporting working herding
[96] herding herding herding hound working
[101] hound sporting herding working herding
[106] terrier toy non-sporting herding sporting
[111] hound herding sporting herding non-sporting
[116] working sporting terrier working working
[121] hound toy hound herding sporting
[126] terrier sporting toy non-sporting working
[131] working terrier working non-sporting terrier
[136] terrier toy working herding hound
[141] non-sporting terrier sporting hound terrier
[146] hound hound herding working herding
[151] herding hound non-sporting hound terrier
[156] non-sporting toy terrier terrier terrier
[161] sporting working sporting herding working
[166] toy sporting sporting terrier terrier
[171] sporting non-sporting
Levels: herding hound non-sporting sporting terrier toy working
> class(dogs$group)
[1] "factor"
> typeof(dogs$group)
[1] "integer"
> levels(dogs$group)
[1] "herding" "hound" "non-sporting" "sporting"
[5] "terrier" "toy" "working"
> factor(c("hi", "bye", "hi"))
[1] hi bye hi
Levels: bye hi
> ?factor
> factor(c("black", "blonde"), c("black", "blonde", "brown", "red"))
[1] black blonde
Levels: black blonde brown red
> hair = factor(c("black", "blonde"), c("black", "blonde", "brown", "red"))
> table(hair)
hair
black blonde brown red
1 1 0 0
> x = c(2, -1, 6)
> x[1]
[1] 2
> x[[1]]
[1] 2
> x[c(1, 2)]
[1] 2 -1
> x[c(2, 1)]
[1] -1 2
> x[[c(2, 1)]]
Error in x[[c(2, 1)]] :
attempt to select more than one element in vectorIndex
> x[-1]
[1] -1 6
> x[-c(1, 3)]
[1] -1
>