Connect With Us


Resources






  • connect to & explore database
  • read & write data
  • use RStudio SQL script & knitr SQL engine
  • query data using dplyr
  • visualize data with dbplot
  • modeling data with modeldb & tidypredict
  • explore RStudio connections pane
  • handling credentials

Libraries


Connect


Connection Summary


##           Length            Class             Mode 
##                1 SQLiteConnection               S4

List Tables


## [1] "COMPANY"    "DEPARTMENT" "ecom"       "trade"

List Fields


##  [1] "id"          "referrer"    "device"      "bouncers"    "n_visit"    
##  [6] "n_pages"     "duration"    "country"     "purchase"    "order_items"
## [11] "order_value"

Data Dictionary


  • id: row id
  • referrer: referrer website/search engine
  • os: operating system
  • browser: browser
  • device: device used to visit the website
  • n_pages: number of pages visited
  • duration: time spent on the website (in seconds)
  • repeat: frequency of visits
  • country: country of origin
  • purchase: whether visitor purchased
  • order_value: order value of visitor (in dollars)

Querying Data


  • read entire table
  • read few rows
  • read data in batches

Entire Table


##        id referrer device bouncers n_visit n_pages duration
## 1       1   google laptop     true      10       1      693
## 2       2    yahoo tablet     true       9       1      459
## 3       3   direct laptop     true       0       1      996
## 4       4     bing tablet    false       3      18      468
## 5       5    yahoo mobile     true       9       1      955
## 6       6    yahoo laptop    false       5       5      135
## 7       7    yahoo mobile     true      10       1       75
## 8       8   direct mobile     true      10       1      908
## 9       9     bing mobile    false       3      19      209
## 10     10   google mobile     true       6       1      208
## 11     11   direct laptop     true       9       1      738
## 12     12   direct tablet    false       6      12      132
## 13     13   direct mobile    false       9      14      406
## 14     14    yahoo tablet    false       5       8       80
## 15     15    yahoo mobile    false       7       1       19
## 16     16     bing laptop     true       1       1      995
## 17     17     bing tablet    false       5      16      368
## 18     18   google tablet     true       7       1      406
## 19     19   social tablet    false       7      10      290
## 20     20   social tablet    false       2       1       28
## 21     21   direct laptop     true       2       1      384
## 22     22   google mobile     true       5       1      147
## 23     23     bing mobile    false       0       7      196
## 24     24   social laptop     true       4       1      850
## 25     25    yahoo laptop     true       1       1      779
## 26     26   social laptop     true       7       1      574
## 27     27   direct tablet    false       2      19      342
## 28     28   google laptop     true       9       1      126
## 29     29   google mobile     true      10       1      338
## 30     30    yahoo mobile    false       8       9      225
## 31     31   social tablet     true       2       1      795
## 32     32   direct mobile     true       2       1      501
## 33     33   direct laptop     true       8       1      658
## 34     34   social tablet    false       9      20      420
## 35     35   direct mobile     true       6       1      404
## 36     36     bing mobile    false       1       1       25
## 37     37     bing laptop     true       0       1      897
## 38     38    yahoo mobile     true       3       1      700
## 39     39   google mobile     true       0       1      796
## 40     40   google mobile     true      10       1      479
## 41     41     bing mobile    false       4      20      440
## 42     42   direct mobile    false       1      13      234
## 43     43     bing laptop     true       0       1      456
## 44     44    yahoo tablet    false       7      11      264
## 45     45     bing laptop     true       7       1      867
## 46     46    yahoo tablet     true       7       1      799
## 47     47     bing mobile     true       6       1      843
## 48     48    yahoo laptop     true       4       1      781
## 49     49   social mobile    false       1       2       44
## 50     50     bing tablet     true       5       1      831
## 51     51   direct mobile     true       9       1      898
## 52     52     bing mobile     true       7       1      569
## 53     53   social tablet    false       3      12      324
## 54     54   social tablet     true       4       1       53
## 55     55   direct mobile     true       0       1      566
## 56     56   google tablet    false       1      19      304
## 57     57   google laptop    false       1       8      136
## 58     58   google tablet    false       9       3       57
## 59     59    yahoo tablet     true       9       1      706
## 60     60     bing laptop     true       4       1      748
## 61     61   google laptop     true       0       1       75
## 62     62   direct tablet     true       8       1      814
## 63     63   direct mobile    false      10       1       17
## 64     64    yahoo tablet    false       3       5      140
## 65     65    yahoo laptop    false       5       8      136
## 66     66   google tablet    false       6       6      114
## 67     67    yahoo tablet     true       3       1      332
## 68     68   direct mobile     true       7       1      912
## 69     69     bing tablet     true       1       1      406
## 70     70     bing mobile     true       5       1      190
## 71     71   social laptop     true       0       1      874
## 72     72   social laptop    false       5      16      176
## 73     73   google tablet     true       4       1      565
## 74     74   social tablet     true       5       1      934
## 75     75   direct tablet     true       9       1       47
## 76     76    yahoo tablet    false       5       3       78
## 77     77    yahoo laptop     true       4       1      928
## 78     78   social laptop    false       4      19      399
## 79     79     bing mobile     true       9       1      823
## 80     80   social laptop    false       8      12      276
## 81     81   social laptop     true       8       1      581
## 82     82   direct tablet     true       7       1      219
## 83     83   social mobile     true       5       1      613
## 84     84    yahoo tablet     true       4       1      804
## 85     85   google tablet     true       3       1      652
## 86     86    yahoo tablet     true       0       1      824
## 87     87   social tablet    false       9      16      432
## 88     88    yahoo tablet    false       3      11      176
## 89     89   direct mobile    false       4       8      144
## 90     90     bing mobile    false       7       1       22
## 91     91   social laptop     true       3       1      365
## 92     92   google mobile    false       5       8      192
## 93     93   google laptop     true       9       1      869
## 94     94    yahoo tablet    false       2      16      480
## 95     95   social tablet     true       1       1      566
## 96     96   direct tablet    false      10       3       57
## 97     97     bing tablet     true       2       1      292
## 98     98     bing mobile    false       3      18      288
## 99     99    yahoo mobile     true       1       1       73
## 100   100   google laptop     true       5       1      751
## 101   101    yahoo tablet    false       2      14      364
## 102   102   google mobile    false       2       3       69
## 103   103   direct laptop    false       0       7      196
## 104   104    yahoo tablet    false       6      18      432
## 105   105   direct mobile     true       1       1      423
## 106   106   direct mobile     true       6       1      227
## 107   107   social mobile     true       2       1      267
## 108   108   google laptop     true       9       1      174
## 109   109   google tablet     true       9       1      382
## 110   110   direct mobile    false       5       5       55
## 111   111   social tablet     true       9       1      717
## 112   112   social mobile    false      10      11      242
## 113   113    yahoo tablet    false       7      16      224
## 114   114     bing tablet    false       0      14      280
## 115   115   google laptop    false       1       6       72
## 116   116   direct mobile     true      10       1      675
## 117   117     bing tablet    false       6      16      176
## 118   118   direct laptop    false       2      16      400
## 119   119     bing laptop     true       1       1      938
## 120   120    yahoo mobile    false       2       5       95
## 121   121   direct laptop     true       4       1      468
## 122   122   direct laptop     true       3       1      768
## 123   123     bing mobile     true       5       1      751
## 124   124   social mobile     true       0       1      345
## 125   125    yahoo mobile    false       6      14      322
## 126   126   direct mobile     true       6       1      981
## 127   127   social tablet     true       2       1      576
## 128   128     bing tablet    false       9       2       50
## 129   129   google tablet     true       8       1      249
## 130   130   direct laptop     true       6       1      178
## 131   131     bing tablet    false       3      15      195
## 132   132     bing tablet    false       0       3       42
## 133   133   direct mobile    false       2       4       76
## 134   134   google mobile    false       1      18      252
## 135   135   social mobile    false       0       3       78
## 136   136    yahoo tablet    false       0      20      200
## 137   137    yahoo mobile    false       5       3       30
## 138   138    yahoo tablet     true       6       1      297
## 139   139    yahoo laptop    false       8       6       60
## 140   140   social laptop     true       5       1      286
## 141   141    yahoo tablet     true       1       1      949
## 142   142   google laptop    false       1       7      126
## 143   143   social mobile    false       7      16      352
## 144   144   social tablet     true       3       1      225
## 145   145   google laptop    false       5       9      261
## 146   146   google laptop     true       7       1      792
## 147   147   direct tablet    false       4       5       55
## 148   148    yahoo laptop     true       5       1      739
## 149   149     bing tablet    false       6       3       54
## 150   150     bing laptop    false       5      10      190
## 151   151   social tablet     true       6       1      133
## 152   152    yahoo mobile    false       6       3       39
## 153   153   google tablet     true      10       1       86
## 154   154   social laptop     true       0       1      720
## 155   155   google mobile    false       8      10      240
## 156   156   direct mobile    false       4      18      324
## 157   157   social laptop    false       9       6       66
## 158   158   google tablet    false       7      12      324
## 159   159   social laptop    false       2      16      288
## 160   160    yahoo tablet     true       6       1       67
## 161   161   google laptop     true       5       1      806
## 162   162   social tablet     true       8       1      502
## 163   163   social laptop     true       1       1       35
## 164   164   social mobile     true      10       1      479
## 165   165   social laptop    false       5       3       90
## 166   166   direct tablet    false       6      20      580
## 167   167   social mobile    false       2       2       36
## 168   168   direct tablet    false       7      15      240
## 169   169   direct laptop    false       6       6       96
## 170   170     bing tablet     true       0       1      985
## 171   171   direct laptop    false       7       5       95
## 172   172    yahoo laptop     true       8       1      109
## 173   173   google mobile    false       2       9      162
## 174   174     bing mobile    false       9       1       22
## 175   175    yahoo mobile    false       4      13      364
## 176   176    yahoo laptop     true       2       1      506
## 177   177     bing laptop    false       5       1       20
## 178   178   direct mobile    false       9      15      210
## 179   179   google laptop     true       2       1      773
## 180   180    yahoo tablet     true       6       1      680
## 181   181     bing mobile     true       9       1      650
## 182   182     bing mobile    false       9       2       42
## 183   183     bing mobile    false       3      15      450
## 184   184   social laptop     true       5       1      544
## 185   185   google mobile    false       8       2       44
## 186   186   google tablet     true       5       1      169
## 187   187     bing laptop    false       1       2       22
## 188   188    yahoo tablet     true       3       1      664
## 189   189   direct mobile     true       2       1      338
## 190   190   social tablet    false       4       8       80
## 191   191     bing mobile     true       4       1      366
## 192   192     bing laptop     true       1       1      989
## 193   193    yahoo tablet    false       1      12      156
## 194   194   google laptop     true       3       1      978
## 195   195   direct laptop     true       3       1      510
## 196   196   direct laptop    false       5      18      540
## 197   197     bing mobile     true       1       1       67
## 198   198     bing tablet     true       0       1      352
## 199   199    yahoo laptop    false      10      11      110
## 200   200   google tablet     true      10       1      905
## 201   201   social laptop    false       7      15      210
## 202   202    yahoo tablet    false       9      13      182
## 203   203   direct tablet     true       6       1       54
## 204   204   direct tablet     true       5       1       32
## 205   205    yahoo tablet     true       0       1       28
## 206   206   google mobile     true       7       1      241
## 207   207   google tablet    false      10       8      200
## 208   208     bing tablet    false       0       2       52
## 209   209    yahoo laptop     true       3       1      373
## 210   210   social mobile     true      10       1      102
## 211   211     bing tablet     true       4       1      493
## 212   212   social tablet     true       4       1      578
## 213   213     bing laptop     true       7       1      811
## 214   214   direct laptop    false       8      10      210
## 215   215    yahoo mobile     true      10       1      594
## 216   216    yahoo laptop     true       3       1      812
## 217   217   google mobile    false       9       9      135
## 218   218   social laptop     true       5       1      553
## 219   219   social mobile    false       1      20      520
## 220   220   social tablet    false       6       6      108
## 221   221   direct tablet    false       6      19      304
## 222   222   direct laptop    false       8       5      150
## 223   223   social tablet    false       1       8      128
## 224   224   social mobile    false       5       7      140
## 225   225   direct tablet    false       3      12      324
## 226   226   google laptop     true       7       1      928
## 227   227    yahoo mobile    false       0      13      351
## 228   228   direct tablet     true      10       1      497
## 229   229   google mobile     true      10       1      948
## 230   230     bing tablet    false       8       6      180
## 231   231     bing tablet     true       0       1      697
## 232   232   social laptop    false       8       2       60
## 233   233   google tablet    false       3       3       78
## 234   234   social tablet     true      10       1      674
## 235   235    yahoo laptop     true       7       1      300
## 236   236    yahoo tablet     true       5       1       10
## 237   237   social laptop     true       8       1      152
## 238   238    yahoo mobile     true       1       1      257
## 239   239   social mobile    false       2      10      190
## 240   240   direct laptop    false       6       4      104
## 241   241    yahoo mobile    false      10      11      209
## 242   242     bing mobile    false      10      13      221
## 243   243     bing tablet    false       6       1       22
## 244   244   google mobile    false       5      13      390
## 245   245   social laptop     true       9       1      164
## 246   246   direct mobile     true       9       1      207
## 247   247     bing laptop     true       1       1      148
## 248   248     bing tablet     true       5       1      151
## 249   249   google mobile    false      10       8       88
## 250   250     bing laptop     true       3       1      422
## 251   251   social tablet    false       3       5       95
## 252   252     bing tablet     true       3       1      798
## 253   253   google mobile    false       8      20      300
## 254   254    yahoo laptop    false       8      13      364
## 255   255   google tablet     true       6       1      216
## 256   256   social laptop    false      10      10      180
## 257   257     bing laptop    false       5      13      286
## 258   258   google mobile    false       3      17      510
## 259   259   google mobile     true       3       1      553
## 260   260    yahoo laptop    false      10      10      290
## 261   261   social laptop     true       0       1      581
## 262   262   google mobile    false       9      17      221
## 263   263   social mobile     true      10       1      432
## 264   264    yahoo laptop    false       7       2       30
## 265   265     bing laptop     true      10       1      777
## 266   266   social laptop     true       8       1      735
## 267   267    yahoo laptop     true       5       1      994
## 268   268    yahoo tablet     true       6       1      669
## 269   269    yahoo laptop    false       9       9      135
## 270   270    yahoo mobile    false       4       9      189
## 271   271   social laptop    false       2       5      150
## 272   272   direct mobile    false       6      12      324
## 273   273   social laptop     true       4       1      794
## 274   274    yahoo mobile    false      10      18      270
## 275   275     bing laptop     true       8       1      484
## 276   276   social laptop    false       4      20      200
## 277   277   google tablet    false       8       1       22
## 278   278    yahoo laptop    false       5      11      143
## 279   279    yahoo laptop    false       7      15      150
## 280   280    yahoo mobile     true       2       1       90
## 281   281   social laptop     true      10       1       81
## 282   282   direct laptop     true       4       1      314
## 283   283   social mobile     true       5       1       22
## 284   284   social mobile     true       9       1      803
## 285   285   direct mobile    false       8      16      464
## 286   286   google tablet     true       4       1       86
## 287   287    yahoo mobile     true       7       1      520
## 288   288     bing tablet    false       5       6      138
## 289   289    yahoo mobile     true       1       1      376
## 290   290     bing mobile    false       4      18      414
## 291   291    yahoo laptop     true       5       1      611
## 292   292    yahoo tablet    false       0      13      390
## 293   293     bing mobile     true      10       1      480
## 294   294    yahoo laptop    false       0       4       52
## 295   295     bing laptop    false      10      16      304
## 296   296   google mobile    false       5       7      133
## 297   297     bing mobile    false      10       8      152
## 298   298     bing laptop    false       5      16      192
## 299   299    yahoo laptop    false      10      18      180
## 300   300   direct laptop     true       9       1      296
## 301   301    yahoo tablet    false       7      10      240
## 302   302   google laptop    false       6       9      135
## 303   303     bing mobile     true       4       1      979
## 304   304   social laptop     true       7       1      185
## 305   305     bing tablet    false       2      11      220
## 306   306   direct mobile    false       7       7       98
## 307   307   google laptop    false       3       8      192
## 308   308    yahoo tablet    false       8      14      322
## 309   309   google mobile     true       0       1      327
## 310   310   social laptop    false       6       5       50
## 311   311   direct tablet     true       2       1      891
## 312   312    yahoo tablet    false       1      18      270
## 313   313    yahoo laptop    false       1      16      400
## 314   314    yahoo mobile    false       3      20      480
## 315   315     bing tablet    false       2       1       23
## 316   316   direct laptop     true       2       1      149
## 317   317   google mobile    false       3      18      270
## 318   318   direct laptop     true       8       1      298
## 319   319     bing laptop    false      10       6       90
## 320   320     bing laptop    false       4       3       48
## 321   321     bing tablet    false       1      17      170
## 322   322     bing tablet     true       3       1      192
## 323   323   google mobile     true       1       1      417
## 324   324   direct laptop    false       9      17      425
## 325   325     bing tablet     true       9       1      281
## 326   326    yahoo mobile     true       4       1      464
## 327   327     bing laptop     true       2       1      646
## 328   328   direct mobile    false       9      15      375
## 329   329     bing mobile     true       3       1      490
## 330   330   direct laptop    false       2       4       40
## 331   331   google mobile     true       8       1      849
## 332   332   google laptop    false       5       5      125
## 333   333     bing tablet     true       1       1      721
## 334   334     bing mobile    false       2       7      196
## 335   335   social tablet     true       4       1      403
## 336   336    yahoo mobile     true       8       1      632
## 337   337     bing mobile    false       8      13      169
## 338   338   direct mobile     true       1       1      860
## 339   339   google tablet     true       0       1      866
## 340   340    yahoo mobile     true       9       1      565
## 341   341     bing mobile    false       5      15      405
## 342   342   google tablet     true       1       1       73
## 343   343     bing tablet     true       4       1      684
## 344   344     bing mobile    false       4       9      261
## 345   345   social laptop     true       8       1       64
## 346   346    yahoo tablet    false       9      16      432
## 347   347    yahoo tablet     true       2       1      652
## 348   348   social laptop    false      10      20      280
## 349   349    yahoo laptop    false       2      17      374
## 350   350   direct mobile    false       1      13      390
## 351   351     bing tablet     true       8       1      577
## 352   352   direct tablet    false       2      17      391
## 353   353   social tablet     true       1       1      200
## 354   354   social laptop     true       8       1      382
## 355   355    yahoo laptop    false       6      17      374
## 356   356     bing laptop     true       4       1      750
## 357   357    yahoo mobile     true       0       1      287
## 358   358   google mobile    false      10       5       50
## 359   359   direct laptop    false       3      13      260
## 360   360    yahoo mobile     true       5       1      213
## 361   361     bing laptop     true       4       1      913
## 362   362   social mobile    false       5      16      272
## 363   363   google laptop    false       2       7      154
## 364   364     bing laptop     true       3       1      369
## 365   365   google laptop    false       9      19      228
## 366   366   direct tablet     true       6       1      814
## 367   367   social laptop     true       2       1      550
## 368   368   google laptop     true       0       1      551
## 369   369   social laptop     true       2       1      341
## 370   370   social tablet    false       2       8      208
## 371   371   social laptop     true       2       1      576
## 372   372   social tablet     true       5       1      175
## 373   373    yahoo mobile    false       2      20      240
## 374   374   social mobile     true       5       1      527
## 375   375   social laptop    false       8      16      160
## 376   376    yahoo mobile     true       7       1      194
## 377   377   google mobile     true      10       1      256
## 378   378    yahoo mobile     true       9       1      871
## 379   379     bing tablet     true       2       1       24
## 380   380   google mobile     true      10       1      351
## 381   381    yahoo laptop    false       7      20      340
## 382   382   direct laptop    false       9       4       80
## 383   383   social mobile    false       9      19      304
## 384   384   google tablet    false       1      12      216
## 385   385     bing tablet    false      10      15      150
## 386   386   direct laptop    false       1       8      200
## 387   387    yahoo mobile     true       7       1      352
## 388   388   google laptop     true       1       1      958
## 389   389     bing mobile    false       6       5       55
## 390   390   social tablet    false       3      15      240
## 391   391   google tablet    false       0       6      144
## 392   392    yahoo laptop    false       0       1       12
## 393   393    yahoo mobile     true       9       1      524
## 394   394   direct laptop    false       8      20      440
## 395   395   google mobile    false      10      13      208
## 396   396     bing mobile    false       3       8      120
## 397   397    yahoo tablet    false       6       5      110
## 398   398     bing laptop     true       9       1      709
## 399   399   google tablet     true       5       1       82
## 400   400     bing mobile    false       9       7      147
## 401   401     bing tablet    false       1       9      135
## 402   402     bing laptop    false       0      18      180
## 403   403   social mobile     true       4       1      425
## 404   404    yahoo laptop    false       8       4       52
## 405   405   direct mobile    false      10      17      493
## 406   406     bing mobile    false      10      14      140
## 407   407    yahoo mobile    false       9      11      286
## 408   408    yahoo laptop    false       3       1       29
## 409   409   direct laptop     true       9       1      244
## 410   410    yahoo mobile    false       6       4       52
## 411   411   direct mobile     true       6       1      937
## 412   412    yahoo mobile     true       8       1      449
## 413   413   direct mobile    false       3      10      200
## 414   414     bing tablet    false       7       3       42
## 415   415    yahoo laptop    false       0       4       48
## 416   416   direct laptop    false       6      16      368
## 417   417   social mobile     true       0       1      672
## 418   418   social tablet     true       8       1      425
## 419   419   social mobile    false       6       4       84
## 420   420   google mobile    false      10       4       92
## 421   421    yahoo laptop    false       8       2       42
## 422   422    yahoo laptop    false       5      18      414
## 423   423   google laptop     true       5       1      304
## 424   424     bing tablet     true       8       1      318
## 425   425    yahoo laptop    false       2       7      105
## 426   426    yahoo mobile    false       3      11      176
## 427   427     bing tablet    false       1      19      361
## 428   428   google laptop     true       4       1      985
## 429   429   social tablet     true       9       1      352
## 430   430   direct mobile    false       5      10      140
## 431   431    yahoo tablet     true       1       1      605
## 432   432    yahoo mobile    false       6       1       21
## 433   433   social tablet     true      10       1       81
## 434   434   direct mobile    false       6       3       57
## 435   435   direct mobile    false       5      15      330
## 436   436     bing mobile    false       8      20      380
## 437   437   google laptop     true       0       1      887
## 438   438   direct tablet     true       9       1      732
## 439   439   google tablet    false       0      13      156
## 440   440    yahoo mobile    false      10      16      160
## 441   441     bing laptop     true       3       1      682
## 442   442   direct tablet     true       3       1      632
## 443   443   social tablet     true       7       1      456
## 444   444   direct tablet    false       3       1       21
## 445   445   social tablet    false       2      12      300
## 446   446     bing laptop    false       0       1       21
## 447   447   social laptop     true       0       1      809
## 448   448   google laptop    false       0      19      418
## 449   449    yahoo laptop    false       7       8      216
## 450   450   google laptop     true       7       1      931
## 451   451   google tablet    false       5      20      220
## 452   452   google tablet    false       6      14      406
## 453   453     bing mobile    false       8       2       48
## 454   454   direct tablet     true      10       1      970
## 455   455   social laptop     true       2       1      806
## 456   456     bing mobile    false       2       2       54
## 457   457   social laptop     true       5       1      659
## 458   458   google mobile    false       8       4       52
## 459   459   social tablet     true       3       1      939
## 460   460   social tablet    false       5      20      220
## 461   461     bing tablet    false       8      17      425
## 462   462    yahoo mobile     true       7       1      561
## 463   463   direct laptop     true      10       1      821
## 464   464   google tablet     true       8       1      414
## 465   465   google laptop    false       1      20      220
## 466   466   direct tablet     true       5       1      581
## 467   467    yahoo laptop    false       3      10      280
## 468   468   direct laptop    false       0       1       13
## 469   469    yahoo tablet    false       2      20      320
## 470   470   social mobile    false      10      14      350
## 471   471   social mobile    false       0      10      160
## 472   472   direct tablet    false       6      13      338
## 473   473    yahoo laptop     true       1       1      154
## 474   474   direct laptop     true       0       1       23
## 475   475   google tablet    false       1      18      180
## 476   476   direct mobile     true       9       1      242
## 477   477     bing tablet    false       8       2       42
## 478   478    yahoo laptop    false       6      19      418
## 479   479   social mobile     true      10       1      198
## 480   480     bing tablet     true       5       1      765
## 481   481   social mobile    false       3      13      208
## 482   482     bing tablet     true       7       1      489
## 483   483   google tablet    false       1       5       75
## 484   484   direct laptop    false       4       4       80
## 485   485     bing tablet     true       7       1      423
## 486   486   direct tablet    false       8      17      255
## 487   487     bing laptop    false       1      10      250
## 488   488   google mobile     true       9       1      201
## 489   489   google tablet    false       9       3       48
## 490   490   direct laptop     true       0       1       70
## 491   491   google tablet    false       8       4       80
## 492   492    yahoo laptop    false       3       1       23
## 493   493   direct mobile     true       7       1      797
## 494   494   google laptop     true       0       1      913
## 495   495   google laptop    false       8      18      522
## 496   496   google tablet     true       1       1       82
## 497   497   social mobile     true      10       1      463
## 498   498     bing mobile    false       0       4       72
## 499   499   social tablet    false      10      18      486
## 500   500     bing mobile     true       9       1      574
## 501   501   social mobile     true       1       1      623
## 502   502     bing laptop     true       7       1      516
## 503   503    yahoo mobile     true       9       1      626
## 504   504   social laptop     true      10       1      504
## 505   505     bing tablet    false       8      19      570
## 506   506    yahoo laptop     true       8       1      924
## 507   507   social mobile    false       8       6      168
## 508   508   google laptop    false       8       2       60
## 509   509    yahoo laptop     true       1       1      991
## 510   510   social mobile     true       0       1      436
## 511   511   google tablet     true       6       1       45
## 512   512   direct mobile     true       1       1      477
## 513   513   direct laptop    false       2      12      180
## 514   514     bing mobile    false       9       3       78
## 515   515    yahoo laptop     true       4       1       55
## 516   516     bing mobile     true       1       1      905
## 517   517     bing laptop     true       6       1      802
## 518   518   direct tablet     true       4       1      164
## 519   519   direct tablet     true       5       1      811
## 520   520   social mobile    false       1      10      170
## 521   521   direct laptop    false       4       5       65
## 522   522   google laptop     true       6       1      235
## 523   523     bing tablet    false       4      15      210
## 524   524    yahoo mobile     true       4       1       42
## 525   525   google laptop     true       2       1      731
## 526   526    yahoo tablet    false      10       9      153
## 527   527   direct laptop    false       1      14      322
## 528   528   google mobile     true       1       1      367
## 529   529   social tablet    false      10      10      170
## 530   530   google mobile     true       8       1      219
## 531   531    yahoo tablet     true       8       1      151
## 532   532   google mobile     true       6       1      644
## 533   533   social laptop    false       9      14      224
## 534   534   google tablet     true       8       1      301
## 535   535   google tablet     true       8       1      506
## 536   536   google mobile     true      10       1      221
## 537   537   direct laptop    false       1      19      399
## 538   538   direct laptop    false       7      10      200
## 539   539     bing mobile    false      10      20      560
## 540   540     bing tablet     true       7       1      718
## 541   541     bing laptop     true       5       1      700
## 542   542   google mobile    false      10      10      300
## 543   543   direct tablet     true       1       1      239
## 544   544     bing mobile    false       2      18      198
## 545   545    yahoo laptop    false       7       4       88
## 546   546    yahoo mobile    false      10       6       90
## 547   547   google laptop     true       5       1      376
## 548   548   google mobile    false       0       4       76
## 549   549   social tablet     true       2       1      888
## 550   550   direct tablet    false       7      17      459
## 551   551   social mobile     true      10       1      866
## 552   552   social tablet    false       4       9      261
## 553   553   direct mobile     true      10       1      144
## 554   554   direct tablet    false       8      16      192
## 555   555    yahoo mobile     true      10       1      122
## 556   556    yahoo mobile    false       4      20      260
## 557   557   direct mobile     true       2       1      646
## 558   558   direct laptop     true      10       1      983
## 559   559     bing laptop     true       0       1      973
## 560   560   social laptop     true       4       1      875
## 561   561    yahoo tablet    false       2      10      280
## 562   562   social laptop     true       6       1      986
## 563   563   social tablet    false       5      16      272
## 564   564   google laptop     true       8       1      157
## 565   565   google mobile     true       3       1      229
## 566   566   social tablet     true       5       1      957
## 567   567   google mobile    false       3      18      522
## 568   568    yahoo tablet    false       6      16      192
## 569   569   direct laptop    false       1      20      320
## 570   570   social laptop     true       2       1      274
## 571   571   direct mobile     true      10       1      433
## 572   572   social laptop    false       1       5      110
## 573   573   google laptop     true       3       1      193
## 574   574     bing mobile     true      10       1       98
## 575   575     bing laptop    false       1      19      380
## 576   576   social laptop    false       8       3       30
## 577   577   direct laptop    false       7       7      154
## 578   578   google tablet     true       3       1      523
## 579   579   google tablet    false       2       4       64
## 580   580     bing laptop     true       7       1      362
## 581   581   google laptop     true       8       1      470
## 582   582   social mobile    false       1      15      405
## 583   583   social laptop    false       1      20      420
## 584   584     bing mobile     true       0       1      686
## 585   585   direct tablet     true       0       1      840
## 586   586   direct laptop     true       2       1      212
## 587   587   direct mobile     true       2       1      206
## 588   588    yahoo mobile     true       4       1       69
## 589   589   social tablet     true       7       1      811
## 590   590   social laptop     true       7       1      991
## 591   591   direct laptop     true       2       1      624
## 592   592   google mobile    false       8      11      198
## 593   593   direct mobile    false       2       5      150
## 594   594   direct laptop     true       3       1      307
## 595   595    yahoo tablet     true       9       1      530
## 596   596   social mobile     true       1       1      958
## 597   597     bing tablet    false       2       5      150
## 598   598    yahoo tablet     true      10       1      668
## 599   599    yahoo mobile     true       8       1      160
## 600   600     bing laptop    false       9      13      299
## 601   601   direct laptop     true       7       1      262
## 602   602   google mobile    false       3      12      312
## 603   603   google mobile     true       7       1      414
## 604   604     bing tablet     true       6       1      567
## 605   605   google laptop    false       2      17      391
## 606   606   social tablet    false       9      17      459
## 607   607   google mobile     true       3       1      412
## 608   608   direct laptop     true       2       1      386
## 609   609   google tablet    false       6      17      476
## 610   610    yahoo laptop     true       4       1       50
## 611   611    yahoo mobile     true       1       1      710
## 612   612   social mobile    false       1      16      336
## 613   613     bing laptop    false       0      12      144
## 614   614    yahoo laptop    false       1       2       30
## 615   615   social laptop     true       1       1       10
## 616   616   google laptop     true       9       1      673
## 617   617   social tablet     true       5       1      634
## 618   618     bing laptop     true       6       1      384
## 619   619     bing laptop     true      10       1      947
## 620   620     bing tablet    false       1       8      144
## 621   621   direct mobile    false       2      12      348
## 622   622   google mobile    false       2       8      184
## 623   623    yahoo tablet     true       1       1      441
## 624   624     bing laptop    false       8       3       57
## 625   625   social mobile    false       7       8      216
## 626   626   direct tablet    false       9       6      102
## 627   627   direct laptop     true       1       1      251
## 628   628    yahoo tablet    false       7       7      168
## 629   629   direct tablet     true       2       1      184
## 630   630   social mobile    false       3      20      440
## 631   631   social tablet     true      10       1      478
## 632   632   social tablet    false       0      14      406
## 633   633   direct mobile    false       6      17      459
## 634   634   social mobile    false       8       9      225
## 635   635   google laptop     true       2       1      154
## 636   636   google laptop    false      10      18      450
## 637   637    yahoo tablet     true       7       1      889
## 638   638   google mobile     true       3       1      545
## 639   639   direct mobile     true       1       1      180
## 640   640   social mobile    false       8       4      100
## 641   641   direct laptop     true       6       1      140
## 642   642    yahoo laptop    false       0      18      522
## 643   643   direct tablet    false       7      12      192
## 644   644     bing laptop    false       5      18      234
## 645   645   google laptop    false       8      16      464
## 646   646   social tablet    false       8      11      143
## 647   647   social laptop     true       5       1      592
## 648   648    yahoo mobile     true       3       1      151
## 649   649   direct laptop    false       7       4       52
## 650   650   google laptop     true       3       1      565
## 651   651   social laptop    false       0      17      204
## 652   652     bing tablet    false       6       9      198
## 653   653   direct mobile     true       6       1      501
## 654   654   direct mobile    false      10      17      272
## 655   655     bing mobile     true       6       1      604
## 656   656     bing laptop    false       0      13      390
## 657   657     bing laptop     true       3       1      396
## 658   658   google laptop     true       3       1      369
## 659   659   direct mobile    false       5      13      325
## 660   660   direct tablet     true       7       1      281
## 661   661    yahoo laptop     true       1       1       63
## 662   662   google tablet    false       5       2       54
## 663   663   google tablet     true       2       1      614
## 664   664   direct laptop    false       8      11      154
## 665   665    yahoo mobile    false       4      16      272
## 666   666   social mobile     true       9       1      425
## 667   667   google mobile    false       4      20      420
## 668   668    yahoo mobile     true       9       1      773
## 669   669    yahoo tablet     true       0       1      238
## 670   670     bing tablet    false       5      20      540
## 671   671   google laptop    false       2      13      169
## 672   672   google tablet     true       6       1      250
## 673   673     bing mobile    false      10       7      119
## 674   674   google mobile     true       7       1      726
## 675   675   social mobile    false       6       6       96
## 676   676     bing laptop     true       8       1      585
## 677   677   direct tablet     true      10       1      682
## 678   678   google mobile    false       3      13      364
## 679   679    yahoo laptop     true       3       1      541
## 680   680   google tablet     true       5       1      978
## 681   681     bing mobile     true       8       1      195
## 682   682   direct tablet    false       5      18      414
## 683   683   direct mobile     true       8       1      310
## 684   684    yahoo tablet     true       5       1      386
## 685   685   social laptop    false       0      11      187
## 686   686   direct tablet    false       1       2       48
## 687   687   direct laptop    false       1      10      120
## 688   688   social mobile     true       2       1       12
## 689   689     bing mobile    false       4       2       22
## 690   690    yahoo mobile    false       5       8       80
## 691   691   social tablet    false       9      15      405
## 692   692   social laptop    false       5       2       26
## 693   693   social tablet    false       3       2       56
## 694   694   direct laptop     true       3       1      700
## 695   695   direct mobile     true       9       1      291
## 696   696   google mobile     true       7       1       67
## 697   697     bing tablet     true       0       1      356
## 698   698   google mobile    false       7      12      288
## 699   699   social mobile     true       8       1      619
## 700   700     bing tablet    false       9      10      210
## 701   701    yahoo tablet    false       1      10      110
## 702   702   social tablet     true       8       1      235
## 703   703   direct mobile    false      10      19      380
## 704   704    yahoo laptop    false       1      11      231
## 705   705     bing laptop     true       3       1      271
## 706   706   google tablet    false       3      18      468
## 707   707   google tablet    false       1      11      220
## 708   708    yahoo laptop    false       7       6      150
## 709   709     bing mobile     true       6       1      966
## 710   710   google mobile    false       6       9      135
## 711   711    yahoo tablet    false       7      19      304
## 712   712   google mobile    false       7      19      456
## 713   713   social tablet    false      10      10      290
## 714   714   direct tablet    false       2      18      540
## 715   715   google laptop    false      10      18      450
## 716   716   social tablet     true       5       1      878
## 717   717    yahoo laptop     true       2       1      731
## 718   718    yahoo mobile     true       3       1      415
## 719   719   direct tablet    false      10      14      252
## 720   720   direct laptop     true       4       1      896
## 721   721   google mobile    false       4      16      416
## 722   722     bing mobile     true      10       1      847
## 723   723   google mobile    false       5       3       66
## 724   724     bing laptop     true       3       1      550
## 725   725   direct laptop    false       6      14      336
## 726   726   google mobile     true       0       1      132
## 727   727     bing mobile     true       5       1      541
## 728   728   direct tablet     true       8       1      528
## 729   729   google laptop    false       0       3       45
## 730   730   social mobile     true       5       1      155
## 731   731   social laptop    false       8       7      105
## 732   732    yahoo mobile    false       4      18      468
## 733   733   google laptop     true       4       1      164
## 734   734     bing mobile     true       3       1      479
## 735   735    yahoo tablet    false       5      20      500
## 736   736     bing tablet    false       1      14      168
## 737   737   google mobile     true       9       1      994
## 738   738    yahoo mobile     true      10       1      761
## 739   739   social mobile     true       9       1      729
## 740   740     bing mobile    false       9       2       24
## 741   741   direct tablet    false       1       3       69
## 742   742   google mobile     true       2       1      337
## 743   743     bing tablet    false       1      18      180
## 744   744     bing tablet     true       2       1      489
## 745   745   direct mobile     true       5       1      352
## 746   746    yahoo laptop    false       0      13      208
## 747   747    yahoo mobile    false      10       7      140
## 748   748    yahoo mobile     true       7       1      124
## 749   749     bing laptop    false       0      17      272
## 750   750   social laptop     true       1       1      111
## 751   751     bing tablet     true       4       1      892
## 752   752   google mobile     true       0       1      851
## 753   753    yahoo laptop    false       7      16      320
## 754   754   google mobile     true       9       1      409
## 755   755   google tablet    false       8       3       69
## 756   756    yahoo tablet    false       6       8      224
## 757   757    yahoo tablet     true       1       1      263
## 758   758   direct tablet     true       4       1      141
## 759   759   google tablet    false       8       2       60
## 760   760   social tablet    false       9       6      114
## 761   761     bing mobile    false       1      18      252
## 762   762   direct laptop     true       2       1      578
## 763   763   social laptop     true       4       1      186
## 764   764    yahoo mobile     true       9       1      919
## 765   765     bing laptop    false       8      10      260
## 766   766   google laptop     true       6       1      402
## 767   767   direct tablet    false       5      12      144
## 768   768     bing tablet    false       2      17      510
## 769   769     bing mobile    false      10       8      176
## 770   770     bing laptop    false       8       6      180
## 771   771   direct tablet     true       1       1      946
## 772   772   social mobile    false       6       9      126
## 773   773     bing laptop     true       1       1      169
## 774   774   direct laptop     true       0       1       93
## 775   775   social laptop    false       8       3       66
## 776   776   direct mobile    false       7      19      570
## 777   777   direct mobile     true       8       1      886
## 778   778   social mobile     true       3       1      876
## 779   779   social laptop     true       4       1      866
## 780   780   direct mobile    false       7      15      210
## 781   781   google laptop     true       2       1      863
## 782   782   direct mobile     true       1       1      129
## 783   783   social laptop     true      10       1       45
## 784   784   direct tablet    false       6      20      540
## 785   785   direct tablet    false       3      10      260
## 786   786    yahoo mobile    false       8       5      115
## 787   787     bing mobile     true       9       1      638
## 788   788    yahoo mobile    false       9       7      147
## 789   789     bing laptop    false      10      17      493
## 790   790    yahoo tablet     true       2       1      772
## 791   791   google mobile    false       3      16      256
## 792   792   social laptop    false       1       4       64
## 793   793     bing laptop     true       5       1      135
## 794   794   direct mobile    false       2       9      243
## 795   795   direct tablet     true       8       1      404
## 796   796   google tablet    false       3       8      112
## 797   797    yahoo tablet     true      10       1      406
## 798   798   direct laptop     true       4       1      158
## 799   799    yahoo mobile    false      10       7       77
## 800   800   social tablet     true       4       1      392
## 801   801     bing mobile    false       5      14      140
## 802   802   direct mobile    false       8      15      180
## 803   803    yahoo laptop     true       8       1      630
## 804   804   social tablet    false       0       2       46
## 805   805   google tablet    false       8       3       33
## 806   806   social mobile    false       0       1       30
## 807   807   google tablet     true       0       1      755
## 808   808     bing mobile     true       8       1      202
## 809   809    yahoo mobile    false       1      19      399
## 810   810     bing mobile     true       3       1      119
## 811   811   social tablet    false       3      15      435
## 812   812     bing mobile    false       1      12      168
## 813   813   direct laptop    false       0      14      252
## 814   814   google mobile    false       9       1       23
## 815   815    yahoo mobile    false       7      19      494
## 816   816    yahoo tablet     true       5       1      251
## 817   817   social laptop     true       6       1      426
## 818   818   social mobile     true       4       1      662
## 819   819   google mobile     true       0       1      134
## 820   820   google tablet    false       1       9       90
## 821   821   social tablet    false       8       6      156
## 822   822     bing laptop    false       4      11      198
## 823   823   social mobile    false       7      12      132
## 824   824    yahoo laptop     true       2       1      997
## 825   825   direct laptop    false       6      17      204
## 826   826   direct mobile     true       7       1      764
## 827   827   google tablet    false       5      20      280
## 828   828     bing tablet    false       3      15      390
## 829   829   google laptop    false       3      20      460
## 830   830   google mobile     true       3       1      918
## 831   831   google tablet     true      10       1      512
## 832   832   direct tablet     true       1       1      103
## 833   833   direct mobile    false       5       8      112
## 834   834    yahoo tablet    false       8       3       36
## 835   835     bing tablet     true       4       1      585
## 836   836   social laptop     true       0       1      651
## 837   837    yahoo mobile     true       7       1      632
## 838   838    yahoo mobile    false      10       7      126
## 839   839   social laptop    false       8      15      240
## 840   840   direct laptop    false       0       7      161
## 841   841    yahoo tablet    false       7      18      198
## 842   842   social laptop    false       8      13      364
## 843   843   google mobile    false       4      10      200
## 844   844   social tablet     true       5       1      752
## 845   845   social tablet    false       0       7      175
## 846   846   direct tablet     true       9       1      709
## 847   847    yahoo mobile     true       0       1      895
## 848   848     bing mobile    false       6      20      480
## 849   849    yahoo tablet    false       9       2       54
## 850   850     bing tablet     true       3       1      134
## 851   851   direct laptop     true       2       1      111
## 852   852     bing tablet     true       0       1      845
## 853   853     bing tablet    false       7       2       34
## 854   854     bing tablet     true       5       1      999
## 855   855   direct laptop     true       5       1      973
## 856   856   social laptop     true       8       1      903
## 857   857   google tablet     true       7       1      693
## 858   858   google tablet     true       6       1      551
## 859   859    yahoo tablet     true       0       1      800
## 860   860   google tablet    false       5      10      180
## 861   861    yahoo tablet     true       1       1      339
## 862   862    yahoo laptop     true       7       1       55
## 863   863   social tablet     true       5       1      387
## 864   864   direct mobile    false      10       3       33
## 865   865   social tablet     true       1       1      609
## 866   866   social mobile    false       3       8      184
## 867   867   social tablet     true       5       1       50
## 868   868   google tablet    false       9      14      308
## 869   869     bing laptop     true       6       1      199
## 870   870   social mobile     true       6       1      193
## 871   871    yahoo mobile    false       0      15      255
## 872   872   direct mobile     true       2       1      217
## 873   873   direct tablet    false       4       2       26
## 874   874    yahoo mobile    false       8       4      112
## 875   875   direct laptop    false       2       4       80
## 876   876   direct laptop    false       4       2       44
## 877   877   social mobile    false       0       8      160
## 878   878    yahoo laptop     true       7       1      163
## 879   879   google mobile    false       2      15      210
## 880   880   direct mobile     true       2       1      357
## 881   881   google mobile     true       7       1      301
## 882   882   direct laptop    false       1      14      364
## 883   883    yahoo mobile     true       4       1      377
## 884   884   direct tablet    false       0      18      252
## 885   885   social laptop     true       7       1      403
## 886   886     bing mobile    false       0      16      272
## 887   887   google tablet    false       2      14      266
## 888   888     bing tablet    false      10      17      442
## 889   889   google mobile    false       5      16      320
## 890   890   social laptop     true       0       1       52
## 891   891     bing tablet    false       4      15      405
## 892   892   google tablet     true       8       1      891
## 893   893    yahoo laptop    false       2       9      162
## 894   894     bing laptop     true       9       1      162
## 895   895     bing tablet     true       0       1      425
## 896   896    yahoo mobile    false       9       4      100
## 897   897   direct mobile    false       1      17      187
## 898   898     bing laptop    false       7       8      112
## 899   899   direct tablet     true       0       1      803
## 900   900   social tablet    false       1      19      399
## 901   901    yahoo mobile    false       5      12      252
## 902   902   social laptop     true       2       1      297
## 903   903   google laptop    false       4       9      117
## 904   904   social tablet     true       9       1      509
## 905   905     bing tablet    false       5      18      216
## 906   906    yahoo tablet    false       9       2       34
## 907   907   google tablet    false       7       5       60
## 908   908   google laptop     true       5       1      484
## 909   909     bing mobile    false       6      18      342
## 910   910   google laptop    false      10       4       60
## 911   911     bing tablet    false       5       8      216
## 912   912   google laptop     true      10       1      579
## 913   913   direct laptop    false       2      18      324
## 914   914     bing mobile    false       4       2       46
## 915   915   social mobile    false       7       1       22
## 916   916   social mobile    false       7      12      192
## 917   917    yahoo laptop     true       2       1      653
## 918   918   google mobile     true       5       1      988
## 919   919   direct laptop     true       5       1      190
## 920   920    yahoo mobile     true       6       1       47
## 921   921     bing tablet    false       1      20      280
## 922   922   google tablet    false       8      10      210
## 923   923   google mobile    false       5      15      150
## 924   924   social tablet    false      10      11      330
## 925   925    yahoo laptop     true       2       1       83
## 926   926    yahoo mobile    false       5       2       50
## 927   927   social tablet    false       1       7       77
## 928   928     bing mobile     true       5       1      475
## 929   929   social tablet     true       3       1      111
## 930   930   social tablet    false       5      10      200
## 931   931   direct tablet    false      10      18      324
## 932   932   google laptop    false       2      17      391
## 933   933   google mobile    false       9       6       96
## 934   934    yahoo mobile    false       1      17      442
## 935   935   social tablet     true       1       1      449
## 936   936   google mobile    false       1      20      320
## 937   937   google mobile    false       3      10      190
## 938   938   google laptop     true       5       1      951
## 939   939   google tablet     true       5       1      391
## 940   940    yahoo tablet     true       4       1      326
## 941   941   direct tablet    false       8       5       50
## 942   942   google tablet     true       6       1      966
## 943   943   social tablet     true       5       1      667
## 944   944    yahoo mobile    false       7      15      345
## 945   945    yahoo tablet    false       6       6       90
## 946   946   direct mobile    false       1      15      180
## 947   947   social tablet     true       9       1      157
## 948   948   social tablet    false      10      13      247
## 949   949     bing mobile    false      10       1       26
## 950   950     bing mobile    false       6      12      144
## 951   951    yahoo tablet    false       4       1       17
## 952   952     bing tablet    false       4      15      435
## 953   953    yahoo mobile    false       5       5      150
## 954   954   google tablet     true       8       1      617
## 955   955   google mobile     true       6       1      965
## 956   956   google laptop     true       3       1      561
## 957   957   google tablet    false       3      13      338
## 958   958   direct tablet     true       4       1      136
## 959   959   direct mobile    false       1       9      135
## 960   960    yahoo laptop    false       2       8      232
## 961   961   direct tablet    false       3      18      522
## 962   962    yahoo laptop     true       6       1      801
## 963   963     bing laptop     true       4       1      857
## 964   964     bing mobile     true       4       1      247
## 965   965   google laptop    false       2       6      174
## 966   966   social tablet     true       7       1      849
## 967   967   social laptop    false       6      10      150
## 968   968   google tablet    false       4      16      448
## 969   969     bing laptop     true      10       1      210
## 970   970   direct laptop     true       8       1      913
## 971   971   google laptop     true       0       1      637
## 972   972   google mobile     true       4       1      425
## 973   973   social mobile     true       4       1      305
## 974   974    yahoo tablet     true       3       1      212
## 975   975     bing tablet    false      10       2       38
## 976   976   google tablet    false       1       7      112
## 977   977   google laptop     true       6       1      369
## 978   978   direct laptop     true       1       1      433
## 979   979   social tablet    false       3       4       44
## 980   980    yahoo mobile    false       7       6      102
## 981   981   google mobile     true       2       1       85
## 982   982    yahoo tablet     true       0       1      929
## 983   983    yahoo mobile     true       3       1      636
## 984   984   google mobile     true       1       1      934
## 985   985   social mobile    false      10      17      459
## 986   986   google laptop     true       7       1       79
## 987   987     bing laptop    false       4      11      187
## 988   988   direct laptop    false       0      15      255
## 989   989    yahoo laptop    false       2      12      144
## 990   990   social laptop     true       7       1      122
## 991   991    yahoo mobile    false       8      11      330
## 992   992   social tablet    false       5      17      306
## 993   993   direct tablet     true       6       1      961
## 994   994   google tablet     true       2       1      239
## 995   995   google tablet    false       7      12      156
## 996   996    yahoo mobile     true       9       1      123
## 997   997   google laptop    false       6      13      325
## 998   998   social tablet     true       4       1      118
## 999   999    yahoo mobile     true       1       1      714
## 1000 1000   google mobile     true       9       1      269
##                               country purchase order_items order_value
## 1                      Czech Republic    false           0           0
## 2                               Yemen    false           0           0
## 3                              Brazil    false           0           0
## 4                               China     true           6         434
## 5                              Poland    false           0           0
## 6                        South Africa    false           0           0
## 7                          Bangladesh    false           0           0
## 8                           Indonesia    false           0           0
## 9                         Netherlands    false           0           0
## 10                     Czech Republic    false           0           0
## 11                            Jamaica    false           0           0
## 12                            Estonia    false           0           0
## 13                            Ireland     true           3         651
## 14                        Philippines    false           2         362
## 15                             France    false           7        2423
## 16                      United States    false           0           0
## 17                               Peru     true           6        1049
## 18                              China    false           0           0
## 19                           Colombia     true           9        1304
## 20                            Namibia    false           7        2077
## 21                              China    false           0           0
## 22                             Brazil    false           0           0
## 23                             Russia    false           4         237
## 24                            Ukraine    false           0           0
## 25                             Brazil    false           0           0
## 26                          Australia    false           0           0
## 27                              Japan     true           5         622
## 28                             Russia    false           0           0
## 29                             Russia    false           0           0
## 30                           Colombia    false           0           0
## 31                              Japan    false           0           0
## 32                        El Salvador    false           0           0
## 33                           Colombia    false           0           0
## 34                          Indonesia     true           7        1613
## 35                          Argentina    false           0           0
## 36                            Ireland    false          10        1885
## 37                            Vietnam    false           0           0
## 38                             Canada    false           0           0
## 39                             Sweden    false           0           0
## 40                           Cameroon    false           0           0
## 41                     Czech Republic     true           3         184
## 42                          Indonesia    false           0           0
## 43                           Portugal    false           0           0
## 44                            Somalia    false           0           0
## 45                              China    false           0           0
## 46                          Indonesia    false           0           0
## 47                             Sweden    false           0           0
## 48                            Uruguay    false           0           0
## 49                             France    false          10        1515
## 50                               Iran    false           0           0
## 51                              China    false           0           0
## 52                             Brazil    false           0           0
## 53                              China    false           0           0
## 54                            Nigeria    false           0           0
## 55                      United States    false           0           0
## 56                           Colombia    false           0           0
## 57                             Russia    false           2        1532
## 58                             Brazil    false           0           0
## 59                        Philippines    false           0           0
## 60                             Russia    false           0           0
## 61                             Greece    false           0           0
## 62                        Philippines    false           0           0
## 63                              China    false           0           0
## 64                             Latvia    false           6        2798
## 65                            Finland    false           9         370
## 66                              China    false           0           0
## 67                             France    false           0           0
## 68                             France    false           0           0
## 69                       Turkmenistan    false           0           0
## 70                              China    false           0           0
## 71                             Brazil    false           0           0
## 72                             Panama    false           5        2216
## 73                              China    false           0           0
## 74                             Brazil    false           0           0
## 75                             Russia    false           0           0
## 76                             Russia    false           3         632
## 77                               Peru    false           0           0
## 78                             Russia    false           0           0
## 79                          Nicaragua    false           0           0
## 80                          Indonesia    false           0           0
## 81                          Indonesia    false           0           0
## 82                           Thailand    false           0           0
## 83                            Ecuador    false           0           0
## 84                             Sweden    false           0           0
## 85                       Sierra Leone    false           0           0
## 86                            Austria    false           0           0
## 87                             Sweden    false           0           0
## 88                        Philippines    false           0           0
## 89                            Ecuador    false           1        2001
## 90                          Indonesia    false           0           0
## 91                          Indonesia    false           0           0
## 92                          Indonesia    false           1        1273
## 93                             Poland    false           0           0
## 94                              China     true           9         286
## 95                           Portugal    false           0           0
## 96                              China    false           4         722
## 97   Democratic Republic of the Congo    false           0           0
## 98                           Portugal     true           6         764
## 99                          Indonesia    false           0           0
## 100                          Portugal    false           0           0
## 101                            Poland     true           6        1667
## 102                           Bahamas    false           3         583
## 103                          Portugal    false           0           0
## 104                            France    false           0           0
## 105                            Mexico    false           0           0
## 106                             China    false           0           0
## 107                            Brazil    false           0           0
## 108                             China    false           0           0
## 109                             Chile    false           0           0
## 110                            Russia    false           0           0
## 111                            Bhutan    false           0           0
## 112                         Argentina     true           4         287
## 113                         Sri Lanka    false           3        1482
## 114                            Brazil    false           0           0
## 115                             Ghana    false           9        2514
## 116                         Indonesia    false           0           0
## 117                         Swaziland    false           0           0
## 118                            Brazil    false           0           0
## 119                             China    false           0           0
## 120                             China    false           6        1772
## 121                            Russia    false           0           0
## 122                         Argentina    false           0           0
## 123                             Yemen    false           0           0
## 124                         Indonesia    false           0           0
## 125                             China     true           3        1443
## 126                              Peru    false           0           0
## 127                           Belarus    false           0           0
## 128                     United States    false           0           0
## 129                            Brazil    false           0           0
## 130                             Italy    false           0           0
## 131                            France    false           2         489
## 132                             Chile    false           0           0
## 133                            Poland    false           0           0
## 134                         Indonesia     true           3        2449
## 135                         Indonesia    false           0           0
## 136                         Indonesia    false           0           0
## 137                          Thailand    false           0           0
## 138                             China    false           0           0
## 139                            Greece    false           9         287
## 140                            Sweden    false           0           0
## 141                             Japan    false           0           0
## 142                            Brazil    false           0           0
## 143                            Sweden     true          10        2824
## 144                             Japan    false           0           0
## 145                          Portugal     true           6        2086
## 146                            Greece    false           0           0
## 147                            Panama    false           1        2055
## 148                             China    false           0           0
## 149                            Sweden    false           2         393
## 150                             China    false           0           0
## 151                            Russia    false           0           0
## 152                         Argentina    false           3         907
## 153                             China    false           0           0
## 154                             China    false           0           0
## 155                            Brazil    false           0           0
## 156                             China     true           3        1670
## 157                     Faroe Islands    false           0           0
## 158                       Philippines     true           2        1358
## 159                           Finland     true           3        1833
## 160                       Philippines    false           0           0
## 161                              Peru    false           0           0
## 162                           Ukraine    false           0           0
## 163                       Netherlands    false           0           0
## 164                            Russia    false           0           0
## 165                           Vietnam    false           0           0
## 166                             Sudan     true           5        1155
## 167                          Honduras    false           8         837
## 168                             China    false           0           0
## 169                           Albania    false           0           0
## 170                     United States    false           0           0
## 171             Republic of the Congo    false           0           0
## 172                            Sweden    false           0           0
## 173                            Russia    false           5         358
## 174                         Indonesia    false           0           0
## 175                          Colombia    false           0           0
## 176                        Madagascar    false           0           0
## 177                          Thailand    false           3        1252
## 178                         Indonesia    false           0           0
## 179                           Nigeria    false           0           0
## 180                             China    false           0           0
## 181                            Poland    false           0           0
## 182                         Indonesia    false           8        2429
## 183                    Czech Republic    false           0           0
## 184                           Ireland    false           0           0
## 185                       Philippines    false           0           0
## 186                             China    false           0           0
## 187                            Brazil    false           1        1286
## 188                             China    false           0           0
## 189                          Pakistan    false           0           0
## 190                            Brazil    false           0           0
## 191                       New Zealand    false           0           0
## 192                             China    false           0           0
## 193                     United States    false           4        1578
## 194                           Belarus    false           0           0
## 195                            Poland    false           0           0
## 196                            Russia    false           0           0
## 197                            Greece    false           0           0
## 198                           Ukraine    false           0           0
## 199                             China    false           0           0
## 200                         Argentina    false           0           0
## 201                           Armenia    false           0           0
## 202                            Brazil    false           0           0
## 203                            Serbia    false           0           0
## 204                            Russia    false           0           0
## 205                       South Korea    false           0           0
## 206                           Somalia    false           0           0
## 207                             China    false           0           0
## 208                           Denmark    false           1         178
## 209                            Serbia    false           0           0
## 210                         Guatemala    false           0           0
## 211                         Nicaragua    false           0           0
## 212                     United States    false           0           0
## 213                             China    false           0           0
## 214                            France    false           0           0
## 215                           Denmark    false           0           0
## 216                            Brazil    false           0           0
## 217                            Poland    false           4        1758
## 218             Palestinian Territory    false           0           0
## 219                     United States     true           5        1021
## 220                          Portugal    false           0           0
## 221                         Indonesia     true           9        2208
## 222                         Indonesia    false           4        2373
## 223                         Indonesia    false           0           0
## 224                           Ukraine    false           0           0
## 225                            Norway     true          10        1257
## 226                            Mexico    false           0           0
## 227                     United States     true          10         288
## 228                            Mexico    false           0           0
## 229                            Greece    false           0           0
## 230                        Costa Rica    false           0           0
## 231                          Portugal    false           0           0
## 232                       Afghanistan    false           0           0
## 233                             China    false           0           0
## 234                          Portugal    false           0           0
## 235                            Brazil    false           0           0
## 236                            Poland    false           0           0
## 237                             China    false           0           0
## 238                            Brazil    false           0           0
## 239                              Peru    false           0           0
## 240                            France    false           0           0
## 241                       Netherlands    false           6        1537
## 242                             China    false           0           0
## 243                            Russia    false           0           0
## 244                          Colombia    false           0           0
## 245                            Brazil    false           0           0
## 246                             China    false           0           0
## 247                             China    false           0           0
## 248                         Macedonia    false           0           0
## 249             Palestinian Territory    false           0           0
## 250                            Russia    false           0           0
## 251                             China    false           6        2157
## 252                         Indonesia    false           0           0
## 253                            Sweden     true           7        2091
## 254            Bosnia and Herzegovina     true           3         343
## 255                              Peru    false           0           0
## 256                          Honduras    false          10        2629
## 257                     United States    false           0           0
## 258                          Portugal    false           0           0
## 259                             Kenya    false           0           0
## 260                        Costa Rica     true           3        2992
## 261                            France    false           0           0
## 262                            France    false           0           0
## 263                              Cuba    false           0           0
## 264                    Czech Republic    false           0           0
## 265                             Japan    false           0           0
## 266                             Japan    false           0           0
## 267                            Brazil    false           0           0
## 268                             China    false           0           0
## 269                         Indonesia    false           6        2633
## 270                            Russia    false           5         947
## 271                             China    false          10        2367
## 272                             China    false           0           0
## 273                         Indonesia    false           0           0
## 274                            France     true          10         813
## 275                             China    false           0           0
## 276                         Indonesia    false           0           0
## 277                             China    false           8        1179
## 278                            Norway    false           0           0
## 279                            Sweden    false           4        2251
## 280                           Vietnam    false           0           0
## 281                            Canada    false           0           0
## 282                          Malaysia    false           0           0
## 283                            Brazil    false           0           0
## 284                              Peru    false           0           0
## 285                         Indonesia    false           0           0
## 286                             China    false           0           0
## 287                             Italy    false           0           0
## 288                          Honduras    false           3        2929
## 289                              Cuba    false           0           0
## 290                            Russia     true           2        2896
## 291                          Colombia    false           0           0
## 292                            Canada     true           5        1748
## 293                            Panama    false           0           0
## 294                            France    false           1         610
## 295                            Poland    false           0           0
## 296                           Ukraine    false           0           0
## 297                            Poland    false           0           0
## 298                           Armenia    false           4        1203
## 299                       Afghanistan    false           0           0
## 300                             Libya    false           0           0
## 301                          Thailand    false           1        1152
## 302                            Greece    false           0           0
## 303                        Madagascar    false           0           0
## 304                         Venezuela    false           0           0
## 305                         Argentina    false           6         631
## 306                       Philippines    false           9         632
## 307                            Greece    false           0           0
## 308                             China    false           0           0
## 309                            Canada    false           0           0
## 310                            Malawi    false           0           0
## 311                        Bangladesh    false           0           0
## 312            Bosnia and Herzegovina     true           4        2578
## 313                             China    false           0           0
## 314                             China    false           0           0
## 315                             China    false           0           0
## 316                            Sweden    false           0           0
## 317                            Poland     true           3        1753
## 318                          Portugal    false           0           0
## 319                    United Kingdom    false           6        2894
## 320                            Sweden    false           3        2716
## 321                       New Zealand    false           9        2433
## 322                           Uruguay    false           0           0
## 323                            Brazil    false           0           0
## 324                             Niger     true           2        2488
## 325                            Poland    false           0           0
## 326                          Colombia    false           0           0
## 327                          Bulgaria    false           0           0
## 328                         Nicaragua     true           1         714
## 329                            Sweden    false           0           0
## 330                             China    false           1        1560
## 331                          Bulgaria    false           0           0
## 332                           Nigeria    false           0           0
## 333                           Armenia    false           0           0
## 334                            Russia    false           0           0
## 335                             China    false           0           0
## 336                            Brazil    false           0           0
## 337                             China    false           0           0
## 338                           Nigeria    false           0           0
## 339                             Japan    false           0           0
## 340                             China    false           0           0
## 341                            Russia     true           7        2274
## 342                             China    false           0           0
## 343                             China    false           0           0
## 344                             China    false           0           0
## 345                             China    false           0           0
## 346                          Djibouti     true           3        2028
## 347                       Philippines    false           0           0
## 348                             Japan     true           1        2011
## 349                             China    false           0           0
## 350                          Malaysia     true           6        2765
## 351                             China    false           0           0
## 352                           Ukraine     true           3        2636
## 353                           Croatia    false           0           0
## 354                              Peru    false           0           0
## 355                          Thailand     true           6        1648
## 356                             Yemen    false           0           0
## 357                          Malaysia    false           0           0
## 358                         Nicaragua    false           0           0
## 359                           Armenia     true           6        2694
## 360                            Canada    false           0           0
## 361                       Philippines    false           0           0
## 362                         Macedonia     true           9        2281
## 363                    Czech Republic    false           0           0
## 364                             Kenya    false           0           0
## 365                            Greece    false           0           0
## 366                             China    false           0           0
## 367                         Indonesia    false           0           0
## 368                           Belgium    false           0           0
## 369                         Indonesia    false           0           0
## 370                        Azerbaijan    false           0           0
## 371                          Colombia    false           0           0
## 372                          Pakistan    false           0           0
## 373                          Portugal    false           0           0
## 374                         Indonesia    false           0           0
## 375                        Kyrgyzstan    false           0           0
## 376                         Indonesia    false           0           0
## 377                            Mexico    false           0           0
## 378                         Indonesia    false           0           0
## 379                             China    false           0           0
## 380                           Ukraine    false           0           0
## 381                             China    false           0           0
## 382                            Russia    false           0           0
## 383                           Croatia     true           4        2057
## 384                           Finland    false           0           0
## 385                          Portugal    false           0           0
## 386                            Russia    false           0           0
## 387                             China    false           0           0
## 388                        Uzbekistan    false           0           0
## 389                         Indonesia    false           0           0
## 390                         Macedonia    false           6        1629
## 391                           Comoros    false           1        1652
## 392                         Indonesia    false           0           0
## 393                             China    false           0           0
## 394                         Indonesia    false           0           0
## 395                             China    false           9        1662
## 396                             China    false           5         472
## 397                             China    false           9        1508
## 398                             China    false           0           0
## 399                         Indonesia    false           0           0
## 400                            Poland    false           2         139
## 401                        Tajikistan    false           0           0
## 402                            Russia    false           0           0
## 403                            Russia    false           0           0
## 404                            Greece    false          10        2482
## 405                         Indonesia    false           0           0
## 406                              Peru    false           0           0
## 407                             China     true           8         312
## 408                             China    false           4        2605
## 409                          Portugal    false           0           0
## 410                             China    false          10        1255
## 411                             China    false           0           0
## 412                            Brazil    false           0           0
## 413                           Liberia    false           0           0
## 414                        Madagascar    false           4         260
## 415                          Colombia    false           0           0
## 416                             China     true           7        1729
## 417                            France    false           0           0
## 418                             China    false           0           0
## 419                Dominican Republic    false           0           0
## 420                            Brazil    false          10        2144
## 421                             China    false          10        1288
## 422                         Indonesia    false           0           0
## 423                           Albania    false           0           0
## 424                     United States    false           0           0
## 425                            Cyprus    false          10        1912
## 426                           Belarus    false           6        2642
## 427                    Czech Republic     true           5          44
## 428                        Kazakhstan    false           0           0
## 429                             China    false           0           0
## 430                           Ukraine    false           0           0
## 431                            Russia    false           0           0
## 432                            Russia    false           0           0
## 433                            Brazil    false           0           0
## 434                            Serbia    false           2        1436
## 435                         Indonesia    false           0           0
## 436                         Argentina    false           0           0
## 437                          Colombia    false           0           0
## 438                             China    false           0           0
## 439                             Chile    false           9         969
## 440                       Philippines    false           3        1625
## 441                     United States    false           0           0
## 442                           Jamaica    false           0           0
## 443                             China    false           0           0
## 444                       Philippines    false           4         793
## 445                       Philippines     true           2        2754
## 446                         Indonesia    false           0           0
## 447                             China    false           0           0
## 448                           Ukraine     true           2         996
## 449                         Indonesia    false           0           0
## 450                         Hong Kong    false           0           0
## 451                             China    false           0           0
## 452                        East Timor    false           0           0
## 453                             China    false          10        2826
## 454                             Syria    false           0           0
## 455                            Brazil    false           0           0
## 456                           Albania    false          10        2182
## 457                         Argentina    false           0           0
## 458                       Philippines    false           0           0
## 459                             China    false           0           0
## 460             Republic of the Congo    false           5        1743
## 461                            Russia    false           0           0
## 462                           Croatia    false           0           0
## 463                            Canada    false           0           0
## 464                             Yemen    false           0           0
## 465                            France    false           7        1436
## 466                             China    false           0           0
## 467                              Peru     true           3        2063
## 468                    Czech Republic    false           5        1598
## 469                          Colombia    false           0           0
## 470                         Argentina     true           3         671
## 471                          Portugal    false           0           0
## 472                            Poland     true           5         683
## 473                           Vietnam    false           0           0
## 474                           Nigeria    false           0           0
## 475                             China    false           0           0
## 476                            Poland    false           0           0
## 477                          Colombia    false           8         364
## 478                             China     true           9        2720
## 479                             Japan    false           0           0
## 480                             China    false           0           0
## 481                             China    false           0           0
## 482                    Czech Republic    false           0           0
## 483                            Canada    false           5        1622
## 484                          Portugal    false           8        1719
## 485                             Qatar    false           0           0
## 486                    Czech Republic    false           0           0
## 487                            France     true           9         697
## 488                             China    false           0           0
## 489                             China    false           0           0
## 490                            Russia    false           0           0
## 491  Democratic Republic of the Congo    false           9        1034
## 492                           Albania    false           0           0
## 493                           Ukraine    false           0           0
## 494                         Indonesia    false           0           0
## 495                             Japan     true           8        2367
## 496                          Thailand    false           0           0
## 497                            Greece    false           0           0
## 498                              Iran    false           0           0
## 499                             China    false           0           0
## 500                             Egypt    false           0           0
## 501                             China    false           0           0
## 502                          Portugal    false           0           0
## 503                         Indonesia    false           0           0
## 504                             China    false           0           0
## 505                          Thailand     true           1         510
## 506                      South Africa    false           0           0
## 507                            France    false           5        1201
## 508                             China    false           9        1760
## 509                            Uganda    false           0           0
## 510                          Mongolia    false           0           0
## 511                      South Africa    false           0           0
## 512                            Taiwan    false           0           0
## 513                       Philippines    false           5        1504
## 514                          Thailand    false           0           0
## 515                             China    false           0           0
## 516                             China    false           0           0
## 517                           Croatia    false           0           0
## 518                             Chile    false           0           0
## 519                            Brazil    false           0           0
## 520                            Sweden    false           3        2332
## 521                            Russia    false           4         153
## 522                            France    false           0           0
## 523                         Indonesia    false           0           0
## 524                             China    false           0           0
## 525                            Russia    false           0           0
## 526                         Indonesia    false           0           0
## 527                             China     true           9        2676
## 528                             Japan    false           0           0
## 529                          Portugal    false           0           0
## 530                            Canada    false           0           0
## 531                          Honduras    false           0           0
## 532                            Russia    false           0           0
## 533                             China    false           9        2462
## 534                      South Africa    false           0           0
## 535                           Ireland    false           0           0
## 536                             China    false           0           0
## 537                         Indonesia     true           2          54
## 538                            Brazil    false           5        2781
## 539                         Nicaragua    false           0           0
## 540                          Thailand    false           0           0
## 541                            France    false           0           0
## 542                            Greece    false           0           0
## 543                            Russia    false           0           0
## 544                            France    false           0           0
## 545                            Russia    false           4        1395
## 546                            Greece    false           1        1648
## 547                            Belize    false           0           0
## 548                             China    false           0           0
## 549                           Ukraine    false           0           0
## 550                          Portugal    false           0           0
## 551                             China    false           0           0
## 552                             China    false           0           0
## 553                           Vietnam    false           0           0
## 554                            Sweden    false           7         487
## 555                         Indonesia    false           0           0
## 556                            Poland     true           9         898
## 557                            Brazil    false           0           0
## 558                           Croatia    false           0           0
## 559                            France    false           0           0
## 560                       Philippines    false           0           0
## 561                             China     true           4         293
## 562                     United States    false           0           0
## 563                             China     true           2         866
## 564                       Philippines    false           0           0
## 565                             Yemen    false           0           0
## 566                            Russia    false           0           0
## 567                         Indonesia     true           6        1270
## 568                     United States    false           0           0
## 569                            Sweden     true           5        2770
## 570                       Afghanistan    false           0           0
## 571                          Ethiopia    false           0           0
## 572                         Argentina    false           3        1931
## 573                            Brazil    false           0           0
## 574                            Poland    false           0           0
## 575                             Yemen     true           4        2036
## 576                          Colombia    false           0           0
## 577                             China    false           0           0
## 578                    Czech Republic    false           0           0
## 579                         Venezuela    false           0           0
## 580                     United States    false           0           0
## 581                            Canada    false           0           0
## 582                            Sweden    false           0           0
## 583                              Iran     true           1        1861
## 584                        Uzbekistan    false           0           0
## 585                    United Kingdom    false           0           0
## 586                             China    false           0           0
## 587                         Indonesia    false           0           0
## 588                            Russia    false           0           0
## 589                    United Kingdom    false           0           0
## 590                           Armenia    false           0           0
## 591                            Serbia    false           0           0
## 592                          Portugal    false           0           0
## 593                              Peru    false           7        2943
## 594                            France    false           0           0
## 595                             China    false           0           0
## 596                       Netherlands    false           0           0
## 597                            Greece    false           0           0
## 598                         Indonesia    false           0           0
## 599                       Philippines    false           0           0
## 600                             China    false           0           0
## 601                             China    false           0           0
## 602                      South Africa     true           7         968
## 603                            Russia    false           0           0
## 604                         Indonesia    false           0           0
## 605                     United States     true           9        1345
## 606                            Sweden    false           0           0
## 607                    Czech Republic    false           0           0
## 608                            Russia    false           0           0
## 609                       Philippines    false           0           0
## 610                             Egypt    false           0           0
## 611                           Ukraine    false           0           0
## 612                       Philippines     true           3          17
## 613                             China    false           4        1747
## 614                            Russia    false           1         122
## 615                           Finland    false           0           0
## 616                            Russia    false           0           0
## 617                         Nicaragua    false           0           0
## 618                            Russia    false           0           0
## 619                            Sweden    false           0           0
## 620                           Morocco    false           0           0
## 621                            Brazil    false           0           0
## 622                             China    false           5        2000
## 623                            France    false           0           0
## 624                          Portugal    false           0           0
## 625                          Tanzania    false           9        2092
## 626                           Ukraine    false           0           0
## 627                          Thailand    false           0           0
## 628                            Russia    false           0           0
## 629                             Japan    false           0           0
## 630                             China     true          10          75
## 631                             China    false           0           0
## 632                         Indonesia    false           0           0
## 633                          Slovenia    false           0           0
## 634                             Italy    false           2         388
## 635                             China    false           0           0
## 636                         Indonesia     true           3        1782
## 637                          Tanzania    false           0           0
## 638                       Netherlands    false           0           0
## 639                          Portugal    false           0           0
## 640                          Colombia    false           4         463
## 641                           Mayotte    false           0           0
## 642                             Syria     true           8        1523
## 643                         Indonesia    false           0           0
## 644                         Indonesia    false           0           0
## 645                           Nigeria    false           0           0
## 646                          Ethiopia    false           0           0
## 647                            Guinea    false           0           0
## 648                         Indonesia    false           0           0
## 649                         Indonesia    false           9          27
## 650                    United Kingdom    false           0           0
## 651                             China    false           0           0
## 652                          Thailand    false           0           0
## 653                     United States    false           0           0
## 654                            Sweden    false           0           0
## 655                           Nigeria    false           0           0
## 656                       Philippines     true           7         683
## 657                            Canada    false           0           0
## 658                       Philippines    false           0           0
## 659                            Sweden    false           0           0
## 660                         Indonesia    false           0           0
## 661                             China    false           0           0
## 662                             China    false           4        1057
## 663                          Pakistan    false           0           0
## 664                             Japan    false           1        2702
## 665                            Brazil    false           0           0
## 666                         Indonesia    false           0           0
## 667                             China    false           0           0
## 668                            France    false           0           0
## 669                            Mexico    false           0           0
## 670                            Brazil    false           0           0
## 671                            Brazil    false           0           0
## 672                             China    false           0           0
## 673                       New Zealand    false           0           0
## 674                         Indonesia    false           0           0
## 675                            Russia    false          10        1922
## 676                             China    false           0           0
## 677                       Afghanistan    false           0           0
## 678                             China     true           3         935
## 679                          Thailand    false           0           0
## 680                         Argentina    false           0           0
## 681                             China    false           0           0
## 682                       Afghanistan     true           8        2006
## 683                           Ukraine    false           0           0
## 684                             China    false           0           0
## 685                        Uzbekistan    false           8        1733
## 686                            Mexico    false           0           0
## 687                          Paraguay    false          10         828
## 688                          Botswana    false           0           0
## 689                            France    false           3        1178
## 690                       New Zealand    false           9        2001
## 691                        Uzbekistan    false           0           0
## 692                         Indonesia    false           0           0
## 693                              Iran    false           0           0
## 694                            Sweden    false           0           0
## 695                         Indonesia    false           0           0
## 696                            Brazil    false           0           0
## 697                            Greece    false           0           0
## 698                            France     true           4        1669
## 699                           Germany    false           0           0
## 700                           Comoros    false           2        2302
## 701                            France    false           4        2780
## 702             Palestinian Territory    false           0           0
## 703                             China    false           0           0
## 704                             China    false           0           0
## 705                       Philippines    false           0           0
## 706                            Poland    false           0           0
## 707                            Russia    false           2        1645
## 708                       Philippines    false          10        1894
## 709                          Colombia    false           0           0
## 710                           Ukraine    false           0           0
## 711                          Honduras    false           0           0
## 712                             China    false           0           0
## 713                       Philippines     true           9          37
## 714                            Russia     true           2        1368
## 715                             China    false           0           0
## 716                             China    false           0           0
## 717                            Poland    false           0           0
## 718                         Indonesia    false           0           0
## 719                             China    false           0           0
## 720                             China    false           0           0
## 721                          Thailand    false           0           0
## 722                             Yemen    false           0           0
## 723                         Argentina    false           4          98
## 724                            Sweden    false           0           0
## 725                             Malta     true           5         154
## 726                          Thailand    false           0           0
## 727                              Cuba    false           0           0
## 728                             China    false           0           0
## 729                             China    false           0           0
## 730                             Libya    false           0           0
## 731                          Malaysia    false           1        2876
## 732                         Macedonia     true           9        2781
## 733                            Russia    false           0           0
## 734                              Peru    false           0           0
## 735                            Norway    false           0           0
## 736                            Israel    false           0           0
## 737                          Portugal    false           0           0
## 738                            Mexico    false           0           0
## 739                             China    false           0           0
## 740                         Indonesia    false           0           0
## 741                       Philippines    false           4        1268
## 742                             China    false           0           0
## 743                         Argentina    false           0           0
## 744                         Indonesia    false           0           0
## 745                            Mexico    false           0           0
## 746                          Portugal    false           1        1238
## 747                             Yemen    false           0           0
## 748                            Brazil    false           0           0
## 749                         Indonesia     true           9        1384
## 750                         Indonesia    false           0           0
## 751                            Poland    false           0           0
## 752                         Indonesia    false           0           0
## 753                     United States    false           0           0
## 754                            Greece    false           0           0
## 755                            Poland    false           7        2671
## 756                            France    false           5         462
## 757                             China    false           0           0
## 758                             China    false           0           0
## 759                            Greece    false           2         388
## 760                             China    false           0           0
## 761                            Sweden    false           0           0
## 762                             China    false           0           0
## 763                            Brazil    false           0           0
## 764                           Comoros    false           0           0
## 765                             China     true           7        1531
## 766                         Indonesia    false           0           0
## 767                            Poland    false           4        2419
## 768                     United States    false           0           0
## 769                             China    false           0           0
## 770                             China    false           3         576
## 771                       Philippines    false           0           0
## 772                            Norway    false           0           0
## 773                         Argentina    false           0           0
## 774                             Japan    false           0           0
## 775                           Morocco    false           8        2717
## 776                       Philippines    false           0           0
## 777                            Russia    false           0           0
## 778                          Colombia    false           0           0
## 779                             Haiti    false           0           0
## 780                          Tanzania    false           3        1320
## 781                           Hungary    false           0           0
## 782                         Argentina    false           0           0
## 783                          Portugal    false           0           0
## 784                         Indonesia    false           0           0
## 785                       Philippines     true           7         980
## 786                         Guatemala    false           0           0
## 787                      South Africa    false           0           0
## 788                    United Kingdom    false           6          29
## 789                             China    false           0           0
## 790                           Ukraine    false           0           0
## 791                         Indonesia     true           1        2845
## 792                          Malaysia    false           0           0
## 793                           Denmark    false           0           0
## 794                         Indonesia    false           0           0
## 795                             China    false           0           0
## 796                             China    false           0           0
## 797                           Myanmar    false           0           0
## 798                            Serbia    false           0           0
## 799                        Luxembourg    false           8        1503
## 800                          Honduras    false           0           0
## 801                              Peru    false           0           0
## 802                       Philippines    false          10          68
## 803                            Israel    false           0           0
## 804                            Russia    false           0           0
## 805                             China    false           0           0
## 806                            France    false           4        1516
## 807                           Nigeria    false           0           0
## 808                             Egypt    false           0           0
## 809                         Indonesia     true           3        2882
## 810                         Indonesia    false           0           0
## 811                          Malaysia    false           0           0
## 812                             Japan    false           0           0
## 813                            Poland     true           3        2560
## 814                             China    false           4          26
## 815                             China     true           2        1762
## 816                       Philippines    false           0           0
## 817                           Nigeria    false           0           0
## 818                          Colombia    false           0           0
## 819                            France    false           0           0
## 820                           Reunion    false           0           0
## 821                             China    false           0           0
## 822                             China    false           0           0
## 823                          Thailand    false           0           0
## 824                           Somalia    false           0           0
## 825                    United Kingdom    false           7        1523
## 826                           Tunisia    false           0           0
## 827                             China     true           5        2429
## 828                              Peru     true           8        1153
## 829                             China    false           0           0
## 830                            Mexico    false           0           0
## 831                          Malaysia    false           0           0
## 832                         Indonesia    false           0           0
## 833                            Uganda    false           0           0
## 834                            France    false           0           0
## 835                       Philippines    false           0           0
## 836                            France    false           0           0
## 837                          Portugal    false           0           0
## 838                            Malawi    false          10        1992
## 839                Dominican Republic    false           5        2991
## 840                         Indonesia    false          10        2235
## 841                             China    false           2         820
## 842                       South Korea     true           4        2717
## 843                             China    false           0           0
## 844                         Indonesia    false           0           0
## 845                             China    false           0           0
## 846                            Russia    false           0           0
## 847                            Russia    false           0           0
## 848                          Thailand    false           0           0
## 849                             China    false           0           0
## 850                            Greece    false           0           0
## 851                          Portugal    false           0           0
## 852                       Philippines    false           0           0
## 853                       Afghanistan    false          10        2122
## 854                            France    false           0           0
## 855                             China    false           0           0
## 856                            Russia    false           0           0
## 857                            France    false           0           0
## 858                         Indonesia    false           0           0
## 859                              Peru    false           0           0
## 860                       Philippines    false           1        1936
## 861                         Indonesia    false           0           0
## 862                       Philippines    false           0           0
## 863                             China    false           0           0
## 864                             China    false           0           0
## 865                       Philippines    false           0           0
## 866                             China    false           0           0
## 867                            Russia    false           0           0
## 868  Democratic Republic of the Congo     true           7        2436
## 869                             China    false           0           0
## 870                       Philippines    false           0           0
## 871                             China    false           0           0
## 872                         Macedonia    false           0           0
## 873                            Latvia    false          10        1564
## 874                            Russia    false           7         621
## 875                     United States    false           0           0
## 876                     United States    false           8        1801
## 877                         Indonesia    false           0           0
## 878                            Brazil    false           0           0
## 879                    United Kingdom    false           0           0
## 880                              Niue    false           0           0
## 881                          Portugal    false           0           0
## 882                         Indonesia     true           1        2802
## 883                            Brazil    false           0           0
## 884                            Brazil    false           0           0
## 885                             China    false           0           0
## 886                              Peru    false           0           0
## 887                             Japan    false           0           0
## 888                             China    false           0           0
## 889                         Argentina     true           9         399
## 890                            Russia    false           0           0
## 891                          Portugal    false           0           0
## 892                             China    false           0           0
## 893                          Thailand    false           0           0
## 894                         Indonesia    false           0           0
## 895                             China    false           0           0
## 896                            Brazil    false           0           0
## 897                          Colombia    false           2        2094
## 898                         Venezuela    false           0           0
## 899                         Indonesia    false           0           0
## 900                       Philippines     true           5        2043
## 901                        Madagascar    false           0           0
## 902                       New Zealand    false           0           0
## 903                              Iran    false           4        1725
## 904                             Chile    false           0           0
## 905                         Indonesia    false           7        2826
## 906                          Tanzania    false           0           0
## 907                        Azerbaijan    false           0           0
## 908                       Philippines    false           0           0
## 909                          Colombia     true           1         637
## 910                            Russia    false           0           0
## 911                             Japan    false           8        1722
## 912                             China    false           0           0
## 913                             China     true          10        1736
## 914                            Sweden    false           5        1607
## 915                          Portugal    false           0           0
## 916                       Philippines    false           6         735
## 917                         Indonesia    false           0           0
## 918                        Bangladesh    false           0           0
## 919                          Thailand    false           0           0
## 920                             China    false           0           0
## 921                          Thailand     true           5        2857
## 922                          Portugal    false           0           0
## 923                             China    false           0           0
## 924                             China     true           1        2171
## 925                    Czech Republic    false           0           0
## 926                             China    false           0           0
## 927                           Vietnam    false           0           0
## 928                          Portugal    false           0           0
## 929                             China    false           0           0
## 930                      Saudi Arabia    false           9         964
## 931                             China     true          10        1497
## 932                           Ukraine    false           0           0
## 933                          Portugal    false           8        1354
## 934                     United States     true           3        1749
## 935                          Slovenia    false           0           0
## 936             Palestinian Territory    false           0           0
## 937                         Indonesia    false           3        1421
## 938                            Brazil    false           0           0
## 939                              Mali    false           0           0
## 940                         Venezuela    false           0           0
## 941                    Czech Republic    false           7          27
## 942                              Cuba    false           0           0
## 943                             China    false           0           0
## 944                            Gambia    false           0           0
## 945                             China    false           0           0
## 946                             Kenya    false           5        1093
## 947                          Portugal    false           0           0
## 948                            Brazil    false           0           0
## 949                             China    false           0           0
## 950                            France    false           0           0
## 951                            Poland    false           3        1478
## 952                             China     true           4         389
## 953                       Philippines    false          10        2591
## 954                         Argentina    false           0           0
## 955                       Netherlands    false           0           0
## 956                             China    false           0           0
## 957                    Czech Republic    false           0           0
## 958                            Poland    false           0           0
## 959                         Indonesia    false           0           0
## 960                            Russia    false           0           0
## 961                             China     true           5        2648
## 962                            Poland    false           0           0
## 963                       Philippines    false           0           0
## 964                            Greece    false           0           0
## 965                              Peru    false           0           0
## 966                          Honduras    false           0           0
## 967                          Thailand    false          10        1397
## 968                             China     true           5         982
## 969                         Indonesia    false           0           0
## 970                    United Kingdom    false           0           0
## 971                             China    false           0           0
## 972                           Tunisia    false           0           0
## 973                              Peru    false           0           0
## 974                         Indonesia    false           0           0
## 975                       Philippines    false           0           0
## 976                          Portugal    false           0           0
## 977                             China    false           0           0
## 978                       Philippines    false           0           0
## 979                            Poland    false           8        1390
## 980                          Portugal    false           7        2006
## 981                            Sweden    false           0           0
## 982                         Indonesia    false           0           0
## 983                             China    false           0           0
## 984                            Sweden    false           0           0
## 985                             China    false           0           0
## 986                          Thailand    false           0           0
## 987                            Mexico    false           4         510
## 988                         Indonesia    false           0           0
## 989                              Peru    false           5        2397
## 990                            Brazil    false           0           0
## 991                            Latvia     true           4        2409
## 992                             China     true           8        1232
## 993                           Albania    false           0           0
## 994                         Indonesia    false           0           0
## 995                          Malaysia    false           0           0
## 996                          Portugal    false           0           0
## 997                          Thailand     true           5        2250
## 998                             China    false           0           0
## 999                          Portugal    false           0           0
## 1000                            China    false           0           0

