-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrsession.txt
457 lines (432 loc) · 12.8 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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
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
> dogs = readRDS("data/dogs/dogs_full.rds")
> x = c(7, 3, 1)
> x = c(7, -3, 1)
> x[1]
[1] 7
> x[[1]]
[1] 7
> x[c(1, 2, 2)]
[1] 7 -3 -3
> x[[c(1, 2, 2)]]
Error in x[[c(1, 2, 2)]] :
attempt to select more than one element in vectorIndex
> x[-1]
[1] -3 1
> x[-2]
[1] 7 1
> x[[-1]]
Error in x[[-1]] :
attempt to select more than one element in get1index <real>
> x[-2]
[1] 7 1
> x
[1] 7 -3 1
> y = c(a = 7, b = -5, c = 1)
> y
a b c
7 -5 1
> x["a"]
[1] NA
> y["a"]
a
7
> x["a"]
[1] NA
> y[["b"]]
[1] -5
> x[["b"]]
Error in x[["b"]] : subscript out of bounds
> x[c("a", "b", "a")]
[1] NA NA NA
> y[c("a", "b", "a")]
a b a
7 -5 7
> y
a b c
7 -5 1
> y > 0
a b c
TRUE FALSE TRUE
> which(y > 0)
a c
1 3
> y[which(y > 0)]
a c
7 1
> y > 0
a b c
TRUE FALSE TRUE
> which(y > 0)
a c
1 3
> y[which(y > 0)]
a c
7 1
> y[y > 0]
a c
7 1
> y_withNA = c(7, -1, NA)
> y_withNA > 0
[1] TRUE FALSE NA
> y_withNA[y_withNA > 0]
[1] 7 NA
> which(y_withNA > 0)
[1] 1
> y_withNA[which(y_withNA > 0)] # drops the NAs
[1] 7
> x
[1] 7 -3 1
> x[[c(FALSE, FALSE, TRUE)]]
Error in x[[c(FALSE, FALSE, TRUE)]] :
attempt to select more than one element in vectorIndex
> y_withNA > 0
[1] TRUE FALSE NA
> x
[1] 7 -3 1
> x[c(TRUE, FALSE)]
[1] 7 1
> x[c(FALSE, TRUE)]
[1] -3
> x
[1] 7 -3 1
> x = list(a = 6, b = 1)
> x = list(a = 6, b = "hi")
> x
$a
[1] 6
$b
[1] "hi"
> x[1]
$a
[1] 6
> class(x[1])
[1] "list"
> x[[1]]
[1] 6
> class(x[[1]])
[1] "numeric"
> x
$a
[1] 6
$b
[1] "hi"
> x = list(a = c(6, 5), b = "hi")
> x
$a
[1] 6 5
$b
[1] "hi"
> x[1]
$a
[1] 6 5
> x[[1]]
[1] 6 5
> x[[c(1, 2)]]
[1] 5
> x[[c(2, 1)]]
[1] "hi"
> x[[c(2, 2)]]
Error in x[[c(2, 2)]] : subscript out of bounds
> x[[c(1, 2)]]
[1] 5
> x[[c(1)]]
[1] 6 5
> x[[c(2, 2)]]
Error in x[[c(2, 2)]] : subscript out of bounds
> x[[2]]
[1] "hi"
> x[[1]][[2]]
[1] 5
> x[[1]]
[1] 6 5
> x[1]
$a
[1] 6 5
> class(x[1])
[1] "list"
> x[1]
$a
[1] 6 5
> x[1][[1]]
[1] 6 5
> x[1]
$a
[1] 6 5
> x[1][1][1][1]
$a
[1] 6 5
> x[c(1, 1, 2)]
$a
[1] 6 5
$a
[1] 6 5
$b
[1] "hi"
> dogs[1]
> class(dogs[1])
[1] "tbl_df" "tbl" "data.frame"
> dogs[[1]]
[1] "Border Collie"
[2] "Border Terrier"
[3] "Brittany"
[4] "Cairn Terrier"
[5] "Welsh Springer Spaniel"
[6] "English Cocker Spaniel"
[7] "Cocker Spaniel"
[8] "Papillon"
[9] "Australian Cattle Dog"
[10] "Shetland Sheepdog"
[11] "Siberian Husky"
[12] "Lhasa Apso"
[13] "Affenpinscher"
[14] "Dachshund"
[15] "Miniature Schnauzer"
[16] "Chihuahua"
[17] "Australian Terrier"
[18] "Whippet"
[19] "English Springer Spaniel"
[20] "West Highland White Terrier"
[21] "Bedlington Terrier"
[22] "Poodle"
[23] "Bichon Frise"
[24] "German Shorthaired Pointer"
[25] "Pointer"
[26] "Tibetan Spaniel"
[27] "Labrador Retriever"
[28] "Maltese"
[29] "Pomeranian"
[30] "Shih Tzu"
[31] "Australian Shepherd"
[32] "Yorkshire Terrier"
[33] "Irish Setter"
[34] "Pharaoh Hound"
[35] "Brussels Griffon"
[36] "Golden Retriever"
[37] "Samoyed"
[38] "Beagle"
[39] "Chesapeake Bay Retriever"
[40] "Tibetan Terrier"
[41] "Gordon Setter"
[42] "English Setter"
[43] "Pug"
[44] "Briard"
[45] "Norfolk Terrier"
[46] "Flat-Coated Retriever"
[47] "Boston Terrier"
[48] "Doberman Pinscher"
[49] "English Toy Spaniel"
[50] "Belgian Tervuren"
[51] "Cavalier King Charles Spaniel"
[52] "Dalmatian"
[53] "Basset Hound"
[54] "Basenji"
[55] "Italian Greyhound"
[56] "Staffordshire Bull Terrier"
[57] "Bouvier des Flandres"
[58] "Pembroke Welsh Corgi"
[59] "Clumber Spaniel"
[60] "Dandie Dinmont Terrier"
[61] "Saluki"
[62] "Giant Schnauzer"
[63] "Greyhound"
[64] "Scottish Terrier"
[65] "Rottweiler"
[66] "Kerry Blue Terrier"
[67] "Afghan Hound"
[68] "Newfoundland"
[69] "German Shepherd"
[70] "Pekingese"
[71] "Old English Sheepdog"
[72] "Akita"
[73] "Rhodesian Ridgeback"
[74] "French Bulldog"
[75] "Borzoi"
[76] "Bernese Mountain Dog"
[77] "Bull Terrier"
[78] "Boxer"
[79] "Alaskan Malamute"
[80] "Chow Chow"
[81] "Bloodhound"
[82] "Irish Wolfhound"
[83] "Bullmastiff"
[84] "Mastiff"
[85] "Great Dane"
[86] "Saint Bernard"
[87] "Bulldog"
[88] "Airedale Terrier"
[89] "American English Coonhound"
[90] "American Eskimo Dog"
[91] "American Foxhound"
[92] "American Staffordshire Terrier"
[93] "American Water Spaniel"
[94] "Anatolian Shepherd Dog"
[95] "Bearded Collie"
[96] "Beauceron"
[97] "Belgian Malinois"
[98] "Belgian Sheepdog"
[99] "Black and Tan Coonhound"
[100] "Black Russian Terrier"
[101] "Bluetick Coonhound"
[102] "Boykin Spaniel"
[103] "Canaan Dog"
[104] "Cane Corso"
[105] "Cardigan Welsh Corgi"
[106] "Cesky Terrier"
[107] "Chinese Crested"
[108] "Chinese Shar Pei"
[109] "Collie"
[110] "Curly Coated Retriever"
[111] "English Foxhound"
[112] "Entlebucher Mountain Dog"
[113] "Field Spaniel"
[114] "Finnish Lapphund"
[115] "Finnish Spitz"
[116] "German Pinscher"
[117] "German Wirehaired Pointer"
[118] "Glen of Imaal Terrier"
[119] "Great Pyrenees"
[120] "Greater Swiss Mountain Dog"
[121] "Harrier"
[122] "Havanese"
[123] "Ibizan Hound"
[124] "Icelandic Sheepdog"
[125] "Irish Red and White Setter"
[126] "Irish Terrier"
[127] "Irish Water Spaniel"
[128] "Japanese Chin"
[129] "Keeshond"
[130] "Komondor"
[131] "Kuvasz"
[132] "Lakeland Terrier"
[133] "Leonberger"
[134] "Löwchen"
[135] "Manchester Terrier"
[136] "Miniature Bull Terrier"
[137] "Miniature Pinscher"
[138] "Neapolitan Mastiff"
[139] "Norwegian Buhund"
[140] "Norwegian Elkhound"
[141] "Norwegian Lundehund"
[142] "Norwich Terrier"
[143] "Nova Scotia Duck Tolling Retriever"
[144] "Otterhound"
[145] "Parson Russell Terrier"
[146] "Petit Basset Griffon Vendeen"
[147] "Plott"
[148] "Polish Lowland Sheepdog"
[149] "Portuguese Water Dog"
[150] "Puli"
[151] "Pyrenean Shepherd"
[152] "Redbone Coonhound"
[153] "Schipperke"
[154] "Scottish Deerhound"
[155] "Sealyham Terrier"
[156] "Shiba Inu"
[157] "Silky Terrier"
[158] "Skye Terrier"
[159] "Smooth Fox Terrier"
[160] "Soft-Coated Wheaten Terrier"
[161] "Spinone Italiano"
[162] "Standard Schnauzer"
[163] "Sussex Spaniel"
[164] "Swedish Vallhund"
[165] "Tibetan Mastiff"
[166] "Toy Fox Terrier"
[167] "Vizsla"
[168] "Weimaraner"
[169] "Welsh Terrier"
[170] "Wire Fox Terrier"
[171] "Wirehaired Pointing Griffon"
[172] "Xoloitzcuintli"
> head(dogs)
> dogs[1, 1]
[1] "Border Collie"
> dogs[[1, 1]]
[1] "Border Collie"
> dogs[1, 1:3]
> dogs[1, ] # first row, all columns
> x
$a
[1] 6 5
$b
[1] "hi"
> x$a
[1] 6 5
> x$"a"
[1] 6 5
> head(dogs)
> colnames(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"
> mean(dogs$weight)
[1] NA
> mean(dogs$weight, na.rm = TRUE)
[1] 44.97093
> dogs$weight > mean(dogs$weight, na.rm = TRUE)
[1] NA FALSE FALSE FALSE NA FALSE FALSE NA NA FALSE TRUE
[12] FALSE NA FALSE FALSE FALSE NA NA TRUE NA FALSE NA
[23] NA TRUE TRUE FALSE TRUE FALSE FALSE FALSE NA FALSE TRUE
[34] NA FALSE TRUE NA NA TRUE FALSE TRUE NA FALSE NA
[45] FALSE NA NA NA FALSE NA FALSE NA NA FALSE NA
[56] FALSE NA FALSE TRUE FALSE NA TRUE TRUE FALSE NA FALSE
[67] TRUE TRUE NA FALSE NA NA TRUE FALSE TRUE NA TRUE
[78] NA TRUE NA TRUE NA TRUE TRUE NA TRUE TRUE NA
[89] NA NA NA NA FALSE TRUE NA NA NA NA NA
[100] NA TRUE NA TRUE NA FALSE FALSE NA TRUE TRUE NA
[111] NA NA NA NA NA NA NA FALSE NA NA NA
[122] NA NA NA NA FALSE TRUE NA NA TRUE TRUE FALSE
[133] NA NA FALSE NA NA TRUE FALSE TRUE NA FALSE NA
[144] TRUE FALSE NA TRUE NA TRUE NA NA NA NA TRUE
[155] FALSE FALSE FALSE FALSE FALSE FALSE NA NA FALSE NA NA
[166] NA NA NA FALSE FALSE NA NA
> above = dogs$weight > mean(dogs$weight, na.rm = TRUE)
> dogs[above, ]
> dogs[which(above), ]
> subset(dogs, weight > mean(weight, na.rm = TRUE))
> dogs[1:3, ]
> rbind(dogs[1:3, ], dogs[1:3, ])
> library(ggplot2)
Registered S3 methods overwritten by 'ggplot2':
method from
[.quosures rlang
c.quosures rlang
print.quosures rlang
Registered S3 method overwritten by 'dplyr':
method from
print.rowwise_df
> ggplot(dogs)
> ggplot(dogs) + geom_point()
Error: geom_point requires the following missing aesthetics: x, y
> ggplot(dogs, aes(x = datadog, y = popularity)) + geom_point()
> class(rbind(dogs, dogs))
[1] "tbl_df" "tbl" "data.frame"
> cbind(1:3, 1:3)
[,1] [,2]
[1,] 1 1
[2,] 2 2
[3,] 3 3
> class(cbind(1:3, 1:3))
[1] "matrix"
>