Few Rows


##    id referrer device bouncers n_visit n_pages duration        country
## 1   1   google laptop     true      10       1      693 Czech Republic
## 2   2    yahoo tablet     true       9       1      459          Yemen
## 3   3   direct laptop     true       0       1      996         Brazil
## 4   4     bing tablet    false       3      18      468          China
## 5   5    yahoo mobile     true       9       1      955         Poland
## 6   6    yahoo laptop    false       5       5      135   South Africa
## 7   7    yahoo mobile     true      10       1       75     Bangladesh
## 8   8   direct mobile     true      10       1      908      Indonesia
## 9   9     bing mobile    false       3      19      209    Netherlands
## 10 10   google mobile     true       6       1      208 Czech Republic
##    purchase order_items order_value
## 1     false           0           0
## 2     false           0           0
## 3     false           0           0
## 4      true           6         434
## 5     false           0           0
## 6     false           0           0
## 7     false           0           0
## 8     false           0           0
## 9     false           0           0
## 10    false           0           0

Read Data in Batches


##    id referrer device bouncers n_visit n_pages duration        country
## 1   1   google laptop     true      10       1      693 Czech Republic
## 2   2    yahoo tablet     true       9       1      459          Yemen
## 3   3   direct laptop     true       0       1      996         Brazil
## 4   4     bing tablet    false       3      18      468          China
## 5   5    yahoo mobile     true       9       1      955         Poland
## 6   6    yahoo laptop    false       5       5      135   South Africa
## 7   7    yahoo mobile     true      10       1       75     Bangladesh
## 8   8   direct mobile     true      10       1      908      Indonesia
## 9   9     bing mobile    false       3      19      209    Netherlands
## 10 10   google mobile     true       6       1      208 Czech Republic
## 11 11   direct laptop     true       9       1      738        Jamaica
## 12 12   direct tablet    false       6      12      132        Estonia
## 13 13   direct mobile    false       9      14      406        Ireland
## 14 14    yahoo tablet    false       5       8       80    Philippines
## 15 15    yahoo mobile    false       7       1       19         France
## 16 16     bing laptop     true       1       1      995  United States
## 17 17     bing tablet    false       5      16      368           Peru
## 18 18   google tablet     true       7       1      406          China
## 19 19   social tablet    false       7      10      290       Colombia
## 20 20   social tablet    false       2       1       28        Namibia
## 21 21   direct laptop     true       2       1      384          China
## 22 22   google mobile     true       5       1      147         Brazil
## 23 23     bing mobile    false       0       7      196         Russia
## 24 24   social laptop     true       4       1      850        Ukraine
## 25 25    yahoo laptop     true       1       1      779         Brazil
## 26 26   social laptop     true       7       1      574      Australia
## 27 27   direct tablet    false       2      19      342          Japan
## 28 28   google laptop     true       9       1      126         Russia
## 29 29   google mobile     true      10       1      338         Russia
## 30 30    yahoo mobile    false       8       9      225       Colombia
##    purchase order_items order_value
## 1     false           0           0
## 2     false           0           0
## 3     false           0           0
## 4      true           6         434
## 5     false           0           0
## 6     false           0           0
## 7     false           0           0
## 8     false           0           0
## 9     false           0           0
## 10    false           0           0
## 11    false           0           0
## 12    false           0           0
## 13     true           3         651
## 14    false           2         362
## 15    false           7        2423
## 16    false           0           0
## 17     true           6        1049
## 18    false           0           0
## 19     true           9        1304
## 20    false           7        2077
## 21    false           0           0
## 22    false           0           0
## 23    false           4         237
## 24    false           0           0
## 25    false           0           0
## 26    false           0           0
## 27     true           5         622
## 28    false           0           0
## 29    false           0           0
## 30    false           0           0

Your Turn


  • list fields in the trade table
  • read all rows & columns from the trade table
  • read first 30 rows from the trade table

Query Status


## [1] FALSE

Query Info


## $statement
## [1] "select * from ecom"
## 
## $row.count
## [1] 30
## 
## $rows.affected
## [1] 0
## 
## $has.completed
## [1] FALSE

Latest Query


## [1] "select * from ecom"

Rows Fetched


## [1] 30

Rows Affected


## [1] 0

Column Info


##           name      type
## 1           id   integer
## 2     referrer character
## 3       device character
## 4     bouncers character
## 5      n_visit   integer
## 6      n_pages    double
## 7     duration    double
## 8      country character
## 9     purchase character
## 10 order_items    double
## 11 order_value    double

Clear Results


Check Table Name


## [1] FALSE

Create Table


List Tables


## [1] "COMPANY"    "DEPARTMENT" "ecom"       "trade"      "trial_db"

Query Data


##   x y
## 1 1 a
## 2 2 b
## 3 3 c
## 4 4 d
## 5 5 e

Overwrite Table


View Data


##     x y
## 1  29 k
## 2  89 l
## 3  66 m
## 4  76 n
## 5   3 o
## 6  13 p
## 7  84 q
## 8  23 r
## 9  75 s
## 10 58 t

Append Data


View Data


##     x y
## 1  29 k
## 2  89 l
## 3  66 m
## 4  76 n
## 5   3 o
## 6  13 p
## 7  84 q
## 8  23 r
## 9  75 s
## 10 58 t
## 11 21 e
## 12 66 f
## 13 96 g
## 14 54 h
## 15 59 i
## 16 92 j
## 17 37 k
## 18 83 l
## 19 94 m
## 20 89 n

Insert Rows


## [1] 3

View Data


##     x y
## 1  29 k
## 2  89 l
## 3  66 m
## 4  76 n
## 5   3 o
## 6  13 p
## 7  84 q
## 8  23 r
## 9  75 s
## 10 58 t
## 11 21 e
## 12 66 f
## 13 96 g
## 14 54 h
## 15 59 i
## 16 92 j
## 17 37 k
## 18 83 l
## 19 94 m
## 20 89 n
## 21 32 c
## 22 45 k
## 23 61 h

Insert Rows


## <SQLiteResult>
##   SQL  INSERT into trial_db (x, y) VALUES (25, 'm'), (54, 'l'), (16, 'y')
##   ROWS Fetched: 0 [complete]
##        Changed: 3

View Data


## Warning: Closing open result set, pending rows
##     x y
## 1  29 k
## 2  89 l
## 3  66 m
## 4  76 n
## 5   3 o
## 6  13 p
## 7  84 q
## 8  23 r
## 9  75 s
## 10 58 t
## 11 21 e
## 12 66 f
## 13 96 g
## 14 54 h
## 15 59 i
## 16 92 j
## 17 37 k
## 18 83 l
## 19 94 m
## 20 89 n
## 21 32 c
## 22 45 k
## 23 61 h
## 24 25 m
## 25 54 l
## 26 16 y

Generate SQL Query


## Warning: Do not rely on the default value of the row.names argument for
## sqlCreateTable(), it will change in the future.
## <SQL> CREATE TABLE `new` (
##   `x` integer,
##   `y` text
## )

Generate SQL Query


## Warning: Do not rely on the default value of the row.names argument for
## sqlAppendTable(), it will change in the future.
## <SQL> INSERT INTO `tria_db`
##   (`x`, `y`)
## VALUES
##   (30, 'k')

Remove Table


Your Turn


  • check if mytable exists in the database
  • create new table mytable using the first 3 rows of mtcars data set
  • list all tables to check if the new table has been created
  • overwrite mytable with the first 10 rows of mtcars data set
  • append the 20th row of mtcars data set to mytable
  • create a new table using the last 5 rows of mtcars and append it to mytable
  • remove mytable

Data Type


## [1] "TEXT"
## [1] "INTEGER"
## [1] "REAL"

Running SQL Scripts





knitr SQL Engine


Your Turn


  • check the data type of "NULL"
  • use SQL script to select duration, n_visit from trade table where device has the value tablet
  • create a html report for the above sql query using the knitr SQL engine

Reference Data


## # Source:   table<ecom> [?? x 11]
## # Database: sqlite 3.22.0 [J:\R\courses\tutorial_slides\sql\mydatabase.db]
##       id referrer device bouncers n_visit n_pages duration country purchase
##    <int> <chr>    <chr>  <chr>      <int>   <dbl>    <dbl> <chr>   <chr>   
##  1     1 google   laptop true          10       1      693 Czech ~ false   
##  2     2 yahoo    tablet true           9       1      459 Yemen   false   
##  3     3 direct   laptop true           0       1      996 Brazil  false   
##  4     4 bing     tablet false          3      18      468 China   true    
##  5     5 yahoo    mobile true           9       1      955 Poland  false   
##  6     6 yahoo    laptop false          5       5      135 South ~ false   
##  7     7 yahoo    mobile true          10       1       75 Bangla~ false   
##  8     8 direct   mobile true          10       1      908 Indone~ false   
##  9     9 bing     mobile false          3      19      209 Nether~ false   
## 10    10 google   mobile true           6       1      208 Czech ~ false   
## # ... with more rows, and 2 more variables: order_items <dbl>,
## #   order_value <dbl>

Query Data


## Warning: Missing values are always removed in SQL.
## Use `AVG(x, na.rm = TRUE)` to silence this warning
## # Source:     lazy query [?? x 2]
## # Database:   sqlite 3.22.0
## #   [J:\R\courses\tutorial_slides\sql\mydatabase.db]
## # Ordered by: avg_tos
##   referrer avg_tos
##   <chr>      <dbl>
## 1 direct      326.
## 2 yahoo       331.
## 3 social      362.
## 4 bing        434.
## 5 google      439.

Collect Data


## # Source:   lazy query [?? x 2]
## # Database: sqlite 3.22.0 [J:\R\courses\tutorial_slides\sql\mydatabase.db]
##    referrer device
##    <chr>    <chr> 
##  1 google   laptop
##  2 yahoo    tablet
##  3 direct   laptop
##  4 bing     tablet
##  5 yahoo    mobile
##  6 yahoo    laptop
##  7 yahoo    mobile
##  8 direct   mobile
##  9 bing     mobile
## 10 google   mobile
## # ... with more rows

Collect Data


## [1] NA

Collect Data


## # A tibble: 1,000 x 2
##    referrer device
##    <chr>    <chr> 
##  1 google   laptop
##  2 yahoo    tablet
##  3 direct   laptop
##  4 bing     tablet
##  5 yahoo    mobile
##  6 yahoo    laptop
##  7 yahoo    mobile
##  8 direct   mobile
##  9 bing     mobile
## 10 google   mobile
## # ... with 990 more rows

Collect Data


## [1] 1000

Display Query


## Warning: Missing values are always removed in SQL.
## Use `AVG(x, na.rm = TRUE)` to silence this warning
## <SQL>
## SELECT `referrer`, AVG(`duration`) AS `avg_tos`
## FROM (SELECT `referrer`, `device`, `duration`
## FROM `ecom`)
## WHERE (`device` = 'laptop')
## GROUP BY `referrer`
## ORDER BY `avg_tos`

SQL Generation


## Warning: Missing values are always removed in SQL.
## Use `AVG(x, na.rm = TRUE)` to silence this warning
## <SQL> SELECT `referrer`, AVG(`duration`) AS `avg_tos`
## FROM `ecom`
## GROUP BY `referrer`

Your Turn


  • use tbl() to reference trade table as trade2
  • use dplyr verbs to compute average duration for device from the trade table
  • store the above query in a variable tos_device
  • use show_query() to display the underlying SQL query of tos_device
  • use collect() to retrieve data from tos_device
  • use explain() to display the underlying computation logic of tos_device

dbplot


  • box plot
  • bar plot
  • histogram
  • line chart
  • raster plot

Bar Plot


Line Chart


Your Turn


  • create bar plot of referrer column from the trade table
  • create line chart of n_visit column from the trade table

Modeling


Simple Regression


## # A tibble: 1 x 2
##   `(Intercept)` n_visit
##           <dbl>   <dbl>
## 1          364.   -1.72

Multiple Regression


## # A tibble: 1 x 3
##   `(Intercept)` n_visit n_pages
##           <dbl>   <dbl>   <dbl>
## 1          415.   -2.02   -8.37

Categorical Variables


## # A tibble: 1 x 3
##   `(Intercept)` device_mobile device_tablet
##           <dbl>         <dbl>         <dbl>
## 1          376.         -39.2         -22.1

Full Example


## # A tibble: 1 x 5
##   `(Intercept)` n_visit n_pages device_mobile device_tablet
##           <dbl>   <dbl>   <dbl>         <dbl>         <dbl>
## 1          427.   -1.52   -8.27         -31.1         -14.4

Your Turn


  • regress duration on n_pages
  • regress duration on referrer
  • and finally regress duration on n_pages, n_visit and referrer

Predict Inside Database


## 
## Call:
## lm(formula = duration ~ device + referrer + n_visit + n_pages, 
##     data = ecom2)
## 
## Coefficients:
##    (Intercept)    devicemobile    devicetablet  referrerdirect  
##        441.450         -30.952         -14.497          -8.980  
## referrergoogle  referrersocial   referreryahoo         n_visit  
##        -10.038         -19.841         -32.097          -1.433  
##        n_pages  
##         -8.298

Fit


## 441.450192491919 + (ifelse(device == "mobile", 1, 0) * -30.9522074131866) + 
##     (ifelse(device == "tablet", 1, 0) * -14.4972018107797) + 
##     (ifelse(referrer == "direct", 1, 0) * -8.98035001912995) + 
##     (ifelse(referrer == "google", 1, 0) * -10.038005625893) + 
##     (ifelse(referrer == "social", 1, 0) * -19.8411767075006) + 
##     (ifelse(referrer == "yahoo", 1, 0) * -32.0969778768984) + 
##     (n_visit * -1.4325653130794) + (n_pages * -8.29825840984566)

Fit


## # Source:   lazy query [?? x 2]
## # Database: sqlite 3.22.0 [J:\R\courses\tutorial_slides\sql\mydatabase.db]
##    duration   fit
##       <dbl> <dbl>
##  1      693  409.
##  2      459  374.
##  3      996  424.
##  4      468  273.
##  5      955  357.
##  6      135  361.
##  7       75  356.
##  8      908  379.
##  9      209  249.
## 10      208  384.
## # ... with more rows

SQL


## <SQL> 441.450192491919 + (CASE WHEN (`device` = 'mobile') THEN (1.0) WHEN NOT(`device` = 'mobile') THEN (0.0) END * -30.9522074131866) + (CASE WHEN (`device` = 'tablet') THEN (1.0) WHEN NOT(`device` = 'tablet') THEN (0.0) END * -14.4972018107797) + (CASE WHEN (`referrer` = 'direct') THEN (1.0) WHEN NOT(`referrer` = 'direct') THEN (0.0) END * -8.98035001912995) + (CASE WHEN (`referrer` = 'google') THEN (1.0) WHEN NOT(`referrer` = 'google') THEN (0.0) END * -10.038005625893) + (CASE WHEN (`referrer` = 'social') THEN (1.0) WHEN NOT(`referrer` = 'social') THEN (0.0) END * -19.8411767075006) + (CASE WHEN (`referrer` = 'yahoo') THEN (1.0) WHEN NOT(`referrer` = 'yahoo') THEN (0.0) END * -32.0969778768984) + (`n_visit` * -1.4325653130794) + (`n_pages` * -8.29825840984566)

Close Connection


Handling Credentials


Summary


  • DBI to connect and interact with databases
  • dplyr and dbplyr for data transformation
  • dbplot for data visualization
  • modeldb and tidypredict for data modeling
  • config, keyring, .Renviron and options() to handle credentials
  • always close the database connection

References